Search in sources :

Example 1 with Project

use of org.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.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.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.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.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.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.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.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.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.Project in project java-docs-samples by GoogleCloudPlatform.

the class SetUsageExportBucket method getUsageExportBucket.

// [END compute_usage_report_set]
// [START compute_usage_report_get]
// Retrieve Compute Engine usage export bucket for the Cloud project.
// Replaces the empty value returned by the API with the default value used
// to generate report file names.
public static UsageExportLocation getUsageExportBucket(String project) throws IOException {
    try (ProjectsClient projectsClient = ProjectsClient.create()) {
        // Get the usage export location for the project from the server.
        Project projectResponse = projectsClient.get(project);
        // used to generate report file names.
        if (projectResponse.hasUsageExportLocation()) {
            UsageExportLocation usageExportLocation = projectResponse.getUsageExportLocation();
            // Verify that the server explicitly sent the optional field.
            if (usageExportLocation.hasReportNamePrefix()) {
                String reportNamePrefix = usageExportLocation.getReportNamePrefix();
                if (reportNamePrefix.length() == 0) {
                    // Although the server explicitly sent the empty string value,
                    // the next usage report generated with these settings still has the default
                    // prefix value "usage_gce".
                    // (see, https://cloud.google.com/compute/docs/reference/rest/v1/projects/get)
                    reportNamePrefix = "usage_gce";
                    System.out.println("Report name prefix not set, replacing with default value of `usage_gce`.");
                }
            }
            return usageExportLocation;
        } else {
            // The usage reports are disabled.
            return null;
        }
    }
}
Also used : Project(com.google.cloud.compute.v1.Project) UsageExportLocation(com.google.cloud.compute.v1.UsageExportLocation) ProjectsClient(com.google.cloud.compute.v1.ProjectsClient)

Aggregations

Project (ini.trakem2.Project)27 ArrayList (java.util.ArrayList)20 EntityManager (jakarta.persistence.EntityManager)15 JpaEntityManager (org.eclipse.persistence.jpa.JpaEntityManager)15 HashMap (java.util.HashMap)14 LargeProject (org.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.LargeProject)13 SmallProject (org.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.SmallProject)13 SuperLargeProject (org.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.SuperLargeProject)13 Employee (org.eclipse.persistence.testing.models.jpa.composite.advanced.member_2.Employee)12 Project (org.openstack4j.model.identity.v3.Project)12 Project (org.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.Project)11 File (java.io.File)8 Map (java.util.Map)8 ImagePlus (ij.ImagePlus)7 HashSet (java.util.HashSet)7 LayerSet (ini.trakem2.display.LayerSet)6 Worker (ini.trakem2.utils.Worker)6 List (java.util.List)6 ProjectThing (ini.trakem2.tree.ProjectThing)5 Rectangle (java.awt.Rectangle)5