use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method searchExperiments.
// CPI Search Methods
public List<ExperimentSummaryModel> searchExperiments(Map<String, String> filters, int limit, int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException {
Map<String, String> fil = new HashMap<String, String>();
if (filters != null && filters.size() != 0) {
List<ExperimentSummaryModel> experimentSummaries = new ArrayList<>();
long fromTime = 0;
long toTime = 0;
try {
for (String field : filters.keySet()) {
if (field.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME)) {
fil.put(AbstractExpCatResource.ExperimentConstants.EXPERIMENT_NAME, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.USER_NAME)) {
fil.put(AbstractExpCatResource.ExperimentConstants.USER_NAME, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.PROJECT_ID)) {
fil.put(AbstractExpCatResource.ExperimentConstants.PROJECT_ID, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID)) {
fil.put(AbstractExpCatResource.ExperimentConstants.GATEWAY_ID, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.DESCRIPTION)) {
fil.put(AbstractExpCatResource.ExperimentConstants.DESCRIPTION, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.EXECUTION_ID)) {
fil.put(AbstractExpCatResource.ExperimentConstants.EXECUTION_ID, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_STATUS)) {
fil.put(AbstractExpCatResource.ExperimentStatusConstants.STATE, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.FROM_DATE)) {
fromTime = Long.parseLong(filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.TO_DATE)) {
toTime = Long.parseLong(filters.get(field));
}
}
List<ExperimentSummaryResource> experimentSummaryResources;
if (fromTime != 0 && toTime != 0) {
experimentSummaryResources = workerResource.searchExperiments(null, new Timestamp(fromTime), new Timestamp(toTime), fil, limit, offset, orderByIdentifier, resultOrderType);
} else {
experimentSummaryResources = workerResource.searchExperiments(null, null, null, fil, limit, offset, orderByIdentifier, resultOrderType);
}
if (experimentSummaryResources != null && !experimentSummaryResources.isEmpty()) {
for (ExperimentSummaryResource ex : experimentSummaryResources) {
experimentSummaries.add(ThriftDataModelConversion.getExperimentSummary(ex));
}
}
return experimentSummaries;
} catch (Exception e) {
logger.error("Error while retrieving experiment summary from registry", e);
throw new RegistryException(e);
}
}
return null;
}
use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method getUserConfigData.
public Object getUserConfigData(String expId, String fieldName) throws RegistryException {
try {
ExperimentResource resource = gatewayResource.getExperiment(expId);
UserConfigurationDataResource userConfigData = resource.getUserConfigurationDataResource();
if (fieldName == null) {
return ThriftDataModelConversion.getUserConfigData(userConfigData);
} else if (fieldName.equals(Constants.FieldConstants.UserConfigurationDataConstants.COMPUTATIONAL_RESOURCE_SCHEDULING)) {
return ThriftDataModelConversion.getComputationalResourceScheduling(userConfigData);
} else {
logger.error("Unsupported field name for experiment configuration data..");
}
} catch (Exception e) {
logger.error("Error while getting config data..", e);
throw new RegistryException(e);
}
return null;
}
use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method getProcessList.
public List<ProcessModel> getProcessList(String fieldName, Object value) throws RegistryException {
List<ProcessModel> processes = new ArrayList<ProcessModel>();
try {
if (fieldName.equals(Constants.FieldConstants.ProcessConstants.EXPERIMENT_ID)) {
ExperimentResource experimentResource = new ExperimentResource();
experimentResource.setExperimentId((String) value);
List<ProcessResource> resources = experimentResource.getProcessList();
for (ProcessResource processResource : resources) {
ProcessModel processModel = ThriftDataModelConversion.getProcessModel(processResource);
processes.add(processModel);
}
return processes;
} else {
logger.error("Unsupported field name to retrieve process list...");
}
} catch (Exception e) {
logger.error("Error while getting process list...", e);
throw new RegistryException(e);
}
return processes;
}
use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method addExperimentError.
public String addExperimentError(ErrorModel experimentError, String expId) throws RegistryException {
try {
ExperimentErrorResource error = new ExperimentErrorResource();
if (experimentError.getErrorId() == null) {
error.setErrorId(AiravataUtils.getId("EXP_ERROR"));
} else {
error.setErrorId(experimentError.getErrorId());
}
error.setExperimentId(expId);
error.setCreationTime(AiravataUtils.getTime(experimentError.getCreationTime()));
error.setActualErrorMessage(experimentError.getActualErrorMessage());
error.setUserFriendlyMessage(experimentError.getUserFriendlyMessage());
error.setTransientOrPersistent(experimentError.isTransientOrPersistent());
if (experimentError.getRootCauseErrorIdList() != null) {
error.setRootCauseErrorIdList(StringUtils.join(experimentError.getRootCauseErrorIdList(), ","));
}
error.save();
} catch (Exception e) {
logger.error(expId, "Error while updating experiment status...", e);
throw new RegistryException(e);
}
return expId;
}
use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method updateProcessInputs.
public void updateProcessInputs(List<InputDataObjectType> processInputs, String processID) throws RegistryException {
try {
ProcessResource processResource = new ProcessResource();
processResource.setProcessId(processID);
List<ProcessInputResource> existingProcessInputs = processResource.getProcessInputs();
for (InputDataObjectType input : processInputs) {
for (ProcessInputResource exinput : existingProcessInputs) {
if (exinput.getInputName().equals(input.getName())) {
exinput.setProcessId(processID);
exinput.setInputValue(input.getValue());
if (input.getType() != null) {
exinput.setDataType(input.getType().toString());
}
exinput.setMetadata(input.getMetaData());
exinput.setApplicationArgument(input.getApplicationArgument());
exinput.setInputOrder(input.getInputOrder());
exinput.setIsRequired(input.isIsRequired());
exinput.setRequiredToAddedToCmd(input.isRequiredToAddedToCommandLine());
exinput.setStorageResourceId(input.getStorageResourceId());
exinput.setIsReadOnly(input.isIsReadOnly());
exinput.save();
}
}
}
} catch (Exception e) {
logger.error("Unable to update experiment inputs", e);
throw new RegistryException(e);
}
}
Aggregations