Changeset 6959


Ignore:
Timestamp:
Oct 1, 2015, 11:37:58 AM (6 years ago)
Author:
Nicklas Nordborg
Message:

References #1941: Store experimental factor values as part experiments

The "Item overview" functionality now load "root raw bioassays" instead of "raw bioassays" when going up from the experiment level. This change is needed so that experimental factor values can be found. The loading then skips the actual raw bioassay item. This change causes lots of other loaders/validators to fail since the are expecting or looking for a raw bioassay. Those have been updated so that they can work with either a root raw bioassay or a raw bioassay.

Location:
trunk/src/core/net/sf/basedb/util/overview
Files:
1 added
16 edited

Legend:

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

    r6870 r6959  
    2929import net.sf.basedb.core.ItemQuery;
    3030import net.sf.basedb.core.ItemResultIterator;
     31import net.sf.basedb.core.RootRawBioAssay;
    3132import net.sf.basedb.util.overview.OverviewContext;
    3233import net.sf.basedb.util.overview.node.AnyToAnyNameGenerator;
     
    6768    // Load all any-to-any links for the give item
    6869    BasicItem parent = parentNode.getItem(dc);
     70    if (parent instanceof RootRawBioAssay)
     71    {
     72      // The parent may be a root raw bioasay if the overview starts at the
     73      // experiment level
     74      parent = ((RootRawBioAssay)parent).getRawBioAssay();
     75    }
     76
    6977    ItemQuery<AnyToAny> query = context.initQuery(AnyToAny.getLinksFrom(parent), "name");
    7078
  • trunk/src/core/net/sf/basedb/util/overview/loader/ArrayDesignLoader.java

    r5500 r6959  
    2424import net.sf.basedb.core.ArrayBatch;
    2525import net.sf.basedb.core.ArrayDesign;
     26import net.sf.basedb.core.BasicItem;
    2627import net.sf.basedb.core.DbControl;
    2728import net.sf.basedb.core.Item;
    2829import net.sf.basedb.core.PermissionDeniedException;
    2930import net.sf.basedb.core.RawBioAssay;
     31import net.sf.basedb.core.RootRawBioAssay;
    3032import net.sf.basedb.util.overview.OverviewContext;
    3133import net.sf.basedb.util.overview.node.ChildNodeDirection;
     
    8183  }
    8284  /**
    83     Create an array design property node from a raw bioassay node.
    84     @return An array design node, or null if the batch doesn't have a design
     85    Create an array design property node from a raw bioassay or
     86    root raw bioassay node.
     87    @return An array design node, or null if the raw bioassay doesn't have a design
    8588  */
    8689  @Override
    87   public Node createPropertyNode(DbControl dc, OverviewContext context, Node rawBioAssayNode)
     90  public Node createPropertyNode(DbControl dc, OverviewContext context, Node parentNode)
    8891  {
    8992    NodeFactory<ArrayDesign> nf = getNodeFactory(dc, context);
     
    9295    try
    9396    {
    94       design = ((RawBioAssay)rawBioAssayNode.getItem(dc)).getArrayDesign();
     97      BasicItem parentItem = parentNode.getItem(dc);
     98      if (parentItem instanceof RootRawBioAssay)
     99      {
     100        // The parent may be a root raw bioasay if the overview starts at the
     101        // experiment level
     102        parentItem = ((RootRawBioAssay)parentItem).getRawBioAssay();
     103      }
     104      if (parentItem instanceof RawBioAssay)
     105      {
     106        RawBioAssay rba = (RawBioAssay)parentItem;
     107        design = rba.getArrayDesign();
     108      }
    95109    }
    96110    catch (PermissionDeniedException ex)
     
    99113    }
    100114    Node designNode = createItemNode(nf, design, design, denied,
    101         rawBioAssayNode, ChildNodeDirection.PROPERTY);
     115        parentNode, ChildNodeDirection.PROPERTY);
    102116    return designNode;
    103117  }
  • trunk/src/core/net/sf/basedb/util/overview/loader/BasicItemNodeLoaderFactory.java

    r6875 r6959  
    227227    registerCheckedNodeLoader(Item.DERIVEDBIOASSAY, DerivedBioAssayLoader.class);
    228228    registerCheckedNodeLoader(Item.RAWBIOASSAY, RawBioAssayLoader.class);
     229    registerCheckedNodeLoader(Item.ROOTRAWBIOASSAY, RootRawBioAssayLoader.class);
    229230    registerCheckedNodeLoader(Item.EXPERIMENT, ExperimentLoader.class);
    230231    registerCheckedNodeLoader(Item.BIOPLATE, BioPlateLoader.class);
  • trunk/src/core/net/sf/basedb/util/overview/loader/DataFileLoader.java

    r4750 r6959  
    3131import net.sf.basedb.core.Item;
    3232import net.sf.basedb.core.ItemQuery;
     33import net.sf.basedb.core.RootRawBioAssay;
    3334import net.sf.basedb.util.overview.OverviewContext;
    3435import net.sf.basedb.util.overview.node.ChildNodeDirection;
     
    6768    Node folderNode = null;
    6869
    69     FileStoreEnabled parent = (FileStoreEnabled)parentNode.getItem(dc);
     70    Item parentType = parentNode.getItemType();
     71    FileStoreEnabled parent = null;
     72    if (parentType == Item.ROOTRAWBIOASSAY)
     73    {
     74      // The parent may be a root raw bioasay if the overview starts at the
     75      // experiment level
     76      RootRawBioAssay root = (RootRawBioAssay)parentNode.getItem(dc);
     77      parent = root.getRawBioAssay();
     78    }
     79    else
     80    {
     81      parent = (FileStoreEnabled)parentNode.getItem(dc);
     82    }
     83   
    7084    if (parent.hasFileSet())
    7185    {
  • trunk/src/core/net/sf/basedb/util/overview/loader/DerivedBioAssayLoader.java

    r6755 r6959  
    3535import net.sf.basedb.core.PhysicalBioAssay;
    3636import net.sf.basedb.core.RawBioAssay;
     37import net.sf.basedb.core.RootRawBioAssay;
    3738import net.sf.basedb.core.Type;
    3839import net.sf.basedb.core.query.Expressions;
     
    121122    {
    122123      returnNode = createReverseNode((RawBioAssay)parentNode.getItem(dc), dc, context, parentNode);
     124    }
     125    else if (parentType == Item.ROOTRAWBIOASSAY)
     126    {
     127      RootRawBioAssay root = (RootRawBioAssay)parentNode.getItem(dc);
     128      returnNode = createReverseNode(root.getRawBioAssay(), dc, context, parentNode);
    123129    }
    124130    return returnNode;
  • trunk/src/core/net/sf/basedb/util/overview/loader/ExperimentLoader.java

    r5966 r6959  
    104104 
    105105  /**
    106     Loads the raw bioassay nodes that are part of this experiment
     106    Loads the root raw bioassay nodes that are part of this experiment
    107107    @see RawBioAssayLoader#createReverseNode(DbControl, OverviewContext, Node)
    108108  */
     
    110110  protected void loadReverseChildNodes(DbControl dc, OverviewContext context, Node experimentNode)
    111111  {
    112     getNodeLoader(context, Item.RAWBIOASSAY).createReverseNode(dc, context, experimentNode);
     112    getNodeLoader(context, Item.ROOTRAWBIOASSAY).createReverseNode(dc, context, experimentNode);
    113113  }
    114114  // --------------------------------
  • trunk/src/core/net/sf/basedb/util/overview/loader/ExtractLoader.java

    r6799 r6959  
    3737import net.sf.basedb.core.ItemResultIterator;
    3838import net.sf.basedb.core.RawBioAssay;
     39import net.sf.basedb.core.RootRawBioAssay;
    3940import net.sf.basedb.core.Sample;
    4041import net.sf.basedb.core.Type;
     
    148149      returnNode = createReverseNode((RawBioAssay)parentNode.getItem(dc), dc, context, parentNode);
    149150    }
     151    else if (parentItem == Item.ROOTRAWBIOASSAY)
     152    {
     153      returnNode = createReverseNode(((RootRawBioAssay)parentNode.getItem(dc)).getRawBioAssay(), dc, context, parentNode);
     154    }
    150155    return returnNode;
    151156  }
  • trunk/src/core/net/sf/basedb/util/overview/loader/PlatformLoader.java

    r6520 r6959  
    3030import net.sf.basedb.core.PlatformVariant;
    3131import net.sf.basedb.core.RawBioAssay;
     32import net.sf.basedb.core.RootRawBioAssay;
    3233import net.sf.basedb.util.overview.Node;
    3334import net.sf.basedb.util.overview.OverviewContext;
     
    7071    {
    7172      BasicItem parentItem = parentNode.getItem(dc);
     73      if (parentItem instanceof RootRawBioAssay)
     74      {
     75        // The parent may be a root raw bioasay if the overview starts at the
     76        // experiment level
     77        parentItem = ((RootRawBioAssay)parentItem).getRawBioAssay();
     78      }
    7279      if (parentItem instanceof RawBioAssay)
    7380      {
  • trunk/src/core/net/sf/basedb/util/overview/loader/ProtocolLoader.java

    r6210 r6959  
    2929import net.sf.basedb.core.PermissionDeniedException;
    3030import net.sf.basedb.core.Protocol;
     31import net.sf.basedb.core.RootRawBioAssay;
    3132import net.sf.basedb.util.overview.Node;
    3233import net.sf.basedb.util.overview.OverviewContext;
     
    6768    {
    6869      BasicItem parentItem = parentNode.getItem(dc);
     70      if (parentItem instanceof RootRawBioAssay)
     71      {
     72        // The parent may be a root raw bioasay if the overview starts at the
     73        // experiment level
     74        parentItem = ((RootRawBioAssay)parentItem).getRawBioAssay();
     75      }
    6976      if (parentItem instanceof Annotatable)
    7077      {
  • trunk/src/core/net/sf/basedb/util/overview/loader/SoftwareLoader.java

    r6334 r6959  
    2828import net.sf.basedb.core.PermissionDeniedException;
    2929import net.sf.basedb.core.RawBioAssay;
     30import net.sf.basedb.core.RootRawBioAssay;
    3031import net.sf.basedb.core.Software;
    3132import net.sf.basedb.util.overview.Node;
     
    6768    {
    6869      BasicItem parentItem = parentNode.getItem(dc);
     70      if (parentItem instanceof RootRawBioAssay)
     71      {
     72        // The parent may be a root raw bioasay if the overview starts at the
     73        // experiment level
     74        parentItem = ((RootRawBioAssay)parentItem).getRawBioAssay();
     75      }
    6976      if (parentItem instanceof RawBioAssay)
    7077      {
  • trunk/src/core/net/sf/basedb/util/overview/validator/AnnotationValidator.java

    r6939 r6959  
    258258   
    259259    // Check for missing experimental factor values (if we have an experiment in the parent path)
    260     if (parentNode.getItemType() == Item.RAWBIOASSAY)
     260    if (parentNode.getItemType() == Item.ROOTRAWBIOASSAY)
    261261    {
    262262      Node experimentNode = parentNode.getFirstParent(new ItemTypeFilter(Item.EXPERIMENT));
     
    271271          if (!all.contains(factor))
    272272          {
    273             Fix fix = factor.isEnabledForItem(Item.RAWBIOASSAY) ?
     273            Fix fix = factor.isEnabledForItem(Item.ROOTRAWBIOASSAY) ?
    274274              new Fix("Add value to experimental factor", (BasicItem)parent, factor, false) :
    275275              new Fix("Inherit annotation from a parent item", (BasicItem)parent, factor, true);
  • trunk/src/core/net/sf/basedb/util/overview/validator/ArrayDesignValidator.java

    r5814 r6959  
    3434import net.sf.basedb.core.Project;
    3535import net.sf.basedb.core.RawBioAssay;
     36import net.sf.basedb.core.RootRawBioAssay;
    3637import net.sf.basedb.util.overview.Fix;
    3738import net.sf.basedb.util.overview.OverviewContext;
     
    8586    // Check that a raw bioassay has same "direct" array desing as
    8687    // via physical bioassay->slide...
    87     if (parentNode != null && parentNode.getItemType() == Item.RAWBIOASSAY)
     88    Item parentType = parentNode.getItemType();
     89    if (parentNode != null && (parentType == Item.RAWBIOASSAY || parentType == Item.ROOTRAWBIOASSAY))
    8890    {
    89       RawBioAssay rba = (RawBioAssay)parentNode.getItem(dc);
     91      RawBioAssay rba = parentType == Item.RAWBIOASSAY ? (RawBioAssay)parentNode.getItem(dc) : ((RootRawBioAssay)parentNode.getItem()).getRawBioAssay();
    9092      try
    9193      {
  • trunk/src/core/net/sf/basedb/util/overview/validator/BasicItemNodeValidatorFactory.java

    r6875 r6959  
    4646{
    4747 
    48   private final Map<Object, Class<? extends NodeValidator<? extends BasicItem>>> validators;
     48  private final Map<Object, Class<?>> validators;
    4949  private boolean useNullValidator;
    5050  private boolean disabled;
     
    5555  public BasicItemNodeValidatorFactory()
    5656  {
    57     validators = new HashMap<Object, Class<? extends NodeValidator<? extends BasicItem>>>();
     57    validators = new HashMap<Object, Class<?>>();
    5858    this.useNullValidator = true;
    5959    this.disabled = false;
     
    9090    @return A node validator object
    9191  */
     92  @SuppressWarnings("unchecked")
    9293  @Override
    9394  public NodeValidator<? extends BasicItem> createNodeValidator(Object key)
    9495  {
    9596    NodeValidator<? extends BasicItem> validator = null;
    96     Class<? extends NodeValidator<? extends BasicItem>> validatorClass =
     97    Class<?> validatorClass =
    9798      disabled ? null : validators.get(key);
    9899    if (validatorClass == null)
     
    111112      try
    112113      {
    113         validator = validatorClass.newInstance();
     114        validator = (NodeValidator<BasicItem>)validatorClass.newInstance();
    114115      }
    115116      catch (Exception ex)
     
    172173  */
    173174  protected void registerCheckedNodeValidator(Object key,
    174       Class<? extends NodeValidator<? extends BasicItem>> validatorClass)
     175      Class<?> validatorClass)
    175176  {
    176177    if (validatorClass == null)
     
    201202    registerCheckedNodeValidator(Item.DERIVEDBIOASSAY, DerivedBioAssayValidator.class);
    202203    registerCheckedNodeValidator(Item.RAWBIOASSAY, RawBioAssayValidator.class);
     204    registerCheckedNodeValidator(Item.ROOTRAWBIOASSAY, RawBioAssayValidator.class);
    203205    registerCheckedNodeValidator(Item.EXPERIMENT, ExperimentValidator.class);
    204206    registerCheckedNodeValidator(Item.BIOPLATE, BioPlateValidator.class);
  • trunk/src/core/net/sf/basedb/util/overview/validator/DataFileValidator.java

    r6089 r6959  
    3939import net.sf.basedb.core.PlatformFileType;
    4040import net.sf.basedb.core.PlatformVariant;
     41import net.sf.basedb.core.RootRawBioAssay;
    4142import net.sf.basedb.core.Subtypable;
    4243import net.sf.basedb.core.UsableDataFileType;
     
    9192    // The parent node is either a folder (if we have more than one file)
    9293    // or the actual parent (for a single file)
    93     FileStoreEnabled parentItem = (FileStoreEnabled)(parentNode.getNodeType() == Node.Type.FOLDER ?
    94         parentNode.getParent().getItem(dc) : parentNode.getItem(dc));
     94    BasicItem parentItem = parentNode.getNodeType() == Node.Type.FOLDER ?
     95        parentNode.getParent().getItem(dc) : parentNode.getItem(dc);
     96    if (parentItem instanceof RootRawBioAssay)
     97    {
     98      // The parent may be a root raw bioasay if the overview starts at the
     99      // experiment level
     100      parentItem = ((RootRawBioAssay)parentItem).getRawBioAssay();
     101    }
     102    FileStoreEnabled fileStoreItem = (FileStoreEnabled)parentItem;
    95103   
    96104    // Check that we have access to the file and it's file type
     
    124132      errorMsg += " is not valid: " + member.getErrorMessage();
    125133      context.createFailure(Validator.DATAFILE_INVALID, node, errorMsg,
    126         new Fix("Select another file", (BasicItem)parentItem, member)
     134        new Fix("Select another file", parentItem, member)
    127135      );
    128136    }
     
    135143        context.createFailure(Validator.DATAFILE_NOTVALIDATED, node,
    136144          fileType.getName() + " has not been validated",
    137           new Fix("Validate the file / Select another file", (BasicItem)parentItem, member));
     145          new Fix("Validate the file / Select another file", parentItem, member));
    138146      }
    139147
     
    143151        context.createFailure(Validator.DATAFILE_INVALID_ITEM, node,
    144152          "Data file '" + fileType.getName() + "' can't be used on item type: " + parentItem.getType(),
    145           new Fix("Remove file", (BasicItem)parentItem, member)
     153          new Fix("Remove file", parentItem, member)
    146154        );
    147155      }
     
    150158      try
    151159      {
    152         Platform platform = parentItem.getPlatform();
    153         PlatformVariant variant = parentItem.getVariant();
     160        Platform platform = fileStoreItem.getPlatform();
     161        PlatformVariant variant = fileStoreItem.getVariant();
    154162        if (platform != null)
    155163        {
     
    213221  {
    214222    super.postValidateFolder(dc, context, folderNode, parentNode);
    215     FileStoreEnabled parentItem = (FileStoreEnabled)parentNode.getItem(dc);
     223    BasicItem parentItem = parentNode.getItem(dc);
     224    if (parentItem instanceof RootRawBioAssay)
     225    {
     226      // The parent may be a root raw bioasay if the overview starts at the
     227      // experiment level
     228      parentItem = ((RootRawBioAssay)parentItem).getRawBioAssay();
     229    }
     230    FileStoreEnabled fileStoreItem = (FileStoreEnabled)parentItem;
    216231   
    217232    // Check that we have linked a file for all file types that
     
    220235    try
    221236    {
    222       Platform platform = parentItem.getPlatform();
    223       PlatformVariant variant = parentItem.getVariant();
     237      Platform platform = fileStoreItem.getPlatform();
     238      PlatformVariant variant = fileStoreItem.getVariant();
    224239      BasicItem pvItem = null;
    225240      ItemSubtype subtype = parentItem instanceof Subtypable ?
     
    236251          Restrictions.eq(
    237252            Hql.property("dft", "itemType"),
    238             Expressions.integer(parentNode.getItemType().getValue())
     253            Expressions.integer(parentItem.getType().getValue())
    239254          )
    240255        );
     
    250265          Restrictions.eq(
    251266            Hql.property("dft", "itemType"),
    252             Expressions.integer(parentNode.getItemType().getValue())
     267            Expressions.integer(parentItem.getType().getValue())
    253268          )
    254269        );
    255270        fileTypes = query.list(dc);
    256271      }
    257       FileSet fs = parentItem.hasFileSet() ? parentItem.getFileSet() : null;
     272      FileSet fs = fileStoreItem.hasFileSet() ? fileStoreItem.getFileSet() : null;
    258273      for (UsableDataFileType fileType : fileTypes)
    259274      {
  • trunk/src/core/net/sf/basedb/util/overview/validator/ExtractValidator.java

    r6799 r6959  
    8484  */
    8585  /**
    86     Do not report missing items if the parent node is a derived or raw bioassay.
     86    Do not report missing items if the parent node is a derived or (root) raw bioassay.
    8787   */
    8888  @Override
     
    9090  {
    9191    Item parentType = parentNode.getItemType();
    92     if (parentType == Item.DERIVEDBIOASSAY || parentType == Item.RAWBIOASSAY) return false;
     92    if (parentType == Item.DERIVEDBIOASSAY || parentType == Item.RAWBIOASSAY || parentType == Item.ROOTRAWBIOASSAY) return false;
    9393    return super.preMissingItem(dc, context, parentNode);
    9494  }
  • trunk/src/core/net/sf/basedb/util/overview/validator/RawBioAssayValidator.java

    r6098 r6959  
    2525
    2626import net.sf.basedb.core.ArrayDesign;
     27import net.sf.basedb.core.BasicItem;
    2728import net.sf.basedb.core.DbControl;
    2829import net.sf.basedb.core.DerivedBioAssay;
    2930import net.sf.basedb.core.Extract;
     31import net.sf.basedb.core.Nameable;
    3032import net.sf.basedb.core.PermissionDeniedException;
    3133import net.sf.basedb.core.PhysicalBioAssay;
     
    3335import net.sf.basedb.core.RawBioAssay;
    3436import net.sf.basedb.core.RawDataType;
     37import net.sf.basedb.core.RootRawBioAssay;
    3538import net.sf.basedb.util.Values;
    3639import net.sf.basedb.util.overview.Fix;
     
    4144
    4245/**
    43   Validator implementation for raw bioassays. Validation rules:
     46  Validator implementation for raw bioassays and root raw bioassays.
     47  Validation rules:
    4448  <ul>
    4549  <li>Non-default raw data type: {@link Validator#NONDEFAULT_RAWDATATYPE}
     
    5458*/
    5559public class RawBioAssayValidator
    56   extends NameableNodeValidator<RawBioAssay>
     60  extends NameableNodeValidator<Nameable>
    5761{
    5862 
     
    7377    // Check raw data type against default raw data type
    7478    Project project = context.getProject();
    75     RawBioAssay rba = (RawBioAssay)node.getItem(dc);
     79    BasicItem item = node.getItem(dc);
     80    if (item instanceof RootRawBioAssay)
     81    {
     82      // The parent may be a root raw bioasay if the overview starts at the
     83      // experiment level
     84      item = ((RootRawBioAssay)item).getRawBioAssay();
     85    }
     86    RawBioAssay rba = (RawBioAssay)item;
    7687    if (project != null)
    7788    {
Note: See TracChangeset for help on using the changeset viewer.