www/admin/annotationtypecategories/edit_category.jsp

Code
Comments
Other
Rev Date Author Line
2356 08 Jun 06 dominic 1 <%-- $Id$
2356 08 Jun 06 dominic 2   ------------------------------------------------------------------
3675 16 Aug 07 jari 3   Copyright (C) 2006 Nicklas Nordborg, Dominic Oyeniran
2356 08 Jun 06 dominic 4
2356 08 Jun 06 dominic 5   This file is part of BASE - BioArray Software Environment.
2356 08 Jun 06 dominic 6   Available at http://base.thep.lu.se/
2356 08 Jun 06 dominic 7
2356 08 Jun 06 dominic 8   BASE is free software; you can redistribute it and/or
2356 08 Jun 06 dominic 9   modify it under the terms of the GNU General Public License
4476 05 Sep 08 jari 10   as published by the Free Software Foundation; either version 3
2356 08 Jun 06 dominic 11   of the License, or (at your option) any later version.
2356 08 Jun 06 dominic 12
2356 08 Jun 06 dominic 13   BASE is distributed in the hope that it will be useful,
2356 08 Jun 06 dominic 14   but WITHOUT ANY WARRANTY; without even the implied warranty of
2356 08 Jun 06 dominic 15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2356 08 Jun 06 dominic 16   GNU General Public License for more details.
2356 08 Jun 06 dominic 17
2356 08 Jun 06 dominic 18   You should have received a copy of the GNU General Public License
4510 11 Sep 08 jari 19   along with BASE. If not, see <http://www.gnu.org/licenses/>.
2356 08 Jun 06 dominic 20   ------------------------------------------------------------------
2356 08 Jun 06 dominic 21
2356 08 Jun 06 dominic 22
2356 08 Jun 06 dominic 23   @author Dominic
2356 08 Jun 06 dominic 24   @version 2.0
2356 08 Jun 06 dominic 25 --%>
5426 24 Sep 10 nicklas 26 <%@ page pageEncoding="UTF-8" session="false"
2356 08 Jun 06 dominic 27   import="net.sf.basedb.core.SessionControl"
2356 08 Jun 06 dominic 28   import="net.sf.basedb.core.DbControl"
2356 08 Jun 06 dominic 29   import="net.sf.basedb.core.Item"
2356 08 Jun 06 dominic 30   import="net.sf.basedb.core.Type"
2356 08 Jun 06 dominic 31   import="net.sf.basedb.core.ItemContext"
3890 30 Oct 07 nicklas 32   import="net.sf.basedb.core.Include"
2356 08 Jun 06 dominic 33   import="net.sf.basedb.core.ItemQuery"
2356 08 Jun 06 dominic 34   import="net.sf.basedb.core.Permission"
2356 08 Jun 06 dominic 35   import="net.sf.basedb.core.AnnotationType"
2356 08 Jun 06 dominic 36   import="net.sf.basedb.core.AnnotationTypeCategory"
2356 08 Jun 06 dominic 37   import="net.sf.basedb.core.SystemItems"
2356 08 Jun 06 dominic 38   import="net.sf.basedb.core.Metadata"
2356 08 Jun 06 dominic 39   import="net.sf.basedb.core.ItemQuery"
2356 08 Jun 06 dominic 40   import="net.sf.basedb.core.ItemResultList"
2356 08 Jun 06 dominic 41   import="net.sf.basedb.core.PermissionDeniedException"
2356 08 Jun 06 dominic 42   import="net.sf.basedb.core.query.Orders"
2356 08 Jun 06 dominic 43   import="net.sf.basedb.core.query.Hql"
2356 08 Jun 06 dominic 44   import="net.sf.basedb.clients.web.Base"
2356 08 Jun 06 dominic 45   import="net.sf.basedb.clients.web.util.HTML"
2753 20 Oct 06 nicklas 46   import="net.sf.basedb.util.Values"
6292 11 Jun 13 nicklas 47   import="net.sf.basedb.util.json.JsonUtil"
6292 11 Jun 13 nicklas 48   import="net.sf.basedb.util.json.NameableConverter"
5510 19 Nov 10 nicklas 49   import="net.sf.basedb.core.plugin.GuiContext"
5510 19 Nov 10 nicklas 50   import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
5510 19 Nov 10 nicklas 51   import="net.sf.basedb.clients.web.extensions.JspContext"
5510 19 Nov 10 nicklas 52   import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
7604 25 Feb 19 nicklas 53   import="net.sf.basedb.clients.web.extensions.tabcontrol.TabAction"
5510 19 Nov 10 nicklas 54   import="net.sf.basedb.util.extensions.ExtensionsInvoker"
2356 08 Jun 06 dominic 55   import="java.util.Set"
6292 11 Jun 13 nicklas 56   import="org.json.simple.JSONArray"
6292 11 Jun 13 nicklas 57   import="org.json.simple.JSONObject"
2356 08 Jun 06 dominic 58 %>
2356 08 Jun 06 dominic 59 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
2356 08 Jun 06 dominic 60 <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
6149 25 Sep 12 nicklas 61 <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
2356 08 Jun 06 dominic 62 <%
2356 08 Jun 06 dominic 63 final Item itemType = Item.ANNOTATIONTYPECATEGORY;
2356 08 Jun 06 dominic 64 final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
2356 08 Jun 06 dominic 65 final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
2356 08 Jun 06 dominic 66 final int itemId = cc.getId();
2356 08 Jun 06 dominic 67 final String ID = sc.getId();
2356 08 Jun 06 dominic 68 final float scale = Base.getScale(sc);
7954 12 May 21 nicklas 69 final DbControl dc = sc.newDbControl(":Edit "+itemType);
2356 08 Jun 06 dominic 70 try
2356 08 Jun 06 dominic 71 {
2356 08 Jun 06 dominic 72   String title = null;
2356 08 Jun 06 dominic 73   AnnotationTypeCategory annotationTypeCategory = null;
2356 08 Jun 06 dominic 74
2356 08 Jun 06 dominic 75   
2515 14 Aug 06 nicklas 76   if (itemId == 0)
2356 08 Jun 06 dominic 77   {
2515 14 Aug 06 nicklas 78     //to create a new annotation category
2356 08 Jun 06 dominic 79     title = "Create annotation type category";
2356 08 Jun 06 dominic 80     cc.removeObject("item");
2356 08 Jun 06 dominic 81   }
2515 14 Aug 06 nicklas 82   else
2356 08 Jun 06 dominic 83   {
2515 14 Aug 06 nicklas 84     //if user click on edit, to edit annotationcategory
2356 08 Jun 06 dominic 85     annotationTypeCategory = AnnotationTypeCategory.getById(dc, itemId);
2356 08 Jun 06 dominic 86     cc.setObject("item", annotationTypeCategory);
2356 08 Jun 06 dominic 87     title = "Edit annotation type category-- " + HTML.encodeTags(annotationTypeCategory.getName());
2515 14 Aug 06 nicklas 88     annotationTypeCategory.checkPermission(Permission.WRITE);
2356 08 Jun 06 dominic 89   }
2356 08 Jun 06 dominic 90   
2356 08 Jun 06 dominic 91   // ---- Query to retrieve annotationtype members for a category
6292 11 Jun 13 nicklas 92   JSONObject jsonAnnotationTypes = new JSONObject();
6292 11 Jun 13 nicklas 93   jsonAnnotationTypes.put("itemType", "ANNOTATIONTYPE");
2356 08 Jun 06 dominic 94   if (annotationTypeCategory != null)
2356 08 Jun 06 dominic 95   {
6292 11 Jun 13 nicklas 96     ItemQuery<AnnotationType> query = annotationTypeCategory.getAnnotationTypes(null);
6292 11 Jun 13 nicklas 97     query.include(Include.ALL);
6292 11 Jun 13 nicklas 98     query.order(Orders.asc(Hql.property("name")));
7604 25 Feb 19 nicklas 99     jsonAnnotationTypes.put("items", JsonUtil.toArray(query.iterate(dc), new NameableConverter<AnnotationType>()));
2356 08 Jun 06 dominic 100   }
2356 08 Jun 06 dominic 101   
5510 19 Nov 10 nicklas 102   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), annotationTypeCategory);
7604 25 Feb 19 nicklas 103   ExtensionsInvoker<TabAction> invoker = EditUtil.useEditExtensions(jspContext);
2356 08 Jun 06 dominic 104   %>
6292 11 Jun 13 nicklas 105   <base:page type="popup" title="<%=title%>" id="edit-page">
6292 11 Jun 13 nicklas 106   <base:head scripts="tabcontrol-2.js,linkitems-2.js,~categories.js" styles="tabcontrol.css">
5510 19 Nov 10 nicklas 107     <ext:scripts context="<%=jspContext%>" />
5510 19 Nov 10 nicklas 108     <ext:stylesheets context="<%=jspContext%>" />
6292 11 Jun 13 nicklas 109   </base:head>
6292 11 Jun 13 nicklas 110   <base:body>
6292 11 Jun 13 nicklas 111     <h1><%=title%> <base:help tabcontrol="settings" /></h1>  
2356 08 Jun 06 dominic 112     
6162 10 Oct 12 nicklas 113     <form action="index.jsp?ID=<%=ID%>" method="post" name="annotationTypeCategory">
2356 08 Jun 06 dominic 114     <input type="hidden" name="cmd" value="UpdateItem">
2356 08 Jun 06 dominic 115
5922 11 Jan 12 nicklas 116     <t:tabcontrol id="settings" 
5922 11 Jan 12 nicklas 117       subclass="content dialogtabcontrol"
5922 11 Jan 12 nicklas 118       position="bottom"
6294 13 Jun 13 nicklas 119       remember="<%=annotationTypeCategory != null %>"
5510 19 Nov 10 nicklas 120       extensions="<%=invoker%>">
6292 11 Jun 13 nicklas 121     <t:tab id="info" title="Annotation type category" 
2515 14 Aug 06 nicklas 122       helpid="annotationtypecategory.edit">
5922 11 Jan 12 nicklas 123       <table class="fullform input100 smaller">
2356 08 Jun 06 dominic 124       <tr>
5922 11 Jan 12 nicklas 125         <th>Name</th>
6292 11 Jun 13 nicklas 126         <td><input class="text required auto-init" data-auto-init="<%=annotationTypeCategory == null ? "focus-select" : "focus" %>"
6292 11 Jun 13 nicklas 127           type="text" name="name" 
2356 08 Jun 06 dominic 128           value="<%=HTML.encodeTags(annotationTypeCategory == null ? Values.getString(cc.getPropertyValue("name"), "New annotation type category") : annotationTypeCategory.getName())%>" 
5922 11 Jan 12 nicklas 129           maxlength="<%=AnnotationTypeCategory.MAX_NAME_LENGTH%>"></td>
5922 11 Jan 12 nicklas 130         <td></td>
2356 08 Jun 06 dominic 131       </tr>
5922 11 Jan 12 nicklas 132       <tr class="dynamic">
5922 11 Jan 12 nicklas 133         <th>Description</th>
5922 11 Jan 12 nicklas 134         <td>
6217 14 Dec 12 nicklas 135           <textarea class="text" rows="6" name="description" id="description"
2356 08 Jun 06 dominic 136             ><%=HTML.encodeTags(annotationTypeCategory == null ? cc.getPropertyValue("description") : annotationTypeCategory.getDescription())%></textarea>
2356 08 Jun 06 dominic 137         </td>
5922 11 Jan 12 nicklas 138         <td style="width: 20px;">
6215 13 Dec 12 nicklas 139           <base:zoom textarea="description" title="Description" />
5922 11 Jan 12 nicklas 140         </td>
2356 08 Jun 06 dominic 141       </tr>
2356 08 Jun 06 dominic 142       </table>
2356 08 Jun 06 dominic 143     </t:tab>
2356 08 Jun 06 dominic 144     
2515 14 Aug 06 nicklas 145     <t:tab id="members" title="Annotation types" tooltip="Add/remove members of this category" 
6292 11 Jun 13 nicklas 146       helpid="annotationtypecategory.edit.members">
5922 11 Jan 12 nicklas 147       <table class="fullform input100">
5922 11 Jan 12 nicklas 148       <tr class="dynamic">
5922 11 Jan 12 nicklas 149         <th>Annotation types</th>
5922 11 Jan 12 nicklas 150         <td>
5922 11 Jan 12 nicklas 151           <div class="selectionlist">
5922 11 Jan 12 nicklas 152             <table>
5922 11 Jan 12 nicklas 153             <tr>
5922 11 Jan 12 nicklas 154               <td>
6292 11 Jun 13 nicklas 155                 <select name="annotationTypes" id="annotationTypes" 
6292 11 Jun 13 nicklas 156                   class="auto-init" data-auto-init="link-container"
6292 11 Jun 13 nicklas 157                   data-initial-items="[<%=HTML.encodeTags(jsonAnnotationTypes.toJSONString()) %>]"
6292 11 Jun 13 nicklas 158                   size="14" multiple>
5922 11 Jan 12 nicklas 159                 </select>
5922 11 Jan 12 nicklas 160               </td>
5922 11 Jan 12 nicklas 161               <td style="vertical-align: top;">
5922 11 Jan 12 nicklas 162                 <base:buttongroup vertical="true">
5922 11 Jan 12 nicklas 163                   <base:button 
6292 11 Jun 13 nicklas 164                     id="btnAddAnnotationTypes"
6292 11 Jun 13 nicklas 165                     subclass="leftaligned auto-init"
6292 11 Jun 13 nicklas 166                     data-auto-init="add-link"
6292 11 Jun 13 nicklas 167                     data-list-id="annotationTypes"
6292 11 Jun 13 nicklas 168                     data-item-type="ANNOTATIONTYPE"
5922 11 Jan 12 nicklas 169                     title="Add&nbsp;annotation&nbsp;types&hellip;" 
5922 11 Jan 12 nicklas 170                     tooltip="Add annotation types to this category"
5922 11 Jan 12 nicklas 171                   />
5922 11 Jan 12 nicklas 172                   <base:button 
6292 11 Jun 13 nicklas 173                     id="btnRemoveAnnotationTypes"
6292 11 Jun 13 nicklas 174                     subclass="leftaligned auto-init"
6292 11 Jun 13 nicklas 175                     data-auto-init="remove-link"
6292 11 Jun 13 nicklas 176                     data-list-id="annotationTypes"
5922 11 Jan 12 nicklas 177                     title="Remove" 
5922 11 Jan 12 nicklas 178                     tooltip="Remove the selected items from this category"
5922 11 Jan 12 nicklas 179                   />
5922 11 Jan 12 nicklas 180                 </base:buttongroup>
5922 11 Jan 12 nicklas 181               </td>
5922 11 Jan 12 nicklas 182             </tr>
5922 11 Jan 12 nicklas 183             </table>
5922 11 Jan 12 nicklas 184           </div>
5922 11 Jan 12 nicklas 185         </td>
5922 11 Jan 12 nicklas 186       </tr>
2356 08 Jun 06 dominic 187       </table>
2356 08 Jun 06 dominic 188     </t:tab>
2356 08 Jun 06 dominic 189     </t:tabcontrol>
5922 11 Jan 12 nicklas 190     </form>
5922 11 Jan 12 nicklas 191     
5922 11 Jan 12 nicklas 192     <div class="legend">
5946 03 Feb 12 nicklas 193       <base:icon image="required.png" />= required information
5922 11 Jan 12 nicklas 194     </div>
2356 08 Jun 06 dominic 195
5922 11 Jan 12 nicklas 196     <base:buttongroup subclass="dialogbuttons">
6292 11 Jun 13 nicklas 197       <base:button id="btnSave" title="Save" />
6292 11 Jun 13 nicklas 198       <base:button id="close" title="Cancel" />
5922 11 Jan 12 nicklas 199     </base:buttongroup>
2356 08 Jun 06 dominic 200   </base:body>
2356 08 Jun 06 dominic 201   </base:page>
2356 08 Jun 06 dominic 202   <%
2356 08 Jun 06 dominic 203 }
2356 08 Jun 06 dominic 204 finally
2356 08 Jun 06 dominic 205 {
2356 08 Jun 06 dominic 206   if (dc != null) dc.close();
2356 08 Jun 06 dominic 207 }
2356 08 Jun 06 dominic 208 %>