Add repository class and override interface methods
MODIFY
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/workflowcatalog/WorkflowEntity.java
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/workflowcatalog/WorkflowEntity.java
@@ -64,11 +64,11 @@ public class WorkflowEntity implements Serializable {
@OneToMany(targetEntity = WorkflowInputEntity.class, cascade = CascadeType.ALL,
mappedBy = "workflow", fetch = FetchType.EAGER)
- private List<InputDataObjectType> workflowInputs;
+ private List<WorkflowInputEntity> workflowInputs;
@OneToMany(targetEntity = WorkflowOutputEntity.class, cascade = CascadeType.ALL,
mappedBy = "workflow", fetch = FetchType.EAGER)
- private List<OutputDataObjectType> workflowOutputs;
+ private List<WorkflowOutputEntity> workflowOutputs;
public WorkflowEntity() {
}
@@ -151,19 +151,19 @@ public class WorkflowEntity implements Serializable {
this.name = name;
}
- public List<InputDataObjectType> getWorkflowInputs() {
+ public List<WorkflowInputEntity> getWorkflowInputs() {
return workflowInputs;
}
- public void setWorkflowInputs(List<InputDataObjectType> workflowInputs) {
+ public void setWorkflowInputs(List<WorkflowInputEntity> workflowInputs) {
this.workflowInputs = workflowInputs;
}
- public List<OutputDataObjectType> getWorkflowOutputs() {
+ public List<WorkflowOutputEntity> getWorkflowOutputs() {
return workflowOutputs;
}
- public void setWorkflowOutputs(List<OutputDataObjectType> workflowOutputs) {
+ public void setWorkflowOutputs(List<WorkflowOutputEntity> workflowOutputs) {
this.workflowOutputs = workflowOutputs;
}
}
\ No newline at end of file

DELETE
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/ComponentStatusRepository.java
-/*
- *
- * 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.repositories.workflowcatalog;
-
-import org.apache.airavata.model.ComponentStatus;
-import org.apache.airavata.registry.core.entities.workflowcatalog.ComponentStatusEntity;
-import org.apache.airavata.registry.core.repositories.AbstractRepository;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ComponentStatusRepository extends AbstractRepository<ComponentStatus, ComponentStatusEntity, String> {
-
-
- private final static Logger logger = LoggerFactory.getLogger(ComponentStatusRepository.class);
-
- public ComponentStatusRepository(Class<ComponentStatus> thriftGenericClass, Class<ComponentStatusEntity> dbEntityGenericClass) {
- super(thriftGenericClass, dbEntityGenericClass);
- }
-}

DELETE
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/EdgeRepository.java
-/*
- *
- * 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.repositories.workflowcatalog;
-
-import org.apache.airavata.model.EdgeModel;
-import org.apache.airavata.registry.core.entities.workflowcatalog.EdgeEntity;
-import org.apache.airavata.registry.core.entities.workflowcatalog.EdgePK;
-import org.apache.airavata.registry.core.repositories.AbstractRepository;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class EdgeRepository extends AbstractRepository<EdgeModel, EdgeEntity, EdgePK> {
-
-
- private final static Logger logger = LoggerFactory.getLogger(EdgeRepository.class);
-
- public EdgeRepository(Class<EdgeModel> thriftGenericClass, Class<EdgeEntity> dbEntityGenericClass) {
- super(thriftGenericClass, dbEntityGenericClass);
- }
-}

DELETE
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/NodeRepository.java
-/*
- *
- * 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.repositories.workflowcatalog;
-
-import org.apache.airavata.model.NodeModel;
-import org.apache.airavata.registry.core.entities.workflowcatalog.NodeEntity;
-import org.apache.airavata.registry.core.entities.workflowcatalog.NodePK;
-import org.apache.airavata.registry.core.repositories.AbstractRepository;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NodeRepository extends AbstractRepository<NodeModel, NodeEntity, NodePK> {
-
-
- private final static Logger logger = LoggerFactory.getLogger(NodeRepository.class);
-
- public NodeRepository(Class<NodeModel> thriftGenericClass, Class<NodeEntity> dbEntityGenericClass) {
- super(thriftGenericClass, dbEntityGenericClass);
- }
-}

ADD
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowCatAbstractRepository.java
+/*
+ *
+ * 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.repositories.workflowcatalog;
+
+import org.apache.airavata.registry.core.utils.Committer;
+import org.apache.airavata.registry.core.utils.DBConstants;
+import org.apache.airavata.registry.core.utils.JPAUtil.RepCatalogJPAUtils;
+import org.apache.airavata.registry.core.utils.JPAUtil.WorkflowCatalogJPAUtils;
+import org.apache.airavata.registry.core.utils.ObjectMapperSingleton;
+import org.dozer.Mapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public abstract class WorkflowCatAbstractRepository<T, E, Id> {
+ private final static Logger logger = LoggerFactory.getLogger(WorkflowCatAbstractRepository.class);
+
+ private Class<T> thriftGenericClass;
+ private Class<E> dbEntityGenericClass;
+
+ public WorkflowCatAbstractRepository(Class<T> thriftGenericClass, Class<E> dbEntityGenericClass) {
+ this.thriftGenericClass = thriftGenericClass;
+ this.dbEntityGenericClass = dbEntityGenericClass;
+ }
+
+ public T create(T t) {
+ return update(t);
+ }
+
+ public T update(T t) {
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ E entity = mapper.map(t, dbEntityGenericClass);
+ E persistedCopy = execute(entityManager -> entityManager.merge(entity));
+ return mapper.map(persistedCopy, thriftGenericClass);
+ }
+
+ public boolean delete(Id id) {
+ execute(entityManager -> {
+ E entity = entityManager.find(dbEntityGenericClass, id);
+ entityManager.remove(entity);
+ return entity;
+ });
+ return true;
+ }
+
+ public T get(Id id) {
+ E entity = execute(entityManager -> entityManager
+ .find(dbEntityGenericClass, id));
+ if(entity == null)
+ return null;
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ return mapper.map(entity, thriftGenericClass);
+ }
+
+ public List<T> select(String query, int offset) {
+ List resultSet = (List) execute(entityManager -> entityManager.createQuery(query).setFirstResult(offset)
+ .getResultList());
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ List<T> gatewayList = new ArrayList<>();
+ resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
+ return gatewayList;
+ }
+
+ public List<T> select(String query, int limit, int offset, Map<String, Object> queryParams) {
+ int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
+
+ List resultSet = (List) execute(entityManager -> {
+ Query jpaQuery = entityManager.createQuery(query);
+
+ for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
+
+ jpaQuery.setParameter(entry.getKey(), entry.getValue());
+ }
+
+ return jpaQuery.setFirstResult(offset).setMaxResults(newLimit).getResultList();
+
+ });
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ List<T> gatewayList = new ArrayList<>();
+ resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
+ return gatewayList;
+ }
+
+ public boolean isExists(Id id) {
+ return get(id) != null;
+ }
+
+ public <R> R execute(Committer<EntityManager, R> committer){
+ EntityManager entityManager = null;
+ try {
+ entityManager = WorkflowCatalogJPAUtils.getEntityManager();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to get Workflow Catalog EntityManager", e);
+ }
+ try {
+ entityManager.getTransaction().begin();
+ R r = committer.commit(entityManager);
+ entityManager.getTransaction().commit();
+ return r;
+ }finally {
+ if (entityManager != null && entityManager.isOpen()) {
+ if (entityManager.getTransaction().isActive()) {
+ entityManager.getTransaction().rollback();
+ }
+ entityManager.close();
+ }
+ }
+ }
+
+}

MODIFY
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowRepository.java
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowRepository.java
package org.apache.airavata.registry.core.repositories.workflowcatalog;
import org.apache.airavata.model.WorkflowModel;
+import org.apache.airavata.model.application.io.OutputDataObjectType;
import org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowEntity;
-import org.apache.airavata.registry.core.repositories.AbstractRepository;
+import org.apache.airavata.registry.core.utils.DBConstants;
+import org.apache.airavata.registry.core.utils.ObjectMapperSingleton;
+import org.apache.airavata.registry.core.utils.QueryConstants;
+import org.apache.airavata.registry.core.utils.WorkflowCatalogUtils;
+import org.apache.airavata.registry.cpi.WorkflowCatalog;
+import org.apache.airavata.registry.cpi.WorkflowCatalogException;
+import org.dozer.Mapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class WorkflowRepository extends AbstractRepository<WorkflowModel, WorkflowEntity, String> {
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+public class WorkflowRepository extends WorkflowCatAbstractRepository<WorkflowModel, WorkflowEntity, String> implements WorkflowCatalog {
private final static Logger logger = LoggerFactory.getLogger(WorkflowRepository.class);
+ public WorkflowRepository() {
+ super(WorkflowModel.class, WorkflowEntity.class);
+ }
+
+ protected String saveWorkflowModelData(WorkflowModel workflowModel, String gatewayId) throws WorkflowCatalogException {
+ WorkflowEntity workflowEntity = saveWorkflow(workflowModel, gatewayId);
+ return workflowEntity.getTemplateId();
+ }
+
+ protected WorkflowEntity saveWorkflow(WorkflowModel workflowModel, String gatewayId) throws WorkflowCatalogException {
+ if (workflowModel.getTemplateId() == null) {
+ logger.debug("Setting the Template ID for the new Workflow");
+ workflowModel.setTemplateId(WorkflowCatalogUtils.getID(workflowModel.getName()));
+ }
+
+ String templateId = workflowModel.getTemplateId();
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ WorkflowEntity workflowEntity = mapper.map(workflowModel, WorkflowEntity.class);
+
+ if (gatewayId != null) {
+ logger.debug("Setting the gateway ID of the Workflow");
+ workflowEntity.setGatewayId(gatewayId);
+ }
+
+ if (workflowEntity.getWorkflowInputs() != null) {
+ logger.debug("Populating the template ID for WorkflowInput objects for the Workflow");
+ workflowEntity.getWorkflowInputs().forEach(workflowInputEntity -> workflowInputEntity.setTemplateId(templateId));
+ }
+
+ if (workflowEntity.getWorkflowOutputs() != null) {
+ logger.debug("Populating the template ID for WorkflowOutput objects for the Workflow");
+ workflowEntity.getWorkflowOutputs().forEach(workflowOutputEntity -> workflowOutputEntity.setTemplateId(templateId));
+ }
+
+ if (get(templateId) == null) {
+ logger.debug("Checking if the Workflow already exists");
+ workflowEntity.setCreationTime(new Timestamp(System.currentTimeMillis()));
+ }
+
+ workflowEntity.setUpdateTime(new Timestamp(System.currentTimeMillis()));
+
+ return execute(entityManager -> entityManager.merge(workflowEntity));
+ }
+
+ @Override
+ public String registerWorkflow(WorkflowModel workflowModel, String gatewayId) throws WorkflowCatalogException {
+ return saveWorkflowModelData(workflowModel, gatewayId);
+ }
+
+ @Override
+ public void updateWorkflow(String templateId, WorkflowModel updatedWorkflowModel) throws WorkflowCatalogException {
+ saveWorkflowModelData(updatedWorkflowModel, null);
+ }
+
+ @Override
+ public WorkflowModel getWorkflow(String templateId) throws WorkflowCatalogException {
+ return get(templateId);
+ }
+
+ @Override
+ public List<String> getAllWorkflows(String gatewayId) throws WorkflowCatalogException {
+ Map<String, Object> queryParameters = new HashMap<>();
+ queryParameters.put(DBConstants.Workflow.GATEWAY_ID, gatewayId);
+ List<WorkflowModel> workflowModelList = select(QueryConstants.GET_ALL_WORKFLOWS, -1, 0, queryParameters);
+ List<String> workflows = new ArrayList<>();
+ for (WorkflowModel workflowModel : workflowModelList) {
+ workflows.add(workflowModel.getTemplateId());
+ }
+ return workflows;
+ }
+
+ @Override
+ public String getWorkflowTemplateId(String workflowName) throws WorkflowCatalogException {
+ Map<String, Object> queryParameters = new HashMap<>();
+ queryParameters.put(DBConstants.Workflow.WORKFLOW_NAME, workflowName);
+ List<WorkflowModel> workflowModelList = select(QueryConstants.GET_WORKFLOW_GIVEN_NAME, -1, 0, queryParameters);
- public WorkflowRepository(Class<WorkflowModel> thriftGenericClass, Class<WorkflowEntity> dbEntityGenericClass) {
- super(thriftGenericClass, dbEntityGenericClass);
+ if (!workflowModelList.isEmpty() && workflowModelList != null) {
+ logger.debug("Return the record (there is only one record)");
+ return workflowModelList.get(0).getTemplateId();
}
+
+ return null;
+ }
+
+ @Override
+ public boolean isWorkflowExistWithName(String workflowName) throws WorkflowCatalogException {
+ Map<String, Object> queryParameters = new HashMap<>();
+ queryParameters.put(DBConstants.Workflow.WORKFLOW_NAME, workflowName);
+ List<WorkflowModel> workflowModelList = select(QueryConstants.GET_WORKFLOW_GIVEN_NAME, -1, 0, queryParameters);
+ return (!workflowModelList.isEmpty() && workflowModelList != null);
+ }
+
+ @Override
+ public void updateWorkflowOutputs(String templateId, List<OutputDataObjectType> workflowOutputs) throws WorkflowCatalogException {
+ WorkflowModel workflowModel = getWorkflow(templateId);
+ workflowModel.setWorkflowOutputs(workflowOutputs);
+ updateWorkflow(workflowModel.getTemplateId(), workflowModel);
+ }
+
+ @Override
+ public void deleteWorkflow(String templateId) throws WorkflowCatalogException {
+ delete(templateId);
+ }
+
}

DELETE
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowStatusRepository.java
-/*
- *
- * 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.repositories.workflowcatalog;
-
-import org.apache.airavata.model.WorkflowStatus;
-import org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowStatusEntity;
-import org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowStatusPK;
-import org.apache.airavata.registry.core.repositories.AbstractRepository;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class WorkflowStatusRepository extends AbstractRepository<WorkflowStatus, WorkflowStatusEntity, WorkflowStatusPK> {
-
- private final static Logger logger = LoggerFactory.getLogger(WorkflowStatusRepository.class);
-
- public WorkflowStatusRepository(Class<WorkflowStatus> thriftGenericClass, Class<WorkflowStatusEntity> dbEntityGenericClass) {
- super(thriftGenericClass, dbEntityGenericClass);
- }
-}

MODIFY
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/DBConstants.java
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/DBConstants.java
@@ -133,4 +133,9 @@ public class DBConstants {
public static final String PARENT_PRODUCT_URI = "parentProductUri";
}
+ public static class Workflow {
+ public static final String GATEWAY_ID = "gatewayId";
+ public static final String WORKFLOW_NAME = "workflowName";
+ }
+
}

ADD
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/JPAUtil/WorkflowCatalogJPAUtils.java
+/**
+ *
+ * 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.utils.JPAUtil;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
+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");
+ 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...");
+ }
+ }
+
+}

MODIFY
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
@@ -22,6 +22,7 @@ package org.apache.airavata.registry.core.utils;
import org.apache.airavata.model.user.UserProfile;
import org.apache.airavata.registry.core.entities.appcatalog.*;
import org.apache.airavata.registry.core.entities.replicacatalog.DataProductEntity;
+import org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowEntity;
public interface QueryConstants {
@@ -113,4 +114,9 @@ public interface QueryConstants {
"WHERE DP.gatewayId LIKE :" + DBConstants.DataProduct.GATEWAY_ID + " AND DP.ownerName LIKE :" +
DBConstants.DataProduct.OWNER_NAME + " AND dp.productName LIKE :" + DBConstants.DataProduct.PRODUCT_NAME;
+ String GET_ALL_WORKFLOWS = "SELECT W FROM " + WorkflowEntity.class.getSimpleName() + " W " +
+ "WHERE W.gatewayId LIKE :" + DBConstants.Workflow.GATEWAY_ID;
+ String GET_WORKFLOW_GIVEN_NAME = "SELECT W FROM " + WorkflowEntity.class.getSimpleName() + " W " +
+ "WHERE W.workflowName LIKE :" + DBConstants.Workflow.WORKFLOW_NAME;
+
}

RENAME
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/PortRepository.java
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/WorkflowCatalogUtils.java
-/*
+/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* 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.repositories.workflowcatalog;
-
-import org.apache.airavata.model.PortModel;
-import org.apache.airavata.registry.core.entities.workflowcatalog.PortEntity;
-import org.apache.airavata.registry.core.entities.workflowcatalog.PortPK;
-import org.apache.airavata.registry.core.repositories.AbstractRepository;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class PortRepository extends AbstractRepository<PortModel, PortEntity, PortPK> {
+package org.apache.airavata.registry.core.utils;
- private final static Logger logger = LoggerFactory.getLogger(PortRepository.class);
+import java.util.UUID;
- public PortRepository(Class<PortModel> thriftGenericClass, Class<PortEntity> dbEntityGenericClass) {
- super(thriftGenericClass, dbEntityGenericClass);
+public class WorkflowCatalogUtils {
+ public static String getID (String name){
+ String pro = name.replaceAll("\\s", "");
+ return pro + "_" + UUID.randomUUID();
}
}

Add repository class and override interface methods