You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2016/02/03 18:09:03 UTC
[1/5] airavata git commit: adding workflow related resource layer
Repository: airavata
Updated Branches:
refs/heads/develop ad0116126 -> 2a2782a60
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogQueryGenerator.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogQueryGenerator.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogQueryGenerator.java
new file mode 100644
index 0000000..d3a5a42
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogQueryGenerator.java
@@ -0,0 +1,90 @@
+/*
+ *
+ * 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.workflow.catalog.utils;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.HashMap;
+import java.util.Map;
+
+public class WorkflowCatalogQueryGenerator {
+ private String tableName;
+ private Map<String,Object> matches=new HashMap<String, Object>();
+ private static final String SELECT_OBJ="p";
+ private static final String DELETE_OBJ="p";
+ private static final String TABLE_OBJ="p";
+
+ public WorkflowCatalogQueryGenerator(String tableName, Object[]... params) {
+ setTableName(tableName);
+ for (Object[] param : params) {
+ addMatch(param[0].toString(), param[1]);
+ }
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+ public void addMatch(String colName, Object matchValue){
+ matches.put(colName, matchValue);
+ }
+
+ public void setParameter(String colName, Object matchValue){
+ addMatch(colName, matchValue);
+ }
+
+ public Query selectQuery(EntityManager entityManager){
+ String queryString="SELECT "+ SELECT_OBJ + " FROM " +getTableName()+" "+TABLE_OBJ;
+ return generateQueryWithParameters(entityManager, queryString);
+ }
+
+ public Query deleteQuery(EntityManager entityManager){
+ String queryString="Delete FROM "+getTableName()+" "+TABLE_OBJ;
+ return generateQueryWithParameters(entityManager, queryString);
+ }
+
+ private Query generateQueryWithParameters(EntityManager entityManager,
+ String queryString) {
+ Map<String,Object> queryParameters=new HashMap<String, Object>();
+ if (matches.size()>0){
+ String matchString = "";
+ int paramCount=0;
+ for (String colName : matches.keySet()) {
+ String paramName="param"+paramCount;
+ queryParameters.put(paramName, matches.get(colName));
+ if (!matchString.equals("")){
+ matchString+=" AND ";
+ }
+ matchString+=TABLE_OBJ+"."+colName+" =:"+paramName;
+ paramCount++;
+ }
+ queryString+=" WHERE "+matchString;
+ }
+ Query query = entityManager.createQuery(queryString);
+ for (String paramName : queryParameters.keySet()) {
+ query.setParameter(paramName, queryParameters.get(paramName));
+ }
+ return query;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogResourceType.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogResourceType.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogResourceType.java
new file mode 100644
index 0000000..2af0151
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogResourceType.java
@@ -0,0 +1,33 @@
+/*
+ *
+ * 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.workflow.catalog.utils;
+
+public enum WorkflowCatalogResourceType {
+ WORKFLOW,
+ WORKFLOW_INPUT,
+ WORKFLOW_OUTPUT,
+ WORKFLOW_STATUS,
+ COMPONENT_STATUS,
+ NODE,
+ EDGE,
+ PORT
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogThriftConversion.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogThriftConversion.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogThriftConversion.java
new file mode 100644
index 0000000..68b42e3
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogThriftConversion.java
@@ -0,0 +1,76 @@
+/*
+ *
+ * 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.workflow.catalog.utils;
+
+import org.apache.airavata.model.Workflow;
+import org.apache.airavata.model.application.io.DataType;
+import org.apache.airavata.model.application.io.InputDataObjectType;
+import org.apache.airavata.registry.core.workflow.catalog.resources.WorkflowCatAbstractResource;
+import org.apache.airavata.registry.core.workflow.catalog.resources.WorkflowCatalogResource;
+import org.apache.airavata.registry.core.workflow.catalog.resources.WorkflowInputResource;
+import org.apache.airavata.registry.core.workflow.catalog.resources.WorkflowResource;
+import org.apache.airavata.registry.cpi.WorkflowCatalogException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class WorkflowCatalogThriftConversion {
+
+ public static InputDataObjectType getWorkflowInput (WorkflowInputResource resource){
+ InputDataObjectType input = new InputDataObjectType();
+ input.setName(resource.getInputKey());
+ input.setApplicationArgument(resource.getAppArgument());
+ input.setInputOrder(resource.getInputOrder());
+ input.setType(DataType.valueOf(resource.getDataType()));
+ input.setMetaData(resource.getMetadata());
+ input.setUserFriendlyDescription(resource.getUserFriendlyDesc());
+ input.setIsRequired(resource.getRequired());
+ input.setRequiredToAddedToCommandLine(resource.getRequiredToCMD());
+ input.setDataStaged(resource.isDataStaged());
+ return input;
+ }
+
+ public static List<InputDataObjectType> getWFInputs(List<WorkflowCatalogResource> resources){
+ List<InputDataObjectType> inputResources = new ArrayList<InputDataObjectType>();
+ if (resources != null && !resources.isEmpty()){
+ for (WorkflowCatalogResource resource : resources){
+ inputResources.add(getWorkflowInput((WorkflowInputResource) resource));
+ }
+ }
+ return inputResources;
+ }
+
+ public static Workflow getWorkflow (WorkflowResource resource) throws WorkflowCatalogException {
+ Workflow workflow = new Workflow();
+ workflow.setTemplateId(resource.getWfTemplateId());
+ workflow.setGraph(resource.getGraph());
+ workflow.setName(resource.getWfName());
+ if (resource.getImage() != null){
+ workflow.setImage(resource.getImage().getBytes());
+ }
+ WorkflowInputResource inputResource = new WorkflowInputResource();
+ List<WorkflowCatalogResource> resources = inputResource.get(WorkflowCatAbstractResource.WorkflowInputConstants.WF_TEMPLATE_ID, resource.getWfTemplateId());
+ workflow.setWorkflowInputs(getWFInputs(resources));
+
+ return workflow;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogUtils.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogUtils.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogUtils.java
new file mode 100644
index 0000000..dce8263
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogUtils.java
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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.workflow.catalog.utils;
+
+import java.util.UUID;
+
+public class WorkflowCatalogUtils {
+ public static String getID (String name){
+ String pro = name.replaceAll("\\s", "");
+ return pro + "_" + UUID.randomUUID();
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml b/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml
index da544c9..7d2a15a 100644
--- a/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml
+++ b/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml
@@ -61,9 +61,6 @@
<class>org.apache.airavata.registry.core.app.catalog.model.JobManagerCommand</class>
<class>org.apache.airavata.registry.core.app.catalog.model.LocalSubmission</class>
<class>org.apache.airavata.registry.core.app.catalog.model.LocalDataMovement</class>
- <class>org.apache.airavata.registry.core.app.catalog.model.Workflow</class>
- <class>org.apache.airavata.registry.core.app.catalog.model.WorkflowInput</class>
- <class>org.apache.airavata.registry.core.app.catalog.model.WorkflowOutput</class>
<class>org.apache.airavata.registry.core.app.catalog.model.Configuration</class>
<class>org.apache.airavata.registry.core.app.catalog.model.GatewayClientCredential</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
@@ -104,4 +101,16 @@
<class>org.apache.airavata.registry.core.data.catalog.model.Configuration</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
</persistence-unit>
+ <persistence-unit name="workflowcatalog_data">
+ <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+ <class>org.apache.airavata.registry.core.workflow.catalog.model.Workflow</class>
+ <class>org.apache.airavata.registry.core.workflow.catalog.model.WorkflowInput</class>
+ <class>org.apache.airavata.registry.core.workflow.catalog.model.WorkflowOutput</class>
+ <class>org.apache.airavata.registry.core.workflow.catalog.model.Edge</class>
+ <class>org.apache.airavata.registry.core.workflow.catalog.model.Node</class>
+ <class>org.apache.airavata.registry.core.workflow.catalog.model.Port</class>
+ <class>org.apache.airavata.registry.core.workflow.catalog.model.ComponentStatus</class>
+ <class>org.apache.airavata.registry.core.workflow.catalog.model.WorkflowStatus</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ </persistence-unit>
</persistence>
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/resources/workflow-derby.sql
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/resources/workflow-derby.sql b/modules/registry/registry-core/src/main/resources/workflow-derby.sql
index f2af1be..8c590f8 100644
--- a/modules/registry/registry-core/src/main/resources/workflow-derby.sql
+++ b/modules/registry/registry-core/src/main/resources/workflow-derby.sql
@@ -36,7 +36,7 @@ CREATE TABLE WORKFLOW_INPUT
(
TEMPLATE_ID VARCHAR(255),
INPUT_KEY VARCHAR(255),
- INPUT_VALUE VARCHAR(255),
+ INPUT_VALUE CLOB,
DATA_TYPE VARCHAR(255),
METADATA VARCHAR(255),
APP_ARGUMENT VARCHAR(255),
@@ -70,10 +70,12 @@ CREATE TABLE WORKFLOW_OUTPUT
CREATE TABLE COMPONENT_STATUS
(
STATUS_ID VARCHAR (255) NOT NULL,
+ TEMPLATE_ID VARCHAR (255) NOT NULL,
STATE VARCHAR(255),
REASON VARCHAR(255),
- PRIMARY KEY (STATUS_ID)
UPDATE_TIME timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (STATUS_ID)
+ FOREIGN KEY (TEMPLATE_ID) REFERENCES WORKFLOW(TEMPLATE_ID) ON DELETE CASCADE
);
CREATE TABLE WORKFLOW_STATUS
@@ -83,7 +85,7 @@ CREATE TABLE WORKFLOW_STATUS
STATE VARCHAR(255),
REASON VARCHAR(255),
UPDATE_TIME timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- PRIMARY KEY (STATUS_ID, COMPONENT_ID),
+ PRIMARY KEY (STATUS_ID, TEMPLATE_ID),
FOREIGN KEY (TEMPLATE_ID) REFERENCES WORKFLOW(TEMPLATE_ID) ON DELETE CASCADE
);
@@ -94,6 +96,7 @@ CREATE TABLE EDGE
NAME VARCHAR (255),
COMPONENT_STATUS_ID VARCHAR(255),
DESCRIPTION VARCHAR(500),
+ CREATED_TIME timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EDGE_ID, TEMPLATE_ID),
FOREIGN KEY (TEMPLATE_ID) REFERENCES WORKFLOW(TEMPLATE_ID) ON DELETE CASCADE
);
@@ -105,6 +108,7 @@ CREATE TABLE PORT
NAME VARCHAR (255),
COMPONENT_STATUS_ID VARCHAR(255),
DESCRIPTION VARCHAR(500),
+ CREATED_TIME timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (PORT_ID, TEMPLATE_ID),
FOREIGN KEY (TEMPLATE_ID) REFERENCES WORKFLOW(TEMPLATE_ID) ON DELETE CASCADE
);
@@ -118,6 +122,7 @@ CREATE TABLE NODE
APPLICATION_NAME VARCHAR (255),
COMPONENT_STATUS_ID VARCHAR(255),
DESCRIPTION VARCHAR(500),
+ CREATED_TIME timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (NODE_ID, TEMPLATE_ID),
FOREIGN KEY (TEMPLATE_ID) REFERENCES WORKFLOW(TEMPLATE_ID) ON DELETE CASCADE
);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/resources/workflow-mysql.sql
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/resources/workflow-mysql.sql b/modules/registry/registry-core/src/main/resources/workflow-mysql.sql
index d723343..3527d60 100644
--- a/modules/registry/registry-core/src/main/resources/workflow-mysql.sql
+++ b/modules/registry/registry-core/src/main/resources/workflow-mysql.sql
@@ -54,7 +54,7 @@ CREATE TABLE WORKFLOW_OUTPUT
(
TEMPLATE_ID VARCHAR(255),
OUTPUT_KEY VARCHAR(255),
- OUTPUT_VALUE VARCHAR(255),
+ OUTPUT_VALUE LONGTEXT,
DATA_TYPE VARCHAR(255),
IS_REQUIRED SMALLINT,
REQUIRED_TO_COMMANDLINE SMALLINT,
@@ -70,10 +70,12 @@ CREATE TABLE WORKFLOW_OUTPUT
CREATE TABLE COMPONENT_STATUS
(
STATUS_ID VARCHAR (255) NOT NULL,
+ TEMPLATE_ID VARCHAR (255) NOT NULL,
STATE VARCHAR(255),
REASON VARCHAR(255),
UPDATE_TIME timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (STATUS_ID)
+ FOREIGN KEY (TEMPLATE_ID) REFERENCES WORKFLOW(TEMPLATE_ID) ON DELETE CASCADE
);
CREATE TABLE WORKFLOW_STATUS
@@ -83,7 +85,7 @@ CREATE TABLE WORKFLOW_STATUS
STATE VARCHAR(255),
REASON VARCHAR(255),
UPDATE_TIME timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- PRIMARY KEY (STATUS_ID, COMPONENT_ID),
+ PRIMARY KEY (STATUS_ID, TEMPLATE_ID),
FOREIGN KEY (TEMPLATE_ID) REFERENCES WORKFLOW(TEMPLATE_ID) ON DELETE CASCADE
);
@@ -94,6 +96,7 @@ CREATE TABLE EDGE
NAME VARCHAR (255),
COMPONENT_STATUS_ID VARCHAR(255),
DESCRIPTION VARCHAR(500),
+ CREATED_TIME timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EDGE_ID, TEMPLATE_ID),
FOREIGN KEY (TEMPLATE_ID) REFERENCES WORKFLOW(TEMPLATE_ID) ON DELETE CASCADE
);
@@ -105,6 +108,7 @@ CREATE TABLE PORT
NAME VARCHAR (255),
COMPONENT_STATUS_ID VARCHAR(255),
DESCRIPTION VARCHAR(500),
+ CREATED_TIME timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (PORT_ID, TEMPLATE_ID),
FOREIGN KEY (TEMPLATE_ID) REFERENCES WORKFLOW(TEMPLATE_ID) ON DELETE CASCADE
);
@@ -118,6 +122,7 @@ CREATE TABLE NODE
APPLICATION_NAME VARCHAR (255),
COMPONENT_STATUS_ID VARCHAR(255),
DESCRIPTION VARCHAR(500),
+ CREATED_TIME timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (NODE_ID, TEMPLATE_ID),
FOREIGN KEY (TEMPLATE_ID) REFERENCES WORKFLOW(TEMPLATE_ID) ON DELETE CASCADE
);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/WorkflowCatalog.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/WorkflowCatalog.java b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/WorkflowCatalog.java
index f465e7e..34c8ff6 100644
--- a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/WorkflowCatalog.java
+++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/WorkflowCatalog.java
@@ -28,19 +28,19 @@ import java.util.List;
public interface WorkflowCatalog {
- public List<String> getAllWorkflows(String gatewayId) throws AppCatalogException;
+ public List<String> getAllWorkflows(String gatewayId) throws WorkflowCatalogException;
- public org.apache.airavata.model.Workflow getWorkflow(String workflowTemplateId) throws AppCatalogException;
+ public org.apache.airavata.model.Workflow getWorkflow(String workflowTemplateId) throws WorkflowCatalogException;
- public void deleteWorkflow(String workflowTemplateId) throws AppCatalogException;
+ public void deleteWorkflow(String workflowTemplateId) throws WorkflowCatalogException;
- public String registerWorkflow(org.apache.airavata.model.Workflow workflow, String gatewayId) throws AppCatalogException;
+ public String registerWorkflow(org.apache.airavata.model.Workflow workflow, String gatewayId) throws WorkflowCatalogException;
- public void updateWorkflow(String workflowTemplateId, org.apache.airavata.model.Workflow workflow) throws AppCatalogException;
+ public void updateWorkflow(String workflowTemplateId, org.apache.airavata.model.Workflow workflow) throws WorkflowCatalogException;
- public String getWorkflowTemplateId(String workflowName) throws AppCatalogException;
+ public String getWorkflowTemplateId(String workflowName) throws WorkflowCatalogException;
- public boolean isWorkflowExistWithName(String workflowName) throws AppCatalogException;
+ public boolean isWorkflowExistWithName(String workflowName) throws WorkflowCatalogException;
- public void updateWorkflowOutputs(String workflowTemplateId, List<OutputDataObjectType> workflowOutputs) throws AppCatalogException;
+ public void updateWorkflowOutputs(String workflowTemplateId, List<OutputDataObjectType> workflowOutputs) throws WorkflowCatalogException;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/WorkflowCatalogException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/WorkflowCatalogException.java b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/WorkflowCatalogException.java
new file mode 100644
index 0000000..5581115
--- /dev/null
+++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/WorkflowCatalogException.java
@@ -0,0 +1,36 @@
+/**
+ * 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.cpi;
+
+public class WorkflowCatalogException extends Exception{
+ private static final long serialVersionUID = -2849422320139467602L;
+
+ public WorkflowCatalogException(Throwable e) {
+ super(e);
+ }
+
+ public WorkflowCatalogException(String message) {
+ super(message, null);
+ }
+
+ public WorkflowCatalogException(String message, Throwable e) {
+ super(message, e);
+ }
+}
[4/5] airavata git commit: adding workflow related resource layer
Posted by ch...@apache.org.
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/WorkflowResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowResource.java
deleted file mode 100644
index 8c03213..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowResource.java
+++ /dev/null
@@ -1,437 +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.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.Workflow;
-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.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-
-public class WorkflowResource extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(WorkflowResource.class);
- private String wfName;
- private String createdUser;
- private String graph;
- private String wfTemplateId;
- private Timestamp createdTime;
- private Timestamp updatedTime;
- private String image;
- private String gatewayId;
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- public String getImage() {
- return image;
- }
-
- public void setImage(String image) {
- this.image = image;
- }
-
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
- generator.setParameter(WorkflowConstants.WF_TEMPLATE_ID, identifier);
- 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();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
- generator.setParameter(WorkflowConstants.WF_TEMPLATE_ID, identifier);
- Query q = generator.selectQuery(em);
- Workflow workflow = (Workflow) q.getSingleResult();
- WorkflowResource workflowResource = (WorkflowResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW, workflow);
- em.getTransaction().commit();
- if (em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- return workflowResource;
- } 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();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> workflowResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
- Query q;
- if ((fieldName.equals(WorkflowConstants.WF_NAME)) || (fieldName.equals(WorkflowConstants.CREATED_USER)) || (fieldName.equals(WorkflowConstants.GRAPH)) || (fieldName.equals(WorkflowConstants.WF_TEMPLATE_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- Workflow workflow = (Workflow) result;
- WorkflowResource workflowResource = (WorkflowResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW, workflow);
- workflowResources.add(workflowResource);
- }
- } else {
- em.getTransaction().commit();
- if (em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- logger.error("Unsupported field name for Workflow Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Workflow Resource.");
- }
- 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();
- }
- }
- return workflowResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- List<AppCatalogResource> workflows = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
- generator.setParameter(WorkflowConstants.GATEWAY_ID, gatewayId);
- Query q = generator.selectQuery(em);
- List results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Workflow workflow = (Workflow) result;
- WorkflowResource wfResource =
- (WorkflowResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW, workflow);
- workflows.add(wfResource);
- }
- }
- 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 workflows;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- List<String> workflowIds = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
- generator.setParameter(WorkflowConstants.GATEWAY_ID, gatewayId);
- Query q = generator.selectQuery(em);
- List results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Workflow workflow = (Workflow) result;
- workflowIds.add(workflow.getWfTemplateId());
- }
- }
- 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 workflowIds;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> workflowResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
- Query q;
- if ((fieldName.equals(WorkflowConstants.WF_NAME)) || (fieldName.equals(WorkflowConstants.CREATED_USER)) || (fieldName.equals(WorkflowConstants.GRAPH)) || (fieldName.equals(WorkflowConstants.WF_TEMPLATE_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- Workflow workflow = (Workflow) result;
- WorkflowResource workflowResource = (WorkflowResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW, workflow);
- workflowResourceIDs.add(workflowResource.getWfTemplateId());
- }
- } else {
- em.getTransaction().commit();
- if (em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- logger.error("Unsupported field name for Workflow Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Workflow Resource.");
- }
- 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();
- }
- }
- return workflowResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- Workflow existingWorkflow = em.find(Workflow.class, wfTemplateId);
- if (em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- Workflow workflow;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingWorkflow == null) {
- workflow = new Workflow();
- workflow.setCreationTime(AiravataUtils.getCurrentTimestamp());
- } else {
- workflow = existingWorkflow;
- workflow.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- }
- workflow.setWfName(getWfName());
- workflow.setCreatedUser(getCreatedUser());
- workflow.setGatewayId(gatewayId);
- if (getGraph() != null){
- workflow.setGraph(getGraph().toCharArray());
- }
- if (image != null){
- workflow.setImage(image.getBytes());
- }
- workflow.setWfTemplateId(getWfTemplateId());
- if (existingWorkflow == null) {
- em.persist(workflow);
- } else {
- em.merge(workflow);
- }
- 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();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- Workflow workflow = em.find(Workflow.class, identifier);
- if (em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- return workflow != 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 getWfName() {
- return wfName;
- }
-
- public String getCreatedUser() {
- return createdUser;
- }
-
- public String 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(String graph) {
- this.graph=graph;
- }
-
- public void setWfTemplateId(String wfTemplateId) {
- this.wfTemplateId=wfTemplateId;
- }
-}
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/util/AppCatalogJPAUtils.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
index 2a7d47e..5cfca50 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
@@ -42,9 +42,9 @@ public class AppCatalogJPAUtils {
private static final String APPCATALOG_VALIDATION_QUERY = "appcatalog.validationQuery";
private static final String JPA_CACHE_SIZE = "jpa.cache.size";
private static final String JPA_CACHE_ENABLED = "cache.enable";
- @PersistenceUnit(unitName="appcatalog_data")
+ @PersistenceUnit(unitName = "appcatalog_data")
protected static EntityManagerFactory factory;
- @PersistenceContext(unitName="appcatalog_data")
+ @PersistenceContext(unitName = "appcatalog_data")
private static EntityManager appCatEntityManager;
public static EntityManager getEntityManager() throws ApplicationSettingsException {
@@ -63,8 +63,8 @@ public class AppCatalogJPAUtils {
// For app catalog, we don't need caching
// properties.put("openjpa.DataCache","" + readServerProperties(JPA_CACHE_ENABLED) + "(CacheSize=" + Integer.valueOf(readServerProperties(JPA_CACHE_SIZE)) + ", SoftReferenceSize=0)");
// properties.put("openjpa.QueryCache","" + readServerProperties(JPA_CACHE_ENABLED) + "(CacheSize=" + Integer.valueOf(readServerProperties(JPA_CACHE_SIZE)) + ", SoftReferenceSize=0)");
- properties.put("openjpa.RemoteCommitProvider","sjvm");
- properties.put("openjpa.Log","DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=INFO");
+ properties.put("openjpa.RemoteCommitProvider", "sjvm");
+ properties.put("openjpa.Log", "DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=INFO");
properties.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
properties.put("openjpa.jdbc.QuerySQLCache", "false");
properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72, PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=31536000, autoReconnect=true");
@@ -74,7 +74,7 @@ public class AppCatalogJPAUtils {
return appCatEntityManager;
}
- private static String readServerProperties (String propertyName) throws ApplicationSettingsException {
+ private static String readServerProperties(String propertyName) throws ApplicationSettingsException {
try {
return ServerSettings.getSetting(propertyName);
} catch (ApplicationSettingsException e) {
@@ -84,118 +84,117 @@ public class AppCatalogJPAUtils {
}
/**
- *
* @param type model type
- * @param o model type instance
+ * @param o model type instance
* @return corresponding resource object
*/
public static AppCatalogResource getResource(AppCatalogResourceType type, Object o) {
- switch (type){
- case COMPUTE_RESOURCE:
- if (o instanceof ComputeResource){
- return createComputeResource((ComputeResource) o);
- }else{
- logger.error("Object should be a Compute Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Compute Resource.");
- }
+ switch (type) {
+ case COMPUTE_RESOURCE:
+ if (o instanceof ComputeResource) {
+ return createComputeResource((ComputeResource) o);
+ } else {
+ logger.error("Object should be a Compute Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Compute Resource.");
+ }
case HOST_ALIAS:
- if (o instanceof HostAlias){
+ if (o instanceof HostAlias) {
return createHostAlias((HostAlias) o);
- }else {
+ } else {
logger.error("Object should be a Host Alias.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a Host Alias.");
}
case HOST_IPADDRESS:
- if (o instanceof HostIPAddress){
+ if (o instanceof HostIPAddress) {
return createHostIPAddress((HostIPAddress) o);
- }else {
+ } else {
logger.error("Object should be a Host IPAdress.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a Host IPAdress.");
}
case GSISSH_SUBMISSION:
- if (o instanceof GSISSHSubmission){
+ if (o instanceof GSISSHSubmission) {
return createGSSISSHSubmission((GSISSHSubmission) o);
- }else {
+ } else {
logger.error("Object should be a GSISSH Submission", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a GSISSH Submission.");
}
case UNICORE_JOB_SUBMISSION:
- if (o instanceof UnicoreJobSubmission){
+ if (o instanceof UnicoreJobSubmission) {
return createUnicoreJobSubmission((UnicoreJobSubmission) o);
- }else {
+ } else {
logger.error("Object should be a GSISSH Submission", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a GSISSH Submission.");
}
case UNICORE_DATA_MOVEMENT:
- if (o instanceof UnicoreDataMovement){
+ if (o instanceof UnicoreDataMovement) {
return createUnicoreDataMovement((UnicoreDataMovement) o);
- }else {
+ } else {
logger.error("Object should be a GSISSH Submission", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a GSISSH Submission.");
}
case GSISSH_EXPORT:
- if (o instanceof GSISSHExport){
+ if (o instanceof GSISSHExport) {
return createGSISSHExport((GSISSHExport) o);
- }else {
+ } else {
logger.error("Object should be a GSISSH Export.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a GSISSH Export.");
}
case PRE_JOBCOMMAND:
- if (o instanceof PreJobCommand){
+ if (o instanceof PreJobCommand) {
return createPreJobCommand((PreJobCommand) o);
- }else {
+ } else {
logger.error("Object should be a GSISSHPreJobCommand.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a GSISSHPreJobCommand.");
}
case POST_JOBCOMMAND:
- if (o instanceof PostJobCommand){
+ if (o instanceof PostJobCommand) {
return createPostJObCommand((PostJobCommand) o);
- }else {
+ } else {
logger.error("Object should be a GSISSHPostJobCommand.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a GSISSHPostJobCommand.");
}
case GLOBUS_SUBMISSION:
- if (o instanceof GlobusJobSubmission){
+ if (o instanceof GlobusJobSubmission) {
return createGlobusJobSubmission((GlobusJobSubmission) o);
- }else {
+ } else {
logger.error("Object should be a GlobusJobSubmission.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a GlobusJobSubmission.");
}
case GLOBUS_GK_ENDPOINT:
- if (o instanceof GlobusGKEndpoint){
+ if (o instanceof GlobusGKEndpoint) {
return createGlobusEndpoint((GlobusGKEndpoint) o);
- }else {
+ } else {
logger.error("Object should be a GlobusJobSubmission.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a GlobusJobSubmission.");
}
case SSH_JOB_SUBMISSION:
- if (o instanceof SshJobSubmission){
- return createSshJobSubmission((SshJobSubmission) o);
- }else{
- logger.error("Object should be a Ssh Job Submission.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Ssh Job Submission.");
- }
+ if (o instanceof SshJobSubmission) {
+ return createSshJobSubmission((SshJobSubmission) o);
+ } else {
+ logger.error("Object should be a Ssh Job Submission.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Ssh Job Submission.");
+ }
case SCP_DATA_MOVEMENT:
- if (o instanceof ScpDataMovement){
- return createScpDataMovement((ScpDataMovement) o);
- }else{
- logger.error("Object should be a Scp Data Movement.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Scp Data Movement.");
- }
+ if (o instanceof ScpDataMovement) {
+ return createScpDataMovement((ScpDataMovement) o);
+ } else {
+ logger.error("Object should be a Scp Data Movement.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Scp Data Movement.");
+ }
case GRIDFTP_DATA_MOVEMENT:
- if (o instanceof GridftpDataMovement){
- return createGridftpDataMovement((GridftpDataMovement) o);
- }else{
- logger.error("Object should be a Gridftp Data Movement.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Gridftp Data Movement.");
- }
+ if (o instanceof GridftpDataMovement) {
+ return createGridftpDataMovement((GridftpDataMovement) o);
+ } else {
+ logger.error("Object should be a Gridftp Data Movement.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Gridftp Data Movement.");
+ }
case GRIDFTP_ENDPOINT:
- if (o instanceof GridftpEndpoint){
- return createGridftpEndpoint((GridftpEndpoint) o);
- }else{
- logger.error("Object should be a Gridftp Endpoint.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Gridftp Endpoint.");
- }
+ if (o instanceof GridftpEndpoint) {
+ return createGridftpEndpoint((GridftpEndpoint) o);
+ } else {
+ logger.error("Object should be a Gridftp Endpoint.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Gridftp Endpoint.");
+ }
// case JOB_SUBMISSION_PROTOCOL:
// if (o instanceof JobSubmissionProtocol){
// return createJobSubmissionProtocol((JobSubmissionProtocol) o);
@@ -211,159 +210,159 @@ public class AppCatalogJPAUtils {
// throw new IllegalArgumentException("Object should be a DataMovementProtocol.");
// }
case APPLICATION_MODULE:
- if (o instanceof ApplicationModule){
+ if (o instanceof ApplicationModule) {
return createApplicationModule((ApplicationModule) o);
- }else {
+ } else {
logger.error("Object should be a Application Module.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a Application Module.");
}
case APPLICATION_DEPLOYMENT:
- if (o instanceof ApplicationDeployment){
+ if (o instanceof ApplicationDeployment) {
return createApplicationDeployment((ApplicationDeployment) o);
- }else {
+ } else {
logger.error("Object should be a Application Deployment.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a Application Deployment.");
}
case LIBRARY_PREPAND_PATH:
- if (o instanceof LibraryPrepandPath){
+ if (o instanceof LibraryPrepandPath) {
return createLibraryPrepPathResource((LibraryPrepandPath) o);
- }else {
+ } else {
logger.error("Object should be a Library Prepand path.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a Library Prepand path.");
}
case LIBRARY_APEND_PATH:
- if (o instanceof LibraryApendPath){
+ if (o instanceof LibraryApendPath) {
return createLibraryApendPathResource((LibraryApendPath) o);
- }else {
+ } else {
logger.error("Object should be a Library Apend path.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a Library Apend.");
}
case APP_ENVIRONMENT:
- if (o instanceof AppEnvironment){
+ if (o instanceof AppEnvironment) {
return createAppEnvironmentResource((AppEnvironment) o);
- }else {
+ } else {
logger.error("Object should be a AppEnvironment.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a AppEnvironment.");
}
case APPLICATION_INTERFACE:
- if (o instanceof ApplicationInterface){
+ if (o instanceof ApplicationInterface) {
return createAppInterfaceResource((ApplicationInterface) o);
- }else {
+ } else {
logger.error("Object should be a ApplicationInterface.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a ApplicationInterface.");
}
case APP_MODULE_MAPPING:
- if (o instanceof AppModuleMapping){
+ if (o instanceof AppModuleMapping) {
return createAppModMappingResource((AppModuleMapping) o);
- }else {
+ } else {
logger.error("Object should be a AppModuleMapping.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a AppModuleMapping.");
}
case APPLICATION_OUTPUT:
- if (o instanceof ApplicationIntOutput){
+ if (o instanceof ApplicationIntOutput) {
return createApplicationOutput((ApplicationIntOutput) o);
- }else {
+ } else {
logger.error("Object should be a ApplicationOutput.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a ApplicationOutput.");
}
case GATEWAY_PROFILE:
- if (o instanceof GatewayProfile){
+ if (o instanceof GatewayProfile) {
return createGatewayProfile((GatewayProfile) o);
- }else {
+ } else {
logger.error("Object should be a GatewayProfile.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a GatewayProfile.");
}
case COMPUTE_RESOURCE_PREFERENCE:
- if (o instanceof ComputeResourcePreference){
+ if (o instanceof ComputeResourcePreference) {
return createComputeResourcePref((ComputeResourcePreference) o);
- }else {
+ } else {
logger.error("Object should be a Compute Resource Preference.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a Compute Resource Preference.");
}
case STORAGE_PREFERENCE:
- if (o instanceof StoragePreference){
+ if (o instanceof StoragePreference) {
return createStoragePref((StoragePreference) o);
- }else {
+ } else {
logger.error("Object should be a data storage Preference.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a data storage Preference.");
}
case STORAGE_RESOURCE:
- if (o instanceof StorageResource){
+ if (o instanceof StorageResource) {
return createStorageResource((StorageResource) o);
- }else {
+ } else {
logger.error("Object should be a storage resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a storage resource.");
}
case STORAGE_INTERFACE:
- if (o instanceof StorageInterface){
+ if (o instanceof StorageInterface) {
return createStorageInterface((StorageInterface) o);
- }else {
+ } else {
logger.error("Object should be a storage interface.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a storage interface.");
}
case APPLICATION_INPUT:
- if (o instanceof ApplicationIntInput){
+ if (o instanceof ApplicationIntInput) {
return createApplicationInput((ApplicationIntInput) o);
- }else {
+ } else {
logger.error("Object should be a ApplicationInput.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a ApplicationInput.");
}
case BATCH_QUEUE:
- if (o instanceof BatchQueue){
- return createBatchQueue((BatchQueue) o);
- }else{
- logger.error("Object should be a Batch Queue.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Batch Queue.");
- }
+ if (o instanceof BatchQueue) {
+ return createBatchQueue((BatchQueue) o);
+ } else {
+ logger.error("Object should be a Batch Queue.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Batch Queue.");
+ }
case COMPUTE_RESOURCE_FILE_SYSTEM:
- if (o instanceof ComputeResourceFileSystem){
- return createComputeResourceFileSystem((ComputeResourceFileSystem) o);
- }else{
- logger.error("Object should be a Compute Resource File System.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Compute Resource File System.");
- }
+ if (o instanceof ComputeResourceFileSystem) {
+ return createComputeResourceFileSystem((ComputeResourceFileSystem) o);
+ } else {
+ logger.error("Object should be a Compute Resource File System.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Compute Resource File System.");
+ }
case JOB_SUBMISSION_INTERFACE:
- if (o instanceof JobSubmissionInterface){
- return createJobSubmissionInterface((JobSubmissionInterface) o);
- }else{
- logger.error("Object should be a Job Submission Interface.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Job Submission Interface.");
- }
+ if (o instanceof JobSubmissionInterface) {
+ return createJobSubmissionInterface((JobSubmissionInterface) o);
+ } else {
+ logger.error("Object should be a Job Submission Interface.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Job Submission Interface.");
+ }
case DATA_MOVEMENT_INTERFACE:
- if (o instanceof DataMovementInterface){
- return createDataMovementInterface((DataMovementInterface) o);
- }else{
- logger.error("Object should be a Data Movement Interface.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Data Movement Interface.");
- }
+ if (o instanceof DataMovementInterface) {
+ return createDataMovementInterface((DataMovementInterface) o);
+ } else {
+ logger.error("Object should be a Data Movement Interface.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Data Movement Interface.");
+ }
case RESOURCE_JOB_MANAGER:
- if (o instanceof ResourceJobManager){
- return createResourceJobManager((ResourceJobManager) o);
- }else{
- logger.error("Object should be a Resource Job Manager.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Resource Job Manager.");
- }
+ if (o instanceof ResourceJobManager) {
+ return createResourceJobManager((ResourceJobManager) o);
+ } else {
+ logger.error("Object should be a Resource Job Manager.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Resource Job Manager.");
+ }
case JOB_MANAGER_COMMAND:
- if (o instanceof JobManagerCommand){
- return createJobManagerCommand((JobManagerCommand) o);
- }else{
- logger.error("Object should be a Job Manager Command.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Job Manager Command.");
- }
- case LOCAL_SUBMISSION:
- if (o instanceof LocalSubmission){
- return createLocalSubmission((LocalSubmission) o);
- }else{
- logger.error("Object should be a Local Submission.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Local Submission.");
- }
- case LOCAL_DATA_MOVEMENT:
- if (o instanceof LocalDataMovement){
- return createLocalDataMovement((LocalDataMovement) o);
- }else{
- logger.error("Object should be a Local Data Movement.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Local Data Movement.");
- }
+ if (o instanceof JobManagerCommand) {
+ return createJobManagerCommand((JobManagerCommand) o);
+ } else {
+ logger.error("Object should be a Job Manager Command.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Job Manager Command.");
+ }
+ case LOCAL_SUBMISSION:
+ if (o instanceof LocalSubmission) {
+ return createLocalSubmission((LocalSubmission) o);
+ } else {
+ logger.error("Object should be a Local Submission.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Local Submission.");
+ }
+ case LOCAL_DATA_MOVEMENT:
+ if (o instanceof LocalDataMovement) {
+ return createLocalDataMovement((LocalDataMovement) o);
+ } else {
+ logger.error("Object should be a Local Data Movement.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Local Data Movement.");
+ }
case MODULE_LOAD_CMD:
if (o instanceof ModuleLoadCmd) {
return createModuleLoadCmd((ModuleLoadCmd) o);
@@ -371,31 +370,10 @@ public class AppCatalogJPAUtils {
logger.error("Object should be a Module Load Cmd.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a Module Load Cmd.");
}
- case WORKFLOW:
- if (o instanceof Workflow) {
- return createWorkflow((Workflow) o);
- } else {
- logger.error("Object should be a Workflow.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Workflow.");
- }
- case WORKFLOW_INPUT:
- if (o instanceof WorkflowInput){
- return createWorflowInput((WorkflowInput) o);
- }else {
- logger.error("Object should be a Workflow Input.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Workflow Input.");
- }
- case WORKFLOW_OUTPUT:
- if (o instanceof WorkflowOutput){
- return createWorkflowOutput((WorkflowOutput) o);
- }else {
- logger.error("Object should be a Workflow Output.", new IllegalArgumentException());
- throw new IllegalArgumentException("Object should be a Workflow Output.");
- }
case GATEWAY_CLIENT_CREDENTIAL:
- if (o instanceof GatewayClientCredential){
+ if (o instanceof GatewayClientCredential) {
return createGatewayClientCredential((GatewayClientCredential) o);
- }else {
+ } else {
logger.error("Object should be a Gateway Client Credential.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a Gateway Client Credential.");
}
@@ -404,103 +382,103 @@ public class AppCatalogJPAUtils {
throw new IllegalArgumentException("Illegal data type..");
}
}
-
- private static AppCatalogResource createLocalDataMovement(LocalDataMovement o) {
- LocalDataMovementResource localDataMovementResource = new LocalDataMovementResource();
- if (o != null){
+
+ private static AppCatalogResource createLocalDataMovement(LocalDataMovement o) {
+ LocalDataMovementResource localDataMovementResource = new LocalDataMovementResource();
+ if (o != null) {
localDataMovementResource.setDataMovementInterfaceId(o.getDataMovementInterfaceId());
}
- return localDataMovementResource;
- }
-
+ return localDataMovementResource;
+ }
+
private static AppCatalogResource createLocalSubmission(LocalSubmission o) {
- LocalSubmissionResource localSubmissionResource = new LocalSubmissionResource();
- if (o != null){
+ LocalSubmissionResource localSubmissionResource = new LocalSubmissionResource();
+ if (o != null) {
localSubmissionResource.setResourceJobManagerId(o.getResourceJobManagerId());
- localSubmissionResource.setResourceJobManagerResource((ResourceJobManagerResource)createResourceJobManager(o.getResourceJobManager()));
+ localSubmissionResource.setResourceJobManagerResource((ResourceJobManagerResource) createResourceJobManager(o.getResourceJobManager()));
localSubmissionResource.setJobSubmissionInterfaceId(o.getJobSubmissionInterfaceId());
localSubmissionResource.setCreatedTime(o.getCreationTime());
- if (o.getUpdateTime() != null){
+ if (o.getUpdateTime() != null) {
localSubmissionResource.setUpdatedTime(o.getUpdateTime());
}
}
- return localSubmissionResource;
- }
-
+ return localSubmissionResource;
+ }
+
private static AppCatalogResource createJobManagerCommand(JobManagerCommand o) {
- JobManagerCommandResource jobManagerCommandResource = new JobManagerCommandResource();
- if (o != null){
+ JobManagerCommandResource jobManagerCommandResource = new JobManagerCommandResource();
+ if (o != null) {
jobManagerCommandResource.setResourceJobManagerId(o.getResourceJobManagerId());
- jobManagerCommandResource.setResourceJobManagerResource((ResourceJobManagerResource)createResourceJobManager(o.getResourceJobManager()));
+ jobManagerCommandResource.setResourceJobManagerResource((ResourceJobManagerResource) createResourceJobManager(o.getResourceJobManager()));
jobManagerCommandResource.setCommandType(o.getCommandType());
jobManagerCommandResource.setCommand(o.getCommand());
}
- return jobManagerCommandResource;
- }
-
+ return jobManagerCommandResource;
+ }
+
private static AppCatalogResource createResourceJobManager(ResourceJobManager o) {
- ResourceJobManagerResource resourceJobManagerResource = new ResourceJobManagerResource();
+ ResourceJobManagerResource resourceJobManagerResource = new ResourceJobManagerResource();
if (o != null) {
resourceJobManagerResource.setResourceJobManagerId(o.getResourceJobManagerId());
resourceJobManagerResource.setPushMonitoringEndpoint(o.getPushMonitoringEndpoint());
resourceJobManagerResource.setJobManagerBinPath(o.getJobManagerBinPath());
resourceJobManagerResource.setResourceJobManagerType(o.getResourceJobManagerType());
resourceJobManagerResource.setCreatedTime(o.getCreationTime());
- if (o.getUpdateTime() != null){
+ if (o.getUpdateTime() != null) {
resourceJobManagerResource.setUpdatedTime(o.getUpdateTime());
}
}
- return resourceJobManagerResource;
- }
-
+ return resourceJobManagerResource;
+ }
+
private static AppCatalogResource createDataMovementInterface(DataMovementInterface o) {
- DataMovementInterfaceResource dataMovementInterfaceResource = new DataMovementInterfaceResource();
+ DataMovementInterfaceResource dataMovementInterfaceResource = new DataMovementInterfaceResource();
if (o != null) {
dataMovementInterfaceResource.setComputeResourceId(o.getComputeResourceId());
- dataMovementInterfaceResource.setComputeHostResource((ComputeResourceResource)createComputeResource(o.getComputeResource()));
+ dataMovementInterfaceResource.setComputeHostResource((ComputeResourceResource) createComputeResource(o.getComputeResource()));
dataMovementInterfaceResource.setDataMovementProtocol(o.getDataMovementProtocol());
dataMovementInterfaceResource.setDataMovementInterfaceId(o.getDataMovementInterfaceId());
dataMovementInterfaceResource.setPriorityOrder(o.getPriorityOrder());
dataMovementInterfaceResource.setCreatedTime(o.getCreationTime());
- if (o.getUpdateTime() != null){
+ if (o.getUpdateTime() != null) {
dataMovementInterfaceResource.setUpdatedTime(o.getUpdateTime());
}
}
- return dataMovementInterfaceResource;
- }
-
+ return dataMovementInterfaceResource;
+ }
+
private static AppCatalogResource createJobSubmissionInterface(JobSubmissionInterface o) {
- JobSubmissionInterfaceResource jobSubmissionInterfaceResource = new JobSubmissionInterfaceResource();
+ JobSubmissionInterfaceResource jobSubmissionInterfaceResource = new JobSubmissionInterfaceResource();
if (o != null) {
jobSubmissionInterfaceResource.setJobSubmissionInterfaceId(o.getJobSubmissionInterfaceId());
jobSubmissionInterfaceResource.setComputeResourceId(o.getComputeResourceId());
- jobSubmissionInterfaceResource.setComputeHostResource((ComputeResourceResource)createComputeResource(o.getComputeResource()));
+ jobSubmissionInterfaceResource.setComputeHostResource((ComputeResourceResource) createComputeResource(o.getComputeResource()));
jobSubmissionInterfaceResource.setJobSubmissionProtocol(o.getJobSubmissionProtocol());
jobSubmissionInterfaceResource.setPriorityOrder(o.getPriorityOrder());
jobSubmissionInterfaceResource.setCreatedTime(o.getCreationTime());
- if (o.getUpdateTime() != null){
+ if (o.getUpdateTime() != null) {
jobSubmissionInterfaceResource.setUpdatedTime(o.getUpdateTime());
}
}
- return jobSubmissionInterfaceResource;
- }
-
+ return jobSubmissionInterfaceResource;
+ }
+
private static AppCatalogResource createComputeResourceFileSystem(ComputeResourceFileSystem o) {
- ComputeResourceFileSystemResource computeResourceFileSystemResource = new ComputeResourceFileSystemResource();
- if (o != null){
+ ComputeResourceFileSystemResource computeResourceFileSystemResource = new ComputeResourceFileSystemResource();
+ if (o != null) {
computeResourceFileSystemResource.setComputeResourceId(o.getComputeResourceId());
- computeResourceFileSystemResource.setComputeHostResource((ComputeResourceResource)createComputeResource(o.getComputeResource()));
+ computeResourceFileSystemResource.setComputeHostResource((ComputeResourceResource) createComputeResource(o.getComputeResource()));
computeResourceFileSystemResource.setPath(o.getPath());
computeResourceFileSystemResource.setFileSystem(o.getFileSystem());
}
- return computeResourceFileSystemResource;
- }
-
+ return computeResourceFileSystemResource;
+ }
+
private static AppCatalogResource createBatchQueue(BatchQueue o) {
- BatchQueueResource batchQueueResource = new BatchQueueResource();
- if (o != null){
+ BatchQueueResource batchQueueResource = new BatchQueueResource();
+ if (o != null) {
batchQueueResource.setComputeResourceId(o.getComputeResourceId());
- batchQueueResource.setComputeHostResource((ComputeResourceResource)createComputeResource(o.getComputeResource()));
+ batchQueueResource.setComputeHostResource((ComputeResourceResource) createComputeResource(o.getComputeResource()));
batchQueueResource.setMaxRuntime(o.getMaxRuntime());
batchQueueResource.setMaxJobInQueue(o.getMaxJobInQueue());
batchQueueResource.setQueueDescription(o.getQueueDescription());
@@ -509,10 +487,11 @@ public class AppCatalogJPAUtils {
batchQueueResource.setMaxNodes(o.getMaxNodes());
batchQueueResource.setMaxMemory(o.getMaxMemory());
}
- return batchQueueResource;
- }
+ return batchQueueResource;
+ }
+
private static AppCatalogResource createComputeResource(ComputeResource o) {
- ComputeResourceResource computeResourceResource = new ComputeResourceResource();
+ ComputeResourceResource computeResourceResource = new ComputeResourceResource();
if (o != null) {
computeResourceResource.setResourceDescription(o.getResourceDescription());
computeResourceResource.setResourceId(o.getResourceId());
@@ -520,29 +499,29 @@ public class AppCatalogJPAUtils {
computeResourceResource.setCreatedTime(o.getCreationTime());
computeResourceResource.setEnabled(o.getEnabled());
computeResourceResource.setMaxMemoryPerNode(o.getMaxMemoryPerNode());
- if (o.getUpdateTime() != null){
+ if (o.getUpdateTime() != null) {
computeResourceResource.setUpdatedTime(o.getUpdateTime());
}
}
- return computeResourceResource;
- }
+ return computeResourceResource;
+ }
private static AppCatalogResource createHostAlias(HostAlias o) {
HostAliasAppResource aliasResource = new HostAliasAppResource();
- if (o != null){
+ if (o != null) {
aliasResource.setResourceID(o.getResourceID());
aliasResource.setAlias(o.getAlias());
- aliasResource.setComputeHostResource((ComputeResourceResource)createComputeResource(o.getComputeResource()));
+ aliasResource.setComputeHostResource((ComputeResourceResource) createComputeResource(o.getComputeResource()));
}
return aliasResource;
}
private static AppCatalogResource createHostIPAddress(HostIPAddress o) {
HostIPAddressResource ipAddressResource = new HostIPAddressResource();
- if (o != null){
+ if (o != null) {
ipAddressResource.setResourceID(o.getResourceID());
ipAddressResource.setIpaddress(o.getIpaddress());
- ipAddressResource.setComputeHostResource((ComputeResourceResource)createComputeResource(o.getComputeResource()));
+ ipAddressResource.setComputeHostResource((ComputeResourceResource) createComputeResource(o.getComputeResource()));
}
return ipAddressResource;
}
@@ -558,8 +537,7 @@ public class AppCatalogJPAUtils {
}
return submissionResource;
}
-
-
+
private static AppCatalogResource createUnicoreJobSubmission(UnicoreJobSubmission o) {
UnicoreJobSubmissionResource submissionResource = new UnicoreJobSubmissionResource();
if (o != null) {
@@ -579,18 +557,18 @@ public class AppCatalogJPAUtils {
}
return dataMovementResource;
}
-
- private static AppCatalogResource createGSISSHExport(GSISSHExport o){
+
+ private static AppCatalogResource createGSISSHExport(GSISSHExport o) {
GSISSHExportResource resource = new GSISSHExportResource();
if (o != null) {
resource.setSubmissionID(o.getSubmissionID());
resource.setExport(o.getExport());
- resource.setGsisshSubmissionResource((GSISSHSubmissionResource)createGSSISSHSubmission(o.getGsisshJobSubmission()));
+ resource.setGsisshSubmissionResource((GSISSHSubmissionResource) createGSSISSHSubmission(o.getGsisshJobSubmission()));
}
return resource;
}
- private static AppCatalogResource createPreJobCommand(PreJobCommand o){
+ private static AppCatalogResource createPreJobCommand(PreJobCommand o) {
PreJobCommandResource resource = new PreJobCommandResource();
if (o != null) {
resource.setAppDeploymentId(o.getDeploymentId());
@@ -601,9 +579,9 @@ public class AppCatalogJPAUtils {
return resource;
}
- private static AppCatalogResource createPostJObCommand(PostJobCommand o){
+ private static AppCatalogResource createPostJObCommand(PostJobCommand o) {
PostJobCommandResource resource = new PostJobCommandResource();
- if (o != null){
+ if (o != null) {
resource.setAppDeploymentId(o.getDeploymentId());
resource.setCommand(o.getCommand());
resource.setOrder(o.getOrder());
@@ -614,7 +592,7 @@ public class AppCatalogJPAUtils {
private static AppCatalogResource createGlobusJobSubmission(GlobusJobSubmission o) {
GlobusJobSubmissionResource resource = new GlobusJobSubmissionResource();
- if (o != null){
+ if (o != null) {
resource.setSubmissionID(o.getSubmissionID());
resource.setResourceJobManager(o.getResourceJobManager());
resource.setSecurityProtocol(o.getSecurityProtocol());
@@ -624,15 +602,15 @@ public class AppCatalogJPAUtils {
private static AppCatalogResource createGlobusEndpoint(GlobusGKEndpoint o) {
GlobusGKEndpointResource resource = new GlobusGKEndpointResource();
- if (o != null){
+ if (o != null) {
resource.setSubmissionID(o.getSubmissionID());
resource.setEndpoint(o.getEndpoint());
- resource.setGlobusJobSubmissionResource((GlobusJobSubmissionResource)createGlobusJobSubmission(o.getGlobusSubmission()));
+ resource.setGlobusJobSubmissionResource((GlobusJobSubmissionResource) createGlobusJobSubmission(o.getGlobusSubmission()));
}
return resource;
}
-
- private static AppCatalogResource createSshJobSubmission(SshJobSubmission o) {
+
+ private static AppCatalogResource createSshJobSubmission(SshJobSubmission o) {
SshJobSubmissionResource sshJobSubmissionResource = new SshJobSubmissionResource();
if (o != null) {
sshJobSubmissionResource.setResourceJobManagerId(o.getResourceJobManagerId());
@@ -643,7 +621,7 @@ public class AppCatalogJPAUtils {
sshJobSubmissionResource.setSshPort(o.getSshPort());
sshJobSubmissionResource.setMonitorMode(o.getMonitorMode());
sshJobSubmissionResource.setCreatedTime(o.getCreationTime());
- if (o.getUpdateTime() != null){
+ if (o.getUpdateTime() != null) {
sshJobSubmissionResource.setUpdatedTime(o.getUpdateTime());
}
}
@@ -651,47 +629,47 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createScpDataMovement(ScpDataMovement o) {
- ScpDataMovementResource scpDataMovementResource = new ScpDataMovementResource();
- if (o != null){
+ ScpDataMovementResource scpDataMovementResource = new ScpDataMovementResource();
+ if (o != null) {
scpDataMovementResource.setQueueDescription(o.getQueueDescription());
scpDataMovementResource.setDataMovementInterfaceId(o.getDataMovementInterfaceId());
scpDataMovementResource.setSecurityProtocol(o.getSecurityProtocol());
scpDataMovementResource.setAlternativeScpHostname(o.getAlternativeScpHostname());
scpDataMovementResource.setSshPort(o.getSshPort());
scpDataMovementResource.setCreatedTime(o.getCreationTime());
- if (o.getUpdateTime() != null){
+ if (o.getUpdateTime() != null) {
scpDataMovementResource.setUpdatedTime(o.getUpdateTime());
}
}
- return scpDataMovementResource;
- }
+ return scpDataMovementResource;
+ }
private static AppCatalogResource createGridftpDataMovement(GridftpDataMovement o) {
- GridftpDataMovementResource gridftpDataMovementResource = new GridftpDataMovementResource();
- if (o != null){
+ GridftpDataMovementResource gridftpDataMovementResource = new GridftpDataMovementResource();
+ if (o != null) {
gridftpDataMovementResource.setDataMovementInterfaceId(o.getDataMovementInterfaceId());
gridftpDataMovementResource.setSecurityProtocol(o.getSecurityProtocol());
gridftpDataMovementResource.setCreatedTime(o.getCreationTime());
- if (o.getUpdateTime() != null){
+ if (o.getUpdateTime() != null) {
gridftpDataMovementResource.setUpdatedTime(o.getUpdateTime());
}
}
- return gridftpDataMovementResource;
- }
+ return gridftpDataMovementResource;
+ }
private static AppCatalogResource createGridftpEndpoint(GridftpEndpoint o) {
- GridftpEndpointResource gridftpEndpointResource = new GridftpEndpointResource();
- if (o != null){
+ GridftpEndpointResource gridftpEndpointResource = new GridftpEndpointResource();
+ if (o != null) {
gridftpEndpointResource.setEndpoint(o.getEndpoint());
gridftpEndpointResource.setDataMovementInterfaceId(o.getDataMovementInterfaceId());
- gridftpEndpointResource.setGridftpDataMovementResource((GridftpDataMovementResource)createGridftpDataMovement(o.getGridftpDataMovement()));
+ gridftpEndpointResource.setGridftpDataMovementResource((GridftpDataMovementResource) createGridftpDataMovement(o.getGridftpDataMovement()));
gridftpEndpointResource.setCreatedTime(o.getCreationTime());
- if (o.getUpdateTime() != null){
+ if (o.getUpdateTime() != null) {
gridftpEndpointResource.setUpdatedTime(o.getUpdateTime());
}
}
- return gridftpEndpointResource;
- }
+ return gridftpEndpointResource;
+ }
// private static Resource createJobSubmissionProtocol(JobSubmissionProtocol o) {
// JobSubmissionProtocolResource resource = new JobSubmissionProtocolResource();
@@ -717,14 +695,14 @@ public class AppCatalogJPAUtils {
private static AppCatalogResource createApplicationModule(ApplicationModule o) {
AppModuleResource moduleResource = new AppModuleResource();
- if (o != null){
+ if (o != null) {
moduleResource.setModuleId(o.getModuleID());
moduleResource.setModuleDesc(o.getModuleDesc());
moduleResource.setGatewayId(o.getGatewayId());
moduleResource.setModuleName(o.getModuleName());
moduleResource.setModuleVersion(o.getModuleVersion());
moduleResource.setCreatedTime(o.getCreationTime());
- if (o.getUpdateTime() != null){
+ if (o.getUpdateTime() != null) {
moduleResource.setUpdatedTime(o.getUpdateTime());
}
}
@@ -733,7 +711,7 @@ public class AppCatalogJPAUtils {
private static AppCatalogResource createApplicationDeployment(ApplicationDeployment o) {
AppDeploymentResource resource = new AppDeploymentResource();
- if (o != null){
+ if (o != null) {
resource.setDeploymentId(o.getDeploymentID());
resource.setAppDes(o.getApplicationDesc());
resource.setAppModuleId(o.getAppModuleID());
@@ -744,7 +722,7 @@ public class AppCatalogJPAUtils {
resource.setModuleResource((AppModuleResource) createApplicationModule(o.getApplicationModule()));
resource.setHostResource((ComputeResourceResource) createComputeResource(o.getComputeResource()));
resource.setCreatedTime(o.getCreationTime());
- if (o.getUpdateTime() != null){
+ if (o.getUpdateTime() != null) {
resource.setUpdatedTime(o.getUpdateTime());
}
}
@@ -753,7 +731,7 @@ public class AppCatalogJPAUtils {
private static AppCatalogResource createLibraryPrepPathResource(LibraryPrepandPath o) {
LibraryPrepandPathResource resource = new LibraryPrepandPathResource();
- if (o != null){
+ if (o != null) {
resource.setDeploymentId(o.getDeploymentID());
resource.setName(o.getName());
resource.setValue(o.getValue());
@@ -764,36 +742,36 @@ public class AppCatalogJPAUtils {
private static AppCatalogResource createLibraryApendPathResource(LibraryApendPath o) {
LibraryApendPathResource resource = new LibraryApendPathResource();
- if (o != null){
+ if (o != null) {
resource.setDeploymentId(o.getDeploymentID());
resource.setName(o.getName());
resource.setValue(o.getValue());
- resource.setAppDeploymentResource((AppDeploymentResource)createApplicationDeployment(o.getApplicationDeployment()));
+ resource.setAppDeploymentResource((AppDeploymentResource) createApplicationDeployment(o.getApplicationDeployment()));
}
return resource;
}
private static AppCatalogResource createAppEnvironmentResource(AppEnvironment o) {
AppEnvironmentResource resource = new AppEnvironmentResource();
- if (o != null){
+ if (o != null) {
resource.setDeploymentId(o.getDeploymentID());
resource.setName(o.getName());
resource.setValue(o.getValue());
resource.setOrder(o.getOrder());
- resource.setAppDeploymentResource((AppDeploymentResource)createApplicationDeployment(o.getApplicationDeployment()));
+ resource.setAppDeploymentResource((AppDeploymentResource) createApplicationDeployment(o.getApplicationDeployment()));
}
return resource;
}
private static AppCatalogResource createAppInterfaceResource(ApplicationInterface o) {
AppInterfaceResource resource = new AppInterfaceResource();
- if (o != null){
+ if (o != null) {
resource.setInterfaceId(o.getInterfaceID());
resource.setAppName(o.getAppName());
resource.setAppDescription(o.getAppDescription());
resource.setCreatedTime(o.getCreationTime());
resource.setGatewayId(o.getGatewayId());
- if (o.getUpdateTime() != null){
+ if (o.getUpdateTime() != null) {
resource.setUpdatedTime(o.getUpdateTime());
}
}
@@ -802,7 +780,7 @@ public class AppCatalogJPAUtils {
private static AppCatalogResource createAppModMappingResource(AppModuleMapping o) {
AppModuleMappingAppCatalogResourceAppCat resource = new AppModuleMappingAppCatalogResourceAppCat();
- if (o != null){
+ if (o != null) {
resource.setInterfaceId(o.getInterfaceID());
resource.setModuleId(o.getModuleID());
}
@@ -811,7 +789,7 @@ public class AppCatalogJPAUtils {
private static AppCatalogResource createApplicationInput(ApplicationIntInput o) {
ApplicationInputResource resource = new ApplicationInputResource();
- if (o != null){
+ if (o != null) {
resource.setInterfaceID(o.getInterfaceID());
resource.setInputKey(o.getInputKey());
resource.setInputVal(o.getInputVal());
@@ -824,36 +802,14 @@ public class AppCatalogJPAUtils {
resource.setRequired(o.isRequired());
resource.setRequiredToCMD(o.isRequiredToCMD());
resource.setDataStaged(o.isDataStaged());
- resource.setAppInterfaceResource((AppInterfaceResource)createAppInterfaceResource(o.getApplicationInterface()));
- }
- return resource;
- }
-
- private static AppCatalogResource createWorflowInput(WorkflowInput o) {
- WorkflowInputResource resource = new WorkflowInputResource();
- if (o != null){
- resource.setWfTemplateId(o.getWfTemplateId());
- resource.setInputKey(o.getInputKey());
- if (o.getInputVal() != null){
- resource.setInputVal(new String(o.getInputVal()));
- }
- resource.setDataType(o.getDataType());
- resource.setMetadata(o.getMetadata());
- resource.setAppArgument(o.getAppArgument());
- resource.setInputOrder(o.getInputOrder());
- resource.setUserFriendlyDesc(o.getUserFriendlyDesc());
- resource.setStandardInput(o.isStandardInput());
- resource.setRequired(o.isRequired());
- resource.setRequiredToCMD(o.isRequiredToCMD());
- resource.setDataStaged(o.isDataStaged());
- resource.setWorkflowResource((WorkflowResource)createWorkflow(o.getWorkflow()));
+ resource.setAppInterfaceResource((AppInterfaceResource) createAppInterfaceResource(o.getApplicationInterface()));
}
return resource;
}
private static AppCatalogResource createApplicationOutput(ApplicationIntOutput o) {
ApplicationOutputResource resource = new ApplicationOutputResource();
- if (o != null){
+ if (o != null) {
resource.setInterfaceID(o.getInterfaceID());
resource.setOutputKey(o.getOutputKey());
resource.setOutputVal(o.getOutputVal());
@@ -865,31 +821,14 @@ public class AppCatalogJPAUtils {
resource.setSearchQuery(o.getSearchQuery());
resource.setAppArgument(o.getApplicationArgument());
resource.setOutputStreaming(o.isOutputStreaming());
- resource.setAppInterfaceResource((AppInterfaceResource)createAppInterfaceResource(o.getApplicationInterface()));
- }
- return resource;
- }
-
- private static AppCatalogResource createWorkflowOutput(WorkflowOutput o) {
- WorkflowOutputResource resource = new WorkflowOutputResource();
- if (o != null){
- resource.setWfTemplateId(o.getWfTemplateId());
- resource.setOutputKey(o.getOutputKey());
- if (o.getOutputVal() != null){
- resource.setOutputVal(new String(o.getOutputVal()));
- }
- resource.setDataType(o.getDataType());
- resource.setValidityType(o.getValidityType());
- resource.setDataMovement(o.isDataMovement());
- resource.setDataNameLocation(o.getDataNameLocation());
- resource.setWorkflowResource((WorkflowResource)createWorkflow(o.getWorkflow()));
+ resource.setAppInterfaceResource((AppInterfaceResource) createAppInterfaceResource(o.getApplicationInterface()));
}
return resource;
}
private static AppCatalogResource createGatewayClientCredential(GatewayClientCredential o) {
GatewayClientCredentialResource resource = new GatewayClientCredentialResource();
- if (o != null){
+ if (o != null) {
resource.setClientKey(o.getClientKey());
resource.setClientSecret(o.getClientSecret());
resource.setGatewayId(o.getGatewayId());
@@ -903,7 +842,7 @@ public class AppCatalogJPAUtils {
resource.setGatewayID(o.getGatewayID());
resource.setCreatedTime(o.getCreationTime());
resource.setCredentialStoreToken(o.getCredentialStoreToken());
- if (o.getUpdateTime() != null){
+ if (o.getUpdateTime() != null) {
resource.setUpdatedTime(o.getUpdateTime());
}
}
@@ -960,38 +899,20 @@ public class AppCatalogJPAUtils {
resource.setDataMovementInterfaceId(o.getDataMovementInterfaceId());
resource.setDataMovementProtocol(o.getDataMovementProtocol());
resource.setPriorityOrder(o.getPriorityOrder());
- resource.setStorageResourceResource((StorageResourceResource)createStorageResource(o.getStorageResource()));
+ resource.setStorageResourceResource((StorageResourceResource) createStorageResource(o.getStorageResource()));
}
return resource;
}
private static AppCatalogResource createModuleLoadCmd(ModuleLoadCmd o) {
ModuleLoadCmdResource moduleLoadCmdResource = new ModuleLoadCmdResource();
- if (o != null){
+ if (o != null) {
moduleLoadCmdResource.setCmd(o.getCmd());
moduleLoadCmdResource.setAppDeploymentId(o.getAppDeploymentId());
moduleLoadCmdResource.setOrder(o.getOrder());
- moduleLoadCmdResource.setAppDeploymentResource((AppDeploymentResource)createApplicationDeployment(o.getApplicationDeployment()));
+ moduleLoadCmdResource.setAppDeploymentResource((AppDeploymentResource) createApplicationDeployment(o.getApplicationDeployment()));
}
return moduleLoadCmdResource;
}
-
- private static AppCatalogResource createWorkflow(Workflow o) {
- WorkflowResource workflowResource = new WorkflowResource();
- workflowResource.setWfName(o.getWfName());
- workflowResource.setCreatedUser(o.getCreatedUser());
- if (o.getGraph() != null){
- workflowResource.setGraph(new String(o.getGraph()));
- }
- if (o.getImage() != null){
- workflowResource.setImage(new String(o.getImage()));
- }
- workflowResource.setCreatedTime(o.getCreationTime());
- if (o.getUpdateTime() != null){
- workflowResource.setUpdatedTime(o.getUpdateTime());
- }
- workflowResource.setWfTemplateId(o.getWfTemplateId());
- workflowResource.setGatewayId(o.getGatewayId());
- return workflowResource;
- }
}
+
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/util/AppCatalogResourceType.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java
index 66a8a03..e30ea06 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java
@@ -63,8 +63,5 @@ public enum AppCatalogResourceType {
LOCAL_DATA_MOVEMENT,
MODULE_LOAD_CMD,
ClOUD_SUBMISSION,
- WORKFLOW,
- WORKFLOW_INPUT,
- WORKFLOW_OUTPUT,
GATEWAY_CLIENT_CREDENTIAL,
}
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/util/AppCatalogThriftConversion.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
index 1420fd1..056181f 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
@@ -21,7 +21,6 @@
package org.apache.airavata.registry.core.app.catalog.util;
-import org.apache.airavata.model.Workflow;
import org.apache.airavata.model.appcatalog.appdeployment.*;
import org.apache.airavata.model.appcatalog.appinterface.*;
import org.apache.airavata.model.appcatalog.computeresource.*;
@@ -846,30 +845,6 @@ public class AppCatalogThriftConversion {
return preferences;
}
- public static InputDataObjectType getWorkflowInput (WorkflowInputResource resource){
- InputDataObjectType input = new InputDataObjectType();
- input.setName(resource.getInputKey());
- input.setApplicationArgument(resource.getAppArgument());
- input.setInputOrder(resource.getInputOrder());
- input.setType(DataType.valueOf(resource.getDataType()));
- input.setMetaData(resource.getMetadata());
- input.setUserFriendlyDescription(resource.getUserFriendlyDesc());
- input.setIsRequired(resource.getRequired());
- input.setRequiredToAddedToCommandLine(resource.getRequiredToCMD());
- input.setDataStaged(resource.isDataStaged());
- return input;
- }
-
- public static List<InputDataObjectType> getWFInputs(List<AppCatalogResource> resources){
- List<InputDataObjectType> inputResources = new ArrayList<InputDataObjectType>();
- if (resources != null && !resources.isEmpty()){
- for (AppCatalogResource resource : resources){
- inputResources.add(getWorkflowInput((WorkflowInputResource) resource));
- }
- }
- return inputResources;
- }
-
public static GatewayResourceProfile getGatewayResourceProfile(GatewayProfileResource gw, List<ComputeResourcePreference> preferences, List<StoragePreference> storagePreferences){
GatewayResourceProfile gatewayProfile = new GatewayResourceProfile();
gatewayProfile.setGatewayID(gw.getGatewayID());
@@ -879,18 +854,4 @@ public class AppCatalogThriftConversion {
return gatewayProfile;
}
- public static Workflow getWorkflow (WorkflowResource resource) throws AppCatalogException {
- Workflow workflow = new Workflow();
- workflow.setTemplateId(resource.getWfTemplateId());
- workflow.setGraph(resource.getGraph());
- workflow.setName(resource.getWfName());
- if (resource.getImage() != null){
- workflow.setImage(resource.getImage().getBytes());
- }
- WorkflowInputResource inputResource = new WorkflowInputResource();
- List<AppCatalogResource> resources = inputResource.get(AppCatAbstractResource.WFInputConstants.WF_TEMPLATE_ID, resource.getWfTemplateId());
- workflow.setWorkflowInputs(getWFInputs(resources));
-
- return workflow;
- }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/ComponentStatus.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/ComponentStatus.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/ComponentStatus.java
index b6353b4..92c06de 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/ComponentStatus.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/ComponentStatus.java
@@ -43,6 +43,13 @@ public class ComponentStatus implements Serializable {
@Column(name = "UPDATE_TIME")
private Timestamp updateTime;
+ @Column(name = "TEMPLATE_ID")
+ private String templateId;
+
+ @ManyToOne(cascade= CascadeType.MERGE)
+ @JoinColumn(name = "TEMPLATE_ID")
+ private Workflow workflow;
+
public String getStatusId() {
return statusId;
}
@@ -74,5 +81,21 @@ public class ComponentStatus implements Serializable {
public void setUpdateTime(Timestamp updateTime) {
this.updateTime = updateTime;
}
+
+ public String getTemplateId() {
+ return templateId;
+ }
+
+ public void setTemplateId(String templateId) {
+ this.templateId = templateId;
+ }
+
+ public Workflow getWorkflow() {
+ return workflow;
+ }
+
+ public void setWorkflow(Workflow workflow) {
+ this.workflow = workflow;
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Edge.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Edge.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Edge.java
index 48ececb..8078000 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Edge.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Edge.java
@@ -48,6 +48,9 @@ public class Edge implements Serializable {
@Column(name = "DESCRIPTION")
private String description;
+ @Column(name = "CREATED_TIME")
+ private Timestamp createdTime;
+
@ManyToOne(cascade= CascadeType.MERGE)
@JoinColumn(name = "TEMPLATE_ID")
private Workflow workflow;
@@ -99,5 +102,13 @@ public class Edge implements Serializable {
public void setWorkflow(Workflow workflow) {
this.workflow = workflow;
}
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Node.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Node.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Node.java
index 0711ad5..54bd079 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Node.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Node.java
@@ -24,6 +24,7 @@ package org.apache.airavata.registry.core.workflow.catalog.model;
import javax.persistence.*;
import java.io.Serializable;
+import java.sql.Timestamp;
@Entity
@Table(name = "NODE")
@@ -53,6 +54,9 @@ public class Node implements Serializable {
@Column(name = "APPLICATION_NAME")
private String applicationName;
+ @Column(name = "CREATED_TIME")
+ private Timestamp createdTime;
+
@ManyToOne(cascade= CascadeType.MERGE)
@JoinColumn(name = "TEMPLATE_ID")
private Workflow workflow;
@@ -120,5 +124,13 @@ public class Node implements Serializable {
public void setApplicationName(String applicationName) {
this.applicationName = applicationName;
}
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Port.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Port.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Port.java
index f0be41f..0badd6e 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Port.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/Port.java
@@ -24,6 +24,7 @@ package org.apache.airavata.registry.core.workflow.catalog.model;
import javax.persistence.*;
import java.io.Serializable;
+import java.sql.Timestamp;
@Entity
@Table(name = "PORT")
@@ -47,6 +48,9 @@ public class Port implements Serializable {
@Column(name = "DESCRIPTION")
private String description;
+ @Column(name = "CREATED_TIME")
+ private Timestamp createdTime;
+
@ManyToOne(cascade= CascadeType.MERGE)
@JoinColumn(name = "TEMPLATE_ID")
private Workflow workflow;
@@ -98,5 +102,13 @@ public class Port implements Serializable {
public void setPortId(String portId) {
this.portId = portId;
}
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
}
[3/5] airavata git commit: adding workflow related resource layer
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/WorkflowInput.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/WorkflowInput.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/WorkflowInput.java
new file mode 100644
index 0000000..c9a319a
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/WorkflowInput.java
@@ -0,0 +1,167 @@
+/*
+ *
+ * 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.workflow.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 = "TEMPLATE_ID")
+ private String templateID;
+ @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 = "TEMPLATE_ID")
+ private Workflow workflow;
+
+ public String getTemplateID() {
+ return templateID;
+ }
+
+ public void setTemplateID(String templateID) {
+ this.templateID = templateID;
+ }
+
+ 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/workflow/catalog/model/WorkflowIntInput.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/WorkflowIntInput.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/WorkflowIntInput.java
deleted file mode 100644
index c8d4952..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/WorkflowIntInput.java
+++ /dev/null
@@ -1,166 +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.workflow.catalog.model;
-
-
-import javax.persistence.*;
-import java.io.Serializable;
-
-@Entity
-@Table(name = "WORKFLOW_INPUT")
-@IdClass(WorkflowInput_PK.class)
-public class WorkflowIntInput implements Serializable {
- @Id
- @Column(name = "INTERFACE_ID")
- private String templateID;
- @Id
- @Column(name = "INPUT_KEY")
- private String inputKey;
- @Column(name = "INPUT_VALUE")
- private String 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 = "TEMPLATE_ID")
- private Workflow workflow;
-
- public String getTemplateID() {
- return templateID;
- }
-
- public void setTemplateID(String templateID) {
- this.templateID = templateID;
- }
-
- public String getInputKey() {
- return inputKey;
- }
-
- public void setInputKey(String inputKey) {
- this.inputKey = inputKey;
- }
-
- public String getInputVal() {
- return inputVal;
- }
-
- public void setInputVal(String 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/workflow/catalog/model/WorkflowOutput.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/WorkflowOutput.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/WorkflowOutput.java
index 2131557..4a79ce8 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/WorkflowOutput.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/model/WorkflowOutput.java
@@ -35,8 +35,9 @@ public class WorkflowOutput implements Serializable {
@Id
@Column(name = "OUTPUT_KEY")
private String outputKey;
+ @Lob
@Column(name = "OUTPUT_VALUE")
- private String outputVal;
+ private char[] outputVal;
@Column(name = "DATA_TYPE")
private String dataType;
@Column(name = "IS_REQUIRED")
@@ -90,11 +91,11 @@ public class WorkflowOutput implements Serializable {
this.outputKey = outputKey;
}
- public String getOutputVal() {
+ public char[] getOutputVal() {
return outputVal;
}
- public void setOutputVal(String outputVal) {
+ public void setOutputVal(char[] outputVal) {
this.outputVal = outputVal;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/ComponentStatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/ComponentStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/ComponentStatusResource.java
new file mode 100644
index 0000000..f6d2ce6
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/ComponentStatusResource.java
@@ -0,0 +1,340 @@
+/**
+ * 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.workflow.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.workflow.catalog.model.ComponentStatus;
+import org.apache.airavata.registry.core.workflow.catalog.model.Workflow;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogJPAUtils;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogQueryGenerator;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogResourceType;
+import org.apache.airavata.registry.cpi.WorkflowCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ComponentStatusResource extends WorkflowCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(ComponentStatusResource.class);
+
+ private String statusId;
+ private String state;
+ private String reason;
+ private String templateId;
+ private Timestamp updatedTime;
+
+ public void remove(Object identifier) throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(COMPONENT_STATUS);
+ generator.setParameter(ComponentStatusConstants.STATUS_ID, identifier.toString());
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public WorkflowCatalogResource get(Object identifier) throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(COMPONENT_STATUS);
+ generator.setParameter(ComponentStatusConstants.STATUS_ID, identifier.toString());
+ Query q = generator.selectQuery(em);
+ ComponentStatus status = (ComponentStatus) q.getSingleResult();
+ ComponentStatusResource statusResource =
+ (ComponentStatusResource) WorkflowCatalogJPAUtils.getResource(WorkflowCatalogResourceType.COMPONENT_STATUS
+ , status);
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return statusResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<WorkflowCatalogResource> get(String fieldName, Object value) throws WorkflowCatalogException {
+ List<WorkflowCatalogResource> statusResources = new ArrayList<WorkflowCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(COMPONENT_STATUS);
+ List results;
+ if (fieldName.equals(ComponentStatusConstants.TEMPLATE_ID)) {
+ generator.setParameter(ComponentStatusConstants.TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ComponentStatus componentStatus = (ComponentStatus) result;
+ ComponentStatusResource statusResource =
+ (ComponentStatusResource) WorkflowCatalogJPAUtils.getResource(
+ WorkflowCatalogResourceType.COMPONENT_STATUS, componentStatus);
+ statusResources.add(statusResource);
+ }
+ }
+ }else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Component status Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Component status 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return statusResources;
+ }
+
+ public List<WorkflowCatalogResource> getAll() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getAllIds() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws WorkflowCatalogException {
+ List<String> statusResourceIds = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(COMPONENT_STATUS);
+ List results;
+ if (fieldName.equals(ComponentStatusConstants.TEMPLATE_ID)) {
+ generator.setParameter(ComponentStatusConstants.TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ComponentStatus componentStatus = (ComponentStatus) result;
+ statusResourceIds.add(componentStatus.getTemplateId());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Component Status resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Component Status 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return statusResourceIds;
+ }
+
+ public void save() throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ ComponentStatus existingStatus = em.find(ComponentStatus.class,statusId);
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingStatus != null) {
+ existingStatus.setTemplateId(templateId);
+ Workflow workflow = em.find(Workflow.class, templateId);
+ existingStatus.setWorkflow(workflow);
+ existingStatus.setReason(reason);
+ existingStatus.setState(state);
+ existingStatus.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ em.merge(existingStatus);
+ } else {
+ ComponentStatus status = new ComponentStatus();
+ status.setTemplateId(templateId);
+ Workflow workflow = em.find(Workflow.class, templateId);
+ status.setWorkflow(workflow);
+ status.setReason(reason);
+ status.setState(state);
+ status.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ em.persist(status);
+ }
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ ComponentStatus status = em.find(ComponentStatus.class, identifier.toString());
+
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return status != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getStatusId() {
+ return statusId;
+ }
+
+ public void setStatusId(String statusId) {
+ this.statusId = statusId;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ public String getTemplateId() {
+ return templateId;
+ }
+
+ public void setTemplateId(String templateId) {
+ this.templateId = templateId;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/EdgeResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/EdgeResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/EdgeResource.java
new file mode 100644
index 0000000..1613943
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/EdgeResource.java
@@ -0,0 +1,380 @@
+/**
+ * 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.workflow.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.workflow.catalog.model.Workflow;
+import org.apache.airavata.registry.core.workflow.catalog.model.Edge;
+import org.apache.airavata.registry.core.workflow.catalog.model.Edge_PK;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogJPAUtils;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogQueryGenerator;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogResourceType;
+import org.apache.airavata.registry.cpi.WorkflowCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class EdgeResource extends WorkflowCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(EdgeResource.class);
+
+ private String edgeId;
+ private String name;
+ private String statusId;
+ private String templateId;
+ private Timestamp createdTime;
+ private String description;
+
+ public void remove(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(EDGE);
+ generator.setParameter(EdgeConstants.EDGE_ID, ids.get(EdgeConstants.EDGE_ID));
+ generator.setParameter(EdgeConstants.TEMPLATE_ID, ids.get(EdgeConstants.TEMPLATE_ID));
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public WorkflowCatalogResource get(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(EDGE);
+ generator.setParameter(EdgeConstants.EDGE_ID, ids.get(EdgeConstants.EDGE_ID));
+ generator.setParameter(EdgeConstants.TEMPLATE_ID, ids.get(EdgeConstants.TEMPLATE_ID));
+ Query q = generator.selectQuery(em);
+ Edge edge = (Edge) q.getSingleResult();
+ EdgeResource edgeResource =
+ (EdgeResource) WorkflowCatalogJPAUtils.getResource(WorkflowCatalogResourceType.EDGE
+ , edge);
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return edgeResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<WorkflowCatalogResource> get(String fieldName, Object value) throws WorkflowCatalogException {
+ List<WorkflowCatalogResource> edgeResources = new ArrayList<WorkflowCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(EDGE);
+ List results;
+ if (fieldName.equals(EdgeConstants.TEMPLATE_ID)) {
+ generator.setParameter(EdgeConstants.TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Edge Edge = (Edge) result;
+ EdgeResource edgeResource =
+ (EdgeResource) WorkflowCatalogJPAUtils.getResource(
+ WorkflowCatalogResourceType.EDGE, Edge);
+ edgeResources.add(edgeResource);
+ }
+ }
+ }else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Edge Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Edge 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return edgeResources;
+ }
+
+ public List<WorkflowCatalogResource> getAll() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getAllIds() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws WorkflowCatalogException {
+ List<String> edgeResourceIds = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(EDGE);
+ List results;
+ if (fieldName.equals(EdgeConstants.TEMPLATE_ID)) {
+ generator.setParameter(EdgeConstants.TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Edge edge = (Edge) result;
+ edgeResourceIds.add(edge.getTemplateId());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Workflow Edge resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Workflow Edge 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return edgeResourceIds;
+ }
+
+ public void save() throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ Edge existingEdge = em.find(Edge.class,new Edge_PK(templateId, edgeId));
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingEdge != null) {
+ existingEdge.setTemplateId(templateId);
+ Workflow workflow = em.find(Workflow.class, templateId);
+ existingEdge.setWorkflow(workflow);
+ existingEdge.setComponentStatusId(statusId);
+ existingEdge.setDescription(description);
+ existingEdge.setName(name);
+ existingEdge.setCreatedTime(createdTime);
+ em.merge(existingEdge);
+ } else {
+ Edge edge = new Edge();
+ edge.setTemplateId(templateId);
+ Workflow workflow = em.find(Workflow.class, templateId);
+ edge.setWorkflow(workflow);
+ edge.setComponentStatusId(statusId);
+ edge.setDescription(description);
+ edge.setName(name);
+ edge.setCreatedTime(AiravataUtils.getCurrentTimestamp());
+ em.persist(edge);
+ }
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ Edge edge = em.find(Edge.class, new Edge_PK(ids.get(EdgeConstants.TEMPLATE_ID), ids.get(EdgeConstants.EDGE_ID)));
+
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return edge != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getStatusId() {
+ return statusId;
+ }
+
+ public void setStatusId(String statusId) {
+ this.statusId = statusId;
+ }
+
+ public String getTemplateId() {
+ return templateId;
+ }
+
+ public void setTemplateId(String templateId) {
+ this.templateId = templateId;
+ }
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public String getEdgeId() {
+ return edgeId;
+ }
+
+ public void setEdgeId(String edgeId) {
+ this.edgeId = edgeId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/NodeResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/NodeResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/NodeResource.java
new file mode 100644
index 0000000..ea034e7
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/NodeResource.java
@@ -0,0 +1,402 @@
+/**
+ * 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.workflow.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.workflow.catalog.model.Node;
+import org.apache.airavata.registry.core.workflow.catalog.model.Node_PK;
+import org.apache.airavata.registry.core.workflow.catalog.model.Workflow;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogJPAUtils;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogQueryGenerator;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogResourceType;
+import org.apache.airavata.registry.cpi.WorkflowCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class NodeResource extends WorkflowCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(NodeResource.class);
+
+ private String nodeId;
+ private String name;
+ private String statusId;
+ private String templateId;
+ private String applicationId;
+ private String applicationName;
+ private Timestamp createdTime;
+ private String description;
+
+ public void remove(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(NODE);
+ generator.setParameter(NodeConstants.NODE_ID, ids.get(NodeConstants.NODE_ID));
+ generator.setParameter(NodeConstants.TEMPLATE_ID, ids.get(NodeConstants.TEMPLATE_ID));
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public WorkflowCatalogResource get(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(NODE);
+ generator.setParameter(NodeConstants.NODE_ID, ids.get(NodeConstants.NODE_ID));
+ generator.setParameter(NodeConstants.TEMPLATE_ID, ids.get(NodeConstants.TEMPLATE_ID));
+ Query q = generator.selectQuery(em);
+ Node node = (Node) q.getSingleResult();
+ NodeResource nodeResource =
+ (NodeResource) WorkflowCatalogJPAUtils.getResource(WorkflowCatalogResourceType.NODE
+ , node);
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return nodeResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<WorkflowCatalogResource> get(String fieldName, Object value) throws WorkflowCatalogException {
+ List<WorkflowCatalogResource> nodeResources = new ArrayList<WorkflowCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(NODE);
+ List results;
+ if (fieldName.equals(NodeConstants.TEMPLATE_ID)) {
+ generator.setParameter(NodeConstants.TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Node node = (Node) result;
+ NodeResource nodeResource =
+ (NodeResource) WorkflowCatalogJPAUtils.getResource(
+ WorkflowCatalogResourceType.NODE, node);
+ nodeResources.add(nodeResource);
+ }
+ }
+ }else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Node Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Node 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return nodeResources;
+ }
+
+ public List<WorkflowCatalogResource> getAll() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getAllIds() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws WorkflowCatalogException {
+ List<String> nodeResourceIds = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(NODE);
+ List results;
+ if (fieldName.equals(NodeConstants.TEMPLATE_ID)) {
+ generator.setParameter(NodeConstants.TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Node node = (Node) result;
+ nodeResourceIds.add(node.getTemplateId());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Workflow node resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Workflow node 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return nodeResourceIds;
+ }
+
+ public void save() throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ Node existingNode = em.find(Node.class,new Node_PK(templateId, nodeId));
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingNode != null) {
+ existingNode.setTemplateId(templateId);
+ Workflow workflow = em.find(Workflow.class, templateId);
+ existingNode.setWorkflow(workflow);
+ existingNode.setComponentStatusId(statusId);
+ existingNode.setDescription(description);
+ existingNode.setName(name);
+ existingNode.setCreatedTime(createdTime);
+ existingNode.setApplicationName(applicationName);
+ existingNode.setApplicationId(applicationId);
+ em.merge(existingNode);
+ } else {
+ Node node = new Node();
+ node.setTemplateId(templateId);
+ Workflow workflow = em.find(Workflow.class, templateId);
+ node.setWorkflow(workflow);
+ node.setComponentStatusId(statusId);
+ node.setDescription(description);
+ node.setName(name);
+ node.setCreatedTime(AiravataUtils.getCurrentTimestamp());
+ node.setApplicationName(applicationName);
+ node.setApplicationId(applicationId);
+ em.persist(node);
+ }
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ Node port = em.find(Node.class, new Node_PK(ids.get(NodeConstants.TEMPLATE_ID), ids.get(NodeConstants.NODE_ID)));
+
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return port != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getStatusId() {
+ return statusId;
+ }
+
+ public void setStatusId(String statusId) {
+ this.statusId = statusId;
+ }
+
+ public String getTemplateId() {
+ return templateId;
+ }
+
+ public void setTemplateId(String templateId) {
+ this.templateId = templateId;
+ }
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public String getApplicationId() {
+ return applicationId;
+ }
+
+ public void setApplicationId(String applicationId) {
+ this.applicationId = applicationId;
+ }
+
+ public String getApplicationName() {
+ return applicationName;
+ }
+
+ public void setApplicationName(String applicationName) {
+ this.applicationName = applicationName;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/PortResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/PortResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/PortResource.java
new file mode 100644
index 0000000..9cdaebf
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/PortResource.java
@@ -0,0 +1,380 @@
+/**
+ * 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.workflow.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.workflow.catalog.model.Port;
+import org.apache.airavata.registry.core.workflow.catalog.model.Port_PK;
+import org.apache.airavata.registry.core.workflow.catalog.model.Workflow;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogJPAUtils;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogQueryGenerator;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogResourceType;
+import org.apache.airavata.registry.cpi.WorkflowCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class PortResource extends WorkflowCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(PortResource.class);
+
+ private String portId;
+ private String name;
+ private String statusId;
+ private String templateId;
+ private Timestamp createdTime;
+ private String description;
+
+ public void remove(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(PORT);
+ generator.setParameter(PortConstants.PORT_ID, ids.get(PortConstants.PORT_ID));
+ generator.setParameter(PortConstants.TEMPLATE_ID, ids.get(PortConstants.TEMPLATE_ID));
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public WorkflowCatalogResource get(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(PORT);
+ generator.setParameter(PortConstants.PORT_ID, ids.get(PortConstants.PORT_ID));
+ generator.setParameter(PortConstants.TEMPLATE_ID, ids.get(PortConstants.TEMPLATE_ID));
+ Query q = generator.selectQuery(em);
+ Port port = (Port) q.getSingleResult();
+ PortResource portResource =
+ (PortResource) WorkflowCatalogJPAUtils.getResource(WorkflowCatalogResourceType.PORT
+ , port);
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return portResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<WorkflowCatalogResource> get(String fieldName, Object value) throws WorkflowCatalogException {
+ List<WorkflowCatalogResource> portResources = new ArrayList<WorkflowCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(PORT);
+ List results;
+ if (fieldName.equals(PortConstants.TEMPLATE_ID)) {
+ generator.setParameter(PortConstants.TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Port port = (Port) result;
+ PortResource portResource =
+ (PortResource) WorkflowCatalogJPAUtils.getResource(
+ WorkflowCatalogResourceType.PORT, port);
+ portResources.add(portResource);
+ }
+ }
+ }else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Port Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Port 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return portResources;
+ }
+
+ public List<WorkflowCatalogResource> getAll() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getAllIds() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws WorkflowCatalogException {
+ List<String> portResourceIds = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(PORT);
+ List results;
+ if (fieldName.equals(PortConstants.TEMPLATE_ID)) {
+ generator.setParameter(PortConstants.TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Port port = (Port) result;
+ portResourceIds.add(port.getTemplateId());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Workflow port resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Workflow port 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return portResourceIds;
+ }
+
+ public void save() throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ Port existingPort = em.find(Port.class,new Port_PK(templateId, portId));
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingPort != null) {
+ existingPort.setTemplateId(templateId);
+ Workflow workflow = em.find(Workflow.class, templateId);
+ existingPort.setWorkflow(workflow);
+ existingPort.setComponentStatusId(statusId);
+ existingPort.setDescription(description);
+ existingPort.setName(name);
+ existingPort.setCreatedTime(createdTime);
+ em.merge(existingPort);
+ } else {
+ Port edge = new Port();
+ edge.setTemplateId(templateId);
+ Workflow workflow = em.find(Workflow.class, templateId);
+ edge.setWorkflow(workflow);
+ edge.setComponentStatusId(statusId);
+ edge.setDescription(description);
+ edge.setName(name);
+ edge.setCreatedTime(AiravataUtils.getCurrentTimestamp());
+ em.persist(edge);
+ }
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ Port port = em.find(Port.class, new Port_PK(ids.get(PortConstants.TEMPLATE_ID), ids.get(PortConstants.PORT_ID)));
+
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return port != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getStatusId() {
+ return statusId;
+ }
+
+ public void setStatusId(String statusId) {
+ this.statusId = statusId;
+ }
+
+ public String getTemplateId() {
+ return templateId;
+ }
+
+ public void setTemplateId(String templateId) {
+ this.templateId = templateId;
+ }
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public String getPortId() {
+ return portId;
+ }
+
+ public void setPortId(String portId) {
+ this.portId = portId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowCatAbstractResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowCatAbstractResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowCatAbstractResource.java
new file mode 100644
index 0000000..cb90fe9
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowCatAbstractResource.java
@@ -0,0 +1,88 @@
+/*
+ *
+ * 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.workflow.catalog.resources;
+
+public abstract class WorkflowCatAbstractResource implements WorkflowCatalogResource {
+ // table names
+ public static final String WORKFLOW = "Workflow";
+ public static final String WORKFLOW_INPUT = "WorkflowInput";
+ public static final String WORKFLOW_OUTPUT = "WorkflowOutput";
+ public static final String EDGE = "Edge";
+ public static final String NODE = "Node";
+ public static final String PORT = "Port";
+ public static final String COMPONENT_STATUS = "ComponentStatus";
+ public static final String WORKFLOW_STATUS = "WorkflowStatus";
+
+ public final class WorkflowInputConstants {
+ public static final String WF_TEMPLATE_ID = "templateID";
+ public static final String INPUT_KEY = "inputKey";
+ public static final String INPUT_VALUE = "inputVal";
+ public static final String DATA_TYPE = "dataType";
+ public static final String METADATA = "metadata";
+ public static final String APP_ARGUMENT = "appArgument";
+ public static final String USER_FRIENDLY_DESC = "userFriendlyDesc";
+ public static final String STANDARD_INPUT = "standardInput";
+ }
+
+ public final class WorkflowOutputConstants {
+ public static final String WF_TEMPLATE_ID = "templateId";
+ public static final String OUTPUT_KEY = "outputKey";
+ public static final String OUTPUT_VALUE = "outputVal";
+ public static final String DATA_TYPE = "dataType";
+ }
+
+ // Workflow Table
+ public final class WorkflowConstants {
+ public static final String TEMPLATE_ID = "templateId";
+ public static final String GATEWAY_ID = "gatewayId";
+ public static final String WORKFLOW_NAME = "workflowName";
+ }
+
+ public final class ComponentStatusConstants {
+ public static final String STATUS_ID = "statusId";
+ public static final String TEMPLATE_ID = "templateId";
+ }
+
+ public final class WorkflowStatusConstants {
+ public static final String STATUS_ID = "statusId";
+ public static final String TEMPLATE_ID = "templateId";
+ }
+
+ public final class EdgeConstants {
+ public static final String STATUS_ID = "statusId";
+ public static final String TEMPLATE_ID = "templateId";
+ public static final String EDGE_ID = "edgeId";
+ }
+
+ public final class PortConstants {
+ public static final String STATUS_ID = "statusId";
+ public static final String TEMPLATE_ID = "templateId";
+ public static final String PORT_ID = "portId";
+ }
+
+ public final class NodeConstants {
+ public static final String STATUS_ID = "statusId";
+ public static final String TEMPLATE_ID = "templateId";
+ public static final String NODE_ID = "nodeId";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowCatalogResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowCatalogResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowCatalogResource.java
new file mode 100644
index 0000000..d536776
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowCatalogResource.java
@@ -0,0 +1,90 @@
+/*
+*
+* 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.workflow.catalog.resources;
+
+
+import org.apache.airavata.registry.cpi.WorkflowCatalogException;
+
+import java.util.List;
+
+public interface WorkflowCatalogResource {
+
+ /**
+ * This method will remove the given resource from the database
+ *
+ * @param identifier identifier that can uniquely identify a single instance of the resource
+ */
+ void remove(Object identifier) throws WorkflowCatalogException;
+
+ /**
+ * This method will return the given resource from the database
+ *
+ * @param identifier identifier that can uniquely identify a single instance of the resource
+ * @return associate resource
+ */
+ WorkflowCatalogResource get(Object identifier) throws WorkflowCatalogException;
+
+ /**
+ * This method will list all the resources according to the filtering criteria
+ * @param fieldName field name
+ * @param value value of the field
+ * @return list of resources
+ */
+ List<WorkflowCatalogResource> get(String fieldName, Object value) throws WorkflowCatalogException;
+
+ /**
+ *
+ * @return
+ * @throws org.apache.airavata.registry.cpi.WorkflowCatalogException
+ */
+ List<WorkflowCatalogResource> getAll() throws WorkflowCatalogException;
+
+ /**
+ *
+ * @return
+ * @throws org.apache.airavata.registry.cpi.WorkflowCatalogException
+ */
+ List<String> getAllIds() throws WorkflowCatalogException;
+
+ /** This method will return list of resource ids according to given criteria
+ * @param fieldName field name
+ * @param value value of the field
+ * @return list of resource Ids
+ * @throws org.apache.airavata.registry.cpi.WorkflowCatalogException
+ */
+ List<String> getIds(String fieldName, Object value) throws WorkflowCatalogException;
+
+ /**
+ * This method will save the resource to the database.
+ */
+ void save() throws WorkflowCatalogException;
+
+ /**
+ * This method will check whether an entry from the given resource and resource name
+ * exists in the database
+ *
+ * @param identifier identifier that can uniquely identify a single instance of the resource
+ * @return whether the entry exists in the database or not
+ */
+ boolean isExists(Object identifier) throws WorkflowCatalogException;
+
+
+}
[5/5] airavata git commit: adding workflow related resource layer
Posted by ch...@apache.org.
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/develop
Commit: 2a2782a60ab40f93677063c2c31cdf28c77ba487
Parents: ad01161
Author: Chathuri Wimalasena <ch...@apache.org>
Authored: Wed Feb 3 12:10:50 2016 -0500
Committer: Chathuri Wimalasena <ch...@apache.org>
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;
- }
-}
[2/5] airavata git commit: adding workflow related resource layer
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowInputResource.java
new file mode 100644
index 0000000..5cda60b
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowInputResource.java
@@ -0,0 +1,496 @@
+/**
+ * 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.workflow.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.workflow.catalog.model.Workflow;
+import org.apache.airavata.registry.core.workflow.catalog.model.WorkflowInput;
+import org.apache.airavata.registry.core.workflow.catalog.model.WorkflowInput_PK;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogJPAUtils;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogQueryGenerator;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogResourceType;
+import org.apache.airavata.registry.cpi.WorkflowCatalogException;
+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 WorkflowCatAbstractResource {
+
+ 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 WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW_INPUT);
+ generator.setParameter(WorkflowInputConstants.WF_TEMPLATE_ID, ids.get(WorkflowInputConstants.WF_TEMPLATE_ID));
+ generator.setParameter(WorkflowInputConstants.INPUT_KEY, ids.get(WorkflowInputConstants.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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public WorkflowCatalogResource get(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW_INPUT);
+ generator.setParameter(WorkflowInputConstants.WF_TEMPLATE_ID, ids.get(WorkflowInputConstants.WF_TEMPLATE_ID));
+ generator.setParameter(WorkflowInputConstants.INPUT_KEY, ids.get(WorkflowInputConstants.INPUT_KEY));
+ Query q = generator.selectQuery(em);
+ WorkflowInput workflowInput = (WorkflowInput) q.getSingleResult();
+ WorkflowInputResource workflowInputResource =
+ (WorkflowInputResource) WorkflowCatalogJPAUtils.getResource(WorkflowCatalogResourceType.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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<WorkflowCatalogResource> get(String fieldName, Object value) throws WorkflowCatalogException {
+ List<WorkflowCatalogResource> wfInputResources = new ArrayList<WorkflowCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW_INPUT);
+ List results;
+ if (fieldName.equals(WorkflowInputConstants.WF_TEMPLATE_ID)) {
+ generator.setParameter(WorkflowInputConstants.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) WorkflowCatalogJPAUtils.getResource(
+ WorkflowCatalogResourceType.WORKFLOW_INPUT, workflowInput);
+ wfInputResources.add(workflowInputResource);
+ }
+ }
+ } else if (fieldName.equals(WorkflowInputConstants.INPUT_KEY)) {
+ generator.setParameter(WorkflowInputConstants.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) WorkflowCatalogJPAUtils.getResource(
+ WorkflowCatalogResourceType.WORKFLOW_INPUT, workflowInput);
+ wfInputResources.add(workflowInputResource);
+ }
+ }
+ } else if (fieldName.equals(WorkflowInputConstants.DATA_TYPE)) {
+ generator.setParameter(WorkflowInputConstants.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) WorkflowCatalogJPAUtils.getResource(
+ WorkflowCatalogResourceType.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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return wfInputResources;
+ }
+
+ public List<WorkflowCatalogResource> getAll() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getAllIds() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws WorkflowCatalogException {
+ List<String> wfInputResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW_INPUT);
+ List results;
+ if (fieldName.equals(WorkflowInputConstants.WF_TEMPLATE_ID)) {
+ generator.setParameter(WorkflowInputConstants.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.getTemplateID());
+ }
+ }
+ } else if (fieldName.equals(WorkflowInputConstants.INPUT_KEY)) {
+ generator.setParameter(WorkflowInputConstants.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.getTemplateID());
+ }
+ }
+ } else if (fieldName.equals(WorkflowInputConstants.DATA_TYPE)) {
+ generator.setParameter(WorkflowInputConstants.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.getTemplateID());
+ }
+ }
+ } 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return wfInputResourceIDs;
+ }
+
+ public void save() throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.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 = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingWFInput == null) {
+ workflowInput = new WorkflowInput();
+ } else {
+ workflowInput=existingWFInput;
+ }
+ workflowInput.setTemplateID(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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ WorkflowInput workflowInput = em.find(WorkflowInput.class, new WorkflowInput_PK(
+ ids.get(WorkflowInputConstants.WF_TEMPLATE_ID),
+ ids.get(WorkflowInputConstants.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 WorkflowCatalogException(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/workflow/catalog/resources/WorkflowOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowOutputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowOutputResource.java
new file mode 100644
index 0000000..910136f
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowOutputResource.java
@@ -0,0 +1,489 @@
+/**
+ * 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.workflow.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.workflow.catalog.model.Workflow;
+import org.apache.airavata.registry.core.workflow.catalog.model.WorkflowOutput;
+import org.apache.airavata.registry.core.workflow.catalog.model.WorkflowOutput_PK;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogJPAUtils;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogQueryGenerator;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogResourceType;
+import org.apache.airavata.registry.cpi.WorkflowCatalogException;
+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 WorkflowCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(WorkflowOutputResource.class);
+
+ private String wfTemplateId;
+ private String outputKey;
+ private String outputVal;
+ private String dataType;
+ private boolean isRequired;
+ private boolean dataMovement;
+ private String dataNameLocation;
+ private boolean requiredToCMD;
+ private String searchQuery;
+ private String appArgument;
+ private boolean outputStreaming;
+
+ private WorkflowResource workflowResource;
+
+ public void remove(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW_OUTPUT);
+ generator.setParameter(WorkflowOutputConstants.WF_TEMPLATE_ID, ids.get(WorkflowOutputConstants.WF_TEMPLATE_ID));
+ generator.setParameter(WorkflowOutputConstants.OUTPUT_KEY, ids.get(WorkflowOutputConstants.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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public WorkflowCatalogResource get(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW_OUTPUT);
+ generator.setParameter(WorkflowOutputConstants.WF_TEMPLATE_ID, ids.get(WorkflowOutputConstants.WF_TEMPLATE_ID));
+ generator.setParameter(WorkflowOutputConstants.OUTPUT_KEY, ids.get(WorkflowOutputConstants.OUTPUT_KEY));
+ Query q = generator.selectQuery(em);
+ WorkflowOutput wfOutput = (WorkflowOutput) q.getSingleResult();
+ WorkflowOutputResource workflowOutputResource =
+ (WorkflowOutputResource) WorkflowCatalogJPAUtils.getResource(WorkflowCatalogResourceType.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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<WorkflowCatalogResource> get(String fieldName, Object value) throws WorkflowCatalogException {
+ List<WorkflowCatalogResource> wfOutputResources = new ArrayList<WorkflowCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW_OUTPUT);
+ List results;
+ if (fieldName.equals(WorkflowOutputConstants.WF_TEMPLATE_ID)) {
+ generator.setParameter(WorkflowOutputConstants.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) WorkflowCatalogJPAUtils.getResource(
+ WorkflowCatalogResourceType.WORKFLOW_OUTPUT, wfOutput);
+ wfOutputResources.add(workflowOutputResource);
+ }
+ }
+ } else if (fieldName.equals(WorkflowOutputConstants.OUTPUT_KEY)) {
+ generator.setParameter(WorkflowOutputConstants.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) WorkflowCatalogJPAUtils.getResource(
+ WorkflowCatalogResourceType.WORKFLOW_OUTPUT, workflowOutput);
+ wfOutputResources.add(workflowOutputResource);
+ }
+ }
+ } else if (fieldName.equals(WorkflowOutputConstants.DATA_TYPE)) {
+ generator.setParameter(WorkflowOutputConstants.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) WorkflowCatalogJPAUtils.getResource(
+ WorkflowCatalogResourceType.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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return wfOutputResources;
+ }
+
+ public List<WorkflowCatalogResource> getAll() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getAllIds() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws WorkflowCatalogException {
+ List<String> wfOutputResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW_OUTPUT);
+ List results;
+ if (fieldName.equals(WorkflowOutputConstants.WF_TEMPLATE_ID)) {
+ generator.setParameter(WorkflowOutputConstants.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.getTemplateId());
+ }
+ }
+ }
+ if (fieldName.equals(WorkflowOutputConstants.OUTPUT_KEY)) {
+ generator.setParameter(WorkflowOutputConstants.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.getTemplateId());
+ }
+ }
+ } else if (fieldName.equals(WorkflowOutputConstants.DATA_TYPE)) {
+ generator.setParameter(WorkflowOutputConstants.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.getTemplateId());
+ }
+ }
+ } 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return wfOutputResourceIDs;
+ }
+
+ public void save() throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.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 = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingWorkflowOutput != null) {
+ existingWorkflowOutput.setTemplateId(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.setDataMovement(dataMovement);
+ existingWorkflowOutput.setDataNameLocation(dataNameLocation);
+ em.merge(existingWorkflowOutput);
+ } else {
+ WorkflowOutput workflowOutput = new WorkflowOutput();
+ workflowOutput.setTemplateId(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.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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ WorkflowOutput workflowOutput = em.find(WorkflowOutput.class, new WorkflowOutput_PK(
+ ids.get(WorkflowOutputConstants.WF_TEMPLATE_ID),
+ ids.get(WorkflowOutputConstants.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 WorkflowCatalogException(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 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;
+ }
+
+ 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 String getSearchQuery() {
+ return searchQuery;
+ }
+
+ public void setSearchQuery(String searchQuery) {
+ this.searchQuery = searchQuery;
+ }
+
+ public String getAppArgument() {
+ return appArgument;
+ }
+
+ public void setAppArgument(String appArgument) {
+ this.appArgument = appArgument;
+ }
+
+ public boolean isOutputStreaming() {
+ return outputStreaming;
+ }
+
+ public void setOutputStreaming(boolean outputStreaming) {
+ this.outputStreaming = outputStreaming;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowResource.java
new file mode 100644
index 0000000..d487742
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowResource.java
@@ -0,0 +1,437 @@
+/*
+ *
+ * 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.workflow.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.workflow.catalog.model.Workflow;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogJPAUtils;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogQueryGenerator;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogResourceType;
+import org.apache.airavata.registry.cpi.WorkflowCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+public class WorkflowResource extends WorkflowCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(WorkflowResource.class);
+ private String wfName;
+ private String createdUser;
+ private String graph;
+ private String wfTemplateId;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+ private String image;
+ private String gatewayId;
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ @Override
+ public void remove(Object identifier) throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW);
+ generator.setParameter(WorkflowConstants.TEMPLATE_ID, identifier);
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public WorkflowCatalogResource get(Object identifier) throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW);
+ generator.setParameter(WorkflowConstants.TEMPLATE_ID, identifier);
+ Query q = generator.selectQuery(em);
+ Workflow workflow = (Workflow) q.getSingleResult();
+ WorkflowResource workflowResource = (WorkflowResource) WorkflowCatalogJPAUtils.getResource(WorkflowCatalogResourceType.WORKFLOW, workflow);
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return workflowResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<WorkflowCatalogResource> get(String fieldName, Object value) throws WorkflowCatalogException {
+ List<WorkflowCatalogResource> workflowResources = new ArrayList<WorkflowCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW);
+ Query q;
+ if ((fieldName.equals(WorkflowConstants.TEMPLATE_ID)) || (fieldName.equals(WorkflowConstants.GATEWAY_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ Workflow workflow = (Workflow) result;
+ WorkflowResource workflowResource = (WorkflowResource) WorkflowCatalogJPAUtils.getResource(WorkflowCatalogResourceType.WORKFLOW, workflow);
+ workflowResources.add(workflowResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Workflow Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Workflow Resource.");
+ }
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return workflowResources;
+ }
+
+ @Override
+ public List<WorkflowCatalogResource> getAll() throws WorkflowCatalogException {
+ List<WorkflowCatalogResource> workflows = new ArrayList<WorkflowCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW);
+ generator.setParameter(WorkflowConstants.GATEWAY_ID, gatewayId);
+ Query q = generator.selectQuery(em);
+ List results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Workflow workflow = (Workflow) result;
+ WorkflowResource wfResource =
+ (WorkflowResource) WorkflowCatalogJPAUtils.getResource(WorkflowCatalogResourceType.WORKFLOW, workflow);
+ workflows.add(wfResource);
+ }
+ }
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return workflows;
+ }
+
+ @Override
+ public List<String> getAllIds() throws WorkflowCatalogException {
+ List<String> workflowIds = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW);
+ generator.setParameter(WorkflowConstants.GATEWAY_ID, gatewayId);
+ Query q = generator.selectQuery(em);
+ List results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Workflow workflow = (Workflow) result;
+ workflowIds.add(workflow.getTemplateId());
+ }
+ }
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return workflowIds;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws WorkflowCatalogException {
+ List<String> workflowResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW);
+ Query q;
+ if ((fieldName.equals(WorkflowConstants.TEMPLATE_ID)) || (fieldName.equals(WorkflowConstants.GATEWAY_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ Workflow workflow = (Workflow) result;
+ WorkflowResource workflowResource = (WorkflowResource) WorkflowCatalogJPAUtils.getResource(WorkflowCatalogResourceType.WORKFLOW, workflow);
+ workflowResourceIDs.add(workflowResource.getWfTemplateId());
+ }
+ } else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Workflow Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Workflow Resource.");
+ }
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return workflowResourceIDs;
+ }
+
+ @Override
+ public void save() throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ Workflow existingWorkflow = em.find(Workflow.class, wfTemplateId);
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ Workflow workflow;
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingWorkflow == null) {
+ workflow = new Workflow();
+ workflow.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ } else {
+ workflow = existingWorkflow;
+ workflow.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ }
+ workflow.setWorkflowName(getWfName());
+ workflow.setCreatedUser(getCreatedUser());
+ workflow.setGatewayId(gatewayId);
+ if (getGraph() != null){
+ workflow.setGraph(getGraph().toCharArray());
+ }
+ if (image != null){
+ workflow.setImage(image.getBytes());
+ }
+ workflow.setTemplateId(getWfTemplateId());
+ if (existingWorkflow == null) {
+ em.persist(workflow);
+ } else {
+ em.merge(workflow);
+ }
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ Workflow workflow = em.find(Workflow.class, identifier);
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return workflow != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getWfName() {
+ return wfName;
+ }
+
+ public String getCreatedUser() {
+ return createdUser;
+ }
+
+ public String 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(String graph) {
+ this.graph=graph;
+ }
+
+ public void setWfTemplateId(String wfTemplateId) {
+ this.wfTemplateId=wfTemplateId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowStatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowStatusResource.java
new file mode 100644
index 0000000..3e0c034
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/resources/WorkflowStatusResource.java
@@ -0,0 +1,369 @@
+/**
+ * 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.workflow.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.workflow.catalog.model.Workflow;
+import org.apache.airavata.registry.core.workflow.catalog.model.WorkflowStatus;
+import org.apache.airavata.registry.core.workflow.catalog.model.WorkflowStatus_PK;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogJPAUtils;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogQueryGenerator;
+import org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogResourceType;
+import org.apache.airavata.registry.cpi.WorkflowCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class WorkflowStatusResource extends WorkflowCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(WorkflowStatusResource.class);
+
+ private String statusId;
+ private String state;
+ private String reason;
+ private String templateId;
+ private Timestamp updatedTime;
+
+ public void remove(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW_STATUS);
+ generator.setParameter(WorkflowStatusConstants.STATUS_ID, ids.get(WorkflowStatusConstants.STATUS_ID));
+ generator.setParameter(WorkflowStatusConstants.TEMPLATE_ID, ids.get(WorkflowStatusConstants.TEMPLATE_ID));
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public WorkflowCatalogResource get(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW_STATUS);
+ generator.setParameter(WorkflowStatusConstants.STATUS_ID, ids.get(WorkflowStatusConstants.STATUS_ID));
+ generator.setParameter(WorkflowStatusConstants.TEMPLATE_ID, ids.get(WorkflowStatusConstants.TEMPLATE_ID));
+ Query q = generator.selectQuery(em);
+ WorkflowStatus status = (WorkflowStatus) q.getSingleResult();
+ WorkflowStatusResource statusResource =
+ (WorkflowStatusResource) WorkflowCatalogJPAUtils.getResource(WorkflowCatalogResourceType.WORKFLOW_STATUS
+ , status);
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return statusResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<WorkflowCatalogResource> get(String fieldName, Object value) throws WorkflowCatalogException {
+ List<WorkflowCatalogResource> statusResources = new ArrayList<WorkflowCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW_STATUS);
+ List results;
+ if (fieldName.equals(WorkflowStatusConstants.TEMPLATE_ID)) {
+ generator.setParameter(WorkflowStatusConstants.TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowStatus WorkflowStatus = (WorkflowStatus) result;
+ WorkflowStatusResource statusResource =
+ (WorkflowStatusResource) WorkflowCatalogJPAUtils.getResource(
+ WorkflowCatalogResourceType.WORKFLOW_STATUS, WorkflowStatus);
+ statusResources.add(statusResource);
+ }
+ }
+ }else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Workflow status Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Workflow status 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return statusResources;
+ }
+
+ public List<WorkflowCatalogResource> getAll() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getAllIds() throws WorkflowCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws WorkflowCatalogException {
+ List<String> statusResourceIds = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ WorkflowCatalogQueryGenerator generator = new WorkflowCatalogQueryGenerator(WORKFLOW_STATUS);
+ List results;
+ if (fieldName.equals(WorkflowStatusConstants.TEMPLATE_ID)) {
+ generator.setParameter(WorkflowStatusConstants.TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowStatus WorkflowStatus = (WorkflowStatus) result;
+ statusResourceIds.add(WorkflowStatus.getTemplateId());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Workflow Status resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Workflow Status 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return statusResourceIds;
+ }
+
+ public void save() throws WorkflowCatalogException {
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ WorkflowStatus existingStatus = em.find(WorkflowStatus.class,new WorkflowStatus_PK(templateId, statusId));
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingStatus != null) {
+ existingStatus.setTemplateId(templateId);
+ Workflow workflow = em.find(Workflow.class, templateId);
+ existingStatus.setWorkflow(workflow);
+ existingStatus.setReason(reason);
+ existingStatus.setState(state);
+ existingStatus.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ em.merge(existingStatus);
+ } else {
+ WorkflowStatus status = new WorkflowStatus();
+ status.setTemplateId(templateId);
+ Workflow workflow = em.find(Workflow.class, templateId);
+ status.setWorkflow(workflow);
+ status.setReason(reason);
+ status.setState(state);
+ status.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ em.persist(status);
+ }
+ 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 WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws WorkflowCatalogException {
+ 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 WorkflowCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = WorkflowCatalogJPAUtils.getEntityManager();
+ WorkflowStatus status = em.find(WorkflowStatus.class, new WorkflowStatus_PK(ids.get(WorkflowStatusConstants.TEMPLATE_ID),ids.get(WorkflowStatusConstants.STATUS_ID)));
+
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return status != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new WorkflowCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getStatusId() {
+ return statusId;
+ }
+
+ public void setStatusId(String statusId) {
+ this.statusId = statusId;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ public String getTemplateId() {
+ return templateId;
+ }
+
+ public void setTemplateId(String templateId) {
+ this.templateId = templateId;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/2a2782a6/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogJPAUtils.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogJPAUtils.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogJPAUtils.java
new file mode 100644
index 0000000..c78ef9b
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/workflow/catalog/utils/WorkflowCatalogJPAUtils.java
@@ -0,0 +1,270 @@
+/*
+ *
+ * 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.workflow.catalog.utils;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.registry.core.workflow.catalog.model.*;
+import org.apache.airavata.registry.core.workflow.catalog.resources.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+import java.util.HashMap;
+import java.util.Map;
+
+public class WorkflowCatalogJPAUtils {
+ private final static Logger logger = LoggerFactory.getLogger(WorkflowCatalogJPAUtils.class);
+ private static final String PERSISTENCE_UNIT_NAME = "workflowcatalog_data";
+ private static final String WFCATALOG_JDBC_DRIVER = "wfcatalog.jdbc.driver";
+ private static final String WFCATALOG_JDBC_URL = "wfcatalog.jdbc.url";
+ private static final String WFCATALOG_JDBC_USER = "wfcatalog.jdbc.user";
+ private static final String WFCATALOG_JDBC_PASSWORD = "wfcatalog.jdbc.password";
+ private static final String WFCATALOG_VALIDATION_QUERY = "wfcatalog.validationQuery";
+ private static final String JPA_CACHE_SIZE = "jpa.cache.size";
+ private static final String JPA_CACHE_ENABLED = "cache.enable";
+ @PersistenceUnit(unitName="workflowcatalog_data")
+ protected static EntityManagerFactory factory;
+ @PersistenceContext(unitName="worlkflowcatalog_data")
+ private static EntityManager wfCatEntityManager;
+
+ public static EntityManager getEntityManager() throws ApplicationSettingsException {
+ if (factory == null) {
+ String connectionProperties = "DriverClassName=" + readServerProperties(WFCATALOG_JDBC_DRIVER) + "," +
+ "Url=" + readServerProperties(WFCATALOG_JDBC_URL) + "?autoReconnect=true," +
+ "Username=" + readServerProperties(WFCATALOG_JDBC_USER) + "," +
+ "Password=" + readServerProperties(WFCATALOG_JDBC_PASSWORD) +
+ ",validationQuery=" + readServerProperties(WFCATALOG_VALIDATION_QUERY);
+ System.out.println(connectionProperties);
+ Map<String, String> properties = new HashMap<String, String>();
+ properties.put("openjpa.ConnectionDriverName", "org.apache.commons.dbcp.BasicDataSource");
+ properties.put("openjpa.ConnectionProperties", connectionProperties);
+ properties.put("openjpa.DynamicEnhancementAgent", "true");
+ properties.put("openjpa.RuntimeUnenhancedClasses", "unsupported");
+ // For app catalog, we don't need caching
+// properties.put("openjpa.DataCache","" + readServerProperties(JPA_CACHE_ENABLED) + "(CacheSize=" + Integer.valueOf(readServerProperties(JPA_CACHE_SIZE)) + ", SoftReferenceSize=0)");
+// properties.put("openjpa.QueryCache","" + readServerProperties(JPA_CACHE_ENABLED) + "(CacheSize=" + Integer.valueOf(readServerProperties(JPA_CACHE_SIZE)) + ", SoftReferenceSize=0)");
+ properties.put("openjpa.RemoteCommitProvider","sjvm");
+ properties.put("openjpa.Log","DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=INFO");
+ properties.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
+ properties.put("openjpa.jdbc.QuerySQLCache", "false");
+ properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72, PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=31536000, autoReconnect=true");
+ factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties);
+ }
+ wfCatEntityManager = factory.createEntityManager();
+ return wfCatEntityManager;
+ }
+
+ private static String readServerProperties (String propertyName) throws ApplicationSettingsException {
+ try {
+ return ServerSettings.getSetting(propertyName);
+ } catch (ApplicationSettingsException e) {
+ logger.error("Unable to read airavata-server.properties...", e);
+ throw new ApplicationSettingsException("Unable to read airavata-server.properties...");
+ }
+ }
+
+ /**
+ *
+ * @param type model type
+ * @param o model type instance
+ * @return corresponding resource object
+ */
+ public static WorkflowCatalogResource getResource(WorkflowCatalogResourceType type, Object o) {
+ switch (type){
+ case WORKFLOW:
+ if (o instanceof Workflow) {
+ return createWorkflow((Workflow) o);
+ } else {
+ logger.error("Object should be a Workflow.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Workflow.");
+ }
+ case WORKFLOW_INPUT:
+ if (o instanceof WorkflowInput){
+ return createWorflowInput((WorkflowInput) o);
+ }else {
+ logger.error("Object should be a Workflow Input.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Workflow Input.");
+ }
+ case WORKFLOW_OUTPUT:
+ if (o instanceof WorkflowOutput){
+ return createWorkflowOutput((WorkflowOutput) o);
+ }else {
+ logger.error("Object should be a Workflow Output.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Workflow Output.");
+ }
+ case COMPONENT_STATUS:
+ if (o instanceof ComponentStatus){
+ return createComponentStatus((ComponentStatus) o);
+ }else {
+ logger.error("Object should be a Workflow Output.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Workflow Output.");
+ }
+ case NODE:
+ if (o instanceof Node){
+ return createNode((Node) o);
+ }else {
+ logger.error("Object should be a Node.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Node.");
+ }
+ case PORT:
+ if (o instanceof Port){
+ return createPort((Port) o);
+ }else {
+ logger.error("Object should be a Port.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Port.");
+ }
+ case EDGE:
+ if (o instanceof Edge){
+ return createEdge((Edge) o);
+ }else {
+ logger.error("Object should be a Edge.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Edge.");
+ }
+ default:
+ logger.error("Illegal data type..", new IllegalArgumentException());
+ throw new IllegalArgumentException("Illegal data type..");
+ }
+ }
+
+ private static WorkflowCatalogResource createWorflowInput(WorkflowInput o) {
+ WorkflowInputResource resource = new WorkflowInputResource();
+ if (o != null){
+ resource.setWfTemplateId(o.getTemplateID());
+ resource.setInputKey(o.getInputKey());
+ if (o.getInputVal() != null){
+ resource.setInputVal(new String(o.getInputVal()));
+ }
+ resource.setDataType(o.getDataType());
+ resource.setMetadata(o.getMetadata());
+ resource.setAppArgument(o.getAppArgument());
+ resource.setInputOrder(o.getInputOrder());
+ resource.setUserFriendlyDesc(o.getUserFriendlyDesc());
+ resource.setStandardInput(o.isStandardInput());
+ resource.setRequired(o.isRequired());
+ resource.setRequiredToCMD(o.isRequiredToCMD());
+ resource.setDataStaged(o.isDataStaged());
+ resource.setWorkflowResource((WorkflowResource)createWorkflow(o.getWorkflow()));
+ }
+ return resource;
+ }
+
+ private static WorkflowCatalogResource createWorkflowOutput(WorkflowOutput o) {
+ WorkflowOutputResource resource = new WorkflowOutputResource();
+ if (o != null){
+ resource.setWfTemplateId(o.getTemplateId());
+ resource.setOutputKey(o.getOutputKey());
+ if (o.getOutputVal() != null){
+ resource.setOutputVal(new String(o.getOutputVal()));
+ }
+ resource.setDataType(o.getDataType());
+ resource.setDataMovement(o.isDataMovement());
+ resource.setDataNameLocation(o.getDataNameLocation());
+ resource.setWorkflowResource((WorkflowResource)createWorkflow(o.getWorkflow()));
+ }
+ return resource;
+ }
+
+ private static ComponentStatusResource createComponentStatus(ComponentStatus o) {
+ ComponentStatusResource resource = new ComponentStatusResource();
+ if (o != null){
+ resource.setStatusId(o.getStatusId());
+ resource.setTemplateId(o.getTemplateId());
+ resource.setUpdatedTime(o.getUpdateTime());
+ resource.setReason(o.getReason());
+ resource.setState(o.getState());
+ }
+ return resource;
+ }
+
+ private static WorkflowStatusResource createWorkflowStatus(WorkflowStatus o) {
+ WorkflowStatusResource resource = new WorkflowStatusResource();
+ if (o != null){
+ resource.setStatusId(o.getStatusId());
+ resource.setTemplateId(o.getTemplateId());
+ resource.setReason(o.getReason());
+ resource.setState(o.getState());
+ resource.setUpdatedTime(o.getUpdateTime());
+ }
+ return resource;
+ }
+
+ private static EdgeResource createEdge(Edge o) {
+ EdgeResource resource = new EdgeResource();
+ if (o != null){
+ resource.setStatusId(o.getComponentStatusId());
+ resource.setTemplateId(o.getTemplateId());
+ resource.setEdgeId(o.getEdgeId());
+ resource.setDescription(o.getDescription());
+ resource.setName(o.getName());
+ resource.setCreatedTime(o.getCreatedTime());
+ }
+ return resource;
+ }
+
+ private static PortResource createPort(Port o) {
+ PortResource resource = new PortResource();
+ if (o != null){
+ resource.setStatusId(o.getComponentStatusId());
+ resource.setTemplateId(o.getTemplateId());
+ resource.setPortId(o.getPortId());
+ resource.setDescription(o.getDescription());
+ resource.setName(o.getName());
+ resource.setCreatedTime(o.getCreatedTime());
+ }
+ return resource;
+ }
+
+ private static NodeResource createNode(Node o) {
+ NodeResource resource = new NodeResource();
+ if (o != null){
+ resource.setStatusId(o.getComponentStatusId());
+ resource.setTemplateId(o.getTemplateId());
+ resource.setNodeId(o.getNodeId());
+ resource.setDescription(o.getDescription());
+ resource.setName(o.getName());
+ resource.setCreatedTime(o.getCreatedTime());
+ resource.setApplicationId(o.getApplicationId());
+ resource.setApplicationName(o.getApplicationName());
+ }
+ return resource;
+ }
+
+ private static WorkflowCatalogResource createWorkflow(Workflow o) {
+ WorkflowResource workflowResource = new WorkflowResource();
+ workflowResource.setWfName(o.getWorkflowName());
+ workflowResource.setCreatedUser(o.getCreatedUser());
+ if (o.getGraph() != null){
+ workflowResource.setGraph(new String(o.getGraph()));
+ }
+ if (o.getImage() != null){
+ workflowResource.setImage(new String(o.getImage()));
+ }
+ workflowResource.setCreatedTime(o.getCreationTime());
+ if (o.getUpdateTime() != null){
+ workflowResource.setUpdatedTime(o.getUpdateTime());
+ }
+ workflowResource.setWfTemplateId(o.getTemplateId());
+ workflowResource.setGatewayId(o.getGatewayId());
+ return workflowResource;
+ }
+}