Changeset 4305
- Timestamp:
- May 21, 2008, 1:11:20 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/AbstractEntityQuery.java
r4302 r4305 72 72 73 73 /** 74 The item type returned by the query. 75 */ 76 private final Item itemType; 74 The item type returned by the query, eg. 75 SELECT [returnType] FROM ... 76 */ 77 private final Item returnType; 78 79 /** 80 The root item type we start with in the query. eq. 81 SELECT ... FROM [rootTypeTable] 82 @since 2.8 83 */ 84 private final Item rootType; 77 85 78 86 /** … … 134 142 Create a new query returning items of the specified item type 135 143 using the default optional runtime filter. 136 @param itemType The type of items that are returned 144 @param returnType The type of items that are returned 145 @param entityName The name of the type of items as known to 146 Hibernate, or null to use the class of the return type 137 147 @param stateless TRUE if the stateless Hibernate session should be used, FALSE 138 148 if the regular Hibernate session should be used 139 149 */ 140 AbstractEntityQuery(Item itemType, String entityName, boolean stateless) 141 { 142 this(itemType, entityName, stateless, QueryRuntimeFilterFactory.getOptionalFilter(itemType)); 150 AbstractEntityQuery(Item returnType, String entityName, boolean stateless) 151 { 152 this(returnType, returnType, entityName, null, stateless, 153 QueryRuntimeFilterFactory.getOptionalFilter(returnType)); 143 154 } 144 155 … … 146 157 Create a new query returning items of the specified type with a non-default 147 158 optional runtime filter. 148 @param itemType The type of items that are returned 159 @param returnType The type of items that are returned 160 @param entityName The name of the type of items as known to 161 Hibernate, or null to use the class of the return type 149 162 @param stateless TRUE if the stateless Hibernate session should be used, FALSE 150 163 if the regular Hibernate session should be used … … 152 165 or null to not use any optional filter 153 166 */ 154 AbstractEntityQuery(Item itemType, String entityName, boolean stateless, QueryRuntimeFilter optionalFilter) 155 { 156 super(entityName == null ? itemType.getDataClass().getName() : entityName); 157 this.itemType = itemType; 167 AbstractEntityQuery(Item returnType, String entityName, boolean stateless, QueryRuntimeFilter optionalFilter) 168 { 169 this(returnType, returnType, entityName, null, stateless, optionalFilter); 170 } 171 172 /** 173 Create a new query that may have different return type and root item type. 174 175 @see DataQuery#DataQuery(Class, Item, String, String) 176 @since 2.8 177 */ 178 AbstractEntityQuery(Item returnType, Item rootType, String rootName, String select, 179 boolean stateless, QueryRuntimeFilter optionalFilter) 180 { 181 super(rootName == null ? rootType.getDataClass().getName() : rootName); 182 super.selectPermanent(Selects.expression(Hql.property(rootType.getAlias(), select), null, true)); 183 this.returnType = returnType; 184 this.rootType = rootType; 158 185 this.stateless = stateless; 159 this.requiredFilter = QueryRuntimeFilterFactory.getRequiredFilter( itemType);186 this.requiredFilter = QueryRuntimeFilterFactory.getRequiredFilter(rootType); 160 187 this.optionalFilter = optionalFilter; 161 super.selectPermanent(Selects.expression(Hql.alias(itemType.getAlias()), null, true));162 188 this.includes = EnumSet.of(Include.NOT_REMOVED, Include.MINE, Include.IN_PROJECT, 163 Include.ANNOTATED, Include.NOT_ANNOTATED);189 Include.ANNOTATED, Include.NOT_ANNOTATED); 164 190 this.permission = Permission.READ; 165 191 setAutoJoinType(JoinType.LEFT); 166 192 } 167 168 193 169 194 /* … … 231 256 232 257 /** 233 The alias of the item that is returned bythis query.258 The alias of the item that is the root of this query. 234 259 @see Item#getAlias() 235 260 */ 236 261 public String getRootAlias() 237 262 { 238 return itemType.getAlias();263 return rootType.getAlias(); 239 264 } 240 265 … … 299 324 public Item getItemType() 300 325 { 301 return itemType; 326 return returnType; 327 } 328 /** 329 @since 2.8 330 */ 331 public Item getRootType() 332 { 333 return rootType; 302 334 } 303 335 public void include(Include... includes) -
trunk/src/core/net/sf/basedb/core/ArrayDesign.java
r4257 r4305 29 29 import net.sf.basedb.core.data.ArrayDesignPlateData; 30 30 import net.sf.basedb.core.data.FeatureData; 31 import net.sf.basedb.core.data.ReporterData; 31 32 import net.sf.basedb.core.query.Hql; 32 33 import net.sf.basedb.core.query.Restrictions; … … 777 778 778 779 /** 780 Get a query that returns the reporters on this array design. The query 781 is rooted at the features, which means that: 782 <ul> 783 <li>All filters, sorting, etc. that works for {@link #getFeatures()} can be 784 used without modifications on this query. 785 <li>The same reporter may be returned multiple times if it is present on several 786 features. 787 <li>'Null' values may be returned if there are features without a reporter 788 </ul> 789 790 @return A {@link DataQuery} object 791 @since 2.8 792 */ 793 public DataQuery<ReporterData> getReporters() 794 { 795 DataQuery<ReporterData> query = 796 new DataQuery<ReporterData>(ReporterData.class, Item.FEATURE, null, "reporter"); 797 query.restrictPermanent( 798 Restrictions.eq( 799 Hql.property("arrayDesignBlock.arrayDesign"), 800 Hql.entity(this) 801 ) 802 ); 803 return query; 804 } 805 806 /** 779 807 Get a feature when you know the id. 780 808 @param id The id of the feature -
trunk/src/core/net/sf/basedb/core/DataQuery.java
r4243 r4305 62 62 63 63 /** 64 Create a query that may have different return type and root entity. 65 For example, to return reporters from a query rooted at features: 66 <code>new DataQuery(ReporterData.class, Item.FEATURE, null, "reporter")</code>. 67 This will be translated to something like (in HQL): 68 <code>SELECT ftr.reporter FROM FeatureData ftr ...</code> 69 70 @param dataClass The class of the data objects that are returned 71 @param rootType The root item type of the query 72 @param rootName The root enitity name, or null to use 73 the class name of the root type 74 @param select The HQL property that we should select on the root 75 type to get to the return type 76 @since 2.8 77 */ 78 DataQuery(Class<I> dataClass, Item rootType, String rootName, String select) 79 { 80 super(Item.fromDataClass(dataClass), rootType, rootName, select, true, 81 QueryRuntimeFilterFactory.getOptionalFilter(rootType)); 82 this.dataClass = dataClass; 83 } 84 85 /** 64 86 Create a new query for the specified item, using a non-default optional 65 87 runtime filter. -
trunk/src/core/net/sf/basedb/core/Plate.java
r4040 r4305 28 28 import net.sf.basedb.core.data.PlateEventData; 29 29 import net.sf.basedb.core.data.PlateCoordinate; 30 import net.sf.basedb.core.data.ReporterData; 30 31 import net.sf.basedb.core.data.WellData; 31 32 import net.sf.basedb.core.query.Restrictions; … … 483 484 } 484 485 486 /** 487 Get a query that returns the reporters on this plate. The query 488 is rooted at the wells, which means that: 489 <ul> 490 <li>All filters, sorting, etc. that works for {@link #getWells()} can be 491 used without modifications on this query. 492 <li>The same reporter may be returned multiple times if it is present on several 493 wells. 494 <li>'Null' values may be returned if there are wells without a reporter 495 </ul> 496 497 @return A {@link DataQuery} object 498 @since 2.8 499 */ 500 public DataQuery<ReporterData> getReporters() 501 { 502 DataQuery<ReporterData> query = 503 new DataQuery<ReporterData>(ReporterData.class, Item.WELL, null, "reporter"); 504 query.restrictPermanent( 505 Restrictions.eq( 506 Hql.property("plate"), 507 Hql.entity(this) 508 ) 509 ); 510 return query; 511 } 512 485 513 } -
trunk/src/core/net/sf/basedb/core/RawBioAssay.java
r4284 r4305 1137 1137 } 1138 1138 DataQuery<RawData> query = new DataQuery<RawData>(RawData.class, rdt.getEntityName()); 1139 query.restrictPermanent( 1140 Restrictions.eq( 1141 Hql.property("rawBioAssay"), 1142 Hql.entity(this) 1143 ) 1144 ); 1145 return query; 1146 } 1147 1148 /** 1149 Get a query that returns the reporters on this raw bioassay. 1150 The query is rooted at the raw data, which means that: 1151 <ul> 1152 <li>All filters, sorting, etc. that works for {@link #getRawData()} can be 1153 used without modifications on this query. 1154 <li>The same reporter may be returned multiple times if it is present on multiple 1155 spots. 1156 <li>'Null' values may be returned if there are spots without a reporter 1157 </ul> 1158 1159 @return A {@link DataQuery} object 1160 @since 2.8 1161 */ 1162 public DataQuery<ReporterData> getReporters() 1163 { 1164 RawDataType rdt = getRawDataType(); 1165 if (!rdt.isStoredInDb()) 1166 { 1167 throw new BaseException("Raw data for raw data type '" + rdt + "' is not stored in the database."); 1168 } 1169 DataQuery<ReporterData> query = 1170 new DataQuery<ReporterData>(ReporterData.class, Item.RAWDATA, rdt.getEntityName(), "reporter"); 1139 1171 query.restrictPermanent( 1140 1172 Restrictions.eq( -
trunk/src/core/net/sf/basedb/core/query/EntityQuery.java
r3679 r4305 49 49 */ 50 50 public Item getItemType(); 51 52 /** 53 The type of items that is the root of the query. In most cases, 54 this is the same as the {@link #getItemType()}, but not 55 always. 56 @since 2.8 57 */ 58 public Item getRootType(); 51 59 52 60 /** -
trunk/www/lims/arraydesigns/features/index.jsp
r4093 r4305 37 37 import="net.sf.basedb.core.ArrayDesign" 38 38 import="net.sf.basedb.core.data.FeatureData" 39 import="net.sf.basedb.core.data.ReporterData" 39 40 import="net.sf.basedb.clients.web.Base" 40 41 import="net.sf.basedb.clients.web.WebException" … … 103 104 redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+features+of+array+design"; 104 105 } 106 else if ("CreateReporterList".equals(cmd)) 107 { 108 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 109 dc = sc.newDbControl(); 110 final ArrayDesign arrayDesign = ArrayDesign.getById(dc, arrayDesignId); 111 final DataQuery<ReporterData> query = arrayDesign.getReporters(); 112 cc.configureQuery(query, true); 113 cc.setQuery(query); 114 redirect = "../../../views/reporterlists/index.jsp?ID="+ID+ 115 "&cmd=NewItem&addReporters=1&formId=features&fromContext=FEATURE" + 116 "&name=" + HTML.urlEncode(arrayDesign.getName()); 117 } 105 118 else 106 119 { -
trunk/www/lims/arraydesigns/features/list_features.jsp
r4302 r4305 156 156 } 157 157 } 158 function newReporterList() 159 { 160 Table.submitToPopup(formId, 'CreateReporterList', 540, 400); 161 } 158 162 </script> 159 163 </base:head> … … 465 469 title="Columns…" 466 470 tooltip="Show, hide and re-order columns" 471 /> 472 <tbl:button 473 image="add.png" 474 onclick="newReporterList()" 475 title="New reporter list…" 476 tooltip="Create a new reporter list from matching features" 477 visible="<%=sc.hasPermission(Permission.CREATE, Item.REPORTERLIST)%>" 467 478 /> 468 479 <tbl:button -
trunk/www/lims/plates/wells/index.jsp
r3679 r4305 33 33 import="net.sf.basedb.core.Well" 34 34 import="net.sf.basedb.core.ItemQuery" 35 import="net.sf.basedb.core.DataQuery" 35 36 import="net.sf.basedb.core.Permission" 36 37 import="net.sf.basedb.core.PermissionDeniedException" 38 import="net.sf.basedb.core.data.ReporterData" 37 39 import="net.sf.basedb.util.RemovableUtil" 38 40 import="net.sf.basedb.clients.web.Base" … … 174 176 redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; 175 177 } 178 else if ("CreateReporterList".equals(cmd)) 179 { 180 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 181 dc = sc.newDbControl(); 182 final Plate plate = Plate.getById(dc, plateId); 183 final DataQuery<ReporterData> query = plate.getReporters(); 184 cc.configureQuery(query, true); 185 cc.setQuery(query); 186 redirect = "../../../views/reporterlists/index.jsp?ID="+ID+ 187 "&cmd=NewItem&addReporters=1&formId=wells&fromContext=WELL"+ 188 "&name=" + HTML.urlEncode(plate.getName()); 189 } 176 190 else 177 191 { -
trunk/www/lims/plates/wells/list_wells.jsp
r4302 r4305 162 162 } 163 163 } 164 function newReporterList() 165 { 166 Table.submitToPopup(formId, 'CreateReporterList', 540, 400); 167 } 164 168 </script> 165 169 </base:head> … … 376 380 title="Columns…" 377 381 tooltip="Show, hide and re-order columns" 382 /> 383 <tbl:button 384 image="add.png" 385 onclick="newReporterList()" 386 title="New reporter list…" 387 tooltip="Create a new reporter list from matching wells" 388 visible="<%=sc.hasPermission(Permission.CREATE, Item.REPORTERLIST)%>" 378 389 /> 379 390 <tbl:button -
trunk/www/views/rawbioassays/rawdata/index.jsp
r3679 r4305 32 32 import="net.sf.basedb.core.ItemContext" 33 33 import="net.sf.basedb.core.data.RawData" 34 import="net.sf.basedb.core.data.ReporterData" 34 35 import="net.sf.basedb.core.RawBioAssay" 35 36 import="net.sf.basedb.core.RawDataType" … … 126 127 redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&subcontext="+rawDataType.getId()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; 127 128 } 129 else if ("CreateReporterList".equals(cmd)) 130 { 131 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext); 132 final DataQuery<ReporterData> query = rba.getReporters(); 133 cc.configureQuery(query, true); 134 cc.setQuery(query); 135 redirect = "../../../views/reporterlists/index.jsp?ID="+ID+ 136 "&cmd=NewItem&addReporters=1&formId=rawdata&fromContext=RAWDATA&subContext="+rawDataType.getId()+ 137 "&name=" + HTML.urlEncode(rba.getName()); 138 } 128 139 else 129 140 { -
trunk/www/views/rawbioassays/rawdata/list_rawdata.jsp
r4302 r4305 162 162 } 163 163 } 164 function newReporterList() 165 { 166 Table.submitToPopup(formId, 'CreateReporterList', 540, 400); 167 } 164 168 </script> 165 169 </base:head> … … 557 561 title="Columns…" 558 562 tooltip="Show, hide and re-order columns" 563 /> 564 <tbl:button 565 image="add.png" 566 onclick="newReporterList()" 567 title="New reporter list…" 568 tooltip="Create a new reporter list from matching spots" 569 visible="<%=sc.hasPermission(Permission.CREATE, Item.REPORTERLIST)%>" 559 570 /> 560 571 <tbl:button -
trunk/www/views/reporterlists/edit_reporterlist.jsp
r4301 r4305 51 51 { 52 52 String title = null; 53 String name = null; 53 54 ReporterList reporterList = null; 54 55 boolean addReporters = false; 55 56 boolean mergeReporterLists = false; 56 57 int numSelectedLists = cc.getSelected().size(); 58 String formId = Values.getString(request.getParameter("formId"), "reporters"); 59 String fromContext = Values.getString(request.getParameter("fromContext"), "REPORTER"); 60 String subContext = request.getParameter("subContext"); 57 61 58 62 if (itemId == 0) … … 62 66 addReporters = Values.getBoolean(request.getParameter("addReporters")); 63 67 mergeReporterLists = !addReporters && numSelectedLists > 0; 68 name = request.getParameter("name"); 69 if (name == null) name = Values.getString(cc.getPropertyValue("name"), "New reporter list"); 64 70 } 65 71 else 66 72 { 67 73 reporterList = ReporterList.getById(dc, itemId); 74 name = reporterList.getName(); 68 75 cc.setObject("item", reporterList); 69 76 title = "Edit reporter list -- " + HTML.encodeTags(reporterList.getName()); … … 152 159 if (!selectedItems) 153 160 { 154 selectedItems = window.opener.Table.getSelected(' reporters');161 selectedItems = window.opener.Table.getSelected('<%=formId%>'); 155 162 } 156 163 return selectedItems; … … 166 173 <form action="index.jsp?ID=<%=ID%>" method="post" name="reporterList" onsubmit="return false;"> 167 174 <input type="hidden" name="cmd" value="UpdateItem"> 168 175 <input type="hidden" name="fromContext" value="<%=fromContext%>"> 176 <% 177 if (subContext != null) 178 { 179 %> 180 <input type="hidden" name="subContext" value="<%=subContext%>"> 181 <% 182 } 183 %> 169 184 <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3> 170 185 <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*260)+"px;"%>" … … 176 191 <td class="prompt">Name</td> 177 192 <td><input <%=requiredClazz%> type="text" name="name" 178 value="<%=HTML.encodeTags( reporterList == null ? Values.getString(cc.getPropertyValue("name"), "New reporter list") : reporterList.getName())%>"193 value="<%=HTML.encodeTags(name)%>" 179 194 size="40" maxlength="<%=ReporterList.MAX_NAME_LENGTH%>"></td> 180 195 </tr> -
trunk/www/views/reporterlists/index.jsp
r4301 r4305 139 139 { 140 140 rl = ReporterList.getNew(dc); 141 message = "Reporter list created";142 141 dc.saveItem(rl); 143 142 … … 146 145 if (which != null) 147 146 { 148 DataQuery<ReporterData> query = (DataQuery<ReporterData>)sc.getCurrentContext(Item.REPORTER).getQuery(); 147 Item fromContext = Item.valueOf(request.getParameter("fromContext")); 148 String subContext = Values.getString(request.getParameter("subContext"), ""); 149 DataQuery<ReporterData> query = 150 (DataQuery<ReporterData>)sc.getCurrentContext(fromContext, subContext).getQuery(); 149 151 if ("all".equals(which)) 150 152 { … … 165 167 query.setParameter("_selected_", Arrays.asList(itemIds), Type.INT); 166 168 } 169 // else -- no modifications to the query mean that we only get the current page 167 170 168 171 DataResultIterator<ReporterData> result = query.iterate(dc); 169 172 while (result.hasNext()) 170 173 { 171 rl.addReporter(result.next(), null); 174 ReporterData reporter = result.next(); 175 if (reporter != null) rl.addReporter(reporter, null); 172 176 } 173 177 } … … 196 200 } 197 201 } 202 message = "Reporter list created with " + rl.getSize() + " reporter(s)"; 198 203 } 199 204 else -
trunk/www/views/reporters/index.jsp
r4093 r4305 272 272 cc.configureQuery(query, true); 273 273 cc.setQuery(query); 274 redirect = "../reporterlists/index.jsp?ID="+ID+"&cmd=NewItem&addReporters=1 ";274 redirect = "../reporterlists/index.jsp?ID="+ID+"&cmd=NewItem&addReporters=1&formId=reporters&fromContext=REPORTER"; 275 275 } 276 276 else
Note: See TracChangeset
for help on using the changeset viewer.