Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes and improvements - 2 #10

Merged
merged 3 commits into from
Jul 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/main/java/omero/gateway/facility/DataManagerFacility.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.concurrent.Future;
import java.util.stream.Collectors;

import omero.cmd.Chgrp2;
import omero.gateway.util.Links;
import omero.sys.ParametersI;
import org.apache.commons.collections.CollectionUtils;
Expand Down Expand Up @@ -597,6 +598,9 @@ public DatasetData createDataset(SecurityContext ctx, DatasetData dataset,
return null;

if (project != null) {
if (project.getId() >= 0)
// reload to be sure we have the latest version
project = browse.findObject(ctx, ProjectData.class, project.getId());
ProjectDatasetLink link = new ProjectDatasetLinkI();
link = new ProjectDatasetLinkI();
link.setChild(dataset.asDataset());
Expand Down Expand Up @@ -857,8 +861,30 @@ public void move(SecurityContext ctx, List<? extends DataObject> objects,
Links.setObjects(link, to, null);
updateObjects(ctx, links, null);
} catch (Throwable t) {
handleException(this, t, "Cannot move the annotation.");
handleException(this, t, "Cannot move the object.");
}
}

/**
* Move the given objects into another group
*
* @param ctx The SecurityContext
* @param objects The objects to move into another group
* @param groupId The group to move the objects into
* @throws DSAccessException
* @throws DSOutOfServiceException
*/
public void changeGroup(SecurityContext ctx, List<? extends DataObject> objects, long groupId)
throws DSAccessException, DSOutOfServiceException {
try {
String type = PojoMapper.getGraphType(objects.iterator().next().getClass());
Collection<Long> ids = objects.stream().map(o -> ((DataObject) o).getId())
.collect(Collectors.toList());
Chgrp2 chgrp2 = Requests.chgrp().target(type).id(ids).toGroup(groupId).build();
CmdCallbackI cb = gateway.submit(ctx, chgrp2);
cb.loop(30, 500);
} catch (Throwable t) {
handleException(this, t, "Change group failed.");
}
}

}