use of com.google.container.v1.Operation in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method revisitServiceTasksExecute.
private void revisitServiceTasksExecute(FlowElementsContainer container, List<RootElement> rootElements, List<Interface> toAddInterfaces, List<Message> toAddMessages, List<ItemDefinition> toAddDefinitions) {
List<FlowElement> flowElements = container.getFlowElements();
for (FlowElement fe : flowElements) {
if (fe instanceof ServiceTask) {
Iterator<FeatureMap.Entry> iter = fe.getAnyAttribute().iterator();
String serviceImplementation = null;
String serviceInterface = null;
String serviceOperation = null;
EStructuralFeature serviceInterfaceFeature = null;
EStructuralFeature serviceOperationFeature = null;
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("serviceimplementation")) {
serviceImplementation = (String) entry.getValue();
}
if (entry.getEStructuralFeature().getName().equals("serviceoperation")) {
serviceOperation = (String) entry.getValue();
serviceOperationFeature = entry.getEStructuralFeature();
}
if (entry.getEStructuralFeature().getName().equals("serviceinterface")) {
serviceInterface = (String) entry.getValue();
serviceInterfaceFeature = entry.getEStructuralFeature();
}
}
boolean foundInterface = false;
Interface touseInterface = null;
if (serviceImplementation != null && serviceImplementation.equals("Java")) {
for (RootElement iroot : rootElements) {
if (iroot instanceof Interface && ((Interface) iroot).getName().equals(serviceInterface)) {
foundInterface = true;
touseInterface = (Interface) iroot;
break;
}
}
if (!foundInterface) {
for (Interface toadd : toAddInterfaces) {
if (toadd.getName() != null && toadd.getName().equals(serviceInterface)) {
foundInterface = true;
touseInterface = toadd;
break;
}
}
}
} else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
for (RootElement iroot : rootElements) {
if (iroot instanceof Interface && ((Interface) iroot).getImplementationRef().equals(serviceInterface)) {
foundInterface = true;
touseInterface = (Interface) iroot;
break;
}
}
if (!foundInterface) {
for (Interface toadd : toAddInterfaces) {
if (toadd.getImplementationRef().equals(serviceInterface)) {
foundInterface = true;
touseInterface = toadd;
break;
}
}
}
}
if (!foundInterface) {
touseInterface = Bpmn2Factory.eINSTANCE.createInterface();
if (serviceInterface == null || serviceInterface.length() == 0) {
serviceInterface = fe.getId() + "_ServiceInterface";
if (serviceInterfaceFeature != null) {
fe.getAnyAttribute().set(serviceInterfaceFeature, serviceInterface);
}
}
touseInterface.setName(serviceInterface);
touseInterface.setImplementationRef(serviceInterface);
touseInterface.setId(fe.getId() + "_ServiceInterface");
toAddInterfaces.add(touseInterface);
}
if (serviceOperation != null) {
boolean foundOperation = false;
for (Operation oper : touseInterface.getOperations()) {
if (serviceImplementation != null && serviceImplementation.equals("Java")) {
if (oper.getName().equals(serviceOperation)) {
foundOperation = true;
break;
}
} else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
if (oper.getImplementationRef().equals(serviceOperation)) {
foundOperation = true;
break;
}
}
}
if (!foundOperation) {
Operation touseOperation = Bpmn2Factory.eINSTANCE.createOperation();
if (serviceOperation == null || serviceOperation.length() == 0) {
serviceOperation = fe.getId() + "_ServiceOperation";
if (serviceOperationFeature != null) {
fe.getAnyAttribute().set(serviceOperationFeature, serviceOperation);
}
}
touseOperation.setId(fe.getId() + "_ServiceOperation");
touseOperation.setName(serviceOperation);
touseOperation.setImplementationRef(serviceOperation);
Message message = Bpmn2Factory.eINSTANCE.createMessage();
message.setId(fe.getId() + "_InMessage");
ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition();
itemdef.setId(message.getId() + "Type");
message.setItemRef(itemdef);
toAddDefinitions.add(itemdef);
toAddMessages.add(message);
touseOperation.setInMessageRef(message);
touseInterface.getOperations().add(touseOperation);
((ServiceTask) fe).setOperationRef(touseOperation);
}
}
} else if (fe instanceof FlowElementsContainer) {
revisitServiceTasksExecute((FlowElementsContainer) fe, rootElements, toAddInterfaces, toAddMessages, toAddDefinitions);
}
}
}
use of com.google.container.v1.Operation in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method deleteSnapshot.
private static void deleteSnapshot(Snapshot snapshot) throws IOException, InterruptedException, ExecutionException {
try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
OperationFuture<Operation, Operation> operation = snapshotsClient.deleteAsync(PROJECT_ID, snapshot.getName());
operation.get();
}
}
use of com.google.container.v1.Operation in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method deleteImage.
private static void deleteImage(Image image) throws IOException, InterruptedException, ExecutionException {
try (ImagesClient imagesClient = ImagesClient.create()) {
OperationFuture<Operation, Operation> operation = imagesClient.deleteAsync(PROJECT_ID, image.getName());
operation.get();
}
}
use of com.google.container.v1.Operation in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method createSnapshot.
private static Snapshot createSnapshot(Disk srcDisk) throws IOException, InterruptedException, ExecutionException {
try (SnapshotsClient snapshotsClient = SnapshotsClient.create();
DisksClient disksClient = DisksClient.create()) {
Snapshot snapshot = Snapshot.newBuilder().setName("test-snap-" + UUID.randomUUID()).build();
OperationFuture<Operation, Operation> operation = disksClient.createSnapshotAsync(PROJECT_ID, ZONE, srcDisk.getName(), snapshot);
operation.get();
return snapshotsClient.get(PROJECT_ID, snapshot.getName());
}
}
use of com.google.container.v1.Operation in project java-docs-samples by GoogleCloudPlatform.
the class CreateWindowsServerInstanceInternalIp method createWindowsServerInstanceInternalIp.
// Creates a new Windows Server instance that has only an internal IP address.
public static void createWindowsServerInstanceInternalIp(String projectId, String zone, String instanceName, String networkLink, String subnetworkLink) throws IOException, ExecutionException, InterruptedException, TimeoutException {
// machineType - Machine type you want to create in following format:
// * "zones/{zone}/machineTypes/{type_name}". For example:
// * "zones/europe-west3-c/machineTypes/f1-micro"
// * You can find the list of available machine types using:
// * https://cloud.google.com/sdk/gcloud/reference/compute/machine-types/list
String machineType = "n1-standard-1";
// sourceImageFamily - Name of the public image family for Windows Server or SQL Server images.
// * https://cloud.google.com/compute/docs/images#os-compute-support
String sourceImageFamily = "windows-2012-r2";
// Instantiates a client.
try (InstancesClient instancesClient = InstancesClient.create()) {
AttachedDisk attachedDisk = AttachedDisk.newBuilder().setInitializeParams(AttachedDiskInitializeParams.newBuilder().setDiskSizeGb(64).setSourceImage(String.format("projects/windows-cloud/global/images/family/%s", sourceImageFamily)).build()).setAutoDelete(true).setBoot(true).setType(AttachedDisk.Type.PERSISTENT.toString()).build();
Instance instance = Instance.newBuilder().setName(instanceName).setMachineType(String.format("zones/%s/machineTypes/%s", zone, machineType)).addDisks(attachedDisk).addNetworkInterfaces(NetworkInterface.newBuilder().setName(networkLink).setSubnetwork(subnetworkLink).build()).build();
InsertInstanceRequest request = InsertInstanceRequest.newBuilder().setProject(projectId).setZone(zone).setInstanceResource(instance).build();
// Wait for the operation to complete.
Operation operation = instancesClient.insertAsync(request).get(3, TimeUnit.MINUTES);
if (operation.hasError()) {
System.out.printf("Error in creating instance %s", operation.getError());
return;
}
System.out.printf("Instance created %s", instanceName);
}
}
Aggregations