www/biomaterials/tags/index.jsp

Code
Comments
Other
Rev Date Author Line
838 28 Jun 05 nicklas 1 <%-- $Id$
838 28 Jun 05 nicklas 2   ------------------------------------------------------------------
3675 16 Aug 07 jari 3   Copyright (C) 2005 Nicklas Nordborg
5425 23 Sep 10 nicklas 4   Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
838 28 Jun 05 nicklas 5
2304 22 May 06 jari 6   This file is part of BASE - BioArray Software Environment.
2304 22 May 06 jari 7   Available at http://base.thep.lu.se/
838 28 Jun 05 nicklas 8
838 28 Jun 05 nicklas 9   BASE is free software; you can redistribute it and/or
838 28 Jun 05 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
838 28 Jun 05 nicklas 12   of the License, or (at your option) any later version.
838 28 Jun 05 nicklas 13
838 28 Jun 05 nicklas 14   BASE is distributed in the hope that it will be useful,
838 28 Jun 05 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
838 28 Jun 05 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
838 28 Jun 05 nicklas 17   GNU General Public License for more details.
838 28 Jun 05 nicklas 18
838 28 Jun 05 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/>.
838 28 Jun 05 nicklas 21   ------------------------------------------------------------------
838 28 Jun 05 nicklas 22
838 28 Jun 05 nicklas 23   @author Nicklas
838 28 Jun 05 nicklas 24   @version 2.0
838 28 Jun 05 nicklas 25 --%>
5426 24 Sep 10 nicklas 26 <%@ page pageEncoding="UTF-8" session="false"
838 28 Jun 05 nicklas 27   import="net.sf.basedb.core.SessionControl"
838 28 Jun 05 nicklas 28   import="net.sf.basedb.core.DbControl"
838 28 Jun 05 nicklas 29   import="net.sf.basedb.core.Item"
1864 30 Jan 06 nicklas 30   import="net.sf.basedb.core.Include"
5632 17 May 11 nicklas 31   import="net.sf.basedb.core.Tag"
5632 17 May 11 nicklas 32   import="net.sf.basedb.core.ItemSubtype"
1418 07 Oct 05 nicklas 33   import="net.sf.basedb.core.ItemQuery"
838 28 Jun 05 nicklas 34   import="net.sf.basedb.core.Permission"
1864 30 Jan 06 nicklas 35   import="net.sf.basedb.core.ItemContext"
1864 30 Jan 06 nicklas 36   import="net.sf.basedb.core.ItemQuery"
1864 30 Jan 06 nicklas 37   import="net.sf.basedb.core.MultiPermissions"
4587 15 Oct 08 martin 38   import="net.sf.basedb.core.OwnedItem"
1864 30 Jan 06 nicklas 39   import="net.sf.basedb.core.PermissionDeniedException"
1864 30 Jan 06 nicklas 40   import="net.sf.basedb.core.ItemAlreadyExistsException"
1864 30 Jan 06 nicklas 41   import="net.sf.basedb.util.RemovableUtil"
1864 30 Jan 06 nicklas 42   import="net.sf.basedb.util.ShareableUtil"
2917 15 Nov 06 nicklas 43   import="net.sf.basedb.util.OwnableUtil"
838 28 Jun 05 nicklas 44   import="net.sf.basedb.clients.web.Base"
1864 30 Jan 06 nicklas 45   import="net.sf.basedb.clients.web.WebException"
2753 20 Oct 06 nicklas 46   import="net.sf.basedb.util.Values"
838 28 Jun 05 nicklas 47   import="net.sf.basedb.clients.web.util.HTML"
5492 16 Nov 10 nicklas 48   import="net.sf.basedb.core.plugin.GuiContext"
5492 16 Nov 10 nicklas 49   import="net.sf.basedb.util.extensions.ExtensionsInvoker"
5492 16 Nov 10 nicklas 50   import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
5492 16 Nov 10 nicklas 51   import="net.sf.basedb.clients.web.extensions.JspContext"
5492 16 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.edit.OnSaveAction"
5492 16 Nov 10 nicklas 54   import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer"
6038 29 Mar 12 nicklas 55   import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer"
7604 25 Feb 19 nicklas 56   import="net.sf.basedb.clients.web.extensions.list.ListColumnAction"
6038 29 Mar 12 nicklas 57   import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
1864 30 Jan 06 nicklas 58   import="java.util.Enumeration"
1864 30 Jan 06 nicklas 59   import="java.util.Set"
1864 30 Jan 06 nicklas 60   import="java.util.HashSet"
1864 30 Jan 06 nicklas 61   import="java.util.List"
1864 30 Jan 06 nicklas 62   import="java.util.ArrayList"
1864 30 Jan 06 nicklas 63   import="java.util.Collections"
838 28 Jun 05 nicklas 64 %>
838 28 Jun 05 nicklas 65 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
838 28 Jun 05 nicklas 66 <%!
5632 17 May 11 nicklas 67   private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,itemSubtype,description");
5632 17 May 11 nicklas 68   private static final Item itemType = Item.TAG;
838 28 Jun 05 nicklas 69 %>
838 28 Jun 05 nicklas 70 <%
1864 30 Jan 06 nicklas 71 final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
838 28 Jun 05 nicklas 72 final String ID = sc.getId();
1864 30 Jan 06 nicklas 73 final String cmd = request.getParameter("cmd");
1864 30 Jan 06 nicklas 74 final String root = request.getContextPath()+"/";
1864 30 Jan 06 nicklas 75 final String mode = request.getParameter("mode");
1864 30 Jan 06 nicklas 76 final String callback = request.getParameter("callback");
1864 30 Jan 06 nicklas 77 final String itemId = request.getParameter("item_id");
5632 17 May 11 nicklas 78 final String listPage = "list_tags.jsp?ID="+ID
1864 30 Jan 06 nicklas 79   +(mode == null ? "" : "&mode="+mode)
1864 30 Jan 06 nicklas 80   +(callback == null ? "" : "&callback="+callback)
1864 30 Jan 06 nicklas 81   +(itemId == null ? "" : "&item_id="+itemId);
5632 17 May 11 nicklas 82 final String viewPage = "view_tag.jsp?ID="+ID;
5632 17 May 11 nicklas 83 final String editPage = "edit_tag.jsp?ID="+ID;
838 28 Jun 05 nicklas 84
1864 30 Jan 06 nicklas 85 String forward = null;
1864 30 Jan 06 nicklas 86 String redirect = null;
1864 30 Jan 06 nicklas 87 String message = null;
1864 30 Jan 06 nicklas 88 DbControl dc = null;
1864 30 Jan 06 nicklas 89
838 28 Jun 05 nicklas 90 try
838 28 Jun 05 nicklas 91 {
1864 30 Jan 06 nicklas 92   if (cmd == null || "List".equals(cmd))
1864 30 Jan 06 nicklas 93   {
1864 30 Jan 06 nicklas 94     // Display the list page without updatinging the current context
2811 26 Oct 06 nicklas 95     Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true);
1864 30 Jan 06 nicklas 96     redirect = listPage;
1864 30 Jan 06 nicklas 97   }
1864 30 Jan 06 nicklas 98   else if ("UpdateContext".equals(cmd))
1864 30 Jan 06 nicklas 99   {
1864 30 Jan 06 nicklas 100     // Display the list page after updating the current context from the request parameters
1864 30 Jan 06 nicklas 101     Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
1864 30 Jan 06 nicklas 102     redirect = listPage;
1864 30 Jan 06 nicklas 103   }
1864 30 Jan 06 nicklas 104   else if ("LoadContext".equals(cmd))
1864 30 Jan 06 nicklas 105   {
1864 30 Jan 06 nicklas 106     // Display the list page after loading a saved context
1864 30 Jan 06 nicklas 107     int contextId = Values.getInt(request.getParameter("context"));
1864 30 Jan 06 nicklas 108     Base.loadContext(sc, contextId, defaultContext);
1864 30 Jan 06 nicklas 109     redirect = listPage;
1864 30 Jan 06 nicklas 110   }
1864 30 Jan 06 nicklas 111
1864 30 Jan 06 nicklas 112   else if ("ViewItem".equals(cmd))
1864 30 Jan 06 nicklas 113   {
1864 30 Jan 06 nicklas 114     // Display the view page for a single item 
1864 30 Jan 06 nicklas 115     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
1864 30 Jan 06 nicklas 116     forward = viewPage;
1864 30 Jan 06 nicklas 117   }
1864 30 Jan 06 nicklas 118   else if ("EditItem".equals(cmd))
1864 30 Jan 06 nicklas 119   {
1864 30 Jan 06 nicklas 120     // Display the edit page for a single item (should be opened in a popup)
1864 30 Jan 06 nicklas 121     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
1864 30 Jan 06 nicklas 122     redirect = editPage;
1864 30 Jan 06 nicklas 123   }
1864 30 Jan 06 nicklas 124   else if ("NewItem".equals(cmd))
1864 30 Jan 06 nicklas 125   {
1864 30 Jan 06 nicklas 126     // Display the edit page for a new item (should be opened in a popup)
1864 30 Jan 06 nicklas 127     if (!sc.hasPermission(Permission.CREATE, itemType))
838 28 Jun 05 nicklas 128     {
1864 30 Jan 06 nicklas 129       throw new PermissionDeniedException(Permission.CREATE, itemType.toString());
838 28 Jun 05 nicklas 130     }
1864 30 Jan 06 nicklas 131     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
1864 30 Jan 06 nicklas 132     cc.setId(0);
1864 30 Jan 06 nicklas 133     redirect = editPage;
1864 30 Jan 06 nicklas 134   }
1864 30 Jan 06 nicklas 135   else if ("UpdateItem".equals(cmd))
1864 30 Jan 06 nicklas 136   {
1864 30 Jan 06 nicklas 137     // Update the properties on an item (will close the popup)
1864 30 Jan 06 nicklas 138     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext);
5632 17 May 11 nicklas 139     final int maxRecent = Base.getMaxRecent(sc);
7954 12 May 21 nicklas 140     dc = sc.newDbControl(":Edit "+itemType);
7605 26 Feb 19 nicklas 141     Tag tag = cc.getObject("item");
5632 17 May 11 nicklas 142     if (tag == null)
838 28 Jun 05 nicklas 143     {
5632 17 May 11 nicklas 144       tag = Tag.getNew(dc);
5632 17 May 11 nicklas 145       message = "Tag created";
5632 17 May 11 nicklas 146       dc.saveItem(tag);
838 28 Jun 05 nicklas 147     }
1864 30 Jan 06 nicklas 148     else
838 28 Jun 05 nicklas 149     {
5632 17 May 11 nicklas 150       dc.reattachItem(tag, false);
5632 17 May 11 nicklas 151       message = "Tag updated";
838 28 Jun 05 nicklas 152     }
5632 17 May 11 nicklas 153     JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), tag);
7604 25 Feb 19 nicklas 154     ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext);
5492 16 Nov 10 nicklas 155     try
5492 16 Nov 10 nicklas 156     {
5632 17 May 11 nicklas 157       tag.setName(Values.getStringOrNull(request.getParameter("name")));
5632 17 May 11 nicklas 158       tag.setDescription(Values.getStringOrNull(request.getParameter("description")));
5632 17 May 11 nicklas 159       int tagTypeId = Values.getInt(request.getParameter("tagtype_id"), -1);
5632 17 May 11 nicklas 160       if (tagTypeId >= 0) // < 0 = denied or unchanged
5632 17 May 11 nicklas 161       {
5632 17 May 11 nicklas 162         ItemSubtype subtype = tagTypeId == 0 ? null : ItemSubtype.getById(dc, tagTypeId);
5632 17 May 11 nicklas 163         tag.setItemSubtype(subtype);
7703 11 Apr 19 nicklas 164         cc.setRecent(Item.ITEMSUBTYPE, subtype, maxRecent);
5632 17 May 11 nicklas 165       }
1864 30 Jan 06 nicklas 166
6335 21 Oct 13 olle 167       Base.updateAnnotations(dc, tag, tag, request);
5492 16 Nov 10 nicklas 168       // OnSave extensions
5492 16 Nov 10 nicklas 169       invoker.render(OnSaveRenderer.ON_SAVE);
5492 16 Nov 10 nicklas 170       dc.commit();
5492 16 Nov 10 nicklas 171       invoker.render(OnSaveRenderer.ON_COMMIT);
5492 16 Nov 10 nicklas 172     }
5492 16 Nov 10 nicklas 173     catch (Exception ex)
5492 16 Nov 10 nicklas 174     {
5492 16 Nov 10 nicklas 175       invoker.render(OnSaveRenderer.onRollback(ex));
5492 16 Nov 10 nicklas 176       throw ex;
5492 16 Nov 10 nicklas 177     }
5492 16 Nov 10 nicklas 178     finally
5492 16 Nov 10 nicklas 179     {
5492 16 Nov 10 nicklas 180       cc.removeObject("item");
5492 16 Nov 10 nicklas 181     }
1864 30 Jan 06 nicklas 182   }
1864 30 Jan 06 nicklas 183   else if ("DeleteItem".equals(cmd))
1864 30 Jan 06 nicklas 184   {
1864 30 Jan 06 nicklas 185     // Delete a single item and then return to the view page
7954 12 May 21 nicklas 186     dc = sc.newDbControl(":Delete "+itemType);
1864 30 Jan 06 nicklas 187     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
1864 30 Jan 06 nicklas 188     RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true);
1864 30 Jan 06 nicklas 189     dc.commit();
1864 30 Jan 06 nicklas 190     redirect = viewPage;
1864 30 Jan 06 nicklas 191   }
1864 30 Jan 06 nicklas 192   else if ("DeleteItems".equals(cmd))
1864 30 Jan 06 nicklas 193   {
1864 30 Jan 06 nicklas 194     // Delete all selected items on the list page
7954 12 May 21 nicklas 195     dc = sc.newDbControl(":Delete "+itemType);
1864 30 Jan 06 nicklas 196     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
1864 30 Jan 06 nicklas 197     int numTotal = cc.getSelected().size();
1864 30 Jan 06 nicklas 198     int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true);
1864 30 Jan 06 nicklas 199     dc.commit();
1864 30 Jan 06 nicklas 200     if (numTotal != numRemoved)
838 28 Jun 05 nicklas 201     {
1864 30 Jan 06 nicklas 202       message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission";
838 28 Jun 05 nicklas 203     }
6335 21 Oct 13 olle 204     redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
1864 30 Jan 06 nicklas 205   }
1864 30 Jan 06 nicklas 206   else if ("RestoreItem".equals(cmd))
1864 30 Jan 06 nicklas 207   {
1864 30 Jan 06 nicklas 208     // Restore a single item and then return to the view page
7954 12 May 21 nicklas 209     dc = sc.newDbControl(":Restore "+itemType);
1864 30 Jan 06 nicklas 210     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
1864 30 Jan 06 nicklas 211     RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false);
1864 30 Jan 06 nicklas 212     dc.commit();
1864 30 Jan 06 nicklas 213     redirect = viewPage;
1864 30 Jan 06 nicklas 214   }
1864 30 Jan 06 nicklas 215   else if ("RestoreItems".equals(cmd))
1864 30 Jan 06 nicklas 216   {
1864 30 Jan 06 nicklas 217     // Restore all selected items on the list page
7954 12 May 21 nicklas 218     dc = sc.newDbControl(":Restore "+itemType);
1864 30 Jan 06 nicklas 219     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
1864 30 Jan 06 nicklas 220     int numTotal = cc.getSelected().size();
1864 30 Jan 06 nicklas 221     int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false);
1864 30 Jan 06 nicklas 222     dc.commit();
1864 30 Jan 06 nicklas 223     if (numTotal != numRemoved)
838 28 Jun 05 nicklas 224     {
2528 15 Aug 06 martin 225       message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission";
838 28 Jun 05 nicklas 226     }
6335 21 Oct 13 olle 227     redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
1864 30 Jan 06 nicklas 228   }
1864 30 Jan 06 nicklas 229   else if ("ShareItem".equals(cmd))
1864 30 Jan 06 nicklas 230   {
1864 30 Jan 06 nicklas 231     // Display a popup window for sharing a single item
7954 12 May 21 nicklas 232     dc = sc.newDbControl(":Share "+itemType);
1864 30 Jan 06 nicklas 233     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
1864 30 Jan 06 nicklas 234     MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId()));
1864 30 Jan 06 nicklas 235     dc.close();
1864 30 Jan 06 nicklas 236     cc.setObject("MultiPermissions", permissions);
1864 30 Jan 06 nicklas 237     redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
1864 30 Jan 06 nicklas 238   }
1864 30 Jan 06 nicklas 239   else if ("ShareItems".equals(cmd))
1864 30 Jan 06 nicklas 240   {
1864 30 Jan 06 nicklas 241     // Display a popup window for sharing all selected items on the list page
7954 12 May 21 nicklas 242     dc = sc.newDbControl(":Share "+itemType);
1864 30 Jan 06 nicklas 243     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
1864 30 Jan 06 nicklas 244     MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected());
1864 30 Jan 06 nicklas 245     dc.close();
1864 30 Jan 06 nicklas 246     cc.setObject("MultiPermissions", permissions);
1864 30 Jan 06 nicklas 247     redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
1864 30 Jan 06 nicklas 248   }
4578 13 Oct 08 martin 249   else if ("SetOwnerOfItem".equals(cmd))
2917 15 Nov 06 nicklas 250   {
4578 13 Oct 08 martin 251     // Change owner of items selected on a list page
7954 12 May 21 nicklas 252     dc = sc.newDbControl(":Set owner of "+itemType);
2917 15 Nov 06 nicklas 253     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
4587 15 Oct 08 martin 254     OwnedItem item = (OwnedItem)itemType.getById(dc, cc.getId());
4587 15 Oct 08 martin 255     cc.setObject("OwnedItems", Collections.singleton(item));
4578 13 Oct 08 martin 256     redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name();
2917 15 Nov 06 nicklas 257   }
4578 13 Oct 08 martin 258   else if ("SetOwnerOfItems".equals(cmd))
2917 15 Nov 06 nicklas 259   {
4578 13 Oct 08 martin 260     // Change owner of items selected on a list page
7954 12 May 21 nicklas 261     dc = sc.newDbControl(":Set owner of "+itemType);
2917 15 Nov 06 nicklas 262     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
4587 15 Oct 08 martin 263     Set<OwnedItem> items = new HashSet<OwnedItem>();
4587 15 Oct 08 martin 264     for (Integer id : cc.getSelected())
4587 15 Oct 08 martin 265     {
4587 15 Oct 08 martin 266       if (id != null) items.add((OwnedItem)itemType.getById(dc, id));
4587 15 Oct 08 martin 267     }
4587 15 Oct 08 martin 268     dc.close();
4587 15 Oct 08 martin 269     cc.setObject("OwnedItems", items);
4578 13 Oct 08 martin 270     redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name();
2917 15 Nov 06 nicklas 271   }
1864 30 Jan 06 nicklas 272   else if ("ExportItems".equals(cmd))
1864 30 Jan 06 nicklas 273   {
1864 30 Jan 06 nicklas 274     // Run an export plugin in a list context
1864 30 Jan 06 nicklas 275     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
5632 17 May 11 nicklas 276     final ItemQuery<Tag> query = Tag.getQuery();
7954 12 May 21 nicklas 277     dc = sc.newDbControl(":Export "+itemType);
7914 23 Feb 21 nicklas 278     JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null);
7914 23 Feb 21 nicklas 279     cc.configureQuery(dc, query, jspContext, true);
6038 29 Mar 12 nicklas 280     cc.setQuery(query);
7604 25 Feb 19 nicklas 281     ExtensionsInvoker<ListColumnAction<Tag,?>> listInvoker = ListColumnUtil.useExtensions(jspContext);
7604 25 Feb 19 nicklas 282     listInvoker.render(new ListColumnExportRenderer<Tag>(cc));
5590 16 Mar 11 nicklas 283     dc.close();
5632 17 May 11 nicklas 284     redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+tags";
1864 30 Jan 06 nicklas 285   }
1864 30 Jan 06 nicklas 286   else if ("ExportItem".equals(cmd))
1864 30 Jan 06 nicklas 287   {
1864 30 Jan 06 nicklas 288     // Run an export plugin in single-item context
1864 30 Jan 06 nicklas 289     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
5632 17 May 11 nicklas 290     redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+tag";
1864 30 Jan 06 nicklas 291   }
1864 30 Jan 06 nicklas 292   else if ("ImportItems".equals(cmd))
1864 30 Jan 06 nicklas 293   {
1864 30 Jan 06 nicklas 294     // Run an import plugin in a list context
1864 30 Jan 06 nicklas 295     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
5632 17 May 11 nicklas 296     final ItemQuery<Tag> query = Tag.getQuery();
7954 12 May 21 nicklas 297     dc = sc.newDbControl(":Import "+itemType);
7914 23 Feb 21 nicklas 298     JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null);
7914 23 Feb 21 nicklas 299     cc.configureQuery(dc, query, jspContext, true);
5590 16 Mar 11 nicklas 300     dc.close();
1864 30 Jan 06 nicklas 301     cc.setQuery(query);
5632 17 May 11 nicklas 302     redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+tags";
1864 30 Jan 06 nicklas 303   }
1864 30 Jan 06 nicklas 304   else if ("ImportItem".equals(cmd))
1864 30 Jan 06 nicklas 305   {
1864 30 Jan 06 nicklas 306     // Run an import plugin in single-item context
1864 30 Jan 06 nicklas 307     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
5632 17 May 11 nicklas 308     redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+tag";
1864 30 Jan 06 nicklas 309   }
1864 30 Jan 06 nicklas 310   else if ("RunListPlugin".equals(cmd))
1864 30 Jan 06 nicklas 311   {
1864 30 Jan 06 nicklas 312     // Run another plugin in a list context
1864 30 Jan 06 nicklas 313     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
5632 17 May 11 nicklas 314     final ItemQuery<Tag> query = Tag.getQuery();
7954 12 May 21 nicklas 315     dc = sc.newDbControl(":Run plugin "+itemType);
7914 23 Feb 21 nicklas 316     JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null);
7914 23 Feb 21 nicklas 317     cc.configureQuery(dc, query, jspContext, true);
5590 16 Mar 11 nicklas 318     dc.close();
1864 30 Jan 06 nicklas 319     cc.setQuery(query);
1864 30 Jan 06 nicklas 320     redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin";
1864 30 Jan 06 nicklas 321   }
1864 30 Jan 06 nicklas 322   else if ("RunPlugin".equals(cmd))
1864 30 Jan 06 nicklas 323   {
1864 30 Jan 06 nicklas 324     // Run another plugin in single-item context
1864 30 Jan 06 nicklas 325     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
1864 30 Jan 06 nicklas 326     redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin";
1864 30 Jan 06 nicklas 327   }
1864 30 Jan 06 nicklas 328   else
1864 30 Jan 06 nicklas 329   {
1864 30 Jan 06 nicklas 330     throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
1864 30 Jan 06 nicklas 331   }
838 28 Jun 05 nicklas 332 }
838 28 Jun 05 nicklas 333 finally
838 28 Jun 05 nicklas 334 {
838 28 Jun 05 nicklas 335   if (dc != null) dc.close();
838 28 Jun 05 nicklas 336 }
1864 30 Jan 06 nicklas 337
1864 30 Jan 06 nicklas 338 if (forward != null)
1864 30 Jan 06 nicklas 339 {
6192 31 Oct 12 nicklas 340   sc.setSessionSetting("alert-message", message);
1864 30 Jan 06 nicklas 341   pageContext.forward(forward);
1864 30 Jan 06 nicklas 342 }
1864 30 Jan 06 nicklas 343 else if (redirect != null)
1864 30 Jan 06 nicklas 344 {
6192 31 Oct 12 nicklas 345   sc.setSessionSetting("alert-message", message);
1864 30 Jan 06 nicklas 346   response.sendRedirect(redirect);
1864 30 Jan 06 nicklas 347 }
1864 30 Jan 06 nicklas 348 else if (message == null)
1864 30 Jan 06 nicklas 349 {
1864 30 Jan 06 nicklas 350   response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
1864 30 Jan 06 nicklas 351 }
1864 30 Jan 06 nicklas 352 else
1864 30 Jan 06 nicklas 353 {
1864 30 Jan 06 nicklas 354   response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
1864 30 Jan 06 nicklas 355 }
1864 30 Jan 06 nicklas 356 %>
1864 30 Jan 06 nicklas 357