Search in sources :

Example 1 with Project

use of org.openstack4j.model.identity.v3.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 org.openstack4j.model.identity.v3.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 org.openstack4j.model.identity.v3.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 org.openstack4j.model.identity.v3.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 org.openstack4j.model.identity.v3.Project in project TrakEM2 by trakem2.

the class DBLoader method getProjects.

/**
 * Fetch all existing projects from the database.
 */
public Project[] getProjects() {
    synchronized (db_lock) {
        // connect if disconnected
        if (!connectToDatabase()) {
            return null;
        }
        Project[] projects = null;
        try {
            ResultSet r = connection.prepareStatement("SELECT title, id FROM ab_projects ORDER BY id").executeQuery();
            ArrayList<Project> al_projects = new ArrayList<Project>();
            while (r.next()) {
                al_projects.add(new Project(r.getLong("id"), r.getString("title")));
            }
            r.close();
            projects = new Project[al_projects.size()];
            al_projects.toArray(projects);
        } catch (Exception e) {
            IJError.print(e);
            return null;
        }
        return projects;
    }
}
Also used : Project(ini.trakem2.Project) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException)

Aggregations

Project (ini.trakem2.Project)26 ArrayList (java.util.ArrayList)13 Project (org.openstack4j.model.identity.v3.Project)9 File (java.io.File)7 HashMap (java.util.HashMap)7 ImagePlus (ij.ImagePlus)6 Worker (ini.trakem2.utils.Worker)6 Map (java.util.Map)6 LayerSet (ini.trakem2.display.LayerSet)5 ProjectThing (ini.trakem2.tree.ProjectThing)5 HashSet (java.util.HashSet)5 DBObject (ini.trakem2.persistence.DBObject)4 VectorString3D (ini.trakem2.vector.VectorString3D)4 GenericDialog (ij.gui.GenericDialog)3 Patch (ini.trakem2.display.Patch)3 Rectangle (java.awt.Rectangle)3 ImageJ (ij.ImageJ)2 Roi (ij.gui.Roi)2 YesNoCancelDialog (ij.gui.YesNoCancelDialog)2 DirectoryChooser (ij.io.DirectoryChooser)2