http://git-wip-us.apache.org/repos/asf/airavata/blob/5a648a60/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/JobDetailResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/JobDetailResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/JobDetailResource.java deleted file mode 100644 index b8ee0fa..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/JobDetailResource.java +++ /dev/null @@ -1,376 +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.experiment.catalog.resources; - -import org.apache.airavata.experiment.catalog.Resource; -import org.apache.airavata.experiment.catalog.ResourceType; -import org.apache.airavata.experiment.catalog.ResourceUtils; -import org.apache.airavata.experiment.catalog.model.*; -import org.apache.airavata.experiment.catalog.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 JobDetailResource extends AbstractResource { - private static final Logger logger = LoggerFactory.getLogger(JobDetailResource.class); - private String jobId; - private String taskId; - private String jobDescription; - private Timestamp creationTime; - private String computeResourceConsumed; - private String jobName; - private String workingDir; - private StatusResource jobStatus; - private List<ErrorDetailResource> errors; - - public void setJobStatus(StatusResource jobStatus) { - this.jobStatus = jobStatus; - } - - public List<ErrorDetailResource> getErrors() { - return errors; - } - - public void setErrors(List<ErrorDetailResource> errors) { - this.errors = errors; - } - - public String getJobName() { - return jobName; - } - - public void setJobName(String jobName) { - this.jobName = jobName; - } - - public String getWorkingDir() { - return workingDir; - } - - public void setWorkingDir(String workingDir) { - this.workingDir = workingDir; - } - - public String getJobId() { - return jobId; - } - - public void setJobId(String jobId) { - this.jobId = jobId; - } - - public String getTaskId() { - return taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getJobDescription() { - return jobDescription; - } - - public void setJobDescription(String jobDescription) { - this.jobDescription = jobDescription; - } - - public Timestamp getCreationTime() { - return creationTime; - } - - public void setCreationTime(Timestamp creationTime) { - this.creationTime = creationTime; - } - - public String getComputeResourceConsumed() { - return computeResourceConsumed; - } - - public void setComputeResourceConsumed(String computeResourceConsumed) { - this.computeResourceConsumed = computeResourceConsumed; - } - - - public Resource create(ResourceType type) throws RegistryException { - switch (type){ - case STATUS: - StatusResource statusResource = new StatusResource(); - statusResource.setJobId(jobId); - return statusResource; - case ERROR_DETAIL: - ErrorDetailResource errorDetailResource = new ErrorDetailResource(); - errorDetailResource.setJobId(jobId); - return errorDetailResource; - default: - logger.error("Unsupported resource type for job details data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } - - - 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 STATUS: - generator = new QueryGenerator(STATUS); - generator.setParameter(StatusConstants.JOB_ID, name); - generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.JOB.toString()); - q = generator.deleteQuery(em); - q.executeUpdate(); - break; - case ERROR_DETAIL: - generator = new QueryGenerator(STATUS); - generator.setParameter(ErrorDetailConstants.JOB_ID, name); - q = generator.deleteQuery(em); - q.executeUpdate(); - break; - default: - logger.error("Unsupported resource type for job details 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 STATUS: - generator = new QueryGenerator(STATUS); - generator.setParameter(StatusConstants.JOB_ID, name); - generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.JOB.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 ERROR_DETAIL: - generator = new QueryGenerator(ERROR_DETAIL); - generator.setParameter(ErrorDetailConstants.JOB_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; - default: - em.getTransaction().commit(); - em.close(); - logger.error("Unsupported resource type for job details resource.", new IllegalArgumentException()); - throw new IllegalArgumentException("Unsupported resource type for job details 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 STATUS: - generator = new QueryGenerator(STATUS); - generator.setParameter(StatusConstants.JOB_ID, jobId); - 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; - case ERROR_DETAIL: - generator = new QueryGenerator(ERROR_DETAIL); - generator.setParameter(ErrorDetailConstants.JOB_ID, jobId); - 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; - 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) { - 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(); - JobDetail existingJobDetail = em.find(JobDetail.class, new JobDetails_PK(jobId, taskId)); - em.close(); - - em = ResourceUtils.getEntityManager(); - em.getTransaction().begin(); - JobDetail jobDetail = new JobDetail(); - jobDetail.setJobId(jobId); - jobDetail.setTaskId(taskId); - jobDetail.setCreationTime(creationTime); - jobDetail.setJobName(jobName); - jobDetail.setWorkingDir(workingDir); - if (jobDescription != null) { - jobDetail.setJobDescription(jobDescription.toCharArray()); - } - jobDetail.setComputeResourceConsumed(computeResourceConsumed); - if (existingJobDetail != null) { - existingJobDetail.setJobId(jobId); - existingJobDetail.setTaskId(taskId); - existingJobDetail.setCreationTime(creationTime); - if (jobDescription != null) { - existingJobDetail.setJobDescription(jobDescription.toCharArray()); - } - existingJobDetail.setComputeResourceConsumed(computeResourceConsumed); - existingJobDetail.setJobName(jobName); - existingJobDetail.setWorkingDir(workingDir); - jobDetail = em.merge(existingJobDetail); - } else { - em.persist(jobDetail); - } - 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 StatusResource getJobStatus() { - return jobStatus; - } - - public StatusResource getJobStatus1() throws RegistryException{ - List<Resource> resources = get(ResourceType.STATUS); - for (Resource resource : resources) { - StatusResource jobStatus = (StatusResource) resource; - if(jobStatus.getStatusType().equals(StatusType.JOB.toString())){ - if (jobStatus.getState() == null || jobStatus.getState().equals("") ){ - jobStatus.setState("UNKNOWN"); - } - return jobStatus; - } - } - return null; - } - - public StatusResource getApplicationStatus() throws RegistryException{ - List<Resource> resources = get(ResourceType.STATUS); - for (Resource resource : resources) { - StatusResource appStatus = (StatusResource) resource; - if(appStatus.getStatusType().equals(StatusType.APPLICATION.toString())){ - if (appStatus.getState() == null || appStatus.getState().equals("") ){ - appStatus.setState("UNKNOWN"); - } - return appStatus; - } - } - return null; - } - - public List<ErrorDetailResource> getErrorDetails () throws RegistryException{ - List<ErrorDetailResource> errorDetailResources = new ArrayList<ErrorDetailResource>(); - List<Resource> resources = get(ResourceType.ERROR_DETAIL); - for(Resource resource : resources){ - errorDetailResources.add((ErrorDetailResource)resource); - } - return errorDetailResources; - } - - -}
http://git-wip-us.apache.org/repos/asf/airavata/blob/5a648a60/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/NodeInputResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/NodeInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/NodeInputResource.java deleted file mode 100644 index 92aba23..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/NodeInputResource.java +++ /dev/null @@ -1,227 +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.experiment.catalog.resources; - -import java.util.List; - -import javax.persistence.EntityManager; - -import org.apache.airavata.experiment.catalog.Resource; -import org.apache.airavata.experiment.catalog.ResourceType; -import org.apache.airavata.experiment.catalog.ResourceUtils; -import org.apache.airavata.experiment.catalog.model.NodeInput; -import org.apache.airavata.experiment.catalog.model.NodeInput_PK; -import org.apache.airavata.registry.cpi.RegistryException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NodeInputResource extends AbstractResource { - private static final Logger logger = LoggerFactory.getLogger(NodeInputResource.class); - - private String nodeId; - private String inputKey; - private String dataType; - private String metadata; - private String value; - private String appArgument; - private boolean standardInput; - private String userFriendlyDesc; - private int inputOrder; - private boolean isRequired; - private boolean requiredToCMD; - private boolean dataStaged; - - public boolean getRequired() { - return isRequired; - } - - public void setRequired(boolean required) { - this.isRequired = required; - } - - public boolean getRequiredToCMD() { - return requiredToCMD; - } - - public void setRequiredToCMD(boolean requiredToCMD) { - this.requiredToCMD = requiredToCMD; - } - - public boolean isDataStaged() { - return dataStaged; - } - - public void setDataStaged(boolean dataStaged) { - this.dataStaged = dataStaged; - } - - public String getAppArgument() { - return appArgument; - } - - public void setAppArgument(String appArgument) { - this.appArgument = appArgument; - } - - public boolean isStandardInput() { - return standardInput; - } - - public void setStandardInput(boolean standardInput) { - this.standardInput = standardInput; - } - - public String getUserFriendlyDesc() { - return userFriendlyDesc; - } - - public void setUserFriendlyDesc(String userFriendlyDesc) { - this.userFriendlyDesc = userFriendlyDesc; - } - - public String getNodeId() { - return nodeId; - } - - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } - - public String getInputKey() { - return inputKey; - } - - public void setInputKey(String inputKey) { - this.inputKey = inputKey; - } - - public String getDataType() { - return dataType; - } - - public void setDataType(String dataType) { - this.dataType = dataType; - } - - public String getMetadata() { - return metadata; - } - - public void setMetadata(String metadata) { - this.metadata = metadata; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public int getInputOrder() { - return inputOrder; - } - - public void setInputOrder(int inputOrder) { - this.inputOrder = inputOrder; - } - - public Resource create(ResourceType type) throws RegistryException { - logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void remove(ResourceType type, Object name) throws RegistryException{ - logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public Resource get(ResourceType type, Object name) throws RegistryException { - logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public List<Resource> get(ResourceType type) throws RegistryException { - logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void save() throws RegistryException{ - EntityManager em = null; - try { - em = ResourceUtils.getEntityManager(); - NodeInput existingInput = em.find(NodeInput.class, new NodeInput_PK(inputKey, nodeId)); - em.close(); - - em = ResourceUtils.getEntityManager(); - em.getTransaction().begin(); - NodeInput nodeInput = new NodeInput(); - nodeInput.setNodeId(nodeId); - nodeInput.setInputKey(inputKey); - nodeInput.setDataType(dataType); - nodeInput.setValue(value); - nodeInput.setMetadata(metadata); - nodeInput.setAppArgument(appArgument); - nodeInput.setStandardInput(standardInput); - nodeInput.setUserFriendlyDesc(userFriendlyDesc); - nodeInput.setInputOrder(inputOrder); - nodeInput.setRequiredToCMD(requiredToCMD); - nodeInput.setIsRequired(isRequired); - nodeInput.setDataStaged(dataStaged); - - if (existingInput != null){ - existingInput.setNodeId(nodeId); - existingInput.setInputKey(inputKey); - existingInput.setDataType(dataType); - existingInput.setValue(value); - existingInput.setMetadata(metadata); - existingInput.setAppArgument(appArgument); - existingInput.setStandardInput(standardInput); - existingInput.setUserFriendlyDesc(userFriendlyDesc); - existingInput.setInputOrder(inputOrder); - existingInput.setRequiredToCMD(requiredToCMD); - existingInput.setIsRequired(isRequired); - existingInput.setDataStaged(dataStaged); - nodeInput = em.merge(existingInput); - }else { - em.persist(nodeInput); - } - 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/5a648a60/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/NodeOutputResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/NodeOutputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/NodeOutputResource.java deleted file mode 100644 index 5edc314..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/NodeOutputResource.java +++ /dev/null @@ -1,207 +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.experiment.catalog.resources; - -import java.util.List; - -import javax.persistence.EntityManager; - -import org.apache.airavata.experiment.catalog.Resource; -import org.apache.airavata.experiment.catalog.ResourceType; -import org.apache.airavata.experiment.catalog.ResourceUtils; -import org.apache.airavata.experiment.catalog.model.NodeOutput; -import org.apache.airavata.experiment.catalog.model.NodeOutput_PK; -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/5a648a60/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/NotificationEmailResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/NotificationEmailResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/NotificationEmailResource.java deleted file mode 100644 index 1bcce9c..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/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.experiment.catalog.resources; - -import org.apache.airavata.experiment.catalog.Resource; -import org.apache.airavata.experiment.catalog.ResourceType; -import org.apache.airavata.experiment.catalog.ResourceUtils; -import org.apache.airavata.experiment.catalog.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/5a648a60/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/ProjectResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/ProjectResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/ProjectResource.java deleted file mode 100644 index 687a8cb..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/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.experiment.catalog.resources; - -import org.apache.airavata.experiment.catalog.Resource; -import org.apache.airavata.experiment.catalog.ResourceType; -import org.apache.airavata.experiment.catalog.ResourceUtils; -import org.apache.airavata.experiment.catalog.model.*; -import org.apache.airavata.experiment.catalog.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/5a648a60/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/ProjectUserResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/ProjectUserResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/ProjectUserResource.java deleted file mode 100644 index f272433..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/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.experiment.catalog.resources; - -import org.apache.airavata.experiment.catalog.Resource; -import org.apache.airavata.experiment.catalog.ResourceType; -import org.apache.airavata.experiment.catalog.ResourceUtils; -import org.apache.airavata.experiment.catalog.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/5a648a60/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/QosParamResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/QosParamResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/QosParamResource.java deleted file mode 100644 index 1d00a5c..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/QosParamResource.java +++ /dev/null @@ -1,144 +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.experiment.catalog.resources; - -import org.apache.airavata.experiment.catalog.Resource; -import org.apache.airavata.experiment.catalog.ResourceType; -import org.apache.airavata.experiment.catalog.ResourceUtils; -import org.apache.airavata.experiment.catalog.model.QosParam; -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/5a648a60/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/StatusResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/StatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/resources/StatusResource.java deleted file mode 100644 index 257b657..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experimet/catalog/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.experiment.catalog.resources; - -import org.apache.airavata.experiment.catalog.Resource; -import org.apache.airavata.experiment.catalog.ResourceType; -import org.apache.airavata.experiment.catalog.ResourceUtils; -import org.apache.airavata.experiment.catalog.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(); - } - } - } -}
