Changeset 2166


Ignore:
Timestamp:
Apr 19, 2006, 3:30:05 PM (17 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #96 and #158:

  • Inherit annotations
  • Resizable annotation tab for most items but mostly needed for BioSource/BioSample?
Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/Base.java

    r2138 r2166  
    719719    throws ItemModifiedException, BaseException
    720720  {
     721    // Modified annotations
    721722    String modified = Values.getStringOrNull(request.getParameter("modifiedAnnotations"));
    722723    if (modified != null)
     
    751752      }
    752753    }
     754   
     755    // Inherited annotations and annotation sets
     756   
     757    // Annotations that are no longer inherited
     758    String removed = Values.getStringOrNull(request.getParameter("removedAnnotations"));
     759    if (removed != null)
     760    {
     761      String[] removedAnnotations = removed.split(",");
     762      AnnotationSet newAs = newItem.getAnnotationSet();
     763      for (int i = 0; i < removedAnnotations.length; ++i)
     764      {
     765        int annotationId = Values.getInt(removedAnnotations[i], -1);
     766        if (annotationId != -1)
     767        {
     768          newAs.removeInheritedAnnotation(Annotation.getById(dc, annotationId));
     769        }
     770      }
     771    }
     772   
     773    // Annotations that we now are inheriting
     774    String added = Values.getStringOrNull(request.getParameter("addedAnnotations"));
     775    if (added != null)
     776    {
     777      String[] addedAnnotations = added.split(",");
     778      AnnotationSet newAs = newItem.getAnnotationSet();
     779      for (int i = 0; i < addedAnnotations.length; ++i)
     780      {
     781        int annotationId = Values.getInt(addedAnnotations[i], -1);
     782        if (annotationId != -1)
     783        {
     784          newAs.inheritAnnotation(Annotation.getById(dc, annotationId));
     785        }
     786      }
     787    }
     788
     789    // Annotation sets that are no longer inherited
     790    String removedSets = Values.getStringOrNull(request.getParameter("removedAnnotationSets"));
     791    if (removedSets != null)
     792    {
     793      String[] removedAnnotationSets = removedSets.split(",");
     794      AnnotationSet newAs = newItem.getAnnotationSet();
     795      for (int i = 0; i < removedAnnotationSets.length; ++i)
     796      {
     797        int annotationSetId = Values.getInt(removedAnnotationSets[i], -1);
     798        if (annotationSetId != -1)
     799        {
     800          newAs.removeInheritedAnnotationSet(AnnotationSet.getById(dc, annotationSetId));
     801        }
     802      }
     803    }
     804   
     805    // Annotation sets that we now are inheriting
     806    String addedSets = Values.getStringOrNull(request.getParameter("addedAnnotationSets"));
     807    if (addedSets != null)
     808    {
     809      String[] addedAnnotationSets = addedSets.split(",");
     810      AnnotationSet newAs = newItem.getAnnotationSet();
     811      for (int i = 0; i < addedAnnotationSets.length; ++i)
     812      {
     813        int annotationSetId = Values.getInt(addedAnnotationSets[i], -1);
     814        if (annotationSetId != -1)
     815        {
     816          newAs.inheritAnnotationSet(AnnotationSet.getById(dc, annotationSetId));
     817        }
     818      }
     819    }
    753820  }
    754821 
  • trunk/src/core/net/sf/basedb/core/Annotation.java

    r2098 r2166  
    2626
    2727import net.sf.basedb.core.data.AnnotationData;
     28import net.sf.basedb.core.query.EntityQuery;
    2829
    2930import java.util.List;
     
    5556 
    5657  /**
     58    This filter gives everybody read permission to annotations.
     59  */
     60  private static final QueryRuntimeFilter RUNTIME_FILTER = new QueryRuntimeFilterImpl();
     61
     62  /**
    5763    Create a new annotation.
    5864    @param dc The DbControl object
     
    103109  static ItemQuery<Annotation> getQuery()
    104110  {
    105     return new ItemQuery<Annotation>(Annotation.class);
     111    return new ItemQuery<Annotation>(Annotation.class, RUNTIME_FILTER);
    106112  }
    107113 
     
    153159    {
    154160      granted |= Permission.grant(Permission.CREATE, Permission.READ, Permission.WRITE, Permission.DELETE);
     161    }
     162    else if (as.hasPermission(Permission.USE))
     163    {
     164      granted |= Permission.grant(Permission.USE);
    155165    }
    156166    else if (as.hasPermission(Permission.READ))
     
    267277  }
    268278
     279  private static class QueryRuntimeFilterImpl
     280    implements QueryRuntimeFilter
     281  {
     282    public void enableFilters(QueryRuntimeFilterManager manager, EntityQuery query, DbControl dc)
     283    {
     284      // Do not add any filters.
     285    }
     286  }
    269287}
    270288
  • trunk/src/core/net/sf/basedb/core/AnnotationSet.java

    r2164 r2166  
    2525package net.sf.basedb.core;
    2626
     27import net.sf.basedb.core.query.EntityQuery;
     28import net.sf.basedb.core.query.Expression;
     29import net.sf.basedb.core.query.Expressions;
    2730import net.sf.basedb.core.query.Restrictions;
    2831import net.sf.basedb.core.query.Hql;
     
    6063 
    6164  /**
     65    This filter gives everybody read permission to annotations.
     66  */
     67  private static final QueryRuntimeFilter RUNTIME_FILTER = new QueryRuntimeFilterImpl();
     68
     69  /**
    6270    Create a new annotation set for the specified item.
    6371    @see AnnotatedItem#getAnnotationSet()
     
    7078    return as;
    7179  }
    72  
     80  /**
     81    Get an <code>AnnotationSet</code> item when you know the id.
     82 
     83    @param dc The <code>DbControl</code> which will be used for
     84      permission checking and database access.
     85    @param id The id of the item to load
     86    @return The <code>AnnotationSet</code> item
     87    @throws ItemNotFoundException If an item with the specified
     88      id is not found
     89    @throws PermissionDeniedException If the logged in user doesn't
     90      have read permission to the item
     91    @throws BaseException If there is another error
     92  */
     93  public static AnnotationSet getById(DbControl dc, int id)
     94    throws ItemNotFoundException, PermissionDeniedException, BaseException
     95  {
     96    AnnotationSet as = dc.loadItem(AnnotationSet.class, id);
     97    if (as == null) throw new ItemNotFoundException("AnnotationSet[id="+id+"]");
     98    return as;
     99  }
    73100  /**
    74101    Get a {@link ItemQuery} object configured to retrieve <code>AnnotationSet</code>
     
    79106  static ItemQuery<AnnotationSet> getQuery()
    80107  {
    81     return new ItemQuery<AnnotationSet>(AnnotationSet.class);
     108    return new ItemQuery<AnnotationSet>(AnnotationSet.class, RUNTIME_FILTER);
    82109  }
    83110
     
    131158  }
    132159  /**
    133     READ permission is granted if the logged in user has READ permission on
    134     the associated item. CREATE, WRITE and DELETE permissions are granted
     160    READ permission is granted to all users. CREATE, WRITE and DELETE permissions are granted
    135161    if the logged in user has WRITE permission on the associated item.
    136162  */
     
    138164    throws BaseException
    139165  {
    140     Annotatable item = getItem();     
    141     if (item.hasPermission(Permission.WRITE))
     166    Annotatable item = null;
     167    try
     168    {
     169      item = getItem();     
     170    }
     171    catch (PermissionDeniedException ex)
     172    {}
     173    if (item != null && item.hasPermission(Permission.WRITE))
    142174    {
    143175      granted |= Permission.grant(Permission.CREATE, Permission.READ, Permission.WRITE, Permission.DELETE);       
    144176    }
    145     else if (item.hasPermission(Permission.READ))
     177    else if (item != null && item.hasPermission(Permission.USE))
     178    {
     179      granted |= Permission.grant(Permission.USE);
     180    }
     181    else
    146182    {
    147183      granted |= Permission.grant(Permission.READ);       
     
    400436 
    401437  /**
    402     Get a query that returns all inherited annotations in this annotation set.
     438    Get a query that returns directly inherited annotations in this annotation set.
     439    Directly inherited annotations are annotations that are linked to this annotation
     440    set.
     441    @see #inheritAnnotation(Annotation)
    403442    @return An <code>ItemQuery</code> object
    404443  */
     
    418457 
    419458  /**
     459      Get a query that returns all inherited (directly and indirectly) annotations in
     460      this annotation set. The directy inherited annotations include annotations added
     461      by {@link #inheritAnnotation(Annotation)}, the indirectly inherited annotations
     462      include annotations in annotation sets added by
     463      {@link #inheritAnnotationSet(AnnotationSet)}
     464     
     465      @see #getInheritedAnnotations()
     466    @return An <code>ItemQuery</code> object
     467  */
     468  public ItemQuery<Annotation> getAllInheritedAnnotations()
     469  {
     470    ItemQuery<Annotation> query = Annotation.getQuery();
     471    query.joinPermanent(Hql.leftJoin("inheritingSets", "direct"));
     472    query.joinPermanent(Hql.leftJoin("annotationSet.inheritingSets", "indirect"));
     473    Expression thisEntity = Expressions.parameter("annotationSet", this.getId(), Type.INT);
     474    query.restrictPermanent(
     475      Restrictions.or(
     476        Restrictions.eq(Hql.alias("direct"), thisEntity),
     477        Restrictions.eq(Hql.alias("indirect"), thisEntity)
     478      )
     479    );
     480    return query;
     481  }
     482 
     483  /**
    420484    Inherit an annotation set.
    421485    @param annotationSet The annotation set to inherit
     
    495559    return query;
    496560  }
     561 
     562  private static class QueryRuntimeFilterImpl
     563    implements QueryRuntimeFilter
     564  {
     565    public void enableFilters(QueryRuntimeFilterManager manager, EntityQuery query, DbControl dc)
     566    {
     567      // Do not add any filters.
     568    }
     569  }
    497570}
  • trunk/src/core/net/sf/basedb/core/Hybridization.java

    r1418 r2166  
    117117  */
    118118  /**
    119     Get the labeled extracts and array slide
     119    Get the labeled extracts and array slide.
    120120  */
    121121  public Set<Annotatable> getAnnotatableParents()
     
    125125    try
    126126    {
    127       annotatable.addAll(getCreationEvent().getSources().list(getDbControl()));
     127      ItemQuery<? extends MeasuredBioMaterial> sources = getCreationEvent().getSources();
     128      sources.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
     129      annotatable.addAll(sources.list(getDbControl()));
    128130      if (getData().getArraySlide() != null) annotatable.add(getArraySlide());
    129131    }
  • trunk/src/core/net/sf/basedb/util/Tree.java

    r2096 r2166  
    256256      Add a child to the node.
    257257      @param child The child to add
     258      @return The <code>Entry</code> object of the new child node
    258259      @throws IllegalArgumentException If the child already exists in the tree
    259260    */
    260     public void addChild(E child)
     261    public Entry<E> addChild(E child)
    261262    {
    262263      if (tree.contains(child))
     
    264265        throw new IllegalArgumentException("Element '" + child + "' is already in the tree.");
    265266      }
    266       tree.addEntry(new Entry<E>(tree, child, this));
     267      Entry<E> childEntry = new Entry<E>(tree, child, this);
     268      tree.addEntry(childEntry);
     269      return childEntry;
    267270    }
    268271
  • trunk/www/common/annotations/annotate.jsp

    r1985 r2166  
    5959try
    6060{
    61 //  final Annotatable item = (Annotatable)sc.getSessionSetting(itemType.name()+".item");
    6261  final Annotatable item = itemId == 0 ? null : (Annotatable)itemType.getById(dc, itemId);
    63   if (item != null) dc.reattachItem((BasicItem)item);
    6462  final String clazz = "class=\"text\"" ;
    6563
     
    110108      }
    111109      icon = "<img id=\"icon_"+at.getId()+"\" src=\"../../images/"+icon+"\" class=\"icon\">";
    112       sb.append("<div class=\"pluginparameter\" id=\"prompt_"+at.getId()+"\" onclick=\"parametersOnClick('"+at.getId()+"')\" onmouseover=\"Main.addClass(this, 'hover')\" onmouseout=\"Main.removeClass(this, 'hover')\" title=\""+fullLabel+"\">"+icon+label+"</div>");
     110      sb.append("<div class=\"param\" id=\"prompt_"+at.getId()+"\" onclick=\"parametersOnClick('"+at.getId()+"')\" onmouseover=\"Main.addClass(this, 'hover')\" onmouseout=\"Main.removeClass(this, 'hover')\" title=\""+fullLabel+"\">"+icon+label+"</div>");
    113111      %>
    114       //new AnnotationType(<%=at.getId()%>, '<%=HTML.javaScriptEncode(at.getName())%>', '<%=at.getValueType().name()%>', <%=at.getMultiplicity()%>, <%=at.isEnumeration()%>, values);
    115112      new Parameter('<%=at.getId()%>', '<%=HTML.javaScriptEncode(at.getName())%>', <%=at.getMultiplicity()%>, <%=at.isEnumeration()%>, false, values);
    116113      <%
     
    351348  <base:body onload="init()" style="background: #E0E0E0;">
    352349    <form name="annotations">
    353     <table class="form" cellspacing="2" border="0" cellpadding="0">
     350    <table class="form" cellspacing="2" border="0" cellpadding="0" width="100%">
    354351    <tr valign="top">
    355       <td>
    356         <div class="parameterlist" style="height: <%=(int)(scale*320)%>px; width:<%=(int)(scale*240)%>px;">
     352      <td width="50%">
     353        <div class="parameterlist" style="height: <%=(int)(scale*320)%>px;">
    357354        <%=sb.toString()%>
    358355        </div>
    359356        <base:icon image="hasvalues.gif" /> = has value(s)
    360357      </td>
    361       <td>&nbsp;</td>
    362       <td>
     358      <td width="50%">
    363359
    364360        <div id="valuecontainer" style="display: none;">
  • trunk/www/common/annotations/inherit.jsp

    r927 r2166  
    3030--%>
    3131<%@ page
    32 
     32  import="net.sf.basedb.core.SessionControl"
     33  import="net.sf.basedb.core.DbControl"
     34  import="net.sf.basedb.core.Item"
     35  import="net.sf.basedb.core.Type"
     36  import="net.sf.basedb.core.BasicItem"
     37  import="net.sf.basedb.core.Permission"
     38  import="net.sf.basedb.core.Annotatable"
     39  import="net.sf.basedb.core.AnnotationSet"
     40  import="net.sf.basedb.core.Annotation"
     41  import="net.sf.basedb.core.ItemQuery"
     42  import="net.sf.basedb.core.Include"
     43  import="net.sf.basedb.core.Nameable"
     44  import="net.sf.basedb.core.ItemResultList"
     45  import="net.sf.basedb.core.AnnotationType"
     46  import="net.sf.basedb.core.PermissionDeniedException"
     47  import="net.sf.basedb.core.query.Orders"
     48  import="net.sf.basedb.core.query.Hql"
     49  import="net.sf.basedb.util.Tree"
     50  import="net.sf.basedb.clients.web.Base"
     51  import="net.sf.basedb.clients.web.util.HTML"
     52  import="net.sf.basedb.clients.web.util.Values"
     53  import="java.util.List"
     54  import="java.util.Set"
     55  import="java.util.HashSet"
     56  import="java.util.Map"
     57  import="java.util.HashMap"
    3358%>
    3459<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
    35 
     60<%!
     61private void loadParents(Set<AnnotationSet> parentAnnotations, Annotatable item)
     62{
     63  Set<Annotatable> parents = item.getAnnotatableParents();
     64  if (parents == null) return;
     65  for (Annotatable parent : parents)
     66  {
     67    if (parent != null && !parentAnnotations.contains(parent))
     68    {
     69      if (parent.hasPermission(Permission.USE) && parent.isAnnotated())
     70      {
     71        AnnotationSet as = parent.getAnnotationSet();
     72        parentAnnotations.add(as);
     73      }
     74      loadParents(parentAnnotations, parent);
     75    }
     76  }
     77}
     78
     79private String generateJoustTree(Set<AnnotationSet> parentAnnotations, Set<Annotation> inheritedAnnotations, Set<AnnotationSet> inheritedSets)
     80{
     81  StringBuilder sb = new StringBuilder();
     82  String itemIcon = "Folder";
     83  String annotationIcon = "Document";
     84 
     85  for (AnnotationSet as : parentAnnotations)
     86  {
     87    //Annotatable item = entry.getKey();
     88    // AnnotationSet as = item.getAnnotationSet();
     89    Annotatable item = null;
     90    try
     91    {
     92      item = as.getItem();
     93    }
     94    catch (PermissionDeniedException ex)
     95    {}
     96   
     97    boolean setInherited = inheritedSets.contains(as);
     98
     99    String input = "<input type=\"checkbox\""+
     100      " name=\"AS"+as.getId()+"\""+
     101      (setInherited ? " checked" : "")+
     102      " onclick=\"itemOnToggle(event, "+as.getId()+")\""+
     103      ">";
     104    String name = item == null ? "<i>- denied -</i>" :
     105      HTML.javaScriptEncode(((Nameable)item).getName()) + " (" + item.getType() + ")";
     106    sb.append("var item").append(as.getId());
     107    sb.append(" = JoustMenu.addMenuItem(-1");
     108    sb.append(",'").append(itemIcon).append("'");
     109    sb.append(",'").append(input).append(name).append("'");
     110    sb.append(", 'itemOnClick(event, ").append(as.getId()).append(")'");
     111    sb.append(", '', 'AS").append(as.getId()).append("', true);\n");
     112
     113    List<Annotation> annotations = as.getAnnotations().list(as.getDbControl());
     114    for (Annotation a : annotations)
     115    {
     116      boolean inherited = inheritedAnnotations.contains(a);
     117      AnnotationType at = null;
     118      String annotationName = "<i>- denied -</i>";
     119      try
     120      {
     121        at = a.getAnnotationType();
     122        annotationName = at.getName();
     123      }
     124      catch (PermissionDeniedException ex)
     125      {}
     126      String values = Values.getString(a.getValues(), ", ", true);
     127      name = HTML.javaScriptEncode(annotationName +
     128        " [" + Values.trimString(values, 20)+"]");
     129      input = "<input type=\"checkbox\""+
     130        " name=\"A"+a.getId()+"\""+
     131        (inherited || setInherited ? " checked" : "")+
     132        (setInherited ? " disabled" : "")+
     133        " onclick=\"annotationOnToggle(event, "+a.getId()+")\""+
     134        ">";
     135      sb.append("JoustMenu.addChildItem(item" + as.getId());
     136      sb.append(",'").append(annotationIcon).append("'");
     137      sb.append(",'").append(input).append(name).append("'");
     138      sb.append(", 'annotationOnClick(event, ").append(a.getId()).append(")'");
     139      sb.append(", '', 'A").append(a.getId()).append("');\n");
     140      sb.append("annotationValues['A").append(a.getId()).append("'] = ");
     141      sb.append("'").append(HTML.javaScriptEncode(values)).append("';\n");
     142    }
     143  }
     144  return sb.toString();
     145}
     146%>
     147<%
     148final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
     149final String ID = sc.getId();
     150final float scale = Base.getScale(sc);
     151final Item itemType = Item.valueOf(request.getParameter("item_type"));
     152final int itemId = Values.getInt(request.getParameter("item_id"));
     153
     154final DbControl dc = sc.newDbControl();
     155ItemResultList<AnnotationType> annotationTypes = null;
     156try
     157{
     158  final Annotatable item = itemId == 0 ? null : (Annotatable)itemType.getById(dc, itemId);
     159 
     160  // Get all annotated parents and their annotation sets
     161  Set<AnnotationSet> parentAnnotations = new HashSet<AnnotationSet>();
     162  loadParents(parentAnnotations, item);
     163
     164//  Map<Annotatable, Set<Annotation>> annotatedParents = new HashMap<Annotatable, Set<Annotation>>();
     165//  loadParents(annotatedParents, item);
     166 
     167  // Get the currently inherited annotations
     168  final AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
     169  Set<Annotation> inheritedAnnotations = null;
     170  Set<AnnotationSet> inheritedSets = null;
     171  if (as != null)
     172  {
     173    ItemQuery<Annotation> inheritedQuery = as.getInheritedAnnotations();
     174    inheritedQuery.order(Orders.asc(Hql.property("annotationSet")));
     175    inheritedQuery.order(Orders.asc(Hql.property("annotationType.name")));
     176    inheritedAnnotations = new HashSet<Annotation>(inheritedQuery.list(dc));
     177    for (Annotation a : inheritedAnnotations)
     178    {
     179      AnnotationSet from = a.getAnnotationSet();
     180      if (!parentAnnotations.contains(from) && from.hasPermission(Permission.USE))
     181      {
     182        parentAnnotations.add(from);
     183      }
     184    }
     185   
     186    ItemQuery<AnnotationSet> setQuery = as.getInheritedAnnotationSets();
     187    inheritedSets = new HashSet<AnnotationSet>(setQuery.list(dc));
     188    for (AnnotationSet ias : inheritedSets)
     189    {
     190      //Annotatable from = ias.getItem();
     191      if (!parentAnnotations.contains(ias) && ias.hasPermission(Permission.USE))
     192      {
     193        parentAnnotations.add(ias);
     194      }
     195    }
     196  }
     197  %>
    36198  <base:page type="popup" title="Inherit annotations">
    37   <base:head />
    38   <base:body >
     199  <base:head  scripts="annotations.js,parameters.js,newjoust.js,linkitems.js" styles="parameters.css,newjoust.css">
     200  <script language="JavaScript">
     201  var annotationValues = new Array();
     202  function init()
     203  {
     204    IconStore.init();
     205    <%=generateJoustTree(parentAnnotations, inheritedAnnotations, inheritedSets)%>
     206    JoustMenu.alwaysSendOnClickToSelected = true;
     207    JoustMenu.draw('joust');
     208  }
     209  function itemOnClick(event, annotationSetId)
     210  {
     211    var frm = document.forms['annotations'];
     212    frm['AS'+annotationSetId].checked = !frm['AS'+annotationSetId].checked;
     213    itemOnToggle(event, annotationSetId);
     214  }
     215 
     216  function itemOnToggle(event, annotationSetId)
     217  {
     218    //alert('itemOnClick: '+annotationSetId);
     219    var frm = document.forms['annotations'];
     220
     221    var linkedItem = Link.getItem('AS', annotationSetId);
     222    if (!linkedItem)
     223    {
     224      linkedItem = new Item('AS', annotationSetId);
     225    }
     226    var checked = frm['AS'+annotationSetId].checked;
     227    linkedItem.action += checked ? 1 : -1;
     228
     229    frm['AS'+annotationSetId].checked = checked;
     230    var menuItem = JoustMenu.menuItems['AS'+annotationSetId];
     231    var childIndex = menuItem.firstChildIndex;
     232    while (childIndex != -1)
     233    {
     234      var childMenuItem = JoustMenu.menuItems[childIndex];
     235      frm[childMenuItem.externalId].checked = checked;
     236      frm[childMenuItem.externalId].disabled = checked;
     237      childIndex = childMenuItem.nextItemIndex;
     238     
     239      var annotationId = childMenuItem.externalId.substr(1);
     240      annotationItem = Link.getItem('A', annotationId);
     241      if (!annotationItem) annotationItem = new Item('A', annotationId);
     242      annotationItem.action = -1;
     243    }
     244    event.cancelBubble = true;
     245  }
     246 
     247  function annotationOnClick(event, annotationId)
     248  {
     249    var frm = document.forms['annotations'];
     250    var annotation = frm['A'+annotationId];
     251    if (!annotation.disabled)
     252    {
     253      annotation.checked = !annotation.checked;
     254      annotationOnToggle(event, annotationId);
     255    }
     256    document.getElementById('annotationValues').innerHTML = annotationValues['A'+annotationId];
     257  }
     258 
     259  function annotationOnToggle(event, annotationId)
     260  {
     261    //alert('itemOnClick: '+annotationSetId);
     262    var frm = document.forms['annotations'];
     263
     264    var linkedItem = Link.getItem('A', annotationId);
     265    if (!linkedItem)
     266    {
     267      linkedItem = new Item('A', annotationId);
     268    }
     269    var checked = frm['A'+annotationId].checked;
     270    linkedItem.action += checked ? 1 : -1;
    39271   
    40   TODO
    41  
     272    frm['A'+annotationId].checked = checked;
     273    event.cancelBubble = true;
     274  }
     275
     276  </script>
     277  </base:head>
     278  <base:body onload="init()" style="background: #E0E0E0;">
     279
     280  <form name="annotations">
     281  <table class="form" cellspacing="2" border="0" cellpadding="0" width="100%">
     282  <tr valign="top">
     283  <td width="50%">
     284    <div id="joust" class="joust parameterlist"
     285      style="height: <%=(int)(scale*320)%>px;">
     286    </div>
     287  </td>
     288  <td width="50%">
     289    <b>Annotation values</b>
     290    <div id="annotationValues">
     291    </div>
     292  </td>
     293  </tr>
     294  </table>
     295     
     296  </form>
    42297  </base:body>
    43298  </base:page>
    44 
     299  <%
     300}
     301finally
     302{
     303  if (dc != null) dc.close();
     304}
     305%>
     306
  • trunk/www/common/annotations/list_annotations.jsp

    r1855 r2166  
    3333  import="net.sf.basedb.core.AnnotationType"
    3434  import="net.sf.basedb.core.AnnotationSet"
     35  import="net.sf.basedb.core.Annotation"
    3536  import="net.sf.basedb.core.Annotatable"
     37  import="net.sf.basedb.core.Nameable"
    3638  import="net.sf.basedb.core.ItemQuery"
    3739  import="net.sf.basedb.core.ItemResultList"
    3840  import="net.sf.basedb.core.PermissionDeniedException"
     41  import="net.sf.basedb.core.query.Orders"
     42  import="net.sf.basedb.core.query.Hql"
    3943  import="net.sf.basedb.clients.web.Base"
    4044  import="net.sf.basedb.clients.web.util.HTML"
     
    5862  final ItemResultList<AnnotationType> annotationTypes = annotationTypeQuery.list(dc);
    5963  final Annotatable item = (Annotatable)itemType.getById(dc, itemId);
     64
     65  final AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
     66  ItemResultList<Annotation> inheritedAnnotations = null;
     67  if (as != null)
     68  {
     69    ItemQuery<Annotation> inheritedQuery = as.getAllInheritedAnnotations();
     70    inheritedQuery.order(Orders.asc(Hql.property("annotationSet")));
     71    inheritedQuery.order(Orders.asc(Hql.property("annotationType.name")));
     72    inheritedAnnotations = inheritedQuery.list(dc);
     73  }
    6074  %>
    6175
     
    6377  <base:head />
    6478  <base:body>
    65 
    6679      <%
    6780      if (annotationTypes.size() == 0)
     
    6982        %>
    7083        <h4>Primary annotations</h4>
    71         No annotation types has been defined for this type of item.
     84        No annotation types has been defined for this type of item
     85        (or you don't have permission to view them).
    7286        <%
    7387      }
     
    98112            <tbl:rows>
    99113            <%
    100             AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
    101114            for (AnnotationType at : annotationTypes)
    102115            {
     
    120133      %>
    121134
    122       <h4>Inherited annotations</h4>
    123       TODO
     135      <%
     136      if (inheritedAnnotations == null || inheritedAnnotations.size() == 0)
     137      {
     138        %>
     139        <h4>Inherited annotations</h4>
     140        No annotations are inherited by this item.
     141        <%
     142      }
     143      else
     144      {
     145        %>
     146        <h4 class="docked">Inherited annotations</h4>
     147        <tbl:table
     148          id="inheritedAnnotations"
     149          clazz="itemlist"
     150          columns="all"
     151          >
     152          <tbl:columndef
     153            id="annotation"
     154            title="Annotation"
     155          />
     156          <tbl:columndef
     157            id="item"
     158            title="From item"
     159          />
     160          <tbl:columndef
     161            id="values"
     162            title="Values"
     163          />
     164          <tbl:columndef
     165            id="description"
     166            title="Description"
     167          />
     168          <tbl:data>
     169            <tbl:columns>
     170            </tbl:columns>
     171            <tbl:rows>
     172            <%
     173            String denied = "<i>- denied -</i>";
     174            for (Annotation a : inheritedAnnotations)
     175            {
     176              AnnotationType at = null;
     177              String name = denied;
     178              String description = "";
     179              try
     180              {
     181                at = a.getAnnotationType();
     182                name = HTML.encodeTags(at.getName());
     183                description = HTML.encodeTags(at.getDescription());
     184              }
     185              catch (PermissionDeniedException ex)
     186              {}
     187              Nameable aItem = null;
     188              String itemName = denied;
     189              try
     190              {
     191                aItem = (Nameable)a.getAnnotationSet().getItem();
     192                itemName = HTML.encodeTags(aItem.getName() + " (" + aItem.getType() + ")");
     193              }
     194              catch (PermissionDeniedException ex)
     195              {}
     196              List<?> values = a.getValues();
     197              %>
     198              <tbl:row>
     199                <tbl:cell column="annotation"><%=name%></tbl:cell>
     200                <tbl:cell column="item"><%=itemName%></tbl:cell>
     201                <tbl:cell column="values"><%=values == null || values.size() == 0 ? "<i>- no values -</i>" : Values.getString(values, ", ", true)%></tbl:cell>
     202                <tbl:cell column="description"><%=description%></tbl:cell>
     203              </tbl:row>
     204              <%
     205            }
     206            %>
     207            </tbl:rows>
     208          </tbl:data>
     209        </tbl:table>
     210        <%
     211      }
     212      %>
    124213      </div>
    125214
  • trunk/www/common/plugin/configure.jsp

    r2147 r2166  
    145145            }
    146146            icon = "<img id=\"icon_"+name+"\" src=\"../../images/"+icon+"\" class=\"icon\">";
    147             sb.append("<div class=\"pluginparameter\" id=\"prompt_"+name+"\" onclick=\"parametersOnClick('"+name+"')\" onmouseover=\"Main.addClass(this, 'hover')\" onmouseout=\"Main.removeClass(this, 'hover')\" title=\""+fullLabel+"\">"+icon+label+"</div>");
     147            sb.append("<div class=\"param\" id=\"prompt_"+name+"\" onclick=\"parametersOnClick('"+name+"')\" onmouseover=\"Main.addClass(this, 'hover')\" onmouseout=\"Main.removeClass(this, 'hover')\" title=\""+fullLabel+"\">"+icon+label+"</div>");
    148148            %>
    149149            var values = new Array();
  • trunk/www/include/scripts/annotations.js

    r1985 r2166  
    33  BioArray Software Environment (BASE) - http://base.thep.lu.se/
    44  Copyright (C) 2002-2004 Lao Saal, Carl Troein,
    5   Johan Vallon-Christersson, Jari Häkkinen, Nicklas Nordborg
     5  Johan Vallon-Christersson, Jari H??kkinen, Nicklas Nordborg
    66
    77  This file is part of BASE.
     
    7171  this.addInheritedAnnotationsToForm = function(theFrame, frm)
    7272  {
    73     // TODO
     73    var addedAnnotations = theFrame.Link.getActionIds(1, 'A');
     74    var removedAnnotations = theFrame.Link.getActionIds(-1, 'A');
     75    var addedAnnotationSets = theFrame.Link.getActionIds(1, 'AS');
     76    var removedAnnotationSets = theFrame.Link.getActionIds(-1, 'AS');
     77
     78    if (frm.addedAnnotations)
     79    {
     80      frm.addedAnnotations.value = addedAnnotations.join(',');
     81    }
     82    else
     83    {
     84      Forms.createHidden(frm, 'addedAnnotations', addedAnnotations.join(','));
     85    }
     86    if (frm.removedAnnotations)
     87    {
     88      frm.removedAnnotations.value = removedAnnotations.join(',');
     89    }
     90    else
     91    {
     92      Forms.createHidden(frm, 'removedAnnotations', removedAnnotations.join(','));
     93    }
     94    if (frm.addedAnnotationSets)
     95    {
     96      frm.addedAnnotationSets.value = addedAnnotationSets.join(',');
     97    }
     98    else
     99    {
     100      Forms.createHidden(frm, 'addedAnnotationSets', addedAnnotationSets.join(','));
     101    }
     102    if (frm.removedAnnotationSets)
     103    {
     104      frm.removedAnnotationSets.value = removedAnnotationSets.join(',');
     105    }
     106    else
     107    {
     108      Forms.createHidden(frm, 'removedAnnotationSets', removedAnnotationSets.join(','));
     109    }
    74110  }
    75  
    76111}
    77112
  • trunk/www/include/scripts/linkitems.js

    r1808 r2166  
    33  BioArray Software Environment (BASE) - http://base.thep.lu.se/
    44  Copyright (C) 2002-2004 Lao Saal, Carl Troein,
    5   Johan Vallon-Christersson, Jari Häkkinen, Nicklas Nordborg
     5  Johan Vallon-Christersson, Jari H?kkinen, Nicklas Nordborg
    66
    77  This file is part of BASE.
  • trunk/www/include/scripts/newjoust.js

    r2097 r2166  
    4040function JoustMenuClass()
    4141{
     42  this.alwaysSendOnClickToSelected = false;
    4243  this.firstItemIndex = -1;
    4344  this.lastItemIndex = -1;
     
    101102    @return The index of the new item
    102103  */
    103   this.addMenuItem = function(afterItemIndex, iconName, text, onclick, tooltip, externalId)
     104  this.addMenuItem = function(afterItemIndex, iconName, text, onclick, tooltip, externalId, isOpen)
    104105  {
    105106    var afterItem = this.menuItems[afterItemIndex];
     
    112113    var insertIndex = this.menuItems.length;
    113114
    114     var menuItem = new MenuItem(this, insertIndex, iconName, text, onclick, tooltip, nextItemIndex, previousItemIndex, parentItemIndex, externalId);
     115    var menuItem = new MenuItem(this, insertIndex, iconName, text, onclick, tooltip, nextItemIndex, previousItemIndex, parentItemIndex, externalId, isOpen);
    115116    this.menuItems[insertIndex] = menuItem;
    116117    if (!this.menuItems[externalId]) this.menuItems[externalId] = menuItem;
     
    147148    @return The index of the new item
    148149  */
    149   this.addChildItem = function(parentItemIndex, iconName, text, onclick, tooltip, externalId)
     150  this.addChildItem = function(parentItemIndex, iconName, text, onclick, tooltip, externalId, isOpen)
    150151  {
    151152    var parentItem = this.menuItems[parentItemIndex];
    152153    if (!parentItem)
    153154    {
    154       return this.addMenuItem(-1, iconName, text, onclick, tooltip);
     155      return this.addMenuItem(-1, iconName, text, onclick, tooltip, externalId, isOpen);
    155156    }
    156157    var afterItem = this.menuItems[parentItem.lastChildIndex];
    157158    if (afterItem)
    158159    {
    159       parentItem.lastChildIndex = this.addMenuItem(parentItem.lastChildIndex, iconName, text, onclick, tooltip, externalId);
     160      parentItem.lastChildIndex = this.addMenuItem(parentItem.lastChildIndex, iconName, text, onclick, tooltip, externalId, isOpen);
    160161      return parentItem.lastChildIndex;
    161162    }
    162163    var insertIndex = this.menuItems.length;
    163     var menuItem = new MenuItem(this, insertIndex, iconName, text, onclick, tooltip, -1, -1, parentItemIndex, externalId);
     164    var menuItem = new MenuItem(this, insertIndex, iconName, text, onclick, tooltip, -1, -1, parentItemIndex, externalId, isOpen);
    164165    this.menuItems[insertIndex] = menuItem;
    165166    if (!this.menuItems[externalId]) this.menuItems[externalId] = menuItem;
     
    213214  {
    214215    var menuItem = this.menuItems[menuItemIndex];
    215     if (!menuItem || menuItemIndex == this.selectedItemIndex) return;
     216    if (!menuItem) return;
    216217   
    217     if (this.selectedItemIndex != -1)
    218     {
    219       var current = this.menuItems[this.selectedItemIndex];
    220       current.isSelected = false;
    221       this.updateIconsAndText(this.selectedItemIndex);
    222     }
    223     menuItem.isSelected = true;
    224     if (menuItem.parentItemIndex != -1) this.open(menuItem.parentItemIndex);
    225     this.selectedItemIndex = menuItemIndex;
    226     this.updateIconsAndText(menuItemIndex);
    227     eval(menuItem.onclick);
     218    if (menuItemIndex != this.selectedItemIndex)
     219    {
     220      if (this.selectedItemIndex != -1)
     221      {
     222        var current = this.menuItems[this.selectedItemIndex];
     223        current.isSelected = false;
     224        this.updateIconsAndText(this.selectedItemIndex);
     225      }
     226      menuItem.isSelected = true;
     227      if (menuItem.parentItemIndex != -1) this.open(menuItem.parentItemIndex);
     228      this.selectedItemIndex = menuItemIndex;
     229      this.updateIconsAndText(menuItemIndex);
     230      eval(menuItem.onclick);
     231    }
     232    else if (this.alwaysSendOnClickToSelected)
     233    {
     234      eval(menuItem.onclick);
     235    }
    228236  }
    229237
     
    279287  @param parentItemIndex The index of the parent menu item, or -1 if this is on the root level
    280288*/
    281 function MenuItem(menu, index, iconName, text, onclick, tooltip, nextItemIndex, previousItemIndex, parentItemIndex, externalId)
     289function MenuItem(menu, index, iconName, text, onclick, tooltip, nextItemIndex, previousItemIndex, parentItemIndex, externalId, isOpen)
    282290{
    283291  this.menu = menu;
     
    291299  this.parentItemIndex = parentItemIndex;
    292300  this.externalId = externalId;
    293   this.isOpen = false;
     301  this.isOpen = isOpen;
    294302  this.isSelected = false;
    295303  this.firstChildIndex = -1;
  • trunk/www/include/styles/parameters.css

    r1985 r2166  
    4141}
    4242
    43 .parameterlist .pluginparameter {
     43.parameterlist .param {
    4444
    4545}
    4646
    47 .parameterlist .icon {
     47.parameterlist .param .icon {
    4848  padding-right: 4px;
    4949}
    50 .parameterlist .hover {
     50.parameterlist .param.hover {
    5151  background: #E0E0E0;
    5252  cursor: pointer;
    5353}
    5454
    55 .parameterlist .selected {
     55.parameterlist .param.selected {
    5656  color: #FFFFFF;
    5757  background: #445577;
  • trunk/www/views/rawbioassays/view_rawbioassay.jsp

    r1855 r2166  
    294294      <tr>
    295295        <td class="prompt">Protocol</td>
    296         <td><%=Base.getEncodedName(currentProtocol, !readCurrentProtocol)%></td>
     296        <td><%=Base.getEncodedName(currentProtocol, !readCurrentProtocol, "../../admin/protocols/index.jsp?ID="+ID)%></td>
    297297      </tr>
    298298      <tr>
    299299        <td class="prompt">Scan</td>
    300         <td><%=Base.getEncodedName(currentScan, !readCurrentScan)%></td>
     300        <td><%=Base.getEncodedName(currentScan, !readCurrentScan, "../scans/index.jsp?ID="+ID)%></td>
    301301      </tr>
    302302      <tr>
    303303        <td class="prompt">Software</td>
    304         <td><%=Base.getEncodedName(currentSoftware, !readCurrentSoftware)%></td>
     304        <td><%=Base.getEncodedName(currentSoftware, !readCurrentSoftware, "../../admin/sfotware/index.jsp?ID="+ID)%></td>
    305305      </tr>
    306306      <tr>
    307307        <td class="prompt">Array design</td>
    308         <td><%=Base.getEncodedName(currentArrayDesign, !readCurrentArrayDesign)%></td>
     308        <td><%=Base.getEncodedName(currentArrayDesign, !readCurrentArrayDesign, "../../lims/arraydesigns/index.jsp?ID="+ID)%></td>
    309309      </tr>
    310310      <tr>
  • trunk/www/views/scans/view_scan.jsp

    r1856 r2166  
    249249      <tr>
    250250        <td class="prompt">Hybridization</td>
    251         <td><%=Base.getEncodedName(currentHybridization, !readCurrentHybridization)%></td>
     251        <td><%=Base.getEncodedName(currentHybridization, !readCurrentHybridization, "../hybridizations/index.jsp?ID="+ID)%></td>
    252252      </tr>
    253253      <tr>
    254254        <td class="prompt">Scanner</td>
    255         <td><%=Base.getEncodedName(currentScanner, !readCurrentScanner)%></td>
     255        <td><%=Base.getEncodedName(currentScanner, !readCurrentScanner, "../../admin/hardware/index.jsp?ID="+ID)%></td>
    256256      </tr>
    257257      <tr>
    258258        <td class="prompt">Protocol</td>
    259         <td><%=Base.getEncodedName(currentProtocol, !readCurrentProtocol)%></td>
     259        <td><%=Base.getEncodedName(currentProtocol, !readCurrentProtocol, "../../admin/protocol/index.jsp?ID="+ID)%></td>
    260260      </tr>
    261261      <tr>
Note: See TracChangeset for help on using the changeset viewer.