Changeset 5695
- Timestamp:
- Aug 12, 2011, 9:39:05 AM (12 years ago)
- Location:
- trunk/src/core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/common-queries.xml
r5685 r5695 1100 1100 </query> 1101 1101 1102 <query id="GET_DERIVEDBIOASSAYS_FOR_EXTRACT" type="HQL"> 1103 <sql> 1104 SELECT {1} 1105 FROM DerivedBioAssayData dba 1106 WHERE dba.extract = :extract 1107 </sql> 1108 <description> 1109 A Hibernate query that gets the derived bioassays 1110 that are referencing a given extract. 1111 </description> 1112 </query> 1113 1114 <query id="GET_RAWBIOASSAYS_FOR_EXTRACT" type="HQL"> 1115 <sql> 1116 SELECT {1} 1117 FROM RawBioAssayData rba 1118 WHERE rba.parentExtract = :extract 1119 </sql> 1120 <description> 1121 A Hibernate query that gets the raw bioassays 1122 that are referencing a given extract. 1123 </description> 1124 </query> 1125 1102 1126 <query id="COUNT_UNREAD_MESSAGES_FOR_USER" type="HQL"> 1103 1127 <sql> … … 1381 1405 </description> 1382 1406 </query> 1407 1408 <query id="GET_CHILD_DERIVEDBIOASSAYS_FOR_DERIVEDBIOASSAY" type="HQL"> 1409 <sql> 1410 SELECT {1} 1411 FROM DerivedBioAssayData dba 1412 WHERE dba.parent = :bioAssay 1413 </sql> 1414 <description> 1415 A Hibernate query that gets child derived bioassays 1416 created from a specific derived bioassay. 1417 </description> 1418 </query> 1419 1383 1420 1384 1421 <query id="GET_RAWBIOASSAYS_FOR_DERIVEDBIOASSAY" type="HQL"> -
trunk/src/core/net/sf/basedb/core/DerivedBioAssay.java
r5689 r5695 166 166 */ 167 167 /** 168 169 */ 168 Get all: 169 <ul> 170 <li>Child derived bioassays 171 <li>Child raw bioassays 172 </ul> 173 */ 170 174 @Override 171 175 public Set<ItemProxy> getUsingItems() 172 176 { 173 177 Set<ItemProxy> using = super.getUsingItems(); 174 // TODO - part of #1153 178 org.hibernate.Session session = getDbControl().getHibernateSession(); 179 180 // Child derived bioassays 181 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 182 "GET_CHILD_DERIVEDBIOASSAYS_FOR_DERIVEDBIOASSAY", "dba.id"); 183 /* 184 SELECT {1} 185 FROM DerivedBioAssayData dba 186 WHERE dba.parent = :bioAssay 187 */ 188 query.setEntity("bioAssay", this.getData()); 189 addUsingItems(using, Item.DERIVEDBIOASSAY, query); 190 191 // Child raw bioassays 192 query = HibernateUtil.getPredefinedQuery(session, 193 "GET_RAWBIOASSAYS_FOR_DERIVEDBIOASSAY", "rba.id"); 194 /* 195 SELECT {1} 196 FROM RawBioAssayData rba 197 WHERE rba.parentBioAssay = :bioAssay 198 */ 199 query.setEntity("bioAssay", this.getData()); 200 addUsingItems(using, Item.RAWBIOASSAY, query); 201 175 202 return using; 176 203 } … … 183 210 throws BaseException 184 211 { 185 // TODO - part of #1153 186 return super.isUsed(); 187 } 188 189 /** 190 Grant READ persmission to everyone that has read permision 191 on the parent physical bioassay. 192 */ 193 @Override 194 void initPermissions(int granted, int denied) 195 throws BaseException 196 { 197 // TODO Auto-generated method stub 198 super.initPermissions(granted, denied); 212 org.hibernate.Session session = getDbControl().getHibernateSession(); 213 boolean used = false; 214 215 if (!used) 216 { 217 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 218 "GET_RAWBIOASSAYS_FOR_DERIVEDBIOASSAY", "count(*)"); 219 /* 220 SELECT {1} 221 FROM RawBioAssayData rba 222 WHERE rba.parentBioAssay = :bioAssay 223 */ 224 query.setEntity("bioAssay", this.getData()); 225 used = HibernateUtil.loadData(Long.class, query) > 0; 226 } 227 228 if (!used) 229 { 230 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 231 "GET_CHILD_DERIVEDBIOASSAYS_FOR_DERIVEDBIOASSAY", "count(*)"); 232 /* 233 SELECT {1} 234 FROM DerivedBioAssayData dba 235 WHERE dba.parent = :bioAssay 236 */ 237 query.setEntity("bioAssay", this.getData()); 238 used = HibernateUtil.loadData(Long.class, query) > 0; 239 } 240 241 return used || super.isUsed(); 199 242 } 200 243 -
trunk/src/core/net/sf/basedb/core/Extract.java
r5663 r5695 165 165 <li>no {@link PhysicalBioAssay}:s has been created from this item 166 166 <li>no {@link Extract}:s has been created from this item 167 <li>no {@link DerivedBioAssay} is referencing this item 168 <li>no {@link RawBioAssay} is referencing this item 167 169 </ul> 168 170 */ 169 171 public boolean isUsed() 170 172 throws BaseException 171 { 172 return super.isUsed(); 173 } 173 { 174 org.hibernate.Session session = getDbControl().getHibernateSession(); 175 boolean used = false; 176 177 if (!used) 178 { 179 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 180 "GET_DERIVEDBIOASSAYS_FOR_EXTRACT", "count(*)"); 181 /* 182 SELECT {1} 183 FROM DerivedBioAssayData dba 184 WHERE dba.extract = :extract 185 */ 186 query.setEntity("extract", this.getData()); 187 used = HibernateUtil.loadData(Long.class, query) > 0; 188 } 189 190 if (!used) 191 { 192 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 193 "GET_RAWBIOASSAYS_FOR_EXTRACT", "count(*)"); 194 /* 195 SELECT {1} 196 FROM RawBioAssayData rba 197 WHERE rba.parentExtract = :extract 198 */ 199 query.setEntity("extract", this.getData()); 200 used = HibernateUtil.loadData(Long.class, query) > 0; 201 } 202 203 return used || super.isUsed(); 204 } 205 174 206 /** 175 207 Get all: 176 208 <ul> 209 <li>Child extracts created from the extract 177 210 <li>{@link PhysicalBioAssay}:s created from this extract 211 <li>{@link DerivedBioAssay}:s referencing the extract 212 <li>{@link RawBioAssay}:s referencing the extract 178 213 <ul> 179 214 @since 2.2 … … 184 219 Set<ItemProxy> using = super.getUsingItems(); 185 220 org.hibernate.Session session = getDbControl().getHibernateSession(); 221 222 // Physical bioassays 186 223 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 187 224 "GET_SOURCEEVENTS_FOR_BIOMATERIAL", "bme.physicalBioAssay.id"); … … 190 227 FROM BioMaterialEventData bme 191 228 JOIN bme.sources src 192 WHERE index(src)= :bioMaterial229 WHERE src.bioMaterial = :bioMaterial 193 230 */ 194 231 query.setEntity("bioMaterial", this.getData()); 195 232 addUsingItems(using, Item.PHYSICALBIOASSAY, query); 233 234 // Derived bioassays 235 query = HibernateUtil.getPredefinedQuery(session, 236 "GET_DERIVEDBIOASSAYS_FOR_EXTRACT", "dba.id"); 237 /* 238 SELECT {1} 239 FROM DerivedBioAssayData dba 240 WHERE dba.extract = :extract 241 */ 242 query.setEntity("extract", this.getData()); 243 addUsingItems(using, Item.DERIVEDBIOASSAY, query); 244 245 // Raw bioassays 246 query = HibernateUtil.getPredefinedQuery(session, 247 "GET_RAWBIOASSAYS_FOR_EXTRACT", "rba.id"); 248 /* 249 SELECT {1} 250 FROM RawBioAssayData rba 251 WHERE rba.parentExtract = :extract 252 */ 253 query.setEntity("extract", this.getData()); 254 addUsingItems(using, Item.RAWBIOASSAY, query); 255 196 256 return using; 197 257 }
Note: See TracChangeset
for help on using the changeset viewer.