http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationInputResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationInputResource.java new file mode 100644 index 0000000..04bb641 --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationInputResource.java @@ -0,0 +1,230 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.airavata.registry.core.experiment.catalog.resources; + +import java.util.List; + +import javax.persistence.EntityManager; + +import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; +import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource; +import org.apache.airavata.registry.core.experiment.catalog.ResourceType; +import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationInput; +import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationInput_PK; +import org.apache.airavata.registry.cpi.RegistryException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ApplicationInputResource extends AbstractExpCatResource { + private static final Logger logger = LoggerFactory.getLogger(ApplicationInputResource.class); + 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; + private String taskId; + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public boolean isRequired() { + return isRequired; + } + + public void setRequired(boolean isRequired) { + this.isRequired = isRequired; + } + + public boolean isRequiredToCMD() { + return requiredToCMD; + } + + public void setRequiredToCMD(boolean requiredToCMD) { + this.requiredToCMD = requiredToCMD; + } + + public boolean isDataStaged() { + return dataStaged; + } + + public void setDataStaged(boolean dataStaged) { + this.dataStaged = dataStaged; + } + + public int getInputOrder() { + return inputOrder; + } + + public void setInputOrder(int inputOrder) { + this.inputOrder = inputOrder; + } + + 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 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 ExperimentCatResource create(ResourceType type) throws RegistryException { + logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public void remove(ResourceType type, Object name) throws RegistryException{ + logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException { + logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{ + logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public void save() throws RegistryException { + EntityManager em = null; + try { + em = ExpCatResourceUtils.getEntityManager(); + ApplicationInput existingInput = em.find(ApplicationInput.class, new ApplicationInput_PK(inputKey, taskId)); + em.close(); + + em = ExpCatResourceUtils.getEntityManager(); + em.getTransaction().begin(); + ApplicationInput applicationInput = new ApplicationInput(); + applicationInput.setTaskId(taskId); + applicationInput.setInputKey(inputKey); + applicationInput.setDataType(dataType); + applicationInput.setAppArgument(appArgument); + applicationInput.setStandardInput(standardInput); + applicationInput.setUserFriendlyDesc(userFriendlyDesc); + applicationInput.setInputOrder(inputOrder); + applicationInput.setRequiredToCMD(requiredToCMD); + applicationInput.setRequired(isRequired); + applicationInput.setDataStaged(dataStaged); + if (value != null) { + applicationInput.setValue(value.toCharArray()); + } + + applicationInput.setMetadata(metadata); + + if (existingInput != null) { + existingInput.setTaskId(taskId); + existingInput.setInputKey(inputKey); + existingInput.setDataType(dataType); + existingInput.setAppArgument(appArgument); + existingInput.setStandardInput(standardInput); + existingInput.setUserFriendlyDesc(userFriendlyDesc); + existingInput.setInputOrder(inputOrder); + existingInput.setRequiredToCMD(requiredToCMD); + existingInput.setRequired(isRequired); + existingInput.setDataStaged(dataStaged); + if (value != null) { + existingInput.setValue(value.toCharArray()); + } + existingInput.setMetadata(metadata); + applicationInput = em.merge(existingInput); + } else { + em.persist(applicationInput); + } + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + throw new RegistryException(e.getMessage()); + } 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputExperimentCatResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputExperimentCatResource.java deleted file mode 100644 index b059513..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputExperimentCatResource.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.registry.core.experiment.catalog.resources; - -import java.util.List; - -import javax.persistence.EntityManager; - -import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; -import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource; -import org.apache.airavata.registry.core.experiment.catalog.ResourceType; -import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationOutput; -import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationOutput_PK; -import org.apache.airavata.registry.cpi.RegistryException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ApplicationOutputExperimentCatResource extends AbstractExperimentCatResource { - private static final Logger logger = LoggerFactory.getLogger(ApplicationOutputExperimentCatResource.class); - private String taskId; - 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 isRequired() { - return isRequired; - } - - public void setRequired(boolean isRequired) { - this.isRequired = isRequired; - } - - public boolean isRequiredToCMD() { - return requiredToCMD; - } - - public void setRequiredToCMD(boolean requiredToCMD) { - this.requiredToCMD = requiredToCMD; - } - - public boolean 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 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 String getTaskId() { - return taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public ExperimentCatResource create(ResourceType type) throws RegistryException { - logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void remove(ResourceType type, Object name) throws RegistryException{ - logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{ - logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{ - logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void save() throws RegistryException { - EntityManager em = null; - try { - em = ExpCatResourceUtils.getEntityManager(); - ApplicationOutput existingOutput = em.find(ApplicationOutput.class, new ApplicationOutput_PK(outputKey, taskId)); - em.close(); - - em = ExpCatResourceUtils.getEntityManager(); - em.getTransaction().begin(); - ApplicationOutput applicationOutput = new ApplicationOutput(); - applicationOutput.setTaskId(taskId); - applicationOutput.setOutputKey(outputKey); - applicationOutput.setDataType(dataType); - applicationOutput.setRequired(isRequired); - applicationOutput.setAddedToCmd(requiredToCMD); - applicationOutput.setDataMovement(dataMovement); - applicationOutput.setDataNameLocation(dataNameLocation); - applicationOutput.setSearchQuery(searchQuery); - applicationOutput.setApplicationArgument(appArgument); - if (value != null){ - applicationOutput.setValue(value.toCharArray()); - } - - if (existingOutput != null) { - existingOutput.setTaskId(taskId); - existingOutput.setOutputKey(outputKey); - existingOutput.setDataType(dataType); - existingOutput.setRequired(isRequired); - existingOutput.setAddedToCmd(requiredToCMD); - existingOutput.setDataMovement(dataMovement); - existingOutput.setDataNameLocation(dataNameLocation); - existingOutput.setSearchQuery(searchQuery); - existingOutput.setApplicationArgument(appArgument); - if (value != null){ - existingOutput.setValue(value.toCharArray()); - } - applicationOutput = em.merge(existingOutput); - } else { - em.persist(applicationOutput); - } - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new RegistryException(e.getMessage()); - } 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputResource.java new file mode 100644 index 0000000..6443814 --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputResource.java @@ -0,0 +1,208 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.airavata.registry.core.experiment.catalog.resources; + +import java.util.List; + +import javax.persistence.EntityManager; + +import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; +import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource; +import org.apache.airavata.registry.core.experiment.catalog.ResourceType; +import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationOutput; +import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationOutput_PK; +import org.apache.airavata.registry.cpi.RegistryException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ApplicationOutputResource extends AbstractExpCatResource { + private static final Logger logger = LoggerFactory.getLogger(ApplicationOutputResource.class); + private String taskId; + 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 isRequired() { + return isRequired; + } + + public void setRequired(boolean isRequired) { + this.isRequired = isRequired; + } + + public boolean isRequiredToCMD() { + return requiredToCMD; + } + + public void setRequiredToCMD(boolean requiredToCMD) { + this.requiredToCMD = requiredToCMD; + } + + public boolean 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 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 String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public ExperimentCatResource create(ResourceType type) throws RegistryException { + logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public void remove(ResourceType type, Object name) throws RegistryException{ + logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{ + logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{ + logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public void save() throws RegistryException { + EntityManager em = null; + try { + em = ExpCatResourceUtils.getEntityManager(); + ApplicationOutput existingOutput = em.find(ApplicationOutput.class, new ApplicationOutput_PK(outputKey, taskId)); + em.close(); + + em = ExpCatResourceUtils.getEntityManager(); + em.getTransaction().begin(); + ApplicationOutput applicationOutput = new ApplicationOutput(); + applicationOutput.setTaskId(taskId); + applicationOutput.setOutputKey(outputKey); + applicationOutput.setDataType(dataType); + applicationOutput.setRequired(isRequired); + applicationOutput.setAddedToCmd(requiredToCMD); + applicationOutput.setDataMovement(dataMovement); + applicationOutput.setDataNameLocation(dataNameLocation); + applicationOutput.setSearchQuery(searchQuery); + applicationOutput.setApplicationArgument(appArgument); + if (value != null){ + applicationOutput.setValue(value.toCharArray()); + } + + if (existingOutput != null) { + existingOutput.setTaskId(taskId); + existingOutput.setOutputKey(outputKey); + existingOutput.setDataType(dataType); + existingOutput.setRequired(isRequired); + existingOutput.setAddedToCmd(requiredToCMD); + existingOutput.setDataMovement(dataMovement); + existingOutput.setDataNameLocation(dataNameLocation); + existingOutput.setSearchQuery(searchQuery); + existingOutput.setApplicationArgument(appArgument); + if (value != null){ + existingOutput.setValue(value.toCharArray()); + } + applicationOutput = em.merge(existingOutput); + } else { + em.persist(applicationOutput); + } + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new RegistryException(e.getMessage()); + } 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingExperimentCatResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingExperimentCatResource.java deleted file mode 100644 index 4ff5085..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingExperimentCatResource.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.registry.core.experiment.catalog.resources; - -import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; -import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource; -import org.apache.airavata.registry.core.experiment.catalog.ResourceType; -import org.apache.airavata.registry.core.experiment.catalog.model.Computational_Resource_Scheduling; -import org.apache.airavata.registry.cpi.RegistryException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.EntityManager; -import java.sql.Timestamp; -import java.util.List; - -public class ComputationSchedulingExperimentCatResource extends AbstractExperimentCatResource { - private static final Logger logger = LoggerFactory.getLogger(ComputationSchedulingExperimentCatResource.class); - private int schedulingId = 0; - private String experimentId; - private String taskId; - private String resourceHostId; - private int cpuCount; - private int nodeCount; - private int numberOfThreads; - private String queueName; - private int walltimeLimit; - private Timestamp jobStartTime; - private int physicalMemory; - private String projectName; - private String chessisName; - - public String getChessisName() { - return chessisName; - } - - public void setChessisName(String chessisName) { - this.chessisName = chessisName; - } - - public int getSchedulingId() { - return schedulingId; - } - - public void setSchedulingId(int schedulingId) { - this.schedulingId = schedulingId; - } - - 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 getResourceHostId() { - return resourceHostId; - } - - public void setResourceHostId(String resourceHostId) { - this.resourceHostId = resourceHostId; - } - - public int getCpuCount() { - return cpuCount; - } - - public void setCpuCount(int cpuCount) { - this.cpuCount = cpuCount; - } - - public int getNodeCount() { - return nodeCount; - } - - public void setNodeCount(int nodeCount) { - this.nodeCount = nodeCount; - } - - public int getNumberOfThreads() { - return numberOfThreads; - } - - public void setNumberOfThreads(int numberOfThreads) { - this.numberOfThreads = numberOfThreads; - } - - public String getQueueName() { - return queueName; - } - - public void setQueueName(String queueName) { - this.queueName = queueName; - } - - public int getWalltimeLimit() { - return walltimeLimit; - } - - public void setWalltimeLimit(int walltimeLimit) { - this.walltimeLimit = walltimeLimit; - } - - public Timestamp getJobStartTime() { - return jobStartTime; - } - - public void setJobStartTime(Timestamp jobStartTime) { - this.jobStartTime = jobStartTime; - } - - public int getPhysicalMemory() { - return physicalMemory; - } - - public void setPhysicalMemory(int physicalMemory) { - this.physicalMemory = physicalMemory; - } - - public String getProjectName() { - return projectName; - } - - public void setProjectName(String projectName) { - this.projectName = projectName; - } - - - public ExperimentCatResource create(ResourceType type) throws RegistryException { - logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void remove(ResourceType type, Object name) throws RegistryException{ - logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{ - logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{ - logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void save() throws RegistryException{ - EntityManager em = null; - try { - em = ExpCatResourceUtils.getEntityManager(); - em.getTransaction().begin(); - Computational_Resource_Scheduling scheduling; - if (schedulingId != 0) { - scheduling = em.find(Computational_Resource_Scheduling.class, schedulingId); - scheduling.setSchedulingId(schedulingId); - } else { - scheduling = new Computational_Resource_Scheduling(); - } - scheduling.setExpId(experimentId); - scheduling.setTaskId(taskId); - scheduling.setResourceHostId(resourceHostId); - scheduling.setCpuCount(cpuCount); - scheduling.setNodeCount(nodeCount); - scheduling.setNumberOfThreads(numberOfThreads); - scheduling.setQueueName(queueName); - scheduling.setWallTimeLimit(walltimeLimit); - scheduling.setJobStartTime(jobStartTime); - scheduling.setTotalPhysicalmemory(physicalMemory); - scheduling.setProjectName(projectName); - scheduling.setChessisName(chessisName); - em.persist(scheduling); - schedulingId = scheduling.getSchedulingId(); - 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingResource.java new file mode 100644 index 0000000..c913f5c --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingResource.java @@ -0,0 +1,221 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.airavata.registry.core.experiment.catalog.resources; + +import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; +import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource; +import org.apache.airavata.registry.core.experiment.catalog.ResourceType; +import org.apache.airavata.registry.core.experiment.catalog.model.Computational_Resource_Scheduling; +import org.apache.airavata.registry.cpi.RegistryException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.EntityManager; +import java.sql.Timestamp; +import java.util.List; + +public class ComputationSchedulingResource extends AbstractExpCatResource { + private static final Logger logger = LoggerFactory.getLogger(ComputationSchedulingResource.class); + private int schedulingId = 0; + private String experimentId; + private String taskId; + private String resourceHostId; + private int cpuCount; + private int nodeCount; + private int numberOfThreads; + private String queueName; + private int walltimeLimit; + private Timestamp jobStartTime; + private int physicalMemory; + private String projectName; + private String chessisName; + + public String getChessisName() { + return chessisName; + } + + public void setChessisName(String chessisName) { + this.chessisName = chessisName; + } + + public int getSchedulingId() { + return schedulingId; + } + + public void setSchedulingId(int schedulingId) { + this.schedulingId = schedulingId; + } + + 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 getResourceHostId() { + return resourceHostId; + } + + public void setResourceHostId(String resourceHostId) { + this.resourceHostId = resourceHostId; + } + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public int getNodeCount() { + return nodeCount; + } + + public void setNodeCount(int nodeCount) { + this.nodeCount = nodeCount; + } + + public int getNumberOfThreads() { + return numberOfThreads; + } + + public void setNumberOfThreads(int numberOfThreads) { + this.numberOfThreads = numberOfThreads; + } + + public String getQueueName() { + return queueName; + } + + public void setQueueName(String queueName) { + this.queueName = queueName; + } + + public int getWalltimeLimit() { + return walltimeLimit; + } + + public void setWalltimeLimit(int walltimeLimit) { + this.walltimeLimit = walltimeLimit; + } + + public Timestamp getJobStartTime() { + return jobStartTime; + } + + public void setJobStartTime(Timestamp jobStartTime) { + this.jobStartTime = jobStartTime; + } + + public int getPhysicalMemory() { + return physicalMemory; + } + + public void setPhysicalMemory(int physicalMemory) { + this.physicalMemory = physicalMemory; + } + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + + public ExperimentCatResource create(ResourceType type) throws RegistryException { + logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public void remove(ResourceType type, Object name) throws RegistryException{ + logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{ + logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{ + logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public void save() throws RegistryException{ + EntityManager em = null; + try { + em = ExpCatResourceUtils.getEntityManager(); + em.getTransaction().begin(); + Computational_Resource_Scheduling scheduling; + if (schedulingId != 0) { + scheduling = em.find(Computational_Resource_Scheduling.class, schedulingId); + scheduling.setSchedulingId(schedulingId); + } else { + scheduling = new Computational_Resource_Scheduling(); + } + scheduling.setExpId(experimentId); + scheduling.setTaskId(taskId); + scheduling.setResourceHostId(resourceHostId); + scheduling.setCpuCount(cpuCount); + scheduling.setNodeCount(nodeCount); + scheduling.setNumberOfThreads(numberOfThreads); + scheduling.setQueueName(queueName); + scheduling.setWallTimeLimit(walltimeLimit); + scheduling.setJobStartTime(jobStartTime); + scheduling.setTotalPhysicalmemory(physicalMemory); + scheduling.setProjectName(projectName); + scheduling.setChessisName(chessisName); + em.persist(scheduling); + schedulingId = scheduling.getSchedulingId(); + 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataExperimentCatResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataExperimentCatResource.java deleted file mode 100644 index bf218f8..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataExperimentCatResource.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.registry.core.experiment.catalog.resources; - -import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; -import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource; -import org.apache.airavata.registry.core.experiment.catalog.ResourceType; -import org.apache.airavata.registry.core.experiment.catalog.model.ExperimentConfigData; -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 ConfigDataExperimentCatResource extends AbstractExperimentCatResource { - private static final Logger logger = LoggerFactory.getLogger(ConfigDataExperimentCatResource.class); - private String experimentId; - private boolean airavataAutoSchedule; - private boolean overrideManualParams; - private boolean shareExp; - private String userDn; - private boolean generateCert; - private ComputationSchedulingExperimentCatResource computationSchedulingResource; - private AdvanceInputDataHandlingExperimentCatResource advanceInputDataHandlingResource; - private AdvancedOutputDataHandlingExperimentCatResource advancedOutputDataHandlingResource; - private QosParamExperimentCatResource qosParamResource; - - public ComputationSchedulingExperimentCatResource getComputationSchedulingResource() { - return computationSchedulingResource; - } - - public void setComputationSchedulingResource(ComputationSchedulingExperimentCatResource computationSchedulingResource) { - this.computationSchedulingResource = computationSchedulingResource; - } - - public AdvanceInputDataHandlingExperimentCatResource getAdvanceInputDataHandlingResource() { - return advanceInputDataHandlingResource; - } - - public void setAdvanceInputDataHandlingResource(AdvanceInputDataHandlingExperimentCatResource advanceInputDataHandlingResource) { - this.advanceInputDataHandlingResource = advanceInputDataHandlingResource; - } - - public AdvancedOutputDataHandlingExperimentCatResource getAdvancedOutputDataHandlingResource() { - return advancedOutputDataHandlingResource; - } - - public void setAdvancedOutputDataHandlingResource(AdvancedOutputDataHandlingExperimentCatResource advancedOutputDataHandlingResource) { - this.advancedOutputDataHandlingResource = advancedOutputDataHandlingResource; - } - - public QosParamExperimentCatResource getQosParamResource() { - return qosParamResource; - } - - public void setQosParamResource(QosParamExperimentCatResource qosParamResource) { - this.qosParamResource = qosParamResource; - } - - public String getUserDn() { - return userDn; - } - - public void setUserDn(String userDn) { - this.userDn = userDn; - } - - public boolean isGenerateCert() { - return generateCert; - } - - public void setGenerateCert(boolean generateCert) { - this.generateCert = generateCert; - } - - public String getExperimentId() { - return experimentId; - } - - public void setExperimentId(String experimentId) { - this.experimentId = experimentId; - } - - public boolean isAiravataAutoSchedule() { - return airavataAutoSchedule; - } - - public void setAiravataAutoSchedule(boolean airavataAutoSchedule) { - this.airavataAutoSchedule = airavataAutoSchedule; - } - - public boolean isOverrideManualParams() { - return overrideManualParams; - } - - public void setOverrideManualParams(boolean overrideManualParams) { - this.overrideManualParams = overrideManualParams; - } - - public boolean isShareExp() { - return shareExp; - } - - public void setShareExp(boolean shareExp) { - this.shareExp = shareExp; - } - - - public ExperimentCatResource create(ResourceType type) throws RegistryException { - logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void remove(ResourceType type, Object name) throws RegistryException{ - logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{ - logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{ - logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void save() throws RegistryException{ - EntityManager em = null; - try { - em = ExpCatResourceUtils.getEntityManager(); - ExperimentConfigData existingConfig = em.find(ExperimentConfigData.class, experimentId); - em.close(); - - em = ExpCatResourceUtils.getEntityManager(); - em.getTransaction().begin(); - ExperimentConfigData configData = new ExperimentConfigData(); - configData.setExpId(experimentId); - configData.setAiravataAutoSchedule(airavataAutoSchedule); - configData.setOverrideManualParams(overrideManualParams); - configData.setShareExp(shareExp); - configData.setUserDn(userDn); - configData.setGenerateCert(generateCert); - if (existingConfig != null) { - existingConfig.setExpId(experimentId); - existingConfig.setAiravataAutoSchedule(airavataAutoSchedule); - existingConfig.setOverrideManualParams(overrideManualParams); - existingConfig.setShareExp(shareExp); - existingConfig.setUserDn(userDn); - existingConfig.setGenerateCert(generateCert); - configData = em.merge(existingConfig); - } else { - em.persist(configData); - } - 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataResource.java new file mode 100644 index 0000000..289715b --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataResource.java @@ -0,0 +1,194 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.airavata.registry.core.experiment.catalog.resources; + +import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; +import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource; +import org.apache.airavata.registry.core.experiment.catalog.ResourceType; +import org.apache.airavata.registry.core.experiment.catalog.model.ExperimentConfigData; +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 ConfigDataResource extends AbstractExpCatResource { + private static final Logger logger = LoggerFactory.getLogger(ConfigDataResource.class); + private String experimentId; + private boolean airavataAutoSchedule; + private boolean overrideManualParams; + private boolean shareExp; + private String userDn; + private boolean generateCert; + private ComputationSchedulingResource computationSchedulingResource; + private AdvanceInputDataHandlingResource advanceInputDataHandlingResource; + private AdvancedOutputDataHandlingResource advancedOutputDataHandlingResource; + private QosParamResource qosParamResource; + + public ComputationSchedulingResource getComputationSchedulingResource() { + return computationSchedulingResource; + } + + public void setComputationSchedulingResource(ComputationSchedulingResource computationSchedulingResource) { + this.computationSchedulingResource = computationSchedulingResource; + } + + public AdvanceInputDataHandlingResource getAdvanceInputDataHandlingResource() { + return advanceInputDataHandlingResource; + } + + public void setAdvanceInputDataHandlingResource(AdvanceInputDataHandlingResource advanceInputDataHandlingResource) { + this.advanceInputDataHandlingResource = advanceInputDataHandlingResource; + } + + public AdvancedOutputDataHandlingResource getAdvancedOutputDataHandlingResource() { + return advancedOutputDataHandlingResource; + } + + public void setAdvancedOutputDataHandlingResource(AdvancedOutputDataHandlingResource advancedOutputDataHandlingResource) { + this.advancedOutputDataHandlingResource = advancedOutputDataHandlingResource; + } + + public QosParamResource getQosParamResource() { + return qosParamResource; + } + + public void setQosParamResource(QosParamResource qosParamResource) { + this.qosParamResource = qosParamResource; + } + + public String getUserDn() { + return userDn; + } + + public void setUserDn(String userDn) { + this.userDn = userDn; + } + + public boolean isGenerateCert() { + return generateCert; + } + + public void setGenerateCert(boolean generateCert) { + this.generateCert = generateCert; + } + + public String getExperimentId() { + return experimentId; + } + + public void setExperimentId(String experimentId) { + this.experimentId = experimentId; + } + + public boolean isAiravataAutoSchedule() { + return airavataAutoSchedule; + } + + public void setAiravataAutoSchedule(boolean airavataAutoSchedule) { + this.airavataAutoSchedule = airavataAutoSchedule; + } + + public boolean isOverrideManualParams() { + return overrideManualParams; + } + + public void setOverrideManualParams(boolean overrideManualParams) { + this.overrideManualParams = overrideManualParams; + } + + public boolean isShareExp() { + return shareExp; + } + + public void setShareExp(boolean shareExp) { + this.shareExp = shareExp; + } + + + public ExperimentCatResource create(ResourceType type) throws RegistryException { + logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public void remove(ResourceType type, Object name) throws RegistryException{ + logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{ + logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{ + logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + public void save() throws RegistryException{ + EntityManager em = null; + try { + em = ExpCatResourceUtils.getEntityManager(); + ExperimentConfigData existingConfig = em.find(ExperimentConfigData.class, experimentId); + em.close(); + + em = ExpCatResourceUtils.getEntityManager(); + em.getTransaction().begin(); + ExperimentConfigData configData = new ExperimentConfigData(); + configData.setExpId(experimentId); + configData.setAiravataAutoSchedule(airavataAutoSchedule); + configData.setOverrideManualParams(overrideManualParams); + configData.setShareExp(shareExp); + configData.setUserDn(userDn); + configData.setGenerateCert(generateCert); + if (existingConfig != null) { + existingConfig.setExpId(experimentId); + existingConfig.setAiravataAutoSchedule(airavataAutoSchedule); + existingConfig.setOverrideManualParams(overrideManualParams); + existingConfig.setShareExp(shareExp); + existingConfig.setUserDn(userDn); + existingConfig.setGenerateCert(generateCert); + configData = em.merge(existingConfig); + } else { + em.persist(configData); + } + 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationExperimentCatResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationExperimentCatResource.java deleted file mode 100644 index a5015fd..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationExperimentCatResource.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.registry.core.experiment.catalog.resources; - -import java.sql.Timestamp; -import java.util.List; - -import javax.persistence.EntityManager; - -import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; -import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource; -import org.apache.airavata.registry.core.experiment.catalog.ResourceType; -import org.apache.airavata.registry.core.experiment.catalog.model.Configuration; -import org.apache.airavata.registry.core.experiment.catalog.model.Configuration_PK; -import org.apache.airavata.registry.cpi.RegistryException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ConfigurationExperimentCatResource extends AbstractExperimentCatResource { - private final static Logger logger = LoggerFactory.getLogger(ConfigurationExperimentCatResource.class); - private String configKey; - private String configVal; - private Timestamp expireDate; - private String categoryID = ConfigurationConstants.CATEGORY_ID_DEFAULT_VALUE; - - public ConfigurationExperimentCatResource() { - } - - /** - * @param configKey configuration key - * @param configVal configuration value - */ - public ConfigurationExperimentCatResource(String configKey, String configVal) { - this.configKey = configKey; - this.configVal = configVal; - } - - /** - * Since Configuration does not depend on any other data structures at the - * system, this method is not valid - * - * @param type child resource types - * @return UnsupportedOperationException - */ - public ExperimentCatResource create(ResourceType type) throws RegistryException { - logger.error("Unsupported operation for configuration resource " + - "since there are no child resources generated by configuration resource.. ", - new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - /** - * Since Configuration does not depend on any other data structures at the - * system, this method is not valid - * - * @param type child resource types - * @param name name of the child resource - * throws UnsupportedOperationException - */ - public void remove(ResourceType type, Object name) throws RegistryException { - logger.error("Unsupported operation for configuration resource " + - "since there are no child resources generated by configuration resource.. ", - new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - /** - * Since Configuration does not depend on any other data structures at the - * system, this method is not valid - * - * @param type child resource types - * @param name name of the child resource - * @return UnsupportedOperationException - */ - public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException { - logger.error("Unsupported operation for configuration resource " + - "since there are no child resources generated by configuration resource.. ", - new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - /** - * Since Configuration does not depend on any other data structures at the - * system, this method is not valid - * - * @param type child resource types - * @return UnsupportedOperationException - */ - public List<ExperimentCatResource> get(ResourceType type) throws RegistryException { - logger.error("Unsupported operation for configuration resource " + - "since there are no child resources generated by configuration resource.. ", - new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - /** - * @param expireDate expire date of the configuration - */ - public void setExpireDate(Timestamp expireDate) { - this.expireDate = expireDate; - } - - /** - * save configuration to database - */ - public synchronized void save() throws RegistryException { - EntityManager em = null; - try { - em = ExpCatResourceUtils.getEntityManager(); - //whether existing - Configuration existing = em.find(Configuration.class, new Configuration_PK(configKey, configVal, categoryID)); - em.close(); - em = ExpCatResourceUtils.getEntityManager(); - em.getTransaction().begin(); - Configuration configuration = new Configuration(); - configuration.setConfig_key(configKey); - configuration.setConfig_val(configVal); - configuration.setExpire_date(expireDate); - configuration.setCategory_id(categoryID); - if (existing != null) { - existing.setExpire_date(expireDate); - existing.setCategory_id(categoryID); - configuration = em.merge(existing); - } else { - em.persist(configuration); - } - 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(); - } - } - } - - /** - * Since Configuration does not depend on any other data structures at the - * system, this method is not valid - * - * @param type child resource types - * @param name of the child resource - * @return UnsupportedOperationException - */ - public boolean isExists(ResourceType type, Object name) { - logger.error("Unsupported operation for configuration resource " + - "since there are no child resources generated by configuration resource.. ", - new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - /** - * @return configuration value - */ - public String getConfigVal() { - return configVal; - } - - /** - * @param configKey configuration key - */ - public void setConfigKey(String configKey) { - this.configKey = configKey; - } - - /** - * @param configVal configuration value - */ - public void setConfigVal(String configVal) { - this.configVal = configVal; - } - - public String getCategoryID() { - return categoryID; - } - - public void setCategoryID(String categoryID) { - this.categoryID = categoryID; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationResource.java new file mode 100644 index 0000000..1a4227e --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationResource.java @@ -0,0 +1,204 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.registry.core.experiment.catalog.resources; + +import java.sql.Timestamp; +import java.util.List; + +import javax.persistence.EntityManager; + +import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; +import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource; +import org.apache.airavata.registry.core.experiment.catalog.ResourceType; +import org.apache.airavata.registry.core.experiment.catalog.model.Configuration; +import org.apache.airavata.registry.core.experiment.catalog.model.Configuration_PK; +import org.apache.airavata.registry.cpi.RegistryException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ConfigurationResource extends AbstractExpCatResource { + private final static Logger logger = LoggerFactory.getLogger(ConfigurationResource.class); + private String configKey; + private String configVal; + private Timestamp expireDate; + private String categoryID = ConfigurationConstants.CATEGORY_ID_DEFAULT_VALUE; + + public ConfigurationResource() { + } + + /** + * @param configKey configuration key + * @param configVal configuration value + */ + public ConfigurationResource(String configKey, String configVal) { + this.configKey = configKey; + this.configVal = configVal; + } + + /** + * Since Configuration does not depend on any other data structures at the + * system, this method is not valid + * + * @param type child resource types + * @return UnsupportedOperationException + */ + public ExperimentCatResource create(ResourceType type) throws RegistryException { + logger.error("Unsupported operation for configuration resource " + + "since there are no child resources generated by configuration resource.. ", + new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + /** + * Since Configuration does not depend on any other data structures at the + * system, this method is not valid + * + * @param type child resource types + * @param name name of the child resource + * throws UnsupportedOperationException + */ + public void remove(ResourceType type, Object name) throws RegistryException { + logger.error("Unsupported operation for configuration resource " + + "since there are no child resources generated by configuration resource.. ", + new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + + /** + * Since Configuration does not depend on any other data structures at the + * system, this method is not valid + * + * @param type child resource types + * @param name name of the child resource + * @return UnsupportedOperationException + */ + public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException { + logger.error("Unsupported operation for configuration resource " + + "since there are no child resources generated by configuration resource.. ", + new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + /** + * Since Configuration does not depend on any other data structures at the + * system, this method is not valid + * + * @param type child resource types + * @return UnsupportedOperationException + */ + public List<ExperimentCatResource> get(ResourceType type) throws RegistryException { + logger.error("Unsupported operation for configuration resource " + + "since there are no child resources generated by configuration resource.. ", + new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + /** + * @param expireDate expire date of the configuration + */ + public void setExpireDate(Timestamp expireDate) { + this.expireDate = expireDate; + } + + /** + * save configuration to database + */ + public synchronized void save() throws RegistryException { + EntityManager em = null; + try { + em = ExpCatResourceUtils.getEntityManager(); + //whether existing + Configuration existing = em.find(Configuration.class, new Configuration_PK(configKey, configVal, categoryID)); + em.close(); + em = ExpCatResourceUtils.getEntityManager(); + em.getTransaction().begin(); + Configuration configuration = new Configuration(); + configuration.setConfig_key(configKey); + configuration.setConfig_val(configVal); + configuration.setExpire_date(expireDate); + configuration.setCategory_id(categoryID); + if (existing != null) { + existing.setExpire_date(expireDate); + existing.setCategory_id(categoryID); + configuration = em.merge(existing); + } else { + em.persist(configuration); + } + 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(); + } + } + } + + /** + * Since Configuration does not depend on any other data structures at the + * system, this method is not valid + * + * @param type child resource types + * @param name of the child resource + * @return UnsupportedOperationException + */ + public boolean isExists(ResourceType type, Object name) { + logger.error("Unsupported operation for configuration resource " + + "since there are no child resources generated by configuration resource.. ", + new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + /** + * @return configuration value + */ + public String getConfigVal() { + return configVal; + } + + /** + * @param configKey configuration key + */ + public void setConfigKey(String configKey) { + this.configKey = configKey; + } + + /** + * @param configVal configuration value + */ + public void setConfigVal(String configVal) { + this.configVal = configVal; + } + + public String getCategoryID() { + return categoryID; + } + + public void setCategoryID(String categoryID) { + this.categoryID = categoryID; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/DataTransferDetailExperimentCatResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/DataTransferDetailExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/DataTransferDetailExperimentCatResource.java deleted file mode 100644 index 39f4257..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/DataTransferDetailExperimentCatResource.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.registry.core.experiment.catalog.resources; - -import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; -import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource; -import org.apache.airavata.registry.core.experiment.catalog.ResourceType; -import org.apache.airavata.registry.core.experiment.catalog.model.DataTransferDetail; -import org.apache.airavata.registry.core.experiment.catalog.model.Status; -import org.apache.airavata.registry.core.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 DataTransferDetailExperimentCatResource extends AbstractExperimentCatResource { - private static final Logger logger = LoggerFactory.getLogger(DataTransferDetailExperimentCatResource.class); - private String transferId; - private String taskId; - private Timestamp creationTime; - private String transferDescription; - private StatusExperimentCatResource datatransferStatus; - - public StatusExperimentCatResource getDatatransferStatus() { - return datatransferStatus; - } - - public void setDatatransferStatus(StatusExperimentCatResource datatransferStatus) { - this.datatransferStatus = datatransferStatus; - } - - public String getTransferId() { - return transferId; - } - - public void setTransferId(String transferId) { - this.transferId = transferId; - } - - public Timestamp getCreationTime() { - return creationTime; - } - - public void setCreationTime(Timestamp creationTime) { - this.creationTime = creationTime; - } - - public String getTransferDescription() { - return transferDescription; - } - - public void setTransferDescription(String transferDescription) { - this.transferDescription = transferDescription; - } - - public String getTaskId() { - return taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public ExperimentCatResource create(ResourceType type) throws RegistryException { - switch (type){ - case STATUS: - StatusExperimentCatResource statusResource = new StatusExperimentCatResource(); - statusResource.setTransferId(transferId); - return statusResource; - default: - logger.error("Unsupported resource type for data transfer details data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } - - - public void remove(ResourceType type, Object name) throws RegistryException { - EntityManager em = null; - try { - em = ExpCatResourceUtils.getEntityManager(); - em.getTransaction().begin(); - Query q; - QueryGenerator generator; - switch (type) { - case STATUS: - generator = new QueryGenerator(STATUS); - generator.setParameter(StatusConstants.TRANSFER_ID, name); - generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.DATA_TRANSFER); - q = generator.deleteQuery(em); - q.executeUpdate(); - break; - default: - logger.error("Unsupported resource type for data transfer 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{ - EntityManager em = null; - try { - em = ExpCatResourceUtils.getEntityManager(); - em.getTransaction().begin(); - QueryGenerator generator; - Query q; - switch (type) { - case STATUS: - generator = new QueryGenerator(STATUS); - generator.setParameter(StatusConstants.TRANSFER_ID, name); - generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.DATA_TRANSFER); - q = generator.selectQuery(em); - Status status = (Status) q.getSingleResult(); - StatusExperimentCatResource statusResource = (StatusExperimentCatResource) Utils.getResource(ResourceType.STATUS, status); - em.getTransaction().commit(); - em.close(); - return statusResource; - default: - em.getTransaction().commit(); - em.close(); - logger.error("Unsupported resource type for data transfer details resource.", new IllegalArgumentException()); - throw new IllegalArgumentException("Unsupported resource type for data transfer details resource."); - } - } catch (Exception e) { - throw new RegistryException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - - public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{ - List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>(); - EntityManager em = null; - try { - em = ExpCatResourceUtils.getEntityManager(); - em.getTransaction().begin(); - Query q; - QueryGenerator generator; - List results; - switch (type) { - case STATUS: - generator = new QueryGenerator(STATUS); - generator.setParameter(StatusConstants.TRANSFER_ID, transferId); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - Status status = (Status) result; - StatusExperimentCatResource statusResource = - (StatusExperimentCatResource) 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 = ExpCatResourceUtils.getEntityManager(); - DataTransferDetail existingDF = em.find(DataTransferDetail.class, transferId); - em.close(); - - em = ExpCatResourceUtils.getEntityManager(); - em.getTransaction().begin(); - DataTransferDetail dataTransferDetail = new DataTransferDetail(); - dataTransferDetail.setTransferId(transferId); - dataTransferDetail.setTaskId(taskId); - dataTransferDetail.setCreationTime(creationTime); - if (transferDescription != null) { - dataTransferDetail.setTransferDesc(transferDescription.toCharArray()); - } - if (existingDF != null) { - existingDF.setTransferId(transferId); - existingDF.setTaskId(taskId); - existingDF.setCreationTime(creationTime); - if (transferDescription != null) { - existingDF.setTransferDesc(transferDescription.toCharArray()); - } - dataTransferDetail = em.merge(existingDF); - } else { - em.persist(dataTransferDetail); - } - 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 StatusExperimentCatResource getDataTransferStatus () throws RegistryException{ - List<ExperimentCatResource> resources = get(ResourceType.STATUS); - for (ExperimentCatResource resource : resources) { - StatusExperimentCatResource dataTransferStatus = (StatusExperimentCatResource) resource; - if(dataTransferStatus.getStatusType().equals(StatusType.DATA_TRANSFER.toString())){ - if (dataTransferStatus.getState() == null || dataTransferStatus.getState().equals("") ){ - dataTransferStatus.setState("UNKNOWN"); - } - return dataTransferStatus; - } - } - return null; - } -}
