Changeset 6738


Ignore:
Timestamp:
Feb 17, 2015, 9:30:41 AM (7 years ago)
Author:
Nicklas Nordborg
Message:

References #1325: Lists of items (similar funcion as biomaterial lists)

Added ItemList as a new item type for holding lists of any type of items. In principle, the underlying implementation can store any type of items, but since we need to support this in the GUI as well, the Listable interface was introduced as a tagging interface for items that we want to put in lists. The initial items type supporting this:

  • Biomaterial (Biosource, Sample, Extract)
  • Bioassays (Physical, Derived and Raw)
  • Files

Adding support for more item types is not difficult, but requires some work in the GUI.

I don't know yet how to handle the "old" BioMaterialList. There is a lot of existing functionality when it comes to working with biomaterial lists and creating lists with parent or child items.

The new funcationality can replace this and it would be relatively easy to transfer existing biomaterial lists to item lists, but API-wise it would introduce a lot of binary incompatibilities. But keeping the biomaterial lists as a separate functionality is not a very good idea either, so maybe it's worth to break the binary compatibility in this case...

Location:
trunk/src/core/net/sf/basedb/core
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/BioMaterial.java

    r6127 r6738  
    4343public abstract class BioMaterial<D extends BioMaterialData>
    4444  extends AnnotatedItem<D>
    45   implements Subtypable
     45  implements Subtypable, Listable
    4646{
    4747
  • trunk/src/core/net/sf/basedb/core/DerivedBioAssay.java

    r6540 r6738  
    5555public class DerivedBioAssay
    5656  extends AnnotatedItem<DerivedBioAssayData>
    57   implements Registered, FileStoreEnabled, Subtypable
     57  implements Registered, FileStoreEnabled, Subtypable, Listable
    5858{
    5959
  • trunk/src/core/net/sf/basedb/core/File.java

    r6520 r6738  
    8080public class File
    8181  extends CommonItem<FileData>
    82   implements Transactional, DiskConsumable, Subtypable
     82  implements Transactional, DiskConsumable, Subtypable, Listable
    8383{
    8484  /**
  • trunk/src/core/net/sf/basedb/core/Item.java

    r6355 r6738  
    219219  ANYTOANY(143, "Any-to-any link", "ata", AnyToAny.class, AnyToAnyData.class, null,
    220220    10),
    221    
     221 
     222  /**
     223    The item is an {@link ItemList}
     224  */
     225  ITEMLIST(148, "Item list", "ils", ItemList.class, ItemListData.class, DefinedPermissions.shareable,
     226      11),
     227
    222228  /**
    223229    The item is a {@link ChangeHistory} entry.
     
    665671  private final Set<Permission> definedPermissions;
    666672  private final transient Method getById;
     673  private final transient Method getQuery;
    667674  private final transient Constructor<? extends BasicItem> constructor;
    668675  private final float deletionOrder;
     
    682689    Method tempGetById = null;
    683690    Constructor<? extends BasicItem> tempConstructor = null;
     691    Method tempGetQuery = null;
    684692    if (itemClass != null)
    685693    {
     
    696704      catch (NoSuchMethodException ex)
    697705      {}
     706      try
     707      {
     708        tempGetQuery = itemClass.getDeclaredMethod("getQuery");
     709      }
     710      catch (NoSuchMethodException ex)
     711      {}
    698712    }
    699713    getById = tempGetById;
     714    getQuery = tempGetQuery;
    700715    constructor = tempConstructor;
    701716  }
     
    823838
    824839  /**
     840    Check if {@link #getQuery()} is supported by this
     841    item type.
     842    @since 3.5
     843  */
     844  public boolean supportsGetQuery()
     845  {
     846    return getQuery != null;
     847  }
     848 
     849  /**
     850    Get a query returning items of this type. This method is supported by
     851    items that declare a static parameterless <code>getQuery()</code> method in their
     852    item class (eg. {@link Sample#getQuery()}.
     853    @since 3.5
     854  */
     855  @SuppressWarnings("unchecked")
     856  public ItemQuery<? extends BasicItem> getQuery()
     857  {
     858    if (getQuery == null)
     859    {
     860      throw new UnsupportedOperationException(getItemClass().getName()+".getQuery()");
     861    }
     862    else
     863    {
     864      try
     865      {
     866        return (ItemQuery<? extends BasicItem>)getQuery.invoke(null);
     867      }
     868      catch (Throwable ex)
     869      {
     870        Throwable cause = ex.getCause();
     871        if (cause instanceof BaseException)
     872        {
     873          throw (BaseException)cause;
     874        }
     875        else if (cause != null)
     876        {
     877          throw new BaseException(cause);
     878        }
     879        else
     880        {
     881          throw new BaseException(ex);
     882        }
     883      }
     884    }
     885  }
     886 
     887  /**
    825888    Get the default constructor for new objects of this type. The
    826889    default constructor is a constructor that takes a
  • trunk/src/core/net/sf/basedb/core/PhysicalBioAssay.java

    r6328 r6738  
    4545public class PhysicalBioAssay
    4646  extends AnnotatedItem<PhysicalBioAssayData>
    47   implements Registered, Subtypable
     47  implements Registered, Subtypable, Listable
    4848{
    4949  /**
  • trunk/src/core/net/sf/basedb/core/RawBioAssay.java

    r6468 r6738  
    6565public class RawBioAssay
    6666  extends AnnotatedItem<RawBioAssayData>
    67   implements DiskConsumable, FileStoreEnabled, Registered
     67  implements DiskConsumable, FileStoreEnabled, Registered, Listable
    6868{
    6969  /**
Note: See TracChangeset for help on using the changeset viewer.