Changeset 5643
- Timestamp:
- May 26, 2011, 1:19:32 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/Base.java
r5623 r5643 33 33 import net.sf.basedb.core.FileSet; 34 34 import net.sf.basedb.core.FileStoreEnabled; 35 import net.sf.basedb.core.ItemSubtype; 35 36 import net.sf.basedb.core.Location; 36 37 import net.sf.basedb.core.Path; … … 1004 1005 1005 1006 /** 1007 Get a query that returns all subtypes for the given main item type. 1008 @param itemType The main item type 1009 @return An <code>ItemQuery</code> object 1010 @since 3.0 1011 */ 1012 public static ItemQuery<ItemSubtype> getSubtypesQuery(Item itemType) 1013 { 1014 ItemQuery<ItemSubtype> query = ItemSubtype.getQuery(itemType); 1015 query.order(Orders.asc(Hql.property("name"))); 1016 query.setCacheResult(true); 1017 return query; 1018 } 1019 1020 1021 /** 1006 1022 Get a query that returns all annotation types defined for a 1007 1023 {@link AnnotatableProxy} item. -
trunk/src/clients/web/net/sf/basedb/clients/web/servlet/Upload.java
r5630 r5643 118 118 compress = Values.getBoolean(upload.getParameter("compressed")); 119 119 } 120 int fileTypeId = Values.getInt(upload.getParameter("filetype_id"));120 int subtypeId = Values.getInt(upload.getParameter("subtype_id")); 121 121 String description = Values.getStringOrNull(upload.getParameter("description")); 122 122 String characterSet = Values.getStringOrNull(upload.getParameter("characterSet")); … … 187 187 String browserMimeType = uploadedFile.getMimeType(); 188 188 f.setMimeTypeAuto(serverMimeType != null ? serverMimeType : browserMimeType, null); 189 if ( fileTypeId >= 0) // < 0 = denied or unchanged190 { 191 ItemSubtype ft = fileTypeId == 0 ? null : ItemSubtype.getById(dc, fileTypeId);192 f.setItemSubtype( ft);193 if ( ft != null) cc.setRecent(ft, maxRecent);189 if (subtypeId >= 0) // < 0 = denied or unchanged 190 { 191 ItemSubtype subtype = subtypeId == 0 ? null : ItemSubtype.getById(dc, subtypeId); 192 f.setItemSubtype(subtype); 193 if (subtype != null) cc.setRecent(subtype, maxRecent); 194 194 } 195 195 f.setDescription(description); -
trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/ColumnDef.java
r5450 r5643 379 379 /** 380 380 Options for enum. 381 */ 382 private String jsEnum = null; 383 381 */ 384 382 private Enumeration<String, String> enumeration; 385 383 … … 535 533 } 536 534 537 public void setEnum(String jsEnum)538 {539 this.jsEnum = jsEnum;540 }541 public String getEnum()542 {543 return jsEnum;544 }545 546 535 public void setEnumeration(Enumeration<String, String> enumeration) 547 536 { -
trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/Table.java
r5474 r5643 423 423 script.append(cd.isFilterable() ? ",true" : ",false"); 424 424 script.append(cd.isExportable() ? ",true" : ",false"); 425 script.append(cd.getEnum() != null ? ","+cd.getEnum() : ",null");426 425 script.append("));\n"); 427 426 } -
trunk/src/core/net/sf/basedb/core/BioMaterial.java
r5535 r5643 28 28 29 29 /** 30 This is the base class for for the four types of biomaterials: 31 {@link BioSource}, {@link Sample}, {@link Extract} 32 and {@link LabeledExtract}. 30 This is the base class for for the three types of biomaterials: 31 {@link BioSource}, {@link Sample} and {@link Extract}. 33 32 34 33 @author Nicklas … … 38 37 public abstract class BioMaterial<D extends BioMaterialData> 39 38 extends AnnotatedItem<D> 39 implements Subtypable 40 40 { 41 41 … … 43 43 Get a biomaterial item when you know the id. This method can return any 44 44 of the subclasses of {@link BioMaterial}. Eg. {@link BioSource}, 45 {@link Sample} , {@link Extract} or {@link LabeledExtract}.45 {@link Sample} or {@link Extract}. 46 46 47 47 @param dc The <code>DbControl</code> which will be used for … … 63 63 } 64 64 65 BioMaterial(D bioMaterialData)66 {67 super(bioMaterialData);68 }69 70 65 /** 71 66 The maximum length of the external id that can be stored in the database. … … 74 69 public static final int MAX_EXTERNAL_ID_LENGTH = BioMaterialData.MAX_EXTERNAL_ID_LENGTH; 75 70 71 BioMaterial(D bioMaterialData) 72 { 73 super(bioMaterialData); 74 } 76 75 76 /* 77 From the Subtypable interface 78 ----------------------------- 79 */ 80 @Override 81 public ItemSubtype getItemSubtype() 82 { 83 return getDbControl().getItem(ItemSubtype.class, getData().getItemSubtype()); 84 } 85 @Override 86 public void setItemSubtype(ItemSubtype subtype) 87 { 88 checkPermission(Permission.WRITE); 89 if (subtype != null) 90 { 91 subtype.setOnItem(this); 92 } 93 else 94 { 95 getData().setItemSubtype(null); 96 } 97 } 98 // ------------------------------------------- 99 100 /* 101 From the BasicItem class 102 ------------------------ 103 */ 77 104 /** 78 105 On delete action: issue an update to decrease the size of all … … 103 130 } 104 131 } 132 // ------------------------------------ 133 105 134 /** 106 135 Get the external id of the biomaterial. This value can be used to link -
trunk/src/core/net/sf/basedb/core/Extract.java
r5642 r5643 179 179 */ 180 180 @Override 181 @SubtypableRelatedItems({Item.PROTOCOL, Item.HARDWARE, Item.TAG })181 @SubtypableRelatedItems({Item.PROTOCOL, Item.HARDWARE, Item.TAG, Item.SAMPLE, Item.EXTRACT}) 182 182 public ItemSubtype getItemSubtype() 183 183 { -
trunk/src/core/net/sf/basedb/core/MeasuredBioMaterial.java
r5631 r5643 55 55 public abstract class MeasuredBioMaterial<D extends MeasuredBioMaterialData> 56 56 extends BioMaterial<D> 57 implements Registered , Subtypable57 implements Registered 58 58 { 59 59 … … 180 180 public ItemSubtype getItemSubtype() 181 181 { 182 return getDbControl().getItem(ItemSubtype.class, getData().getItemSubtype()); 183 } 184 @Override 185 public void setItemSubtype(ItemSubtype subtype) 186 { 187 checkPermission(Permission.WRITE); 188 if (subtype != null) 189 { 190 subtype.setOnItem(this); 191 } 192 else 193 { 194 getData().setItemSubtype(null); 195 } 196 } 197 182 return super.getItemSubtype(); 183 } 198 184 // ------------------------------------------- 199 185 -
trunk/src/core/net/sf/basedb/core/Sample.java
r5523 r5643 161 161 } 162 162 // ------------------------------------------- 163 /* 164 From the Subtypable interface 165 ----------------------------- 166 */ 167 @Override 168 @SubtypableRelatedItems({Item.PROTOCOL, Item.HARDWARE, Item.BIOSOURCE, Item.SAMPLE}) 169 public ItemSubtype getItemSubtype() 170 { 171 return super.getItemSubtype(); 172 } 173 // ------------------------------------------- 163 174 164 175 /* -
trunk/src/core/net/sf/basedb/core/data/BioMaterialData.java
r4889 r5643 38 38 public abstract class BioMaterialData 39 39 extends AnnotatedData 40 implements SubtypableData 40 41 { 41 42 42 43 public BioMaterialData() 43 44 {} 45 46 /* 47 From the SubtypableData interface 48 ---------------------------------- 49 */ 50 private ItemSubtypeData subtype; 51 @Override 52 public ItemSubtypeData getItemSubtype() 53 { 54 return subtype; 55 } 56 @Override 57 public void setItemSubtype(ItemSubtypeData subtype) 58 { 59 this.subtype = subtype; 60 } 61 // ------------------------------ 62 44 63 45 64 /** -
trunk/src/core/net/sf/basedb/core/data/MeasuredBioMaterialData.java
r5630 r5643 38 38 public abstract class MeasuredBioMaterialData 39 39 extends BioMaterialData 40 implements SubtypableData41 40 { 42 41 43 42 public MeasuredBioMaterialData() 44 43 {} 45 46 /*47 From the SubtypableData interface48 ----------------------------------49 */50 private ItemSubtypeData subtype;51 @Override52 public ItemSubtypeData getItemSubtype()53 {54 return subtype;55 }56 @Override57 public void setItemSubtype(ItemSubtypeData subtype)58 {59 this.subtype = subtype;60 }61 // ------------------------------62 63 44 64 45 private BioMaterialData parent; -
trunk/src/core/net/sf/basedb/util/Enumeration.java
r5384 r5643 25 25 26 26 import java.io.Serializable; 27 import java.util.Collection; 27 28 import java.util.Collections; 28 29 import java.util.Comparator; 29 30 import java.util.List; 30 31 import java.util.LinkedList; 32 33 import net.sf.basedb.core.Nameable; 31 34 32 35 /** … … 41 44 42 45 private static final long serialVersionUID = 1222952912319368574L; 46 47 /** 48 Create a new enumeration from a list of basic items. 49 The key of the enumeration is the id of each item 50 and the value is the name. 51 @param items A collection with items 52 @param noneOption If not null, this options will be inserted first in the 53 enumeration with an empty string as the key 54 */ 55 public static Enumeration<String, String> fromItems(Collection<? extends Nameable> items, String noneOption) 56 { 57 Enumeration<String, String> e = new Enumeration<String, String>(); 58 if (noneOption != null) 59 { 60 e.add("", noneOption); 61 } 62 for (Nameable item : items) 63 { 64 e.add(Integer.toString(item.getId()), ((Nameable)item).getName()); 65 } 66 e.lock(); 67 return e; 68 } 69 70 43 71 private final List<Entry<K, V>> entries; 44 72 private boolean locked; … … 90 118 public void remove(int index) 91 119 { 92 if (locked) throw new UnsupportedOperationException(" add; The enumeration has been locked for modifications.");120 if (locked) throw new UnsupportedOperationException("remove; The enumeration has been locked for modifications."); 93 121 entries.remove(index); 94 122 } -
trunk/www/WEB-INF/table.tld
r5186 r5643 188 188 </attribute> 189 189 <attribute> 190 <name>enum</name>191 <required>false</required>192 <rtexprvalue>true</rtexprvalue>193 </attribute>194 <attribute>195 190 <name>enumeration</name> 196 191 <required>false</required> -
trunk/www/admin/hardware/edit_hardware.jsp
r5630 r5643 34 34 import="net.sf.basedb.core.ItemSubtype" 35 35 import="net.sf.basedb.core.ItemQuery" 36 import="net.sf.basedb.core.Include" 36 37 import="net.sf.basedb.core.ItemResultList" 37 38 import="net.sf.basedb.core.PermissionDeniedException" … … 61 62 String title = null; 62 63 Hardware hardware = null; 63 boolean readCurrent HardwareType = true;64 int current HardwareTypeId = 0;64 boolean readCurrentSubtype = true; 65 int currentSubtypeId = 0; 65 66 66 67 if (itemId == 0) … … 68 69 title = "Create hardware"; 69 70 cc.removeObject("item"); 70 current HardwareTypeId = Values.getInt(request.getParameter("hardwaretype_id"));71 if (current HardwareTypeId == 0)72 { 73 int recent HardwareTypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0));74 current HardwareTypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentHardwareTypeId);71 currentSubtypeId = Values.getInt(request.getParameter("subtype_id")); 72 if (currentSubtypeId == 0) 73 { 74 int recentSubtypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0)); 75 currentSubtypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentSubtypeId); 75 76 } 76 77 } … … 78 79 { 79 80 hardware = Hardware.getById(dc, itemId); 81 hardware.checkPermission(Permission.WRITE); 80 82 cc.setObject("item", hardware); 81 83 title = "Edit hardware -- " + HTML.encodeTags(hardware.getName()); 82 84 try 83 85 { 84 ItemSubtype ht= hardware.getItemSubtype();85 if ( ht != null) currentHardwareTypeId = ht.getId();86 ItemSubtype subtype = hardware.getItemSubtype(); 87 if (subtype != null) currentSubtypeId = subtype.getId(); 86 88 } 87 89 catch (PermissionDeniedException ex) 88 90 { 89 readCurrentHardwareType = false; 90 } 91 } 92 if (hardware != null && !hardware.hasPermission(Permission.WRITE)) 93 { 94 throw new PermissionDeniedException(Permission.WRITE, itemType.toString()); 91 readCurrentSubtype = false; 92 } 95 93 } 96 94 97 95 // Query to retrieve file types 98 final ItemQuery<ItemSubtype> hardwareTypeQuery = ItemSubtype.getQuery(itemType);99 hardwareTypeQuery.order(Orders.asc(Hql.property("name")));96 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); 97 subtypesQuery.include(Include.ALL); 100 98 101 99 final String clazz = "class=\"text\""; … … 164 162 size="40" maxlength="<%=Hardware.MAX_NAME_LENGTH%>"></td> 165 163 </tr> 166 <tr>167 <td class="prompt">Version</td>168 <td><input <%=clazz%> type="text" name="version"169 value="<%=HTML.encodeTags(hardware == null ? cc.getPropertyValue("versionString") : hardware.getVersionString())%>"170 size="40" maxlength="<%=Hardware.MAX_VERSIONSTRING_LENGTH%>"></td>171 </tr>172 164 <tr valign="top"> 173 165 <td class="prompt">Type</td> 174 166 <td colspan="2"> 175 <select name=" hardwaretype_id"176 <%=!readCurrent HardwareType ? "disabled readonly class=\"disabled\"" : "class=\"required\""%>>167 <select name="subtype_id" 168 <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>> 177 169 <% 178 if (!readCurrent HardwareType)170 if (!readCurrentSubtype) 179 171 { 180 172 %> … … 184 176 else 185 177 { 186 for (ItemSubtype hardwareType : hardwareTypeQuery.list(dc)) 178 %> 179 <option value="0">-none- 180 <% 181 for (ItemSubtype subtype : subtypesQuery.list(dc)) 187 182 { 188 int id = hardwareType.getId(); 183 int id = subtype.getId(); 184 if (id != currentSubtypeId && subtype.isRemoved()) continue; 189 185 %> 190 <option value="<%=id == currentHardwareTypeId && hardware != null ? -id : id%>" 191 <%=id == currentHardwareTypeId ? "selected" : ""%> 192 ><%=HTML.encodeTags(hardwareType.getName())%> 186 <option value="<%=id == currentSubtypeId && hardware != null ? -id : id%>" 187 <%=id == currentSubtypeId ? "selected" : ""%> 188 title="<%=HTML.encodeTags(subtype.getDescription()) %>" 189 ><%=HTML.encodeTags(subtype.getName())%> 193 190 <% 194 191 } … … 198 195 </td> 199 196 </tr> 200 197 <tr> 198 <td class="prompt">Version</td> 199 <td><input <%=clazz%> type="text" name="version" 200 value="<%=HTML.encodeTags(hardware == null ? cc.getPropertyValue("versionString") : hardware.getVersionString())%>" 201 size="40" maxlength="<%=Hardware.MAX_VERSIONSTRING_LENGTH%>"></td> 202 </tr> 201 203 <tr valign=top> 202 204 <td class="prompt">Description</td> -
trunk/www/admin/hardware/index.jsp
r5630 r5643 60 60 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> 61 61 <%! 62 private static final ItemContext defaultContext = Base.createDefaultContext("name", "name, version,itemSubtype,description");62 private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,itemSubtype,version,description"); 63 63 private static final Item itemType = Item.HARDWARE; 64 64 %> … … 153 153 hardware.setVersionString(Values.getStringOrNull(request.getParameter("version"))); 154 154 hardware.setDescription(Values.getStringOrNull(request.getParameter("description"))); 155 int hardwareTypeId = Values.getInt(request.getParameter("hardwaretype_id"), -1); 156 if (hardwareTypeId >= 0) // < 0 = denied or unchanged 155 156 int subtypeId = Values.getInt(request.getParameter("subtype_id"), -1); 157 if (subtypeId >= 0) // < 0 = denied or unchanged 157 158 { 158 ItemSubtype hwt = hardwareTypeId == 0 ? null : ItemSubtype.getById(dc, hardwareTypeId);159 hardware.setItemSubtype( hwt);160 if ( hwt != null) cc.setRecent(hwt, maxRecent);159 ItemSubtype subtype = subtypeId == 0 ? null : ItemSubtype.getById(dc, subtypeId); 160 hardware.setItemSubtype(subtype); 161 if (subtype != null) cc.setRecent(subtype, maxRecent); 161 162 } 162 163 -
trunk/www/admin/hardware/list_hardware.jsp
r5630 r5643 82 82 { 83 83 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 84 85 final ItemQuery<ItemSubtype> typeQuery = ItemSubtype.getQuery(Item.HARDWARE); 86 typeQuery.order(Orders.asc(Hql.property("name"))); 87 typeQuery.setCacheResult(true); 84 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); 88 85 89 86 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); … … 253 250 exportable="true" 254 251 /> 255 <%256 Enumeration<String, String> hardwareTypes = new Enumeration<String, String>();257 for (ItemSubtype st : typeQuery.list(dc))258 {259 hardwareTypes.add(Integer.toString(st.getId()), HTML.encodeTags(st.getName()));260 }261 %>262 252 <tbl:columndef 263 253 id="itemSubtype" … … 266 256 exportproperty="itemSubtype.name" 267 257 datatype="int" 268 enumeration="<%= hardwareTypes%>"258 enumeration="<%=Enumeration.fromItems(subtypesQuery.list(dc), "-none-")%>" 269 259 title="Type" 270 260 sortable="true" -
trunk/www/admin/hardware/view_hardware.jsp
r5630 r5643 242 242 </tr> 243 243 <tr> 244 <td class="prompt">Type</td> 245 <td><base:propertyvalue item="<%=hardware%>" property="itemSubtype" /></td> 246 </tr> 247 <tr> 244 248 <td class="prompt">Registered</td> 245 249 <td><%=dateFormatter.format(hardware.getEntryDate())%></td> 246 </tr>247 <tr>248 <td class="prompt">Type</td>249 <td><base:propertyvalue item="<%=hardware%>" property="itemSubtype" /></td>250 250 </tr> 251 251 <tr> -
trunk/www/admin/itemsubtypes/edit_subtype.jsp
r5631 r5643 160 160 } 161 161 %> 162 Main.showHide('section.none', related[mainType] == '') 162 163 } 163 164 … … 248 249 <tr> 249 250 <td class="prompt">Related subtypes</td> 250 <td>< /td>251 <td><div id="section.none" style="display: none;"><i>- none -</i></div></td> 251 252 </tr> 252 253 <% -
trunk/www/admin/protocols/edit_protocol.jsp
r5631 r5643 66 66 String title = null; 67 67 Protocol protocol = null; 68 boolean readCurrent ProtocolType = true;69 int current ProtocolTypeId = 0;68 boolean readCurrentSubtype = true; 69 int currentSubtypeId = 0; 70 70 boolean readCurrentFile = true; 71 71 File currentFile = null; … … 79 79 title = "Create protocol"; 80 80 81 current ProtocolTypeId = Values.getInt(request.getParameter("protocoltype_id"));82 if (current ProtocolTypeId == 0)83 { 84 int recent ProtocolTypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0));85 current ProtocolTypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentProtocolTypeId);81 currentSubtypeId = Values.getInt(request.getParameter("subtype_id")); 82 if (currentSubtypeId == 0) 83 { 84 int recentSubtypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0)); 85 currentSubtypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentSubtypeId); 86 86 } 87 87 cc.removeObject("item"); … … 90 90 { 91 91 protocol = Protocol.getById(dc, itemId); 92 protocol.checkPermission(Permission.WRITE); 93 92 94 parameterQuery = protocol.getParameters(); 93 95 cc.setObject("item", protocol); … … 95 97 try 96 98 { 97 ItemSubtype pt= protocol.getItemSubtype();98 if ( pt != null) currentProtocolTypeId = pt.getId();99 ItemSubtype subtype = protocol.getItemSubtype(); 100 if (subtype != null) currentSubtypeId = subtype.getId(); 99 101 } 100 102 catch (PermissionDeniedException ex) 101 103 { 102 readCurrent ProtocolType = false;104 readCurrentSubtype = false; 103 105 } 104 106 try … … 110 112 readCurrentFile = false; 111 113 } 112 }113 if (protocol != null && !protocol.hasPermission(Permission.WRITE))114 {115 throw new PermissionDeniedException(Permission.WRITE, itemType.toString());116 114 } 117 115 118 116 // Query to retrieve protocol types 119 final ItemQuery<ItemSubtype> protocolTypeQuery = ItemSubtype.getQuery(itemType); 120 protocolTypeQuery.include(Include.ALL); 121 protocolTypeQuery.order(Orders.asc(Hql.property("name"))); 117 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); 118 subtypesQuery.include(Include.ALL); 122 119 123 120 final String clazz = "class=\"text\""; … … 182 179 { 183 180 var frm = document.forms['protocol']; 184 var protocolType = Math.abs(frm.protocoltype_id[frm.protocoltype_id.selectedIndex].value);185 var relatedFileSubtype = ItemSubtype.getRelatedSubtype( protocolType, 'FILE', <%=SystemItems.getId(File.PROTOCOL)%>);186 var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SelectOne&title=Select+protocol &callback=setFileCallback';181 var subtype = Math.abs(frm.subtype_id[frm.subtype_id.selectedIndex].value); 182 var relatedFileSubtype = ItemSubtype.getRelatedSubtype(subtype, 'FILE', <%=SystemItems.getId(File.PROTOCOL)%>); 183 var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SelectOne&title=Select+protocol+file&callback=setFileCallback'; 187 184 url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=' + relatedFileSubtype.id; 188 185 if (frm.file_id.length > 1) 189 186 { 190 var id = Math.abs(parseInt(frm.file_id[1].value)); 187 var id = Math.abs(parseInt(frm.file_id[1].value)); 191 188 url += '&item_id='+id; 192 189 } … … 276 273 <td class="prompt">Type</td> 277 274 <td colspan="2"> 278 <select name=" protocoltype_id"279 <%=!readCurrent ProtocolType ? "disabled readonly class=\"disabled\"" : "class=\"required\""%>>275 <select name="subtype_id" 276 <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>> 280 277 <% 281 if (!readCurrent ProtocolType)278 if (!readCurrentSubtype) 282 279 { 283 280 %> … … 287 284 else 288 285 { 289 for (ItemSubtype protocolType : protocolTypeQuery.list(dc)) 286 %> 287 <option value="0">-none- 288 <% 289 for (ItemSubtype subtype : subtypesQuery.list(dc)) 290 290 { 291 int id = protocolType.getId();292 if (id != current ProtocolTypeId && protocolType.isRemoved()) continue;291 int id = subtype.getId(); 292 if (id != currentSubtypeId && subtype.isRemoved()) continue; 293 293 %> 294 <option value="<%=id == currentProtocolTypeId && protocol != null ? -id : id%>" 295 <%=id == currentProtocolTypeId ? "selected" : ""%> 296 ><%=HTML.encodeTags(protocolType.getName())%> 294 <option value="<%=id == currentSubtypeId && protocol != null ? -id : id%>" 295 <%=id == currentSubtypeId ? "selected" : ""%> 296 title="<%=HTML.encodeTags(subtype.getDescription()) %>" 297 ><%=HTML.encodeTags(subtype.getName())%> 297 298 <% 298 299 } -
trunk/www/admin/protocols/index.jsp
r5630 r5643 155 155 protocol.setDescription(Values.getStringOrNull(request.getParameter("description"))); 156 156 protocol.setExternalId(Values.getStringOrNull(request.getParameter("external_id"))); 157 int protocolTypeId = Values.getInt(request.getParameter("protocoltype_id"), -1);158 if ( protocolTypeId >= 0) // < 0 = denied or unchanged157 int subtypeId = Values.getInt(request.getParameter("subtype_id"), -1); 158 if (subtypeId >= 0) // < 0 = denied or unchanged 159 159 { 160 ItemSubtype pt = protocolTypeId == 0 ? null : ItemSubtype.getById(dc, protocolTypeId);161 protocol.setItemSubtype( pt);162 if ( pt != null) cc.setRecent(pt, maxRecent);160 ItemSubtype subtype = subtypeId == 0 ? null : ItemSubtype.getById(dc, subtypeId); 161 protocol.setItemSubtype(subtype); 162 if (subtype != null) cc.setRecent(subtype, maxRecent); 163 163 } 164 164 int fileId = Values.getInt(request.getParameter("file_id"), -1); -
trunk/www/admin/protocols/list_protocol.jsp
r5630 r5643 86 86 { 87 87 final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType); 88 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); 88 89 annotationTypes = annotationTypeQuery.list(dc); 89 90 90 91 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 91 92 final ItemQuery<Protocol> query = Base.getConfiguredQuery(dc, cc, true, Protocol.getQuery(), mode); 92 93 final ItemQuery<ItemSubtype> typeQuery = ItemSubtype.getQuery(itemType);94 typeQuery.order(Orders.asc(Hql.property("name")));95 typeQuery.setCacheResult(true);96 93 97 94 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); … … 251 248 formatter="<%=dateFormatter%>" 252 249 /> 253 <%254 Enumeration<String, String> protocolTypes = new Enumeration<String, String>();255 for (ItemSubtype pt : typeQuery.list(dc))256 {257 protocolTypes.add(Integer.toString(pt.getId()), HTML.encodeTags(pt.getName()));258 }259 %>260 250 <tbl:columndef 261 251 id="externalId" … … 273 263 exportproperty="itemSubtype.name" 274 264 datatype="int" 275 enumeration="<%= protocolTypes%>"265 enumeration="<%=Enumeration.fromItems(subtypesQuery.list(dc), "-none-")%>" 276 266 title="Type" 277 267 sortable="true" -
trunk/www/admin/software/edit_software.jsp
r5630 r5643 34 34 import="net.sf.basedb.core.ItemSubtype" 35 35 import="net.sf.basedb.core.ItemQuery" 36 import="net.sf.basedb.core.Include" 36 37 import="net.sf.basedb.core.ItemResultList" 37 38 import="net.sf.basedb.core.PermissionDeniedException" … … 61 62 String title = null; 62 63 Software software = null; 63 boolean readCurrentS oftwareType = true;64 int currentS oftwareTypeId = 0;64 boolean readCurrentSubtype = true; 65 int currentSubtypeId = 0; 65 66 66 67 if (itemId == 0) … … 68 69 title = "Create software"; 69 70 cc.removeObject("item"); 70 currentS oftwareTypeId = Values.getInt(request.getParameter("softwaretype_id"));71 if (currentS oftwareTypeId == 0)72 { 73 int recentS oftwareTypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0));74 currentS oftwareTypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentSoftwareTypeId);71 currentSubtypeId = Values.getInt(request.getParameter("subtype_id")); 72 if (currentSubtypeId == 0) 73 { 74 int recentSubtypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0)); 75 currentSubtypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentSubtypeId); 75 76 } 76 77 } … … 78 79 { 79 80 software = Software.getById(dc, itemId); 81 software.checkPermission(Permission.WRITE); 80 82 cc.setObject("item", software); 81 83 title = "Edit software -- " + HTML.encodeTags(software.getName()); 82 84 try 83 85 { 84 ItemSubtype s t= software.getItemSubtype();85 if (s t != null) currentSoftwareTypeId = st.getId();86 ItemSubtype subtype = software.getItemSubtype(); 87 if (subtype != null) currentSubtypeId = subtype.getId(); 86 88 } 87 89 catch (PermissionDeniedException ex) 88 90 { 89 readCurrentSoftwareType = false; 90 } 91 } 92 if (software != null && !software.hasPermission(Permission.WRITE)) 93 { 94 throw new PermissionDeniedException(Permission.WRITE, itemType.toString()); 91 readCurrentSubtype = false; 92 } 95 93 } 96 94 97 95 // Query to retrieve file types 98 final ItemQuery<ItemSubtype> softwareTypeQuery = ItemSubtype.getQuery(itemType); 99 softwareTypeQuery.order(Orders.asc(Hql.property("name"))); 96 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); 97 subtypesQuery.include(Include.ALL); 98 100 99 final String clazz = "class=\"text\""; 101 100 final String requiredClazz = "class=\"text required\""; … … 163 162 size="40" maxlength="<%=Software.MAX_NAME_LENGTH%>"></td> 164 163 </tr> 165 <tr>166 <td class="prompt">Version</td>167 <td><input <%=clazz%> type="text" name="version"168 value="<%=HTML.encodeTags(software == null ? cc.getPropertyValue("versionString") : software.getVersionString())%>"169 size="40" maxlength="<%=Software.MAX_VERSIONSTRING_LENGTH%>"></td>170 </tr>171 164 <tr valign="top"> 172 165 <td class="prompt">Type</td> 173 166 <td colspan="2"> 174 <select name="s oftwaretype_id"175 <%=!readCurrentS oftwareType ? "disabled readonly class=\"disabled\"" : "class=\"required\""%>>167 <select name="subtype_id" 168 <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>> 176 169 <% 177 if (!readCurrentS oftwareType)170 if (!readCurrentSubtype) 178 171 { 179 172 %> … … 183 176 else 184 177 { 185 for (ItemSubtype softwareType : softwareTypeQuery.list(dc)) 178 %> 179 <option value="0">-none- 180 <% 181 for (ItemSubtype subtype : subtypesQuery.list(dc)) 186 182 { 187 int id = softwareType.getId(); 183 int id = subtype.getId(); 184 if (id != currentSubtypeId && subtype.isRemoved()) continue; 188 185 %> 189 <option value="<%=id == currentSoftwareTypeId && software != null ? -id : id%>" 190 <%=softwareType.getId() == currentSoftwareTypeId ? "selected" : ""%> 191 ><%=HTML.encodeTags(softwareType.getName())%> 186 <option value="<%=id == currentSubtypeId && software != null ? -id : id%>" 187 <%=id == currentSubtypeId ? "selected" : ""%> 188 title="<%=HTML.encodeTags(subtype.getDescription()) %>" 189 ><%=HTML.encodeTags(subtype.getName())%> 192 190 <% 193 191 } … … 196 194 </select> 197 195 </td> 196 </tr> 197 <tr> 198 <td class="prompt">Version</td> 199 <td><input <%=clazz%> type="text" name="version" 200 value="<%=HTML.encodeTags(software == null ? cc.getPropertyValue("versionString") : software.getVersionString())%>" 201 size="40" maxlength="<%=Software.MAX_VERSIONSTRING_LENGTH%>"></td> 198 202 </tr> 199 203 -
trunk/www/admin/software/index.jsp
r5630 r5643 60 60 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> 61 61 <%! 62 private static final ItemContext defaultContext = Base.createDefaultContext("name", "name, version,itemSubtype,description");62 private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,itemSubtype,version,description"); 63 63 private static final Item itemType = Item.SOFTWARE; 64 64 %> … … 153 153 software.setVersionString(Values.getStringOrNull(request.getParameter("version"))); 154 154 software.setDescription(Values.getStringOrNull(request.getParameter("description"))); 155 int softwareTypeId = Values.getInt(request.getParameter("softwaretype_id"), -1); 156 if (softwareTypeId >= 0) // < 0 = denied or unchanged 155 156 int subtypeId = Values.getInt(request.getParameter("subtype_id"), -1); 157 if (subtypeId >= 0) // < 0 = denied or unchanged 157 158 { 158 ItemSubtype s wt = softwareTypeId == 0 ? null : ItemSubtype.getById(dc, softwareTypeId);159 software.setItemSubtype(s wt);160 if (s wt != null) cc.setRecent(swt, maxRecent);159 ItemSubtype subtype = subtypeId == 0 ? null : ItemSubtype.getById(dc, subtypeId); 160 software.setItemSubtype(subtype); 161 if (subtype != null) cc.setRecent(subtype, maxRecent); 161 162 } 162 163 -
trunk/www/admin/software/list_software.jsp
r5630 r5643 82 82 { 83 83 Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 84 85 final ItemQuery<ItemSubtype> typeQuery = ItemSubtype.getQuery(itemType); 86 typeQuery.order(Orders.asc(Hql.property("name"))); 87 typeQuery.setCacheResult(true); 84 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); 88 85 89 86 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); … … 253 250 exportable="true" 254 251 /> 255 <%256 Enumeration<String, String> softwareTypes = new Enumeration<String, String>();257 for (ItemSubtype st : typeQuery.list(dc))258 {259 softwareTypes.add(Integer.toString(st.getId()), HTML.encodeTags(st.getName()));260 }261 %>262 252 <tbl:columndef 263 253 id="itemSubtype" … … 266 256 exportproperty="itemSubtype.name" 267 257 datatype="int" 268 enumeration="<%= softwareTypes%>"258 enumeration="<%=Enumeration.fromItems(subtypesQuery.list(dc), "-none-")%>" 269 259 title="Type" 270 260 sortable="true" -
trunk/www/admin/software/view_software.jsp
r5630 r5643 241 241 </tr> 242 242 <tr> 243 <td class="prompt">Type</td> 244 <td><base:propertyvalue item="<%=software%>" property="itemSubtype" /></td> 245 </tr> 246 <tr> 243 247 <td class="prompt">Registered</td> 244 248 <td><%=dateFormatter.format(software.getEntryDate())%></td> 245 </tr>246 <tr>247 <td class="prompt">Type</td>248 <td><base:propertyvalue item="<%=software%>" property="itemSubtype" /></td>249 249 </tr> 250 250 <tr> -
trunk/www/biomaterials/biosources/edit_biosource.jsp
r5492 r5643 33 33 import="net.sf.basedb.core.Permission" 34 34 import="net.sf.basedb.core.BioSource" 35 import="net.sf.basedb.core.ItemSubtype" 36 import="net.sf.basedb.core.ItemQuery" 37 import="net.sf.basedb.core.Include" 35 38 import="net.sf.basedb.core.PermissionDeniedException" 36 39 import="net.sf.basedb.core.BaseException" … … 61 64 String title = null; 62 65 BioSource bioSource = null; 66 boolean readCurrentSubtype = true; 67 int currentSubtypeId = 0; 63 68 64 69 if (itemId == 0) … … 66 71 title = "Create biosource"; 67 72 cc.removeObject("item"); 73 74 currentSubtypeId = Values.getInt(request.getParameter("subtype_id")); 75 if (currentSubtypeId == 0) 76 { 77 int recentSubtypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0)); 78 currentSubtypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentSubtypeId); 79 } 68 80 } 69 81 else 70 82 { 71 83 bioSource = BioSource.getById(dc, itemId); 84 bioSource.checkPermission(Permission.WRITE); 85 72 86 cc.setObject("item", bioSource); 73 87 title = "Edit biosource -- " + HTML.encodeTags(bioSource.getName()); 88 89 try 90 { 91 ItemSubtype subtype = bioSource.getItemSubtype(); 92 if (subtype != null) currentSubtypeId = subtype.getId(); 93 } 94 catch (PermissionDeniedException ex) 95 { 96 readCurrentSubtype = false; 97 } 98 74 99 } 75 if (bioSource != null && !bioSource.hasPermission(Permission.WRITE)) 76 { 77 throw new PermissionDeniedException(Permission.WRITE, itemType.toString()); 78 } 100 101 // Query to retrieve item types 102 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); 103 subtypesQuery.include(Include.ALL); 104 79 105 final String clazz = "class=\"text\""; 80 106 final String requiredClazz = "class=\"text required\""; … … 158 184 value="<%=HTML.encodeTags(bioSource == null ? Values.getString(cc.getPropertyValue("name"), "New biosource") : bioSource.getName())%>" 159 185 size="40" maxlength="<%=BioSource.MAX_NAME_LENGTH%>"></td> 186 </tr> 187 <tr valign="top"> 188 <td class="prompt">Type</td> 189 <td colspan="2"> 190 <select name="subtype_id" 191 <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>> 192 <% 193 if (!readCurrentSubtype) 194 { 195 %> 196 <option value="-1">- denied - 197 <% 198 } 199 else 200 { 201 %> 202 <option value="0">-none- 203 <% 204 for (ItemSubtype subtype : subtypesQuery.list(dc)) 205 { 206 int id = subtype.getId(); 207 if (id != currentSubtypeId && subtype.isRemoved()) continue; 208 %> 209 <option value="<%=id == currentSubtypeId && bioSource != null ? -id : id%>" 210 <%=id == currentSubtypeId ? "selected" : ""%> 211 title="<%=HTML.encodeTags(subtype.getDescription()) %>" 212 ><%=HTML.encodeTags(subtype.getName())%> 213 <% 214 } 215 } 216 %> 217 </select> 218 </td> 160 219 </tr> 161 220 <tr> -
trunk/www/biomaterials/biosources/index.jsp
r5590 r5643 30 30 import="net.sf.basedb.core.Include" 31 31 import="net.sf.basedb.core.BioSource" 32 import="net.sf.basedb.core.ItemSubtype" 32 33 import="net.sf.basedb.core.ItemQuery" 33 34 import="net.sf.basedb.core.ItemResultIterator" … … 67 68 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> 68 69 <%! 69 private static final ItemContext defaultContext = Base.createDefaultContext("name", "name, samples,description");70 private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,itemSubtype,samples,description"); 70 71 private static final Item itemType = Item.BIOSOURCE; 71 72 … … 153 154 // Update the properties on an item (will close the popup) 154 155 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); 156 final int maxRecent = Base.getMaxRecent(sc); 155 157 dc = sc.newDbControl(); 156 158 BioSource bioSource = (BioSource)cc.getObject("item"); … … 173 175 bioSource.setDescription(Values.getStringOrNull(request.getParameter("description"))); 174 176 bioSource.setExternalId(Values.getStringOrNull(request.getParameter("external_id"))); 177 178 int subtypeId = Values.getInt(request.getParameter("subtype_id"), -1); 179 if (subtypeId >= 0) // < 0 = denied or unchanged 180 { 181 ItemSubtype subtype = subtypeId == 0 ? null : ItemSubtype.getById(dc, subtypeId); 182 bioSource.setItemSubtype(subtype); 183 if (subtype != null) cc.setRecent(subtype, maxRecent); 184 } 175 185 176 186 // Annotations tab -
trunk/www/biomaterials/biosources/list_biosources.jsp
r5426 r5643 31 31 import="net.sf.basedb.core.Sample" 32 32 import="net.sf.basedb.core.AnnotationType" 33 import="net.sf.basedb.core.ItemSubtype" 33 34 import="net.sf.basedb.core.AnnotationSet" 34 35 import="net.sf.basedb.core.Annotation" … … 89 90 { 90 91 final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType); 92 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); 93 91 94 final ItemQuery<Sample> sampleQuery = Sample.getQuery(); 92 95 sampleQuery.include(cc.getInclude()); … … 243 246 exportable="true" 244 247 show="always" 248 /> 249 <tbl:columndef 250 id="itemSubtype" 251 property="itemSubtype" 252 sortproperty="itemSubtype.name" 253 exportproperty="itemSubtype.name" 254 datatype="int" 255 enumeration="<%=Enumeration.fromItems(subtypesQuery.list(dc), "-none-")%>" 256 title="Type" 257 sortable="true" 258 filterable="true" 259 exportable="true" 245 260 /> 246 261 <tbl:columndef … … 524 539 title="<%=tooltip%>"><%=name%></div></tbl:cell> 525 540 <tbl:cell column="id"><%=item.getId()%></tbl:cell> 541 <tbl:cell column="itemSubtype"><base:propertyvalue 542 item="<%=item%>" 543 property="itemSubtype" 544 enableEditLink="<%=mode.hasEditLink()%>" 545 enablePropertyLink="<%=mode.hasPropertyLink()%>" 546 /></tbl:cell> 526 547 <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell> 527 548 <tbl:cell column="samples"> -
trunk/www/biomaterials/biosources/view_biosource.jsp
r5496 r5643 276 276 <td class="prompt">Name</td> 277 277 <td><%=HTML.encodeTags(bioSource.getName())%></td> 278 </tr> 279 <tr> 280 <td class="prompt">Type</td> 281 <td><base:propertyvalue item="<%=bioSource%>" property="itemSubtype" /></td> 278 282 </tr> 279 283 <tr> -
trunk/www/filemanager/files/edit_file.jsp
r5630 r5643 39 39 import="net.sf.basedb.core.Location" 40 40 import="net.sf.basedb.core.ItemQuery" 41 import="net.sf.basedb.core.Include" 41 42 import="net.sf.basedb.core.ItemResultList" 42 43 import="net.sf.basedb.core.PermissionDeniedException" … … 72 73 File file = null; 73 74 Directory directory = null; 74 boolean readCurrent FileType = true;75 int current FileTypeId = 0;75 boolean readCurrentSubtype = true; 76 int currentSubtypeId = 0; 76 77 boolean readCurrentFileServer = true; 77 78 FileServer currentFileServer = null; … … 81 82 { 82 83 title = "Create file"; 83 currentFileTypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), 0); 84 if (currentFileTypeId == 0) 85 { 86 currentFileTypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0), 0); 84 currentSubtypeId = Values.getInt(request.getParameter("subtype_id")); 85 if (currentSubtypeId == 0) 86 { 87 int recentSubtypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0)); 88 currentSubtypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentSubtypeId); 87 89 } 88 90 if (cc.getPropertyFilter("fileServer.name") != null) … … 97 99 { 98 100 file = File.getById(dc, itemId); 101 file.checkPermission(Permission.WRITE); 102 99 103 directory = file.getDirectory(); 100 104 cc.setObject("item", file); … … 102 106 try 103 107 { 104 ItemSubtype ft= file.getItemSubtype();105 if ( ft != null) currentFileTypeId = ft.getId();108 ItemSubtype subtype = file.getItemSubtype(); 109 if (subtype != null) currentSubtypeId = subtype.getId(); 106 110 } 107 111 catch (PermissionDeniedException ex) 108 112 { 109 readCurrent FileType = false;113 readCurrentSubtype = false; 110 114 } 111 115 try … … 117 121 readCurrentFileServer = false; 118 122 } 119 }120 if (file != null && !file.hasPermission(Permission.WRITE))121 {122 throw new PermissionDeniedException(Permission.WRITE, itemType.toString());123 123 } 124 124 125 125 // Query to retrieve file types 126 final ItemQuery<ItemSubtype> fileTypeQuery = ItemSubtype.getQuery(itemType); 127 fileTypeQuery.order(Orders.asc(Hql.property("name"))); 128 fileTypeQuery.setCacheResult(true); 126 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); 127 subtypesQuery.include(Include.ALL); 129 128 130 129 final String clazz = "class=\"text\""; … … 292 291 <td class="prompt">Type</td> 293 292 <td colspan="2"> 294 <select name="filetype_id" <%=!readCurrentFileType ? "disabled readonly class=\"disabled\"" : ""%>> 293 <select name="subtype_id" 294 <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>> 295 295 <% 296 if (!readCurrent FileType)296 if (!readCurrentSubtype) 297 297 { 298 298 %> … … 303 303 { 304 304 %> 305 <option value="0">- none-305 <option value="0">-none- 306 306 <% 307 ItemResultList<ItemSubtype> fileTypes = fileTypeQuery.list(dc); 308 for (ItemSubtype fileType : fileTypes) 307 for (ItemSubtype subtype : subtypesQuery.list(dc)) 309 308 { 310 int id = fileType.getId(); 309 int id = subtype.getId(); 310 if (id != currentSubtypeId && subtype.isRemoved()) continue; 311 311 %> 312 <option 313 value="<%=file != null && id == currentFileTypeId ? -id : id%>"314 <%=id == currentFileTypeId ? "selected" : ""%>315 ><%=HTML.encodeTags( fileType.getName())%>312 <option value="<%=id == currentSubtypeId && file != null ? -id : id%>" 313 <%=id == currentSubtypeId ? "selected" : ""%> 314 title="<%=HTML.encodeTags(subtype.getDescription()) %>" 315 ><%=HTML.encodeTags(subtype.getName())%> 316 316 <% 317 317 } -
trunk/www/filemanager/files/index.jsp
r5630 r5643 197 197 file.setCharacterSet(Values.getStringOrNull(request.getParameter("characterSet"))); 198 198 file.setWriteProtected(Values.getBoolean(request.getParameter("write_protected"), false)); 199 int fileTypeId = Values.getInt(request.getParameter("filetype_id"), -1);200 if (fileTypeId >= 0) // < 0 = denied or unchanged201 {202 ItemSubtype ft = fileTypeId == 0 ? null : ItemSubtype.getById(dc, fileTypeId);203 file.setItemSubtype(ft);204 if (ft != null) cc.setRecent(ft, maxRecent);205 }206 199 file.setDescription(Values.getStringOrNull(request.getParameter("description"))); 200 201 int subtypeId = Values.getInt(request.getParameter("subtype_id"), -1); 202 if (subtypeId >= 0) // < 0 = denied or unchanged 203 { 204 ItemSubtype subtype = subtypeId == 0 ? null : ItemSubtype.getById(dc, subtypeId); 205 file.setItemSubtype(subtype); 206 if (subtype != null) cc.setRecent(subtype, maxRecent); 207 } 208 207 209 if (file.getLocation() == Location.EXTERNAL) 208 210 { -
trunk/www/filemanager/files/list_files.jsp
r5630 r5643 106 106 107 107 // Get all file types 108 final ItemQuery<ItemSubtype> typeQuery = ItemSubtype.getQuery(itemType); 109 typeQuery.order(Orders.asc(Hql.property("name"))); 110 typeQuery.setCacheResult(true); 108 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); 111 109 112 110 // Create directory query … … 584 582 exportable="true" 585 583 /> 586 <%587 Enumeration<String, String> fileTypes = new Enumeration<String, String>();588 fileTypes.add("", "- none -");589 for (ItemSubtype ft : typeQuery.list(dc))590 {591 fileTypes.add(Integer.toString(ft.getId()), ft.getName());592 }593 %>594 584 <tbl:columndef 595 585 id="itemSubtype" … … 598 588 exportproperty="itemSubtype.name" 599 589 datatype="int" 600 enumeration="<%= fileTypes%>"590 enumeration="<%=Enumeration.fromItems(subtypesQuery.list(dc), "-none-")%>" 601 591 title="Type" 602 592 sortable="true" -
trunk/www/filemanager/upload/select.jsp
r5630 r5643 75 75 File file = null; 76 76 Directory directory = null; 77 boolean readCurrent FileType = true;78 int current FileTypeId = 0;77 boolean readCurrentSubtype = true; 78 int currentSubtypeId = 0; 79 79 Boolean compress = Application.autoCompressionEnabled() ? null : false; // null == auto 80 80 … … 82 82 { 83 83 title = "Upload new file"; 84 current FileTypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), 0);85 if (current FileTypeId == 0)86 { 87 current FileTypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0), 0);84 currentSubtypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), 0); 85 if (currentSubtypeId == 0) 86 { 87 currentSubtypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0), 0); 88 88 } 89 89 directory = Directory.getById(dc, Values.getInt(request.getParameter("directory_id"), SystemItems.getId(Directory.ROOT))); … … 94 94 { 95 95 file = File.getById(dc, itemId); 96 file.checkPermission(Permission.WRITE); 97 96 98 directory = file.getDirectory(); 97 99 cc.setObject("item", file); … … 99 101 try 100 102 { 101 ItemSubtype ft= file.getItemSubtype();102 if ( ft != null) currentFileTypeId = ft.getId();103 ItemSubtype subtype = file.getItemSubtype(); 104 if (subtype != null) currentSubtypeId = subtype.getId(); 103 105 } 104 106 catch (PermissionDeniedException ex) 105 107 { 106 readCurrentFileType = false; 107 } 108 } 109 if (file != null && !file.hasPermission(Permission.WRITE)) 110 { 111 throw new PermissionDeniedException(Permission.WRITE, itemType.toString()); 108 readCurrentSubtype = false; 109 } 112 110 } 113 111 … … 128 126 129 127 // Query to retrieve file types 130 final ItemQuery<ItemSubtype> fileTypeQuery = ItemSubtype.getQuery(itemType); 131 fileTypeQuery.order(Orders.asc(Hql.property("name"))); 132 fileTypeQuery.setCacheResult(true); 128 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); 129 subtypesQuery.include(Include.ALL); 133 130 134 131 // Query to retreive FileUnpacker plugins … … 183 180 } 184 181 frm.characterSet.value = frm.temp_charset[frm.temp_charset.selectedIndex].value; 185 frm. filetype_id.value = frm.temp_filetype_id[frm.temp_filetype_id.selectedIndex].value;182 frm.subtype_id.value = frm.temp_subtype_id[frm.temp_subtype_id.selectedIndex].value; 186 183 frm.description.value = frm.temp_description.value; 187 184 frm.submit(); … … 378 375 <input type="hidden" name="zip_overwrite" value="0"> 379 376 <input type="hidden" name="zip_keep" value="1"> 380 <input type="hidden" name=" filetype_id" value="">377 <input type="hidden" name="subtype_id" value=""> 381 378 <input type="hidden" name="description" value=""> 382 379 <input type="hidden" name="characterSet" value=""> … … 450 447 <td class="prompt">Type</td> 451 448 <td colspan="2"> 452 <select name="temp_filetype_id" <%=!readCurrentFileType ? "disabled readonly class=\"disabled\"" : ""%>> 449 <select name="temp_subtype_id" 450 <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>> 453 451 <% 454 if (!readCurrent FileType)452 if (!readCurrentSubtype) 455 453 { 456 454 %> … … 463 461 <option value="0">- none - 464 462 <% 465 ItemResultList<ItemSubtype> fileTypes = fileTypeQuery.list(dc); 466 for (ItemSubtype fileType : fileTypes) 463 for (ItemSubtype subtype : subtypesQuery.list(dc)) 467 464 { 468 int id = fileType.getId();469 boolean current = id == current FileTypeId;465 int id = subtype.getId(); 466 boolean current = id == currentSubtypeId; 470 467 %> 471 468 <option 472 469 value="<%=current && file != null ? -id : id%>" 473 470 <%=current ? "selected" : ""%> 474 ><%=HTML.encodeTags(fileType.getName())%> 471 title="<%=HTML.encodeTags(subtype.getDescription())%>" 472 ><%=HTML.encodeTags(subtype.getName())%> 475 473 <% 476 474 } -
trunk/www/include/scripts/table.js
r5111 r5643 411 411 } 412 412 413 /**414 Initialise the columns list of the quick filter415 @param tableId The ID attribute of the table tag416 @param property The filter property value of the currently selected column417 @param value The current filter value418 */419 this.initQuickFilter = function(tableId, property, value)420 {421 var frm = document.forms[tableId];422 var quickcolumn = frm.quickcolumn;423 var selectedIndex = 0;424 frm.quickvalue.value = value;425 for (var i = 0; i < this.columns.length; i++)426 {427 var col = this.columns[i];428 if (col.dataType && col.visible)429 {430 selectedIndex = col.filterProperty == property ? quickcolumn.length : selectedIndex;431 quickcolumn[quickcolumn.length] = new Option(col.title, col.filterProperty, false, false);432 }433 }434 quickcolumn.selectedIndex = selectedIndex;435 if (!this.columns['prop'+property] && quickcolumn.length > 0) property = quickcolumn[0].value;436 this.quickColumnOnChange(tableId, property, value);437 }438 439 var oldType;440 // Update the displayed filter depending on the dataType of the selected column441 this.quickColumnOnChange = function(tableId, property, value)442 {443 var column = this.columns['prop'+property];444 var dataType = column.dataType;445 var frm = document.forms[tableId];446 frm.quickcolumn_type.value = dataType;447 frm.quickcolumn_collection.value = column.isCollection ? 1 : 0;448 if (oldType) Main.hide(oldType);449 if (column.enumeration)450 {451 frm.quickvalue_enum.length = 0;452 frm.quickvalue_enum[frm.quickvalue_enum.length] = new Option();453 for (var i = 0; i < column.enumeration.length; i++) // >454 {455 frm.quickvalue_enum[frm.quickvalue_enum.length] = new Option(column.enumeration[i].text, column.enumeration[i].value);456 }457 if (value != undefined) Forms.selectListOption(frm.quickvalue_enum, value);458 oldType = 'enum';459 }460 else461 {462 if (dataType == 'string')463 {464 oldType = 'string';465 if (value != undefined) frm.quickvalue_string.value = value;466 }467 else if (dataType == 'int')468 {469 oldType = 'int';470 if (value != undefined) frm.quickvalue_int.value = value;471 }472 else if (dataType == 'long')473 {474 oldType = 'long';475 if (value != undefined) frm.quickvalue_long.value = value;476 }477 else if (dataType == 'float')478 {479 oldType = 'float';480 if (value != undefined) frm.quickvalue_float.value = value;481 }482 else if (dataType == 'double')483 {484 oldType = 'double';485 if (value != undefined) frm.quickvalue_double.value = value;486 }487 else if (dataType == 'date')488 {489 oldType = 'date';490 if (value != undefined) frm.quickvalue_date.value = value;491 }492 else if (dataType == 'boolean')493 {494 oldType = 'boolean';495 Forms.checkRadio(frm.quickvalue_boolean, value);496 }497 }498 Main.showInline(oldType);499 }500 501 this.setQuickValue = function(frm, value)502 {503 frm.quickvalue.value = value;504 frm.submit();505 }506 413 507 414 this.itemOnClick = function(tableId, evt, itemId, mode, viewFunction, editFunction, returnFunction) … … 545 452 } 546 453 547 function Column(id, title, property, sortProperty, filterProperty, exportProperty, dataType, isCollection, isAnnotation, visible, alwaysShow, alwaysHide, sortable, filterable, exportable , enumeration)454 function Column(id, title, property, sortProperty, filterProperty, exportProperty, dataType, isCollection, isAnnotation, visible, alwaysShow, alwaysHide, sortable, filterable, exportable) 548 455 { 549 456 this.id = id; … … 562 469 this.filterable = filterable; 563 470 this.exportable = exportable; 564 this.enumeration = enumeration;565 471 } 566 472 -
trunk/www/include/styles/main.css
r5599 r5643 203 203 } 204 204 205 .selectionlist select {205 .selectionlist select, select.selectionlist { 206 206 width: 20em; 207 207 }
Note: See TracChangeset
for help on using the changeset viewer.