Changeset 7809


Ignore:
Timestamp:
May 19, 2020, 1:35:05 PM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #2206: Display information about item list membership

Implemented in the list and view pages for all other item types (sample, extracts, physical bioassays, derived bioassays and raw bioassays).

Location:
branches/3.16-stable/www
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/3.16-stable/www/biomaterials/biosources/list_biosources.jsp

    r7801 r7809  
    118118  final boolean createSamplePermission = sc.hasPermission(Permission.CREATE, Item.SAMPLE);
    119119
     120  // List membership
    120121  final ItemQuery<ItemList> listQuery = ItemList.getQuery();
    121122  listQuery.setIncludes(cc.getInclude());
     
    245246        title="Description"
    246247        sortable="true"
    247         filterable="true" subclass="foobar"
     248        filterable="true"
    248249        exportable="true"
    249250      />     
  • branches/3.16-stable/www/biomaterials/extracts/list_extracts.jsp

    r7804 r7809  
    4848  import="net.sf.basedb.core.ItemResultList"
    4949  import="net.sf.basedb.core.ItemContext"
     50  import="net.sf.basedb.core.ItemList"
    5051  import="net.sf.basedb.core.Nameable"
    5152  import="net.sf.basedb.core.Permission"
     
    7475  import="net.sf.basedb.util.formatter.Formatter"
    7576  import="net.sf.basedb.util.formatter.WellCoordinateFormatter"
     77  import="net.sf.basedb.util.formatter.NameableFormatter"
     78  import="net.sf.basedb.clients.web.formatter.LinkedItemFormatter"
    7679  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    7780  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
     
    105108
    106109final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
     110final Formatter<Nameable> nameableFormatter = mode.hasPropertyLink() ? new LinkedItemFormatter(mode.hasEditLink()) : new NameableFormatter();
    107111final String callback = request.getParameter("callback");
    108112final String title = mode.generateTitle("extract", "extracts");
     
    141145  bioAssayQuery.restrict(Restrictions.eq(Hql.property("src", "bioMaterial"), Hql.entityParameter("extract", Item.EXTRACT)));
    142146  bioAssayQuery.order(Orders.asc(Hql.property("name")));
    143   bioAssayQuery.include(cc.getInclude());
     147  bioAssayQuery.setIncludes(cc.getInclude());
    144148
    145149  // Child derived bioassays
     
    147151  derivedAssayQuery.restrict(Restrictions.eq(Hql.property("extract"), Hql.entityParameter("extract", Item.EXTRACT)));
    148152  derivedAssayQuery.order(Orders.asc(Hql.property("name")));
    149   derivedAssayQuery.include(cc.getInclude());
     153  derivedAssayQuery.setIncludes(cc.getInclude());
    150154
    151155  // Child raw bioassays
     
    153157  rawAssayQuery.restrict(Restrictions.eq(Hql.property("parentExtract"), Hql.entityParameter("extract", Item.EXTRACT)));
    154158  rawAssayQuery.order(Orders.asc(Hql.property("name")));
    155   rawAssayQuery.include(cc.getInclude());
     159  rawAssayQuery.setIncludes(cc.getInclude());
    156160
    157161  // Child extracts
     
    161165  childExtractsQuery.restrict(Restrictions.eq(Hql.property("src", "bioMaterial"), Hql.entityParameter("extract", Item.EXTRACT)));
    162166  childExtractsQuery.order(Orders.asc(Hql.property("name")));
    163   childExtractsQuery.include(cc.getInclude());
     167  childExtractsQuery.setIncludes(cc.getInclude());
    164168 
    165169  // Parent extracts
     
    169173  parentExtractsQuery.restrict(Restrictions.eq(Hql.alias("evt"), Hql.entityParameter("creationEvent", Item.BIOMATERIALEVENT)));
    170174  parentExtractsQuery.order(Orders.asc(Hql.property("name")));
    171   parentExtractsQuery.include(cc.getInclude());
     175  parentExtractsQuery.setIncludes(cc.getInclude());
    172176 
     177  // List membership
     178  final ItemQuery<ItemList> listQuery = ItemList.getQuery();
     179  listQuery.setIncludes(cc.getInclude());
     180  listQuery.join(Hql.innerJoin("members", "m"));
     181  listQuery.restrict(Restrictions.eq(Hql.property("memberType"), Expressions.integer(itemType.getValue())));
     182  listQuery.restrict(Restrictions.eq(Hql.alias("m"), Expressions.parameter("itemId", Type.INT)));
     183  listQuery.order(Orders.asc(Hql.property("name")));
     184
    173185  Unit microGram = UnitUtil.getUnit(dc, Quantity.MASS, "µg");
    174186  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
     
    896908                  <%
    897909                  childExtractsQuery.setEntityParameter("extract", item);
    898                   String separator = "";
    899                   for (Extract e : childExtractsQuery.list(dc))
    900                   {
    901                     out.write(separator);
    902                     if (mode.hasPropertyLink())
    903                     {
    904                       out.write(Base.getLinkedName(ID, e, false, mode.hasEditLink()));
    905                     }
    906                     else
    907                     {
    908                       out.write(HTML.encodeTags(e.getName()));
    909                     }
    910                     separator = ", ";
    911                   }
    912910                  %>
     911                  <%=Values.getString(childExtractsQuery.list(dc), ", ", false, nameableFormatter) %>
    913912                  <base:icon
    914913                    id="<%="newextract."+itemId%>"
     
    923922                <tbl:cell column="physicalBioAssays">
    924923                  <%                 
    925                   try
    926                   {
    927                     bioAssayQuery.setEntityParameter("extract", item);
    928                     String separator = "";
    929                     for (PhysicalBioAssay pba : bioAssayQuery.list(dc))
    930                     {
    931                       out.write(separator);
    932                       if (mode.hasPropertyLink())
    933                       {
    934                         out.write(Base.getLinkedName(ID, pba, false, mode.hasEditLink()));
    935                       }
    936                       else
    937                       {
    938                         out.write(HTML.encodeTags(pba.getName()));
    939                       }
    940                       separator = ", ";
    941                     }
    942                   }
    943                   catch (Throwable t)
    944                   {
    945                     %>
    946                     <div class="error"><%=t.getMessage()%></div>
    947                     <%
    948                   }
     924                  bioAssayQuery.setEntityParameter("extract", item);
    949925                  %>
     926                  <%=Values.getString(bioAssayQuery.list(dc), ", ", false, nameableFormatter) %>
    950927                </tbl:cell>
    951928                <tbl:cell column="derivedBioAssays">
    952929                  <%                 
    953                   try
    954                   {
    955                     derivedAssayQuery.setEntityParameter("extract", item);
    956                     String separator = "";
    957                     for (DerivedBioAssay dba : derivedAssayQuery.list(dc))
    958                     {
    959                       out.write(separator);
    960                       if (mode.hasPropertyLink())
    961                       {
    962                         out.write(Base.getLinkedName(ID, dba, false, mode.hasEditLink()));
    963                       }
    964                       else
    965                       {
    966                         out.write(HTML.encodeTags(dba.getName()));
    967                       }
    968                       separator = ", ";
    969                     }
    970                   }
    971                   catch (Throwable t)
    972                   {
    973                     %>
    974                     <div class="error"><%=t.getMessage()%></div>
    975                     <%
    976                   }
     930                  derivedAssayQuery.setEntityParameter("extract", item);
    977931                  %>
     932                  <%=Values.getString(derivedAssayQuery.list(dc), ", ", false, nameableFormatter) %>
    978933                  <base:icon
    979934                    id="<%="newDerivedBioAssay."+itemId%>"
     
    988943                <tbl:cell column="rawBioAssays">
    989944                  <%                 
    990                   try
    991                   {
    992                     rawAssayQuery.setEntityParameter("extract", item);
    993                     String separator = "";
    994                     for (RawBioAssay rba : rawAssayQuery.list(dc))
    995                     {
    996                       out.write(separator);
    997                       if (mode.hasPropertyLink())
    998                       {
    999                         out.write(Base.getLinkedName(ID, rba, false, mode.hasEditLink()));
    1000                       }
    1001                       else
    1002                       {
    1003                         out.write(HTML.encodeTags(rba.getName()));
    1004                       }
    1005                       separator = ", ";
    1006                     }
    1007                   }
    1008                   catch (Throwable t)
    1009                   {
    1010                     %>
    1011                     <div class="error"><%=t.getMessage()%></div>
    1012                     <%
    1013                   }
     945                  rawAssayQuery.setEntityParameter("extract", item);
    1014946                  %>
     947                  <%=Values.getString(rawAssayQuery.list(dc), ", ", false, nameableFormatter) %>
    1015948                  <base:icon
    1016949                    id="<%="newRawBioAssay."+itemId%>"
     
    1022955                    visible="<%=mode.hasEditLink() && createRawBioAssayPermission && usePermission %>"
    1023956                  />
     957                </tbl:cell>
     958                <tbl:cell column="itemList">
     959                  <%
     960                  listQuery.setParameter("itemId", itemId, Type.INT);
     961                  %>
     962                  <%=Values.getString(listQuery.list(dc), ", ", false, nameableFormatter) %>
    1024963                </tbl:cell>
    1025964                <%               
     
    11201059                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
    11211060                <tbl:cell column="sharedTo">
    1122                   <%
    1123                   Iterator<Nameable> sharees = ShareableUtil.getSharedTo(dc, item).iterator();
    1124                   while(sharees.hasNext())
    1125                   {
    1126                     Nameable n = sharees.next();
    1127                     if (mode.hasPropertyLink())
    1128                     {
    1129                       out.write(Base.getLinkedName(ID, n, false, mode.hasEditLink()));
    1130                     }
    1131                     else
    1132                     {
    1133                       out.write(HTML.encodeTags(n.getName()));
    1134                     }
    1135                     out.write(sharees.hasNext() ? ", " : "");
    1136                   }
    1137                   %>
     1061                  <%=Values.getString(ShareableUtil.getSharedTo(dc, item), ", ", false, nameableFormatter) %>
    11381062                </tbl:cell>
    11391063                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
  • branches/3.16-stable/www/biomaterials/extracts/view_extract.jsp

    r7604 r7809  
    628628        <jsp:param name="title" value="Other items related to this extract" />
    629629      </jsp:include>
     630     
     631      <jsp:include page="../../common/itemlists/list_membership.jsp">
     632        <jsp:param name="ID" value="<%=ID%>" />
     633        <jsp:param name="item_type" value="<%=itemType.name()%>" />
     634        <jsp:param name="item_id" value="<%=itemId%>" />
     635        <jsp:param name="title" value="Item lists where this extract is a member" />
     636      </jsp:include>
     637     
    630638      <jsp:include page="../../common/share/list_share.jsp">
    631639        <jsp:param name="ID" value="<%=ID%>" />
  • branches/3.16-stable/www/biomaterials/samples/list_samples.jsp

    r7804 r7809  
    4242  import="net.sf.basedb.core.ItemResultList"
    4343  import="net.sf.basedb.core.ItemContext"
     44  import="net.sf.basedb.core.ItemList"
    4445  import="net.sf.basedb.core.Nameable"
    4546  import="net.sf.basedb.core.Permission"
     
    7273  import="net.sf.basedb.util.formatter.Formatter"
    7374  import="net.sf.basedb.util.formatter.WellCoordinateFormatter"
     75  import="net.sf.basedb.util.formatter.NameableFormatter"
     76  import="net.sf.basedb.clients.web.formatter.LinkedItemFormatter"
    7477  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    7578  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
     
    102105
    103106final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
     107final Formatter<Nameable> nameableFormatter = mode.hasPropertyLink() ? new LinkedItemFormatter(mode.hasEditLink()) : new NameableFormatter();
    104108final String callback = request.getParameter("callback");
    105109final String title = mode.generateTitle("sample", "samples");
     
    125129  childSamplesQuery.restrict(Restrictions.eq(Hql.property("src", "bioMaterial"), Hql.entityParameter("sample", Item.SAMPLE)));
    126130  childSamplesQuery.order(Orders.asc(Hql.property("name")));
    127   childSamplesQuery.include(cc.getInclude());
     131  childSamplesQuery.setIncludes(cc.getInclude());
    128132 
    129133  // Parent samples
     
    133137  parentSamplesQuery.restrict(Restrictions.eq(Hql.alias("evt"), Hql.entityParameter("creationEvent", Item.BIOMATERIALEVENT)));
    134138  parentSamplesQuery.order(Orders.asc(Hql.property("name")));
    135   parentSamplesQuery.include(cc.getInclude());
     139  parentSamplesQuery.setIncludes(cc.getInclude());
    136140
     141  // List membership
     142  final ItemQuery<ItemList> listQuery = ItemList.getQuery();
     143  listQuery.setIncludes(cc.getInclude());
     144  listQuery.join(Hql.innerJoin("members", "m"));
     145  listQuery.restrict(Restrictions.eq(Hql.property("memberType"), Expressions.integer(itemType.getValue())));
     146  listQuery.restrict(Restrictions.eq(Hql.alias("m"), Expressions.parameter("itemId", Type.INT)));
     147  listQuery.order(Orders.asc(Hql.property("name")));
     148 
    137149  Unit microGram = UnitUtil.getUnit(dc, Quantity.MASS, "µg");
    138150  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
     
    842854                  <%
    843855                  childSamplesQuery.setEntityParameter("sample", item);
    844                   String separator = "";
    845                   for (Sample s : childSamplesQuery.list(dc))
    846                   {
    847                     out.write(separator);
    848                     if (mode.hasPropertyLink())
    849                     {
    850                       out.write(Base.getLinkedName(ID, s, false, mode.hasEditLink()));
    851                     }
    852                     else
    853                     {
    854                       out.write(HTML.encodeTags(s.getName()));
    855                     }
    856                     separator = ", ";
    857                   }
    858856                  %>
     857                  <%=Values.getString(childSamplesQuery.list(dc), ", ", false, nameableFormatter) %>
    859858                  <base:icon
    860859                    id="<%="newsample."+itemId%>"
     
    870869                  <%
    871870                  extractQuery.setEntityParameter("sample", item);
    872                   try
    873                   {
    874                     String separator = "";
    875                     for(Extract e : extractQuery.list(dc))
    876                     {
    877                       out.write(separator);
    878                       if (mode.hasPropertyLink())
    879                       {
    880                         out.write(Base.getLinkedName(ID, e, false, mode.hasEditLink()));
    881                       }
    882                       else
    883                       {
    884                         out.write(HTML.encodeTags(e.getName()));
    885                       }
    886                       separator = ", ";
    887                     }
    888                   }
    889                   catch (Throwable t)
    890                   {
    891                     %>
    892                     <div class="error"><%=t.getMessage()%></div>
    893                     <%
    894                   }
    895871                  %>
     872                  <%=Values.getString(extractQuery.list(dc), ", ", false, nameableFormatter) %>
    896873                  <base:icon
    897874                    id="<%="newsample."+itemId%>"
     
    903880                    visible="<%=mode.hasEditLink() && createExtractPermission && usePermission %>"
    904881                  />
     882                </tbl:cell>
     883                <tbl:cell column="itemList">
     884                  <%
     885                  listQuery.setParameter("itemId", itemId, Type.INT);
     886                  %>
     887                  <%=Values.getString(listQuery.list(dc), ", ", false, nameableFormatter) %>
    905888                </tbl:cell>
    906889                <tbl:cell column="owner"
     
    937920                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
    938921                <tbl:cell column="sharedTo">
    939                   <%
    940                   Iterator<Nameable> sharees = ShareableUtil.getSharedTo(dc, item).iterator();
    941                   while(sharees.hasNext())
    942                   {
    943                     Nameable n = sharees.next();
    944                     if (mode.hasPropertyLink())
    945                     {
    946                       out.write(Base.getLinkedName(ID, n, false, mode.hasEditLink()));
    947                     }
    948                     else
    949                     {
    950                       out.write(HTML.encodeTags(n.getName()));
    951                     }
    952                     out.write(sharees.hasNext() ? ", " : "");
    953                   }
    954                   %>
     922                  <%=Values.getString(ShareableUtil.getSharedTo(dc, item), ", ", false, nameableFormatter) %>
    955923                </tbl:cell>
    956924                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
  • branches/3.16-stable/www/biomaterials/samples/view_sample.jsp

    r7604 r7809  
    490490          <jsp:param name="title" value="Other items related to this sample" />
    491491        </jsp:include>
     492       
     493        <jsp:include page="../../common/itemlists/list_membership.jsp">
     494          <jsp:param name="ID" value="<%=ID%>" />
     495          <jsp:param name="item_type" value="<%=itemType.name()%>" />
     496          <jsp:param name="item_id" value="<%=itemId%>" />
     497          <jsp:param name="title" value="Item lists where this sample is a member" />
     498        </jsp:include>
     499     
    492500
    493501        <jsp:include page="../../common/share/list_share.jsp">
  • branches/3.16-stable/www/common/itemlists/list_membership.jsp

    r7808 r7809  
    149149                    RawDataType rdt = list.getRawDataType();
    150150                    %>
    151                     (<%=rdt != null ? HTML.encodeTags(rdt.getName()) : "<i>any</i>"%>)
     151                    <%=rdt != null ? HTML.encodeTags(rdt.getName()) : "<i>any</i>"%>
    152152                    <%
    153153                  }
  • branches/3.16-stable/www/views/derivedbioassays/list_bioassays.jsp

    r7804 r7809  
    3636  import="net.sf.basedb.core.DataFileType"
    3737  import="net.sf.basedb.core.ItemQuery"
     38  import="net.sf.basedb.core.ItemList"
    3839  import="net.sf.basedb.core.Include"
    3940  import="net.sf.basedb.core.Type"
     
    6465  import="net.sf.basedb.clients.web.util.HTML"
    6566  import="net.sf.basedb.util.formatter.Formatter"
     67  import="net.sf.basedb.util.formatter.NameableFormatter"
     68  import="net.sf.basedb.clients.web.formatter.LinkedItemFormatter"
    6669  import="net.sf.basedb.clients.web.formatter.DataFileFormatter"
    6770  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     
    97100
    98101final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
     102final Formatter<Nameable> nameableFormatter = mode.hasPropertyLink() ? new LinkedItemFormatter(mode.hasEditLink()) : new NameableFormatter();
    99103final String callback = request.getParameter("callback");
    100104final String title = mode.generateTitle("derived bioassay", "derived bioassays");
     
    123127  // Query for parent physical bioassays to the current bioassay
    124128  final ItemQuery<PhysicalBioAssay> physicalBioAssayQuery = PhysicalBioAssay.getQuery();
    125   physicalBioAssayQuery.include(cc.getInclude());
     129  physicalBioAssayQuery.setIncludes(cc.getInclude());
    126130  physicalBioAssayQuery.join(Hql.innerJoin("derivedBioAssays", "dba"));
    127131  physicalBioAssayQuery.restrict(Restrictions.eq(Hql.alias("dba"), Expressions.parameter("bioAssay")));
     
    130134  // Query for parent bioassays to the current bioassay
    131135  final ItemQuery<DerivedBioAssay> parentQuery = DerivedBioAssay.getQuery();
    132   parentQuery.include(cc.getInclude());
     136  parentQuery.setIncludes(cc.getInclude());
    133137  parentQuery.join(Hql.innerJoin("children", "c"));
    134138  parentQuery.restrict(Restrictions.eq(Hql.alias("c"), Expressions.parameter("bioAssay")));
     
    137141  // Query for child bioassays to the current bioassay
    138142  final ItemQuery<DerivedBioAssay> childQuery = DerivedBioAssay.getQuery();
    139   childQuery.include(cc.getInclude());
     143  childQuery.setIncludes(cc.getInclude());
    140144  childQuery.join(Hql.innerJoin("parents", "p"));
    141145  childQuery.restrict(Restrictions.eq(Hql.alias("p"), Expressions.parameter("bioAssay")));
     
    144148  // Query for raw bioassays to the current bioassay
    145149  final ItemQuery<RawBioAssay> rawBioAssayQuery = RawBioAssay.getQuery();
    146   rawBioAssayQuery.include(cc.getInclude());
     150  rawBioAssayQuery.setIncludes(cc.getInclude());
    147151  rawBioAssayQuery.restrict(Restrictions.eq(Hql.property("parentBioAssay"), Expressions.parameter("bioAssay")));
    148152  rawBioAssayQuery.order(Orders.asc(Hql.property("name")));
    149  
     153
     154  // List membership
     155  final ItemQuery<ItemList> listQuery = ItemList.getQuery();
     156  listQuery.setIncludes(cc.getInclude());
     157  listQuery.join(Hql.innerJoin("members", "m"));
     158  listQuery.restrict(Restrictions.eq(Hql.property("memberType"), Expressions.integer(itemType.getValue())));
     159  listQuery.restrict(Restrictions.eq(Hql.alias("m"), Expressions.parameter("itemId", Type.INT)));
     160  listQuery.order(Orders.asc(Hql.property("name")));
     161
    150162  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    151163  try
     
    676688                  <%
    677689                  childQuery.setParameter("bioAssay", itemId, Type.INT);
    678                   try
    679                   {
    680                     String separator = "";
    681                     for (DerivedBioAssay child : childQuery.list(dc))
    682                     {
    683                       out.write(separator);
    684                       if (mode.hasPropertyLink())
    685                       {
    686                         out.write(Base.getLinkedName(ID, child, false, mode.hasEditLink()));
    687                       }
    688                       else
    689                       {
    690                         out.write(HTML.encodeTags(child.getName()));
    691                       }
    692                       separator = ", ";
    693                     }
    694                   }
    695                   catch (Throwable t)
    696                   {
    697                     %>
    698                     <div class="error"><%=t.getMessage()%></div>
    699                     <%
    700                   }
    701690                  %>             
     691                  <%=Values.getString(childQuery.list(dc), ", ", false, nameableFormatter) %>
    702692                  <base:icon
    703693                    subclass="link auto-init"
     
    712702                  <%
    713703                  rawBioAssayQuery.setParameter("bioAssay", itemId, Type.INT);
    714                   try
    715                   {
    716                     String separator = "";
    717                     for (RawBioAssay rba : rawBioAssayQuery.list(dc))
    718                     {
    719                       out.write(separator);
    720                       if (mode.hasPropertyLink())
    721                       {
    722                         out.write(Base.getLinkedName(ID, rba, false, mode.hasEditLink()));
    723                       }
    724                       else
    725                       {
    726                         out.write(HTML.encodeTags(rba.getName()));
    727                       }
    728                       separator = ", ";
    729                     }
    730                   }
    731                   catch (Throwable t)
    732                   {
    733                     %>
    734                     <div class="error"><%=t.getMessage()%></div>
    735                     <%
    736                   }
    737704                  %>             
     705                  <%=Values.getString(rawBioAssayQuery.list(dc), ", ", false, nameableFormatter) %>
    738706                  <base:icon
    739707                    subclass="link auto-init"
     
    748716                  <%
    749717                  physicalBioAssayQuery.setParameter("bioAssay", itemId, Type.INT);
    750                   try
    751                   {
    752                     String separator = "";
    753                     for (PhysicalBioAssay pba : physicalBioAssayQuery.list(dc))
    754                     {
    755                       out.write(separator);
    756                       if (mode.hasPropertyLink())
    757                       {
    758                         out.write(Base.getLinkedName(ID, pba, false, mode.hasEditLink()));
    759                       }
    760                       else
    761                       {
    762                         out.write(HTML.encodeTags(pba.getName()));
    763                       }
    764                       separator = ", ";
    765                     }
    766                   }
    767                   catch (Throwable t)
    768                   {
    769                     %>
    770                     <div class="error"><%=t.getMessage()%></div>
    771                     <%
    772                   }
    773718                  %>             
     719                  <%=Values.getString(physicalBioAssayQuery.list(dc), ", ", false, nameableFormatter) %>
    774720                </tbl:cell>
    775721                <tbl:cell column="parents">
     
    778724                  {
    779725                    parentQuery.setParameter("bioAssay", itemId, Type.INT);
    780                     try
    781                     {
    782                       String separator = "";
    783                       for (DerivedBioAssay dba : parentQuery.list(dc))
    784                       {
    785                         out.write(separator);
    786                         if (mode.hasPropertyLink())
    787                         {
    788                           out.write(Base.getLinkedName(ID, dba, false, mode.hasEditLink()));
    789                         }
    790                         else
    791                         {
    792                           out.write(HTML.encodeTags(dba.getName()));
    793                         }
    794                         separator = ", ";
    795                       }
    796                     }
    797                     catch (Throwable t)
    798                     {
    799                       %>
    800                       <div class="error"><%=t.getMessage()%></div>
    801                       <%
    802                     }
     726                    %>
     727                    <%=Values.getString(parentQuery.list(dc), ", ", false, nameableFormatter) %>
     728                    <%
    803729                  }
    804730                  %>             
     731                </tbl:cell>
     732                <tbl:cell column="itemList">
     733                  <%
     734                  listQuery.setParameter("itemId", itemId, Type.INT);
     735                  %>
     736                  <%=Values.getString(listQuery.list(dc), ", ", false, nameableFormatter) %>
    805737                </tbl:cell>
    806738                <tbl:cell column="extract"
     
    896828                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
    897829                <tbl:cell column="sharedTo">
    898                   <%
    899                   Iterator<Nameable> sharees = ShareableUtil.getSharedTo(dc, item).iterator();
    900                   while(sharees.hasNext())
    901                   {
    902                     Nameable n = sharees.next();
    903                     if (mode.hasPropertyLink())
    904                     {
    905                       out.write(Base.getLinkedName(ID, n, false, mode.hasEditLink()));
    906                     }
    907                     else
    908                     {
    909                       out.write(HTML.encodeTags(n.getName()));
    910                     }
    911                     out.write(sharees.hasNext() ? ", " : "");
    912                   }
    913                   %>
     830                  <%=Values.getString(ShareableUtil.getSharedTo(dc, item), ", ", false, nameableFormatter) %>
    914831                </tbl:cell>
    915832                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
  • branches/3.16-stable/www/views/derivedbioassays/view_bioassay.jsp

    r7786 r7809  
    740740        <jsp:param name="title" value="Other items related to this bioassay" />
    741741      </jsp:include>
     742      <jsp:include page="../../common/itemlists/list_membership.jsp">
     743        <jsp:param name="ID" value="<%=ID%>" />
     744        <jsp:param name="item_type" value="<%=itemType.name()%>" />
     745        <jsp:param name="item_id" value="<%=itemId%>" />
     746        <jsp:param name="title" value="Item lists where this bioassay is a member" />
     747      </jsp:include>
     748     
    742749      <jsp:include page="../../common/share/list_share.jsp">
    743750        <jsp:param name="ID" value="<%=ID%>" />
  • branches/3.16-stable/www/views/physicalbioassays/list_bioassays.jsp

    r7804 r7809  
    4444  import="net.sf.basedb.core.ItemResultList"
    4545  import="net.sf.basedb.core.ItemContext"
     46  import="net.sf.basedb.core.ItemList"
    4647  import="net.sf.basedb.core.Nameable"
    4748  import="net.sf.basedb.core.Permission"
     
    6768  import="net.sf.basedb.clients.web.util.HTML"
    6869  import="net.sf.basedb.util.formatter.Formatter"
     70  import="net.sf.basedb.util.formatter.NameableFormatter"
     71  import="net.sf.basedb.clients.web.formatter.LinkedItemFormatter"
    6972  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    7073  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
     
    98101
    99102final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
     103final Formatter<Nameable> nameableFormatter = mode.hasPropertyLink() ? new LinkedItemFormatter(mode.hasEditLink()) : new NameableFormatter();
    100104final String callback = request.getParameter("callback");
    101105final String title = mode.generateTitle("physical bioassay", "physical bioassays");
     
    121125  // Query for extracts relatated to the current bioassay
    122126  final ItemQuery<Extract> extractQuery = Extract.getQuery();
    123   extractQuery.include(cc.getInclude());
     127  extractQuery.setIncludes(cc.getInclude());
    124128  extractQuery.join(Hql.innerJoin("childCreationEvents", "cce"));
    125129  extractQuery.join(Hql.innerJoin("cce", "event", "evt"));
     
    130134  // Query for derived bioassay sets from to the current bioassay
    131135  final ItemQuery<DerivedBioAssay> dbasQuery = DerivedBioAssay.getQuery();
    132   dbasQuery.include(cc.getInclude());
     136  dbasQuery.setIncludes(cc.getInclude());
    133137  dbasQuery.join(Hql.innerJoin("physicalBioAssays", "pba"));
    134138  dbasQuery.restrict(Restrictions.eq(Hql.alias("pba"), Expressions.parameter("bioAssay")));
    135139  dbasQuery.restrict(Restrictions.eq(Hql.property("root"), Expressions.bool(true)));
    136140  dbasQuery.order(Orders.asc(Hql.property("name")));
     141
     142  // List membership
     143  final ItemQuery<ItemList> listQuery = ItemList.getQuery();
     144  listQuery.setIncludes(cc.getInclude());
     145  listQuery.join(Hql.innerJoin("members", "m"));
     146  listQuery.restrict(Restrictions.eq(Hql.property("memberType"), Expressions.integer(itemType.getValue())));
     147  listQuery.restrict(Restrictions.eq(Hql.alias("m"), Expressions.parameter("itemId", Type.INT)));
     148  listQuery.order(Orders.asc(Hql.property("name")));
     149
    137150  final boolean createDerivedBioAssayPermission = sc.hasPermission(Permission.CREATE, Item.DERIVEDBIOASSAY); 
    138151 
     
    693706                  <%
    694707                  dbasQuery.setParameter("bioAssay", itemId, Type.INT);
    695                   try
    696                   {
    697                     String separator = "";
    698                     for (DerivedBioAssay dbas : dbasQuery.list(dc))
    699                     {
    700                       out.write(separator);
    701                       if (mode.hasPropertyLink())
    702                       {
    703                         out.write(Base.getLinkedName(ID, dbas, false, mode.hasEditLink()));
    704                       }
    705                       else
    706                       {
    707                         out.write(HTML.encodeTags(dbas.getName()));
    708                       }
    709                       separator = ", ";
    710                     }
    711                   }
    712                   catch (Throwable t)
    713                   {
    714                     %>
    715                     <div class="error"><%=t.getMessage()%></div>
    716                     <%
    717                   }
    718708                  %>
     709                  <%=Values.getString(dbasQuery.list(dc), ", ", false, nameableFormatter) %>
    719710                  <base:icon
    720711                    subclass="link auto-init"
     
    725716                    visible="<%=mode.hasEditLink() && createDerivedBioAssayPermission && usePermission %>"
    726717                  />
     718                </tbl:cell>
     719                <tbl:cell column="itemList">
     720                  <%
     721                  listQuery.setParameter("itemId", itemId, Type.INT);
     722                  %>
     723                  <%=Values.getString(listQuery.list(dc), ", ", false, nameableFormatter) %>
    727724                </tbl:cell>
    728725                <tbl:cell column="protocol"
     
    782779                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
    783780                <tbl:cell column="sharedTo">
    784                   <%
    785                   Iterator<Nameable> sharees = ShareableUtil.getSharedTo(dc, item).iterator();
    786                   while(sharees.hasNext())
    787                   {
    788                     Nameable n = sharees.next();
    789                     if (mode.hasPropertyLink())
    790                     {
    791                       out.write(Base.getLinkedName(ID, n, false, mode.hasEditLink()));
    792                     }
    793                     else
    794                     {
    795                       out.write(HTML.encodeTags(n.getName()));
    796                     }
    797                     out.write(sharees.hasNext() ? ", " : "");
    798                   }
    799                   %>
     781                  <%=Values.getString(ShareableUtil.getSharedTo(dc, item), ", ", false, nameableFormatter) %>
    800782                </tbl:cell>
    801783                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
  • branches/3.16-stable/www/views/physicalbioassays/view_bioassay.jsp

    r7604 r7809  
    476476        <jsp:param name="title" value="Other items related to this physical bioassay" />
    477477      </jsp:include>
     478      <jsp:include page="../../common/itemlists/list_membership.jsp">
     479        <jsp:param name="ID" value="<%=ID%>" />
     480        <jsp:param name="item_type" value="<%=itemType.name()%>" />
     481        <jsp:param name="item_id" value="<%=itemId%>" />
     482        <jsp:param name="title" value="Item lists where this physical bioassay is a member" />
     483      </jsp:include>
     484     
    478485      <jsp:include page="../../common/share/list_share.jsp">
    479486        <jsp:param name="ID" value="<%=ID%>" />
  • branches/3.16-stable/www/views/rawbioassays/list_rawbioassays.jsp

    r7804 r7809  
    4747  import="net.sf.basedb.core.ItemResultList"
    4848  import="net.sf.basedb.core.ItemContext"
     49  import="net.sf.basedb.core.ItemList"
    4950  import="net.sf.basedb.core.Job"
    5051  import="net.sf.basedb.core.Nameable"
     
    7576  import="net.sf.basedb.util.Values"
    7677  import="net.sf.basedb.util.formatter.Formatter"
     78  import="net.sf.basedb.util.formatter.NameableFormatter"
     79  import="net.sf.basedb.clients.web.formatter.LinkedItemFormatter"
    7780  import="net.sf.basedb.clients.web.formatter.DataFileFormatter"
    7881  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     
    108111
    109112final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
     113final Formatter<Nameable> nameableFormatter = mode.hasPropertyLink() ? new LinkedItemFormatter(mode.hasEditLink()) : new NameableFormatter();
    110114final String callback = request.getParameter("callback");
    111115final String title = mode.generateTitle("raw bioassay", "raw bioassays");
     
    133137  // Query for experiments relatated to the current raw bioassay
    134138  final ItemQuery<Experiment> experimentQuery = Experiment.getQuery();
    135   experimentQuery.include(cc.getInclude());
     139  experimentQuery.setIncludes(cc.getInclude());
    136140  experimentQuery.join(Hql.innerJoin("rawBioAssays", "rba"));
    137141  experimentQuery.restrict(Restrictions.eq(Hql.alias("rba"), Expressions.parameter("rawBioAssay")));
    138142  experimentQuery.order(Orders.asc(Hql.property("name")));
    139  
     143
     144  // List membership
     145  final ItemQuery<ItemList> listQuery = ItemList.getQuery();
     146  listQuery.setIncludes(cc.getInclude());
     147  listQuery.join(Hql.innerJoin("members", "m"));
     148  listQuery.restrict(Restrictions.eq(Hql.property("memberType"), Expressions.integer(itemType.getValue())));
     149  listQuery.restrict(Restrictions.eq(Hql.alias("m"), Expressions.parameter("itemId", Type.INT)));
     150  listQuery.order(Orders.asc(Hql.property("name")));
     151
    140152  // Get all platforms
    141153  final ItemQuery<Platform> platformQuery = Platform.getQuery();
    142   platformQuery.include(cc.getInclude());
     154  platformQuery.setIncludes(cc.getInclude());
    143155  platformQuery.order(Orders.asc(Hql.property("name")));
    144156  platformQuery.setCacheResult(true);
     
    818830                  value="<%=job == null ? null : job.getEnded() %>"
    819831                />
     832                <tbl:cell column="itemList">
     833                  <%
     834                  listQuery.setParameter("itemId", itemId, Type.INT);
     835                  %>
     836                  <%=Values.getString(listQuery.list(dc), ", ", false, nameableFormatter) %>
     837                </tbl:cell>
    820838                <tbl:cell column="experiments">
    821839                  <%
    822840                  experimentQuery.setParameter("rawBioAssay", itemId, Type.INT);
    823                   try
    824                   {
    825                     String separator = "";
    826                     for (Experiment e : experimentQuery.list(dc))
    827                     {
    828                       out.write(separator);
    829                       if (mode.hasPropertyLink())
    830                       {
    831                         out.write(Base.getLinkedName(ID, e, false, mode.hasEditLink()));
    832                       }
    833                       else
    834                       {
    835                         out.write(HTML.encodeTags(e.getName()));
    836                       }
    837                       separator = ", ";
    838                     }
    839                   }
    840                   catch (Throwable t)
    841                   {
    842                     %>
    843                     <div class="error"><%=t.getMessage()%></div>
    844                     <%
    845                   }
    846841                  %>
     842                  <%=Values.getString(experimentQuery.list(dc), ", ", false, nameableFormatter) %>
    847843                </tbl:cell>
    848844                <tbl:cell column="owner"
     
    889885                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
    890886                <tbl:cell column="sharedTo">
    891                   <%
    892                   Iterator<Nameable> sharees = ShareableUtil.getSharedTo(dc, item).iterator();
    893                   while(sharees.hasNext())
    894                   {
    895                     Nameable n = sharees.next();
    896                     if (mode.hasPropertyLink())
    897                     {
    898                       out.write(Base.getLinkedName(ID, n, false, mode.hasEditLink()));
    899                     }
    900                     else
    901                     {
    902                       out.write(HTML.encodeTags(n.getName()));
    903                     }
    904                     out.write(sharees.hasNext() ? ", " : "");
    905                   }
    906                   %>
     887                  <%=Values.getString(ShareableUtil.getSharedTo(dc, item), ", ", false, nameableFormatter) %>
    907888                </tbl:cell>
    908889                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
  • branches/3.16-stable/www/views/rawbioassays/view_rawbioassay.jsp

    r7635 r7809  
    592592        <jsp:param name="title" value="Other items related to this sample" />
    593593      </jsp:include>
     594      <jsp:include page="../../common/itemlists/list_membership.jsp">
     595        <jsp:param name="ID" value="<%=ID%>" />
     596        <jsp:param name="item_type" value="<%=itemType.name()%>" />
     597        <jsp:param name="item_id" value="<%=itemId%>" />
     598        <jsp:param name="title" value="Item lists where this raw bioassay is a member" />
     599      </jsp:include>
     600     
    594601      <jsp:include page="../../common/share/list_share.jsp">
    595602        <jsp:param name="ID" value="<%=ID%>" />
Note: See TracChangeset for help on using the changeset viewer.