Search in sources :

Example 1 with Project

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);
}
Also used : Project(org.openstack4j.model.identity.v3.Project) Message(org.apache.camel.Message)

Example 2 with Project

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;
}
Also used : Project(org.openstack4j.model.identity.v3.Project) ProjectBuilder(org.openstack4j.model.identity.v3.builder.ProjectBuilder) Map(java.util.Map)

Example 3 with 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);
}
Also used : Project(org.openstack4j.model.identity.v3.Project) Message(org.apache.camel.Message)

Example 4 with Project

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());
}
Also used : Project(org.openstack4j.model.identity.v3.Project) ProjectProducer(org.apache.camel.component.openstack.keystone.producer.ProjectProducer) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 5 with Project

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;
}
Also used : ImageProcessor(ij.process.ImageProcessor) Patch(ini.trakem2.display.Patch) Layer(ini.trakem2.display.Layer) ImagePlus(ij.ImagePlus) Point(java.awt.Point) PGpoint(org.postgresql.geometric.PGpoint)

Aggregations

ArrayList (java.util.ArrayList)33 Project (ini.trakem2.Project)26 HashMap (java.util.HashMap)25 Layer (ini.trakem2.display.Layer)21 Displayable (ini.trakem2.display.Displayable)19 Patch (ini.trakem2.display.Patch)18 File (java.io.File)18 HashSet (java.util.HashSet)18 ZDisplayable (ini.trakem2.display.ZDisplayable)17 ImagePlus (ij.ImagePlus)16 ProjectThing (ini.trakem2.tree.ProjectThing)16 Worker (ini.trakem2.utils.Worker)16 TemplateThing (ini.trakem2.tree.TemplateThing)15 Map (java.util.Map)15 LayerSet (ini.trakem2.display.LayerSet)14 ResultSet (java.sql.ResultSet)13 DBObject (ini.trakem2.persistence.DBObject)12 AffineTransform (java.awt.geom.AffineTransform)11 TreeMap (java.util.TreeMap)11 FSLoader (ini.trakem2.persistence.FSLoader)10