001/*
002 $Id: IPG.java 3207 2009-04-09 06:48:11Z gregory $
003
004 Copyright (C) 2007 Gregory Vincic, Olle Mansson
005
006 This file is part of Proteios.
007 Available at http://www.proteios.org/
008
009 Proteios is free software; you can redistribute it and/or modify it
010 under the terms of the GNU General Public License as published by
011 the Free Software Foundation; either version 2 of the License, or
012 (at your option) any later version.
013
014 Proteios is distributed in the hope that it will be useful, but
015 WITHOUT ANY WARRANTY; without even the implied warranty of
016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017 General Public License for more details.
018
019 You should have received a copy of the GNU General Public License
020 along with this program; if not, write to the Free Software
021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
022 02111-1307, USA.
023 */
024package org.proteios.core;
025
026import org.proteios.core.data.IPGData;
027import java.util.Set;
028
029/**
030 * This class represent IPG (Immobilized pH Gradient) items. An IPG has
031 * information about the separation method used in an experiment.
032 * 
033 * @author Olle
034 * @version 2.0
035 * @proteios.modified $Date: 2006-09-19 12:33:12Z $
036 */
037public class IPG
038                extends SeparationMethod<IPGData>
039{
040        /**
041         * The type of item represented by this class.
042         * 
043         * @see Item#PROTEIOS_IPG
044         * @see #getType()
045         */
046        public static final Item TYPE = Item.PROTEIOS_IPG;
047
048
049        /**
050         * Get a query that returns IPG items.
051         * 
052         * @return An {@link ItemQuery} object.
053         */
054        public static ItemQuery<IPG> getQuery()
055        {
056                return new ItemQuery<IPG>(IPG.class);
057        }
058
059
060        IPG(IPGData ipgData)
061        {
062                super(ipgData);
063        }
064
065
066        /**
067         * Get an <code>IPG</code> item when you know the external ID.
068         * The method with the same name inherited from the super class
069         * is used to retrieve the item, which is then casted to
070         * the right type.
071         * 
072         * @param dc The <code>DbControl</code> which will be used for permission
073         *        checking and database access.
074         * @param externalId The external id of the item to load
075         * @return The <code>IPG</code> item
076         * @throws ItemNotFoundException If an item with the specified ID is not
077         *         found
078         * @throws PermissionDeniedException If the logged in user doesn't have
079         *         {@link Permission#READ READ} permission for the item
080         * @throws BaseException If there is another error
081         */
082        public static IPG getByExternalId(DbControl dc,
083                        String externalId)
084                        throws ItemNotFoundException, PermissionDeniedException,
085                        BaseException
086        {
087                IPG ipg = null;
088                SeparationMethod sm = SeparationMethod.getByExternalId(dc, externalId);
089                if (sm instanceof IPG)
090                {
091                        ipg = (IPG) sm;
092                }
093                return ipg;
094        }
095
096
097        /*
098         * From the Identifiable interface
099         * -------------------------------------------
100         */
101        @Override
102        public Item getType()
103        {
104                return TYPE;
105        }
106
107
108        // -------------------------------------------
109        /**
110         * Always null.
111         */
112        public Set<Annotatable> getAnnotatableParents()
113                        throws BaseException
114        {
115                return null;
116        }
117
118
119        // -------------------------------------------
120        /*
121         * From the BasicItem class -------------------------------------------
122         */
123        /**
124         * Check that:
125         * <ul>
126         * <li>no item has been created from this IPG
127         * </ul>
128         */
129        @Override
130        public boolean isUsed()
131                        throws BaseException
132        {
133                return false;
134        }
135
136
137        /**
138         * Get the int length value.
139         * 
140         * @return the int length value
141         */
142        public int getLengthInCentiMeters()
143        {
144                return getData().getLengthInCentiMeters();
145        }
146
147
148        /**
149         * Set the int length value.
150         * 
151         * @param length The int length value to set.
152         */
153        public void setLengthInCentiMeters(int length)
154        {
155                getData().setLengthInCentiMeters(IntegerUtil.checkMin(length, "length", 0));
156        }
157
158
159        /**
160         * Get the int piEnd value.
161         * 
162         * @return the int piEnd value
163         */
164        public int getPiEnd()
165        {
166                return getData().getPiEnd();
167        }
168
169
170        /**
171         * Set the int piEnd value.
172         * 
173         * @param piEnd The int piEnd value to set.
174         */
175        public void setPiEnd(int piEnd)
176        {
177                getData().setPiEnd(IntegerUtil.checkMin(piEnd, "piEnd", 0));
178        }
179
180
181        /**
182         * Get the int piStart value.
183         * 
184         * @return the int piStart value
185         */
186        public int getPiStart()
187        {
188                return getData().getPiStart();
189        }
190
191
192        /**
193         * Set the int piStart value.
194         * 
195         * @param piStart The int piStart value to set.
196         */
197        public void setPiStart(int piStart)
198        {
199                getData().setPiStart(IntegerUtil.checkMin(piStart, "piStart", 0));
200        }
201}