use of org.apache.airavata.registry.core.workflow.catalog.model.Workflow in project airavata by apache.
the class WorkflowResource method getAll.
@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;
}
use of org.apache.airavata.registry.core.workflow.catalog.model.Workflow in project airavata by apache.
the class EdgeResource method save.
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();
}
}
}
use of org.apache.airavata.registry.core.workflow.catalog.model.Workflow in project airavata by apache.
the class NodeResource method save.
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();
}
}
}
use of org.apache.airavata.registry.core.workflow.catalog.model.Workflow in project airavata by apache.
the class PortResource method save.
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();
}
}
}
use of org.apache.airavata.registry.core.workflow.catalog.model.Workflow in project airavata by apache.
the class WorkflowOutputResource method save.
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();
}
}
}
Aggregations