Changeset 5648


Ignore:
Timestamp:
May 30, 2011, 12:31:51 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1597: Subtypes of items

Added subtype functionality for extracts. Including the web gui and batch importer.

Fixed some minor problems with samples.

Location:
trunk
Files:
13 edited

Legend:

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

    r5590 r5648  
    284284    for (Integer itemId : HibernateUtil.loadList(Integer.class, query, getSessionControl()))
    285285    {
    286       using.add(new ItemProxy(itemId, itemType));
     286      if (itemId != null) using.add(new ItemProxy(itemId, itemType));
    287287    }
    288288  }
  • trunk/src/core/net/sf/basedb/core/Extract.java

    r5643 r5648  
    200200    throws BaseException
    201201  {   
    202     return /*countPhysicalBioAssays() > 0 || */ super.isUsed();
     202    return super.isUsed();
    203203  }
    204204  /**
    205205    Get all:
    206206    <ul>
    207     <li>{@link PhysicalBioassay}:s created from this extract
     207    <li>{@link PhysicalBioAssay}:s created from this extract
    208208    <ul>
    209209    @since 2.2
     
    213213  {
    214214    Set<ItemProxy> using = super.getUsingItems();
    215     // TODO
     215    org.hibernate.Session session = getDbControl().getHibernateSession();
     216    org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     217      "GET_SOURCEEVENTS_FOR_BIOMATERIAL", "bme.physicalBioAssay.id");
     218      /*
     219        SELECT {1}
     220        FROM BioMaterialEventData bme
     221        JOIN bme.sources src
     222        WHERE index(src) = :bioMaterial
     223      */
     224    query.setEntity("bioMaterial", this.getData());
     225    addUsingItems(using, Item.PHYSICALBIOASSAY, query);
    216226    return using;
    217227  }
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/AbstractItemImporter.java

    r5647 r5648  
    14711471    @param dc The DbControl to use for database access
    14721472    @param identifier The identifier protocol
    1473     @param subtype The biosource subtype, or null if the type doesn't matter
     1473    @param subtype The sample subtype, or null if the type doesn't matter
    14741474    @return A sample, or null if no item could be found
    14751475    @since 3.0
     
    14861486 
    14871487  private ItemQuery<Extract> extractQuery;
     1488  /**
     1489    Same as {@link #findSample(DbControl, IdMethod, String, ItemSubtype)}
     1490    with a null subtype.
     1491  */
     1492  protected Extract findExtract(DbControl dc, IdMethod idMethod, String identifier)
     1493  {
     1494    return findExtract(dc, idMethod, identifier, null);
     1495  }
     1496
    14881497  /**
    14891498    Find an extract with a given identifier. This is a utility method that
     
    14941503    Subsequent calls uses the same query. Thus, this method should always be
    14951504    called with the same id method object, otherwise the result is undefined.
    1496    
     1505    <p>
     1506    NOTE! If this method is called with a non-null item subtype parameter and
     1507    no extract is found the query will be retried without any subtype.
     1508 
    14971509    @param dc The DbControl to use for database access
    14981510    @param identifier The identifier protocol
     1511    @param subtype The extract subtype, or null if the type doesn't matter
    14991512    @return An extract, or null if no item could be found
    1500   */
    1501   protected Extract findExtract(DbControl dc, IdMethod idMethod, String identifier)
     1513    @since 3.0
     1514  */
     1515  protected Extract findExtract(DbControl dc, IdMethod idMethod, String identifier, ItemSubtype subtype)
    15021516  {
    15031517    if (identifier == null) return null;
    15041518    if (extractQuery == null)
    15051519    {
    1506       extractQuery = initReferenceQuery(dc, idMethod, Extract.getQuery(), false);
    1507     }
    1508     return findReferencedItem(dc, idMethod, extractQuery, identifier, 0, false);
     1520      extractQuery = initReferenceQuery(dc, idMethod, Extract.getQuery(), true);
     1521    }
     1522    return findReferencedItemWithSubtype(dc, idMethod, extractQuery, identifier, subtype, false);
    15091523  }
    15101524
     
    15361550      );
    15371551    }
    1538     return findReferencedItem(dc, idMethod, labeledExtractQuery, identifier, 0, false);
     1552    return findReferencedItem(dc, idMethod, labeledExtractQuery, identifier, SystemItems.getId(Extract.LABELED), false);
    15391553  }
    15401554 
     
    19781992    T item = null;
    19791993    Item itemType = query.getItemType();
    1980     String cacheKey = itemType.name() + ":" + identifier + ":" + subtypeId;
    1981     if (itemCache.containsKey(cacheKey))
    1982     {
    1983       item = (T)itemCache.get(cacheKey);
     1994    String cacheKey1 = itemType.name() + ":" + identifier;
     1995    String cacheKey2 = cacheKey1 + ":" + subtypeId;
     1996    if (itemCache.containsKey(cacheKey2))
     1997    {
     1998      item = (T)itemCache.get(cacheKey2);
     1999    }
     2000    else if (itemCache.containsKey(cacheKey1))
     2001    {
     2002      item = (T)itemCache.get(cacheKey1);
    19842003    }
    19852004    else
     
    20252044          item = accessibleItems.get(0);
    20262045        }
    2027         itemCache.put(cacheKey, item);
     2046        itemCache.put(cacheKey2, item);
    20282047      }
    20292048    }
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/ExtractImporter.java

    r5630 r5648  
    3838import net.sf.basedb.core.Sample;
    3939import net.sf.basedb.core.SystemItems;
     40import net.sf.basedb.core.Tag;
    4041import net.sf.basedb.core.plugin.GuiContext;
    4142import net.sf.basedb.util.Values;
     
    5758  private static final Set<GuiContext> guiContexts = 
    5859    Collections.singleton(new GuiContext(Item.EXTRACT, GuiContext.Type.LIST));
    59  
     60
     61  protected static final PluginParameter<String> tagColumnMapping = new PluginParameter<String>(
     62      "tagColumnMapping",
     63      "Tag",
     64      "Mapping that picks the name or ID of a tag from the data columns. The plug-in will first " +
     65      "try to find a tag with the given name. If none is found and the value is numeric it will " +
     66      "try to load by internal ID. " +
     67      "Example: \\Tag\\",
     68      optionalColumnMapping
     69      );
     70
    6071  public ExtractImporter()
    6172  {}
     
    8091  private Mapper descriptionMapper;
    8192  private Mapper externalIdMapper;
     93  private Mapper tagMapper;
    8294  private Mapper originalQuantityMapper;
    8395  private Mapper createdMapper;
     
    106118  }
    107119 
     120  @Override
     121  protected Item getItemForSubtypes()
     122  {
     123    return Item.EXTRACT;
     124  }
     125
    108126  /**
    109127    Adds column mappings for name, externalId, description,
     
    116134    parameters.add(internalIdColumnMapping);
    117135    parameters.add(nameColumnMapping);
     136    parameters.add(subtypeColumnMapping);
    118137    parameters.add(externalIdColumnMapping);
     138    parameters.add(tagColumnMapping);
    119139    parameters.add(descriptionColumnMapping);
    120140    parameters.add(protocolColumnMapping);
     
    149169    externalIdMapper = getMapper(ffp, (String)job.getValue("externalIdColumnMapping"),
    150170        cropStrings ? Extract.MAX_EXTERNAL_ID_LENGTH : null, null);
     171    tagMapper = getMapper(ffp, (String)job.getValue("tagColumnMapping"), null, null);
    151172    originalQuantityMapper = getMapper(ffp, (String)job.getValue("originalQuantityColumnMapping"), null, null);
    152173    createdMapper = getMapper(ffp, (String)job.getValue("createdColumnMapping"), null, null);
     
    177198    BioMaterialEvent creationEvent = extract.getCreationEvent();
    178199    if (createdMapper != null) creationEvent.setEventDate(parseDate(createdMapper.getValue(data)));
     200    updateItemSubtype(dc, extract, data);
    179201    if (pooledMapper != null)
    180202    {
    181203      extract.setPooled(Values.getBoolean(pooledMapper.getValue(data)));
    182204    }
     205
     206    if (tagMapper != null)
     207    {
     208      String nameOrId = tagMapper.getValue(data);
     209      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, extract, Item.TAG, 0);
     210      Tag tag = findTag(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
     211      if (nameOrId == null || tag != null) extract.setTag(tag);
     212    }
     213   
    183214    if (protocolMapper != null)
    184215    {
    185216      String nameOrId = protocolMapper.getValue(data);
    186       ItemSubtype type = ItemSubtype.getById(dc,
     217      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, extract, Item.PROTOCOL,
    187218          SystemItems.getId(extract.isPooled() ? Protocol.POOLING : Protocol.EXTRACTION));
    188219      Protocol protocol = findProtocol(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
     
    206237      {
    207238        String nameOrId = parentMapper.getValue(data);
    208         Sample sample = findSample(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId);
     239        ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, extract, Item.SAMPLE, 0);
     240        Sample sample = findSample(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
    209241        Float usedQuantity = usedQuantityMapper == null ?
    210242          null : usedQuantityMapper.getFloat(data);
     
    228260    {
    229261      String nameOrId = parentMapper.getValue(data);
    230       Extract parent = findExtract(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId);
     262      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, extract, Item.EXTRACT, 0);
     263      Extract parent = findExtract(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
    231264      if (parent != null)
    232265      {
     
    234267            null : usedQuantityMapper.getFloat(data);
    235268        extract.getCreationEvent().addSource(parent, usedQuantity);
     269        // Use same tag as parent if not yet set and not mapped in the file
     270        if (tagMapper == null && parent.getTag() != null && extract.getTag() == null)
     271        {
     272          extract.setTag(parent.getTag());
     273        }
    236274      }
    237275    }
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/LabeledExtractImporter.java

    r5641 r5648  
    148148 
    149149  /**
    150     Calls {@link Extract#getQuery()}.
     150    Calls {@link Extract#getQuery()} and set a subtype filter for
     151    {@link Extract#LABELED}.
    151152  */
    152153  @Override
     
    187188  protected Extract createItem(DbControl dc, FlatFileParser.Data data)
    188189  {
    189     Tag label = null;
    190     if (labelMapper != null)
    191     {
    192       ItemSubtype labelType = ItemSubtype.getById(dc, SystemItems.getId(Tag.LABEL));
    193       label = findTag(dc, FallbackIdMethod.NAME_OR_ID, labelMapper.getValue(data), labelType);
    194     }
    195     if (label == null)
    196     {
    197       // If pooled, try to get the label from the first parent
    198       if (pooledMapper != null && parentMapper != null &&
    199         Values.getBoolean(pooledMapper.getValue(data)))
    200       {
    201         Extract parent = findLabeledExtract(dc, FallbackIdMethod.NAME_OR_ID, parentMapper.getValue(data));
    202         if (parent != null) label = parent.getTag();
    203       }
    204     }
    205190    Extract e = Extract.getNew(dc);
    206     e.setTag(label);
     191    e.setItemSubtype(ItemSubtype.getById(dc, SystemItems.getId(Extract.LABELED)));
    207192    updateItem(dc, e, data);
    208193    return e;
     
    230215      if (nameOrId == null || protocol != null) creationEvent.setProtocol(protocol);
    231216    }
    232     if (labelMapper != null && extract.isInDatabase())
     217   
     218    if (labelMapper != null)
    233219    {
    234220      String nameOrId = labelMapper.getValue(data);
    235       if (nameOrId != null)
    236       {
    237         ItemSubtype labelType = ItemSubtype.getById(dc, SystemItems.getId(Tag.LABEL));
    238         Tag label = findTag(dc, FallbackIdMethod.NAME_OR_ID, labelMapper.getValue(data), labelType);
    239         extract.setTag(label);
    240       }
    241     }
     221      ItemSubtype labelType = ItemSubtype.getById(dc, SystemItems.getId(Tag.LABEL));
     222      Tag label = findTag(dc, FallbackIdMethod.NAME_OR_ID, labelMapper.getValue(data), labelType);
     223      if (nameOrId == null || label != null) extract.setTag(label);
     224    }
     225   
    242226    if (bioPlateMapper != null && bioWellRowMapper != null && bioWellColMapper != null)
    243227    {
     
    285269            null : usedQuantityMapper.getFloat(data);
    286270        extract.getCreationEvent().addSource(parent, usedQuantity);
     271        // Use same tag as parent if not yet set and not mapped in the file
     272        if (labelMapper == null && parent.getTag() != null && extract.getTag() == null)
     273        {
     274          extract.setTag(parent.getTag());
     275        }
    287276      }
    288277    }
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/SampleImporter.java

    r5647 r5648  
    295295    if (createdMapper != null) creationEvent.setEventDate(parseDate(createdMapper.getValue(data)));
    296296    updateItemSubtype(dc, sample, data);
     297    if (pooledMapper != null)
     298    {
     299      sample.setPooled(Values.getBoolean(pooledMapper.getValue(data)));
     300    }
    297301    if (protocolMapper != null)
    298302    {
     
    315319      }
    316320    }
    317     if (pooledMapper != null)
    318     {
    319       sample.setPooled(Values.getBoolean(pooledMapper.getValue(data)));
    320     }
    321321    if (!sample.isPooled())
    322322    {
  • trunk/src/test/TestItemImporter.java

    r5642 r5648  
    104104    // Import labeled extracts
    105105    int labledExtractFileId = TestFile.test_create("data/test.batchimport.labeledextracts.txt", false, false);
    106     int labledExtractImporterId  = TestPluginDefinition.test_get("net.sf.basedb.plugins.batchimport.LabeledExtractImporter");
     106    int labledExtractImporterId  = extractImporterId;
    107107    int labledExtractJobId = test_create_item_import_job(Item.EXTRACT, labledExtractImporterId, labledExtractFileId);
    108108    ok &= TestJob.test_execute(labledExtractJobId, false);
     
    353353    if (file.getName().contains("labeledextracts"))
    354354    {
    355       request.setParameterValue("labelColumnMapping", "\\Label\\");
     355      request.setParameterValue("tagColumnMapping", "\\Label\\");
     356      request.setParameterValue("subtypeColumnMapping", "Labeled extract");
     357      request.setParameterValue("pooledColumnMapping", "1");
    356358    }
    357359    if (itemType == Item.PHYSICALBIOASSAY)
  • trunk/src/test/net/sf/basedb/test/roles/UserTest.java

    r5642 r5648  
    3737import net.sf.basedb.core.File;
    3838import net.sf.basedb.core.FileParameterType;
     39import net.sf.basedb.core.ItemSubtype;
    3940import net.sf.basedb.core.PhysicalBioAssay;
    4041import net.sf.basedb.core.Include;
     
    411412   
    412413    Extract labeledExtract = Extract.getNew(dc);
     414    labeledExtract.setItemSubtype(ItemSubtype.getById(dc, SystemItems.getId(Extract.LABELED)));
    413415    labeledExtract.setName(name);
    414416    labeledExtract.setOriginalQuantity(100.0f);
  • trunk/www/biomaterials/extracts/edit_extract.jsp

    r5630 r5648  
    3434  import="net.sf.basedb.core.Sample"
    3535  import="net.sf.basedb.core.Extract"
     36  import="net.sf.basedb.core.ItemSubtype"
     37  import="net.sf.basedb.core.Tag"
    3638  import="net.sf.basedb.core.BioMaterialEvent"
    3739  import="net.sf.basedb.core.BioPlate"
     
    8587  WellCoordinateFormatter columnFormatter = new WellCoordinateFormatter(false);
    8688
     89  boolean readCurrentSubtype = true;
     90  int currentSubtypeId = 0;
    8791  boolean readCurrentProtocol = true;
    8892  Protocol currentProtocol = null;
    8993  Protocol defaultProtocol = null;
     94  boolean readCurrentTag = true;
     95  Tag currentTag = null;
    9096  boolean readCurrentSample = true;
    9197  Sample currentSample = null;
     
    103109  List<Sample> recentSamples = (List<Sample>)cc.getRecent(dc, Item.SAMPLE);
    104110  List<BioPlate> recentBioPlates = (List<BioPlate>)cc.getRecent(dc, Item.BIOPLATE);
     111  List<Tag> recentTags = (List<Tag>)cc.getRecent(dc, Item.TAG);
    105112
    106113  int activeProjectId = sc.getActiveProjectId();
     
    125132      currentProtocol = Base.getFirstMatching(dc, Protocol.getQuery(), "name", cc.getPropertyFilter("creationEvent.protocol.name"));
    126133    }
     134    if (cc.getPropertyFilter("tag.name") != null)
     135    {
     136      currentTag = Base.getFirstMatching(dc, Tag.getQuery(), "name", cc.getPropertyFilter("tag.name"));
     137    }
     138    currentSubtypeId = Values.getInt(request.getParameter("subtype_id"));
     139    if (currentSubtypeId == 0)
     140    {
     141      int recentSubtypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0));
     142      currentSubtypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentSubtypeId);
     143    }
    127144    int sampleId = Values.getInt(request.getParameter("sample_id"));
    128145    if (sampleId != 0)
     
    147164  {
    148165    extract = Extract.getById(dc, itemId);
     166    extract.checkPermission(Permission.WRITE);
    149167    cc.setObject("item", extract);
    150168    title = "Edit extract -- " + HTML.encodeTags(extract.getName());
     
    158176    try
    159177    {
     178      ItemSubtype subtype = extract.getItemSubtype();
     179      if (subtype != null) currentSubtypeId = subtype.getId();
     180    }
     181    catch (PermissionDeniedException ex)
     182    {
     183      readCurrentSubtype = false;
     184    }
     185
     186    try
     187    {
    160188      currentProtocol = creationEvent.getProtocol();
    161189    }
     
    165193    }
    166194 
     195    try
     196    {
     197      currentTag = extract.getTag();
     198    }
     199    catch (PermissionDeniedException ex)
     200    {
     201      readCurrentTag = false;
     202    }
     203
    167204    try
    168205    {
     
    195232 
    196233  }
    197   if (extract != null && !extract.hasPermission(Permission.WRITE))
    198   {
    199     throw new PermissionDeniedException(Permission.WRITE, itemType.toString());
    200   }
     234 
     235  // Query to retrieve item types
     236  final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType);
     237  subtypesQuery.include(Include.ALL);
     238
    201239  final String clazz = "class=\"text\"";
    202240  final String requiredClazz = "class=\"text required\"";
     
    209247  %>
    210248  <base:page type="popup" title="<%=title%>">
    211   <base:head scripts="tabcontrol.js,annotations.js,linkitems.js" styles="tabcontrol.css">
     249  <base:head scripts="tabcontrol.js,annotations.js,linkitems.js,subtypes.js,ajax.js,json2.js" styles="tabcontrol.css">
    212250    <ext:scripts context="<%=jspContext%>" />
    213251    <ext:stylesheets context="<%=jspContext%>" />
     
    309347    {
    310348      var frm = document.forms['extract'];
    311       var url = '../../admin/protocols/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setProtocolCallback';
     349      var url = '../../admin/protocols/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone';
     350      url += '&callback=setProtocolCallback&resetTemporary=1';
     351      url += ItemSubtype.createRelatedFilter('extract', 'PROTOCOL', <%=SystemItems.getId(Protocol.EXTRACTION)%>);
    312352      if (frm.protocol_id.length > 1)
    313353      {
     
    315355        url += '&item_id='+id;
    316356      }
    317       url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=<%=SystemItems.getId(Protocol.EXTRACTION)%>';
    318357      Main.openPopup(url, 'SelectProtocol', 1000, 700);
    319358    }
     
    334373    {
    335374      protocolChanged = true;
     375    }
     376    function selectTagOnClick()
     377    {
     378      var frm = document.forms['extract'];
     379      var url = '../tags/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone';
     380      url += '&callback=setTagCallback&resetTemporary=1';
     381      url += ItemSubtype.createRelatedFilter('extract', 'TAG');
     382      if (frm.tag_id.length > 1)
     383      {
     384        var id = Math.abs(parseInt(frm.tag_id[1].value));       
     385        url += '&item_id='+id;
     386      }
     387      Main.openPopup(url, 'SelectTag', 1000, 700);
     388    }
     389    function setTagCallback(id, name)
     390    {
     391      var frm = document.forms['extract'];
     392      var list = frm.tag_id;
     393      if (list.length < 2 || list[1].value == '0') // >
     394      {
     395        Forms.addListOption(list, 1, new Option());
     396      }
     397      list[1].value = id;
     398      list[1].text = name;
     399      list.selectedIndex = 1;
    336400    }
    337401    function selectBioPlateOnClick()
     
    446510        return;
    447511      }
    448       var url = '../samples/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setSampleCallback';
     512      var url = '../samples/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone';
     513      url += '&callback=setSampleCallback&resetTemporary=1';
     514      url += ItemSubtype.createRelatedFilter('extract', 'SAMPLE');
    449515      if (frm.sample_id.length > 1)
    450516      {
     
    476542        return;
    477543      }
    478       Main.openPopup('index.jsp?ID=<%=ID%>&mode=selectmultiple&callback=addExtractCallback', 'AddExtracts', 1000, 700);
     544      var url = 'index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple';
     545      url += '&callback=addExtractCallback&resetTemporary=1';
     546      url += ItemSubtype.createRelatedFilter('extract', 'EXTRACT');
     547      Main.openPopup(url, 'AddExtracts', 1000, 700);
    479548    }
    480549   
     
    595664          value="<%=HTML.encodeTags(name)%>"
    596665          size="40" maxlength="<%=Extract.MAX_NAME_LENGTH%>"></td>
     666      </tr>
     667      <tr valign="top">
     668        <td class="prompt">Type</td>
     669        <td colspan="2">
     670          <select name="subtype_id"
     671            <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>>
     672          <%
     673          if (!readCurrentSubtype)
     674          {
     675            %>
     676            <option value="-1">- denied -
     677            <%
     678          }
     679          else
     680          {
     681            %>
     682            <option value="0">-none-
     683            <%
     684            for (ItemSubtype subtype : subtypesQuery.list(dc))
     685            {
     686              int id = subtype.getId();
     687              if (id != currentSubtypeId && subtype.isRemoved()) continue;
     688              %>
     689              <option value="<%=id == currentSubtypeId && extract != null ? -id : id%>"
     690                <%=id == currentSubtypeId ? "selected" : ""%>
     691                title="<%=HTML.encodeTags(subtype.getDescription()) %>"
     692                ><%=HTML.encodeTags(subtype.getName())%>
     693              <%
     694            }
     695          }
     696          %>
     697          </select>
     698        </td>
     699      </tr>
     700      <tr>
     701        <td class="prompt">Tag</td>
     702        <td>
     703          <base:select
     704            id="tag_id"
     705            clazz="selectionlist"
     706            required="false"
     707            current="<%=currentTag%>"
     708            denied="<%=!readCurrentTag%>"
     709            recent="<%=recentTags%>"
     710            newitem="<%=extract == null%>"
     711            onselect="selectTagOnClick()"
     712          />
     713        </td>
    597714      </tr>
    598715      <tr>
  • trunk/www/biomaterials/extracts/index.jsp

    r5642 r5648  
    3535  import="net.sf.basedb.core.BioWell"
    3636  import="net.sf.basedb.core.Protocol"
     37  import="net.sf.basedb.core.Tag"
    3738  import="net.sf.basedb.core.PhysicalBioAssay"
     39  import="net.sf.basedb.core.ItemSubtype"
    3840  import="net.sf.basedb.core.ItemQuery"
    3941  import="net.sf.basedb.core.ItemResultIterator"
     
    7779<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
    7880<%!
    79   private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,originalQuantity,remainingQuantity,physicalBioAssays,description");
     81  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,itemSubtype,originalQuantity,remainingQuantity,physicalBioAssays,description");
    8082  private static final Item itemType = Item.EXTRACT;
    8183 
     
    243245      }
    244246     
     247      int subtypeId = Values.getInt(request.getParameter("subtype_id"), -1);
     248      if (subtypeId >= 0) // < 0 = denied or unchanged
     249      {
     250        ItemSubtype subtype = subtypeId == 0 ? null : ItemSubtype.getById(dc, subtypeId);
     251        extract.setItemSubtype(subtype);
     252        if (subtype != null) cc.setRecent(subtype, maxRecent);
     253      }
     254     
     255      int tagId = Values.getInt(request.getParameter("tag_id"), -1);
     256      if (tagId >= 0) // < 0 = denied or unchanged
     257      {
     258        Tag tag = tagId == 0 ? null : Tag.getById(dc, tagId);
     259        extract.setTag(tag);
     260        if (tag != null) cc.setRecent(tag, maxRecent);
     261      }
     262
    245263      int biowellId = Values.getInt(request.getParameter("biowell_id"), -1);
    246264      if (biowellId >= 0) // < 0 = denied or unchanged
  • trunk/www/biomaterials/extracts/list_extracts.jsp

    r5642 r5648  
    3434  import="net.sf.basedb.core.BioMaterialEvent"
    3535  import="net.sf.basedb.core.BioWell"
     36  import="net.sf.basedb.core.ItemSubtype"
    3637  import="net.sf.basedb.core.AnnotationType"
    3738  import="net.sf.basedb.core.AnnotationSet"
     
    99100{
    100101  final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
     102  final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType);
    101103  final boolean createBioAssayPermission = sc.hasPermission(Permission.CREATE, Item.PHYSICALBIOASSAY);
    102104
     
    291293        exportable="true"
    292294        show="always"
     295      />
     296      <tbl:columndef
     297        id="itemSubtype"
     298        property="itemSubtype"
     299        sortproperty="itemSubtype.name"
     300        exportproperty="itemSubtype.name"
     301        datatype="int"
     302        enumeration="<%=Enumeration.fromItems(subtypesQuery.list(dc), "-none-")%>"
     303        title="Type"
     304        sortable="true"
     305        filterable="true"
     306        exportable="true"
    293307      />
    294308      <tbl:columndef
     
    704718                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
    705719                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
     720                <tbl:cell column="itemSubtype"><base:propertyvalue
     721                    item="<%=item%>"
     722                    property="itemSubtype"
     723                    enableEditLink="<%=mode.hasEditLink()%>"
     724                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
     725                  /></tbl:cell>
    706726                <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell>
    707727                <tbl:cell column="originalQuantity"><%=Values.formatNumber(item.getOriginalQuantity(), 2)%></tbl:cell>
  • trunk/www/biomaterials/extracts/view_extract.jsp

    r5642 r5648  
    296296      </tr>
    297297      <tr>
     298        <td class="prompt">Type</td>
     299        <td><base:propertyvalue item="<%=extract%>" property="itemSubtype" /></td>
     300      </tr>
     301      <tr>
    298302        <td class="prompt">External ID</td>
    299303        <td><%=HTML.encodeTags(extract.getExternalId())%></td>
  • trunk/www/biomaterials/samples/edit_sample.jsp

    r5645 r5648  
    340340        url += '&item_id='+id;
    341341      }
    342       url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=<%=SystemItems.getId(Protocol.SAMPLING)%>';
    343342      Main.openPopup(url, 'SelectProtocol', 1000, 700);
    344343    }
     
    473472      var url = '../biosources/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone';
    474473      url += '&callback=setBioSourceCallback&resetTemporary=1';
    475       ItemSubtype.createRelatedFilter('sample', 'BIOSOURCE');
     474      url += ItemSubtype.createRelatedFilter('sample', 'BIOSOURCE');
    476475      if (frm.biosource_id.length > 1)
    477476      {
Note: See TracChangeset for help on using the changeset viewer.