Changeset 7860
- Timestamp:
- Oct 20, 2020, 3:30:21 PM (3 years ago)
- Location:
- trunk/src/core/net/sf/basedb/util/overview
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/util/overview/loader/AnnotationLoader.java
r7859 r7860 55 55 { 56 56 57 /** 58 Get the annotatable item from the node. This is in most cases 59 the {@link Node#getItem()} item, but can also be the target 60 item of an {@link AnyToAny} node or the file of a {@link FileSetMember} 61 node. 62 @since 3.17 63 */ 64 public static Annotatable getAnnotatableFromNode(DbControl dc, Node node) 65 { 66 Annotatable annotatable = null; 67 Item nodeType = node.getItemType(); 68 try 69 { 70 if (nodeType == Item.ANYTOANY) 71 { 72 // The parent item is the 'to' target of the any-to-any 73 AnyToAny any = (AnyToAny)node.getItem(dc); 74 annotatable = (Annotatable)any.getTo(); 75 } 76 else if (nodeType == Item.FILESETMEMBER) 77 { 78 // The parent item is the 'file' item 79 FileSetMember member = (FileSetMember)node.getItem(dc); 80 annotatable = member.getFile(); 81 } 82 else 83 { 84 annotatable = (Annotatable)node.getItem(dc); 85 } 86 } 87 catch (PermissionDeniedException ex) 88 {} 89 return annotatable; 90 } 91 57 92 public AnnotationLoader() 58 93 { … … 68 103 { 69 104 NodeFactory<Annotation> nf = getNodeFactory(dc, context); 70 Annotatable parent = null; 71 Item parentNodeType = parentNode.getItemType(); 72 try 73 { 74 if (parentNodeType == Item.ANYTOANY) 75 { 76 // The parent item is the 'to' target of the any-to-any 77 AnyToAny any = (AnyToAny)parentNode.getItem(dc); 78 parent = (Annotatable)any.getTo(); 79 } 80 else if (parentNodeType == Item.FILESETMEMBER) 81 { 82 // The parent item is the 'file' item 83 FileSetMember member = (FileSetMember)parentNode.getItem(dc); 84 parent = member.getFile(); 85 } 86 else 87 { 88 parent = (Annotatable)parentNode.getItem(dc); 89 } 90 } 91 catch (PermissionDeniedException ex) 92 {} 105 Annotatable parent = getAnnotatableFromNode(dc, parentNode); 93 106 94 107 Node folderNode = null; -
trunk/src/core/net/sf/basedb/util/overview/validator/AnnotationValidator.java
r6960 r7860 48 48 import net.sf.basedb.util.overview.Validator; 49 49 import net.sf.basedb.util.overview.filter.ItemTypeFilter; 50 import net.sf.basedb.util.overview.loader.AnnotationLoader; 50 51 51 52 /** … … 88 89 super.postValidate(dc, context, node, parentNode); 89 90 if (parentNode.getNodeType() == Node.Type.FOLDER) parentNode = parentNode.getParent(); 90 Annotatable parent = (Annotatable)parentNode.getItem(dc); 91 Item parentItemType = parentNode.getItemType(); 91 Annotatable parent = AnnotationLoader.getAnnotatableFromNode(dc, parentNode); 92 if (parent == null) return; 93 94 Item parentItemType = parent.getType(); 92 95 93 96 Annotation a = (Annotation)node.getItem(dc); … … 221 224 { 222 225 super.postValidateFolder(dc, context, folderNode, parentNode); 223 Annotatable parent = (Annotatable)parentNode.getItem(dc); 226 Annotatable parent = AnnotationLoader.getAnnotatableFromNode(dc, parentNode); 227 if (parent == null) return; 228 Item parentItemType = parent.getType(); 224 229 225 230 // Check for 'Required by MIAME' annotations and duplicates 226 Set<AnnotationType> miame = OverviewUtil.getMiameAnnotationTypes(dc, context, parent Node.getItemType());231 Set<AnnotationType> miame = OverviewUtil.getMiameAnnotationTypes(dc, context, parentItemType); 227 232 Set<AnnotationType> all = new HashSet<AnnotationType>(); 228 233 Map<AnnotationType, Annotation> duplicates = new HashMap<AnnotationType, Annotation>(); … … 249 254 context.createFailure(Validator.ANNOTATION_INHERIT_MULTIPLE, parentNode, 250 255 "Duplicate annotations of type '" + dup.getKey().getName() + "'", 251 new Fix("Modify annotations", parentNode.getItem(), dup.getValue())256 new Fix("Modify annotations", (BasicItem)parent, dup.getValue()) 252 257 ); 253 258 }
Note: See TracChangeset
for help on using the changeset viewer.