Changeset 5721
- Timestamp:
- Sep 6, 2011, 3:39:13 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/util/overview/OverviewUtil.java
r5689 r5721 120 120 Validator.DATAFILE_INVALID, Validator.DATAFILE_NOTVALIDATED, 121 121 Validator.MISSING_DATAFILE, Validator.DATAFILE_NOTPLATFORM, 122 Validator.DATAFILE_TOOMANYFILES, 122 123 Validator.DATAFILE_INVALID_ITEM, Validator.DENIED_DATAFILETYPE, 123 124 Validator.DENIED_FILE -
trunk/src/core/net/sf/basedb/util/overview/Validator.java
r5651 r5721 748 748 749 749 /** 750 Validator rule that checks if a ll files required by the platform751 a re presentor not. Default severity level is WARNING.750 Validator rule that checks if a file is registered with 751 a platform/item subtype or not. Default severity level is WARNING. 752 752 */ 753 753 public static final Validator DATAFILE_NOTPLATFORM = new Validator( 754 "datafile.notplatform", "File is not used by platform", 755 "Checks that all data files are used by the current platform.", 756 "File is not used by platform", Severity.WARNING 754 "datafile.notplatform", "File is not used by platform/subtype", 755 "Checks that all data files are used by the current platform/subtype.", 756 "File is not used by platform/subtype", Severity.WARNING 757 ); 758 759 /** 760 Validator rule that checks if there are more than one file 761 of a file type that doesn't allow multiple files. Default 762 severity level is WARNING. 763 @since 3.0 764 */ 765 public static final Validator DATAFILE_TOOMANYFILES = new Validator( 766 "datafile.toomanyfiles", "Too many files", 767 "Checks if an item has too many files of a type that doesn't " + 768 "allow more than one file.", 769 "Too many files", Severity.WARNING 757 770 ); 758 771 -
trunk/src/core/net/sf/basedb/util/overview/validator/DataFileValidator.java
r5713 r5721 22 22 package net.sf.basedb.util.overview.validator; 23 23 24 import java.util.List; 25 24 26 import net.sf.basedb.core.BasicItem; 25 27 import net.sf.basedb.core.DataFileType; 26 28 import net.sf.basedb.core.DbControl; 27 29 import net.sf.basedb.core.File; 30 import net.sf.basedb.core.FileSet; 28 31 import net.sf.basedb.core.FileSetMember; 29 32 import net.sf.basedb.core.FileStoreEnabled; 30 33 import net.sf.basedb.core.ItemQuery; 31 import net.sf.basedb.core.ItemResultIterator; 34 import net.sf.basedb.core.ItemSubtype; 35 import net.sf.basedb.core.ItemSubtypeFileType; 32 36 import net.sf.basedb.core.PermissionDeniedException; 33 37 import net.sf.basedb.core.Platform; 34 38 import net.sf.basedb.core.PlatformFileType; 35 39 import net.sf.basedb.core.PlatformVariant; 36 import net.sf.basedb.core.Type; 40 import net.sf.basedb.core.Subtypable; 41 import net.sf.basedb.core.UsableDataFileType; 37 42 import net.sf.basedb.core.query.Expressions; 38 43 import net.sf.basedb.core.query.Hql; 39 import net.sf.basedb.core.query.Restriction;40 44 import net.sf.basedb.core.query.Restrictions; 41 45 import net.sf.basedb.util.overview.Fix; … … 58 62 <li>File type doesn't match parent item type: {@link Validator#DATAFILE_INVALID_ITEM} 59 63 <li>File type is not part of used platform: {@link Validator#DATAFILE_NOTPLATFORM} 64 <li>Too many files of a single-file file type: {@link Validator#DATAFILE_TOOMANYFILES} 60 65 <li>Missing a required file: {@link Validator#MISSING_DATAFILE} 61 66 </ul> … … 141 146 } 142 147 143 // Check that the file type is part of the used platform/variant 148 // Check that the file type is part of the used platform/variant/subtype 144 149 try 145 150 { … … 161 166 pvName = platform.getName(); 162 167 } 163 // TODO #1604 164 /* 165 if (platform.getFileType(fileType, variant) == null) 168 if (platform.getFileType(fileType, variant, false) == null) 166 169 { 167 170 context.createFailure(Validator.DATAFILE_NOTPLATFORM, node, … … 172 175 ); 173 176 } 174 */ 177 } 178 else if (parentItem instanceof Subtypable) 179 { 180 ItemSubtype subtype = ((Subtypable)parentItem).getItemSubtype(); 181 if (subtype != null) 182 { 183 if (subtype.getAssociatedDataFileType(fileType, false) == null) 184 { 185 context.createFailure(Validator.DATAFILE_NOTPLATFORM, node, 186 fileType.getName() + " can't be used with '" + subtype.getName() + "' subtype", 187 new Fix("Remove '" + fileType.getName() + "' from " + parentItem.getType().toString().toLowerCase(), 188 (BasicItem)parentItem, fileType), 189 new Fix("Add '" + fileType.getName() +"' to '" + subtype.getName() + "' subtype", subtype, fileType) 190 ); 191 } 192 } 175 193 } 176 194 } … … 197 215 198 216 // Check that we have linked a file for all file types that 199 // are required by the platform 217 // are required by the platform and that the multiplicity setting 218 // is ok 200 219 try 201 220 { 202 221 Platform platform = parentItem.getPlatform(); 203 222 PlatformVariant variant = parentItem.getVariant(); 204 BasicItem pvItem = variant != null ? variant : platform; 205 if (platform == null) return; 206 207 // Create a query that returns all required platform file types 208 ItemQuery<PlatformFileType> query = platform.getFileTypes(variant, variant == null); 209 query.join(Hql.innerJoin("dataFileType", "dft")); 210 query.restrict( 211 Restrictions.eq( 212 Hql.property("required"), 213 Expressions.parameter("isRequired", true, Type.BOOLEAN) 214 ) 215 ); 216 query.restrict( 217 Restrictions.eq( 218 Hql.property("dft", "itemType"), 219 Expressions.integer(parentNode.getItemType().getValue()) 220 ) 221 ); 222 if (parentItem.hasFileSet()) 223 { 224 // Add a restriction that filters out the files that we already have 225 Restriction myFileSet = Restrictions.eq(Hql.property("mbr", "fileSet.id"), 226 Hql.entity(parentItem.getFileSet())); 227 query.join(Hql.leftJoin("dft", "fileSetMembers", "mbr", myFileSet, false)); 228 query.restrict(Restrictions.eq(Hql.alias("mbr"), null)); 229 } 230 ItemResultIterator<PlatformFileType> it = query.iterate(dc); 231 while (it.hasNext()) 232 { 233 PlatformFileType pft = it.next(); 234 DataFileType dft = pft.getDataFileType(); 235 context.createFailure(Validator.MISSING_DATAFILE, parentNode, 236 "Missing '" + dft.getName() + "'", 237 new Fix("Add '" + dft.getName() + "' to " + parentItem.getType().toString().toLowerCase(), 238 (BasicItem)parentItem, dft), 239 new Fix("Remove 'Required' flag from '" + dft.getName() + "'", pvItem, dft) 240 ); 223 BasicItem pvItem = null; 224 ItemSubtype subtype = parentItem instanceof Subtypable ? 225 ((Subtypable)parentItem).getItemSubtype() : null; 226 // List for holding all file types defined by the platform or subtype 227 List<? extends UsableDataFileType> fileTypes = null; 228 if (platform != null) 229 { 230 pvItem = variant != null ? variant : platform; 231 // Create a query that returns all required platform file types 232 ItemQuery<PlatformFileType> query = platform.getFileTypes(variant, variant == null); 233 query.join(Hql.innerJoin("dataFileType", "dft")); 234 query.restrict( 235 Restrictions.eq( 236 Hql.property("dft", "itemType"), 237 Expressions.integer(parentNode.getItemType().getValue()) 238 ) 239 ); 240 fileTypes = query.list(dc); 241 } 242 if (subtype != null) 243 { 244 pvItem = subtype; 245 // Create a query that returns all required subtype file types 246 ItemQuery<ItemSubtypeFileType> query = subtype.getDataFileTypes(); 247 query.join(Hql.innerJoin("dataFileType", "dft")); 248 query.restrict( 249 Restrictions.eq( 250 Hql.property("dft", "itemType"), 251 Expressions.integer(parentNode.getItemType().getValue()) 252 ) 253 ); 254 fileTypes = query.list(dc); 255 } 256 FileSet fs = parentItem.hasFileSet() ? parentItem.getFileSet() : null; 257 for (UsableDataFileType fileType : fileTypes) 258 { 259 DataFileType dft = fileType.getDataFileType(); 260 int numMembers = fs == null ? 0 : fs.getNumMembers(dft); 261 if (fileType.isRequired() && numMembers == 0) 262 { 263 context.createFailure(Validator.MISSING_DATAFILE, parentNode, 264 "Missing '" + dft.getName() + "'", 265 new Fix("Add '" + dft.getName() + "' to " + parentItem.getType().toString().toLowerCase(), 266 (BasicItem)parentItem, dft), 267 new Fix("Remove 'Required' flag from '" + dft.getName() + "'", pvItem, dft) 268 ); 269 } 270 if (!fileType.getAllowMultiple() && numMembers > 1) 271 { 272 context.createFailure(Validator.DATAFILE_TOOMANYFILES, parentNode, 273 "Too many files: '" + dft.getName() + "'", 274 new Fix("Remove '" + dft.getName() + "' from " + parentItem.getType().toString().toLowerCase(), 275 (BasicItem)parentItem, dft), 276 new Fix("Check 'Allow multiple files' on '" + dft.getName() + "'", pvItem, dft) 277 ); 278 } 241 279 } 242 280 } -
trunk/www/views/derivedbioassays/edit_bioassay.jsp
r5714 r5721 60 60 final SessionControl sc = Base.getExistingSessionControl(pageContext, true); 61 61 final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); 62 final String tabId = Values.getString(request.getParameter("tab"), null); 62 63 final int itemId = cc.getId(); 63 64 final String ID = sc.getId(); … … 672 673 <form action="index.jsp?ID=<%=ID%>" method="post" name="bioAssay" onsubmit="return false;"> 673 674 <input type="hidden" name="cmd" value="UpdateItem"> 674 675 675 <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3> 676 676 <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*370)+"px;"%>" 677 position="bottom" remember="<%=bioAssay != null%>" switch="switchTab"677 position="bottom" active="<%=tabId%>" remember="<%=tabId == null && bioAssay != null%>" switch="switchTab" 678 678 extensions="<%=invoker%>"> 679 679 <t:tab id="info" title="Bioassay" validate="validateBioAssay()" helpid="derivedbioassay.edit"> -
trunk/www/views/derivedbioassays/index.jsp
r5687 r5721 154 154 // Display the edit page for a single item (should be opened in a popup) 155 155 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 156 redirect= editPage;156 forward = editPage; 157 157 } 158 158 else if ("NewItem".equals(cmd))
Note: See TracChangeset
for help on using the changeset viewer.