Changeset 2918


Ignore:
Timestamp:
Nov 15, 2006, 12:21:13 PM (16 years ago)
Author:
Nicklas Nordborg
Message:

References #348: Take ownership of items

Implemented on all pages in the "View" menu.

Location:
trunk/www
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/filemanager/directories/index.jsp

    r2811 r2918  
    3939  import="net.sf.basedb.util.RemovableUtil"
    4040  import="net.sf.basedb.util.ShareableUtil"
     41  import="net.sf.basedb.util.OwnableUtil"
    4142  import="net.sf.basedb.clients.web.Base"
    4243  import="net.sf.basedb.clients.web.WebException"
     
    115116    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    116117  }
     118  else if ("TakeOwnershipOfItem".equals(cmd))
     119  {
     120    // Take ownership a single item and then return to the view page
     121    dc = sc.newDbControl();
     122    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     123    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     124    dc.commit();
     125    redirect = viewPage;
     126  }
    117127  else if ("UpdateItem".equals(cmd))
    118128  {
  • trunk/www/filemanager/files/index.jsp

    r2811 r2918  
    4444  import="net.sf.basedb.util.RemovableUtil"
    4545  import="net.sf.basedb.util.ShareableUtil"
     46  import="net.sf.basedb.util.OwnableUtil"
    4647  import="net.sf.basedb.clients.web.Base"
    4748  import="net.sf.basedb.clients.web.WebException"
     
    258259    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    259260  }
     261  else if ("TakeOwnershipOfItem".equals(cmd))
     262  {
     263    // Take ownership a single item and then return to the view page
     264    dc = sc.newDbControl();
     265    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     266    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     267    dc.commit();
     268    redirect = viewPage;
     269  }
     270  else if ("TakeOwnershipOfItems".equals(cmd))
     271  {
     272    // Take ownership all selected items on the list page
     273    dc = sc.newDbControl();
     274    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     275    // Files
     276    int numTotal = cc.getSelected().size();
     277    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     278   
     279    // Directories
     280    numTotal += dirContext.getSelected().size();
     281    numOwned += OwnableUtil.setOwner(dc, Item.DIRECTORY, dirContext.getSelected(), null);
     282    dc.commit();
     283    if (numTotal != numOwned)
     284    {
     285      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     286    }
     287    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     288  }
    260289  else if ("ExportItems".equals(cmd))
    261290  {
  • trunk/www/filemanager/files/list_files.jsp

    r2753 r2918  
    196196      frm.submit();
    197197    }
     198    function takeOwnership()
     199    {
     200      var frm = document.forms[formId];
     201      if (Forms.numChecked(frm) == 0)
     202      {
     203        alert('Please select at least one item in the list');
     204        return;
     205      }
     206      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     207      {
     208        frm.action = submitPage;
     209        frm.cmd.value = 'TakeOwnershipOfItems';
     210        frm.submit();
     211      }
     212    }
    198213    function shareDirectory(itemId)
    199214    {
     
    503518          tooltip="Share the selected items"
    504519          visible="<%=mode.hasToolbar()%>"
     520        />
     521        <tbl:button
     522          image="take_ownership.png"
     523          onclick="takeOwnership()"
     524          title="Take ownership&hellip;"
     525          tooltip="Take ownership of the selected items"
    505526        />
    506527        <tbl:button
  • trunk/www/filemanager/files/view_file.jsp

    r2753 r2918  
    7474  final boolean deletePermission = file.hasPermission(Permission.DELETE);
    7575  final boolean sharePermission = file.hasPermission(Permission.SET_PERMISSION);
     76  final boolean setOwnerPermission = file.hasPermission(Permission.SET_OWNER);
     77  final boolean isOwner = file.isOwner();
    7678  %>
    77 
    7879  <base:page type="popup" title="<%=title%>">
    7980  <base:head styles="toolbar.css">
     
    9495    {
    9596      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     97    }
     98    function takeOwnership()
     99    {
     100      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     101      {
     102        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     103      }
    96104    }
    97105    function runPlugin(cmd)
     
    137145        title="Share&hellip;"
    138146        tooltip="<%=sharePermission ? "Share this file to other user, groups and projects" : "You do not have permission to share this file"%>"
     147      />
     148      <tbl:button
     149        disabled="<%=setOwnerPermission ? false : true%>"
     150        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     151        onclick="takeOwnership()"
     152        title="Take ownership&hellip;"
     153        visible="<%=!isOwner%>"
     154        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    139155      />
    140156      <tbl:button
  • trunk/www/my_base/projects/index.jsp

    r2811 r2918  
    4141  import="net.sf.basedb.core.ItemAlreadyExistsException"
    4242  import="net.sf.basedb.util.RemovableUtil"
     43  import="net.sf.basedb.util.OwnableUtil"
    4344  import="net.sf.basedb.clients.web.Base"
    4445  import="net.sf.basedb.clients.web.PermissionUtil"
     
    215216    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
    216217  }
     218  else if ("TakeOwnershipOfItem".equals(cmd))
     219  {
     220    // Take ownership a single item and then return to the view page
     221    dc = sc.newDbControl();
     222    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     223    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     224    dc.commit();
     225    redirect = viewPage;
     226  }
     227  else if ("TakeOwnershipOfItems".equals(cmd))
     228  {
     229    // Take ownership all selected items on the list page
     230    dc = sc.newDbControl();
     231    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     232    int numTotal = cc.getSelected().size();
     233    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     234    dc.commit();
     235    if (numTotal != numOwned)
     236    {
     237      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     238    }
     239    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     240  }
    217241  else if ("ExportItems".equals(cmd))
    218242  {
  • trunk/www/my_base/projects/list_projects.jsp

    r2753 r2918  
    128128      frm.submit();
    129129    }
     130    function takeOwnership()
     131    {
     132      var frm = document.forms[formId];
     133      if (Forms.numChecked(frm) == 0)
     134      {
     135        alert('Please select at least one item in the list');
     136        return;
     137      }
     138      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     139      {
     140        frm.action = submitPage;
     141        frm.cmd.value = 'TakeOwnershipOfItems';
     142        frm.submit();
     143      }
     144    }
    130145    function configureColumns()
    131146    {
     
    240255          title="Restore"
    241256          tooltip="Restore the selected (deleted) items"
     257        />
     258        <tbl:button
     259          image="take_ownership.png"
     260          onclick="takeOwnership()"
     261          title="Take ownership&hellip;"
     262          tooltip="Take ownership of the selected items"
     263          visible="<%=sc.hasPermission(Permission.SET_OWNER, Item.PROJECT)%>"
    242264        />
    243265        <tbl:button
  • trunk/www/my_base/projects/view_project.jsp

    r2753 r2918  
    7878  final boolean writePermission = project.hasPermission(Permission.WRITE);
    7979  final boolean deletePermission = project.hasPermission(Permission.DELETE);
     80  final boolean setOwnerPermission = project.hasPermission(Permission.SET_OWNER);
     81  final boolean isOwner = project.isOwner();
    8082  %>
    8183
     
    9496    {
    9597      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     98    }
     99    function takeOwnership()
     100    {
     101      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     102      {
     103        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     104      }
    96105    }
    97106    function runPlugin(cmd)
     
    154163        visible="<%=project.isRemoved()%>"
    155164        tooltip="<%=writePermission ? "Restore this project" : "You do not have permission to restore this project"%>"
     165      />
     166      <tbl:button
     167        disabled="<%=setOwnerPermission ? false : true%>"
     168        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     169        onclick="takeOwnership()"
     170        title="Take ownership&hellip;"
     171        visible="<%=!isOwner%>"
     172        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    156173      />
    157174      <tbl:button
  • trunk/www/views/experiments/index.jsp

    r2811 r2918  
    4646  import="net.sf.basedb.util.RemovableUtil"
    4747  import="net.sf.basedb.util.ShareableUtil"
     48  import="net.sf.basedb.util.OwnableUtil"
    4849  import="net.sf.basedb.clients.web.Base"
    4950  import="net.sf.basedb.clients.web.WebException"
     
    268269    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    269270  }
     271  else if ("TakeOwnershipOfItem".equals(cmd))
     272  {
     273    // Take ownership a single item and then return to the view page
     274    dc = sc.newDbControl();
     275    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     276    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     277    dc.commit();
     278    redirect = viewPage;
     279  }
     280  else if ("TakeOwnershipOfItems".equals(cmd))
     281  {
     282    // Take ownership all selected items on the list page
     283    dc = sc.newDbControl();
     284    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     285    int numTotal = cc.getSelected().size();
     286    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     287    dc.commit();
     288    if (numTotal != numOwned)
     289    {
     290      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     291    }
     292    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     293  }
    270294  else if ("ExportItems".equals(cmd))
    271295  {
  • trunk/www/views/experiments/list_experiments.jsp

    r2753 r2918  
    130130      frm.submit();
    131131    }
     132    function takeOwnership()
     133    {
     134      var frm = document.forms[formId];
     135      if (Forms.numChecked(frm) == 0)
     136      {
     137        alert('Please select at least one item in the list');
     138        return;
     139      }
     140      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     141      {
     142        frm.action = submitPage;
     143        frm.cmd.value = 'TakeOwnershipOfItems';
     144        frm.submit();
     145      }
     146    }
    132147    function shareItem(itemId)
    133148    {
     
    367382          title="Share&hellip;"
    368383          tooltip="Share the selected items"
     384        />
     385        <tbl:button
     386          image="take_ownership.png"
     387          onclick="takeOwnership()"
     388          title="Take ownership&hellip;"
     389          tooltip="Take ownership of the selected items"
    369390        />
    370391        <tbl:button
  • trunk/www/views/experiments/view_experiment.jsp

    r2893 r2918  
    8080  final boolean deletePermission = experiment.hasPermission(Permission.DELETE);
    8181  final boolean sharePermission = experiment.hasPermission(Permission.SET_PERMISSION);
     82  final boolean setOwnerPermission = experiment.hasPermission(Permission.SET_OWNER);
     83  final boolean isOwner = experiment.isOwner();
    8284  %>
    8385
     
    100102    {
    101103      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     104    }
     105    function takeOwnership()
     106    {
     107      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     108      {
     109        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     110      }
    102111    }
    103112    function runPlugin(cmd)
     
    167176        title="Share&hellip;"
    168177        tooltip="<%=sharePermission ? "Share this experiment to other user, groups and projects" : "You do not have permission to share this experiment"%>"
     178      />
     179      <tbl:button
     180        disabled="<%=setOwnerPermission ? false : true%>"
     181        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     182        onclick="takeOwnership()"
     183        title="Take ownership&hellip;"
     184        visible="<%=!isOwner%>"
     185        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    169186      />
    170187      <tbl:button
  • trunk/www/views/formulas/index.jsp

    r2811 r2918  
    4343  import="net.sf.basedb.util.RemovableUtil"
    4444  import="net.sf.basedb.util.ShareableUtil"
     45  import="net.sf.basedb.util.OwnableUtil"
    4546  import="net.sf.basedb.clients.web.Base"
    4647  import="net.sf.basedb.clients.web.WebException"
     
    232233    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    233234  }
     235  else if ("TakeOwnershipOfItem".equals(cmd))
     236  {
     237    // Take ownership a single item and then return to the view page
     238    dc = sc.newDbControl();
     239    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     240    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     241    dc.commit();
     242    redirect = viewPage;
     243  }
     244  else if ("TakeOwnershipOfItems".equals(cmd))
     245  {
     246    // Take ownership all selected items on the list page
     247    dc = sc.newDbControl();
     248    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     249    int numTotal = cc.getSelected().size();
     250    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     251    dc.commit();
     252    if (numTotal != numOwned)
     253    {
     254      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     255    }
     256    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     257  }
    234258  else if ("ExportItems".equals(cmd))
    235259  {
  • trunk/www/views/formulas/list_formulas.jsp

    r2753 r2918  
    143143      frm.submit();
    144144    }
     145    function takeOwnership()
     146    {
     147      var frm = document.forms[formId];
     148      if (Forms.numChecked(frm) == 0)
     149      {
     150        alert('Please select at least one item in the list');
     151        return;
     152      }
     153      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     154      {
     155        frm.action = submitPage;
     156        frm.cmd.value = 'TakeOwnershipOfItems';
     157        frm.submit();
     158      }
     159    }
    145160    function shareItem(itemId)
    146161    {
     
    353368          title="Share&hellip;"
    354369          tooltip="Share the selected items"
     370        />
     371        <tbl:button
     372          image="take_ownership.png"
     373          onclick="takeOwnership()"
     374          title="Take ownership&hellip;"
     375          tooltip="Take ownership of the selected items"
    355376        />
    356377        <tbl:button
  • trunk/www/views/formulas/view_formula.jsp

    r2733 r2918  
    7575  final boolean deletePermission = formula.hasPermission(Permission.DELETE);
    7676  final boolean sharePermission = formula.hasPermission(Permission.SET_PERMISSION);
     77  final boolean setOwnerPermission = formula.hasPermission(Permission.SET_OWNER);
     78  final boolean isOwner = formula.isOwner();
    7779  %>
    7880
     
    9597    {
    9698      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     99    }
     100    function takeOwnership()
     101    {
     102      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     103      {
     104        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     105      }
    97106    }
    98107    function runPlugin(cmd)
     
    142151        title="Share&hellip;"
    143152        tooltip="<%=sharePermission ? "Share this formula to other user, groups and projects" : "You do not have permission to share this formula"%>"
     153      />
     154      <tbl:button
     155        disabled="<%=setOwnerPermission ? false : true%>"
     156        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     157        onclick="takeOwnership()"
     158        title="Take ownership&hellip;"
     159        visible="<%=!isOwner%>"
     160        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    144161      />
    145162      <tbl:button
  • trunk/www/views/hybridizations/index.jsp

    r2811 r2918  
    4545  import="net.sf.basedb.util.RemovableUtil"
    4646  import="net.sf.basedb.util.ShareableUtil"
     47  import="net.sf.basedb.util.OwnableUtil"
    4748  import="net.sf.basedb.clients.web.Base"
    4849  import="net.sf.basedb.clients.web.WebException"
     
    264265    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    265266  }
     267  else if ("TakeOwnershipOfItem".equals(cmd))
     268  {
     269    // Take ownership a single item and then return to the view page
     270    dc = sc.newDbControl();
     271    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     272    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     273    dc.commit();
     274    redirect = viewPage;
     275  }
     276  else if ("TakeOwnershipOfItems".equals(cmd))
     277  {
     278    // Take ownership all selected items on the list page
     279    dc = sc.newDbControl();
     280    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     281    int numTotal = cc.getSelected().size();
     282    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     283    dc.commit();
     284    if (numTotal != numOwned)
     285    {
     286      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     287    }
     288    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     289  }
    266290  else if ("ExportItems".equals(cmd))
    267291  {
  • trunk/www/views/hybridizations/list_hybridizations.jsp

    r2893 r2918  
    155155      frm.submit();
    156156    }
     157    function takeOwnership()
     158    {
     159      var frm = document.forms[formId];
     160      if (Forms.numChecked(frm) == 0)
     161      {
     162        alert('Please select at least one item in the list');
     163        return;
     164      }
     165      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     166      {
     167        frm.action = submitPage;
     168        frm.cmd.value = 'TakeOwnershipOfItems';
     169        frm.submit();
     170      }
     171    }
    157172    function shareItem(itemId)
    158173    {
     
    365380          title="Share&hellip;"
    366381          tooltip="Share the selected items"
     382        />
     383        <tbl:button
     384          image="take_ownership.png"
     385          onclick="takeOwnership()"
     386          title="Take ownership&hellip;"
     387          tooltip="Take ownership of the selected items"
    367388        />
    368389        <tbl:button
  • trunk/www/views/hybridizations/view_hybridization.jsp

    r2875 r2918  
    8989  final boolean deletePermission = hyb.hasPermission(Permission.DELETE);
    9090  final boolean sharePermission = hyb.hasPermission(Permission.SET_PERMISSION);
    91 
     91  final boolean setOwnerPermission = hyb.hasPermission(Permission.SET_OWNER);
     92  final boolean isOwner = hyb.isOwner();
    9293  %>
    9394
     
    110111    {
    111112      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     113    }
     114    function takeOwnership()
     115    {
     116      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     117      {
     118        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     119      }
    112120    }
    113121    function runPlugin(cmd)
     
    162170        title="Share&hellip;"
    163171        tooltip="<%=sharePermission ? "Share this hybridization to other user, groups and projects" : "You do not have permission to share this hybridization"%>"
     172      />
     173      <tbl:button
     174        disabled="<%=setOwnerPermission ? false : true%>"
     175        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     176        onclick="takeOwnership()"
     177        title="Take ownership&hellip;"
     178        visible="<%=!isOwner%>"
     179        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    164180      />
    165181      <tbl:button
  • trunk/www/views/jobs/index.jsp

    r2811 r2918  
    4040  import="net.sf.basedb.util.RemovableUtil"
    4141  import="net.sf.basedb.util.ShareableUtil"
     42  import="net.sf.basedb.util.OwnableUtil"
    4243  import="net.sf.basedb.clients.web.Base"
    4344  import="net.sf.basedb.clients.web.WebException"
     
    158159    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
    159160  }
     161  else if ("TakeOwnershipOfItem".equals(cmd))
     162  {
     163    // Take ownership a single item and then return to the view page
     164    dc = sc.newDbControl();
     165    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     166    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     167    dc.commit();
     168    redirect = viewPage;
     169  }
     170  else if ("TakeOwnershipOfItems".equals(cmd))
     171  {
     172    // Take ownership all selected items on the list page
     173    dc = sc.newDbControl();
     174    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     175    int numTotal = cc.getSelected().size();
     176    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     177    dc.commit();
     178    if (numTotal != numOwned)
     179    {
     180      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     181    }
     182    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     183  }
    160184  else if ("ExportItems".equals(cmd))
    161185  {
  • trunk/www/views/jobs/list_jobs.jsp

    r2753 r2918  
    141141      frm.submit();
    142142    }
     143    function takeOwnership()
     144    {
     145      var frm = document.forms[formId];
     146      if (Forms.numChecked(frm) == 0)
     147      {
     148        alert('Please select at least one item in the list');
     149        return;
     150      }
     151      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     152      {
     153        frm.action = submitPage;
     154        frm.cmd.value = 'TakeOwnershipOfItems';
     155        frm.submit();
     156      }
     157    }
    143158    function configureColumns()
    144159    {
     
    358373          title="Restore"
    359374          tooltip="Restore the selected (deleted) items"
     375        />
     376        <tbl:button
     377          image="take_ownership.png"
     378          onclick="takeOwnership()"
     379          title="Take ownership&hellip;"
     380          tooltip="Take ownership of the selected items"
     381          visible="<%=sc.hasPermission(Permission.SET_OWNER, Item.JOB)%>"
    360382        />
    361383        <tbl:button
  • trunk/www/views/rawbioassays/index.jsp

    r2811 r2918  
    5959  import="net.sf.basedb.util.RemovableUtil"
    6060  import="net.sf.basedb.util.ShareableUtil"
     61  import="net.sf.basedb.util.OwnableUtil"
    6162  import="net.sf.basedb.clients.web.Base"
    6263  import="net.sf.basedb.clients.web.WebException"
     
    279280    cc.setObject("MultiPermissions", permissions);
    280281    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
     282  }
     283  else if ("TakeOwnershipOfItem".equals(cmd))
     284  {
     285    // Take ownership a single item and then return to the view page
     286    dc = sc.newDbControl();
     287    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     288    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     289    dc.commit();
     290    redirect = viewPage;
     291  }
     292  else if ("TakeOwnershipOfItems".equals(cmd))
     293  {
     294    // Take ownership all selected items on the list page
     295    dc = sc.newDbControl();
     296    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     297    int numTotal = cc.getSelected().size();
     298    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     299    dc.commit();
     300    if (numTotal != numOwned)
     301    {
     302      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     303    }
     304    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
    281305  }
    282306  else if ("ExportItems".equals(cmd))
  • trunk/www/views/rawbioassays/list_rawbioassays.jsp

    r2893 r2918  
    150150      frm.submit();
    151151    }
     152    function takeOwnership()
     153    {
     154      var frm = document.forms[formId];
     155      if (Forms.numChecked(frm) == 0)
     156      {
     157        alert('Please select at least one item in the list');
     158        return;
     159      }
     160      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     161      {
     162        frm.action = submitPage;
     163        frm.cmd.value = 'TakeOwnershipOfItems';
     164        frm.submit();
     165      }
     166    }
    152167    function shareItem(itemId)
    153168    {
     
    396411          title="Share&hellip;"
    397412          tooltip="Share the selected items"
     413        />
     414        <tbl:button
     415          image="take_ownership.png"
     416          onclick="takeOwnership()"
     417          title="Take ownership&hellip;"
     418          tooltip="Take ownership of the selected items"
    398419        />
    399420        <tbl:button
  • trunk/www/views/rawbioassays/view_rawbioassay.jsp

    r2875 r2918  
    9494  final boolean deletePermission = rawBioAssay.hasPermission(Permission.DELETE);
    9595  final boolean sharePermission = rawBioAssay.hasPermission(Permission.SET_PERMISSION);
     96  final boolean setOwnerPermission = rawBioAssay.hasPermission(Permission.SET_OWNER);
     97  final boolean isOwner = rawBioAssay.isOwner();
    9698  %>
    9799
     
    114116    {
    115117      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     118    }
     119    function takeOwnership()
     120    {
     121      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     122      {
     123        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     124      }
    116125    }
    117126    function runPlugin(cmd)
     
    181190        title="Share&hellip;"
    182191        tooltip="<%=sharePermission ? "Share this raw bioassay to other user, groups and projects" : "You do not have permission to share this raw bioassay"%>"
     192      />
     193      <tbl:button
     194        disabled="<%=setOwnerPermission ? false : true%>"
     195        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     196        onclick="takeOwnership()"
     197        title="Take ownership&hellip;"
     198        visible="<%=!isOwner%>"
     199        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    183200      />
    184201      <tbl:button
  • trunk/www/views/reporterlists/index.jsp

    r2811 r2918  
    4747  import="net.sf.basedb.util.RemovableUtil"
    4848  import="net.sf.basedb.util.ShareableUtil"
     49  import="net.sf.basedb.util.OwnableUtil"
    4950  import="net.sf.basedb.clients.web.Base"
    5051  import="net.sf.basedb.clients.web.WebException"
     
    249250    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    250251  }
     252  else if ("TakeOwnershipOfItem".equals(cmd))
     253  {
     254    // Take ownership a single item and then return to the view page
     255    dc = sc.newDbControl();
     256    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     257    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     258    dc.commit();
     259    redirect = viewPage;
     260  }
     261  else if ("TakeOwnershipOfItems".equals(cmd))
     262  {
     263    // Take ownership all selected items on the list page
     264    dc = sc.newDbControl();
     265    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     266    int numTotal = cc.getSelected().size();
     267    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     268    dc.commit();
     269    if (numTotal != numOwned)
     270    {
     271      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     272    }
     273    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     274  }
    251275  else if ("ExportItems".equals(cmd))
    252276  {
  • trunk/www/views/reporterlists/list_reporterlists.jsp

    r2753 r2918  
    124124      frm.submit();
    125125    }
     126    function takeOwnership()
     127    {
     128      var frm = document.forms[formId];
     129      if (Forms.numChecked(frm) == 0)
     130      {
     131        alert('Please select at least one item in the list');
     132        return;
     133      }
     134      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     135      {
     136        frm.action = submitPage;
     137        frm.cmd.value = 'TakeOwnershipOfItems';
     138        frm.submit();
     139      }
     140    }
    126141    function shareItem(itemId)
    127142    {
     
    263278          title="Share&hellip;"
    264279          tooltip="Share the selected items"
     280        />
     281        <tbl:button
     282          image="take_ownership.png"
     283          onclick="takeOwnership()"
     284          title="Take ownership&hellip;"
     285          tooltip="Take ownership of the selected items"
    265286        />
    266287        <tbl:button
  • trunk/www/views/reporterlists/view_reporterlist.jsp

    r2753 r2918  
    7171  final boolean deletePermission = reporterList.hasPermission(Permission.DELETE);
    7272  final boolean sharePermission = reporterList.hasPermission(Permission.SET_PERMISSION);
     73  final boolean setOwnerPermission = reporterList.hasPermission(Permission.SET_OWNER);
     74  final boolean isOwner = reporterList.isOwner();
    7375  %>
    74 
    7576  <base:page title="<%=title%>">
    7677  <base:head scripts="tabcontrol.js" styles="toolbar.css,headertabcontrol.css,path.css">
     
    9192    {
    9293      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     94    }
     95    function takeOwnership()
     96    {
     97      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     98      {
     99        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     100      }
    93101    }
    94102    function runPlugin(cmd)
     
    155163      />
    156164      <tbl:button
     165        disabled="<%=setOwnerPermission ? false : true%>"
     166        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     167        onclick="takeOwnership()"
     168        title="Take ownership&hellip;"
     169        visible="<%=!isOwner%>"
     170        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
     171      />
     172      <tbl:button
    157173        image="import.gif"
    158174        onclick="runPlugin('ImportItem')"
  • trunk/www/views/scans/index.jsp

    r2811 r2918  
    4343  import="net.sf.basedb.util.RemovableUtil"
    4444  import="net.sf.basedb.util.ShareableUtil"
     45  import="net.sf.basedb.util.OwnableUtil"
    4546  import="net.sf.basedb.clients.web.Base"
    4647  import="net.sf.basedb.clients.web.WebException"
     
    237238    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    238239  }
     240  else if ("TakeOwnershipOfItem".equals(cmd))
     241  {
     242    // Take ownership a single item and then return to the view page
     243    dc = sc.newDbControl();
     244    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     245    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     246    dc.commit();
     247    redirect = viewPage;
     248  }
     249  else if ("TakeOwnershipOfItems".equals(cmd))
     250  {
     251    // Take ownership all selected items on the list page
     252    dc = sc.newDbControl();
     253    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     254    int numTotal = cc.getSelected().size();
     255    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     256    dc.commit();
     257    if (numTotal != numOwned)
     258    {
     259      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     260    }
     261    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     262  }
    239263  else if ("ExportItems".equals(cmd))
    240264  {
  • trunk/www/views/scans/list_scans.jsp

    r2893 r2918  
    144144      frm.submit();
    145145    }
     146    function takeOwnership()
     147    {
     148      var frm = document.forms[formId];
     149      if (Forms.numChecked(frm) == 0)
     150      {
     151        alert('Please select at least one item in the list');
     152        return;
     153      }
     154      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     155      {
     156        frm.action = submitPage;
     157        frm.cmd.value = 'TakeOwnershipOfItems';
     158        frm.submit();
     159      }
     160    }
    146161    function shareItem(itemId)
    147162    {
     
    329344          title="Share&hellip;"
    330345          tooltip="Share the selected items"
     346        />
     347        <tbl:button
     348          image="take_ownership.png"
     349          onclick="takeOwnership()"
     350          title="Take ownership&hellip;"
     351          tooltip="Take ownership of the selected items"
    331352        />
    332353        <tbl:button
  • trunk/www/views/scans/view_scan.jsp

    r2875 r2918  
    8585  final boolean deletePermission = scan.hasPermission(Permission.DELETE);
    8686  final boolean sharePermission = scan.hasPermission(Permission.SET_PERMISSION);
     87  final boolean setOwnerPermission = scan.hasPermission(Permission.SET_OWNER);
     88  final boolean isOwner = scan.isOwner();
    8789  %>
    8890
     
    105107    {
    106108      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     109    }
     110    function takeOwnership()
     111    {
     112      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     113      {
     114        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     115      }
    107116    }
    108117    function runPlugin(cmd)
     
    172181        title="Share&hellip;"
    173182        tooltip="<%=sharePermission ? "Share this scan to other user, groups and projects" : "You do not have permission to share this scan"%>"
     183      />
     184      <tbl:button
     185        disabled="<%=setOwnerPermission ? false : true%>"
     186        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     187        onclick="takeOwnership()"
     188        title="Take ownership&hellip;"
     189        visible="<%=!isOwner%>"
     190        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    174191      />
    175192      <tbl:button
Note: See TracChangeset for help on using the changeset viewer.