Changeset 6447


Ignore:
Timestamp:
Apr 15, 2014, 8:50:29 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1802: Jobs should be shareable

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/Job.java

    r6444 r6447  
    8181@SuppressWarnings("deprecation")
    8282public class Job
    83   extends OwnedItem<JobData>
    84   implements Nameable, Removable, Transactional
     83  extends CommonItem<JobData>
     84  implements Transactional
    8585{
    8686  /**
     
    196196  {
    197197    return TYPE;
    198   }
    199   // -------------------------------------------
    200   /*
    201     From the Nameable interface
    202     -------------------------------------------
    203   */
    204   @Override
    205   public String getName()
    206   {
    207     return getData().getName();
    208   }
    209   @Override
    210   public void setName(String name)
    211     throws PermissionDeniedException, InvalidDataException
    212   {
    213     checkPermission(Permission.WRITE);
    214     NameableUtil.setName(getData(), name);
    215   }
    216   @Override
    217   public String getDescription()
    218   {
    219     return getData().getDescription();
    220   }
    221   @Override
    222   public void setDescription(String description)
    223     throws PermissionDeniedException, InvalidDataException
    224   {
    225     checkPermission(Permission.WRITE);
    226     NameableUtil.setDescription(getData(), description);
    227   }
    228   // -------------------------------------------
    229   /*
    230     From the Removable interface
    231     -------------------------------------------
    232   */
    233   @Override
    234   public boolean isRemoved()
    235   {
    236     return getData().isRemoved();
    237   }
    238   @Override
    239   public void setRemoved(boolean removed)
    240     throws PermissionDeniedException
    241   {
    242     checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    243     getData().setRemoved(removed);
    244198  }
    245199  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Update.java

    r6444 r6447  
    4040import org.hibernate.mapping.PersistentClass;
    4141import org.hibernate.mapping.Table;
     42
    4243
    4344
     
    7677import net.sf.basedb.core.data.RoleKeyData;
    7778import net.sf.basedb.core.data.SchemaVersionData;
     79import net.sf.basedb.core.data.ShareableData;
    7880import net.sf.basedb.core.data.UserData;
    7981import net.sf.basedb.core.dbengine.DbEngine;
     
    212214    <td>116</td>
    213215    <td>
    214       Added {@link JobData#getExternalId()}. No special database update is needed. Only increase
    215       the schema version.
     216      Added {@link JobData#getExternalId()} and made {@link JobData} a {@link ShareableData} item.
     217      No special database update is needed. Only increase the schema version.
    216218    </td>
    217219  </tr>
  • trunk/src/core/net/sf/basedb/core/data/JobData.java

    r6446 r6447  
    4040*/
    4141public class JobData
    42   extends OwnedData
    43   implements NameableData, RemovableData
     42  extends CommonData
    4443{
    4544
    4645  public JobData()
    4746  {}
    48 
    49   /*
    50     From the NameableData interface
    51     -------------------------------------------
    52   */
    53   private String name;
    54   @Override
    55   public String getName()
    56   {
    57     return name;
    58   }
    59   @Override
    60   public void setName(String name)
    61   {
    62     this.name = name;
    63   }
    64   private String description;
    65   @Override
    66   public String getDescription()
    67   {
    68     return description;
    69   }
    70   @Override
    71   public void setDescription(String description)
    72   {
    73     this.description = description;
    74   }
    75   // -------------------------------------------
    76   /*
    77     From the RemovableData interface
    78     -------------------------------------------
    79   */
    80   private boolean removed;
    81   @Override
    82   public boolean isRemoved()
    83   {
    84     return removed;
    85   }
    86   @Override
    87   public void setRemoved(boolean removed)
    88   {
    89     this.removed = removed;
    90   }
    91   // -------------------------------------------
    9247
    9348  private int type;
  • trunk/www/views/jobs/index.jsp

    r6432 r6447  
    170170    redirect = listPage;
    171171  }
     172  else if ("ShareItem".equals(cmd))
     173  {
     174    // Display a popup window for sharing a single item
     175    dc = sc.newDbControl();
     176    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     177    MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId()));
     178    dc.close();
     179    cc.setObject("MultiPermissions", permissions);
     180    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
     181  }
     182  else if ("ShareItems".equals(cmd))
     183  {
     184    // Display a popup window for sharing all selected items on the list page
     185    dc = sc.newDbControl();
     186    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     187    MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected());
     188    dc.close();
     189    cc.setObject("MultiPermissions", permissions);
     190    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
     191  }
    172192  else if ("SetOwnerOfItem".equals(cmd))
    173193  {
  • trunk/www/views/jobs/list_jobs.jsp

    r6439 r6447  
    3636  import="net.sf.basedb.core.ItemContext"
    3737  import="net.sf.basedb.core.Permission"
     38  import="net.sf.basedb.core.Nameable"
    3839  import="net.sf.basedb.core.PluginDefinition"
    3940  import="net.sf.basedb.core.PermissionDeniedException"
     
    4546  import="net.sf.basedb.core.plugin.Plugin"
    4647  import="net.sf.basedb.util.Enumeration"
     48  import="net.sf.basedb.util.ShareableUtil"
    4749  import="net.sf.basedb.clients.web.Base"
    4850  import="net.sf.basedb.clients.web.ModeInfo"
     
    5860  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
    5961  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
     62  import="java.util.Iterator"
    6063  import="java.util.List"
    6164  import="java.util.Map"
     
    382385        title="Permission"
    383386      />
     387      <tbl:columndef
     388        id="sharedTo"
     389        title="Shared to"
     390        filterable="true"
     391        filterproperty="!sharedTo.name"
     392        datatype="string"
     393      />
    384394      <tbl:columndef
    385395        id="xt-columns"
     
    403413            title="Restore"
    404414            tooltip="Restore the selected (deleted) items"
     415          />
     416          <tbl:button
     417            id="btnShareItems"
     418            image="share.png"
     419            title="Share&hellip;"
     420            tooltip="Share the selected items"
    405421          />
    406422          <tbl:button
     
    701717                  /></tbl:cell>
    702718                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
     719                <tbl:cell column="sharedTo">
     720                  <%
     721                  Iterator<Nameable> sharees = ShareableUtil.getSharedTo(dc, item).iterator();
     722                  while(sharees.hasNext())
     723                  {
     724                    Nameable n = sharees.next();
     725                    if (mode.hasPropertyLink())
     726                    {
     727                      out.write(Base.getLinkedName(ID, n, false, mode.hasEditLink()));
     728                    }
     729                    else
     730                    {
     731                      out.write(HTML.encodeTags(n.getName()));
     732                    }
     733                    out.write(sharees.hasNext() ? ", " : "");
     734                  }
     735                  %>
     736                </tbl:cell>
    703737                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
    704738                  <tbl:cell column="xt-columns" />
Note: See TracChangeset for help on using the changeset viewer.