Changeset 6328


Ignore:
Timestamp:
Oct 15, 2013, 2:11:28 PM (9 years ago)
Author:
olle
Message:

Refs #1771. Support for annotatable Hardware items added.

Location:
trunk
Files:
15 edited

Legend:

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

    r6092 r6328  
    367367      }
    368368      if (getData().getExtract() != null) annotatable.add(getExtract());
     369      if (getData().getHardware() != null) annotatable.add(getHardware());
    369370    }
    370371    catch (PermissionDeniedException ex)
  • trunk/src/core/net/sf/basedb/core/Hardware.java

    r6127 r6328  
    3838*/
    3939public class Hardware
    40   extends CommonItem<HardwareData>
     40  extends AnnotatedItem<HardwareData>
    4141  implements Registered, Subtypable
    4242{
     
    211211  {
    212212    return DateUtil.copy(getData().getEntryDate());
     213  }
     214  // -------------------------------------------
     215  /*
     216    From the Annotatable interface
     217    -------------------------------------------
     218  */
     219  /**
     220    @return Always null
     221    @since 2.12
     222  */
     223  @Override
     224  public Set<Annotatable> getAnnotatableParents()
     225  {
     226    return null;
    213227  }
    214228  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Install.java

    r6268 r6328  
    119119    method.
    120120  */
    121   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(112).intValue();
     121  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(113).intValue();
    122122 
    123123  public static synchronized int createTables(SchemaGenerator.Mode mode, ProgressReporter progress,
  • trunk/src/core/net/sf/basedb/core/PhysicalBioAssay.java

    r6132 r6328  
    326326      annotatable.addAll(query.list(getDbControl()));
    327327      if (getData().getArraySlide() != null) annotatable.add(getArraySlide());
     328      if (getCreationEvent().getHardware() != null) annotatable.add(getCreationEvent().getHardware());
    328329    }
    329330    catch (PermissionDeniedException ex)
  • trunk/src/core/net/sf/basedb/core/Update.java

    r6268 r6328  
    178178    </td>
    179179  </tr>
     180  <tr>
     181    <td>113</td>
     182    <td>
     183      Made {@link Hardware} an {@link Annotatable} item.
     184      No special database update is needed. Only increase the schema version.
     185      For more info see BASE ticket: http://base.thep.lu.se/ticket/1771
     186    </td>
     187  </tr>
    180188  </table>
    181189
     
    291299        if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 112...");
    292300        schemaVersion = updateToSchemaVersion112(session, progress);
     301        progress_current += progress_step;
     302      }
     303
     304      if (schemaVersion < 113)
     305      {
     306        if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 113...");
     307        // Schemaversion 113 only updates the version number
     308        schemaVersion = setSchemaVersionInTransaction(session, 113);
    293309        progress_current += progress_step;
    294310      }
  • trunk/src/core/net/sf/basedb/core/data/HardwareData.java

    r6127 r6328  
    3636*/
    3737public class HardwareData
    38   extends CommonData
     38  extends AnnotatedData
    3939  implements RegisteredData, SubtypableData
    4040{
  • trunk/src/core/net/sf/basedb/util/overview/loader/HardwareLoader.java

    r6210 r6328  
    113113    NodeFactory<Hardware> nf = getNodeFactory(dc, context);
    114114    Node hardwareNode = createItemNode(nf, hardware, hardware, denied,
    115         parentNode, ChildNodeDirection.NONE);
     115        parentNode, ChildNodeDirection.PROPERTY);
    116116    return hardwareNode;
    117117  }
    118118  // -----------------------------------
    119  
     119  /*
     120    From the AbstractNodeLoader class
     121    ----------------------------------
     122  */
     123  /**
     124    Loads annotations and hardware parameters for the given hardware node.
     125    @see RawBioAssayLoader#createForwardNode(DbControl, OverviewContext, Node)
     126  */
     127  @Override
     128  protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node hardwareNode)
     129  {
     130    getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, hardwareNode);
     131  }
     132  // ------------------------------------- 
    120133}
  • trunk/www/admin/hardware/edit_hardware.jsp

    r6296 r6328  
    2626--%>
    2727<%@ page pageEncoding="UTF-8" session="false"
     28  import="net.sf.basedb.core.AnnotationType"
    2829  import="net.sf.basedb.core.SessionControl"
    2930  import="net.sf.basedb.core.DbControl"
     
    102103  %>
    103104  <base:page type="popup" title="<%=title%>" id="edit-page">
    104   <base:head scripts="tabcontrol-2.js,subtypes.js,~hardware.js" styles="tabcontrol.css">
     105  <base:head scripts="tabcontrol-2.js,annotations.js,subtypes.js,~hardware.js" styles="tabcontrol.css">
    105106    <ext:scripts context="<%=jspContext%>" />
    106107    <ext:stylesheets context="<%=jspContext%>" />
     
    196197      </table>
    197198    </t:tab>
     199    <t:tab id="annotations" title="Annotations" helpid="annotations.edit">
     200      <jsp:include page="../../common/annotations/annotate_frameset.jsp">
     201        <jsp:param name="item_type" value="<%=itemType.name()%>" />
     202        <jsp:param name="item_id" value="<%=itemId%>" />
     203        <jsp:param name="ID" value="<%=ID%>" />
     204      </jsp:include>
     205    </t:tab>
    198206    </t:tabcontrol>
    199207    </form>
  • trunk/www/admin/hardware/hardware.js

    r6297 r6328  
    4040
    4141      // Tab validation
     42      TabControl.addTabActivateListener('settings.annotations', hardware.loadAnnotationsFrame);
    4243      TabControl.addTabValidator('settings.info', hardware.validateHardware);
    4344     
     
    6061      Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes);
    6162      Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes);
     63
     64      TabControl.addTabActivateListener('main.annotations', AnnotationsList.loadOnce);
    6265    }
    6366    else if (pageId == 'list-page')
     
    97100    if (TabControl.validateActiveTab('settings'))
    98101    {
     102      Annotations.saveModifiedAnnotationsToForm(frm);
    99103      frm.submit();
    100104    }
    101105  }
    102106 
     107  hardware.loadAnnotationsFrame = function()
     108  {
     109    Annotations.autoLoadEditFrame(null, ItemSubtype.getSubtypeId('subtype_id'));
     110  }
     111
    103112  hardware.subtypeOnChange = function()
    104113  {
  • trunk/www/admin/hardware/index.jsp

    r6192 r6328  
    179179      }
    180180     
     181      Base.updateAnnotations(dc, hardware, hardware, request);
    181182      // OnSave extensions
    182183      invoker.render(OnSaveRenderer.ON_SAVE);
     
    215216      message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission";
    216217    }
    217     redirect = listPage;
     218    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
    218219  }
    219220  else if ("RestoreItem".equals(cmd))
     
    238239      message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission";
    239240    }
    240     redirect = listPage;
     241    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
    241242  }
    242243  else if ("ShareItem".equals(cmd))
  • trunk/www/admin/hardware/list_hardware.jsp

    r6262 r6328  
    3030  import="net.sf.basedb.core.Hardware"
    3131  import="net.sf.basedb.core.ItemSubtype"
     32  import="net.sf.basedb.core.Annotation"
     33  import="net.sf.basedb.core.AnnotationType"
     34  import="net.sf.basedb.core.AnnotationSet"
    3235  import="net.sf.basedb.core.ItemQuery"
    3336  import="net.sf.basedb.core.Include"
     
    8083final DbControl dc = sc.newDbControl();
    8184ItemResultIterator<Hardware> hardware = null;
     85ItemResultList<AnnotationType> annotationTypes = null;
    8286try
    8387{
    8488  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    8589  final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType);
     90  final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
     91  annotationTypes = annotationTypeQuery.list(dc);
    8692
    8793  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
     
    197203        exportable="true"
    198204      />
     205      <%
     206      for (AnnotationType at : annotationTypes)
     207      {
     208        Enumeration<String, String> annotationEnum = null;
     209        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
     210        if (at.isEnumeration())
     211        {
     212          annotationEnum = new Enumeration<String, String>();
     213          List<?> values = at.getValues();
     214          for (Object value : values)
     215          {
     216            String encoded = formatter.format(value);
     217            annotationEnum.add(encoded, encoded);
     218          }
     219        }
     220        %>
     221        <tbl:columndef
     222          id="<%="at"+at.getId()%>"
     223          title="<%=HTML.encodeTags(at.getName())+" [A]"%>"
     224          property="<%="#"+at.getId()%>"
     225          annotation="true"
     226          datatype="<%=at.getValueType().getStringValue()%>"
     227          enumeration="<%=annotationEnum%>"
     228          smartenum="<%=at.getDisplayAsList() %>"
     229          sortable="<%=at.getMultiplicity() == 1%>"
     230          filterable="true"
     231          exportable="true"
     232          formatter="<%=formatter%>"
     233          unit="<%=at.getDefaultUnit()%>"
     234        />
     235        <%
     236      }
     237      %> 
    199238      <tbl:columndef
    200239        id="permission"
     
    416455                  /></tbl:cell>
    417456                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
     457                <%
     458                AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
     459                if (as != null)
     460                {
     461                  for (AnnotationType at : annotationTypes)
     462                  {
     463                    if (as.hasAnnotation(at))
     464                    {
     465                      Annotation a = as.getAnnotation(at);
     466                      String suffix = a.getUnitSymbol(null);
     467                      if (suffix != null) suffix = "&nbsp;" + suffix;
     468                      %>
     469                      <tbl:cell
     470                        column="<%="at"+at.getId()%>"
     471                        ><tbl:cellvalue
     472                          list="<%=a.getValues(null)%>"
     473                          suffix="<%=suffix%>"
     474                      /></tbl:cell>
     475                      <%
     476                    }
     477                  }
     478                }
     479                %>
    418480                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
    419481                <tbl:cell column="sharedTo">
  • trunk/www/admin/hardware/view_hardware.jsp

    r6262 r6328  
    251251      </jsp:include>
    252252    </t:tab>
     253    <t:tab id="annotations" title="Annotations"
     254      tooltip="View annotation values" clazz="white">
     255      <jsp:include page="../../common/annotations/list_frameset.jsp">
     256        <jsp:param name="item_type" value="<%=itemType.name()%>" />
     257        <jsp:param name="item_id" value="<%=itemId%>" />
     258        <jsp:param name="ID" value="<%=ID%>" />
     259      </jsp:include>
     260    </t:tab>
    253261    </t:tabcontrol>
    254262  </base:body>
  • trunk/www/include/scripts/main.js

    r6315 r6328  
    512512    this.controllers['FORMULA'] = { url:'views/formulas/index.jsp', width:750, height:500 };
    513513    this.controllers['GROUP'] = { url:'admin/groups/index.jsp', width:600, height:400 };
    514     this.controllers['HARDWARE'] = { url:'admin/hardware/index.jsp', width:450, height:300 };
     514    this.controllers['HARDWARE'] = { url:'admin/hardware/index.jsp', width:800, height:500 };
    515515    this.controllers['HELP'] = { url:'admin/clients/help/index.jsp', width:600, height:400, noAnyToAny:true };
    516516    this.controllers['ITEMSUBTYPE'] = { url:'admin/itemsubtypes/index.jsp', width:600, height:400 };
  • trunk/www/views/derivedbioassays/bioassays.js

    r6314 r6328  
    236236    var extractId = Math.abs(parseInt(frm.extract_id.value));
    237237    if (extractId > 0) parents[parents.length] = 'EXTRACT:'+extractId;
     238    var protocolId = Math.abs(parseInt(frm.protocol_id.value));
     239    if (protocolId > 0) parents[parents.length] = 'PROTOCOL:'+protocolId;
     240    var hardwareId = Math.abs(parseInt(frm.hardware_id.value));
     241    if (hardwareId > 0) parents[parents.length] = 'HARDWARE:'+hardwareId;
    238242    return parents;
    239243  }
  • trunk/www/views/physicalbioassays/bioassays.js

    r6314 r6328  
    199199    var arraySlideId = Math.abs(parseInt(frm.arrayslide_id.value));
    200200    if (arraySlideId > 0) parents[parents.length] = 'ARRAYSLIDE:'+arraySlideId;
     201    var hardwareId = Math.abs(parseInt(frm.hardware_id.value));
     202    if (hardwareId > 0) parents[parents.length] = 'HARDWARE:'+hardwareId;
    201203
    202204    var ids = Link.getIdsInList(frm.extracts, 'EXTRACT');
Note: See TracChangeset for help on using the changeset viewer.