adding workflow related resource layer
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/2a2782a6 Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/2a2782a6 Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/2a2782a6 Branch: refs/heads/master Commit: 2a2782a60ab40f93677063c2c31cdf28c77ba487 Parents: ad01161 Author: Chathuri Wimalasena <[email protected]> Authored: Wed Feb 3 12:10:50 2016 -0500 Committer: Chathuri Wimalasena <[email protected]> Committed: Wed Feb 3 12:10:50 2016 -0500 ---------------------------------------------------------------------- .../main/resources/airavata-server.properties | 2 +- .../app/catalog/impl/WorkflowCatalogImpl.java | 57 +- .../core/app/catalog/model/Workflow.java | 124 ---- .../core/app/catalog/model/WorkflowInput.java | 167 ------ .../app/catalog/model/WorkflowInput_PK.java | 64 --- .../core/app/catalog/model/WorkflowOutput.java | 117 ---- .../app/catalog/model/WorkflowOutput_PK.java | 64 --- .../resources/WorkflowInputResource.java | 496 ---------------- .../resources/WorkflowOutputResource.java | 455 --------------- .../app/catalog/resources/WorkflowResource.java | 437 -------------- .../app/catalog/util/AppCatalogJPAUtils.java | 571 ++++++++----------- .../catalog/util/AppCatalogResourceType.java | 3 - .../util/AppCatalogThriftConversion.java | 39 -- .../workflow/catalog/model/ComponentStatus.java | 23 + .../core/workflow/catalog/model/Edge.java | 11 + .../core/workflow/catalog/model/Node.java | 12 + .../core/workflow/catalog/model/Port.java | 12 + .../workflow/catalog/model/WorkflowInput.java | 167 ++++++ .../catalog/model/WorkflowIntInput.java | 166 ------ .../workflow/catalog/model/WorkflowOutput.java | 7 +- .../resources/ComponentStatusResource.java | 340 +++++++++++ .../catalog/resources/EdgeResource.java | 380 ++++++++++++ .../catalog/resources/NodeResource.java | 402 +++++++++++++ .../catalog/resources/PortResource.java | 380 ++++++++++++ .../resources/WorkflowCatAbstractResource.java | 88 +++ .../resources/WorkflowCatalogResource.java | 90 +++ .../resources/WorkflowInputResource.java | 496 ++++++++++++++++ .../resources/WorkflowOutputResource.java | 489 ++++++++++++++++ .../catalog/resources/WorkflowResource.java | 437 ++++++++++++++ .../resources/WorkflowStatusResource.java | 369 ++++++++++++ .../catalog/utils/WorkflowCatalogJPAUtils.java | 270 +++++++++ .../utils/WorkflowCatalogQueryGenerator.java | 90 +++ .../utils/WorkflowCatalogResourceType.java | 33 ++ .../utils/WorkflowCatalogThriftConversion.java | 76 +++ .../catalog/utils/WorkflowCatalogUtils.java | 31 + .../src/main/resources/META-INF/persistence.xml | 15 +- .../src/main/resources/workflow-derby.sql | 11 +- .../src/main/resources/workflow-mysql.sql | 9 +- .../airavata/registry/cpi/WorkflowCatalog.java | 16 +- .../registry/cpi/WorkflowCatalogException.java | 36 ++ 40 files changed, 4547 insertions(+), 2505 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/configuration/server/src/main/resources/airavata-server.properties ---------------------------------------------------------------------- diff --git a/modules/configuration/server/src/main/resources/airavata-server.properties b/modules/configuration/server/src/main/resources/airavata-server.properties index 445449c..9275e56 100644 --- a/modules/configuration/server/src/main/resources/airavata-server.properties +++ b/modules/configuration/server/src/main/resources/airavata-server.properties @@ -173,7 +173,7 @@ job.notification.flags=abe ########################################################################### # Credential Store module Configuration ########################################################################### -start.credential.store=false +start.credential.store=true credential.store.keystore.url=/Users/chathuri/dev/airavata/credential-store/oa4mp/airavata_sym.jks credential.store.keystore.alias=airavata credential.store.keystore.password=airavata http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/WorkflowCatalogImpl.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/WorkflowCatalogImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/WorkflowCatalogImpl.java index f54419a..9c7df56 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/WorkflowCatalogImpl.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/WorkflowCatalogImpl.java @@ -24,11 +24,12 @@ package org.apache.airavata.registry.core.app.catalog.impl; import org.apache.airavata.model.Workflow; import org.apache.airavata.model.application.io.InputDataObjectType; import org.apache.airavata.model.application.io.OutputDataObjectType; -import org.apache.airavata.registry.core.app.catalog.resources.*; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogThriftConversion; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogUtils; +import org.apache.airavata.registry.core.workflow.catalog.resources.*; +import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogThriftConversion; +import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogUtils; import org.apache.airavata.registry.cpi.AppCatalogException; import org.apache.airavata.registry.cpi.WorkflowCatalog; +import org.apache.airavata.registry.cpi.WorkflowCatalogException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +42,7 @@ public class WorkflowCatalogImpl implements WorkflowCatalog { private final static Logger logger = LoggerFactory.getLogger(WorkflowCatalogImpl.class); @Override - public List<String> getAllWorkflows(String gatewayId) throws AppCatalogException { + public List<String> getAllWorkflows(String gatewayId) throws WorkflowCatalogException { List<String> workflowIds = new ArrayList<String>(); try { WorkflowResource resource = new WorkflowResource(); @@ -49,39 +50,39 @@ public class WorkflowCatalogImpl implements WorkflowCatalog { workflowIds = resource.getAllIds(); } catch (Exception e) { logger.error("Error while retrieving all the workflow template ids...", e); - throw new AppCatalogException(e); + throw new WorkflowCatalogException(e); } return workflowIds; } @Override - public Workflow getWorkflow(String workflowTemplateId) throws AppCatalogException { + public Workflow getWorkflow(String workflowTemplateId) throws WorkflowCatalogException { try { WorkflowResource resource = new WorkflowResource(); WorkflowResource wfResource = (WorkflowResource)resource.get(workflowTemplateId); - return AppCatalogThriftConversion.getWorkflow(wfResource); + return WorkflowCatalogThriftConversion.getWorkflow(wfResource); } catch (Exception e) { logger.error("Error while retrieving the workflow...", e); - throw new AppCatalogException(e); + throw new WorkflowCatalogException(e); } } @Override - public void deleteWorkflow(String workflowTemplateId) throws AppCatalogException { + public void deleteWorkflow(String workflowTemplateId) throws WorkflowCatalogException { try { WorkflowResource resource = new WorkflowResource(); resource.remove(workflowTemplateId); } catch (Exception e) { logger.error("Error while deleting the workflow...", e); - throw new AppCatalogException(e); + throw new WorkflowCatalogException(e); } } @Override - public String registerWorkflow(Workflow workflow, String gatewayId) throws AppCatalogException { + public String registerWorkflow(Workflow workflow, String gatewayId) throws WorkflowCatalogException { try { WorkflowResource resource = new WorkflowResource(); - resource.setWfTemplateId(AppCatalogUtils.getID(workflow.getName())); + resource.setWfTemplateId(WorkflowCatalogUtils.getID(workflow.getName())); resource.setWfName(workflow.getName()); resource.setGraph(workflow.getGraph()); resource.setGatewayId(gatewayId); @@ -121,12 +122,12 @@ public class WorkflowCatalogImpl implements WorkflowCatalog { return resource.getWfTemplateId(); } catch (Exception e) { logger.error("Error while saving the workflow...", e); - throw new AppCatalogException(e); + throw new WorkflowCatalogException(e); } } @Override - public void updateWorkflow(String workflowTemplateId, Workflow workflow) throws AppCatalogException { + public void updateWorkflow(String workflowTemplateId, Workflow workflow) throws WorkflowCatalogException { try { WorkflowResource resource = new WorkflowResource(); WorkflowResource existingWF = (WorkflowResource)resource.get(workflowTemplateId); @@ -141,8 +142,8 @@ public class WorkflowCatalogImpl implements WorkflowCatalog { for (InputDataObjectType input : existingwFInputs){ WorkflowInputResource wfInputResource = new WorkflowInputResource(); Map<String, String> ids = new HashMap<String, String>(); - ids.put(AppCatAbstractResource.WFInputConstants.WF_TEMPLATE_ID,existingWF.getWfTemplateId()); - ids.put(AppCatAbstractResource.WFInputConstants.INPUT_KEY,input.getName()); + ids.put(WorkflowCatAbstractResource.WorkflowInputConstants.WF_TEMPLATE_ID,existingWF.getWfTemplateId()); + ids.put(WorkflowCatAbstractResource.WorkflowInputConstants.INPUT_KEY,input.getName()); WorkflowInputResource existingInput = (WorkflowInputResource)wfInputResource.get(ids); existingInput.setWorkflowResource(existingWF); existingInput.setInputKey(input.getName()); @@ -161,8 +162,8 @@ public class WorkflowCatalogImpl implements WorkflowCatalog { for (OutputDataObjectType output : workflowOutputs){ WorkflowOutputResource outputResource = new WorkflowOutputResource(); Map<String, String> ids = new HashMap<String, String>(); - ids.put(AppCatAbstractResource.WFOutputConstants.WF_TEMPLATE_ID,existingWF.getWfTemplateId()); - ids.put(AppCatAbstractResource.WFOutputConstants.OUTPUT_KEY,output.getName()); + ids.put(WorkflowCatAbstractResource.WorkflowOutputConstants.WF_TEMPLATE_ID,existingWF.getWfTemplateId()); + ids.put(WorkflowCatAbstractResource.WorkflowOutputConstants.OUTPUT_KEY,output.getName()); WorkflowOutputResource existingOutput = (WorkflowOutputResource)outputResource.get(ids); existingOutput.setWorkflowResource(existingWF); existingOutput.setOutputKey(output.getName()); @@ -174,51 +175,51 @@ public class WorkflowCatalogImpl implements WorkflowCatalog { } } catch (Exception e) { logger.error("Error while updating the workflow...", e); - throw new AppCatalogException(e); + throw new WorkflowCatalogException(e); } } @Override - public String getWorkflowTemplateId(String workflowName) throws AppCatalogException { + public String getWorkflowTemplateId(String workflowName) throws WorkflowCatalogException { try { WorkflowResource resource = new WorkflowResource(); - List<AppCatalogResource> resourceList = resource.get(AppCatAbstractResource.WorkflowConstants.WF_NAME, workflowName); + List<WorkflowCatalogResource> resourceList = resource.get(WorkflowCatAbstractResource.WorkflowConstants.WORKFLOW_NAME, workflowName); if (resourceList != null && !resourceList.isEmpty()){ WorkflowResource wfResource = (WorkflowResource)resourceList.get(0); return wfResource.getWfTemplateId(); } } catch (Exception e) { logger.error("Error while retrieving the workflow with the workflow name...", e); - throw new AppCatalogException(e); + throw new WorkflowCatalogException(e); } return null; } @Override - public boolean isWorkflowExistWithName(String workflowName) throws AppCatalogException { + public boolean isWorkflowExistWithName(String workflowName) throws WorkflowCatalogException { try { WorkflowResource resource = new WorkflowResource(); - List<AppCatalogResource> resourceList = resource.get(AppCatAbstractResource.WorkflowConstants.WF_NAME, workflowName); + List<WorkflowCatalogResource> resourceList = resource.get(WorkflowCatAbstractResource.WorkflowConstants.WORKFLOW_NAME, workflowName); if (resourceList != null && !resourceList.isEmpty()){ return true; } } catch (Exception e) { logger.error("Error while retrieving the workflow with the workflow name...", e); - throw new AppCatalogException(e); + throw new WorkflowCatalogException(e); } return false; } @Override - public void updateWorkflowOutputs(String workflowTemplateId, List<OutputDataObjectType> workflowOutputs) throws AppCatalogException { + public void updateWorkflowOutputs(String workflowTemplateId, List<OutputDataObjectType> workflowOutputs) throws WorkflowCatalogException { WorkflowResource resource = new WorkflowResource(); WorkflowResource existingWF = (WorkflowResource)resource.get(workflowTemplateId); if (workflowOutputs != null && workflowOutputs.size() != 0) { for (OutputDataObjectType output : workflowOutputs) { WorkflowOutputResource outputResource = new WorkflowOutputResource(); Map<String, String> ids = new HashMap<String, String>(); - ids.put(AppCatAbstractResource.WFOutputConstants.WF_TEMPLATE_ID, existingWF.getWfTemplateId()); - ids.put(AppCatAbstractResource.WFOutputConstants.OUTPUT_KEY, output.getName()); + ids.put(WorkflowCatAbstractResource.WorkflowOutputConstants.WF_TEMPLATE_ID, existingWF.getWfTemplateId()); + ids.put(WorkflowCatAbstractResource.WorkflowOutputConstants.OUTPUT_KEY, output.getName()); WorkflowOutputResource existingOutput = (WorkflowOutputResource) outputResource.get(ids); existingOutput.setWorkflowResource(existingWF); existingOutput.setOutputKey(output.getName()); http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/Workflow.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/Workflow.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/Workflow.java deleted file mode 100644 index 27cb18c..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/Workflow.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.registry.core.app.catalog.model; - - -import javax.persistence.*; -import java.io.Serializable; -import java.sql.Timestamp; - -@Entity -@Table(name = "WORKFLOW") -public class Workflow implements Serializable { - - @Column(name = "WF_NAME") - private String wfName; - - @Column(name = "CREATED_USER") - private String createdUser; - - @Lob - @Column(name = "GRAPH") - private char[] graph; - - @Id - @Column(name = "WF_TEMPLATE_ID") - private String wfTemplateId; - - @Column(name = "CREATION_TIME") - private Timestamp creationTime; - - @Column(name = "UPDATE_TIME") - private Timestamp updateTime; - - @Lob - @Column(name = "IMAGE") - private byte[] image; - - @Column(name = "GATEWAY_ID") - private String gatewayId; - - public String getGatewayId() { - return gatewayId; - } - - public void setGatewayId(String gatewayId) { - this.gatewayId = gatewayId; - } - - public Timestamp getCreationTime() { - return creationTime; - } - - public void setCreationTime(Timestamp creationTime) { - this.creationTime = creationTime; - } - - public Timestamp getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Timestamp updateTime) { - this.updateTime = updateTime; - } - - public String getWfName() { - return wfName; - } - - public String getCreatedUser() { - return createdUser; - } - - public char[] getGraph() { - return graph; - } - - public String getWfTemplateId() { - return wfTemplateId; - } - - public void setWfName(String wfName) { - this.wfName=wfName; - } - - public void setCreatedUser(String createdUser) { - this.createdUser=createdUser; - } - - public void setGraph(char[] graph) { - this.graph=graph; - } - - public void setWfTemplateId(String wfTemplateId) { - this.wfTemplateId=wfTemplateId; - } - - public byte[] getImage() { - return image; - } - - public void setImage(byte[] image) { - this.image = image; - } -} - http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowInput.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowInput.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowInput.java deleted file mode 100644 index c559906..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowInput.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.registry.core.app.catalog.model; - - -import javax.persistence.*; -import java.io.Serializable; - -@Entity -@Table(name = "WORKFLOW_INPUT") -@IdClass(WorkflowInput_PK.class) -public class WorkflowInput implements Serializable { - @Id - @Column(name = "WF_TEMPLATE_ID") - private String wfTemplateId; - @Id - @Column(name = "INPUT_KEY") - private String inputKey; - @Lob - @Column(name = "INPUT_VALUE") - private char[] inputVal; - @Column(name = "DATA_TYPE") - private String dataType; - @Column(name = "METADATA") - private String metadata; - @Column(name = "APP_ARGUMENT") - private String appArgument; - @Column(name = "USER_FRIENDLY_DESC") - private String userFriendlyDesc; - @Column(name = "STANDARD_INPUT") - private boolean standardInput; - @Column(name = "INPUT_ORDER") - private int inputOrder; - @Column(name="IS_REQUIRED") - private boolean isRequired; - @Column(name="REQUIRED_TO_COMMANDLINE") - private boolean requiredToCMD; - @Column(name = "DATA_STAGED") - private boolean dataStaged; - - @ManyToOne(cascade = CascadeType.MERGE) - @JoinColumn(name = "WF_TEMPLATE_ID") - private Workflow workflow; - - public String getWfTemplateId() { - return wfTemplateId; - } - - public void setWfTemplateId(String wfTemplateId) { - this.wfTemplateId = wfTemplateId; - } - - public String getInputKey() { - return inputKey; - } - - public void setInputKey(String inputKey) { - this.inputKey = inputKey; - } - - public char[] getInputVal() { - return inputVal; - } - - public void setInputVal(char[] inputVal) { - this.inputVal = inputVal; - } - - public String getDataType() { - return dataType; - } - - public void setDataType(String dataType) { - this.dataType = dataType; - } - - public String getMetadata() { - return metadata; - } - - public void setMetadata(String metadata) { - this.metadata = metadata; - } - - public String getAppArgument() { - return appArgument; - } - - public void setAppArgument(String appArgument) { - this.appArgument = appArgument; - } - - public String getUserFriendlyDesc() { - return userFriendlyDesc; - } - - public void setUserFriendlyDesc(String userFriendlyDesc) { - this.userFriendlyDesc = userFriendlyDesc; - } - - public Workflow getWorkflow() { - return workflow; - } - - public void setWorkflow(Workflow workflow) { - this.workflow = workflow; - } - - public boolean isStandardInput() { - return standardInput; - } - - public void setStandardInput(boolean standardInput) { - this.standardInput = standardInput; - } - - public int getInputOrder() { - return inputOrder; - } - - public void setInputOrder(int inputOrder) { - this.inputOrder = inputOrder; - } - - public boolean isRequired() { - return isRequired; - } - - public void setRequired(boolean isRequired) { - this.isRequired = isRequired; - } - - public boolean isRequiredToCMD() { - return requiredToCMD; - } - - public void setRequiredToCMD(boolean requiredToCMD) { - this.requiredToCMD = requiredToCMD; - } - - public boolean isDataStaged() { - return dataStaged; - } - - public void setDataStaged(boolean dataStaged) { - this.dataStaged = dataStaged; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowInput_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowInput_PK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowInput_PK.java deleted file mode 100644 index d72799c..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowInput_PK.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.registry.core.app.catalog.model; - -import java.io.Serializable; - -public class WorkflowInput_PK implements Serializable { - private String wfTemplateId; - private String inputKey; - - public WorkflowInput_PK(String wfTemplateId, String inputKey) { - this.wfTemplateId = wfTemplateId; - this.inputKey = inputKey; - } - - public WorkflowInput_PK() { - ; - } - - @Override - public boolean equals(Object o) { - return false; - } - - @Override - public int hashCode() { - return 1; - } - - public String getWfTemplateId() { - return wfTemplateId; - } - - public void setWfTemplateId(String wfTemplateId) { - this.wfTemplateId = wfTemplateId; - } - - public String getInputKey() { - return inputKey; - } - - public void setInputKey(String inputKey) { - this.inputKey = inputKey; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowOutput.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowOutput.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowOutput.java deleted file mode 100644 index 3080b0f..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowOutput.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.registry.core.app.catalog.model; - - -import javax.persistence.*; -import java.io.Serializable; - -@Entity -@Table(name = "WORKFLOW_OUTPUT") -@IdClass(WorkflowOutput_PK.class) -public class WorkflowOutput implements Serializable { - @Id - @Column(name = "WF_TEMPLATE_ID") - private String wfTemplateId; - @Id - @Column(name = "OUTPUT_KEY") - private String outputKey; - @Lob - @Column(name = "OUTPUT_VALUE") - private char[] outputVal; - @Column(name = "DATA_TYPE") - private String dataType; - @Column(name = "VALIDITY_TYPE") - private String validityType; - @Column(name = "DATA_MOVEMENT") - private boolean dataMovement; - @Column(name = "DATA_NAME_LOCATION") - private String dataNameLocation; - - @ManyToOne(cascade= CascadeType.MERGE) - @JoinColumn(name = "WF_TEMPLATE_ID") - private Workflow workflow; - - public String getWfTemplateId() { - return wfTemplateId; - } - - public void setWfTemplateId(String wfTemplateId) { - this.wfTemplateId = wfTemplateId; - } - - public String getDataType() { - return dataType; - } - - public void setDataType(String dataType) { - this.dataType = dataType; - } - - public Workflow getWorkflow() { - return workflow; - } - - public void setWorkflow(Workflow workflow) { - this.workflow = workflow; - } - - public String getOutputKey() { - return outputKey; - } - - public void setOutputKey(String outputKey) { - this.outputKey = outputKey; - } - - public char[] getOutputVal() { - return outputVal; - } - - public void setOutputVal(char[] outputVal) { - this.outputVal = outputVal; - } - - public String getValidityType() { - return validityType; - } - - public void setValidityType(String validityType) { - this.validityType = validityType; - } - - public boolean isDataMovement() { - return dataMovement; - } - - public void setDataMovement(boolean dataMovement) { - this.dataMovement = dataMovement; - } - - public String getDataNameLocation() { - return dataNameLocation; - } - - public void setDataNameLocation(String dataNameLocation) { - this.dataNameLocation = dataNameLocation; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowOutput_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowOutput_PK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowOutput_PK.java deleted file mode 100644 index 183afe8..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/WorkflowOutput_PK.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.registry.core.app.catalog.model; - -import java.io.Serializable; - -public class WorkflowOutput_PK implements Serializable { - private String wfTemplateId; - private String outputKey; - - public WorkflowOutput_PK(String wfTemplateId, String outputKey) { - this.wfTemplateId = wfTemplateId; - this.outputKey = outputKey; - } - - public WorkflowOutput_PK() { - ; - } - - @Override - public boolean equals(Object o) { - return false; - } - - @Override - public int hashCode() { - return 1; - } - - public String getWfTemplateId() { - return wfTemplateId; - } - - public void setWfTemplateId(String wfTemplateId) { - this.wfTemplateId = wfTemplateId; - } - - public String getOutputKey() { - return outputKey; - } - - public void setOutputKey(String outputKey) { - this.outputKey = outputKey; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputResource.java deleted file mode 100644 index 94eb02b..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputResource.java +++ /dev/null @@ -1,496 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.airavata.registry.core.app.catalog.resources; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.registry.core.app.catalog.model.Workflow; -import org.apache.airavata.registry.core.app.catalog.model.WorkflowInput; -import org.apache.airavata.registry.core.app.catalog.model.WorkflowInput_PK; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType; -import org.apache.airavata.registry.cpi.AppCatalogException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.EntityManager; -import javax.persistence.Query; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class WorkflowInputResource extends AppCatAbstractResource { - - private final static Logger logger = LoggerFactory.getLogger(WorkflowInputResource.class); - - private String wfTemplateId; - private String inputKey; - private String dataType; - private String inputVal; - private String metadata; - private String appArgument; - private String userFriendlyDesc; - private boolean standardInput; - private int inputOrder; - private boolean isRequired; - private boolean requiredToCMD; - private boolean dataStaged; - - private WorkflowResource workflowResource; - - public void remove(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map) { - ids = (HashMap) identifier; - } else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT); - generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, ids.get(WFInputConstants.WF_TEMPLATE_ID)); - generator.setParameter(WFInputConstants.INPUT_KEY, ids.get(WFInputConstants.INPUT_KEY)); - Query q = generator.deleteQuery(em); - q.executeUpdate(); - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - public AppCatalogResource get(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map) { - ids = (HashMap<String, String>) identifier; - } else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT); - generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, ids.get(WFInputConstants.WF_TEMPLATE_ID)); - generator.setParameter(WFInputConstants.INPUT_KEY, ids.get(WFInputConstants.INPUT_KEY)); - Query q = generator.selectQuery(em); - WorkflowInput workflowInput = (WorkflowInput) q.getSingleResult(); - WorkflowInputResource workflowInputResource = - (WorkflowInputResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW_INPUT - , workflowInput); - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - return workflowInputResource; - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException { - List<AppCatalogResource> wfInputResources = new ArrayList<AppCatalogResource>(); - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - Query q; - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT); - List results; - if (fieldName.equals(WFInputConstants.WF_TEMPLATE_ID)) { - generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - WorkflowInput workflowInput = (WorkflowInput) result; - WorkflowInputResource workflowInputResource = - (WorkflowInputResource) AppCatalogJPAUtils.getResource( - AppCatalogResourceType.WORKFLOW_INPUT, workflowInput); - wfInputResources.add(workflowInputResource); - } - } - } else if (fieldName.equals(WFInputConstants.INPUT_KEY)) { - generator.setParameter(WFInputConstants.INPUT_KEY, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - WorkflowInput workflowInput = (WorkflowInput) result; - WorkflowInputResource workflowInputResource = - (WorkflowInputResource) AppCatalogJPAUtils.getResource( - AppCatalogResourceType.WORKFLOW_INPUT, workflowInput); - wfInputResources.add(workflowInputResource); - } - } - } else if (fieldName.equals(WFInputConstants.DATA_TYPE)) { - generator.setParameter(WFInputConstants.DATA_TYPE, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - WorkflowInput workflowInput = (WorkflowInput) result; - WorkflowInputResource workflowInputResource = - (WorkflowInputResource) AppCatalogJPAUtils.getResource( - AppCatalogResourceType.WORKFLOW_INPUT, workflowInput); - wfInputResources.add(workflowInputResource); - } - } - } else { - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - logger.error("Unsupported field name for WFInput Resource.", new IllegalArgumentException()); - throw new IllegalArgumentException("Unsupported field name for WFInput Resource."); - } - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return wfInputResources; - } - - public List<AppCatalogResource> getAll() throws AppCatalogException { - return null; - } - - public List<String> getAllIds() throws AppCatalogException { - return null; - } - - public List<String> getIds(String fieldName, Object value) throws AppCatalogException { - List<String> wfInputResourceIDs = new ArrayList<String>(); - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - Query q; - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT); - List results; - if (fieldName.equals(WFInputConstants.WF_TEMPLATE_ID)) { - generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - WorkflowInput workflowInput = (WorkflowInput) result; - wfInputResourceIDs.add(workflowInput.getWfTemplateId()); - } - } - } else if (fieldName.equals(WFInputConstants.INPUT_KEY)) { - generator.setParameter(WFInputConstants.INPUT_KEY, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - WorkflowInput workflowInput = (WorkflowInput) result; - wfInputResourceIDs.add(workflowInput.getWfTemplateId()); - } - } - } else if (fieldName.equals(WFInputConstants.DATA_TYPE)) { - generator.setParameter(WFInputConstants.DATA_TYPE, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - WorkflowInput workflowInput = (WorkflowInput) result; - wfInputResourceIDs.add(workflowInput.getWfTemplateId()); - } - } - } else { - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - logger.error("Unsupported field name for WFInput resource.", new IllegalArgumentException()); - throw new IllegalArgumentException("Unsupported field name for WFInput Resource."); - } - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return wfInputResourceIDs; - } - - public void save() throws AppCatalogException { - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - WorkflowInput existingWFInput = em.find(WorkflowInput.class, new WorkflowInput_PK(wfTemplateId, inputKey)); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - WorkflowInput workflowInput; - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - if (existingWFInput == null) { - workflowInput = new WorkflowInput(); - } else { - workflowInput=existingWFInput; - } - workflowInput.setWfTemplateId(wfTemplateId); - Workflow workflow = em.find(Workflow.class, wfTemplateId); - workflowInput.setWorkflow(workflow); - workflowInput.setDataType(dataType); - workflowInput.setInputKey(inputKey); - if (inputVal != null){ - workflowInput.setInputVal(inputVal.toCharArray()); - } - workflowInput.setMetadata(metadata); - workflowInput.setAppArgument(appArgument); - workflowInput.setUserFriendlyDesc(userFriendlyDesc); - workflowInput.setStandardInput(standardInput); - workflowInput.setRequiredToCMD(requiredToCMD); - workflowInput.setRequired(isRequired); - workflowInput.setDataStaged(dataStaged); - if (existingWFInput == null) { - em.persist(workflowInput); - } else { - em.merge(workflowInput); - } - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - public boolean isExists(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map) { - ids = (HashMap<String, String>) identifier; - } else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - WorkflowInput workflowInput = em.find(WorkflowInput.class, new WorkflowInput_PK( - ids.get(WFInputConstants.WF_TEMPLATE_ID), - ids.get(WFInputConstants.INPUT_KEY))); - - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - return workflowInput != null; - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - public String getWfTemplateId() { - return wfTemplateId; - } - - public void setWfTemplateId(String wfTemplateId) { - this.wfTemplateId = wfTemplateId; - } - - public String getInputKey() { - return inputKey; - } - - public void setInputKey(String inputKey) { - this.inputKey = inputKey; - } - - public String getDataType() { - return dataType; - } - - public void setDataType(String dataType) { - this.dataType = dataType; - } - - public String getInputVal() { - return inputVal; - } - - public void setInputVal(String inputVal) { - this.inputVal = inputVal; - } - - public String getMetadata() { - return metadata; - } - - public void setMetadata(String metadata) { - this.metadata = metadata; - } - - public String getAppArgument() { - return appArgument; - } - - public void setAppArgument(String appArgument) { - this.appArgument = appArgument; - } - - public String getUserFriendlyDesc() { - return userFriendlyDesc; - } - - public void setUserFriendlyDesc(String userFriendlyDesc) { - this.userFriendlyDesc = userFriendlyDesc; - } - - public WorkflowResource getWorkflowResource() { - return workflowResource; - } - - public void setWorkflowResource(WorkflowResource workflowResource) { - this.workflowResource = workflowResource; - } - - public boolean isStandardInput() { - return standardInput; - } - - public void setStandardInput(boolean standardInput) { - this.standardInput = standardInput; - } - - public int getInputOrder() { - return inputOrder; - } - - public void setInputOrder(int inputOrder) { - this.inputOrder = inputOrder; - } - - public boolean getRequired() { - return isRequired; - } - - public void setRequired(boolean required) { - this.isRequired = required; - } - - public boolean getRequiredToCMD() { - return requiredToCMD; - } - - public void setRequiredToCMD(boolean requiredToCMD) { - this.requiredToCMD = requiredToCMD; - } - - public boolean isDataStaged() { - return dataStaged; - } - - public void setDataStaged(boolean dataStaged) { - this.dataStaged = dataStaged; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputResource.java deleted file mode 100644 index f216731..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputResource.java +++ /dev/null @@ -1,455 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.airavata.registry.core.app.catalog.resources; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.registry.core.app.catalog.model.Workflow; -import org.apache.airavata.registry.core.app.catalog.model.WorkflowOutput; -import org.apache.airavata.registry.core.app.catalog.model.WorkflowOutput_PK; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType; -import org.apache.airavata.registry.cpi.AppCatalogException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.EntityManager; -import javax.persistence.Query; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class WorkflowOutputResource extends AppCatAbstractResource { - private final static Logger logger = LoggerFactory.getLogger(WorkflowOutputResource.class); - - private String wfTemplateId; - private String outputKey; - private String outputVal; - private String dataType; - private String validityType; - private boolean dataMovement; - private String dataNameLocation; - - private WorkflowResource workflowResource; - - public void remove(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map) { - ids = (HashMap) identifier; - } else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT); - generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, ids.get(WFOutputConstants.WF_TEMPLATE_ID)); - generator.setParameter(WFOutputConstants.OUTPUT_KEY, ids.get(WFOutputConstants.OUTPUT_KEY)); - Query q = generator.deleteQuery(em); - q.executeUpdate(); - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - public AppCatalogResource get(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map) { - ids = (HashMap) identifier; - } else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT); - generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, ids.get(WFOutputConstants.WF_TEMPLATE_ID)); - generator.setParameter(WFOutputConstants.OUTPUT_KEY, ids.get(WFOutputConstants.OUTPUT_KEY)); - Query q = generator.selectQuery(em); - WorkflowOutput wfOutput = (WorkflowOutput) q.getSingleResult(); - WorkflowOutputResource workflowOutputResource = - (WorkflowOutputResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW_OUTPUT - , wfOutput); - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - return workflowOutputResource; - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException { - List<AppCatalogResource> wfOutputResources = new ArrayList<AppCatalogResource>(); - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - Query q; - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT); - List results; - if (fieldName.equals(WFOutputConstants.WF_TEMPLATE_ID)) { - generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - WorkflowOutput wfOutput = (WorkflowOutput) result; - WorkflowOutputResource workflowOutputResource = - (WorkflowOutputResource) AppCatalogJPAUtils.getResource( - AppCatalogResourceType.WORKFLOW_OUTPUT, wfOutput); - wfOutputResources.add(workflowOutputResource); - } - } - } else if (fieldName.equals(WFOutputConstants.OUTPUT_KEY)) { - generator.setParameter(WFOutputConstants.OUTPUT_KEY, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - WorkflowOutput workflowOutput = (WorkflowOutput) result; - WorkflowOutputResource workflowOutputResource = - (WorkflowOutputResource) AppCatalogJPAUtils.getResource( - AppCatalogResourceType.WORKFLOW_OUTPUT, workflowOutput); - wfOutputResources.add(workflowOutputResource); - } - } - } else if (fieldName.equals(WFOutputConstants.DATA_TYPE)) { - generator.setParameter(WFOutputConstants.DATA_TYPE, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - WorkflowOutput workflowOutput = (WorkflowOutput) result; - WorkflowOutputResource workflowOutputResource = - (WorkflowOutputResource) AppCatalogJPAUtils.getResource( - AppCatalogResourceType.WORKFLOW_OUTPUT, workflowOutput); - wfOutputResources.add(workflowOutputResource); - } - } - } else { - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - logger.error("Unsupported field name for WF Output Resource.", new IllegalArgumentException()); - throw new IllegalArgumentException("Unsupported field name for WF Output Resource."); - } - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return wfOutputResources; - } - - public List<AppCatalogResource> getAll() throws AppCatalogException { - return null; - } - - public List<String> getAllIds() throws AppCatalogException { - return null; - } - - public List<String> getIds(String fieldName, Object value) throws AppCatalogException { - List<String> wfOutputResourceIDs = new ArrayList<String>(); - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - Query q; - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT); - List results; - if (fieldName.equals(WFOutputConstants.WF_TEMPLATE_ID)) { - generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - WorkflowOutput workflowOutput = (WorkflowOutput) result; - wfOutputResourceIDs.add(workflowOutput.getWfTemplateId()); - } - } - } - if (fieldName.equals(WFOutputConstants.OUTPUT_KEY)) { - generator.setParameter(WFOutputConstants.OUTPUT_KEY, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - WorkflowOutput workflowOutput = (WorkflowOutput) result; - wfOutputResourceIDs.add(workflowOutput.getWfTemplateId()); - } - } - } else if (fieldName.equals(WFOutputConstants.DATA_TYPE)) { - generator.setParameter(WFOutputConstants.DATA_TYPE, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - WorkflowOutput workflowOutput = (WorkflowOutput) result; - wfOutputResourceIDs.add(workflowOutput.getWfTemplateId()); - } - } - } else { - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - logger.error("Unsupported field name for WF Output resource.", new IllegalArgumentException()); - throw new IllegalArgumentException("Unsupported field name for WF Output Resource."); - } - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return wfOutputResourceIDs; - } - - public void save() throws AppCatalogException { - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - WorkflowOutput existingWorkflowOutput = em.find(WorkflowOutput.class, - new WorkflowOutput_PK(wfTemplateId, outputKey)); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - if (existingWorkflowOutput != null) { - existingWorkflowOutput.setWfTemplateId(wfTemplateId); - Workflow workflow = em.find(Workflow.class, wfTemplateId); - existingWorkflowOutput.setWorkflow(workflow); - existingWorkflowOutput.setDataType(dataType); - existingWorkflowOutput.setOutputKey(outputKey); - if (outputVal != null){ - existingWorkflowOutput.setOutputVal(outputVal.toCharArray()); - } - existingWorkflowOutput.setValidityType(validityType); - existingWorkflowOutput.setDataMovement(dataMovement); - existingWorkflowOutput.setDataNameLocation(dataNameLocation); - em.merge(existingWorkflowOutput); - } else { - WorkflowOutput workflowOutput = new WorkflowOutput(); - workflowOutput.setWfTemplateId(wfTemplateId); - Workflow workflow = em.find(Workflow.class, wfTemplateId); - workflowOutput.setWorkflow(workflow); - workflowOutput.setDataType(dataType); - workflowOutput.setOutputKey(outputKey); - if (outputVal != null){ - workflowOutput.setOutputVal(outputVal.toCharArray()); - } - workflowOutput.setValidityType(validityType); - workflowOutput.setDataMovement(dataMovement); - workflowOutput.setDataNameLocation(dataNameLocation); - em.persist(workflowOutput); - } - em.getTransaction().commit(); - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - public boolean isExists(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map) { - ids = (HashMap) identifier; - } else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - WorkflowOutput workflowOutput = em.find(WorkflowOutput.class, new WorkflowOutput_PK( - ids.get(WFOutputConstants.WF_TEMPLATE_ID), - ids.get(WFOutputConstants.OUTPUT_KEY))); - - if (em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - return workflowOutput != null; - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - public String getWfTemplateId() { - return wfTemplateId; - } - - public void setWfTemplateId(String wfTemplateId) { - this.wfTemplateId = wfTemplateId; - } - - public String getOutputKey() { - return outputKey; - } - - public void setOutputKey(String outputKey) { - this.outputKey = outputKey; - } - - public String getOutputVal() { - return outputVal; - } - - public void setOutputVal(String outputVal) { - this.outputVal = outputVal; - } - - public String getDataType() { - return dataType; - } - - public void setDataType(String dataType) { - this.dataType = dataType; - } - - public WorkflowResource getWorkflowResource() { - return workflowResource; - } - - public void setWorkflowResource(WorkflowResource workflowResource) { - this.workflowResource = workflowResource; - } - - public String getValidityType() { - return validityType; - } - - public void setValidityType(String validityType) { - this.validityType = validityType; - } - - public boolean isDataMovement() { - return dataMovement; - } - - public void setDataMovement(boolean dataMovement) { - this.dataMovement = dataMovement; - } - - public String getDataNameLocation() { - return dataNameLocation; - } - - public void setDataNameLocation(String dataNameLocation) { - this.dataNameLocation = dataNameLocation; - } -}
