Changeset 7859


Ignore:
Timestamp:
Oct 20, 2020, 1:35:21 PM (14 months ago)
Author:
Nicklas Nordborg
Message:

References #2224: Files should be annotatable

Updated the "Item overview" functionality to include annotations for file items. File items are either included as "data files" or as the the target in any-to-any links.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/overview/loader/AnnotationLoader.java

    r6939 r7859  
    2727import net.sf.basedb.core.Annotatable;
    2828import net.sf.basedb.core.Annotation;
     29import net.sf.basedb.core.AnyToAny;
    2930import net.sf.basedb.core.DbControl;
     31import net.sf.basedb.core.FileSetMember;
    3032import net.sf.basedb.core.Item;
    3133import net.sf.basedb.core.PermissionDeniedException;
     
    6668  {
    6769    NodeFactory<Annotation> nf = getNodeFactory(dc, context);
    68     Annotatable parent = (Annotatable)parentNode.getItem(dc);
     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    {}
     93
    6994    Node folderNode = null;
    70     if (parent.isAnnotated())
     95    if (parent != null && parent.isAnnotated())
    7196    {
    7297      // Load the protocol, if any, so that we can ignore annotations
  • trunk/src/core/net/sf/basedb/util/overview/loader/AnyToAnyLoader.java

    r6959 r7859  
    2323
    2424
     25import net.sf.basedb.core.Annotatable;
    2526import net.sf.basedb.core.AnyToAny;
    2627import net.sf.basedb.core.BasicItem;
     
    8586      }
    8687      AnyToAny any = it.next();
    87       createItemNode(nf, any, null, false, folderNode, ChildNodeDirection.NONE);
     88      boolean annotatableTarget = Annotatable.class.isAssignableFrom(any.getToType().getItemClass());
     89      createItemNode(nf, any, null, false, folderNode, annotatableTarget ? ChildNodeDirection.PROPERTY : ChildNodeDirection.NONE);
    8890    }
    8991    postValidateFolder(nf, folderNode, parentNode, false);
     
    9193  }
    9294  // --------------------------------
     95  /**
     96    Loads property nodes of an any-to-any node.
     97    <ul>
     98    <li>Annotations: {@link AnnotationLoader#createPropertyNode(DbControl, OverviewContext, Node)}
     99    </ul>
     100    @since 3.17
     101  */
     102  @Override
     103  protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node anyNode)
     104  {
     105    getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, anyNode);
     106  }
     107 
    93108}
  • trunk/src/core/net/sf/basedb/util/overview/loader/DataFileLoader.java

    r6959 r7859  
    9797      for (FileSetMember member : files)
    9898      {
    99         createItemNode(nf, member, member, false, folderNode, ChildNodeDirection.NONE);
     99        createItemNode(nf, member, member, false, folderNode, ChildNodeDirection.PROPERTY);
    100100      }
    101101    }
     
    104104  }
    105105  // -----------------------------------
    106  
     106  /**
     107    Loads property nodes of files.
     108    <ul>
     109    <li>Annotations: {@link AnnotationLoader#createPropertyNode(DbControl, OverviewContext, Node)}
     110    </ul>
     111    @since 3.17
     112  */
     113  @Override
     114  protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node memberNode)
     115  {
     116    getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, memberNode);
     117  }
     118
    107119}
  • trunk/www/common/overview/info.jsp

    r7855 r7859  
    138138 
    139139  BasicItem item = node.getItem(dc);
     140  BasicItem annotationsItem = item;
    140141  List<Failure> failures = overview.getFailures();
    141142  if (failures == null) failures = new LinkedList<Failure>();
     
    215216          {
    216217            file = member.getFile();
     218            annotationsItem = file;
    217219          }
    218220          catch (PermissionDeniedException ex)
     
    261263        {
    262264          BasicItem to = any.getTo();
     265          annotationsItem = to;
    263266          String name = to instanceof Nameable ? ((Nameable)to).getName() : to.toString();
    264267          linkTo = Base.getLink(ID, HTML.encodeTags(name),
     
    381384      String annotationsTitle = "";
    382385      Annotatable annotatable = null;
    383       if (item instanceof Annotation)
    384       {
    385         Annotation a = Annotation.getById(dc, item.getId());
     386      if (annotationsItem instanceof Annotation)
     387      {
     388        Annotation a = Annotation.getById(dc, annotationsItem.getId());
    386389        AnnotationSetSnapshot snapshot = snapshotManager.getSnapshot(dc, a.getAnnotationSet().getId());
    387390        annotationFilter.setAnnotation(a);
     
    402405        annotationsTitle = "Annotation values";
    403406      }
    404       else if (item instanceof AnnotationType)
     407      else if (annotationsItem instanceof AnnotationType)
    405408      {
    406409        // Find the annotatable parent
     
    423426        }
    424427      }
    425       else if (item instanceof Annotatable)
     428      else if (annotationsItem instanceof Annotatable)
    426429      {
    427430        annotationsTitle = "Annotations &amp; protocol parameters";
    428         annotatable = (Annotatable)item.getType().getById(dc, item.getId());
     431        annotatable = (Annotatable)annotationsItem.getType().getById(dc, annotationsItem.getId());
    429432        if (annotatable.isAnnotated())
    430433        {
Note: See TracChangeset for help on using the changeset viewer.