use of org.apache.airavata.registry.core.experiment.catalog.model.ProcessInput in project airavata by apache.
the class ProcessInputResource method save.
public void save() throws RegistryException {
EntityManager em = null;
try {
if (processId == null) {
throw new RegistryException("Does not have the process id");
}
em = ExpCatResourceUtils.getEntityManager();
ProcessInput processInput;
ProcessInputPK processInputPk = new ProcessInputPK();
processInputPk.setProcessId(processId);
processInputPk.setInputName(inputName);
ProcessInput existingProInput = em.find(ProcessInput.class, processInputPk);
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
em = ExpCatResourceUtils.getEntityManager();
em.getTransaction().begin();
if (existingProInput == null) {
processInput = new ProcessInput();
} else {
processInput = existingProInput;
}
processInput.setProcessId(processId);
processInput.setInputName(inputName);
processInput.setInputValue(inputValue);
processInput.setDataType(dataType);
processInput.setApplicationArgument(applicationArgument);
processInput.setStandardInput(standardInput);
processInput.setUserFriendlyDescription(userFriendlyDescription);
processInput.setMetadata(metadata);
processInput.setInputOrder(inputOrder);
processInput.setIsRequired(isRequired);
processInput.setRequiredToAddedToCmd(requiredToAddedToCmd);
processInput.setDataStaged(dataStaged);
processInput.setStorageResourceId(storageResourceId);
processInput.setIsReadOnly(isReadOnly);
if (existingProInput == null) {
em.persist(processInput);
} else {
em.merge(processInput);
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new RegistryException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
Aggregations