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 2015/06/02 22:41:13 UTC
[17/25] airavata git commit: rename airavata-jpa-registry module to
experiment-catalog
http://git-wip-us.apache.org/repos/asf/airavata/blob/22bcbb40/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
deleted file mode 100644
index 24459b0..0000000
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
+++ /dev/null
@@ -1,208 +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.persistance.registry.jpa.resources;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.NodeOutput;
-import org.apache.airavata.persistance.registry.jpa.model.NodeOutput_PK;
-import org.apache.airavata.persistance.registry.jpa.model.WorkflowNodeDetail;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NodeOutputResource extends AbstractResource {
- private static final Logger logger = LoggerFactory.getLogger(NodeOutputResource.class);
-
- private String nodeId;
- private String outputKey;
- private String dataType;
- private String value;
- private boolean isRequired;
- private boolean dataMovement;
- private String dataNameLocation;
- private boolean requiredToCMD;
- private String searchQuery;
- private String appArgument;
-
- 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 getRequiredToCMD() {
- return requiredToCMD;
- }
-
- public void setRequiredToCMD(boolean requiredToCMD) {
- this.requiredToCMD = requiredToCMD;
- }
-
- public boolean getRequired() {
- return isRequired;
- }
-
- public void setRequired(boolean required) {
- this.isRequired = required;
- }
-
- 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 String getNodeId() {
- return nodeId;
- }
-
- public void setNodeId(String nodeId) {
- this.nodeId = nodeId;
- }
-
- public String getOutputKey() {
- return outputKey;
- }
-
- public void setOutputKey(String outputKey) {
- this.outputKey = outputKey;
- }
-
- public String getDataType() {
- return dataType;
- }
-
- public void setDataType(String dataType) {
- this.dataType = dataType;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
-
- public Resource create(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public Resource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<Resource> get(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ResourceUtils.getEntityManager();
- NodeOutput existingOutput = em.find(NodeOutput.class, new NodeOutput_PK(outputKey, nodeId));
- em.close();
-
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- NodeOutput nodeOutput = new NodeOutput();
- nodeOutput.setNodeId(nodeId);
- nodeOutput.setOutputKey(outputKey);
- nodeOutput.setDataType(dataType);
- nodeOutput.setValue(value);
- nodeOutput.setRequired(isRequired);
- nodeOutput.setRequiredToCMD(requiredToCMD);
- nodeOutput.setDataMovement(dataMovement);
- nodeOutput.setDataNameLocation(dataNameLocation);
- nodeOutput.setApplicationArgument(appArgument);
- nodeOutput.setSearchQuery(searchQuery);
-
- if (existingOutput != null) {
- existingOutput.setNodeId(nodeId);
- existingOutput.setOutputKey(outputKey);
- existingOutput.setDataType(dataType);
- existingOutput.setValue(value);
- existingOutput.setRequired(isRequired);
- existingOutput.setRequiredToCMD(requiredToCMD);
- existingOutput.setDataMovement(dataMovement);
- existingOutput.setDataNameLocation(dataNameLocation);
- existingOutput.setApplicationArgument(appArgument);
- existingOutput.setSearchQuery(searchQuery);
- nodeOutput = em.merge(existingOutput);
- } else {
- em.persist(nodeOutput);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/22bcbb40/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java
deleted file mode 100644
index fc29b13..0000000
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java
+++ /dev/null
@@ -1,119 +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.persistance.registry.jpa.resources;
-
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.*;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import java.util.List;
-
-public class NotificationEmailResource extends AbstractResource {
- private static final Logger logger = LoggerFactory.getLogger(NotificationEmailResource.class);
-
- private int emailId = 0;
- private String experimentId;
- private String taskId;
- private String emailAddress;
-
-
- public String getEmailAddress() {
- return emailAddress;
- }
-
- public void setEmailAddress(String emailAddress) {
- this.emailAddress = emailAddress;
- }
-
- public String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public Resource create(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public Resource get(ResourceType type, Object name) throws RegistryException {
- logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public List<Resource> get(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Notification_Email notification_email;
- if (emailId != 0 ){
- notification_email = em.find(Notification_Email.class, emailId);
- notification_email.setEmailId(emailId);
- }else {
- notification_email = new Notification_Email();
- }
- notification_email.setExperiment_id(experimentId);
- notification_email.setTaskId(taskId);
- notification_email.setEmailAddress(emailAddress);
- em.persist(notification_email);
- emailId = notification_email.getEmailId();
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/22bcbb40/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
deleted file mode 100644
index 4d73de2..0000000
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
+++ /dev/null
@@ -1,508 +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.persistance.registry.jpa.resources;
-
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.*;
-import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.apache.airavata.registry.cpi.ResultOrderType;
-import org.apache.airavata.registry.cpi.utils.Constants;
-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 ProjectResource extends AbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(ProjectResource.class);
- private String name;
- private String id;
- private String gatewayId;
- private WorkerResource worker;
- private String description;
- private Timestamp creationTime;
-
- /**
- *
- */
- public ProjectResource() {
- }
-
- /**
- *
- * @param type child resource type
- * @return child resource
- */
- public Resource create(ResourceType type) throws RegistryException {
- if (type == ResourceType.EXPERIMENT) {
- ExperimentResource experimentResource = new ExperimentResource();
- experimentResource.setGatewayId(gatewayId);
- experimentResource.setExecutionUser(worker.getUser());
- experimentResource.setProjectId(id);
- return experimentResource;
- } else if (type == ResourceType.PROJECT_USER){
- ProjectUserResource pr = new ProjectUserResource();
- pr.setProjectId(id);
- pr.setUserName(worker.getUser());
- return pr;
- }
- else {
- logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for project resource.");
- }
- }
-
- /**
- *
- * @param type child resource type
- * @param name child resource name
- */
- public void remove(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- if (type == ResourceType.EXPERIMENT) {
- QueryGenerator generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- } else if (type == ResourceType.PROJECT_USER) {
- QueryGenerator generator = new QueryGenerator(PROJECT_USER);
- generator.setParameter(ProjectUserConstants.USERNAME, name);
- generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- } else {
- logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for project resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- /**
- *
- * @param type child resource type
- * @param name child resource name
- * @return child resource
- */
- public Resource get(ResourceType type, Object name) throws RegistryException {
- EntityManager em = null;
- try {
- if (type == ResourceType.EXPERIMENT) {
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
- Query q = generator.selectQuery(em);
- Experiment experiment = (Experiment) q.getSingleResult();
- ExperimentResource experimentResource = (ExperimentResource)
- Utils.getResource(ResourceType.EXPERIMENT, experiment);
- em.getTransaction().commit();
- em.close();
- return experimentResource;
- } else if (type == ResourceType.PROJECT_USER) {
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(PROJECT_USER);
- generator.setParameter(ProjectUserConstants.USERNAME, name);
- generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
- Query q = generator.selectQuery(em);
- ProjectUser prUser = (ProjectUser) q.getSingleResult();
- ExperimentResource experimentResource = (ExperimentResource)
- Utils.getResource(ResourceType.PROJECT_USER, prUser);
- em.getTransaction().commit();
- em.close();
- return experimentResource;
- } else {
- logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for project resource.");
- }
- } catch (Exception e) {
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- /**
- *
- * @param type child resource type
- * @return list of child resources
- */
- @Override
- public List<Resource> get(ResourceType type) throws RegistryException{
- List<Resource> resourceList = new ArrayList<Resource>();
- EntityManager em = null;
- try {
- if (type == ResourceType.EXPERIMENT) {
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.PROJECT_ID, id);
- Query q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Experiment experiment = (Experiment) result;
- ExperimentResource experimentResource = (ExperimentResource)
- Utils.getResource(ResourceType.EXPERIMENT, experiment);
- resourceList.add(experimentResource);
- }
- }
- em.getTransaction().commit();
- em.close();
- } else if (type == ResourceType.PROJECT_USER) {
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(PROJECT_USER);
- generator.setParameter(ProjectUserConstants.PROJECT_ID, id);
- Query q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ProjectUser projectUser = (ProjectUser) result;
- ProjectUserResource pr = (ProjectUserResource)
- Utils.getResource(ResourceType.PROJECT_USER, projectUser);
- resourceList.add(pr);
- }
- }
- em.getTransaction().commit();
- em.close();
- } else {
- logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for project resource.");
- }
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceList;
- }
-
- /**
- * Get results with pagination and ordering
- *
- * @param type
- * @param limit
- * @param offset
- * @param orderByIdentifier
- * @return
- * @throws RegistryException
- */
- public List<Resource> get(ResourceType type, int limit, int offset, Object orderByIdentifier,
- ResultOrderType resultOrderType) throws RegistryException{
- List<Resource> resourceList = new ArrayList<Resource>();
- EntityManager em = null;
- try {
- if (type == ResourceType.EXPERIMENT) {
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.PROJECT_ID, id);
- Query q;
- //ordering - supported only by CREATION_TIME
- if(orderByIdentifier != null && resultOrderType != null
- && orderByIdentifier.equals(Constants.FieldConstants.ExperimentConstants.CREATION_TIME)) {
- q = generator.selectQuery(em, ExperimentConstants.CREATION_TIME, resultOrderType);
- }else{
- q = generator.selectQuery(em);
- }
-
- //pagination
- if(limit>0 && offset>=0){
- q.setFirstResult(offset);
- q.setMaxResults(limit);
- }
- List<?> results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Experiment experiment = (Experiment) result;
- ExperimentResource experimentResource = (ExperimentResource)
- Utils.getResource(ResourceType.EXPERIMENT, experiment);
- resourceList.add(experimentResource);
- }
- }
- em.getTransaction().commit();
- em.close();
- } else if (type == ResourceType.PROJECT_USER) {
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(PROJECT_USER);
- generator.setParameter(ProjectUserConstants.PROJECT_ID, id);
- Query q;
- //ordering - only supported only by CREATION_TIME
- if(orderByIdentifier != null && resultOrderType != null
- && orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME)) {
- q = generator.selectQuery(em, ProjectConstants.CREATION_TIME, resultOrderType);
- }else{
- q = generator.selectQuery(em);
- }
-
- //pagination
- if(limit>0 && offset>=0){
- q.setFirstResult(offset);
- q.setMaxResults(limit);
- }
- List<?> results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ProjectUser projectUser = (ProjectUser) result;
- ProjectUserResource pr = (ProjectUserResource)
- Utils.getResource(ResourceType.PROJECT_USER, projectUser);
- resourceList.add(pr);
- }
- }
- em.getTransaction().commit();
- em.close();
- } else {
- logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for project resource.");
- }
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceList;
- }
-
- /**
- * save project to the database
- */
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ResourceUtils.getEntityManager();
- Project existingProject = em.find(Project.class, id);
- em.close();
-
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Project project = new Project();
- project.setProject_id(id);
- project.setProject_name(name);
- project.setGateway_id(gatewayId);
- Users user = em.find(Users.class, worker.getUser());
- project.setUsers(user);
- project.setUser_name(user.getUser_name());
- project.setDescription(description);
- project.setCreationTime(creationTime);
-
- if (existingProject != null) {
- existingProject.setProject_name(name);
- existingProject.setGateway_id(gatewayId);
- existingProject.setUsers(user);
- existingProject.setUser_name(user.getUser_name());
- existingProject.setDescription(description);
- existingProject.setCreationTime(creationTime);
- project = em.merge(existingProject);
- } else {
- em.persist(project);
- }
-
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- *
- * @return project name
- */
- public String getName() {
- return name;
- }
-
- /**
- *
- * @param name project name
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- *
- * @return gateway worker
- */
- public WorkerResource getWorker() {
- return worker;
- }
-
- /**
- *
- * @param worker gateway worker
- */
- public void setWorker(WorkerResource worker) {
- this.worker = worker;
- }
-
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Timestamp getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Timestamp creationTime) {
- this.creationTime = creationTime;
- }
-
- /**
- *
- * @param experimentId experiment ID
- * @return whether the experiment exist
- */
- public boolean isExperimentExists(String experimentId) throws RegistryException{
- return isExists(ResourceType.EXPERIMENT, experimentId);
- }
-
- /**
- *
- * @param experimentId experiment ID
- * @return experiment resource
- */
- public ExperimentResource createExperiment(String experimentId) throws RegistryException{
- ExperimentResource experimentResource = (ExperimentResource)create(ResourceType.EXPERIMENT);
- experimentResource.setExpID(experimentId);
- return experimentResource;
- }
-
- /**
- *
- * @param experimentId experiment ID
- * @return experiment resource
- */
- public ExperimentResource getExperiment(String experimentId) throws RegistryException{
- return (ExperimentResource)get(ResourceType.EXPERIMENT,experimentId);
- }
-
- /**
- *
- * @return list of experiments
- */
- public List<ExperimentResource> getExperiments() throws RegistryException{
- List<Resource> list = get(ResourceType.EXPERIMENT);
- List<ExperimentResource> result=new ArrayList<ExperimentResource>();
- for (Resource resource : list) {
- result.add((ExperimentResource) resource);
- }
- return result;
- }
-
- public List<ExperimentResource> getExperiments(int limit, int offset, Object orderByIdentifier,
- ResultOrderType resultOrderType) throws RegistryException{
- List<Resource> list = get(ResourceType.EXPERIMENT, limit, offset, orderByIdentifier, resultOrderType);
- List<ExperimentResource> result=new ArrayList<ExperimentResource>();
- for (Resource resource : list) {
- result.add((ExperimentResource) resource);
- }
- return result;
- }
-
- /**
- *
- * @param experimentId experiment ID
- */
- public void removeExperiment(String experimentId) throws RegistryException{
- remove(ResourceType.EXPERIMENT, experimentId);
- }
-
- public List<ProjectUserResource> getProjectUserList () throws RegistryException{
- List<Resource> resources = get(ResourceType.PROJECT_USER);
- List<ProjectUserResource> projectUserResources = new ArrayList<ProjectUserResource>();
- if (resources != null && !resources.isEmpty()){
- for (Resource r : resources){
- projectUserResources.add((ProjectUserResource)r);
- }
- }
- return projectUserResources;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/22bcbb40/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java
deleted file mode 100644
index dd50b7c..0000000
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java
+++ /dev/null
@@ -1,123 +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.persistance.registry.jpa.resources;
-
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.*;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import java.util.List;
-
-public class ProjectUserResource extends AbstractResource {
- private String projectId;
- private String userName;
-
- private static final Logger logger = LoggerFactory.getLogger(ProjectUserResource.class);
-
- public String getProjectId() {
- return projectId;
- }
-
- public void setProjectId(String projectId) {
- this.projectId = projectId;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
-
- public Resource create(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public Resource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<Resource> get(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ResourceUtils.getEntityManager();
- ProjectUser existingPrUser = em.find(ProjectUser.class, new ProjectUser_PK(projectId, userName));
- em.close();
-
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- ProjectUser prUser = new ProjectUser();
- prUser.setProjectID(projectId);
- prUser.setUserName(userName);
- Users user = em.find(Users.class, userName);
- prUser.setUser(user);
- Project project = em.find(Project.class, projectId);
- prUser.setProject(project);
-
- if (existingPrUser != null) {
- existingPrUser.setProjectID(projectId);
- existingPrUser.setUserName(userName);
- existingPrUser.setUser(user);
- existingPrUser.setProject(project);
- prUser = em.merge(existingPrUser);
- } else {
- em.persist(prUser);
- }
-
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/22bcbb40/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java
deleted file mode 100644
index f9a8b33..0000000
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java
+++ /dev/null
@@ -1,146 +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.persistance.registry.jpa.resources;
-
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.Experiment;
-import org.apache.airavata.persistance.registry.jpa.model.QosParam;
-import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.airavata.registry.cpi.RegistryException;
-
-import javax.persistence.EntityManager;
-import java.util.List;
-
-public class QosParamResource extends AbstractResource {
- private static final Logger logger = LoggerFactory.getLogger(QosParamResource.class);
- private int qosId;
- private String experimentId;
- private String taskId;
- private String startExecutionAt;
- private String executeBefore;
- private int noOfRetries;
-
- public int getQosId() {
- return qosId;
- }
-
- public void setQosId(int qosId) {
- this.qosId = qosId;
- }
-
- public String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public String getStartExecutionAt() {
- return startExecutionAt;
- }
-
- public void setStartExecutionAt(String startExecutionAt) {
- this.startExecutionAt = startExecutionAt;
- }
-
- public String getExecuteBefore() {
- return executeBefore;
- }
-
- public void setExecuteBefore(String executeBefore) {
- this.executeBefore = executeBefore;
- }
-
- public int getNoOfRetries() {
- return noOfRetries;
- }
-
- public void setNoOfRetries(int noOfRetries) {
- this.noOfRetries = noOfRetries;
- }
-
-
- public Resource create(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public Resource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<Resource> get(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QosParam qosParam = new QosParam();
- qosParam.setTaskId(taskId);
- qosParam.setExpId(experimentId);
- qosParam.setStartExecutionAt(startExecutionAt);
- qosParam.setExecuteBefore(executeBefore);
- qosParam.setNoOfRetries(noOfRetries);
- em.persist(qosParam);
- qosId = qosParam.getQosId();
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/22bcbb40/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
deleted file mode 100644
index cecf925..0000000
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
+++ /dev/null
@@ -1,181 +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.persistance.registry.jpa.resources;
-
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.airavata.registry.cpi.RegistryException;
-
-import javax.persistence.EntityManager;
-import java.sql.Timestamp;
-import java.util.List;
-
-public class StatusResource extends AbstractResource {
- private static final Logger logger = LoggerFactory.getLogger(StatusResource.class);
- private int statusId = 0;
- private String experimentId;
- private String nodeId;
- private String transferId;
- private String taskId;
- private String jobId;
- private String state;
- private Timestamp statusUpdateTime;
- private String statusType;
-
- public int getStatusId() {
- return statusId;
- }
-
- public void setStatusId(int statusId) {
- this.statusId = statusId;
- }
-
- public String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- public String getNodeId() {
- return nodeId;
- }
-
- public void setNodeId(String nodeId) {
- this.nodeId = nodeId;
- }
-
- public String getTransferId() {
- return transferId;
- }
-
- public void setTransferId(String transferId) {
- this.transferId = transferId;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public String getJobId() {
- return jobId;
- }
-
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
-
- public String getState() {
- return state;
- }
-
- public void setState(String state) {
- this.state = state;
- }
-
- public Timestamp getStatusUpdateTime() {
- return statusUpdateTime;
- }
-
- public void setStatusUpdateTime(Timestamp statusUpdateTime) {
- this.statusUpdateTime = statusUpdateTime;
- }
-
- public String getStatusType() {
- return statusType;
- }
-
- public void setStatusType(String statusType) {
- this.statusType = statusType;
- }
-
-
- public Resource create(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public Resource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<Resource> get(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Status status;
- if (statusId != 0) {
- status = em.find(Status.class, statusId);
- status.setStatusId(statusId);
- } else {
- status = new Status();
- }
- status.setExpId(experimentId);
- status.setTaskId(taskId);
- status.setNodeId(nodeId);
- status.setTransferId(transferId);
- status.setJobId(jobId);
- status.setState(state);
- status.setStatusUpdateTime(statusUpdateTime);
- status.setStatusType(statusType);
- em.persist(status);
- statusId = status.getStatusId();
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/22bcbb40/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
deleted file mode 100644
index 995704e..0000000
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
+++ /dev/null
@@ -1,748 +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.persistance.registry.jpa.resources;
-
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.*;
-import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.apache.airavata.registry.cpi.utils.StatusType;
-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 TaskDetailResource extends AbstractResource {
- private static final Logger logger = LoggerFactory.getLogger(TaskDetailResource.class);
- private String taskId;
- private String nodeId;
- private Timestamp creationTime;
- private String applicationId;
- private String applicationVersion;
- private String applicationDeploymentId;
- private boolean enableEmailNotifications;
- private List<ApplicationInputResource> applicationInputs;
- private List<ApplicationOutputResource> applicationOutputs;
- private ComputationSchedulingResource schedulingResource;
- private AdvanceInputDataHandlingResource inputDataHandlingResource;
- private AdvancedOutputDataHandlingResource outputDataHandlingResource;
- private StatusResource taskStatus;
- private List<JobDetailResource> jobDetailResources;
- private List<DataTransferDetailResource> transferDetailResourceList;
- private List<NotificationEmailResource> emailResourceList;
- private List<ErrorDetailResource> errors;
-
- public List<JobDetailResource> getJobDetailResources() {
- return jobDetailResources;
- }
-
- public void setJobDetailResources(List<JobDetailResource> jobDetailResources) {
- this.jobDetailResources = jobDetailResources;
- }
-
- public void setApplicationInputs(List<ApplicationInputResource> applicationInputs) {
- this.applicationInputs = applicationInputs;
- }
-
- public void setApplicationOutputs(List<ApplicationOutputResource> applicationOutputs) {
- this.applicationOutputs = applicationOutputs;
- }
-
- public ComputationSchedulingResource getSchedulingResource() {
- return schedulingResource;
- }
-
- public void setSchedulingResource(ComputationSchedulingResource schedulingResource) {
- this.schedulingResource = schedulingResource;
- }
-
- public AdvanceInputDataHandlingResource getInputDataHandlingResource() {
- return inputDataHandlingResource;
- }
-
- public void setInputDataHandlingResource(AdvanceInputDataHandlingResource inputDataHandlingResource) {
- this.inputDataHandlingResource = inputDataHandlingResource;
- }
-
- public AdvancedOutputDataHandlingResource getOutputDataHandlingResource() {
- return outputDataHandlingResource;
- }
-
- public void setOutputDataHandlingResource(AdvancedOutputDataHandlingResource outputDataHandlingResource) {
- this.outputDataHandlingResource = outputDataHandlingResource;
- }
-
- public void setTaskStatus(StatusResource taskStatus) {
- this.taskStatus = taskStatus;
- }
-
- public List<DataTransferDetailResource> getTransferDetailResourceList() {
- return transferDetailResourceList;
- }
-
- public void setTransferDetailResourceList(List<DataTransferDetailResource> transferDetailResourceList) {
- this.transferDetailResourceList = transferDetailResourceList;
- }
-
- public List<NotificationEmailResource> getEmailResourceList() {
- return emailResourceList;
- }
-
- public void setEmailResourceList(List<NotificationEmailResource> emailResourceList) {
- this.emailResourceList = emailResourceList;
- }
-
- public List<ErrorDetailResource> getErrors() {
- return errors;
- }
-
- public void setErrors(List<ErrorDetailResource> errors) {
- this.errors = errors;
- }
-
- public boolean isEnableEmailNotifications() {
- return enableEmailNotifications;
- }
-
- public void setEnableEmailNotifications(boolean enableEmailNotifications) {
- this.enableEmailNotifications = enableEmailNotifications;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public String getNodeId() {
- return nodeId;
- }
-
- public void setNodeId(String nodeId) {
- this.nodeId = nodeId;
- }
-
- public Timestamp getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Timestamp creationTime) {
- this.creationTime = creationTime;
- }
-
- public String getApplicationId() {
- return applicationId;
- }
-
- public void setApplicationId(String applicationId) {
- this.applicationId = applicationId;
- }
-
- public String getApplicationVersion() {
- return applicationVersion;
- }
-
- public void setApplicationVersion(String applicationVersion) {
- this.applicationVersion = applicationVersion;
- }
-
-
- public Resource create(ResourceType type) throws RegistryException{
- switch (type){
- case ERROR_DETAIL:
- ErrorDetailResource errorDetailResource = new ErrorDetailResource();
- errorDetailResource.setTaskId(taskId);
- return errorDetailResource;
- case NOTIFICATION_EMAIL:
- NotificationEmailResource emailResource = new NotificationEmailResource();
- emailResource.setTaskId(taskId);
- return emailResource;
- case APPLICATION_INPUT:
- ApplicationInputResource applicationInputResource = new ApplicationInputResource();
- applicationInputResource.setTaskId(taskId);
- return applicationInputResource;
- case APPLICATION_OUTPUT:
- ApplicationOutputResource applicationOutputResource = new ApplicationOutputResource();
- applicationOutputResource.setTaskId(taskId);
- return applicationOutputResource;
- case JOB_DETAIL:
- JobDetailResource jobDetailResource = new JobDetailResource();
- jobDetailResource.setTaskId(taskId);
- return jobDetailResource;
- case DATA_TRANSFER_DETAIL:
- DataTransferDetailResource dataTransferDetailResource = new DataTransferDetailResource();
- dataTransferDetailResource.setTaskId(taskId);
- return dataTransferDetailResource;
- case STATUS:
- StatusResource statusResource = new StatusResource();
- statusResource.setTaskId(taskId);
- return statusResource;
- case COMPUTATIONAL_RESOURCE_SCHEDULING:
- ComputationSchedulingResource schedulingResource = new ComputationSchedulingResource();
- schedulingResource.setTaskId(taskId);
- return schedulingResource;
- case ADVANCE_INPUT_DATA_HANDLING:
- AdvanceInputDataHandlingResource inputDataHandlingResource = new AdvanceInputDataHandlingResource();
- inputDataHandlingResource.setTaskId(taskId);
- return inputDataHandlingResource;
- case ADVANCE_OUTPUT_DATA_HANDLING:
- AdvancedOutputDataHandlingResource outputDataHandlingResource = new AdvancedOutputDataHandlingResource();
- outputDataHandlingResource.setTaskId(taskId);
- return outputDataHandlingResource;
- case QOS_PARAM:
- QosParamResource qosParamResource = new QosParamResource();
- qosParamResource.setTaskId(taskId);
- return qosParamResource;
- default:
- logger.error("Unsupported resource type for task detail resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for task detail resource.");
- }
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- switch (type) {
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case NOTIFICATION_EMAIL:
- generator = new QueryGenerator(NOTIFICATION_EMAIL);
- generator.setParameter(NotificationEmailConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case APPLICATION_INPUT:
- generator = new QueryGenerator(APPLICATION_INPUT);
- generator.setParameter(ApplicationInputConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case APPLICATION_OUTPUT:
- generator = new QueryGenerator(APPLICATION_OUTPUT);
- generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case JOB_DETAIL:
- generator = new QueryGenerator(JOB_DETAIL);
- generator.setParameter(JobDetailConstants.TASK_ID, taskId);
- generator.setParameter(JobDetailConstants.JOB_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case DATA_TRANSFER_DETAIL:
- generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
- generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.TASK_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.TASK.toString());
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case COMPUTATIONAL_RESOURCE_SCHEDULING:
- generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
- generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case ADVANCE_INPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
- generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case ADVANCE_OUTPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
- generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case QOS_PARAM:
- generator = new QueryGenerator(QOS_PARAMS);
- generator.setParameter(QosParamsConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- default:
- logger.error("Unsupported resource type for task detail resource.", new IllegalArgumentException());
- break;
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
-
- public Resource get(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator;
- Query q;
- switch (type) {
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
- ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- em.getTransaction().commit();
- em.close();
- return errorDetailResource;
- case NOTIFICATION_EMAIL:
- generator = new QueryGenerator(NOTIFICATION_EMAIL);
- generator.setParameter(NotificationEmailConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- Notification_Email notificationEmail = (Notification_Email) q.getSingleResult();
- NotificationEmailResource emailResource = (NotificationEmailResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
- em.getTransaction().commit();
- em.close();
- return emailResource;
- case APPLICATION_INPUT:
- generator = new QueryGenerator(APPLICATION_INPUT);
- generator.setParameter(ApplicationInputConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- ApplicationInput applicationInput = (ApplicationInput) q.getSingleResult();
- ApplicationInputResource inputResource = (ApplicationInputResource) Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
- em.getTransaction().commit();
- em.close();
- return inputResource;
- case APPLICATION_OUTPUT:
- generator = new QueryGenerator(APPLICATION_OUTPUT);
- generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- ApplicationOutput applicationOutput = (ApplicationOutput) q.getSingleResult();
- ApplicationOutputResource outputResource = (ApplicationOutputResource) Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
- em.getTransaction().commit();
- em.close();
- return outputResource;
- case JOB_DETAIL:
- generator = new QueryGenerator(JOB_DETAIL);
- generator.setParameter(JobDetailConstants.JOB_ID, name);
- generator.setParameter(JobDetailConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- JobDetail jobDetail = (JobDetail) q.getSingleResult();
- JobDetailResource jobDetailResource = (JobDetailResource) Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
- em.getTransaction().commit();
- em.close();
- return jobDetailResource;
- case DATA_TRANSFER_DETAIL:
- generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
- generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
- q = generator.selectQuery(em);
- DataTransferDetail transferDetail = (DataTransferDetail) q.getSingleResult();
- DataTransferDetailResource transferDetailResource = (DataTransferDetailResource) Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
- em.getTransaction().commit();
- em.close();
- return transferDetailResource;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.TASK_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.TASK.toString());
- q = generator.selectQuery(em);
- Status status = (Status) q.getSingleResult();
- StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
- em.getTransaction().commit();
- em.close();
- return statusResource;
- case COMPUTATIONAL_RESOURCE_SCHEDULING:
- generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
- generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- Computational_Resource_Scheduling resourceScheduling = (Computational_Resource_Scheduling) q.getSingleResult();
- ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource) Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling);
- em.getTransaction().commit();
- em.close();
- return schedulingResource;
- case ADVANCE_INPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
- generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- AdvancedInputDataHandling dataHandling = (AdvancedInputDataHandling) q.getSingleResult();
- AdvanceInputDataHandlingResource inputDataHandlingResource = (AdvanceInputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, dataHandling);
- em.getTransaction().commit();
- em.close();
- return inputDataHandlingResource;
- case ADVANCE_OUTPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
- generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling) q.getSingleResult();
- AdvancedOutputDataHandlingResource outputDataHandlingResource = (AdvancedOutputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
- em.getTransaction().commit();
- em.close();
- return outputDataHandlingResource;
- case QOS_PARAM:
- generator = new QueryGenerator(QOS_PARAMS);
- generator.setParameter(QosParamsConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- QosParam qosParam = (QosParam) q.getSingleResult();
- QosParamResource qosParamResource = (QosParamResource) Utils.getResource(ResourceType.QOS_PARAM, qosParam);
- em.getTransaction().commit();
- em.close();
- return qosParamResource;
- default:
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported resource type for workflow node resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for workflow node resource.");
- }
- } catch (Exception e) {
-// logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
-
- public List<Resource> get(ResourceType type) throws RegistryException{
- List<Resource> resourceList = new ArrayList<Resource>();
- EntityManager em = null;
- try {
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- List results;
- switch (type) {
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ErrorDetail errorDetail = (ErrorDetail) result;
- ErrorDetailResource errorDetailResource =
- (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- resourceList.add(errorDetailResource);
- }
- }
- break;
- case NOTIFICATION_EMAIL:
- generator = new QueryGenerator(NOTIFICATION_EMAIL);
- generator.setParameter(NotificationEmailConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Notification_Email notificationEmail = (Notification_Email) result;
- NotificationEmailResource emailResource =
- (NotificationEmailResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
- resourceList.add(emailResource);
- }
- }
- break;
- case APPLICATION_INPUT:
- generator = new QueryGenerator(APPLICATION_INPUT);
- generator.setParameter(ApplicationInputConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationInput applicationInput = (ApplicationInput) result;
- ApplicationInputResource inputResource =
- (ApplicationInputResource) Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
- resourceList.add(inputResource);
- }
- }
- break;
- case APPLICATION_OUTPUT:
- generator = new QueryGenerator(APPLICATION_OUTPUT);
- generator.setParameter(ApplicationOutputConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationOutput applicationOutput = (ApplicationOutput) result;
- ApplicationOutputResource outputResource =
- (ApplicationOutputResource) Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
- resourceList.add(outputResource);
- }
- }
- break;
- case JOB_DETAIL:
- generator = new QueryGenerator(JOB_DETAIL);
- generator.setParameter(JobDetailConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- JobDetail jobDetail = (JobDetail) result;
- JobDetailResource jobDetailResource =
- (JobDetailResource) Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
- resourceList.add(jobDetailResource);
- }
- }
- break;
- case DATA_TRANSFER_DETAIL:
- generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
- generator.setParameter(DataTransferDetailConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- DataTransferDetail transferDetail = (DataTransferDetail) result;
- DataTransferDetailResource transferDetailResource =
- (DataTransferDetailResource) Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
- resourceList.add(transferDetailResource);
- }
- }
- break;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Status status = (Status) result;
- StatusResource statusResource =
- (StatusResource) Utils.getResource(ResourceType.STATUS, status);
- resourceList.add(statusResource);
- }
- }
- break;
- default:
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceList;
- }
-
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ResourceUtils.getEntityManager();
- TaskDetail taskDetail = em.find(TaskDetail.class, taskId);
- em.close();
- em = ResourceUtils.getEntityManager();
- em.getTransaction().begin();
- if (taskDetail != null) {
- updateTaskDetail(taskDetail, nodeId);
- em.merge(taskDetail);
- } else {
- taskDetail = new TaskDetail();
- updateTaskDetail(taskDetail, nodeId);
- em.persist(taskDetail);
- }
- em.getTransaction().commit();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- private void updateTaskDetail(TaskDetail taskDetail, String nodeId) {
- taskDetail.setTaskId(taskId);
- taskDetail.setNodeId(nodeId);
- taskDetail.setCreationTime(creationTime);
- taskDetail.setAppId(applicationId);
- taskDetail.setAppVersion(applicationVersion);
- taskDetail.setAllowNotification(enableEmailNotifications);
- taskDetail.setApplicationDeploymentId(getApplicationDeploymentId());
- }
-
- public List<ApplicationInputResource> getApplicationInputs() {
- return applicationInputs;
- }
-
- public List<ApplicationOutputResource> getApplicationOutputs() {
- return applicationOutputs;
- }
-
- public List<ApplicationInputResource> getApplicationInputs1() throws RegistryException{
- List<ApplicationInputResource> applicationInputResources = new ArrayList<ApplicationInputResource>();
- List<Resource> resources = get(ResourceType.APPLICATION_INPUT);
- for (Resource resource : resources) {
- ApplicationInputResource inputResource = (ApplicationInputResource) resource;
- applicationInputResources.add(inputResource);
- }
- return applicationInputResources;
- }
-
- public List<ApplicationOutputResource> getApplicationOutputs1() throws RegistryException{
- List<ApplicationOutputResource> outputResources = new ArrayList<ApplicationOutputResource>();
- List<Resource> resources = get(ResourceType.APPLICATION_OUTPUT);
- for (Resource resource : resources) {
- ApplicationOutputResource outputResource = (ApplicationOutputResource) resource;
- outputResources.add(outputResource);
- }
- return outputResources;
- }
-
- public StatusResource getTaskStatus() {
- return taskStatus;
- }
-
- public StatusResource getTaskStatus1() throws RegistryException{
- List<Resource> resources = get(ResourceType.STATUS);
- for (Resource resource : resources) {
- StatusResource taskStatus = (StatusResource) resource;
- if(taskStatus.getStatusType().equals(StatusType.TASK.toString())){
- if (taskStatus.getState() == null || taskStatus.getState().equals("") ){
- taskStatus.setState("UNKNOWN");
- }
- return taskStatus;
- }
- }
- return null;
- }
-
- public List<JobDetailResource> getJobDetailList() throws RegistryException{
- List<JobDetailResource> jobDetailResources = new ArrayList<JobDetailResource>();
- List<Resource> resources = get(ResourceType.JOB_DETAIL);
- for (Resource resource : resources) {
- JobDetailResource jobDetailResource = (JobDetailResource) resource;
- jobDetailResources.add(jobDetailResource);
- }
- return jobDetailResources;
- }
-
- public List<DataTransferDetailResource> getDataTransferDetailList() throws RegistryException{
- List<DataTransferDetailResource> transferDetails = new ArrayList<DataTransferDetailResource>();
- List<Resource> resources = get(ResourceType.DATA_TRANSFER_DETAIL);
- for (Resource resource : resources) {
- DataTransferDetailResource transferDetailResource = (DataTransferDetailResource) resource;
- transferDetails.add(transferDetailResource);
- }
- return transferDetails;
- }
-
- public List<ErrorDetailResource> getErrorDetailList() throws RegistryException{
- List<ErrorDetailResource> errorDetailResources = new ArrayList<ErrorDetailResource>();
- List<Resource> resources = get(ResourceType.ERROR_DETAIL);
- for (Resource resource : resources) {
- ErrorDetailResource errorDetailResource = (ErrorDetailResource) resource;
- errorDetailResources.add(errorDetailResource);
- }
- return errorDetailResources;
- }
-
- public ComputationSchedulingResource getComputationScheduling (String taskId) throws RegistryException{
- return (ComputationSchedulingResource)get(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, taskId);
- }
-
- public AdvanceInputDataHandlingResource getInputDataHandling (String taskId) throws RegistryException{
- return (AdvanceInputDataHandlingResource)get(ResourceType.ADVANCE_INPUT_DATA_HANDLING, taskId);
- }
-
- public AdvancedOutputDataHandlingResource getOutputDataHandling (String taskId) throws RegistryException{
- return (AdvancedOutputDataHandlingResource)get(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, taskId);
- }
-
- public JobDetailResource createJobDetail (String jobId) throws RegistryException{
- JobDetailResource resource = (JobDetailResource)create(ResourceType.JOB_DETAIL);
- resource.setJobId(jobId);
- return resource;
- }
-
- public JobDetailResource getJobDetail (String jobId) throws RegistryException{
- return (JobDetailResource)get(ResourceType.JOB_DETAIL, jobId);
- }
-
- public DataTransferDetailResource getDataTransferDetail (String dataTransferId) throws RegistryException{
- return (DataTransferDetailResource)get(ResourceType.DATA_TRANSFER_DETAIL, dataTransferId);
- }
-
- public boolean isTaskStatusExist (String taskId) throws RegistryException{
- return isExists(ResourceType.STATUS, taskId);
- }
-
- public String getApplicationDeploymentId() {
- return applicationDeploymentId;
- }
-
- public void setApplicationDeploymentId(String applicationDeploymentId) {
- this.applicationDeploymentId = applicationDeploymentId;
- }
-
- public List<NotificationEmailResource> getNotificationEmails () throws RegistryException{
- List<NotificationEmailResource> emailResources = new ArrayList<NotificationEmailResource>();
- List<Resource> resources = get(ResourceType.NOTIFICATION_EMAIL);
- for (Resource resource : resources) {
- emailResources.add((NotificationEmailResource) resource);
- }
- return emailResources;
- }
-}