Changeset 7199


Ignore:
Timestamp:
Oct 17, 2016, 10:38:36 AM (6 years ago)
Author:
Nicklas Nordborg
Message:

References #2029: Projects should be annotatable

Added support for annotations to the project list page, view page and edit page.

Also enabled logging for projects so that it is possible to keep track of changes to the annotation values.

Location:
trunk
Files:
7 edited

Legend:

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

    r7198 r7199  
    4343public class ProjectData
    4444  extends OwnedData
    45   implements NameableData, RemovableData, RegisteredData, AnnotatableData
     45  implements NameableData, RemovableData, RegisteredData,
     46    AnnotatableData, LoggableData
    4647{
    4748
  • trunk/www/include/scripts/main-2.js

    r7096 r7199  
    20502050    controllers['PLUGINDEFINITION'] = { url:'admin/plugindefinitions/index.jsp', width:750, height:500 };
    20512051    controllers['PLUGINTYPE'] = { url:'admin/plugintypes/index.jsp', width:600, height:400 };
    2052     controllers['PROJECT'] = { url:'my_base/projects/index.jsp', width:600, height:400 };
     2052    controllers['PROJECT'] = { url:'my_base/projects/index.jsp', width:750, height:500 };
    20532053    controllers['PROTOCOL'] = { url:'admin/protocols/index.jsp', width:750, height:500 };
    20542054    controllers['QUANTITY'] = { url:'admin/quantities/index.jsp', width:450, height:300 };
  • trunk/www/my_base/projects/edit_project.jsp

    r6610 r7199  
    468468      </table>
    469469    </t:tab>
     470   
     471    <t:tab id="annotations" title="Annotations" helpid="annotations.edit">
     472      <jsp:include page="../../common/annotations/annotate_frameset.jsp">
     473        <jsp:param name="item_type" value="<%=itemType.name()%>" />
     474        <jsp:param name="item_id" value="<%=itemId%>" />
     475        <jsp:param name="ID" value="<%=ID%>" />
     476      </jsp:include>
     477    </t:tab>
     478   
    470479    </t:tabcontrol>
    471480    </form>
  • trunk/www/my_base/projects/index.jsp

    r6320 r7199  
    217217      project.setDefaultRawDataType(rdt);   
    218218     
     219      // Annotations tab
     220      Base.updateAnnotations(dc, project, project, request);
     221     
    219222      // OnSave extensions
    220223      invoker.render(OnSaveRenderer.ON_SAVE);
  • trunk/www/my_base/projects/list_projects.jsp

    r6834 r7199  
    2929  import="net.sf.basedb.core.Item"
    3030  import="net.sf.basedb.core.Project"
     31  import="net.sf.basedb.core.AnnotationType"
    3132  import="net.sf.basedb.core.ItemQuery"
    3233  import="net.sf.basedb.core.Include"
     
    4142  import="net.sf.basedb.core.plugin.GuiContext"
    4243  import="net.sf.basedb.core.plugin.Plugin"
     44  import="net.sf.basedb.core.snapshot.AnnotationLoaderUtil"
     45  import="net.sf.basedb.core.snapshot.AnnotationSetSnapshot"
     46  import="net.sf.basedb.core.snapshot.SnapshotManager"
    4347  import="net.sf.basedb.util.Enumeration"
    4448  import="net.sf.basedb.clients.web.Base"
     
    5660  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
    5761  import="java.util.Date"
     62  import="java.util.ArrayList"
    5863  import="java.util.List"
    5964  import="java.util.Map"
     
    7782final DbControl dc = sc.newDbControl();
    7883ItemResultIterator<Project> projects = null;
     84List<AnnotationLoaderUtil> annotationLoaders = new ArrayList<AnnotationLoaderUtil>();
    7985try
    8086{
    8187  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
     88
     89  ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
     90  SnapshotManager manager = new SnapshotManager();
     91  for (AnnotationType at : annotationTypeQuery.list(dc))
     92  {
     93    annotationLoaders.add(new AnnotationLoaderUtil(dc, manager, at));
     94  }
     95 
    8296  try
    8397  {
     
    89103    cc.setMessage(t.getMessage());
    90104  }
     105 
    91106  int numListed = 0;
    92107  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     
    181196        exportable="true"
    182197      />
     198      <%
     199      for (AnnotationLoaderUtil loader : annotationLoaders)
     200      {
     201        AnnotationType at = loader.getAnnotationType();
     202        Enumeration<String, String> annotationEnum = null;
     203        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
     204        if (at.isEnumeration())
     205        {
     206          annotationEnum = new Enumeration<String, String>();
     207          if (!at.getDisplayAsList()) annotationEnum.add("", "-none-");
     208          List<?> values = at.getValues();
     209          for (Object value : values)
     210          {
     211            String encoded = formatter.format(value);
     212            annotationEnum.add(encoded, encoded);
     213          }
     214        }
     215        %>
     216        <tbl:columndef
     217          id="<%=(loader.isSearchingInheritedAnnotations() ? "ia" : "at")+at.getId()%>"
     218          title="<%=HTML.encodeTags(at.getName())+(loader.isSearchingInheritedAnnotations() ? " [I]" : " [A]")%>"
     219          property="<%=(loader.isSearchingInheritedAnnotations() ? "##" : "#")+at.getId()%>"
     220          annotation="true"
     221          datatype="<%=at.getValueType().getStringValue()%>"
     222          enumeration="<%=annotationEnum%>"
     223          smartenum="<%=at.getDisplayAsList() %>"
     224          sortable="<%=at.getMultiplicity() == 1 && !loader.isSearchingInheritedAnnotations()%>"
     225          filterable="true"
     226          exportable="true"
     227          formatter="<%=formatter%>"
     228          unit="<%=at.getDefaultUnit()%>"
     229        />
     230        <%
     231      }
     232      %>
    183233      <tbl:columndef
    184234        id="actions"
     
    406456                <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" />
    407457                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
     458                <%
     459                if (item.isAnnotated())
     460                {
     461                  AnnotationSetSnapshot snapshot = manager.getSnapshot(dc, item.getAnnotationSet().getId());
     462                  for (AnnotationLoaderUtil loader : annotationLoaders)
     463                  {
     464                    %>
     465                    <tbl:cell
     466                      column="<%=(loader.isSearchingInheritedAnnotations() ? "ia" : "at")+loader.getId()%>"
     467                      ><%
     468                      if (loader.find(snapshot))
     469                      {
     470                        %><tbl:cellvalue
     471                          list="<%=loader.getValues()%>"
     472                          suffix="<%=loader.getUnitSymbol()%>"
     473                        /><%
     474                      }
     475                      %></tbl:cell>
     476                    <%
     477                  }
     478                }
     479                %>
    408480                <tbl:cell column="actions"><span class="link auto-init" data-auto-init="set-active" data-item-id="<%=itemId%>">Set active</span></tbl:cell>
    409481                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
  • trunk/www/my_base/projects/projects.js

    r7030 r7199  
    4949      // Tab validation
    5050      TabControl.addTabValidator('settings.info', projects.validateProject);
     51      TabControl.addTabActivateListener('settings.annotations', Annotations.autoLoadEditFrame);
    5152
    5253      // Members
     
    9899     
    99100      TabControl.addTabActivateListener('main.items', projects.viewItems);
     101      TabControl.addTabActivateListener('main.annotations', AnnotationsList.loadOnce);
     102      TabControl.addTabActivateListener('main.history', History.loadOnce);
    100103    }
    101104    else if (pageId == 'list-page')
     
    163166    if (TabControl.validateActiveTab('settings'))
    164167    {
     168      Annotations.saveModifiedAnnotationsToForm(frm);
    165169      Link.exportActions('defaultItems');
    166170      Link.exportActions('members', '!');
  • trunk/www/my_base/projects/view_project.jsp

    r6605 r7199  
    4747  import="net.sf.basedb.core.query.Hql"
    4848  import="net.sf.basedb.clients.web.Base"
     49  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
    4950  import="net.sf.basedb.clients.web.PermissionUtil"
    5051  import="net.sf.basedb.clients.web.util.HTML"
     
    419420     
    420421    <t:tab id="items" title="Items" tooltip="List all items in this project" />
    421      
     422    <t:tab id="annotations" title="Annotations"
     423      tooltip="View annotation values" clazz="white">
     424      <jsp:include page="../../common/annotations/list_frameset.jsp">
     425        <jsp:param name="item_type" value="<%=itemType.name()%>" />
     426        <jsp:param name="item_id" value="<%=itemId%>" />
     427        <jsp:param name="ID" value="<%=ID%>" />
     428      </jsp:include>
     429    </t:tab>
     430    <t:tab id="history" title="History"
     431      tooltip="Displays a log with the history of this item"
     432      visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
     433      <jsp:include page="../../common/history/frameset.jsp">
     434        <jsp:param name="item_type" value="<%=itemType.name()%>" />
     435        <jsp:param name="item_id" value="<%=itemId%>" />
     436        <jsp:param name="ID" value="<%=ID%>" />
     437      </jsp:include>
     438    </t:tab>
    422439    </t:tabcontrol>
    423440
Note: See TracChangeset for help on using the changeset viewer.