Changeset 2210
- Timestamp:
- May 3, 2006, 3:42:21 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/Base.java
r2199 r2210 309 309 sc.getCurrentContext(Item.DIRECTORY, subContext) : null; // Used in special case for file manager 310 310 311 ItemContext transformationContext = itemType == Item.BIOASSAYSET ? 312 sc.getCurrentContext(Item.TRANSFORMATION, subContext) : null; // Used in special case for analysis tree 313 311 314 // Detect if active project has changed and then set the include option 312 315 int projectId = sc.getActiveProjectId(); … … 395 398 cc.getSelected().clear(); 396 399 if (dirContext != null) dirContext.getSelected().clear(); 400 if (transformationContext != null) transformationContext.getSelected().clear(); 397 401 while (names.hasMoreElements()) 398 402 { … … 466 470 } 467 471 } 468 else if ( name.startsWith("D:") && dirContext != null)472 else if (dirContext != null && name.startsWith("D:")) 469 473 { 470 474 // Special case for file manager which lists both files and directories in the … … 472 476 int id = Values.getInt(name.substring(2), -1); 473 477 if (id != -1) dirContext.getSelected().add(id); 478 } 479 else if (transformationContext != null && name.startsWith("T:")) 480 { 481 // Special case for analysis tree which lists both bioassay sets and 482 // transformations in the same list 483 int id = Values.getInt(name.substring(2), -1); 484 if (id != -1) transformationContext.getSelected().add(id); 474 485 } 475 486 else -
trunk/www/views/experiments/bioassaysets/index.jsp
r2200 r2210 71 71 private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,transformation,spots,reporters,date,tools"); 72 72 private static final Item itemType = Item.BIOASSAYSET; 73 74 75 private void setClosed(HttpServletRequest request, ItemContext cc) 76 { 77 String closed = request.getParameter("closed"); 78 if (closed != null) 79 { 80 cc.setObject("closed", new HashSet<String>(Arrays.asList(closed.split(",")))); 81 } 82 } 73 83 %> 74 84 <% … … 111 121 // Display the list page after updating the current context from the request parameters 112 122 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 113 String closed = request.getParameter("closed"); 114 if (closed != null) 115 { 116 cc.setObject("closed", new HashSet<Integer>(Arrays.asList(Values.getInt(closed.split(","))))); 117 } 123 setClosed(request, cc); 118 124 redirect = listPage; 119 125 } … … 180 186 dc = sc.newDbControl(); 181 187 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 182 int numTotal = cc.getSelected().size(); 188 ItemContext tc = sc.getCurrentContext(Item.TRANSFORMATION); 189 setClosed(request, cc); 190 191 int numTotal = cc.getSelected().size()+tc.getSelected().size(); 183 192 int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); 193 numRemoved += RemovableUtil.setRemoved(dc, Item.TRANSFORMATION, tc.getSelected(), true); 184 194 dc.commit(); 185 195 if (numTotal != numRemoved) … … 203 213 dc = sc.newDbControl(); 204 214 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 205 int numTotal = cc.getSelected().size(); 215 ItemContext tc = sc.getCurrentContext(Item.TRANSFORMATION); 216 setClosed(request, cc); 217 218 int numTotal = cc.getSelected().size()+tc.getSelected().size(); 206 219 int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); 220 numRemoved += RemovableUtil.setRemoved(dc, Item.TRANSFORMATION, tc.getSelected(), false); 207 221 dc.commit(); 208 222 if (numTotal != numRemoved) … … 216 230 // Run an export plugin in a list context 217 231 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 232 setClosed(request, cc); 218 233 dc = sc.newDbControl(); 219 234 final Experiment experiment = Experiment.getById(dc, experimentId); … … 234 249 // Run an import plugin in a list context 235 250 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 251 setClosed(request, cc); 236 252 dc = sc.newDbControl(); 237 253 final Experiment experiment = Experiment.getById(dc, experimentId); … … 252 268 // Run another plugin in a list context 253 269 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 270 setClosed(request, cc); 254 271 dc = sc.newDbControl(); 255 272 final Experiment experiment = Experiment.getById(dc, experimentId); -
trunk/www/views/experiments/bioassaysets/list_bioassaysets.jsp
r2173 r2210 31 31 import="net.sf.basedb.core.Item" 32 32 import="net.sf.basedb.core.ItemContext" 33 import="net.sf.basedb.core.BasicItem" 33 34 import="net.sf.basedb.core.Experiment" 34 35 import="net.sf.basedb.core.BioAssaySet" 36 import="net.sf.basedb.core.Transformation" 35 37 import="net.sf.basedb.core.ItemQuery" 38 import="net.sf.basedb.core.Nameable" 36 39 import="net.sf.basedb.core.ItemResultIterator" 37 40 import="net.sf.basedb.core.ItemResultList" … … 43 46 import="net.sf.basedb.core.query.Orders" 44 47 import="net.sf.basedb.core.query.Hql" 48 import="net.sf.basedb.core.query.Restrictions" 45 49 import="net.sf.basedb.core.plugin.GuiContext" 46 50 import="net.sf.basedb.core.plugin.Plugin" … … 51 55 import="net.sf.basedb.clients.web.util.Values" 52 56 import="java.util.List" 57 import="java.util.ArrayList" 53 58 import="java.util.LinkedList" 54 59 import="java.util.Map" … … 67 72 <%! 68 73 69 private static void addToTree(Tree<B ioAssaySet> tree, BioAssaySet bas)74 private static void addToTree(Tree<BasicItem> tree, BioAssaySet bas) 70 75 { 71 76 if (!tree.contains(bas)) 72 77 { 73 BioAssaySet source = bas.getTransformation().getSource();74 Tree.Entry<B ioAssaySet> parent = tree.getEntry(source);78 Transformation transformation = bas.getTransformation(); 79 Tree.Entry<BasicItem> parent = tree.getEntry(transformation); 75 80 if (parent == null) 76 81 { 77 addToTree(tree, source);78 parent = tree.getEntry( source);82 addToTree(tree, transformation); 83 parent = tree.getEntry(transformation); 79 84 } 80 85 parent.addChild(bas); … … 82 87 } 83 88 84 private static Tree<BioAssaySet> getBioAssaySetTree(DbControl dc, ItemQuery<BioAssaySet> query)89 private static void addToTree(Tree<BasicItem> tree, Transformation transformation) 85 90 { 86 Tree<BioAssaySet> tree = new Tree<BioAssaySet>(null); 87 ItemResultList<BioAssaySet> allBioAssaySets = query.list(dc); 91 if (!tree.contains(transformation)) 92 { 93 BioAssaySet source = transformation.getSource(); 94 Tree.Entry<BasicItem> parent = tree.getEntry(source); 95 if (parent == null) 96 { 97 addToTree(tree, source); 98 parent = tree.getEntry(source); 99 } 100 parent.addChild(transformation); 101 } 102 } 103 104 private static Tree<BasicItem> getAnalysisTree(DbControl dc, ItemQuery<BioAssaySet> bioAssaySetQuery, ItemQuery<Transformation> transformationQuery) 105 { 106 Tree<BasicItem> tree = new Tree<BasicItem>(null); 107 ItemResultList<BioAssaySet> allBioAssaySets = bioAssaySetQuery.list(dc); 108 List<Integer> ids = new ArrayList<Integer>(allBioAssaySets.size()); 109 88 110 for (BioAssaySet bas : allBioAssaySets) 89 111 { 90 112 addToTree(tree, bas); 113 ids.add(bas.getId()); 114 } 115 116 transformationQuery.restrict( 117 Restrictions.in( 118 Hql.property("source.id"), 119 Expressions.parameter("bioAssaySets", ids) 120 ) 121 ); 122 ItemResultList<Transformation> allTransformations = transformationQuery.list(dc); 123 for (Transformation t: allTransformations) 124 { 125 addToTree(tree, t); 91 126 } 92 127 return tree; 93 128 } 94 String generateTree(Tree<B ioAssaySet> tree, BioAssaySet root, Collection<Integer> closed)129 String generateTree(Tree<BasicItem> tree, BasicItem root, Collection<String> closed) 95 130 { 96 131 StringBuilder sb = new StringBuilder(); 97 Tree.Entry<B ioAssaySet> rootEntry = tree.getEntry(root);132 Tree.Entry<BasicItem> rootEntry = tree.getEntry(root); 98 133 if (rootEntry == null) return ""; 99 134 100 List<Tree.Entry<B ioAssaySet>> children = rootEntry.getChildren();135 List<Tree.Entry<BasicItem>> children = rootEntry.getChildren(); 101 136 if (children != null) 102 137 { 103 for (Tree.Entry<BioAssaySet> child : children) 104 { 105 String folderIcon = "BioAssaySet"; 106 BioAssaySet childBa = child.getNode(); 107 sb.append("var ba").append(childBa.getId()); 138 for (Tree.Entry<BasicItem> child : children) 139 { 140 BasicItem node = child.getNode(); 141 int id = node.getId(); 142 String var = node.getType().name() + "_" + id; 143 String name = ((Nameable)node).getName(); 144 145 String folderIcon = node.getType() == Item.BIOASSAYSET ? 146 "BioAssaySet" : "Transformation"; 147 sb.append("var ").append(var); 108 148 if (root == null) 109 149 { … … 112 152 else 113 153 { 114 sb.append(" = JoustMenu.addChildItem(ba" + root.getId()); 154 String rootVar = root.getType().name() + "_" + root.getId(); 155 sb.append(" = JoustMenu.addChildItem(").append(rootVar); 115 156 } 116 157 sb.append(",'").append(folderIcon).append("'"); 117 sb.append(",'").append(HTML.javaScriptEncode( childBa.getName())).append("'");118 sb.append(", 'itemOnClick(event, ").append( childBa.getId()).append(")', '', '").append(childBa.getId()).append("');\n");119 if ((closed == null || !closed.contains( childBa.getId())) && child.getNumChildren() > 0)120 { 121 sb.append("JoustMenu.menuItems[ ba").append(childBa.getId()).append("].isOpen = true;\n");122 } 123 sb.append(generateTree(tree, childBa, closed));158 sb.append(",'").append(HTML.javaScriptEncode(name)).append("'"); 159 sb.append(", 'itemOnClick(event, ").append(id).append(")', '', '").append(var).append("');\n"); 160 if ((closed == null || !closed.contains(var)) && child.getNumChildren() > 0) 161 { 162 sb.append("JoustMenu.menuItems[").append(var).append("].isOpen = true;\n"); 163 } 164 sb.append(generateTree(tree, node, closed)); 124 165 } 125 166 } … … 132 173 final String ID = sc.getId(); 133 174 final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); 175 final ItemContext tc = sc.getCurrentContext(Item.TRANSFORMATION); 134 176 135 177 final ModeInfo mode = ModeInfo.get(request.getParameter("mode")); … … 137 179 final String title = mode.generateTitle("bioassay set", "bioassay sets"); 138 180 final DbControl dc = sc.newDbControl(); 139 Tree<B ioAssaySet> bioAssaySets= null;181 Tree<BasicItem> analysisTree = null; 140 182 try 141 183 { … … 146 188 147 189 final ItemQuery<BioAssaySet> query = Base.getConfiguredQuery(cc, true, experiment.getBioAssaySets()); 190 final ItemQuery<Transformation> transformationQuery = experiment.getTransformations(); 148 191 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 149 192 try 150 193 { 151 bioAssaySets = getBioAssaySetTree(dc, query);194 analysisTree = getAnalysisTree(dc, query, transformationQuery); 152 195 } 153 196 catch (Throwable t) … … 156 199 } 157 200 // Contains the ID:s of the bioassaysets that are closed in the tree 158 Collection< Integer> closed = (Collection<Integer>)cc.getObject("closed");201 Collection<String> closed = (Collection<String>)cc.getObject("closed"); 159 202 int numListed = 0; 160 203 %> … … 168 211 Main.openPopup('index.jsp?ID=<%=ID%>&cmd=NewItem&experiment_id=<%=experimentId%>', 'NewBioAssaySet', 740, 540); 169 212 } 170 function edit Item(itemId)213 function editBioAssaySet(itemId) 171 214 { 172 215 Main.openPopup('index.jsp?ID=<%=ID%>&cmd=EditItem&experiment_id=<%=experimentId%>&item_id='+itemId, 'EditBioAssaySet', 500, 300); 173 216 } 174 function view Item(itemId)217 function viewBioAssaySet(itemId) 175 218 { 176 219 location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&experiment_id=<%=experimentId%>&item_id='+itemId; 177 220 } 178 function itemOnClick(evt, itemId) 179 { 180 Table.itemOnClick(formId, evt, itemId, '<%=mode.getName()%>', viewItem, editItem, returnSelected); 221 function bioAssaySetOnClick(evt, itemId) 222 { 223 Table.itemOnClick(formId, evt, itemId, '<%=mode.getName()%>', viewBioAssaySet, editBioAssaySet, returnSelected); 224 } 225 function viewTransformation(itemId) 226 { 227 location.href = '../transformations/index.jsp?ID=<%=ID%>&cmd=ViewItem&experiment_id=<%=experimentId%>&item_id='+itemId; 228 } 229 function transformationOnClick(evt, itemId) 230 { 231 viewTransformation(itemId); 181 232 } 182 233 function deleteItems() … … 258 309 frm.closed.value += menuItem.externalId+','; 259 310 } 260 //alert(document.forms[formId].closed.value);311 // alert(document.forms[formId].closed.value); 261 312 this.updateIconsAndText(menuItemIndex); 262 313 } … … 324 375 } 325 376 326 <%= generateTree(bioAssaySets, null, closed)%>377 <%=analysisTree == null ? "" : generateTree(analysisTree, null, closed)%> 327 378 JoustMenu.draw('joust'); 328 379 … … 404 455 datatype="int" 405 456 title="Reporters" 406 sortable="true"407 filterable="true"408 exportable="true"409 />410 <tbl:columndef411 id="transformation"412 property="transformation.name"413 datatype="string"414 title="Transformation"415 457 sortable="true" 416 458 filterable="true" … … 537 579 int index = cc.getPage()*cc.getRowsPerPage(); 538 580 int selectedItemId = cc.getId(); 539 if ( bioAssaySets!= null)581 if (analysisTree != null) 540 582 { 541 Iterator<Tree.Entry<B ioAssaySet>> baas = bioAssaySets.entryIterator();583 Iterator<Tree.Entry<BasicItem>> baas = analysisTree.entryIterator(); 542 584 while (baas.hasNext()) 543 585 { 544 Tree.Entry<B ioAssaySet> entry = baas.next();545 B ioAssaySetitem = entry.getNode();586 Tree.Entry<BasicItem> entry = baas.next(); 587 BasicItem item = entry.getNode(); 546 588 if (item != null) 547 589 { 548 int level = entry.getDepth() - 1; 549 int itemId = item.getId(); 550 String name = HTML.encodeTags(item.getName()); 551 index++; 552 numListed++; 553 boolean hasChildren = entry.getNumChildren() > 0; 554 boolean isFirstChild = entry.getParent().isFirstChild(item); 555 boolean isLastChild = entry.getParent().isLastChild(item); 556 String outlineIcon = ""; 557 String docIcon = ""; 558 if (hasChildren) 559 { 560 docIcon = "folderopen.gif"; 561 outlineIcon = "minus"; 562 if (isFirstChild && isLastChild) 590 int level = entry.getDepth() - 1; 591 int itemId = item.getId(); 592 String joustId = item.getType().name() + "_" + itemId; 593 String name = HTML.encodeTags(((Nameable)item).getName()); 594 String description = HTML.encodeTags(((Nameable)item).getDescription()); 595 boolean removed = false; 596 Transformation t = null; 597 BioAssaySet bas = null; 598 String prefix = ""; 599 ItemContext ccc = null; 600 String view = ""; 601 String onClick = ""; 602 if (item.getType() == Item.TRANSFORMATION) 563 603 { 564 outlineIcon += "only.gif"; 565 } 566 else if (isFirstChild) 567 { 568 outlineIcon += "top.gif"; 569 } 570 else if (isLastChild) 571 { 572 outlineIcon += "bottom.gif"; 604 t = (Transformation)item; 605 removed = t.isRemoved(); 606 prefix = "T:"; 607 ccc = tc; 608 view = "View this transformation (use CTRL, ALT or SHIFT to edit)"; 609 onClick = "transformationOnClick"; 573 610 } 574 611 else 575 612 { 576 outlineIcon += ".gif"; 613 bas = (BioAssaySet)item; 614 removed = bas.isRemoved(); 615 ccc = cc; 616 view = "View this bioassay set (use CTRL, ALT or SHIFT to edit)"; 617 onClick = "bioAssaySetOnClick"; 577 618 } 578 }579 else580 {581 docIcon = "folderclosed.gif";582 outlineIcon = "join";583 if (isLastChild)584 {585 outlineIcon += "bottom.gif";586 }587 else if (isFirstChild)588 {589 outlineIcon += "top.gif";590 }591 else592 {593 outlineIcon += ".gif";594 }595 }596 %>597 <tbl:row598 id="<%="row."+itemId%>"599 >600 <tbl:header601 clazz="index"602 ><%=index%></tbl:header>603 <tbl:header604 clazz="check"605 visible="<%=mode.hasCheck()%>"606 ><input607 type="checkbox"608 name="<%=itemId%>"609 value="<%=itemId%>"610 title="<%=name%>"611 <%=cc.getSelected().contains(itemId) ? "checked" : ""%>612 ></tbl:header>613 <tbl:header614 clazz="check"615 visible="<%=mode.hasRadio()%>"616 ><input617 type="radio"618 name="item_id"619 value="<%=itemId%>"620 title="<%=name%>"621 <%=selectedItemId == itemId ? "checked" : ""%>622 ></tbl:header>623 <tbl:header624 clazz="icons"625 visible="<%=mode.hasIcons()%>"626 ><base:icon627 image="deleted.gif"628 tooltip="This item has been scheduled for deletion"629 visible="<%=item.isRemoved()%>"630 /> </tbl:header>631 619 632 <tbl:cell clazz="joustcell" column="name"> 633 <div id="tree.<%=itemId%>" class="link" onclick="itemOnClick(event, <%=itemId%>)" title="View this bioassay set (use CTRL, ALT or SHIFT to edit)"> 634 <img src="../../../images/joust/blank.gif" width="<%=level*18%>" height="1"> 635 <img src="../../../images/joust/<%=outlineIcon%>"> 636 <img src="../../../images/joust/<%=docIcon%>"> 637 <%=name%> 638 </div> 639 </tbl:cell> 640 <tbl:cell column="spots"><%=item.getNumSpots()%></tbl:cell> 641 <tbl:cell column="reporters"><%=item.getNumReporters()%></tbl:cell> 642 <tbl:cell column="transformation"><base:propertyvalue item="<%=item%>" property="transformation.name" /></tbl:cell> 643 <tbl:cell column="date"><base:propertyvalue item="<%=item%>" property="transformation.job.ended" /></tbl:cell> 644 <tbl:cell column="plugin"><base:propertyvalue item="<%=item%>" property="transformation.job.pluginDefinition.name" /></tbl:cell> 645 <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> 646 <tbl:cell column="tools">TODO</tbl:cell> 647 </tbl:row> 648 <% 620 index++; 621 numListed++; 622 623 %> 624 <tbl:row 625 id="<%="row."+joustId%>" 626 > 627 <tbl:header 628 clazz="index" 629 ><%=index%></tbl:header> 630 <tbl:header 631 clazz="check" 632 visible="<%=mode.hasCheck()%>" 633 ><input 634 type="checkbox" 635 name="<%=prefix+itemId%>" 636 value="<%=itemId%>" 637 title="<%=name%>" 638 <%=ccc.getSelected().contains(itemId) ? "checked" : ""%> 639 ></tbl:header> 640 <tbl:header 641 clazz="check" 642 visible="<%=mode.hasRadio()%>" 643 ><input 644 type="radio" 645 name="item_id" 646 value="<%=itemId%>" 647 title="<%=name%>" 648 <%=selectedItemId == itemId ? "checked" : ""%> 649 ></tbl:header> 650 <tbl:header 651 clazz="icons" 652 visible="<%=mode.hasIcons()%>" 653 ><base:icon 654 image="deleted.gif" 655 tooltip="This item has been scheduled for deletion" 656 visible="<%=removed%>" 657 /> </tbl:header> 658 659 <tbl:cell clazz="joustcell" column="name"> 660 <div id="tree.<%=joustId%>" class="link" onclick="<%=onClick%>(event, <%=itemId%>)" title="<%=view%>"> 661 <%=name%> 662 </div> 663 </tbl:cell> 664 <tbl:cell column="spots"><%=bas == null ? "" : bas.getNumSpots()%></tbl:cell> 665 <tbl:cell column="reporters"><%=bas == null ? "" : bas.getNumReporters()%></tbl:cell> 666 <% 667 if (t != null) 668 { 669 %> 670 <tbl:cell column="date"><base:propertyvalue item="<%=t%>" property="job.ended" /></tbl:cell> 671 <tbl:cell column="plugin"><base:propertyvalue item="<%=t%>" property="job.pluginDefinition.name" /></tbl:cell> 672 <% 673 } 674 else 675 { 676 %> 677 <tbl:cell column="date"> </tbl:cell> 678 <tbl:cell column="plugin"> </tbl:cell> 679 <% 680 } 681 %> 682 <tbl:cell column="description"><%=description%></tbl:cell> 683 <tbl:cell column="tools">TODO</tbl:cell> 684 </tbl:row> 685 <% 649 686 } 650 687 }
Note: See TracChangeset
for help on using the changeset viewer.