http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandResource.java new file mode 100644 index 0000000..4cc623b --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandResource.java @@ -0,0 +1,307 @@ +/* + * + * 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.app.catalog.resources; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.persistence.EntityManager; +import javax.persistence.Query; + +import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.apache.airavata.registry.core.app.catalog.model.JobManagerCommand; +import org.apache.airavata.registry.core.app.catalog.model.JobManagerCommand_PK; +import org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType; +import org.apache.airavata.registry.cpi.AppCatalogException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class JobManagerCommandResource extends AppCatAbstractResource { + private final static Logger logger = LoggerFactory.getLogger(JobManagerCommandResource.class); + private String resourceJobManagerId; + private ResourceJobManagerResource resourceJobManagerResource; + private String commandType; + private String command; + + @Override + public void remove(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap<String, String>) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_MANAGER_COMMAND); + generator.setParameter(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID, ids.get(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID)); + generator.setParameter(JobManagerCommandConstants.COMMAND_TYPE, ids.get(JobManagerCommandConstants.COMMAND_TYPE)); + Query q = generator.deleteQuery(em); + q.executeUpdate(); + em.getTransaction().commit(); + em.close(); + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public AppCatalogResource get(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap<String, String>) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_MANAGER_COMMAND); + generator.setParameter(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID, ids.get(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID)); + generator.setParameter(JobManagerCommandConstants.COMMAND_TYPE, ids.get(JobManagerCommandConstants.COMMAND_TYPE)); + Query q = generator.selectQuery(em); + JobManagerCommand jobManagerCommand = (JobManagerCommand) q.getSingleResult(); + JobManagerCommandResource jobManagerCommandResource = (JobManagerCommandResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_MANAGER_COMMAND, jobManagerCommand); + em.getTransaction().commit(); + em.close(); + return jobManagerCommandResource; + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException { + List<AppCatalogResource> jobManagerCommandResources = new ArrayList<AppCatalogResource>(); + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_MANAGER_COMMAND); + Query q; + if ((fieldName.equals(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(JobManagerCommandConstants.COMMAND_TYPE)) || (fieldName.equals(JobManagerCommandConstants.COMMAND))) { + generator.setParameter(fieldName, value); + q = generator.selectQuery(em); + List<?> results = q.getResultList(); + for (Object result : results) { + JobManagerCommand jobManagerCommand = (JobManagerCommand) result; + JobManagerCommandResource jobManagerCommandResource = (JobManagerCommandResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_MANAGER_COMMAND, jobManagerCommand); + jobManagerCommandResources.add(jobManagerCommandResource); + } + } else { + em.getTransaction().commit(); + em.close(); + logger.error("Unsupported field name for Job Manager Command Resource.", new IllegalArgumentException()); + throw new IllegalArgumentException("Unsupported field name for Job Manager Command Resource."); + } + em.getTransaction().commit(); + em.close(); + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return jobManagerCommandResources; + } + + @Override + public List<AppCatalogResource> getAll() throws AppCatalogException { + return null; + } + + @Override + public List<String> getAllIds() throws AppCatalogException { + return null; + } + + @Override + public List<String> getIds(String fieldName, Object value) throws AppCatalogException { + List<String> jobManagerCommandResourceIDs = new ArrayList<String>(); + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_MANAGER_COMMAND); + Query q; + if ((fieldName.equals(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(JobManagerCommandConstants.COMMAND_TYPE)) || (fieldName.equals(JobManagerCommandConstants.COMMAND))) { + generator.setParameter(fieldName, value); + q = generator.selectQuery(em); + List<?> results = q.getResultList(); + for (Object result : results) { + JobManagerCommand jobManagerCommand = (JobManagerCommand) result; + JobManagerCommandResource jobManagerCommandResource = (JobManagerCommandResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_MANAGER_COMMAND, jobManagerCommand); + jobManagerCommandResourceIDs.add(jobManagerCommandResource.getResourceJobManagerId()); + } + } else { + em.getTransaction().commit(); + em.close(); + logger.error("Unsupported field name for Job Manager Command Resource.", new IllegalArgumentException()); + throw new IllegalArgumentException("Unsupported field name for Job Manager Command Resource."); + } + em.getTransaction().commit(); + em.close(); + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return jobManagerCommandResourceIDs; + } + + @Override + public void save() throws AppCatalogException { + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + JobManagerCommand existingJobManagerCommand = em.find(JobManagerCommand.class, new JobManagerCommand_PK(resourceJobManagerId, commandType)); + em.close(); + JobManagerCommand jobManagerCommand; + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + if (existingJobManagerCommand == null) { + jobManagerCommand = new JobManagerCommand(); + } else { + jobManagerCommand = existingJobManagerCommand; + } + jobManagerCommand.setResourceJobManagerId(getResourceJobManagerId()); + ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, getResourceJobManagerId()); + jobManagerCommand.setResourceJobManager(resourceJobManager); + jobManagerCommand.setCommandType(getCommandType()); + jobManagerCommand.setCommand(getCommand()); + if (existingJobManagerCommand == null) { + em.persist(jobManagerCommand); + } else { + em.merge(jobManagerCommand); + } + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public boolean isExists(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap<String, String>) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + JobManagerCommand jobManagerCommand = em.find(JobManagerCommand.class, new JobManagerCommand_PK(ids.get(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID), ids.get(JobManagerCommandConstants.COMMAND_TYPE))); + em.close(); + return jobManagerCommand != null; + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + public String getResourceJobManagerId() { + return resourceJobManagerId; + } + + public ResourceJobManagerResource getResourceJobManagerResource() { + return resourceJobManagerResource; + } + + public String getCommandType() { + return commandType; + } + + public String getCommand() { + return command; + } + + public void setResourceJobManagerId(String resourceJobManagerId) { + this.resourceJobManagerId=resourceJobManagerId; + } + + public void setResourceJobManagerResource(ResourceJobManagerResource resourceJobManagerResource) { + this.resourceJobManagerResource=resourceJobManagerResource; + } + + public void setCommandType(String commandType) { + this.commandType=commandType; + } + + public void setCommand(String command) { + this.command=command; + } +}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceAppCatalogResourceAppCat.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceAppCatalogResourceAppCat.java deleted file mode 100644 index ab34dff..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceAppCatalogResourceAppCat.java +++ /dev/null @@ -1,339 +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.app.catalog.resources; - -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.persistence.EntityManager; -import javax.persistence.Query; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.common.utils.AiravataUtils; -import org.apache.airavata.registry.core.app.catalog.model.ComputeResource; -import org.apache.airavata.registry.core.app.catalog.model.JobSubmissionInterface; -import org.apache.airavata.registry.core.app.catalog.model.JobSubmissionInterface_PK; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType; -import org.apache.airavata.registry.cpi.AppCatalogException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class JobSubmissionInterfaceAppCatalogResourceAppCat extends AppCatAbstractResource { - private final static Logger logger = LoggerFactory.getLogger(JobSubmissionInterfaceAppCatalogResourceAppCat.class); - private String jobSubmissionInterfaceId; - private String computeResourceId; - private ComputeResourceAppCatalogResourceAppCat computeHostResource; - private String jobSubmissionProtocol; - private int priorityOrder; - private Timestamp createdTime; - private Timestamp updatedTime; - - public Timestamp getCreatedTime() { - return createdTime; - } - - public void setCreatedTime(Timestamp createdTime) { - this.createdTime = createdTime; - } - - public Timestamp getUpdatedTime() { - return updatedTime; - } - - public void setUpdatedTime(Timestamp updatedTime) { - this.updatedTime = updatedTime; - } - - @Override - public void remove(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map) { - ids = (HashMap<String, String>) identifier; - } else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE); - generator.setParameter(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID, ids.get(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID)); - generator.setParameter(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID, ids.get(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)); - Query q = generator.deleteQuery(em); - q.executeUpdate(); - em.getTransaction().commit(); - em.close(); - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public AppCatalogResource get(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map) { - ids = (HashMap<String, String>) identifier; - } else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE); - generator.setParameter(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID, ids.get(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID)); - generator.setParameter(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID, ids.get(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)); - Query q = generator.selectQuery(em); - JobSubmissionInterface jobSubmissionInterface = (JobSubmissionInterface) q.getSingleResult(); - JobSubmissionInterfaceAppCatalogResourceAppCat jobSubmissionInterfaceResource = (JobSubmissionInterfaceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_SUBMISSION_INTERFACE, jobSubmissionInterface); - em.getTransaction().commit(); - em.close(); - return jobSubmissionInterfaceResource; - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException { - List<AppCatalogResource> jobSubmissionInterfaceResources = new ArrayList<AppCatalogResource>(); - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE); - Query q; - if ((fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_PROTOCOL)) || (fieldName.equals(JobSubmissionInterfaceConstants.PRIORITY_ORDER))) { - generator.setParameter(fieldName, value); - q = generator.selectQuery(em); - List<?> results = q.getResultList(); - for (Object result : results) { - JobSubmissionInterface jobSubmissionInterface = (JobSubmissionInterface) result; - JobSubmissionInterfaceAppCatalogResourceAppCat jobSubmissionInterfaceResource = (JobSubmissionInterfaceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_SUBMISSION_INTERFACE, jobSubmissionInterface); - jobSubmissionInterfaceResources.add(jobSubmissionInterfaceResource); - } - } else { - em.getTransaction().commit(); - em.close(); - logger.error("Unsupported field name for Job Submission Interface Resource.", new IllegalArgumentException()); - throw new IllegalArgumentException("Unsupported field name for Job Submission Interface Resource."); - } - em.getTransaction().commit(); - em.close(); - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return jobSubmissionInterfaceResources; - } - - @Override - public List<AppCatalogResource> getAll() throws AppCatalogException { - return null; - } - - @Override - public List<String> getAllIds() throws AppCatalogException { - return null; - } - - @Override - public List<String> getIds(String fieldName, Object value) throws AppCatalogException { - List<String> jobSubmissionInterfaceResourceIDs = new ArrayList<String>(); - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE); - Query q; - if ((fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_PROTOCOL)) || (fieldName.equals(JobSubmissionInterfaceConstants.PRIORITY_ORDER))) { - generator.setParameter(fieldName, value); - q = generator.selectQuery(em); - List<?> results = q.getResultList(); - for (Object result : results) { - JobSubmissionInterface jobSubmissionInterface = (JobSubmissionInterface) result; - JobSubmissionInterfaceAppCatalogResourceAppCat jobSubmissionInterfaceResource = (JobSubmissionInterfaceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_SUBMISSION_INTERFACE, jobSubmissionInterface); - jobSubmissionInterfaceResourceIDs.add(jobSubmissionInterfaceResource.getComputeResourceId()); - } - } else { - em.getTransaction().commit(); - em.close(); - logger.error("Unsupported field name for Job Submission Interface Resource.", new IllegalArgumentException()); - throw new IllegalArgumentException("Unsupported field name for Job Submission Interface Resource."); - } - em.getTransaction().commit(); - em.close(); - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return jobSubmissionInterfaceResourceIDs; - } - - @Override - public void save() throws AppCatalogException { - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - JobSubmissionInterface existingJobSubmissionInterface = em.find(JobSubmissionInterface.class, new JobSubmissionInterface_PK(jobSubmissionInterfaceId, computeResourceId)); - em.close(); - JobSubmissionInterface jobSubmissionInterface; - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - if (existingJobSubmissionInterface == null) { - jobSubmissionInterface = new JobSubmissionInterface(); - jobSubmissionInterface.setCreationTime(AiravataUtils.getCurrentTimestamp()); - } else { - jobSubmissionInterface = existingJobSubmissionInterface; - jobSubmissionInterface.setUpdateTime(AiravataUtils.getCurrentTimestamp()); - } - jobSubmissionInterface.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId()); - jobSubmissionInterface.setComputeResourceId(getComputeResourceId()); - ComputeResource computeResource = em.find(ComputeResource.class, getComputeResourceId()); - jobSubmissionInterface.setComputeResource(computeResource); - jobSubmissionInterface.setJobSubmissionProtocol(getJobSubmissionProtocol()); - jobSubmissionInterface.setPriorityOrder(getPriorityOrder()); - if (existingJobSubmissionInterface == null) { - em.persist(jobSubmissionInterface); - } else { - em.merge(jobSubmissionInterface); - } - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public boolean isExists(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map) { - ids = (HashMap<String, String>) identifier; - } else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - JobSubmissionInterface jobSubmissionInterface = em.find(JobSubmissionInterface.class, new JobSubmissionInterface_PK(ids.get(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID), ids.get(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID))); - em.close(); - return jobSubmissionInterface != null; - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - public String getJobSubmissionInterfaceId() { - return jobSubmissionInterfaceId; - } - - public String getComputeResourceId() { - return computeResourceId; - } - - public ComputeResourceAppCatalogResourceAppCat getComputeHostResource() { - return computeHostResource; - } - - public String getJobSubmissionProtocol() { - return jobSubmissionProtocol; - } - - public int getPriorityOrder() { - return priorityOrder; - } - - public void setJobSubmissionInterfaceId(String jobSubmissionInterfaceId) { - this.jobSubmissionInterfaceId=jobSubmissionInterfaceId; - } - - public void setComputeResourceId(String computeResourceId) { - this.computeResourceId=computeResourceId; - } - - public void setComputeHostResource(ComputeResourceAppCatalogResourceAppCat computeHostResource) { - this.computeHostResource=computeHostResource; - } - - public void setJobSubmissionProtocol(String jobSubmissionProtocol) { - this.jobSubmissionProtocol=jobSubmissionProtocol; - } - - public void setPriorityOrder(int priorityOrder) { - this.priorityOrder=priorityOrder; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceResource.java new file mode 100644 index 0000000..a8df941 --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceResource.java @@ -0,0 +1,339 @@ +/* + * + * 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.app.catalog.resources; + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.persistence.EntityManager; +import javax.persistence.Query; + +import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.apache.airavata.common.utils.AiravataUtils; +import org.apache.airavata.registry.core.app.catalog.model.ComputeResource; +import org.apache.airavata.registry.core.app.catalog.model.JobSubmissionInterface; +import org.apache.airavata.registry.core.app.catalog.model.JobSubmissionInterface_PK; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType; +import org.apache.airavata.registry.cpi.AppCatalogException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class JobSubmissionInterfaceResource extends AppCatAbstractResource { + private final static Logger logger = LoggerFactory.getLogger(JobSubmissionInterfaceResource.class); + private String jobSubmissionInterfaceId; + private String computeResourceId; + private ComputeResourceResource computeHostResource; + private String jobSubmissionProtocol; + private int priorityOrder; + private Timestamp createdTime; + private Timestamp updatedTime; + + public Timestamp getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(Timestamp createdTime) { + this.createdTime = createdTime; + } + + public Timestamp getUpdatedTime() { + return updatedTime; + } + + public void setUpdatedTime(Timestamp updatedTime) { + this.updatedTime = updatedTime; + } + + @Override + public void remove(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap<String, String>) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE); + generator.setParameter(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID, ids.get(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID)); + generator.setParameter(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID, ids.get(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)); + Query q = generator.deleteQuery(em); + q.executeUpdate(); + em.getTransaction().commit(); + em.close(); + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public AppCatalogResource get(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap<String, String>) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE); + generator.setParameter(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID, ids.get(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID)); + generator.setParameter(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID, ids.get(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)); + Query q = generator.selectQuery(em); + JobSubmissionInterface jobSubmissionInterface = (JobSubmissionInterface) q.getSingleResult(); + JobSubmissionInterfaceResource jobSubmissionInterfaceResource = (JobSubmissionInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_SUBMISSION_INTERFACE, jobSubmissionInterface); + em.getTransaction().commit(); + em.close(); + return jobSubmissionInterfaceResource; + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException { + List<AppCatalogResource> jobSubmissionInterfaceResources = new ArrayList<AppCatalogResource>(); + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE); + Query q; + if ((fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_PROTOCOL)) || (fieldName.equals(JobSubmissionInterfaceConstants.PRIORITY_ORDER))) { + generator.setParameter(fieldName, value); + q = generator.selectQuery(em); + List<?> results = q.getResultList(); + for (Object result : results) { + JobSubmissionInterface jobSubmissionInterface = (JobSubmissionInterface) result; + JobSubmissionInterfaceResource jobSubmissionInterfaceResource = (JobSubmissionInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_SUBMISSION_INTERFACE, jobSubmissionInterface); + jobSubmissionInterfaceResources.add(jobSubmissionInterfaceResource); + } + } else { + em.getTransaction().commit(); + em.close(); + logger.error("Unsupported field name for Job Submission Interface Resource.", new IllegalArgumentException()); + throw new IllegalArgumentException("Unsupported field name for Job Submission Interface Resource."); + } + em.getTransaction().commit(); + em.close(); + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return jobSubmissionInterfaceResources; + } + + @Override + public List<AppCatalogResource> getAll() throws AppCatalogException { + return null; + } + + @Override + public List<String> getAllIds() throws AppCatalogException { + return null; + } + + @Override + public List<String> getIds(String fieldName, Object value) throws AppCatalogException { + List<String> jobSubmissionInterfaceResourceIDs = new ArrayList<String>(); + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE); + Query q; + if ((fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_PROTOCOL)) || (fieldName.equals(JobSubmissionInterfaceConstants.PRIORITY_ORDER))) { + generator.setParameter(fieldName, value); + q = generator.selectQuery(em); + List<?> results = q.getResultList(); + for (Object result : results) { + JobSubmissionInterface jobSubmissionInterface = (JobSubmissionInterface) result; + JobSubmissionInterfaceResource jobSubmissionInterfaceResource = (JobSubmissionInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_SUBMISSION_INTERFACE, jobSubmissionInterface); + jobSubmissionInterfaceResourceIDs.add(jobSubmissionInterfaceResource.getComputeResourceId()); + } + } else { + em.getTransaction().commit(); + em.close(); + logger.error("Unsupported field name for Job Submission Interface Resource.", new IllegalArgumentException()); + throw new IllegalArgumentException("Unsupported field name for Job Submission Interface Resource."); + } + em.getTransaction().commit(); + em.close(); + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return jobSubmissionInterfaceResourceIDs; + } + + @Override + public void save() throws AppCatalogException { + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + JobSubmissionInterface existingJobSubmissionInterface = em.find(JobSubmissionInterface.class, new JobSubmissionInterface_PK(jobSubmissionInterfaceId, computeResourceId)); + em.close(); + JobSubmissionInterface jobSubmissionInterface; + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + if (existingJobSubmissionInterface == null) { + jobSubmissionInterface = new JobSubmissionInterface(); + jobSubmissionInterface.setCreationTime(AiravataUtils.getCurrentTimestamp()); + } else { + jobSubmissionInterface = existingJobSubmissionInterface; + jobSubmissionInterface.setUpdateTime(AiravataUtils.getCurrentTimestamp()); + } + jobSubmissionInterface.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId()); + jobSubmissionInterface.setComputeResourceId(getComputeResourceId()); + ComputeResource computeResource = em.find(ComputeResource.class, getComputeResourceId()); + jobSubmissionInterface.setComputeResource(computeResource); + jobSubmissionInterface.setJobSubmissionProtocol(getJobSubmissionProtocol()); + jobSubmissionInterface.setPriorityOrder(getPriorityOrder()); + if (existingJobSubmissionInterface == null) { + em.persist(jobSubmissionInterface); + } else { + em.merge(jobSubmissionInterface); + } + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public boolean isExists(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap<String, String>) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + JobSubmissionInterface jobSubmissionInterface = em.find(JobSubmissionInterface.class, new JobSubmissionInterface_PK(ids.get(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID), ids.get(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID))); + em.close(); + return jobSubmissionInterface != null; + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + public String getJobSubmissionInterfaceId() { + return jobSubmissionInterfaceId; + } + + public String getComputeResourceId() { + return computeResourceId; + } + + public ComputeResourceResource getComputeHostResource() { + return computeHostResource; + } + + public String getJobSubmissionProtocol() { + return jobSubmissionProtocol; + } + + public int getPriorityOrder() { + return priorityOrder; + } + + public void setJobSubmissionInterfaceId(String jobSubmissionInterfaceId) { + this.jobSubmissionInterfaceId=jobSubmissionInterfaceId; + } + + public void setComputeResourceId(String computeResourceId) { + this.computeResourceId=computeResourceId; + } + + public void setComputeHostResource(ComputeResourceResource computeHostResource) { + this.computeHostResource=computeHostResource; + } + + public void setJobSubmissionProtocol(String jobSubmissionProtocol) { + this.jobSubmissionProtocol=jobSubmissionProtocol; + } + + public void setPriorityOrder(int priorityOrder) { + this.priorityOrder=priorityOrder; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathAppCatalogResourceAppCat.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathAppCatalogResourceAppCat.java deleted file mode 100644 index e7e83ce..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathAppCatalogResourceAppCat.java +++ /dev/null @@ -1,292 +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.app.catalog.resources; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment; -import org.apache.airavata.registry.core.app.catalog.model.LibraryApendPath; -import org.apache.airavata.registry.core.app.catalog.model.LibraryApendPath_PK; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType; -import org.apache.airavata.registry.cpi.AppCatalogException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.EntityManager; -import javax.persistence.Query; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class LibraryApendPathAppCatalogResourceAppCat extends AppCatAbstractResource { - private final static Logger logger = LoggerFactory.getLogger(LibraryApendPathAppCatalogResourceAppCat.class); - private String deploymentId; - private String name; - private String value; - private AppDeploymentAppCatalogResourceAppCat appDeploymentResource; - - public String getDeploymentId() { - return deploymentId; - } - - public void setDeploymentId(String deploymentId) { - this.deploymentId = deploymentId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public AppDeploymentAppCatalogResourceAppCat getAppDeploymentResource() { - return appDeploymentResource; - } - - public void setAppDeploymentResource(AppDeploymentAppCatalogResourceAppCat appDeploymentResource) { - this.appDeploymentResource = appDeploymentResource; - } - - @Override - public void remove(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map){ - ids = (HashMap)identifier; - }else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(LIBRARY_APEND_PATH); - generator.setParameter(LibraryApendPathConstants.DEPLOYMENT_ID, ids.get(LibraryApendPathConstants.DEPLOYMENT_ID)); - if (ids.get(LibraryApendPathConstants.NAME) != null){ - generator.setParameter(LibraryApendPathConstants.NAME, ids.get(LibraryApendPathConstants.NAME)); - } - Query q = generator.deleteQuery(em); - q.executeUpdate(); - em.getTransaction().commit(); - em.close(); - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public AppCatalogResource get(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map){ - ids = (HashMap)identifier; - }else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_APEND_PATH); - generator.setParameter(LibraryApendPathConstants.DEPLOYMENT_ID, ids.get(LibraryApendPathConstants.DEPLOYMENT_ID)); - generator.setParameter(LibraryApendPathConstants.NAME, ids.get(LibraryApendPathConstants.NAME)); - Query q = generator.selectQuery(em); - LibraryApendPath libraryApendPath = (LibraryApendPath) q.getSingleResult(); - LibraryApendPathAppCatalogResourceAppCat resource = - (LibraryApendPathAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_APEND_PATH, libraryApendPath); - em.getTransaction().commit(); - em.close(); - return resource; - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException { - List<AppCatalogResource> libApPathList = new ArrayList<AppCatalogResource>(); - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - Query q; - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_APEND_PATH); - List results; - if (fieldName.equals(LibraryApendPathConstants.DEPLOYMENT_ID)) { - generator.setParameter(LibraryApendPathConstants.DEPLOYMENT_ID, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - LibraryApendPath prepandPath = (LibraryApendPath) result; - LibraryApendPathAppCatalogResourceAppCat resource = - (LibraryApendPathAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_APEND_PATH, prepandPath); - libApPathList.add(resource); - } - } - } else if (fieldName.equals(LibraryApendPathConstants.NAME)) { - generator.setParameter(LibraryApendPathConstants.NAME, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - LibraryApendPath prepandPath = (LibraryApendPath) result; - LibraryApendPathAppCatalogResourceAppCat resource = - (LibraryApendPathAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_APEND_PATH, prepandPath); - libApPathList.add(resource); - } - } - }else { - em.getTransaction().commit(); - em.close(); - logger.error("Unsupported field name for libraryApendPath resource.", new IllegalArgumentException()); - throw new IllegalArgumentException("Unsupported field name for libraryApendPath resource."); - } - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return libApPathList; - } - - @Override - public List<AppCatalogResource> getAll() throws AppCatalogException { - return null; - } - - @Override - public List<String> getAllIds() throws AppCatalogException { - return null; - } - - @Override - public List<String> getIds(String fieldName, Object value) throws AppCatalogException { - logger.error("Unsupported for objects with a composite identifier"); - throw new AppCatalogException("Unsupported for objects with a composite identifier"); - } - - @Override - public void save() throws AppCatalogException { - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - LibraryApendPath existigApendPath = em.find(LibraryApendPath.class, new LibraryApendPath_PK(deploymentId, name)); - em.close(); - - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - - ApplicationDeployment deployment = em.find(ApplicationDeployment.class, deploymentId); - if (existigApendPath != null){ - existigApendPath.setValue(value); - existigApendPath.setApplicationDeployment(deployment); - em.merge(existigApendPath); - }else { - LibraryApendPath apendPath = new LibraryApendPath(); - apendPath.setDeploymentID(deploymentId); - apendPath.setName(name); - apendPath.setValue(value); - apendPath.setApplicationDeployment(deployment); - em.persist(apendPath); - } - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public boolean isExists(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map){ - ids = (HashMap)identifier; - }else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - LibraryApendPath apendPath = em.find(LibraryApendPath.class, - new LibraryApendPath_PK(ids.get(LibraryApendPathConstants.DEPLOYMENT_ID), - ids.get(LibraryApendPathConstants.NAME))); - em.close(); - return apendPath != null; - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathResource.java new file mode 100644 index 0000000..0949f20 --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathResource.java @@ -0,0 +1,292 @@ +/* + * + * 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.app.catalog.resources; + +import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment; +import org.apache.airavata.registry.core.app.catalog.model.LibraryApendPath; +import org.apache.airavata.registry.core.app.catalog.model.LibraryApendPath_PK; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType; +import org.apache.airavata.registry.cpi.AppCatalogException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.EntityManager; +import javax.persistence.Query; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class LibraryApendPathResource extends AppCatAbstractResource { + private final static Logger logger = LoggerFactory.getLogger(LibraryApendPathResource.class); + private String deploymentId; + private String name; + private String value; + private AppDeploymentResource appDeploymentResource; + + public String getDeploymentId() { + return deploymentId; + } + + public void setDeploymentId(String deploymentId) { + this.deploymentId = deploymentId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public AppDeploymentResource getAppDeploymentResource() { + return appDeploymentResource; + } + + public void setAppDeploymentResource(AppDeploymentResource appDeploymentResource) { + this.appDeploymentResource = appDeploymentResource; + } + + @Override + public void remove(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map){ + ids = (HashMap)identifier; + }else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(LIBRARY_APEND_PATH); + generator.setParameter(LibraryApendPathConstants.DEPLOYMENT_ID, ids.get(LibraryApendPathConstants.DEPLOYMENT_ID)); + if (ids.get(LibraryApendPathConstants.NAME) != null){ + generator.setParameter(LibraryApendPathConstants.NAME, ids.get(LibraryApendPathConstants.NAME)); + } + Query q = generator.deleteQuery(em); + q.executeUpdate(); + em.getTransaction().commit(); + em.close(); + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public AppCatalogResource get(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map){ + ids = (HashMap)identifier; + }else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_APEND_PATH); + generator.setParameter(LibraryApendPathConstants.DEPLOYMENT_ID, ids.get(LibraryApendPathConstants.DEPLOYMENT_ID)); + generator.setParameter(LibraryApendPathConstants.NAME, ids.get(LibraryApendPathConstants.NAME)); + Query q = generator.selectQuery(em); + LibraryApendPath libraryApendPath = (LibraryApendPath) q.getSingleResult(); + LibraryApendPathResource resource = + (LibraryApendPathResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_APEND_PATH, libraryApendPath); + em.getTransaction().commit(); + em.close(); + return resource; + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException { + List<AppCatalogResource> libApPathList = new ArrayList<AppCatalogResource>(); + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + Query q; + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_APEND_PATH); + List results; + if (fieldName.equals(LibraryApendPathConstants.DEPLOYMENT_ID)) { + generator.setParameter(LibraryApendPathConstants.DEPLOYMENT_ID, value); + q = generator.selectQuery(em); + results = q.getResultList(); + if (results.size() != 0) { + for (Object result : results) { + LibraryApendPath prepandPath = (LibraryApendPath) result; + LibraryApendPathResource resource = + (LibraryApendPathResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_APEND_PATH, prepandPath); + libApPathList.add(resource); + } + } + } else if (fieldName.equals(LibraryApendPathConstants.NAME)) { + generator.setParameter(LibraryApendPathConstants.NAME, value); + q = generator.selectQuery(em); + results = q.getResultList(); + if (results.size() != 0) { + for (Object result : results) { + LibraryApendPath prepandPath = (LibraryApendPath) result; + LibraryApendPathResource resource = + (LibraryApendPathResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_APEND_PATH, prepandPath); + libApPathList.add(resource); + } + } + }else { + em.getTransaction().commit(); + em.close(); + logger.error("Unsupported field name for libraryApendPath resource.", new IllegalArgumentException()); + throw new IllegalArgumentException("Unsupported field name for libraryApendPath resource."); + } + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return libApPathList; + } + + @Override + public List<AppCatalogResource> getAll() throws AppCatalogException { + return null; + } + + @Override + public List<String> getAllIds() throws AppCatalogException { + return null; + } + + @Override + public List<String> getIds(String fieldName, Object value) throws AppCatalogException { + logger.error("Unsupported for objects with a composite identifier"); + throw new AppCatalogException("Unsupported for objects with a composite identifier"); + } + + @Override + public void save() throws AppCatalogException { + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + LibraryApendPath existigApendPath = em.find(LibraryApendPath.class, new LibraryApendPath_PK(deploymentId, name)); + em.close(); + + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + + ApplicationDeployment deployment = em.find(ApplicationDeployment.class, deploymentId); + if (existigApendPath != null){ + existigApendPath.setValue(value); + existigApendPath.setApplicationDeployment(deployment); + em.merge(existigApendPath); + }else { + LibraryApendPath apendPath = new LibraryApendPath(); + apendPath.setDeploymentID(deploymentId); + apendPath.setName(name); + apendPath.setValue(value); + apendPath.setApplicationDeployment(deployment); + em.persist(apendPath); + } + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public boolean isExists(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map){ + ids = (HashMap)identifier; + }else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + LibraryApendPath apendPath = em.find(LibraryApendPath.class, + new LibraryApendPath_PK(ids.get(LibraryApendPathConstants.DEPLOYMENT_ID), + ids.get(LibraryApendPathConstants.NAME))); + em.close(); + return apendPath != null; + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()){ + em.getTransaction().rollback(); + } + em.close(); + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathAppCatalogResourceAppCat.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathAppCatalogResourceAppCat.java deleted file mode 100644 index 799b0b3..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathAppCatalogResourceAppCat.java +++ /dev/null @@ -1,291 +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.app.catalog.resources; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment; -import org.apache.airavata.registry.core.app.catalog.model.LibraryPrepandPath; -import org.apache.airavata.registry.core.app.catalog.model.LibraryPrepandPath_PK; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType; -import org.apache.airavata.registry.cpi.AppCatalogException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.EntityManager; -import javax.persistence.Query; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class LibraryPrepandPathAppCatalogResourceAppCat extends AppCatAbstractResource { - private final static Logger logger = LoggerFactory.getLogger(LibraryPrepandPathAppCatalogResourceAppCat.class); - private String deploymentId; - private String name; - private String value; - private AppDeploymentAppCatalogResourceAppCat appDeploymentResource; - - public String getDeploymentId() { - return deploymentId; - } - - public void setDeploymentId(String deploymentId) { - this.deploymentId = deploymentId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public AppDeploymentAppCatalogResourceAppCat getAppDeploymentResource() { - return appDeploymentResource; - } - - public void setAppDeploymentResource(AppDeploymentAppCatalogResourceAppCat appDeploymentResource) { - this.appDeploymentResource = appDeploymentResource; - } - - @Override - public void remove(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map){ - ids = (HashMap)identifier; - }else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(LIBRARY_PREPAND_PATH); - generator.setParameter(LibraryPrepandPathConstants.DEPLOYMENT_ID, ids.get(LibraryPrepandPathConstants.DEPLOYMENT_ID)); - if (ids.get(LibraryPrepandPathConstants.NAME) != null){ - generator.setParameter(LibraryPrepandPathConstants.NAME, ids.get(LibraryPrepandPathConstants.NAME)); - } - Query q = generator.deleteQuery(em); - q.executeUpdate(); - em.getTransaction().commit(); - em.close(); - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public AppCatalogResource get(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map){ - ids = (HashMap)identifier; - }else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_PREPAND_PATH); - generator.setParameter(LibraryPrepandPathConstants.DEPLOYMENT_ID, ids.get(LibraryPrepandPathConstants.DEPLOYMENT_ID)); - generator.setParameter(LibraryPrepandPathConstants.NAME, ids.get(LibraryPrepandPathConstants.NAME)); - Query q = generator.selectQuery(em); - LibraryPrepandPath libraryPrepandPath = (LibraryPrepandPath) q.getSingleResult(); - LibraryPrepandPathAppCatalogResourceAppCat resource = - (LibraryPrepandPathAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_PREPAND_PATH, libraryPrepandPath); - em.getTransaction().commit(); - em.close(); - return resource; - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException { - List<AppCatalogResource> libPrepPathList = new ArrayList<AppCatalogResource>(); - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - Query q; - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_PREPAND_PATH); - List results; - if (fieldName.equals(LibraryPrepandPathConstants.DEPLOYMENT_ID)) { - generator.setParameter(LibraryPrepandPathConstants.DEPLOYMENT_ID, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - LibraryPrepandPath prepandPath = (LibraryPrepandPath) result; - LibraryPrepandPathAppCatalogResourceAppCat resource = - (LibraryPrepandPathAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_PREPAND_PATH, prepandPath); - libPrepPathList.add(resource); - } - } - } else if (fieldName.equals(LibraryPrepandPathConstants.NAME)) { - generator.setParameter(LibraryPrepandPathConstants.NAME, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - LibraryPrepandPath prepandPath = (LibraryPrepandPath) result; - LibraryPrepandPathAppCatalogResourceAppCat resource = - (LibraryPrepandPathAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_PREPAND_PATH, prepandPath); - libPrepPathList.add(resource); - } - } - }else { - em.getTransaction().commit(); - em.close(); - logger.error("Unsupported field name for libraryPrepandPath resource.", new IllegalArgumentException()); - throw new IllegalArgumentException("Unsupported field name for libraryPrepandPath resource."); - } - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return libPrepPathList; - } - - @Override - public List<AppCatalogResource> getAll() throws AppCatalogException { - return null; - } - - @Override - public List<String> getAllIds() throws AppCatalogException { - return null; - } - - @Override - public List<String> getIds(String fieldName, Object value) throws AppCatalogException { - logger.error("Unsupported for objects with a composite identifier"); - throw new AppCatalogException("Unsupported for objects with a composite identifier"); - } - - @Override - public void save() throws AppCatalogException { - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - LibraryPrepandPath existigPrepPath = em.find(LibraryPrepandPath.class, new LibraryPrepandPath_PK(deploymentId, name)); - em.close(); - - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - ApplicationDeployment deployment = em.find(ApplicationDeployment.class, deploymentId); - if (existigPrepPath != null){ - existigPrepPath.setValue(value); - existigPrepPath.setApplicationDeployment(deployment); - em.merge(existigPrepPath); - }else { - LibraryPrepandPath prepandPath = new LibraryPrepandPath(); - prepandPath.setDeploymentID(deploymentId); - prepandPath.setName(name); - prepandPath.setValue(value); - prepandPath.setApplicationDeployment(deployment); - em.persist(prepandPath); - } - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public boolean isExists(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map){ - ids = (HashMap)identifier; - }else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - LibraryPrepandPath prepandPath = em.find(LibraryPrepandPath.class, - new LibraryPrepandPath_PK(ids.get(LibraryPrepandPathConstants.DEPLOYMENT_ID), - ids.get(LibraryPrepandPathConstants.NAME))); - em.close(); - return prepandPath != null; - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } - } -}
