Changeset 5632


Ignore:
Timestamp:
May 17, 2011, 11:35:34 AM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1153: Handling short read transcript sequence data

Replaced Label with Tag. It re-uses much of the old code including the database table.

The code compiles and most test programs pass. Not all gui pages in the web client work. Since LabeledExtract is going to be removed functionality that is related with this may not do what is expected.

Location:
trunk
Files:
3 added
6 deleted
30 edited
3 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/config/dist/ehcache.xml

    r5630 r5632  
    151151  />
    152152  <cache
    153     name="net.sf.basedb.core.data.LabelData"
    154     maxElementsInMemory="100"
    155     eternal="false"
    156     timeToIdleSeconds="3600"
    157     timeToLiveSeconds="3600"
    158     overflowToDisk="false"
    159   />
    160   <cache
    161153    name="net.sf.basedb.core.data.MimeTypeData"
    162154    maxElementsInMemory="100"
     
    303295  />
    304296  <cache
     297    name="net.sf.basedb.core.data.TagData"
     298    maxElementsInMemory="100"
     299    eternal="false"
     300    timeToIdleSeconds="3600"
     301    timeToLiveSeconds="3600"
     302    overflowToDisk="false"
     303  />
     304  <cache
    305305    name="net.sf.basedb.core.data.UnitData"
    306306    maxElementsInMemory="100"
  • trunk/config/dist/hibernate.cfg.xml

    r5630 r5632  
    107107    />
    108108    <class-cache
    109       class="net.sf.basedb.core.data.LabelData"
    110       usage="nonstrict-read-write"
    111     />
    112     <class-cache
    113109      class="net.sf.basedb.core.data.MimeTypeData"
    114110      usage="nonstrict-read-write"
     
    183179    />
    184180    <class-cache
     181      class="net.sf.basedb.core.data.TagData"
     182      usage="nonstrict-read-write"
     183    />
     184    <class-cache
    185185      class="net.sf.basedb.core.data.UnitData"
    186186      usage="nonstrict-read-write"
  • trunk/src/clients/web/net/sf/basedb/clients/web/PermissionUtil.java

    r5630 r5632  
    196196        Arrays.asList(new Item[]
    197197        {
    198           Item.BIOSOURCE, Item.SAMPLE, Item.EXTRACT, Item.LABELEDEXTRACT, Item.LABEL,
     198          Item.BIOSOURCE, Item.SAMPLE, Item.EXTRACT, Item.LABELEDEXTRACT, Item.TAG,
    199199          Item.BIOMATERIALLIST, Item.BIOPLATE, Item.BIOPLATETYPE, Item.BIOPLATEEVENT, Item.BIOPLATEEVENTTYPE,
    200200          Item.HYBRIDIZATION, Item.SCAN, Item.RAWBIOASSAY, Item.EXPERIMENT, Item.FORMULA
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/edit/EditUtil.java

    r5631 r5632  
    5656  public static final Item[] EDIT_ITEMS = new Item[]
    5757    {
    58       Item.BIOSOURCE, Item.SAMPLE, Item.EXTRACT, Item.LABELEDEXTRACT, Item.LABEL,
     58      Item.BIOSOURCE, Item.SAMPLE, Item.EXTRACT, Item.LABELEDEXTRACT, Item.TAG,
    5959      Item.BIOPLATE, Item.BIOWELL, Item.BIOPLATETYPE, Item.BIOMATERIALLIST, Item.BIOMATERIALEVENT,
    6060      Item.BIOPLATEEVENT, Item.BIOPLATEEVENTTYPE,
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/toolbar/ToolbarUtil.java

    r5631 r5632  
    6262      Item.SCAN, Item.IMAGE, Item.HYBRIDIZATION,
    6363      Item.BIOSOURCE, Item.SAMPLE, Item.EXTRACT,
    64       Item.LABELEDEXTRACT, Item.LABEL, Item.BIOMATERIALEVENT,
     64      Item.LABELEDEXTRACT, Item.TAG, Item.BIOMATERIALEVENT,
    6565      Item.BIOMATERIALLIST, Item.BIOPLATE, Item.BIOWELL, Item.BIOPLATETYPE,
    6666      Item.BIOPLATEEVENT, Item.BIOPLATEEVENTTYPE,
  • trunk/src/clients/web/net/sf/basedb/clients/web/resources/common.properties

    r5630 r5632  
    106106item.labeledextract Labeled extract
    107107item.labeledextract+  Labeled extracts
    108 item.label  Label
    109 item.label+ Labels
     108item.tag  Tag
     109item.tag+ Tags
    110110item.bioplate Bioplate
    111111item.bioplate+  Bioplates
  • trunk/src/clients/web/net/sf/basedb/clients/web/resources/menu.properties

    r5631 r5632  
    113113labeledextracts.tooltip.1 Manage labeled extracts
    114114labeledextracts.tooltip.0 You do not have permission to manage labeled extracts
    115 labels.tooltip.1  Manage labels
    116 labels.tooltip.0  You do not have permission to manage labels
     115tags.tooltip.1  Manage tags
     116tags.tooltip.0  You do not have permission to manage tags
    117117# --------------
    118118bioplates.tooltip.1 Manage bio plates
  • trunk/src/core/common-queries.xml

    r5630 r5632  
    759759  </query>
    760760 
    761   <query id="GET_LABEL_WITH_NAME" type="HQL">
    762     <sql>
    763       SELECT lbl
    764       FROM LabelData lbl
    765       WHERE lbl.name = :name
    766     </sql>
    767     <description>
    768       A Hibernate query that returns the label with the specified
     761  <query id="GET_TAG_WITH_NAME" type="HQL">
     762    <sql>
     763      SELECT tag
     764      FROM TagData tag
     765      WHERE tag.name = :name
     766    </sql>
     767    <description>
     768      A Hibernate query that returns the tag with the specified
    769769      name.
    770770    </description>
     
    10741074  </query>
    10751075
    1076   <query id="GET_LABELED_EXTRACTS_FOR_LABEL" type="HQL">
    1077     <sql>
    1078       SELECT {1}
    1079       FROM LabeledExtractData le
    1080       WHERE le.label = :label
    1081     </sql>
    1082     <description>
    1083       A Hibernate query that gets labeled extracts
    1084       with a given label.
     1076  <query id="GET_EXTRACTS_FOR_TAG" type="HQL">
     1077    <sql>
     1078      SELECT {1}
     1079      FROM ExtractData ext
     1080      WHERE ext.tag = :tag
     1081    </sql>
     1082    <description>
     1083      A Hibernate query that gets extracts with a given tag.
    10851084    </description>
    10861085  </query>
  • trunk/src/core/net/sf/basedb/core/Extract.java

    r5631 r5632  
    162162  // -------------------------------------------
    163163  /*
     164    From the Subtypable interface
     165    -----------------------------
     166  */
     167  @Override
     168  @SubtypableRelatedItems({Item.PROTOCOL, Item.HARDWARE, Item.TAG})
     169  public ItemSubtype getItemSubtype()
     170  {
     171    return getDbControl().getItem(ItemSubtype.class, getData().getItemSubtype());
     172  }
     173  // -------------------------------------------
     174
     175  /*
    164176    From the BasicItem class
    165177    -------------------------------------------
     
    250262    @throws BaseException If there is another error
    251263  */
    252   public LabeledExtract newLabeledExtract(Label label, Float usedQuantity)
     264  public LabeledExtract newLabeledExtract(Tag tag, Float usedQuantity)
    253265    throws PermissionDeniedException, BaseException
    254266  {
    255     return newLabeledExtract(label, usedQuantity, null);
     267    return newLabeledExtract(tag, usedQuantity, null);
    256268  }
    257269
     
    269281    @since 2.17
    270282  */
    271   public LabeledExtract newLabeledExtract(Label label, Float usedQuantity, BioPlateEventParticipant master)
     283  public LabeledExtract newLabeledExtract(Tag tag, Float usedQuantity, BioPlateEventParticipant master)
    272284    throws PermissionDeniedException, BaseException
    273285  {
    274     LabeledExtract le = LabeledExtract.getNew(getDbControl(), label, master);
     286    LabeledExtract le = LabeledExtract.getNew(getDbControl(), tag, master);
    275287    le.setExtract(this, usedQuantity);
    276288    return le;
  • trunk/src/core/net/sf/basedb/core/Install.java

    r5631 r5632  
    4646import net.sf.basedb.core.data.ShareableData;
    4747import net.sf.basedb.core.data.SoftwareData;
     48import net.sf.basedb.core.data.TagData;
    4849import net.sf.basedb.core.data.UnitData;
    4950import net.sf.basedb.core.data.UnitSymbolData;
     
    5455import net.sf.basedb.core.data.RoleKeyData;
    5556import net.sf.basedb.core.data.NewsData;
    56 import net.sf.basedb.core.data.LabelData;
    5757import net.sf.basedb.core.data.AnnotationTypeData;
    5858import net.sf.basedb.core.data.ParameterValueData;
     
    340340     
    341341      // BioMaterials
    342       createRoleKey(Item.LABEL, "Labels", "Gives access to labels", power_users_create);
     342      createRoleKey(Item.TAG, "Tags", "Gives access to tags", power_users_create);
    343343      createRoleKey(Item.BIOSOURCE, "BioSource", "Gives access to biosources", users_create);
    344344      createRoleKey(Item.SAMPLE, "Samples", "Gives access to samples", users_create);
     
    457457      // Software subtypes
    458458      ItemSubtypeData feature = createItemSubtype(Item.SOFTWARE, Software.FEATURE_EXTRACTION, "Feature extraction", "Extracts features from microarray images.");
     459     
     460      // Tag subtypes
     461      ItemSubtypeData labelTag = createItemSubtype(Item.TAG, Tag.LABEL, "Label",
     462        "Fluorescent dye used to tag extracts before it can be used in experiments.");
     463      ItemSubtypeData barcodeTag = createItemSubtype(Item.TAG, Tag.BARCODE, "Barcode",
     464        "Adaptor used to tag libraries to enable multiplexing in sequencing experiments.");
    459465     
    460466      // Hardware
     
    617623          "An event that creates child hybridizations.");
    618624     
    619       // Labels
     625      // Tags
    620626      progressStep++;
    621       if (progress != null) progress.display((int)(progressStep*progress_factor), "--Creating labels...");
    622       createLabel("cy3", "", rootUser, keyEveryoneUse);
    623       createLabel("cy5", "", rootUser, keyEveryoneUse);
    624       createLabel("Biotin", "", rootUser, keyEveryoneUse);
     627      if (progress != null) progress.display((int)(progressStep*progress_factor), "--Creating tags...");
     628      createTag("cy3", "", labelTag, rootUser, keyEveryoneUse);
     629      createTag("cy5", "", labelTag, rootUser, keyEveryoneUse);
     630      createTag("Biotin", "", labelTag, rootUser, keyEveryoneUse);
    625631     
    626632      // Annotation types
     
    18551861
    18561862  /**
    1857     Create a {@link Label}.
    1858   */
    1859   private static LabelData createLabel(String name, String description, UserData owner, ItemKeyData shareTo)
    1860     throws BaseException
    1861   {
    1862     org.hibernate.Transaction tx = null;
    1863     LabelData label = null;
    1864     try
    1865     {
    1866       tx = HibernateUtil.newTransaction(session);
    1867       if (label == null)
    1868       {
    1869         org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, "GET_LABEL_WITH_NAME");
     1863    Create a {@link Tag}.
     1864  */
     1865  private static TagData createTag(String name, String description, ItemSubtypeData subtype, UserData owner, ItemKeyData shareTo)
     1866    throws BaseException
     1867  {
     1868    org.hibernate.Transaction tx = null;
     1869    TagData tag = null;
     1870    try
     1871    {
     1872      tx = HibernateUtil.newTransaction(session);
     1873      if (tag == null)
     1874      {
     1875        org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, "GET_TAG_WITH_NAME");
    18701876        query.setString("name", name);
    1871         label = HibernateUtil.loadData(LabelData.class, query);
    1872       }
    1873      
    1874       if (label != null)
    1875       {
    1876         log.info("createLabel: EXISITS [NAME="+name+"]");
    1877         HibernateUtil.commit(tx);
    1878       }
    1879       else
    1880       {
    1881         label = new LabelData();
    1882         label.setEntryDate(new Date());
    1883         label.setName(name);
    1884         label.setDescription(description);
    1885         label.setOwner(owner);
    1886         label.setItemKey(shareTo);
    1887         HibernateUtil.saveData(session, label);
    1888         HibernateUtil.commit(tx);
    1889         log.info("createLabel: OK [NAME="+name+"]");
     1877        tag = HibernateUtil.loadData(TagData.class, query);
     1878      }
     1879     
     1880      if (tag != null)
     1881      {
     1882        log.info("createTag: EXISITS [NAME="+name+"]");
     1883        HibernateUtil.commit(tx);
     1884      }
     1885      else
     1886      {
     1887        tag = new TagData();
     1888        tag.setEntryDate(new Date());
     1889        tag.setName(name);
     1890        tag.setDescription(description);
     1891        tag.setOwner(owner);
     1892        tag.setItemSubtype(subtype);
     1893        tag.setItemKey(shareTo);
     1894        HibernateUtil.saveData(session, tag);
     1895        HibernateUtil.commit(tx);
     1896        log.info("createTag: OK [NAME="+name+"]");
    18901897      }
    18911898    }
     
    18931900    {
    18941901      if (tx != null) HibernateUtil.rollback(tx);
    1895       log.info("createLabel: FAILED [NAME="+name+"]", ex);
    1896       throw ex;
    1897     }
    1898     return label;
     1902      log.info("createTag: FAILED [NAME="+name+"]", ex);
     1903      throw ex;
     1904    }
     1905    return tag;
    18991906  }
    19001907 
  • trunk/src/core/net/sf/basedb/core/Item.java

    r5630 r5632  
    304304    450),
    305305  /**
    306     The item is a {@link Label}.
    307   */
    308   LABEL(206, "Label", "lbl", Label.class, LabelData.class, DefinedPermissions.shareable,
     306    The item is a {@link Tag}.
     307  */
     308  TAG(206, "Tag", "lbl", Tag.class, TagData.class, DefinedPermissions.shareable,
    309309    440),
    310310
  • trunk/src/core/net/sf/basedb/core/LabeledExtract.java

    r5523 r5632  
    6161    @throws BaseException If there is an error
    6262  */
    63   public static LabeledExtract getNew(DbControl dc, Label label)
    64     throws BaseException
    65   {
    66     return getNew(dc, label, null);
     63  public static LabeledExtract getNew(DbControl dc, Tag tag)
     64    throws BaseException
     65  {
     66    return getNew(dc, tag, null);
    6767  }
    6868
     
    7979    @since 2.17
    8080  */
    81   public static LabeledExtract getNew(DbControl dc, Label label, BioPlateEventParticipant master)
     81  public static LabeledExtract getNew(DbControl dc, Tag tag, BioPlateEventParticipant master)
    8282    throws BaseException
    8383  {
    8484    LabeledExtract le = dc.newItem(LabeledExtract.class);
    8585    le.setName("New labeled extract");
    86     le.setLabel(label);
     86    le.setLabel(tag);
    8787    le.setBioPlateEventParticipant(master);
    8888    return le;
     
    213213    @throws BaseException If there is another error
    214214  */
    215   public Label getLabel()
     215  public Tag getLabel()
    216216    throws PermissionDeniedException, BaseException
    217217  {
    218     return getDbControl().getItem(Label.class, getData().getLabel());
     218    return getDbControl().getItem(Tag.class, getData().getTag());
    219219  }
    220220
     
    227227    @throws BaseException If there is another error
    228228  */
    229   public void setLabel(Label label)
     229  public void setLabel(Tag label)
    230230    throws PermissionDeniedException, InvalidDataException
    231231  {
     
    233233    if (label == null) throw new InvalidUseOfNullException("label");
    234234    label.checkPermission(Permission.USE);
    235     getData().setLabel(label.getData());
     235    getData().setTag(label.getData());
    236236  }
    237237
  • trunk/src/core/net/sf/basedb/core/data/ExtractData.java

    r4889 r5632  
    4040  {}
    4141
     42  private TagData tag;
     43  /**
     44    The tag used for tagging the extract so that it can be tracked on physical bioassays.
     45    @hibernate.many-to-one column="`label_id`" not-null="false" outer-join="false"
     46    @since 3.0
     47  */
     48  public TagData getTag()
     49  {
     50    return tag;
     51  }
     52  public void setTag(TagData tag)
     53  {
     54    this.tag = tag;
     55  }
    4256}
  • trunk/src/core/net/sf/basedb/core/data/LabeledExtractData.java

    r4889 r5632  
    3434*/
    3535public class LabeledExtractData
    36   extends MeasuredBioMaterialData
     36  extends ExtractData
    3737{
    3838
     
    4040  {}
    4141 
    42   private LabelData label;
    43   /**
    44     The label compound used to label the extract. This property is actually not-null="true", but
    45     since we are using a common table for all biomaterial and the other types doesn't have a label,
    46     it must be declared not-null="false". It is up to the core to check that no null values are
    47     passed to the database.
    48     @hibernate.many-to-one column="`label_id`" not-null="false" outer-join="false"
    49   */
    50   public LabelData getLabel()
    51   {
    52     return label;
    53   }
    54   public void setLabel(LabelData label)
    55   {
    56     this.label = label;
    57   }
    5842}
  • trunk/src/core/net/sf/basedb/util/overview/node/LabeledExtractNameGenerator.java

    r5384 r5632  
    2222package net.sf.basedb.util.overview.node;
    2323
    24 import net.sf.basedb.core.Label;
    2524import net.sf.basedb.core.LabeledExtract;
     25import net.sf.basedb.core.Tag;
    2626import net.sf.basedb.util.overview.Node;
    2727
     
    6464    try
    6565    {
    66       Label label = item.getLabel();
     66      Tag label = item.getLabel();
    6767      title = label.getName() + ": " + title;
    6868    }
  • trunk/src/core/net/sf/basedb/util/overview/validator/LabeledExtractValidator.java

    r5518 r5632  
    3232import net.sf.basedb.core.Hybridization;
    3333import net.sf.basedb.core.Item;
    34 import net.sf.basedb.core.Label;
    3534import net.sf.basedb.core.LabeledExtract;
    3635import net.sf.basedb.core.PermissionDeniedException;
    3736import net.sf.basedb.core.RawBioAssay;
     37import net.sf.basedb.core.Tag;
    3838import net.sf.basedb.util.overview.Failure;
    3939import net.sf.basedb.util.overview.Fix;
     
    128128        try
    129129        {
    130           Label label = extract.getLabel();
     130          Tag label = extract.getLabel();
    131131          int arrayIndex = creationEvent.getSourceGroup(extract);
    132132          if (arrayIndex < minArrayIndex) minArrayIndex = arrayIndex;
     
    230230    // Check that the child has the same label as the parent
    231231    LabeledExtract parent = (LabeledExtract)parentNode.getItem(dc);
    232     Label parentLabel = null;
     232    Tag parentLabel = null;
    233233    try
    234234    {
     
    237237    catch (PermissionDeniedException ex)
    238238    {}
    239     Label label = null;
     239    Tag label = null;
    240240    LabeledExtract child = (LabeledExtract)node.getItem(dc);
    241241    try
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/AbstractItemImporter.java

    r5630 r5632  
    6161import net.sf.basedb.core.ItemSubtype;
    6262import net.sf.basedb.core.Job;
    63 import net.sf.basedb.core.Label;
    6463import net.sf.basedb.core.LabeledExtract;
    6564import net.sf.basedb.core.NumberOutOfRangeException;
     
    8584import net.sf.basedb.core.StringTooLongException;
    8685import net.sf.basedb.core.StringUtil;
     86import net.sf.basedb.core.Tag;
    8787import net.sf.basedb.core.Type;
    8888import net.sf.basedb.core.plugin.GuiContext;
     
    10661066  }
    10671067
    1068   private ItemQuery<Label> labelQuery;
    1069   /**
    1070     Find a label with a given identifier. This is a utility method that
     1068  private ItemQuery<Tag> tagQuery;
     1069  /**
     1070    Same as {@link #findTag(DbControl, IdMethod, String, ItemSubtype)} with
     1071    a null item subtype.
     1072  */
     1073  protected Tag findTag(DbControl dc, IdMethod idMethod, String identifier)
     1074  {
     1075    return findTag(dc, idMethod, identifier, null);
     1076  }
     1077 
     1078  /**
     1079    Find a tag with a given identifier. This is a utility method that
    10711080    subclasses can use when creating or updating items.
    10721081    <p>
     
    10751084    Subsequent calls uses the same query. Thus, this method should always be
    10761085    called with the same id method object, otherwise the result is undefined.
     1086    <p>
     1087    NOTE! If this method is called with a non-null item subtype parameter and
     1088    no hardware is found the query will be retried without any subtype.
    10771089   
    10781090    @param dc The DbControl to use for database access
    10791091    @param identifier The identifier protocol
    1080     @return A label, or null if no item could be found
    1081   */
    1082   protected Label findLabel(DbControl dc, IdMethod idMethod, String identifier)
     1092    @param subtype The tag subtype, or null if the type doesn't matter
     1093    @return A tag, or null if no item could be found
     1094    @since 3.0
     1095  */
     1096  protected Tag findTag(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
    10831097  {
    10841098    if (identifier == null) return null;
    1085     if (labelQuery == null) labelQuery = initReferenceQuery(dc, idMethod, Label.getQuery());
    1086     return findReferencedItem(dc, idMethod, labelQuery, identifier, false);
    1087   }
    1088 
     1099    if (tagQuery == null)
     1100    {
     1101      // where ... (itemSubtype = :subtype AND checkType = 1) || checkType = 0
     1102      Expression checkType = Expressions.parameter("checkType");
     1103      tagQuery = initReferenceQuery(dc, idMethod, Tag.getQuery());
     1104      tagQuery.restrictPermanent(
     1105        Restrictions.or(
     1106          Restrictions.and(
     1107            Restrictions.eq(Hql.property("itemSubtype"), Expressions.parameter("subtype")),
     1108            Restrictions.eq(checkType, Expressions.integer(1))
     1109          ),
     1110          Restrictions.eq(checkType, Expressions.integer(0))
     1111        )
     1112      );
     1113    }
     1114    tagQuery.setParameter("subtype", subtype == null ? 0 : subtype.getId(), Type.INT);
     1115    tagQuery.setParameter("checkType", subtype == null ? 0 : 1, Type.INT);
     1116    Tag tag = findReferencedItem(dc, idMethod, tagQuery, identifier, true);
     1117    if (tag == null)
     1118    {
     1119      tagQuery.setParameter("checkType", 0, Type.INT);
     1120      tag = findReferencedItem(dc, idMethod, tagQuery, identifier, false);
     1121    }
     1122    return tag;
     1123  }
     1124 
    10891125 
    10901126  private ItemQuery<Hardware> hardwareQuery;
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/LabeledExtractImporter.java

    r5630 r5632  
    3434import net.sf.basedb.core.ItemQuery;
    3535import net.sf.basedb.core.ItemSubtype;
    36 import net.sf.basedb.core.Label;
    3736import net.sf.basedb.core.LabeledExtract;
    3837import net.sf.basedb.core.PluginParameter;
    3938import net.sf.basedb.core.Protocol;
    4039import net.sf.basedb.core.SystemItems;
     40import net.sf.basedb.core.Tag;
    4141import net.sf.basedb.core.plugin.GuiContext;
    4242import net.sf.basedb.util.Values;
     
    178178  protected LabeledExtract createItem(DbControl dc, FlatFileParser.Data data)
    179179  {
    180     Label label = null;
     180    Tag label = null;
    181181    if (labelMapper != null)
    182182    {
    183       label = findLabel(dc, FallbackIdMethod.NAME_OR_ID, labelMapper.getValue(data));
     183      ItemSubtype labelType = ItemSubtype.getById(dc, SystemItems.getId(Tag.LABEL));
     184      label = findTag(dc, FallbackIdMethod.NAME_OR_ID, labelMapper.getValue(data), labelType);
    184185    }
    185186    if (label == null)
     
    224225      if (nameOrId != null)
    225226      {
    226         Label label = findLabel(dc, FallbackIdMethod.NAME_OR_ID, labelMapper.getValue(data));
     227        ItemSubtype labelType = ItemSubtype.getById(dc, SystemItems.getId(Tag.LABEL));
     228        Tag label = findTag(dc, FallbackIdMethod.NAME_OR_ID, labelMapper.getValue(data), labelType);
    227229        extract.setLabel(label);
    228230      }
  • trunk/src/test/TestAll.java

    r5630 r5632  
    7979    results.put("TestSample", TestSample.test_all());
    8080    results.put("TestExtract", TestExtract.test_all());
    81     results.put("TestLabel", TestLabel.test_all());
     81    results.put("TestTag", TestTag.test_all());
    8282    results.put("TestLabeledExtract", TestLabeledExtract.test_all());
    8383    results.put("TestBioMaterialList", TestBioMaterialList.test_all());
  • trunk/src/test/TestBioPlate.java

    r5630 r5632  
    3131import net.sf.basedb.core.ItemProxy;
    3232import net.sf.basedb.core.ItemResultList;
    33 import net.sf.basedb.core.Label;
    3433import net.sf.basedb.core.LabeledExtract;
    3534import net.sf.basedb.core.MeasuredBioMaterial;
     
    3938import net.sf.basedb.core.Sample;
    4039import net.sf.basedb.core.SystemItems;
     40import net.sf.basedb.core.Tag;
    4141import net.sf.basedb.core.Trashcan;
    4242import net.sf.basedb.util.collections.BasicItemToIdTransformer;
     
    7474    int sample3Id = TestSample.test_create(0, "Sample A.3", true);
    7575    int extractId = TestExtract.test_create(sampleId, true);
    76     int labelId = TestLabel.test_create(true);
     76    int labelId = TestTag.test_create("Test label", SystemItems.getId(Tag.LABEL), true);
    7777    int labeledExtractId = TestLabeledExtract.test_create(extractId, labelId, true);
    7878    int freezerId = TestHardware.test_create(SystemItems.getId(Hardware.FREEZER), null, false);
     
    117117    // Standard test: Delete
    118118    TestLabeledExtract.test_delete(labeledExtractId);
    119     TestLabel.test_delete(labelId);
     119    TestTag.test_delete(labelId);
    120120    TestExtract.test_delete(extractId);
    121121    TestSample.test_delete(sampleId);
     
    488488
    489489 
    490   static List<Integer> test_fill(int bioPlateId, Item itemType, String rootName, int labelId)
     490  static List<Integer> test_fill(int bioPlateId, Item itemType, String rootName, int tagId)
    491491  {
    492492    if (bioPlateId == 0) return null;
     
    497497      dc = TestUtil.getDbControl();
    498498      BioPlate plate = BioPlate.getById(dc, bioPlateId);
    499       Label label = labelId == 0 ? null : Label.getById(dc, labelId);
     499      Tag label = tagId == 0 ? null : Tag.getById(dc, tagId);
    500500      PlateGeometry geometry = plate.getPlateGeometry();
    501501      int rows = geometry.getRows();
  • trunk/src/test/TestGenericOverview.java

    r5630 r5632  
    9292    int extractPooled = TestExtract.test_create_pooled(extract1, extract2);
    9393   
    94     int cy3 = TestLabel.test_load("cy3");
    95     int cy5 = TestLabel.test_load("cy5");
     94    int cy3 = TestTag.test_load("cy3");
     95    int cy5 = TestTag.test_load("cy5");
    9696    int labeledExtract1 = TestLabeledExtract.test_create(extract1, cy3, false);
    9797    int labeledExtract2 = TestLabeledExtract.test_create(extract2, cy3, false);
  • trunk/src/test/TestHybridization.java

    r5340 r5632  
    5353    int id3 = test_create(arraySlideId, false);
    5454   
    55     int labelId1 = TestLabel.test_create(false);
    56     int labelId2 = TestLabel.test_create(false);
     55    int labelId1 = TestTag.test_create("Test label #1", SystemItems.getId(Tag.LABEL), false);
     56    int labelId2 = TestTag.test_create("Test label #2", SystemItems.getId(Tag.LABEL), false);
    5757    int labeledExtractId1 = TestLabeledExtract.test_create(0, labelId1, false);
    5858    int labeledExtractId2 = TestLabeledExtract.test_create(0, labelId2, false);
     
    7373    TestLabeledExtract.test_delete(labeledExtractId1);
    7474    TestLabeledExtract.test_delete(labeledExtractId2);
    75     TestLabel.test_delete(labelId1);
    76     TestLabel.test_delete(labelId2);
     75    TestTag.test_delete(labelId1);
     76    TestTag.test_delete(labelId2);
    7777   
    7878    TestArraySlide.test_delete(arraySlideId);
  • trunk/src/test/TestLabeledExtract.java

    r5340 r5632  
    4343    write_header();
    4444    // Standard tests: create, load, list
    45     int labelId = TestLabel.test_create(true);
     45    int labelId = TestTag.test_create("Test label", SystemItems.getId(Tag.LABEL), true);
    4646    int id = test_create(0, labelId, true);
    4747    int id2 = test_create(0, labelId, false);
     
    7171    test_delete(id);
    7272    TestExtract.test_delete(extractId);
    73     TestLabel.test_delete(labelId);
     73    TestTag.test_delete(labelId);
    7474 
    7575    write("++Testing labeled extracts "+(ok ? "OK" : "Failed")+"\n");
     
    8585    {
    8686      dc = TestUtil.getDbControl();
    87       Label l = Label.getById(dc, labelId);
     87      Tag l = Tag.getById(dc, labelId);
    8888      LabeledExtract le = LabeledExtract.getNew(dc, l);
    8989      if (setAll)
     
    129129    {
    130130      dc = TestUtil.getDbControl();
    131       Label l = Label.getById(dc, labelId);
     131      Tag l = Tag.getById(dc, labelId);
    132132      LabeledExtract le = LabeledExtract.getNew(dc, l);
    133133      le.setName("Test pooled labeled extract");
  • trunk/src/test/TestMetadata.java

    r5475 r5632  
    3434import net.sf.basedb.core.Scan;
    3535import net.sf.basedb.core.Metadata.PropertyPath;
     36import net.sf.basedb.core.SystemItems;
     37import net.sf.basedb.core.Tag;
    3638
    3739public class TestMetadata
     
    8486    int batchId = TestArrayBatch.test_create(designId, true);
    8587    int slideId = TestArraySlide.test_create(batchId, true);
    86     int labelId = TestLabel.test_create(true);
     88    int labelId = TestTag.test_create("Test label", SystemItems.getId(Tag.LABEL), true);
    8789    int labeledExtractId = TestLabeledExtract.test_create(0, labelId, true);
    8890    int hybId = TestHybridization.test_create(slideId, true, labeledExtractId);
     
    109111    TestHybridization.test_delete(hybId);
    110112    TestLabeledExtract.test_delete(labeledExtractId);
    111     TestLabel.test_delete(labelId);
     113    TestTag.test_delete(labelId);
    112114    TestArraySlide.test_delete(slideId);
    113115    TestArrayBatch.test_delete(batchId);
  • trunk/src/test/TestPermissionTemplate.java

    r5368 r5632  
    8484  static int test_create(String name, int itemKeyId, int projectKeyId)
    8585  {
    86     if (!TestUtil.hasPermission(Permission.CREATE, Item.LABEL)) return 0;
     86    if (!TestUtil.hasPermission(Permission.CREATE, Item.PERMISSIONTEMPLATE)) return 0;
    8787    int id = 0;
    8888    DbControl dc = null;
  • trunk/src/test/net/sf/basedb/test/roles/UserTest.java

    r5630 r5632  
    4343import net.sf.basedb.core.ItemQuery;
    4444import net.sf.basedb.core.Job;
    45 import net.sf.basedb.core.Label;
    4645import net.sf.basedb.core.LabeledExtract;
    4746import net.sf.basedb.core.PlateGeometry;
     
    5857import net.sf.basedb.core.StringParameterType;
    5958import net.sf.basedb.core.SystemItems;
     59import net.sf.basedb.core.Tag;
    6060import net.sf.basedb.core.Unit;
    6161import net.sf.basedb.core.query.Hql;
     
    204204        eRef.setBioWell(bioPlate.getBioWell(1, 2));
    205205       
    206         Label cy3 = Util.findLabel(dc, "cy3");     
    207         Label cy5 = Util.findLabel(dc, "cy5");     
     206        Tag cy3 = Util.findTag(dc, "cy3");     
     207        Tag cy5 = Util.findTag(dc, "cy5");     
    208208        LabeledExtract le1 = createLabeledExtract(dc, "Labeled extract A.00h", e1, cy3);
    209209        le1.setBioWell(bioPlate.getBioWell(2, 0));
     
    407407    Create a labeled extract.
    408408  */
    409   public static LabeledExtract createLabeledExtract(DbControl dc, String name, Extract extract, Label label)
     409  public static LabeledExtract createLabeledExtract(DbControl dc, String name, Extract extract, Tag label)
    410410  {
    411411    TestUtil.write("--Creating labeled extract: " + name + "\n");
  • trunk/src/test/net/sf/basedb/test/roles/Util.java

    r5260 r5632  
    4242import net.sf.basedb.core.Item;
    4343import net.sf.basedb.core.ItemQuery;
    44 import net.sf.basedb.core.Label;
    4544import net.sf.basedb.core.Plate;
    4645import net.sf.basedb.core.PlateGeometry;
     
    5554import net.sf.basedb.core.Scan;
    5655import net.sf.basedb.core.Software;
     56import net.sf.basedb.core.Tag;
    5757import net.sf.basedb.core.Unit;
    5858import net.sf.basedb.core.User;
     
    218218    Find the label with a matching name.
    219219  */
    220   public static Label findLabel(DbControl dc, String name)
    221   {
    222     ItemQuery<Label> query = Label.getQuery();
     220  public static Tag findTag(DbControl dc, String name)
     221  {
     222    ItemQuery<Tag> query = Tag.getQuery();
    223223    query.restrict(Restrictions.eq(Hql.property("name"), Expressions.string(name)));
    224224    query.include(Include.SHARED);
  • trunk/www/biomaterials/tags/edit_tag.jsp

    r5629 r5632  
    3131  import="net.sf.basedb.core.ItemContext"
    3232  import="net.sf.basedb.core.Permission"
    33   import="net.sf.basedb.core.Label"
     33  import="net.sf.basedb.core.Tag"
     34  import="net.sf.basedb.core.ItemSubtype"
    3435  import="net.sf.basedb.core.PermissionDeniedException"
     36  import="net.sf.basedb.core.ItemQuery"
     37  import="net.sf.basedb.core.Include"
     38  import="net.sf.basedb.core.query.Orders"
     39  import="net.sf.basedb.core.query.Hql"
    3540  import="net.sf.basedb.clients.web.Base"
    3641  import="net.sf.basedb.clients.web.util.HTML"
     
    4550<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
    4651<%
    47 final Item itemType = Item.LABEL;
     52final Item itemType = Item.TAG;
    4853final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
    4954final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
     
    5560{
    5661  String title = null;
    57   Label label = null;
     62  Tag tag = null;
     63  boolean readCurrentTagType = true;
     64  int currentTagTypeId = 0;
    5865
    5966  if (itemId == 0)
    6067  {
    61     title = "Create label";
     68    title = "Create tag";
    6269    cc.removeObject("item");
     70    currentTagTypeId = Values.getInt(request.getParameter("tagtype_id"));
     71    if (currentTagTypeId == 0)
     72    {
     73      int recentTagTypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0));
     74      currentTagTypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentTagTypeId);
     75    }
    6376  }
    6477  else
    6578  {
    66     label = Label.getById(dc, itemId);
    67     cc.setObject("item", label);
    68     title = "Edit label -- " + HTML.encodeTags(label.getName());
    69   }
    70   if (label != null && !label.hasPermission(Permission.WRITE))
    71   {
    72     throw new PermissionDeniedException(Permission.WRITE, itemType.toString());
     79    tag = Tag.getById(dc, itemId);
     80    tag.checkPermission(Permission.WRITE);
     81    cc.setObject("item", tag);
     82    title = "Edit tag -- " + HTML.encodeTags(tag.getName());
     83    try
     84    {
     85      ItemSubtype tagType = tag.getItemSubtype();
     86      if (tagType != null) currentTagTypeId = tagType.getId();
     87    }
     88    catch (PermissionDeniedException ex)
     89    {
     90      readCurrentTagType = false;
     91    }
    7392  }
    7493 
     94  // Query to retrieve protocol types
     95  final ItemQuery<ItemSubtype> tagTypeQuery = ItemSubtype.getQuery(itemType);
     96  tagTypeQuery.include(Include.ALL);
     97  tagTypeQuery.order(Orders.asc(Hql.property("name")));
     98
    7599  final String clazz = "class=\"text\"";
    76100  final String requiredClazz = "class=\"text required\"";
    77   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), label);
     101  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), tag);
    78102  ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext);
    79103  %>
     
    83107    <ext:stylesheets context="<%=jspContext%>" />
    84108    <script language="JavaScript">
    85     // Validate the "Label" tab
    86     function validateLabel()
    87     {
    88       var frm = document.forms['label'];
     109    // Validate the "Tag" tab
     110    function validateTag()
     111    {
     112      var frm = document.forms['tag'];
    89113      if (Main.trimString(frm.name.value) == '')
    90114      {
     
    99123    function saveSettings()
    100124    {
    101       var frm = document.forms['label'];
     125      var frm = document.forms['tag'];
    102126      if (TabControl.validateActiveTab('settings'))
    103127      {
     
    109133    {
    110134      <%
    111       if (label == null)
     135      if (tag == null)
    112136      {
    113137        %>
    114         var frm = document.forms['label'];
     138        var frm = document.forms['tag'];
    115139        frm.name.focus();
    116140        frm.name.select();
     
    123147  <base:body onload="init()">
    124148    <p>
    125     <form action="index.jsp?ID=<%=ID%>" method="post" name="label" onsubmit="return false;">
     149    <form action="index.jsp?ID=<%=ID%>" method="post" name="tag" onsubmit="return false;">
    126150    <input type="hidden" name="cmd" value="UpdateItem">
    127151
    128152    <h3 class="docked"><%=title%> <base:help tabcontrol="settings"/></h3>
    129153    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*160)+"px;"%>"
    130       position="bottom"  remember="<%=label != null%>"
     154      position="bottom"  remember="<%=tag != null%>"
    131155      extensions="<%=invoker%>">
    132     <t:tab id="info" title="Label" validate="validateLabel()" helpid="label.edit">
     156    <t:tab id="info" title="Tag" validate="validateTag()" helpid="tag.edit">
    133157      <table class="form" cellspacing=0>
    134158      <tr>
    135159        <td class="prompt">Name</td>
    136160        <td><input <%=requiredClazz%> type="text" name="name"
    137           value="<%=HTML.encodeTags(label == null ? Values.getString(cc.getPropertyValue("name"), "New label") : label.getName())%>"
    138           size="40" maxlength="<%=Label.MAX_NAME_LENGTH%>"></td>
     161          value="<%=HTML.encodeTags(tag == null ? Values.getString(cc.getPropertyValue("name"), "New tag") : tag.getName())%>"
     162          size="40" maxlength="<%=Tag.MAX_NAME_LENGTH%>"></td>
     163      </tr>
     164      <tr valign="top">
     165        <td class="prompt">Type</td>
     166        <td colspan="2">
     167          <select name="tagtype_id"
     168            <%=!readCurrentTagType ? "disabled readonly class=\"disabled\"" : "class=\"required\""%>>
     169          <%
     170          if (!readCurrentTagType)
     171          {
     172            %>
     173            <option value="-1">- denied -
     174            <%
     175          }
     176          else
     177          {
     178            for (ItemSubtype tagType : tagTypeQuery.list(dc))
     179            {
     180              int id = tagType.getId();
     181              if (id != currentTagTypeId && tagType.isRemoved()) continue;
     182              %>
     183              <option value="<%=id == currentTagTypeId && tag != null ? -id : id%>"
     184                <%=id == currentTagTypeId ? "selected" : ""%>
     185                ><%=HTML.encodeTags(tagType.getName())%>
     186              <%
     187            }
     188          }
     189          %>
     190          </select>
     191        </td>
    139192      </tr>
    140193      <tr valign=top>
     
    142195        <td nowrap>
    143196          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
    144             ><%=HTML.encodeTags(label == null ? cc.getPropertyValue("description") : label.getDescription())%></textarea>
    145           <a href="javascript:Main.zoom('Description', 'label', 'description')"
     197            ><%=HTML.encodeTags(tag == null ? cc.getPropertyValue("description") : tag.getDescription())%></textarea>
     198          <a href="javascript:Main.zoom('Description', 'tag', 'description')"
    146199            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
    147200        </td>
  • trunk/www/biomaterials/tags/index.jsp

    r5590 r5632  
    2929  import="net.sf.basedb.core.Item"
    3030  import="net.sf.basedb.core.Include"
    31   import="net.sf.basedb.core.Label"
     31  import="net.sf.basedb.core.Tag"
     32  import="net.sf.basedb.core.ItemSubtype"
    3233  import="net.sf.basedb.core.ItemQuery"
    3334  import="net.sf.basedb.core.Permission"
     
    6061<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
    6162<%!
    62   private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,description");
    63   private static final Item itemType = Item.LABEL;
     63  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,itemSubtype,description");
     64  private static final Item itemType = Item.TAG;
    6465%>
    6566<%
     
    7172final String callback = request.getParameter("callback");
    7273final String itemId = request.getParameter("item_id");
    73 final String listPage = "list_labels.jsp?ID="+ID
     74final String listPage = "list_tags.jsp?ID="+ID
    7475  +(mode == null ? "" : "&mode="+mode)
    7576  +(callback == null ? "" : "&callback="+callback)
    7677  +(itemId == null ? "" : "&item_id="+itemId);
    77 final String viewPage = "view_label.jsp?ID="+ID;
    78 final String editPage = "edit_label.jsp?ID="+ID;
     78final String viewPage = "view_tag.jsp?ID="+ID;
     79final String editPage = "edit_tag.jsp?ID="+ID;
    7980
    8081String forward = null;
     
    132133    // Update the properties on an item (will close the popup)
    133134    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext);
    134     dc = sc.newDbControl();
    135     Label label = (Label)cc.getObject("item");
    136     if (label == null)
    137     {
    138       label = Label.getNew(dc);
    139       message = "Label created";
    140       dc.saveItem(label);
     135    final int maxRecent = Base.getMaxRecent(sc);
     136    dc = sc.newDbControl();
     137    Tag tag = (Tag)cc.getObject("item");
     138    if (tag == null)
     139    {
     140      tag = Tag.getNew(dc);
     141      message = "Tag created";
     142      dc.saveItem(tag);
    141143    }
    142144    else
    143145    {
    144       dc.reattachItem(label, false);
    145       message = "Label updated";
    146     }
    147     JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.LABEL), label);
     146      dc.reattachItem(tag, false);
     147      message = "Tag updated";
     148    }
     149    JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), tag);
    148150    ExtensionsInvoker invoker = EditUtil.useOnSaveExtensions(jspContext);
    149151    try
    150152    {
    151       label.setName(Values.getStringOrNull(request.getParameter("name")));
    152       label.setDescription(Values.getStringOrNull(request.getParameter("description")));
     153      tag.setName(Values.getStringOrNull(request.getParameter("name")));
     154      tag.setDescription(Values.getStringOrNull(request.getParameter("description")));
     155      int tagTypeId = Values.getInt(request.getParameter("tagtype_id"), -1);
     156      if (tagTypeId >= 0) // < 0 = denied or unchanged
     157      {
     158        ItemSubtype subtype = tagTypeId == 0 ? null : ItemSubtype.getById(dc, tagTypeId);
     159        tag.setItemSubtype(subtype);
     160        if (subtype != null) cc.setRecent(subtype, maxRecent);
     161      }
    153162
    154163      // OnSave extensions
     
    260269    // Run an export plugin in a list context
    261270    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    262     final ItemQuery<Label> query = Label.getQuery();
     271    final ItemQuery<Tag> query = Tag.getQuery();
    263272    dc = sc.newDbControl();
    264273    cc.configureQuery(dc, query, true);
    265274    dc.close();
    266275    cc.setQuery(query);
    267     redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+labels";
     276    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+tags";
    268277  }
    269278  else if ("ExportItem".equals(cmd))
     
    271280    // Run an export plugin in single-item context
    272281    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    273     redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+label";
     282    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+tag";
    274283  }
    275284  else if ("ImportItems".equals(cmd))
     
    277286    // Run an import plugin in a list context
    278287    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    279     final ItemQuery<Label> query = Label.getQuery();
     288    final ItemQuery<Tag> query = Tag.getQuery();
    280289    dc = sc.newDbControl();
    281290    cc.configureQuery(dc, query, true);
    282291    dc.close();
    283292    cc.setQuery(query);
    284     redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+labels";
     293    redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+tags";
    285294  }
    286295  else if ("ImportItem".equals(cmd))
     
    288297    // Run an import plugin in single-item context
    289298    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    290     redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+label";
     299    redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+tag";
    291300  }
    292301  else if ("RunListPlugin".equals(cmd))
     
    294303    // Run another plugin in a list context
    295304    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    296     final ItemQuery<Label> query = Label.getQuery();
     305    final ItemQuery<Tag> query = Tag.getQuery();
    297306    dc = sc.newDbControl();
    298307    cc.configureQuery(dc, query, true);
  • trunk/www/biomaterials/tags/list_tags.jsp

    r5629 r5632  
    2828  import="net.sf.basedb.core.DbControl"
    2929  import="net.sf.basedb.core.Item"
    30   import="net.sf.basedb.core.Label"
     30  import="net.sf.basedb.core.Tag"
     31  import="net.sf.basedb.core.ItemSubtype"
    3132  import="net.sf.basedb.core.ItemQuery"
    3233  import="net.sf.basedb.core.ItemResultIterator"
    3334  import="net.sf.basedb.core.ItemContext"
    34   import="net.sf.basedb.core.LabeledExtract"
    3535  import="net.sf.basedb.core.Nameable"
    3636  import="net.sf.basedb.core.Permission"
     
    4444  import="net.sf.basedb.clients.web.ModeInfo"
    4545  import="net.sf.basedb.clients.web.util.HTML"
     46  import="net.sf.basedb.util.Enumeration"
    4647  import="net.sf.basedb.util.ShareableUtil"
    4748  import="net.sf.basedb.util.Values"
     
    6263<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
    6364<%!
    64   private static final Item itemType = Item.LABEL;
     65  private static final Item itemType = Item.TAG;
    6566  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
    6667%>
     
    7374final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
    7475final String callback = request.getParameter("callback");
    75 final String title = mode.generateTitle("label", "labels");
     76final String title = mode.generateTitle("tag", "tags");
    7677final DbControl dc = sc.newDbControl();
    77 ItemResultIterator<Label> labels = null;
     78ItemResultIterator<Tag> tags = null;
    7879try
    7980{
    8081  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    8182
     83  final ItemQuery<ItemSubtype> typeQuery = ItemSubtype.getQuery(itemType);
     84  typeQuery.order(Orders.asc(Hql.property("name")));
     85  typeQuery.setCacheResult(true);
     86
    8287  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    8388  try
    8489  {
    85     final ItemQuery<Label> query = Base.getConfiguredQuery(dc, cc, true, Label.getQuery(), mode);
    86     labels = query.iterate(dc);
     90    final ItemQuery<Tag> query = Base.getConfiguredQuery(dc, cc, true, Tag.getQuery(), mode);
     91    tags = query.iterate(dc);
    8792  }
    8893  catch (Throwable t)
     
    9499  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    95100  %>
    96   <base:page title="<%=title==null ? "Labels" : title%>" type="<%=mode.getPageType()%>">
     101  <base:page title="<%=title==null ? "Tags" : title%>" type="<%=mode.getPageType()%>">
    97102  <base:head scripts="menu.js,table.js" styles="menu.css,table.css">
    98103    <ext:scripts context="<%=jspContext%>" />
     
    100105    <script language="JavaScript">
    101106    var submitPage = 'index.jsp';
    102     var formId = 'labels';
     107    var formId = 'tags';
    103108    function newItem()
    104109    {
     
    151156    function shareItem(itemId)
    152157    {
    153       Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id='+itemId, 'ShareLabels', 600, 400);
     158      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id='+itemId, 'ShareTags', 600, 400);
    154159    }
    155160    function shareItems()
     
    174179      Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
    175180    }
    176     function newLabeledExtract(labelId)
    177     {
    178       Main.viewOrEditItem('<%=ID%>', 'LABELEDEXTRACT', 0, true, '&label_id='+labelId);
     181    function newLabeledExtract(tagId)
     182    {
     183      Main.viewOrEditItem('<%=ID%>', 'LABELEDEXTRACT', 0, true, '&label_id='+tagId);
    179184    }   
    180185    </script>
     
    192197    %>
    193198    <tbl:table
    194       id="labels"
     199      id="tags"
    195200      clazz="itemlist"
    196201      columns="<%=cc.getSetting("columns")%>"
     
    250255        formatter="<%=dateFormatter%>"
    251256      />
     257      <%
     258      Enumeration<String, String> tagTypes = new Enumeration<String, String>();
     259      for (ItemSubtype subtype : typeQuery.list(dc))
     260      {
     261        tagTypes.add(Integer.toString(subtype.getId()), HTML.encodeTags(subtype.getName()));
     262      }
     263      %>   
     264      <tbl:columndef
     265        id="itemSubtype"
     266        property="itemSubtype"
     267        sortproperty="itemSubtype.name"
     268        exportproperty="itemSubtype.name"
     269        datatype="int"
     270        enumeration="<%=tagTypes%>"
     271        title="Type"
     272        sortable="true"
     273        filterable="true"
     274        exportable="true"
     275      />
    252276      <tbl:columndef
    253277        id="description"
     
    278302          onclick="newItem()"
    279303          title="New&hellip;"
    280           tooltip="<%=createPermission ? "Create new label" : "You do not have permission to create labels"%>"
     304          tooltip="<%=createPermission ? "Create new tag" : "You do not have permission to create tags"%>"
    281305        />
    282306        <tbl:button
     
    337361        page="<%=cc.getPage()%>"
    338362        rowsperpage="<%=cc.getRowsPerPage()%>"
    339         totalrows="<%=labels == null ? 0 : labels.getTotalCount()%>"
     363        totalrows="<%=tags == null ? 0 : tags.getTotalCount()%>"
    340364        visible="<%=mode.hasNavigator()%>"
    341365      />
     
    376400          int index = cc.getPage()*cc.getRowsPerPage();
    377401          int selectedItemId = cc.getId();
    378           if (labels != null)
     402          if (tags != null)
    379403          {           
    380             while (labels.hasNext())
     404            while (tags.hasNext())
    381405            {
    382               Label item = labels.next();
    383               int itemId = item.getId();
    384               ItemQuery<LabeledExtract> labeledExtractQuery = item.getLabeledExtracts();
    385               labeledExtractQuery.include(cc.getInclude());
    386               labeledExtractQuery.order(Orders.asc(Hql.property("name")));             
     406              Tag item = tags.next();
     407              int itemId = item.getId(); 
    387408              String openSharePopup = "shareItem("+itemId+")";
    388409              String deletePermanently = "deleteItemPermanently("+itemId+")";
     
    447468                  /></tbl:cell>
    448469                <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" />
     470                <tbl:cell column="itemSubtype"
     471                  ><base:propertyvalue
     472                    item="<%=item%>"
     473                    property="itemSubtype"
     474                    enableEditLink="<%=mode.hasEditLink()%>"
     475                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
     476                  /></tbl:cell>
    449477                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
    450478                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
     
    478506      {
    479507        %>
    480         <tbl:panel><%=labels == null || labels.getTotalCount() == 0 ? "No labels were found" : "No labels on this page. Please select another page!" %></tbl:panel>
     508        <tbl:panel><%=tags == null || tags.getTotalCount() == 0 ? "No tags were found" : "No tags on this page. Please select another page!" %></tbl:panel>
    481509        <%
    482510      }
     
    487515          page="<%=cc.getPage()%>"
    488516          rowsperpage="<%=cc.getRowsPerPage()%>"
    489           totalrows="<%=labels == null ? 0 : labels.getTotalCount()%>"
     517          totalrows="<%=tags == null ? 0 : tags.getTotalCount()%>"
    490518          visible="<%=mode.hasNavigator()%>"
    491519          locked="true"
     
    507535finally
    508536{
    509   if (labels != null) labels.close();
     537  if (tags != null) tags.close();
    510538  if (dc != null) dc.close();
    511539}
  • trunk/www/biomaterials/tags/view_tag.jsp

    r5629 r5632  
    3535  import="net.sf.basedb.core.ItemResultList"
    3636  import="net.sf.basedb.core.Permission"
    37   import="net.sf.basedb.core.Label"
    38   import="net.sf.basedb.core.LabeledExtract"
     37  import="net.sf.basedb.core.Tag"
    3938  import="net.sf.basedb.core.MultiPermissions"
    4039  import="net.sf.basedb.core.User"
     
    6867<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
    6968<%!
    70   private static final Item itemType = Item.LABEL;
     69  private static final Item itemType = Item.TAG;
    7170  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
    7271%>
     
    8483
    8584  String title = null;
    86   Label label = Label.getById(dc, itemId);
     85  Tag tag = Tag.getById(dc, itemId);
    8786 
    88   final boolean writePermission = label.hasPermission(Permission.WRITE);
    89   final boolean deletePermission = label.hasPermission(Permission.DELETE);
    90   final boolean sharePermission = label.hasPermission(Permission.SET_PERMISSION);
    91   final boolean usePermission = label.hasPermission(Permission.USE);
    92   final boolean setOwnerPermission = label.hasPermission(Permission.SET_OWNER);
    93   final boolean isRemoved = label.isRemoved();
    94   final boolean isUsed = isRemoved && label.isUsed();
     87  final boolean writePermission = tag.hasPermission(Permission.WRITE);
     88  final boolean deletePermission = tag.hasPermission(Permission.DELETE);
     89  final boolean sharePermission = tag.hasPermission(Permission.SET_PERMISSION);
     90  final boolean usePermission = tag.hasPermission(Permission.USE);
     91  final boolean setOwnerPermission = tag.hasPermission(Permission.SET_OWNER);
     92  final boolean isRemoved = tag.isRemoved();
     93  final boolean isUsed = isRemoved && tag.isUsed();
    9594  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
    96   final boolean isOwner = label.isOwner();
    97   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, label);
     95  final boolean isOwner = tag.isOwner();
     96  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, tag);
    9897  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
    9998  %>
     
    109108    function shareItem()
    110109    {
    111       Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareLabel', 600, 400);
     110      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareTag', 600, 400);
    112111    }
    113112    function deleteItem()
     
    148147    <p>
    149148    <p:path>
    150       <p:pathelement title="Labels" href="<%="index.jsp?ID="+ID%>" />
    151       <p:pathelement title="<%=HTML.encodeTags(label.getName())%>" />
     149      <p:pathelement title="Tags" href="<%="index.jsp?ID="+ID%>" />
     150      <p:pathelement title="<%=HTML.encodeTags(tag.getName())%>" />
    152151    </p:path>
    153152   
     
    161160        onclick="editItem()"
    162161        title="Edit&hellip;"
    163         tooltip="<%=writePermission ? "Edit this label" : "You do not have permission to edit this label"%>"
     162        tooltip="<%=writePermission ? "Edit this tag" : "You do not have permission to edit this tag"%>"
    164163      />
    165164      <tbl:button
     
    168167        onclick="deleteItem()"
    169168        title="Delete"
    170         visible="<%=!label.isRemoved()%>"
    171         tooltip="<%=deletePermission ? "Delete this label" : "You do not have permission to delete this label"%>"
     169        visible="<%=!tag.isRemoved()%>"
     170        tooltip="<%=deletePermission ? "Delete this tag" : "You do not have permission to delete this tag"%>"
    172171      />
    173172      <tbl:button
     
    176175        onclick="restoreItem()"
    177176        title="Restore"
    178         visible="<%=label.isRemoved()%>"
    179         tooltip="<%=writePermission ? "Restore this label" : "You do not have permission to restore this label"%>"
     177        visible="<%=tag.isRemoved()%>"
     178        tooltip="<%=writePermission ? "Restore this tag" : "You do not have permission to restore this tag"%>"
    180179      />
    181180      <tbl:button
     
    184183        onclick="shareItem()"
    185184        title="Share&hellip;"
    186         tooltip="<%=sharePermission ? "Share this label to other user, groups and projects" : "You do not have permission to share this label"%>"
     185        tooltip="<%=sharePermission ? "Share this tag to other user, groups and projects" : "You do not have permission to share this tag"%>"
    187186      />
    188187      <tbl:button
     
    198197        title="New labeled extract&hellip;"
    199198        tooltip="Create a new labeled extract with this label"
    200         visible="<%=sc.hasPermission(Permission.CREATE, Item.LABEL) && usePermission%>"
     199        visible="<%=sc.hasPermission(Permission.CREATE, Item.LABELEDEXTRACT) && usePermission%>"
    201200      />
    202201      <tbl:button
     
    225224      <tbl:button
    226225        image="help.gif"
    227         onclick="<%="Main.openHelp('" + ID +"', 'label.view.properties')"%>"
     226        onclick="<%="Main.openHelp('" + ID +"', 'tag.view.properties')"%>"
    228227        title="Help&hellip;"
    229228        tooltip="Get help about this page"
     
    231230      </tbl:toolbar>
    232231    <div class="boxedbottom">
    233       <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(label)%></i></div>
     232      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(tag)%></i></div>
    234233      <%
    235       if (label.isRemoved() || label.isShared())
     234      if (tag.isRemoved() || tag.isShared())
    236235      {
    237236        %>
     
    247246            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
    248247          <base:icon image="shared.gif"
    249             visible="<%=label.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
     248            visible="<%=tag.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
    250249        </div>
    251250        <%
     
    255254      <tr>
    256255        <td class="prompt">Name</td>
    257         <td><%=HTML.encodeTags(label.getName())%></td>
     256        <td><%=HTML.encodeTags(tag.getName())%></td>
     257      </tr>
     258      <tr>
     259        <td class="prompt">Type</td>
     260        <td><base:propertyvalue item="<%=tag%>" property="itemSubtype" /></td>
    258261      </tr>
    259262      <tr>
    260263        <td class="prompt">Registered</td>
    261         <td><%=dateFormatter.format(label.getEntryDate())%></td>
     264        <td><%=dateFormatter.format(tag.getEntryDate())%></td>
    262265      </tr>
    263266      <tr>
    264267        <td class="prompt">Owner</td>
    265         <td><base:propertyvalue item="<%=label%>" property="owner"/></td>
     268        <td><base:propertyvalue item="<%=tag%>" property="owner"/></td>
    266269      </tr>
    267270      <tr>
    268271        <td class="prompt">Description</td>
    269         <td><%=HTML.niceFormat(label.getDescription())%></td>
     272        <td><%=HTML.niceFormat(tag.getDescription())%></td>
    270273      </tr>
    271274      </table>
     
    274277        <jsp:param name="item_type" value="<%=itemType.name()%>" />
    275278        <jsp:param name="item_id" value="<%=itemId%>" />
    276         <jsp:param name="title" value="Other items related to this label" />
     279        <jsp:param name="title" value="Other items related to this tag" />
    277280      </jsp:include>
    278281      <%
    279282      // Tables with users/groups/projects that this item is shared to
    280       MultiPermissions mp = new MultiPermissions(Collections.singleton(label));
     283      MultiPermissions mp = new MultiPermissions(Collections.singleton(tag));
    281284      ItemResultList<User> users = mp.getUsers().list(dc);
    282285      ItemResultList<Group> groups = mp.getGroups().list(dc);
     
    376379        %>
    377380        <h4>Shared to</h4>
    378         This label is not shared
     381        This tag is not shared
    379382        (or, you don't have permission to view the ones it is shared to).
    380383        <%
  • trunk/www/include/menu.jsp

    r5631 r5632  
    642642    <%
    643643    // BioLIMS - menu
    644     final boolean hasLabels             = !sc.hasPermission(Permission.DENIED, Item.LABEL);
    645     final boolean createLabels          =  sc.hasPermission(Permission.CREATE, Item.LABEL);
     644    final boolean hasTags             = !sc.hasPermission(Permission.DENIED, Item.TAG);
     645    final boolean createTags          =  sc.hasPermission(Permission.CREATE, Item.TAG);
    646646
    647647    final boolean hasBioSources         = !sc.hasPermission(Permission.DENIED, Item.BIOSOURCE);
     
    663663    final boolean hasBioPlateTypes  = !sc.hasPermission(Permission.DENIED, Item.BIOPLATETYPE);
    664664    final boolean hasBioPlateEventTypes = !sc.hasPermission(Permission.DENIED, Item.BIOPLATEEVENTTYPE);
    665     final boolean hasBioLims      =  hasLabels || hasBioSources || hasSamples || hasExtracts ||
     665    final boolean hasBioLims      =  hasTags || hasBioSources || hasSamples || hasExtracts ||
    666666                      hasLabeledExtracts || hasBioMaterialLists || hasBioPlates ||
    667667                      hasBioPlateTypes || hasBioPlateEventTypes;
     
    699699        />
    700700        <m:menuitem
    701           title="<%=common.getString("item.label+")%>"
    702           onclick="<%="Menu.openUrl('"+root+"biomaterials/labels/index.jsp?ID="+ID+"')"%>"
    703           tooltip="<%=menu.getString("labels.tooltip", hasLabels)%>"
    704           enabled="<%=hasLabels%>"
     701          title="<%=common.getString("item.tag+")%>"
     702          onclick="<%="Menu.openUrl('"+root+"biomaterials/tags/index.jsp?ID="+ID+"')"%>"
     703          tooltip="<%=menu.getString("tags.tooltip", hasTags)%>"
     704          enabled="<%=hasTags%>"
    705705        />
    706706        <m:menuseparator />
  • trunk/www/include/scripts/main.js

    r5630 r5632  
    539539    this.controllers['IMAGE'] = { url:'views/scans/images/index.jsp', width:500, height:340 };
    540540    this.controllers['SESSION'] = { url:'views/sessions/index.jsp', width:400, height:300, popup:true, edit:false };
    541     this.controllers['LABEL'] = { url:'biomaterials/labels/index.jsp', width:450, height:280 };
     541    this.controllers['TAG'] = { url:'biomaterials/tags/index.jsp', width:450, height:280 };
    542542    this.controllers['LABELEDEXTRACT'] = { url:'biomaterials/labeledextracts/index.jsp', width:800, height:500 };
    543543    this.controllers['EXTRACT'] = { url:'biomaterials/extracts/index.jsp', width:800, height:500 };
Note: See TracChangeset for help on using the changeset viewer.