Skip to content

Commit

Permalink
Merge pull request ome#100 from jburel/multi-group-test
Browse files Browse the repository at this point in the history
Multi group test
  • Loading branch information
chris-allan committed Feb 28, 2012
2 parents 3f317b4 + e82b4db commit 891ed0d
Show file tree
Hide file tree
Showing 417 changed files with 14,854 additions and 7,529 deletions.
11 changes: 11 additions & 0 deletions components/blitz/src/pojos/DataObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,17 @@ public Timestamp getUpdated() {
return timeOfEvent(getDetails().getUpdateEvent());
}

/**
* Returns the id of the group.
*
* @return See above.
*/
public long getGroupId() {
Details d = getDetails();
if (d == null) return -1;
if (d.getGroup() == null) return -1;
return d.getGroup().getId().getValue();
}
// ~ VIEWS
// =========================================================================
// These methods should never a null value
Expand Down
10 changes: 10 additions & 0 deletions components/blitz/src/pojos/ExperimenterData.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,14 @@ public boolean isActive()
return false;
}

/**
* Overridden to return the id of the default group.
* @see DataObject#getGroupId()
*/
public long getGroupId() {
GroupData g = getDefaultGroup();
if (g == null) return -1;
return g.getId();
}

}
7 changes: 7 additions & 0 deletions components/blitz/src/pojos/GroupData.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ && asGroup().sizeOfGroupExperimenterMap() >= 0) {
return experimenters == null ? null : new HashSet(experimenters);
}

