use of ini.trakem2.Project in project camel by apache.
the class ProjectProducer method doUpdate.
private void doUpdate(Exchange exchange) {
final Message msg = exchange.getIn();
final Project in = messageToProject(msg);
final Project out = osV3Client.identity().projects().update(in);
msg.setBody(out);
}
use of ini.trakem2.Project in project camel by apache.
the class ProjectProducer method messageToProject.
private Project messageToProject(Message message) {
Project project = message.getBody(Project.class);
if (project == null) {
Map headers = message.getHeaders();
ProjectBuilder builder = Builders.project();
ObjectHelper.notEmpty(message.getHeader(OpenstackConstants.NAME, String.class), "Name");
builder.name(message.getHeader(OpenstackConstants.NAME, String.class));
if (headers.containsKey(KeystoneConstants.DOMAIN_ID)) {
builder.domainId(message.getHeader(KeystoneConstants.DOMAIN_ID, String.class));
}
if (headers.containsKey(KeystoneConstants.DESCRIPTION)) {
builder.description(message.getHeader(KeystoneConstants.DESCRIPTION, String.class));
}
if (headers.containsKey(KeystoneConstants.PARENT_ID)) {
builder.parentId(message.getHeader(KeystoneConstants.PARENT_ID, String.class));
}
project = builder.build();
}
return project;
}
use of ini.trakem2.Project in project camel by apache.
the class ProjectProducer method doGet.
private void doGet(Exchange exchange) {
final Message msg = exchange.getIn();
final String id = msg.getHeader(OpenstackConstants.ID, String.class);
ObjectHelper.notEmpty(id, "Project ID");
final Project result = osV3Client.identity().projects().get(id);
msg.setBody(result);
}
use of ini.trakem2.Project in project camel by apache.
the class ProjectProducerTest method setUp.
@Before
public void setUp() {
producer = new ProjectProducer(endpoint, client);
when(projectService.create(any(Project.class))).thenReturn(testOSproject);
when(projectService.get(anyString())).thenReturn(testOSproject);
List<Project> getAllList = new ArrayList<>();
getAllList.add(testOSproject);
getAllList.add(testOSproject);
doReturn(getAllList).when(projectService).list();
dummyProject = createProject();
when(testOSproject.getName()).thenReturn(dummyProject.getName());
when(testOSproject.getDescription()).thenReturn(dummyProject.getDescription());
}
use of ini.trakem2.Project in project TrakEM2 by trakem2.
the class DBLoader method importStackAsPatches.
/**
* Returns the last Patch.
*/
protected Patch importStackAsPatches(final Project project, final Layer first_layer, final double x, final double y, final ImagePlus imp_stack, final boolean as_copy, final String filepath) {
double pos_x = Double.MAX_VALUE != x ? x : first_layer.getLayerWidth() / 2 - imp_stack.getWidth() / 2;
double pos_y = Double.MAX_VALUE != y ? y : first_layer.getLayerHeight() / 2 - imp_stack.getHeight() / 2;
final double thickness = first_layer.getThickness();
final String title = Utils.removeExtension(imp_stack.getTitle()).replace(' ', '_');
Utils.showProgress(0);
Patch previous_patch = null;
final int n = imp_stack.getStackSize();
for (int i = 1; i <= n; i++) {
Layer layer = first_layer;
double z = first_layer.getZ() + (i - 1) * thickness;
// will create new layer if not found
if (i > 1)
layer = first_layer.getParent().getLayer(z, thickness, true);
if (null == layer) {
Utils.log("Display.importStack: could not create new layers.");
return null;
}
ImageProcessor ip = imp_stack.getStack().getProcessor(i);
if (as_copy)
ip = ip.duplicate();
ImagePlus imp_patch_i = new ImagePlus(title + "__slice=" + i, ip);
String label = imp_stack.getStack().getSliceLabel(i);
if (null == label)
label = "";
Patch patch = new Patch(project, label + " " + title + " " + i, pos_x, pos_y, imp_patch_i);
layer.add(patch);
if (null != previous_patch)
patch.link(previous_patch);
previous_patch = patch;
Utils.showProgress(i * (1.0 / n));
}
Utils.showProgress(1.0);
// return the last Patch
return previous_patch;
}
Aggregations