5675 |
28 Jun 11 |
nicklas |
1 |
/* |
5675 |
28 Jun 11 |
nicklas |
$Id $ |
5675 |
28 Jun 11 |
nicklas |
3 |
|
5675 |
28 Jun 11 |
nicklas |
Copyright (C) 2011 Your name |
5675 |
28 Jun 11 |
nicklas |
5 |
|
5675 |
28 Jun 11 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
5675 |
28 Jun 11 |
nicklas |
Available at http://base.thep.lu.se/ |
5675 |
28 Jun 11 |
nicklas |
8 |
|
5675 |
28 Jun 11 |
nicklas |
BASE is free software; you can redistribute it and/or |
5675 |
28 Jun 11 |
nicklas |
modify it under the terms of the GNU General Public License |
5675 |
28 Jun 11 |
nicklas |
as published by the Free Software Foundation; either version 3 |
5675 |
28 Jun 11 |
nicklas |
of the License, or (at your option) any later version. |
5675 |
28 Jun 11 |
nicklas |
13 |
|
5675 |
28 Jun 11 |
nicklas |
BASE is distributed in the hope that it will be useful, |
5675 |
28 Jun 11 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5675 |
28 Jun 11 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5675 |
28 Jun 11 |
nicklas |
GNU General Public License for more details. |
5675 |
28 Jun 11 |
nicklas |
18 |
|
5675 |
28 Jun 11 |
nicklas |
You should have received a copy of the GNU General Public License |
5675 |
28 Jun 11 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
5675 |
28 Jun 11 |
nicklas |
21 |
*/ |
5675 |
28 Jun 11 |
nicklas |
package net.sf.basedb.core; |
5675 |
28 Jun 11 |
nicklas |
import net.sf.basedb.core.data.AnyData; |
5675 |
28 Jun 11 |
nicklas |
24 |
/** |
5675 |
28 Jun 11 |
nicklas |
This class is used to represent an AnyItem in BASE. |
5675 |
28 Jun 11 |
nicklas |
26 |
|
5675 |
28 Jun 11 |
nicklas |
@author Your name |
5675 |
28 Jun 11 |
nicklas |
@since 3.0 |
5675 |
28 Jun 11 |
nicklas |
@see AnyData |
5675 |
28 Jun 11 |
nicklas |
@base.modified $Date$ |
5675 |
28 Jun 11 |
nicklas |
31 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public class AnyItem |
5675 |
28 Jun 11 |
nicklas |
extends CommonItem<AnyData> |
5675 |
28 Jun 11 |
nicklas |
implements Subtypable |
5675 |
28 Jun 11 |
nicklas |
35 |
{ |
5675 |
28 Jun 11 |
nicklas |
36 |
|
5675 |
28 Jun 11 |
nicklas |
37 |
/** |
5675 |
28 Jun 11 |
nicklas |
Create a new <code>AnyItem</code> item. |
5675 |
28 Jun 11 |
nicklas |
39 |
|
5675 |
28 Jun 11 |
nicklas |
@param dc The <code>DbControl</code> which will be used for |
5675 |
28 Jun 11 |
nicklas |
permission checking and database access |
5675 |
28 Jun 11 |
nicklas |
@return The new <code>AnyItem</code> item |
5675 |
28 Jun 11 |
nicklas |
@throws BaseException If there is an error |
5675 |
28 Jun 11 |
nicklas |
44 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public static AnyItem getNew(DbControl dc) |
5675 |
28 Jun 11 |
nicklas |
throws BaseException |
5675 |
28 Jun 11 |
nicklas |
47 |
{ |
5675 |
28 Jun 11 |
nicklas |
AnyItem a = dc.newItem(AnyItem.class); |
5675 |
28 Jun 11 |
nicklas |
a.setName("New any item"); |
5675 |
28 Jun 11 |
nicklas |
return a; |
5675 |
28 Jun 11 |
nicklas |
51 |
} |
5675 |
28 Jun 11 |
nicklas |
52 |
|
5675 |
28 Jun 11 |
nicklas |
53 |
/** |
5675 |
28 Jun 11 |
nicklas |
Get an <code>AnyItem</code> item when you know the id. |
5675 |
28 Jun 11 |
nicklas |
55 |
|
5675 |
28 Jun 11 |
nicklas |
@param dc The <code>DbControl</code> which will be used for |
5675 |
28 Jun 11 |
nicklas |
permission checking and database access. |
5675 |
28 Jun 11 |
nicklas |
@param id The id of the item to load |
5675 |
28 Jun 11 |
nicklas |
@return The <code>AnyItem</code> item |
5675 |
28 Jun 11 |
nicklas |
@throws ItemNotFoundException If an item with the specified |
5675 |
28 Jun 11 |
nicklas |
id is not found |
5675 |
28 Jun 11 |
nicklas |
@throws PermissionDeniedException If the logged in user doesn't |
5675 |
28 Jun 11 |
nicklas |
have read permission to the item |
5675 |
28 Jun 11 |
nicklas |
@throws BaseException If there is another error |
5675 |
28 Jun 11 |
nicklas |
65 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public static AnyItem getById(DbControl dc, int id) |
5675 |
28 Jun 11 |
nicklas |
throws ItemNotFoundException, PermissionDeniedException, BaseException |
5675 |
28 Jun 11 |
nicklas |
68 |
{ |
5675 |
28 Jun 11 |
nicklas |
AnyItem a = dc.loadItem(AnyItem.class, id); |
5675 |
28 Jun 11 |
nicklas |
if (a == null) throw new ItemNotFoundException("AnyItem[id="+id+"]"); |
5675 |
28 Jun 11 |
nicklas |
return a; |
5675 |
28 Jun 11 |
nicklas |
72 |
} |
5675 |
28 Jun 11 |
nicklas |
73 |
|
5675 |
28 Jun 11 |
nicklas |
74 |
/** |
5675 |
28 Jun 11 |
nicklas |
Get a query configured to retrieve anyitems. |
5675 |
28 Jun 11 |
nicklas |
@return An {@link ItemQuery} object |
5675 |
28 Jun 11 |
nicklas |
77 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public static ItemQuery<AnyItem> getQuery() |
5675 |
28 Jun 11 |
nicklas |
79 |
{ |
5675 |
28 Jun 11 |
nicklas |
return new ItemQuery<AnyItem>(AnyItem.class); |
5675 |
28 Jun 11 |
nicklas |
81 |
} |
5675 |
28 Jun 11 |
nicklas |
82 |
|
5675 |
28 Jun 11 |
nicklas |
// Constructor |
5675 |
28 Jun 11 |
nicklas |
AnyItem(AnyData anyData) |
5675 |
28 Jun 11 |
nicklas |
85 |
{ |
5675 |
28 Jun 11 |
nicklas |
super(anyData); |
5675 |
28 Jun 11 |
nicklas |
87 |
} |
5675 |
28 Jun 11 |
nicklas |
88 |
|
5675 |
28 Jun 11 |
nicklas |
89 |
/* |
5675 |
28 Jun 11 |
nicklas |
From the BasicItem class |
5675 |
28 Jun 11 |
nicklas |
91 |
------------------------------------------- |
5675 |
28 Jun 11 |
nicklas |
92 |
*/ |
5675 |
28 Jun 11 |
nicklas |
93 |
/** |
5675 |
28 Jun 11 |
nicklas |
TODO - Check if: |
5675 |
28 Jun 11 |
nicklas |
<ul> |
5675 |
28 Jun 11 |
nicklas |
<li>other items are using this AnyItem |
5675 |
28 Jun 11 |
nicklas |
</ul> |
5675 |
28 Jun 11 |
nicklas |
(or remove this method) |
5675 |
28 Jun 11 |
nicklas |
99 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public boolean isUsed() |
5675 |
28 Jun 11 |
nicklas |
throws BaseException |
5675 |
28 Jun 11 |
nicklas |
102 |
{ |
5675 |
28 Jun 11 |
nicklas |
org.hibernate.Session session = getDbControl().getHibernateSession(); |
5675 |
28 Jun 11 |
nicklas |
org.hibernate.Query query = |
5675 |
28 Jun 11 |
nicklas |
HibernateUtil.getPredefinedQuery(session, "GET_OTHER_ITEM_FOR_ANYITEM", "count(*)"); |
5675 |
28 Jun 11 |
nicklas |
106 |
/* |
5675 |
28 Jun 11 |
nicklas |
SELECT {1} |
5675 |
28 Jun 11 |
nicklas |
FROM OtherItemData o |
5675 |
28 Jun 11 |
nicklas |
WHERE o.anyItem = :anyItem |
5675 |
28 Jun 11 |
nicklas |
110 |
*/ |
5675 |
28 Jun 11 |
nicklas |
query.setEntity("anyItem", this.getData()); |
5675 |
28 Jun 11 |
nicklas |
boolean used = HibernateUtil.loadData(Long.class, query) > 0; |
5675 |
28 Jun 11 |
nicklas |
return used || super.isUsed(); |
5675 |
28 Jun 11 |
nicklas |
114 |
} |
5675 |
28 Jun 11 |
nicklas |
115 |
|
5675 |
28 Jun 11 |
nicklas |
116 |
/** |
5675 |
28 Jun 11 |
nicklas |
TODO - Get all: |
5675 |
28 Jun 11 |
nicklas |
<ul> |
5675 |
28 Jun 11 |
nicklas |
<li>other items using this AnyItem |
5675 |
28 Jun 11 |
nicklas |
<ul> |
5675 |
28 Jun 11 |
nicklas |
(or remove this method) |
5675 |
28 Jun 11 |
nicklas |
122 |
*/ |
5675 |
28 Jun 11 |
nicklas |
@Override |
5675 |
28 Jun 11 |
nicklas |
public Set<ItemProxy> getUsingItems() |
5675 |
28 Jun 11 |
nicklas |
125 |
{ |
5675 |
28 Jun 11 |
nicklas |
Set<ItemProxy> using = super.getUsingItems(); |
5675 |
28 Jun 11 |
nicklas |
org.hibernate.Session session = getDbControl().getHibernateSession(); |
5675 |
28 Jun 11 |
nicklas |
128 |
|
5675 |
28 Jun 11 |
nicklas |
// Other items |
5675 |
28 Jun 11 |
nicklas |
org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, |
5675 |
28 Jun 11 |
nicklas |
"GET_OTHER_ITEM_FOR_ANYITEM", "o.id"); |
5675 |
28 Jun 11 |
nicklas |
132 |
/* |
5675 |
28 Jun 11 |
nicklas |
SELECT {1} |
5675 |
28 Jun 11 |
nicklas |
FROM OtherItemData o |
5675 |
28 Jun 11 |
nicklas |
WHERE o.anyItem = :anyItem |
5675 |
28 Jun 11 |
nicklas |
136 |
*/ |
5675 |
28 Jun 11 |
nicklas |
query.setEntity("anyItem", this.getData()); |
5675 |
28 Jun 11 |
nicklas |
addUsingItems(using, Item.OTHER, query); |
5675 |
28 Jun 11 |
nicklas |
return using; |
5675 |
28 Jun 11 |
nicklas |
140 |
} |
5675 |
28 Jun 11 |
nicklas |
141 |
|
5675 |
28 Jun 11 |
nicklas |
142 |
/** |
5675 |
28 Jun 11 |
nicklas |
TODO - grant or deny extra permissions or remove this method |
5675 |
28 Jun 11 |
nicklas |
144 |
*/ |
5675 |
28 Jun 11 |
nicklas |
void initPermissions(int granted, int denied) |
5675 |
28 Jun 11 |
nicklas |
throws BaseException |
5675 |
28 Jun 11 |
nicklas |
147 |
{ |
5675 |
28 Jun 11 |
nicklas |
// Place your extra permissions here |
5675 |
28 Jun 11 |
nicklas |
super.initPermissions(granted, denied); |
5675 |
28 Jun 11 |
nicklas |
150 |
} |
5675 |
28 Jun 11 |
nicklas |
151 |
/** |
5675 |
28 Jun 11 |
nicklas |
TODO - set default items |
5675 |
28 Jun 11 |
nicklas |
(or remove this method |
5675 |
28 Jun 11 |
nicklas |
154 |
*/ |
5675 |
28 Jun 11 |
nicklas |
void setProjectDefaults(Project activeProject) |
5675 |
28 Jun 11 |
nicklas |
throws BaseException |
5675 |
28 Jun 11 |
nicklas |
157 |
{ |
5675 |
28 Jun 11 |
nicklas |
// The protocol used to create the item |
5675 |
28 Jun 11 |
nicklas |
if (!protocolHasBeenSet) |
5675 |
28 Jun 11 |
nicklas |
160 |
{ |
5675 |
28 Jun 11 |
nicklas |
ProtocolData protocol = |
5675 |
28 Jun 11 |
nicklas |
(ProtocolData)activeProject.findDefaultRelatedData(dc, this, Item.PROTOCOL, false); |
5675 |
28 Jun 11 |
nicklas |
if (protocol != null) |
5675 |
28 Jun 11 |
nicklas |
164 |
{ |
5675 |
28 Jun 11 |
nicklas |
getData().setProtocol(protocol); |
5675 |
28 Jun 11 |
nicklas |
protocolHasBeenSet = true; |
5675 |
28 Jun 11 |
nicklas |
167 |
} |
5675 |
28 Jun 11 |
nicklas |
168 |
} |
5675 |
28 Jun 11 |
nicklas |
169 |
} |
5675 |
28 Jun 11 |
nicklas |
170 |
// ------------------------------------------- |
5675 |
28 Jun 11 |
nicklas |
171 |
/* |
5675 |
28 Jun 11 |
nicklas |
From the Subtypable interface |
5675 |
28 Jun 11 |
nicklas |
173 |
----------------------------- |
5675 |
28 Jun 11 |
nicklas |
174 |
*/ |
5675 |
28 Jun 11 |
nicklas |
@Override |
5675 |
28 Jun 11 |
nicklas |
@SubtypableRelatedItems({Item.PROTOCOL}) |
5675 |
28 Jun 11 |
nicklas |
public ItemSubtype getItemSubtype() |
5675 |
28 Jun 11 |
nicklas |
178 |
{ |
5675 |
28 Jun 11 |
nicklas |
return getDbControl().getItem(ItemSubtype.class, getData().getItemSubtype()); |
5675 |
28 Jun 11 |
nicklas |
180 |
} |
5675 |
28 Jun 11 |
nicklas |
@Override |
5675 |
28 Jun 11 |
nicklas |
public void setItemSubtype(ItemSubtype subtype) |
5675 |
28 Jun 11 |
nicklas |
183 |
{ |
5675 |
28 Jun 11 |
nicklas |
checkPermission(Permission.WRITE); |
5675 |
28 Jun 11 |
nicklas |
if (subtype != null) |
5675 |
28 Jun 11 |
nicklas |
186 |
{ |
5675 |
28 Jun 11 |
nicklas |
subtype.setOnItem(this); |
5675 |
28 Jun 11 |
nicklas |
188 |
} |
5675 |
28 Jun 11 |
nicklas |
else |
5675 |
28 Jun 11 |
nicklas |
190 |
{ |
5675 |
28 Jun 11 |
nicklas |
getData().setItemSubtype(null); |
5675 |
28 Jun 11 |
nicklas |
192 |
} |
5675 |
28 Jun 11 |
nicklas |
193 |
} |
5675 |
28 Jun 11 |
nicklas |
194 |
// ------------------------------------------- |
5675 |
28 Jun 11 |
nicklas |
195 |
|
5675 |
28 Jun 11 |
nicklas |
// TODO - Methods below this line are examples only, modify or remove as needed |
5675 |
28 Jun 11 |
nicklas |
197 |
/** |
5675 |
28 Jun 11 |
nicklas |
Get the value of the string property. |
5675 |
28 Jun 11 |
nicklas |
199 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public String getStringProperty() |
5675 |
28 Jun 11 |
nicklas |
201 |
{ |
5675 |
28 Jun 11 |
nicklas |
return getData().getStringProperty(); |
5675 |
28 Jun 11 |
nicklas |
203 |
} |
5675 |
28 Jun 11 |
nicklas |
public static final int MAX_STRINGPROPERTY_LENGTH = AnyData.MAX_STRINGPROPERTY_LENGTH; |
5675 |
28 Jun 11 |
nicklas |
205 |
/** |
5675 |
28 Jun 11 |
nicklas |
Set the value of the string property. Null values are not |
5675 |
28 Jun 11 |
nicklas |
allowed and the length must be shorter than |
5675 |
28 Jun 11 |
nicklas |
{@link #MAX_STRINGPROPERTY_LENGTH}. |
5675 |
28 Jun 11 |
nicklas |
@param value The new value |
5675 |
28 Jun 11 |
nicklas |
@throws PermissionDeniedException If the logged in user |
5675 |
28 Jun 11 |
nicklas |
doesn't have write permission |
5675 |
28 Jun 11 |
nicklas |
@throws InvalidDataException If the value is null or too long |
5675 |
28 Jun 11 |
nicklas |
213 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public void setStringProperty(String value) |
5675 |
28 Jun 11 |
nicklas |
throws PermissionDeniedException, InvalidDataException |
5675 |
28 Jun 11 |
nicklas |
216 |
{ |
5675 |
28 Jun 11 |
nicklas |
checkPermission(Permission.WRITE); |
5675 |
28 Jun 11 |
nicklas |
getData.setStringProperty( |
5675 |
28 Jun 11 |
nicklas |
StringUtil.setNotNullString(value, "stringProperty", MAX_STRINGPROPERTY_LENGTH) |
5675 |
28 Jun 11 |
nicklas |
220 |
); |
5675 |
28 Jun 11 |
nicklas |
221 |
} |
5675 |
28 Jun 11 |
nicklas |
222 |
|
5675 |
28 Jun 11 |
nicklas |
223 |
/** |
5675 |
28 Jun 11 |
nicklas |
Get the value of the int property. |
5675 |
28 Jun 11 |
nicklas |
225 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public int getIntProperty() |
5675 |
28 Jun 11 |
nicklas |
227 |
{ |
5675 |
28 Jun 11 |
nicklas |
return getData().getIntProperty(); |
5675 |
28 Jun 11 |
nicklas |
229 |
} |
5675 |
28 Jun 11 |
nicklas |
230 |
/** |
5675 |
28 Jun 11 |
nicklas |
Set the value of the int property. The value mustn't be less than |
5675 |
28 Jun 11 |
nicklas |
zero. |
5675 |
28 Jun 11 |
nicklas |
@param value The new value |
5675 |
28 Jun 11 |
nicklas |
@throws PermissionDeniedException If the logged in user |
5675 |
28 Jun 11 |
nicklas |
doesn't have write permission |
5675 |
28 Jun 11 |
nicklas |
@throws InvalidDataException If the value is less than zero |
5675 |
28 Jun 11 |
nicklas |
237 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public void setIntProperty(int value) |
5675 |
28 Jun 11 |
nicklas |
throws PermissionDeniedException, InvalidDataException |
5675 |
28 Jun 11 |
nicklas |
240 |
{ |
5675 |
28 Jun 11 |
nicklas |
checkPermission(Permission.WRITE); |
5675 |
28 Jun 11 |
nicklas |
getData.setIntProperty( |
5675 |
28 Jun 11 |
nicklas |
IntegerUtil.checkMin(value, "intProperty", 0) |
5675 |
28 Jun 11 |
nicklas |
244 |
); |
5675 |
28 Jun 11 |
nicklas |
245 |
} |
5675 |
28 Jun 11 |
nicklas |
246 |
|
5675 |
28 Jun 11 |
nicklas |
247 |
/** |
5675 |
28 Jun 11 |
nicklas |
Get the value of the boolean property. |
5675 |
28 Jun 11 |
nicklas |
249 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public boolean isBooleanProperty() |
5675 |
28 Jun 11 |
nicklas |
251 |
{ |
5675 |
28 Jun 11 |
nicklas |
return getData().isBooleanProperty(); |
5675 |
28 Jun 11 |
nicklas |
253 |
} |
5675 |
28 Jun 11 |
nicklas |
254 |
/** |
5675 |
28 Jun 11 |
nicklas |
Set the value of the boolean property. |
5675 |
28 Jun 11 |
nicklas |
@param value The new value |
5675 |
28 Jun 11 |
nicklas |
@throws PermissionDeniedException If the logged in user |
5675 |
28 Jun 11 |
nicklas |
doesn't have write permission |
5675 |
28 Jun 11 |
nicklas |
259 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public void setBooleanProperty(boolean value) |
5675 |
28 Jun 11 |
nicklas |
throws PermissionDeniedException |
5675 |
28 Jun 11 |
nicklas |
262 |
{ |
5675 |
28 Jun 11 |
nicklas |
checkPermission(Permission.WRITE); |
5675 |
28 Jun 11 |
nicklas |
getData.setBooleanProperty(value); |
5675 |
28 Jun 11 |
nicklas |
265 |
} |
5675 |
28 Jun 11 |
nicklas |
266 |
|
5675 |
28 Jun 11 |
nicklas |
267 |
/** |
5675 |
28 Jun 11 |
nicklas |
Get the value of the date property. |
5675 |
28 Jun 11 |
nicklas |
@return A date object or null if unknown |
5675 |
28 Jun 11 |
nicklas |
270 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public Date getDateProperty() |
5675 |
28 Jun 11 |
nicklas |
272 |
{ |
5675 |
28 Jun 11 |
nicklas |
return DateUtil.copy(getData().getDateProperty()); |
5675 |
28 Jun 11 |
nicklas |
274 |
} |
5675 |
28 Jun 11 |
nicklas |
275 |
/** |
5675 |
28 Jun 11 |
nicklas |
Set the value of the date property. Null values are allowed. |
5675 |
28 Jun 11 |
nicklas |
@param value The new value |
5675 |
28 Jun 11 |
nicklas |
@throws PermissionDeniedException If the logged in user |
5675 |
28 Jun 11 |
nicklas |
doesn't have write permission |
5675 |
28 Jun 11 |
nicklas |
280 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public void setDateProperty(Date value) |
5675 |
28 Jun 11 |
nicklas |
throws PermissionDeniedException |
5675 |
28 Jun 11 |
nicklas |
283 |
{ |
5675 |
28 Jun 11 |
nicklas |
checkPermission(Permission.WRITE); |
5675 |
28 Jun 11 |
nicklas |
getData().setDateProperty(DateUtil.setNullableDate(value, "dateProperty")); |
5675 |
28 Jun 11 |
nicklas |
286 |
} |
5675 |
28 Jun 11 |
nicklas |
287 |
|
5675 |
28 Jun 11 |
nicklas |
288 |
/** |
5675 |
28 Jun 11 |
nicklas |
Get the associated other item. |
5675 |
28 Jun 11 |
nicklas |
@return The <code>OtherItem</code> item |
5675 |
28 Jun 11 |
nicklas |
@throws PermissionDeniedException If the logged in user |
5675 |
28 Jun 11 |
nicklas |
doesn't have read permission |
5675 |
28 Jun 11 |
nicklas |
@throws BaseException If there is another error |
5675 |
28 Jun 11 |
nicklas |
294 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public OtherItem getOtherItem() |
5675 |
28 Jun 11 |
nicklas |
throws PermissionDeniedException, BaseException |
5675 |
28 Jun 11 |
nicklas |
297 |
{ |
5675 |
28 Jun 11 |
nicklas |
return getDbControl().getItem(OtherItem.class, getData().getOtherItem()); |
5675 |
28 Jun 11 |
nicklas |
299 |
} |
5675 |
28 Jun 11 |
nicklas |
300 |
/** |
5675 |
28 Jun 11 |
nicklas |
Set the associated item. Null is not allowed. |
5675 |
28 Jun 11 |
nicklas |
@param other The other item |
5675 |
28 Jun 11 |
nicklas |
@throws PermissionDeniedException If the logged in user |
5675 |
28 Jun 11 |
nicklas |
doesn't have write permission |
5675 |
28 Jun 11 |
nicklas |
@throws InvalidDataException If the other item is null |
5675 |
28 Jun 11 |
nicklas |
@throws BaseException If there is another error |
5675 |
28 Jun 11 |
nicklas |
307 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public void setOtherItem(OtherItem other) |
5675 |
28 Jun 11 |
nicklas |
throws PermissionDeniedException, InvalidDataException, BaseException |
5675 |
28 Jun 11 |
nicklas |
310 |
{ |
5675 |
28 Jun 11 |
nicklas |
checkPermission(Permission.WRITE); |
5675 |
28 Jun 11 |
nicklas |
if (otherItem == null) throw new InvalidUseOfNullException("otherItem"); |
5675 |
28 Jun 11 |
nicklas |
getData().setOtherItem(otherItem.getData()); |
5675 |
28 Jun 11 |
nicklas |
314 |
} |
5675 |
28 Jun 11 |
nicklas |
315 |
|
5675 |
28 Jun 11 |
nicklas |
316 |
/** |
5675 |
28 Jun 11 |
nicklas |
Create a child item for this any item. |
5675 |
28 Jun 11 |
nicklas |
@return The new <code>ChildItem</code> object |
5675 |
28 Jun 11 |
nicklas |
@throws PermissionDeniedException If the logged in user doesn't have |
5675 |
28 Jun 11 |
nicklas |
write permission |
5675 |
28 Jun 11 |
nicklas |
@throws BaseException If there is another error |
5675 |
28 Jun 11 |
nicklas |
322 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public AChildItem newChildItem() |
5675 |
28 Jun 11 |
nicklas |
throws PermissionDeniedException, BaseException |
5675 |
28 Jun 11 |
nicklas |
325 |
{ |
5675 |
28 Jun 11 |
nicklas |
checkPermission(Permission.WRITE); |
5675 |
28 Jun 11 |
nicklas |
return AChildItem.getNew(getDbControl(), this); |
5675 |
28 Jun 11 |
nicklas |
328 |
} |
5675 |
28 Jun 11 |
nicklas |
329 |
|
5675 |
28 Jun 11 |
nicklas |
330 |
/** |
5675 |
28 Jun 11 |
nicklas |
Get a query that will return all child items for this any item. |
5675 |
28 Jun 11 |
nicklas |
@return An {@link ItemQuery} object |
5675 |
28 Jun 11 |
nicklas |
333 |
*/ |
5675 |
28 Jun 11 |
nicklas |
public ItemQuery<AChildItem> getChildItems() |
5675 |
28 Jun 11 |
nicklas |
335 |
{ |
5675 |
28 Jun 11 |
nicklas |
return AChildItem.getQuery(this); |
5675 |
28 Jun 11 |
nicklas |
337 |
} |
5675 |
28 Jun 11 |
nicklas |
338 |
|
5675 |
28 Jun 11 |
nicklas |
339 |
} |