/**
* Overridden to return the id of the object.
* @see DataObject#getGroupId()
*/
public long getGroupId() {
return getId();
}
// Link mutations

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
import pojos.TagAnnotationData;
Expand Down Expand Up @@ -98,17 +99,18 @@ private void checkType(Class value)
*
* @param viewer The viewer this data loader is for.
* Mustn't be <code>null</code>.
* @param ctx The security context.
* @param type One of the annotation type.
* Mustn't be <code>null</code>.
* @param annotated Pass <code>true</code> to filter the annotated nodes,
* <code>false</code> otherwise.
* @param nodes The collection of objects to filter.
* Mustn't be <code>null</code>.
*/
public AnnotatedFilter(DataBrowser viewer, Class type, boolean annotated,
Collection<DataObject> nodes)
public AnnotatedFilter(DataBrowser viewer, SecurityContext ctx, Class type,
boolean annotated, Collection<DataObject> nodes)
{
super(viewer);
super(viewer, ctx);
if (nodes == null || nodes.size() == 0)
throw new IllegalArgumentException("No nodes to filter.");
checkType(type);
Expand Down Expand Up @@ -139,8 +141,8 @@ public AnnotatedFilter(DataBrowser viewer, Class type, boolean annotated,
public void load()
{
long userID = -1;//DataBrowserAgent.getUserDetails().getId();
handle = mhView.filterByAnnotated(nodeType, nodeIds, annotationType,
annotated, userID, this);
handle = mhView.filterByAnnotated(ctx, nodeType, nodeIds,
annotationType, annotated, userID, this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
import pojos.TextualAnnotationData;
Expand Down Expand Up @@ -78,16 +79,17 @@ public class CommentsFilter
*
* @param viewer The viewer this data loader is for.
* Mustn't be <code>null</code>.
* @param ctx The security context.
* @param comments The collection of comments to filter by.
* If <code>null</code> or <code>empty</code>
* retrieve the uncommented objects.
* @param nodes The collection of objects to filter.
* Mustn't be <code>null</code>.
*/
public CommentsFilter(DataBrowser viewer, List<String> comments,
Collection<DataObject> nodes)
public CommentsFilter(DataBrowser viewer, SecurityContext ctx,
List<String> comments, Collection<DataObject> nodes)
{
super(viewer);
super(viewer, ctx);
if (nodes == null || nodes.size() == 0)
throw new IllegalArgumentException("No nodes to filter.");
this.comments = comments;
Expand Down Expand Up @@ -116,8 +118,8 @@ public CommentsFilter(DataBrowser viewer, List<String> comments,
public void load()
{
long userID = -1;//DataBrowserAgent.getUserDetails().getId();
handle = mhView.filterByAnnotation(nodeType, nodeIds,
TextualAnnotationData.class, comments, userID, this);
handle = mhView.filterByAnnotation(ctx, nodeType, nodeIds,
TextualAnnotationData.class, comments, userID, this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ public class DataBrowserAgent
*/
public static Registry getRegistry() { return registry; }

/**
* Returns the available user groups.
*
* @return See above.
*/
public static Set getAvailableUserGroups()
{
return (Set) registry.lookup(LookupNames.USER_GROUP_DETAILS);
}

/**
* Helper method returning the current user's details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.env.config.Registry;
import org.openmicroscopy.shoola.env.data.events.DSCallAdapter;
import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.DataHandlerView;
import org.openmicroscopy.shoola.env.data.views.DataManagerView;
import org.openmicroscopy.shoola.env.data.views.HierarchyBrowsingView;
Expand Down Expand Up @@ -65,33 +66,39 @@ public abstract class DataBrowserLoader
{

/** The viewer this data loader is for. */
protected final DataBrowser viewer;
protected final DataBrowser viewer;

/** Convenience reference for subclasses. */
protected final Registry registry;
protected final Registry registry;

/** Convenience reference for subclasses. */
protected final HierarchyBrowsingView hiBrwView;
protected final HierarchyBrowsingView hiBrwView;

/** Convenience reference for subclasses. */
protected final DataHandlerView dhView;
protected final DataHandlerView dhView;

/** Convenience reference for subclasses. */
protected final MetadataHandlerView mhView;
protected final MetadataHandlerView mhView;

/** Convenience reference for subclasses. */
protected final DataManagerView dmView;
protected final DataManagerView dmView;

/** The security context.*/
protected final SecurityContext ctx;

/**
* Creates a new instance.
*
* @param viewer The viewer this data loader is for.
* Mustn't be <code>null</code>.
* @param ctx The security context.
*/
protected DataBrowserLoader(DataBrowser viewer)
protected DataBrowserLoader(DataBrowser viewer, SecurityContext ctx)
{
if (viewer == null) throw new NullPointerException("No viewer.");
if (viewer == null) throw new NullPointerException("No viewer.");
if (ctx == null) throw new NullPointerException("No security context.");
this.viewer = viewer;
this.ctx = ctx;
registry = DataBrowserAgent.getRegistry();
hiBrwView = (HierarchyBrowsingView)
registry.getDataServicesView(HierarchyBrowsingView.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import pojos.DatasetData;
import pojos.ExperimenterData;
import pojos.FileData;
import pojos.GroupData;
import pojos.ImageData;
import pojos.MultiImageData;
import pojos.PermissionData;
Expand Down Expand Up @@ -565,6 +566,36 @@ else if (ho instanceof ImageData) {
return results;
}

/**
* Transforms a set of {@link DataObject}s into their corresponding
* visualization objects. The elements of the set only be {@link ImageData}.
* The {@link ImageData}s are added to a {@link ImageSet}.
*
* @param dataObjects The {@link DataObject}s to transform.
* Mustn't be <code>null</code>.
* @param userID The id of the current user.
* @param group The the group the current user selects when
* retrieving the data.
* @return See above.
*/
public static ImageSet transformObjects(Collection dataObjects, long userID,
GroupData group)
{
if (dataObjects == null)
throw new IllegalArgumentException("No objects.");
Set results = new HashSet();
DataObject ho;
Iterator i = dataObjects.iterator();
long groupId = group.getId();
ImageSet groupNode = new ImageSet(group.getName(), group);
while (i.hasNext()) {
ho = (DataObject) i.next();
if (isReadable(ho, userID, groupId) && ho instanceof ImageData)
linkImageTo((ImageData) ho, groupNode);
}
return groupNode;
}

/**
* Transforms a set of {@link DataObject}s into their corresponding
* visualization objects. The elements of the set only be {@link ImageData}.
Expand All @@ -573,26 +604,25 @@ else if (ho instanceof ImageData) {
* @param dataObjects The {@link DataObject}s to transform.
* Mustn't be <code>null</code>.
* @param userID The id of the current user.
* @param groupID The id of the group the current user selects when
* retrieving the data.
* @param groupId The id of the group the current user selects when
* retrieving the data.
* @return See above.
*/
public static Set transformObjects(Collection dataObjects, long userID,
long groupID)
public static Set<ImageDisplay> transformObjects(Collection dataObjects,
long userID, long groupId)
{
if (dataObjects == null)
throw new IllegalArgumentException("No objects.");
Set results = new HashSet();
Set<ImageDisplay> results = new HashSet<ImageDisplay>();
DataObject ho;
Iterator i = dataObjects.iterator();
while (i.hasNext()) {
ho = (DataObject) i.next();
if (isReadable(ho, userID, groupID) && ho instanceof ImageData)
if (isReadable(ho, userID, groupId) && ho instanceof ImageData)
results.add(linkImageTo((ImageData) ho, null));
}
return results;
}

/**
* Transforms a set of {@link DataObject}s into their corresponding
* visualization objects. The elements of the set only be {@link ImageData}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.env.data.util.FilterContext;
import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;

Expand Down Expand Up @@ -78,14 +79,15 @@ public class DataFilter
*
* @param viewer The viewer this data loader is for.
* Mustn't be <code>null</code>.
* @param ctx The security context.
* @param context The filtering context. Mustn't be <code>null</code>.
* @param nodes The collection of objects to filter.
* Mustn't be <code>null</code>.
*/
public DataFilter(DataBrowser viewer, FilterContext context,
Collection<DataObject> nodes)
public DataFilter(DataBrowser viewer, SecurityContext ctx,
FilterContext context, Collection<DataObject> nodes)
{
super(viewer);
super(viewer, ctx);
if (nodes == null || nodes.size() == 0)
throw new IllegalArgumentException("No nodes to filter.");
if (context == null)
Expand Down Expand Up @@ -116,7 +118,8 @@ public DataFilter(DataBrowser viewer, FilterContext context,
public void load()
{
long userID = -1;//DataBrowserAgent.getUserDetails().getId();
handle = mhView.filterData(nodeType, nodeIds, context, userID, this);
handle = mhView.filterData(ctx, nodeType, nodeIds, context, userID,
this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;

Expand Down Expand Up @@ -70,16 +71,17 @@ public class DataObjectCreator
*
* @param viewer The viewer this data loader is for.
* Mustn't be <code>null</code>.
* @param ctx The security context.
* @param parent The parent of the <code>DataObject</code> to create
* or <code>null</code>.
* @param data The <code>DataObject</code> to create.
* Mustn't be <code>null</code>.
* @param children The nodes to add to the newly created object.
*/
public DataObjectCreator(DataBrowser viewer, DataObject parent,
DataObject data, Collection children)
public DataObjectCreator(DataBrowser viewer, SecurityContext ctx,
DataObject parent, DataObject data, Collection children)
{
super(viewer);
super(viewer, ctx);
if (data == null)
throw new IllegalArgumentException("No object to create.");
this.data = data;
Expand All @@ -99,7 +101,7 @@ public DataObjectCreator(DataBrowser viewer, DataObject parent,
*/
public void load()
{
handle = mhView.createDataObject(parent, data, children, this);
handle = mhView.createDataObject(ctx, parent, data, children, this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;

/**
Expand Down Expand Up @@ -63,14 +64,15 @@ public class DataObjectSaver
*
* @param viewer The viewer this data loader is for.
* Mustn't be <code>null</code>.
* @param ctx The security context.
* @param datasets The datasets to add the images to.
* Mustn't be <code>null</code>.
* @param images The images to add. Mustn't be <code>null</code>.
*/
public DataObjectSaver(DataBrowser viewer, Collection datasets,
Collection images)
public DataObjectSaver(DataBrowser viewer, SecurityContext ctx,
Collection datasets, Collection images)
{
super(viewer);
super(viewer, ctx);
if (datasets == null || datasets.size() == 0)
throw new IllegalArgumentException("No datasets to add the images" +
" to.");
Expand All @@ -93,7 +95,7 @@ public DataObjectSaver(DataBrowser viewer, Collection datasets,
public void load()
{

handle = dmView.addExistingObjects(datasets, images, this);
handle = dmView.addExistingObjects(ctx, datasets, images, this);
}

/**
Expand Down
Loading

0 comments on commit 891ed0d

Please sign in to comment.