Changeset 7579 for branches/3.14-stable


Ignore:
Timestamp:
Jan 14, 2019, 9:10:17 AM (3 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #2146: Exclude some annotation type categories from selection list when editing annotations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.14-stable/www/common/annotations/annotate.jsp

    r7578 r7579  
    4141  import="net.sf.basedb.core.RawBioAssay"
    4242  import="net.sf.basedb.core.RawDataType"
     43  import="net.sf.basedb.core.RawDataTypes"
    4344  import="net.sf.basedb.core.AnnotationSet"
    4445  import="net.sf.basedb.core.Annotation"
     
    199200    new TreeSet<AnnotationTypeCategory>(new NameableComparator(false));
    200201 
     202  // Load all ItemSubtypes that are NOT related to the current item type
     203  // We need this to get rid of annotation type categories that are not intended
     204  // for the current item type
     205  Set<String> excludedCategories = new HashSet<>();
     206  ItemQuery<ItemSubtype> query = ItemSubtype.getQuery(null);
     207  query.restrict(Restrictions.neq(Hql.property("itemType"), Expressions.integer(itemType.getValue())));
     208  for (ItemSubtype s : query.list(dc))
     209  {
     210    excludedCategories.add(s.getName());
     211  }
     212  // Raw data types are also used as subtypes
     213  if (itemType != Item.RAWBIOASSAY)
     214  {
     215    for (RawDataType rdt : RawDataTypes.getRawDataTypes())
     216    {
     217      excludedCategories.add(rdt.getName());
     218    }
     219  }
     220 
    201221  // Load existing annotations
    202222  AnnotationSet as = null;
     
    560580          {
    561581            boolean selected = category.getName().equals(selectedCategoryName);
     582            if (!selected && excludedCategories.contains(category.getName())) continue;
    562583            %>
    563584            <option value="<%=category.getId()%>"
Note: See TracChangeset for help on using the changeset viewer.