Changeset 2166
- Timestamp:
- Apr 19, 2006, 3:30:05 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/Base.java
r2138 r2166 719 719 throws ItemModifiedException, BaseException 720 720 { 721 // Modified annotations 721 722 String modified = Values.getStringOrNull(request.getParameter("modifiedAnnotations")); 722 723 if (modified != null) … … 751 752 } 752 753 } 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 } 753 820 } 754 821 -
trunk/src/core/net/sf/basedb/core/Annotation.java
r2098 r2166 26 26 27 27 import net.sf.basedb.core.data.AnnotationData; 28 import net.sf.basedb.core.query.EntityQuery; 28 29 29 30 import java.util.List; … … 55 56 56 57 /** 58 This filter gives everybody read permission to annotations. 59 */ 60 private static final QueryRuntimeFilter RUNTIME_FILTER = new QueryRuntimeFilterImpl(); 61 62 /** 57 63 Create a new annotation. 58 64 @param dc The DbControl object … … 103 109 static ItemQuery<Annotation> getQuery() 104 110 { 105 return new ItemQuery<Annotation>(Annotation.class );111 return new ItemQuery<Annotation>(Annotation.class, RUNTIME_FILTER); 106 112 } 107 113 … … 153 159 { 154 160 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); 155 165 } 156 166 else if (as.hasPermission(Permission.READ)) … … 267 277 } 268 278 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 } 269 287 } 270 288 -
trunk/src/core/net/sf/basedb/core/AnnotationSet.java
r2164 r2166 25 25 package net.sf.basedb.core; 26 26 27 import net.sf.basedb.core.query.EntityQuery; 28 import net.sf.basedb.core.query.Expression; 29 import net.sf.basedb.core.query.Expressions; 27 30 import net.sf.basedb.core.query.Restrictions; 28 31 import net.sf.basedb.core.query.Hql; … … 60 63 61 64 /** 65 This filter gives everybody read permission to annotations. 66 */ 67 private static final QueryRuntimeFilter RUNTIME_FILTER = new QueryRuntimeFilterImpl(); 68 69 /** 62 70 Create a new annotation set for the specified item. 63 71 @see AnnotatedItem#getAnnotationSet() … … 70 78 return as; 71 79 } 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 } 73 100 /** 74 101 Get a {@link ItemQuery} object configured to retrieve <code>AnnotationSet</code> … … 79 106 static ItemQuery<AnnotationSet> getQuery() 80 107 { 81 return new ItemQuery<AnnotationSet>(AnnotationSet.class );108 return new ItemQuery<AnnotationSet>(AnnotationSet.class, RUNTIME_FILTER); 82 109 } 83 110 … … 131 158 } 132 159 /** 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 135 161 if the logged in user has WRITE permission on the associated item. 136 162 */ … … 138 164 throws BaseException 139 165 { 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)) 142 174 { 143 175 granted |= Permission.grant(Permission.CREATE, Permission.READ, Permission.WRITE, Permission.DELETE); 144 176 } 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 146 182 { 147 183 granted |= Permission.grant(Permission.READ); … … 400 436 401 437 /** 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) 403 442 @return An <code>ItemQuery</code> object 404 443 */ … … 418 457 419 458 /** 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 /** 420 484 Inherit an annotation set. 421 485 @param annotationSet The annotation set to inherit … … 495 559 return query; 496 560 } 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 } 497 570 } -
trunk/src/core/net/sf/basedb/core/Hybridization.java
r1418 r2166 117 117 */ 118 118 /** 119 Get the labeled extracts and array slide 119 Get the labeled extracts and array slide. 120 120 */ 121 121 public Set<Annotatable> getAnnotatableParents() … … 125 125 try 126 126 { 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())); 128 130 if (getData().getArraySlide() != null) annotatable.add(getArraySlide()); 129 131 } -
trunk/src/core/net/sf/basedb/util/Tree.java
r2096 r2166 256 256 Add a child to the node. 257 257 @param child The child to add 258 @return The <code>Entry</code> object of the new child node 258 259 @throws IllegalArgumentException If the child already exists in the tree 259 260 */ 260 public voidaddChild(E child)261 public Entry<E> addChild(E child) 261 262 { 262 263 if (tree.contains(child)) … … 264 265 throw new IllegalArgumentException("Element '" + child + "' is already in the tree."); 265 266 } 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; 267 270 } 268 271 -
trunk/www/common/annotations/annotate.jsp
r1985 r2166 59 59 try 60 60 { 61 // final Annotatable item = (Annotatable)sc.getSessionSetting(itemType.name()+".item");62 61 final Annotatable item = itemId == 0 ? null : (Annotatable)itemType.getById(dc, itemId); 63 if (item != null) dc.reattachItem((BasicItem)item);64 62 final String clazz = "class=\"text\"" ; 65 63 … … 110 108 } 111 109 icon = "<img id=\"icon_"+at.getId()+"\" src=\"../../images/"+icon+"\" class=\"icon\">"; 112 sb.append("<div class=\"p luginparameter\" 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>"); 113 111 %> 114 //new AnnotationType(<%=at.getId()%>, '<%=HTML.javaScriptEncode(at.getName())%>', '<%=at.getValueType().name()%>', <%=at.getMultiplicity()%>, <%=at.isEnumeration()%>, values);115 112 new Parameter('<%=at.getId()%>', '<%=HTML.javaScriptEncode(at.getName())%>', <%=at.getMultiplicity()%>, <%=at.isEnumeration()%>, false, values); 116 113 <% … … 351 348 <base:body onload="init()" style="background: #E0E0E0;"> 352 349 <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%"> 354 351 <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;"> 357 354 <%=sb.toString()%> 358 355 </div> 359 356 <base:icon image="hasvalues.gif" /> = has value(s) 360 357 </td> 361 <td> </td> 362 <td> 358 <td width="50%"> 363 359 364 360 <div id="valuecontainer" style="display: none;"> -
trunk/www/common/annotations/inherit.jsp
r927 r2166 30 30 --%> 31 31 <%@ 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" 33 58 %> 34 59 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> 35 60 <%! 61 private 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 79 private 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 <% 148 final SessionControl sc = Base.getExistingSessionControl(pageContext, true); 149 final String ID = sc.getId(); 150 final float scale = Base.getScale(sc); 151 final Item itemType = Item.valueOf(request.getParameter("item_type")); 152 final int itemId = Values.getInt(request.getParameter("item_id")); 153 154 final DbControl dc = sc.newDbControl(); 155 ItemResultList<AnnotationType> annotationTypes = null; 156 try 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 %> 36 198 <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; 39 271 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> 42 297 </base:body> 43 298 </base:page> 44 299 <% 300 } 301 finally 302 { 303 if (dc != null) dc.close(); 304 } 305 %> 306 -
trunk/www/common/annotations/list_annotations.jsp
r1855 r2166 33 33 import="net.sf.basedb.core.AnnotationType" 34 34 import="net.sf.basedb.core.AnnotationSet" 35 import="net.sf.basedb.core.Annotation" 35 36 import="net.sf.basedb.core.Annotatable" 37 import="net.sf.basedb.core.Nameable" 36 38 import="net.sf.basedb.core.ItemQuery" 37 39 import="net.sf.basedb.core.ItemResultList" 38 40 import="net.sf.basedb.core.PermissionDeniedException" 41 import="net.sf.basedb.core.query.Orders" 42 import="net.sf.basedb.core.query.Hql" 39 43 import="net.sf.basedb.clients.web.Base" 40 44 import="net.sf.basedb.clients.web.util.HTML" … … 58 62 final ItemResultList<AnnotationType> annotationTypes = annotationTypeQuery.list(dc); 59 63 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 } 60 74 %> 61 75 … … 63 77 <base:head /> 64 78 <base:body> 65 66 79 <% 67 80 if (annotationTypes.size() == 0) … … 69 82 %> 70 83 <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). 72 86 <% 73 87 } … … 98 112 <tbl:rows> 99 113 <% 100 AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;101 114 for (AnnotationType at : annotationTypes) 102 115 { … … 120 133 %> 121 134 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 %> 124 213 </div> 125 214 -
trunk/www/common/plugin/configure.jsp
r2147 r2166 145 145 } 146 146 icon = "<img id=\"icon_"+name+"\" src=\"../../images/"+icon+"\" class=\"icon\">"; 147 sb.append("<div class=\"p luginparameter\" 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>"); 148 148 %> 149 149 var values = new Array(); -
trunk/www/include/scripts/annotations.js
r1985 r2166 3 3 BioArray Software Environment (BASE) - http://base.thep.lu.se/ 4 4 Copyright (C) 2002-2004 Lao Saal, Carl Troein, 5 Johan Vallon-Christersson, Jari H äkkinen, Nicklas Nordborg5 Johan Vallon-Christersson, Jari H??kkinen, Nicklas Nordborg 6 6 7 7 This file is part of BASE. … … 71 71 this.addInheritedAnnotationsToForm = function(theFrame, frm) 72 72 { 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 } 74 110 } 75 76 111 } 77 112 -
trunk/www/include/scripts/linkitems.js
r1808 r2166 3 3 BioArray Software Environment (BASE) - http://base.thep.lu.se/ 4 4 Copyright (C) 2002-2004 Lao Saal, Carl Troein, 5 Johan Vallon-Christersson, Jari H äkkinen, Nicklas Nordborg5 Johan Vallon-Christersson, Jari H?kkinen, Nicklas Nordborg 6 6 7 7 This file is part of BASE. -
trunk/www/include/scripts/newjoust.js
r2097 r2166 40 40 function JoustMenuClass() 41 41 { 42 this.alwaysSendOnClickToSelected = false; 42 43 this.firstItemIndex = -1; 43 44 this.lastItemIndex = -1; … … 101 102 @return The index of the new item 102 103 */ 103 this.addMenuItem = function(afterItemIndex, iconName, text, onclick, tooltip, externalId )104 this.addMenuItem = function(afterItemIndex, iconName, text, onclick, tooltip, externalId, isOpen) 104 105 { 105 106 var afterItem = this.menuItems[afterItemIndex]; … … 112 113 var insertIndex = this.menuItems.length; 113 114 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); 115 116 this.menuItems[insertIndex] = menuItem; 116 117 if (!this.menuItems[externalId]) this.menuItems[externalId] = menuItem; … … 147 148 @return The index of the new item 148 149 */ 149 this.addChildItem = function(parentItemIndex, iconName, text, onclick, tooltip, externalId )150 this.addChildItem = function(parentItemIndex, iconName, text, onclick, tooltip, externalId, isOpen) 150 151 { 151 152 var parentItem = this.menuItems[parentItemIndex]; 152 153 if (!parentItem) 153 154 { 154 return this.addMenuItem(-1, iconName, text, onclick, tooltip );155 return this.addMenuItem(-1, iconName, text, onclick, tooltip, externalId, isOpen); 155 156 } 156 157 var afterItem = this.menuItems[parentItem.lastChildIndex]; 157 158 if (afterItem) 158 159 { 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); 160 161 return parentItem.lastChildIndex; 161 162 } 162 163 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); 164 165 this.menuItems[insertIndex] = menuItem; 165 166 if (!this.menuItems[externalId]) this.menuItems[externalId] = menuItem; … … 213 214 { 214 215 var menuItem = this.menuItems[menuItemIndex]; 215 if (!menuItem || menuItemIndex == this.selectedItemIndex) return;216 if (!menuItem) return; 216 217 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 } 228 236 } 229 237 … … 279 287 @param parentItemIndex The index of the parent menu item, or -1 if this is on the root level 280 288 */ 281 function MenuItem(menu, index, iconName, text, onclick, tooltip, nextItemIndex, previousItemIndex, parentItemIndex, externalId )289 function MenuItem(menu, index, iconName, text, onclick, tooltip, nextItemIndex, previousItemIndex, parentItemIndex, externalId, isOpen) 282 290 { 283 291 this.menu = menu; … … 291 299 this.parentItemIndex = parentItemIndex; 292 300 this.externalId = externalId; 293 this.isOpen = false;301 this.isOpen = isOpen; 294 302 this.isSelected = false; 295 303 this.firstChildIndex = -1; -
trunk/www/include/styles/parameters.css
r1985 r2166 41 41 } 42 42 43 .parameterlist .p luginparameter{43 .parameterlist .param { 44 44 45 45 } 46 46 47 .parameterlist . icon {47 .parameterlist .param .icon { 48 48 padding-right: 4px; 49 49 } 50 .parameterlist . hover {50 .parameterlist .param.hover { 51 51 background: #E0E0E0; 52 52 cursor: pointer; 53 53 } 54 54 55 .parameterlist . selected {55 .parameterlist .param.selected { 56 56 color: #FFFFFF; 57 57 background: #445577; -
trunk/www/views/rawbioassays/view_rawbioassay.jsp
r1855 r2166 294 294 <tr> 295 295 <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> 297 297 </tr> 298 298 <tr> 299 299 <td class="prompt">Scan</td> 300 <td><%=Base.getEncodedName(currentScan, !readCurrentScan )%></td>300 <td><%=Base.getEncodedName(currentScan, !readCurrentScan, "../scans/index.jsp?ID="+ID)%></td> 301 301 </tr> 302 302 <tr> 303 303 <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> 305 305 </tr> 306 306 <tr> 307 307 <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> 309 309 </tr> 310 310 <tr> -
trunk/www/views/scans/view_scan.jsp
r1856 r2166 249 249 <tr> 250 250 <td class="prompt">Hybridization</td> 251 <td><%=Base.getEncodedName(currentHybridization, !readCurrentHybridization )%></td>251 <td><%=Base.getEncodedName(currentHybridization, !readCurrentHybridization, "../hybridizations/index.jsp?ID="+ID)%></td> 252 252 </tr> 253 253 <tr> 254 254 <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> 256 256 </tr> 257 257 <tr> 258 258 <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> 260 260 </tr> 261 261 <tr>
Note: See TracChangeset
for help on using the changeset viewer.