www/admin/platforms/variants/edit_variant.jsp

Code
Comments
Other
Rev Date Author Line
3859 18 Oct 07 nicklas 1 <%-- $Id:edit_variant.jsp 3820 2007-10-12 10:03:18Z nicklas $
3799 28 Sep 07 nicklas 2   ------------------------------------------------------------------
3799 28 Sep 07 nicklas 3   Copyright (C) 2005 Nicklas Nordborg
4889 06 Apr 09 nicklas 4   Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
3799 28 Sep 07 nicklas 5
3799 28 Sep 07 nicklas 6   This file is part of BASE - BioArray Software Environment.
3799 28 Sep 07 nicklas 7   Available at http://base.thep.lu.se/
3799 28 Sep 07 nicklas 8
3799 28 Sep 07 nicklas 9   BASE is free software; you can redistribute it and/or
3799 28 Sep 07 nicklas 10   modify it under the terms of the GNU General Public License
4476 05 Sep 08 jari 11   as published by the Free Software Foundation; either version 3
3799 28 Sep 07 nicklas 12   of the License, or (at your option) any later version.
3799 28 Sep 07 nicklas 13
3799 28 Sep 07 nicklas 14   BASE is distributed in the hope that it will be useful,
3799 28 Sep 07 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
3799 28 Sep 07 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3799 28 Sep 07 nicklas 17   GNU General Public License for more details.
3799 28 Sep 07 nicklas 18
3799 28 Sep 07 nicklas 19   You should have received a copy of the GNU General Public License
4510 11 Sep 08 jari 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
3799 28 Sep 07 nicklas 21   ------------------------------------------------------------------
3799 28 Sep 07 nicklas 22
3799 28 Sep 07 nicklas 23
3799 28 Sep 07 nicklas 24   @author Nicklas
3799 28 Sep 07 nicklas 25   @version 2.0
3799 28 Sep 07 nicklas 26 --%>
5426 24 Sep 10 nicklas 27 <%@ page pageEncoding="UTF-8" session="false"
3799 28 Sep 07 nicklas 28   import="net.sf.basedb.core.SessionControl"
3799 28 Sep 07 nicklas 29   import="net.sf.basedb.core.DbControl"
3799 28 Sep 07 nicklas 30   import="net.sf.basedb.core.Item"
3799 28 Sep 07 nicklas 31   import="net.sf.basedb.core.ItemContext"
3890 30 Oct 07 nicklas 32   import="net.sf.basedb.core.Include"
3799 28 Sep 07 nicklas 33   import="net.sf.basedb.core.Permission"
3799 28 Sep 07 nicklas 34   import="net.sf.basedb.core.Platform"
3799 28 Sep 07 nicklas 35   import="net.sf.basedb.core.PlatformVariant"
3800 28 Sep 07 nicklas 36   import="net.sf.basedb.core.PlatformFileType"
3800 28 Sep 07 nicklas 37   import="net.sf.basedb.core.DataFileType"
3799 28 Sep 07 nicklas 38   import="net.sf.basedb.core.RawDataType"
3799 28 Sep 07 nicklas 39   import="net.sf.basedb.core.RawDataTypes"
3799 28 Sep 07 nicklas 40   import="net.sf.basedb.core.PermissionDeniedException"
3800 28 Sep 07 nicklas 41   import="net.sf.basedb.core.ItemQuery"
3800 28 Sep 07 nicklas 42   import="net.sf.basedb.core.ItemResultList"
3800 28 Sep 07 nicklas 43   import="net.sf.basedb.core.query.Orders"
3800 28 Sep 07 nicklas 44   import="net.sf.basedb.core.query.Hql"
3799 28 Sep 07 nicklas 45   import="net.sf.basedb.clients.web.Base"
3799 28 Sep 07 nicklas 46   import="net.sf.basedb.clients.web.util.HTML"
3799 28 Sep 07 nicklas 47   import="net.sf.basedb.util.Values"
5508 19 Nov 10 nicklas 48   import="net.sf.basedb.core.plugin.GuiContext"
5508 19 Nov 10 nicklas 49   import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
5508 19 Nov 10 nicklas 50   import="net.sf.basedb.clients.web.extensions.JspContext"
5508 19 Nov 10 nicklas 51   import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
7604 25 Feb 19 nicklas 52   import="net.sf.basedb.clients.web.extensions.tabcontrol.TabAction"
5508 19 Nov 10 nicklas 53   import="net.sf.basedb.util.extensions.ExtensionsInvoker"
6305 09 Aug 13 nicklas 54   import="net.sf.basedb.util.json.JsonConverter"
6305 09 Aug 13 nicklas 55   import="net.sf.basedb.util.json.JsonUtil"
6305 09 Aug 13 nicklas 56   import="org.json.simple.JSONArray"
6305 09 Aug 13 nicklas 57   import="org.json.simple.JSONObject"
3799 28 Sep 07 nicklas 58 %>
3799 28 Sep 07 nicklas 59 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
3799 28 Sep 07 nicklas 60 <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
6149 25 Sep 12 nicklas 61 <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
3799 28 Sep 07 nicklas 62 <%
3799 28 Sep 07 nicklas 63 final int platformId = Values.getInt(request.getParameter("platform_id"));
3799 28 Sep 07 nicklas 64 final Item itemType = Item.PLATFORMVARIANT;
3799 28 Sep 07 nicklas 65 final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
3799 28 Sep 07 nicklas 66 final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
3859 18 Oct 07 nicklas 67 final String tabId = Values.getString(request.getParameter("tab"), null);
3799 28 Sep 07 nicklas 68 final int itemId = cc.getId();
3799 28 Sep 07 nicklas 69 final String ID = sc.getId();
3799 28 Sep 07 nicklas 70 final float scale = Base.getScale(sc);
7954 12 May 21 nicklas 71 final DbControl dc = sc.newDbControl(":Edit "+itemType);
3799 28 Sep 07 nicklas 72 try
3799 28 Sep 07 nicklas 73 {
3799 28 Sep 07 nicklas 74   String title = null;
3799 28 Sep 07 nicklas 75   Platform platform = null;
3799 28 Sep 07 nicklas 76   PlatformVariant variant = null;
3799 28 Sep 07 nicklas 77   boolean isFileOnly = false;
6305 09 Aug 13 nicklas 78   ItemQuery<PlatformFileType> fileTypesQuery = null;
3800 28 Sep 07 nicklas 79   
3799 28 Sep 07 nicklas 80   if (itemId == 0)
3799 28 Sep 07 nicklas 81   {
3799 28 Sep 07 nicklas 82     title = "Create platform variant";
3799 28 Sep 07 nicklas 83     platform = Platform.getById(dc, platformId);
3799 28 Sep 07 nicklas 84     isFileOnly = Values.getBoolean(cc.getPropertyValue("fileOnly"), platform.isFileOnly());
3799 28 Sep 07 nicklas 85     cc.removeObject("item");
3799 28 Sep 07 nicklas 86     platform.checkPermission(Permission.WRITE);
3799 28 Sep 07 nicklas 87   }
3799 28 Sep 07 nicklas 88   else
3799 28 Sep 07 nicklas 89   {
3799 28 Sep 07 nicklas 90     variant = PlatformVariant.getById(dc, itemId);
6305 09 Aug 13 nicklas 91     variant.checkPermission(Permission.WRITE);
3799 28 Sep 07 nicklas 92     platform = variant.getPlatform();
3799 28 Sep 07 nicklas 93     isFileOnly = variant.isFileOnly();
3799 28 Sep 07 nicklas 94     cc.setObject("item", variant);
3799 28 Sep 07 nicklas 95     title = "Edit platform variant -- " + HTML.encodeTags(variant.getName());
6305 09 Aug 13 nicklas 96     fileTypesQuery = platform.getFileTypes(variant, true);
6305 09 Aug 13 nicklas 97     fileTypesQuery.include(Include.ALL);
6305 09 Aug 13 nicklas 98     fileTypesQuery.order(Orders.asc(Hql.property("dataFileType.name")));
3799 28 Sep 07 nicklas 99   }
3799 28 Sep 07 nicklas 100   
6305 09 Aug 13 nicklas 101   JSONObject jsonFileTypes = new JSONObject();
6305 09 Aug 13 nicklas 102   jsonFileTypes.put("itemType", "DATAFILETYPE");
6305 09 Aug 13 nicklas 103   if (fileTypesQuery != null)
6305 09 Aug 13 nicklas 104   {
6305 09 Aug 13 nicklas 105     jsonFileTypes.put("items", JsonUtil.toArray(fileTypesQuery.iterate(dc), new JsonConverter<PlatformFileType>() 
6305 09 Aug 13 nicklas 106     {
6305 09 Aug 13 nicklas 107       public Object convert(PlatformFileType ft)
6305 09 Aug 13 nicklas 108       {
6305 09 Aug 13 nicklas 109         JSONObject json = new JSONObject();
6305 09 Aug 13 nicklas 110         DataFileType dft = ft.getDataFileType();
6305 09 Aug 13 nicklas 111         boolean required = ft.isRequired();
6305 09 Aug 13 nicklas 112         boolean multiple = ft.getAllowMultiple();
6305 09 Aug 13 nicklas 113         int value = 0;
6305 09 Aug 13 nicklas 114         if (required) value += 1;
6305 09 Aug 13 nicklas 115         if (multiple) value += 2;
6305 09 Aug 13 nicklas 116         json.put("id", dft.getId());
6305 09 Aug 13 nicklas 117         json.put("name", dft.getName() + (required ? " [×]" : " [-]"));
6305 09 Aug 13 nicklas 118         json.put("value", value);
6305 09 Aug 13 nicklas 119         return json;
6305 09 Aug 13 nicklas 120       }
6305 09 Aug 13 nicklas 121     }));
6305 09 Aug 13 nicklas 122   }
6305 09 Aug 13 nicklas 123
5508 19 Nov 10 nicklas 124   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), variant);
7604 25 Feb 19 nicklas 125   ExtensionsInvoker<TabAction> invoker = EditUtil.useEditExtensions(jspContext);
3799 28 Sep 07 nicklas 126   %>
6305 09 Aug 13 nicklas 127   <base:page type="popup" title="<%=title%>" id="edit-page">
6305 09 Aug 13 nicklas 128   <base:head scripts="tabcontrol-2.js,linkitems-2.js,~variants.js" styles="tabcontrol.css">
5508 19 Nov 10 nicklas 129     <ext:scripts context="<%=jspContext%>" />
5508 19 Nov 10 nicklas 130     <ext:stylesheets context="<%=jspContext%>" />
3799 28 Sep 07 nicklas 131   </base:head>
6305 09 Aug 13 nicklas 132   <base:body>
5922 11 Jan 12 nicklas 133     <h1><%=title%> <base:help tabcontrol="settings" /></h1>
6162 10 Oct 12 nicklas 134     <form action="index.jsp?ID=<%=ID%>" method="post" name="variant">
3799 28 Sep 07 nicklas 135     <input type="hidden" name="cmd" value="UpdateItem">
3799 28 Sep 07 nicklas 136     <input type="hidden" name="platform_id" value="<%=platformId%>">
3799 28 Sep 07 nicklas 137
5922 11 Jan 12 nicklas 138     <t:tabcontrol id="settings"
5922 11 Jan 12 nicklas 139       subclass="content dialogtabcontrol"
5508 19 Nov 10 nicklas 140       position="bottom" active="<%=tabId%>" remember="<%=tabId == null && variant != null%>"
5508 19 Nov 10 nicklas 141       extensions="<%=invoker%>">
6305 09 Aug 13 nicklas 142     <t:tab id="info" title="Variant" helpid="platformvariant.edit">
5922 11 Jan 12 nicklas 143       <table class="fullform input100 smaller">
3799 28 Sep 07 nicklas 144       <tr>
5922 11 Jan 12 nicklas 145         <th>Name</th>
6305 09 Aug 13 nicklas 146         <td><input class="text required auto-init" data-auto-init="<%=variant == null ? "focus-select" : "focus" %>" 
6305 09 Aug 13 nicklas 147           type="text" name="name" 
3799 28 Sep 07 nicklas 148           value="<%=HTML.encodeTags(variant == null ? 
3799 28 Sep 07 nicklas 149               Values.getString(cc.getPropertyValue("name"), "New " + platform.getName() + " variant") : 
3799 28 Sep 07 nicklas 150               variant.getName())%>" 
5922 11 Jan 12 nicklas 151           maxlength="<%=PlatformVariant.MAX_NAME_LENGTH%>"></td>
5922 11 Jan 12 nicklas 152         <td></td>
3799 28 Sep 07 nicklas 153       </tr>
3799 28 Sep 07 nicklas 154       <%
3799 28 Sep 07 nicklas 155       if (variant == null)
3799 28 Sep 07 nicklas 156       {
3799 28 Sep 07 nicklas 157         // For new platforms only
3799 28 Sep 07 nicklas 158         RawDataType currentRawDataType = 
3799 28 Sep 07 nicklas 159           RawDataTypes.getRawDataType(cc.getPropertyValue("rawDataType"));
3799 28 Sep 07 nicklas 160         if (currentRawDataType == null)
3799 28 Sep 07 nicklas 161         {
3799 28 Sep 07 nicklas 162           currentRawDataType = platform.getRawDataType();
3799 28 Sep 07 nicklas 163         }
3799 28 Sep 07 nicklas 164         %>
3799 28 Sep 07 nicklas 165         <tr>
5922 11 Jan 12 nicklas 166           <th>External ID</th>
6217 14 Dec 12 nicklas 167           <td><input class="text required unchangeable" type="text" name="externalId" 
3799 28 Sep 07 nicklas 168             value="<%=HTML.encodeTags(Values.getString(cc.getPropertyValue("externalId"), platform.getExternalId() + ".new"))%>" 
5922 11 Jan 12 nicklas 169             maxlength="<%=PlatformVariant.MAX_EXTERNAL_ID_LENGTH%>"></td>
5922 11 Jan 12 nicklas 170           <td></td>
3799 28 Sep 07 nicklas 171         </tr>
3799 28 Sep 07 nicklas 172         <tr>
5922 11 Jan 12 nicklas 173           <th>File-only</th>
3799 28 Sep 07 nicklas 174           <td>
6217 14 Dec 12 nicklas 175             <input class="unchangeable" type="radio" name="fileOnly" id="fileOnlyNo" value="0" 
6305 09 Aug 13 nicklas 176               <%=!isFileOnly ? "checked" : ""%>><label for="fileOnlyNo">no</label>
6217 14 Dec 12 nicklas 177             <input class="unchangeable" type="radio" name="fileOnly" id="fileOnlyYes" value="1" 
6305 09 Aug 13 nicklas 178               <%=isFileOnly ? "checked" : ""%>><label for="fileOnlyYes">yes</label>
3799 28 Sep 07 nicklas 179           </td>
5922 11 Jan 12 nicklas 180           <td></td>
3799 28 Sep 07 nicklas 181         </tr>
3799 28 Sep 07 nicklas 182         <tr>
5922 11 Jan 12 nicklas 183           <th>Raw data type</th>
3799 28 Sep 07 nicklas 184           <td>
6217 14 Dec 12 nicklas 185             <select name="rawdatatype" class="required unchangeable">
3799 28 Sep 07 nicklas 186             <option value="">- any -
3799 28 Sep 07 nicklas 187             <%
5574 18 Feb 11 nicklas 188             for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator()))
3799 28 Sep 07 nicklas 189             {
3867 19 Oct 07 nicklas 190               if (rdt.isStoredInDb())
3867 19 Oct 07 nicklas 191               {
3867 19 Oct 07 nicklas 192                 String selected = rdt.equals(currentRawDataType) ? "selected" : "";
3867 19 Oct 07 nicklas 193                 %>
3867 19 Oct 07 nicklas 194                 <option value="<%=rdt.getId()%>" <%=selected%>><%=HTML.encodeTags(rdt.getName())%>
3867 19 Oct 07 nicklas 195                 <%
3867 19 Oct 07 nicklas 196               }
3799 28 Sep 07 nicklas 197             }
3799 28 Sep 07 nicklas 198             %>
3799 28 Sep 07 nicklas 199             </select>
3799 28 Sep 07 nicklas 200           </td>
5922 11 Jan 12 nicklas 201           <td></td>
3799 28 Sep 07 nicklas 202         </tr>
3799 28 Sep 07 nicklas 203         <tr>
5922 11 Jan 12 nicklas 204           <th>Channels</th>
6305 09 Aug 13 nicklas 205           <td><input class="text required unchangeable" type="text" name="channels" id="channels"
3799 28 Sep 07 nicklas 206             value="<%=Values.getInt(cc.getPropertyValue("channels"), currentRawDataType == null ? 1 : currentRawDataType.getChannels())%>" 
6305 09 Aug 13 nicklas 207             maxlength="10" style="width: 15em;"></td>
5922 11 Jan 12 nicklas 208           <td></td>
3799 28 Sep 07 nicklas 209         </tr>
3799 28 Sep 07 nicklas 210         <%
3799 28 Sep 07 nicklas 211       }
3799 28 Sep 07 nicklas 212       %>
5922 11 Jan 12 nicklas 213       <tr class="dynamic">
5922 11 Jan 12 nicklas 214         <th>Description</th>
5922 11 Jan 12 nicklas 215         <td>
6217 14 Dec 12 nicklas 216           <textarea class="text" rows="6" name="description" id="description"
3799 28 Sep 07 nicklas 217             ><%=HTML.encodeTags(variant == null ? cc.getPropertyValue("description") : variant.getDescription())%></textarea>
3799 28 Sep 07 nicklas 218         </td>
5922 11 Jan 12 nicklas 219         <td style="width: 20px;">
6215 13 Dec 12 nicklas 220           <base:zoom textarea="description" title="Description" />
5922 11 Jan 12 nicklas 221         </td>
3799 28 Sep 07 nicklas 222       </tr>
3799 28 Sep 07 nicklas 223       </table>
3799 28 Sep 07 nicklas 224     </t:tab>
3800 28 Sep 07 nicklas 225     <t:tab id="fileTypes" title="Data file types"
3800 28 Sep 07 nicklas 226       tooltip="Associate this platform variant with date file types"
3800 28 Sep 07 nicklas 227       helpid="platformvariant.edit.filetypes"
3800 28 Sep 07 nicklas 228       >
5922 11 Jan 12 nicklas 229       <table class="fullform input100 smaller">
5922 11 Jan 12 nicklas 230       <tr class="dynamic">
5922 11 Jan 12 nicklas 231         <th>Data file types</th>
5922 11 Jan 12 nicklas 232         <td>
5922 11 Jan 12 nicklas 233           <div class="selectionlist">
5922 11 Jan 12 nicklas 234             <table>
5922 11 Jan 12 nicklas 235             <tr>
5922 11 Jan 12 nicklas 236               <td>
6305 09 Aug 13 nicklas 237                 <select name="fileTypes" id="fileTypes" 
6305 09 Aug 13 nicklas 238                   class="auto-init"
6305 09 Aug 13 nicklas 239                   data-auto-init="link-container"
6305 09 Aug 13 nicklas 240                   data-initial-items="[<%=HTML.encodeTags(jsonFileTypes.toJSONString()) %>]"
6305 09 Aug 13 nicklas 241                   size="15" multiple>
5922 11 Jan 12 nicklas 242                 </select>
5922 11 Jan 12 nicklas 243               </td>
5922 11 Jan 12 nicklas 244               <td style="vertical-align: top;">
5922 11 Jan 12 nicklas 245                 <base:buttongroup vertical="true">
5922 11 Jan 12 nicklas 246                   <base:button 
6305 09 Aug 13 nicklas 247                     id="btnAddFileTypes"
5922 11 Jan 12 nicklas 248                     subclass="leftaligned"
5922 11 Jan 12 nicklas 249                     style="width: 14em;"
5922 11 Jan 12 nicklas 250                     title="Add&nbsp;data file types&hellip;" 
5922 11 Jan 12 nicklas 251                     tooltip="Add more data file types to this platform"
5922 11 Jan 12 nicklas 252                   />
5922 11 Jan 12 nicklas 253                   <base:button 
6305 09 Aug 13 nicklas 254                     subclass="leftaligned auto-init"
6305 09 Aug 13 nicklas 255                     data-auto-init="remove-link"
6305 09 Aug 13 nicklas 256                     data-list-id="fileTypes"
5922 11 Jan 12 nicklas 257                     style="width: 14em;"
5922 11 Jan 12 nicklas 258                     title="Remove" 
5922 11 Jan 12 nicklas 259                     tooltip="Remove the selected data file types"
5922 11 Jan 12 nicklas 260                   />
5922 11 Jan 12 nicklas 261                 </base:buttongroup>
6305 09 Aug 13 nicklas 262                 <input type="checkbox" id="required" name="required" value="1">
5922 11 Jan 12 nicklas 263                   <label for="required">Required</label><br>
6305 09 Aug 13 nicklas 264                 <input type="checkbox" id="multiple" name="multiple" value="1">
5922 11 Jan 12 nicklas 265                   <label for="multiple">Allow multiple files</label>
5922 11 Jan 12 nicklas 266               </td>
5922 11 Jan 12 nicklas 267             </tr>
5922 11 Jan 12 nicklas 268             </table>
5922 11 Jan 12 nicklas 269           </div>
5922 11 Jan 12 nicklas 270         </td>
5922 11 Jan 12 nicklas 271       </tr>
3800 28 Sep 07 nicklas 272       </table>
3800 28 Sep 07 nicklas 273     </t:tab>    
3799 28 Sep 07 nicklas 274     </t:tabcontrol>
5922 11 Jan 12 nicklas 275     </form>
5922 11 Jan 12 nicklas 276     
5922 11 Jan 12 nicklas 277     <div class="legend">
5946 03 Feb 12 nicklas 278       <base:icon image="required.png" />= required information
5922 11 Jan 12 nicklas 279       <%if (variant == null) {%><br>
5967 16 Feb 12 nicklas 280         <base:icon image="unchangeable.png" />= can't be changed later
5922 11 Jan 12 nicklas 281       <%}%>
5922 11 Jan 12 nicklas 282     </div>
3799 28 Sep 07 nicklas 283
5922 11 Jan 12 nicklas 284     <base:buttongroup subclass="dialogbuttons">
6305 09 Aug 13 nicklas 285       <base:button id="btnSave" title="Save" />
6305 09 Aug 13 nicklas 286       <base:button id="close" title="Cancel" />
5922 11 Jan 12 nicklas 287     </base:buttongroup>
3799 28 Sep 07 nicklas 288   </base:body>
3799 28 Sep 07 nicklas 289   </base:page>
3799 28 Sep 07 nicklas 290   <%
3799 28 Sep 07 nicklas 291 }
3799 28 Sep 07 nicklas 292 finally
3799 28 Sep 07 nicklas 293 {
3799 28 Sep 07 nicklas 294   if (dc != null) dc.close();
3799 28 Sep 07 nicklas 295 }
3799 28 Sep 07 nicklas 296 %>