Search in sources :

Example 1 with ExperimentSummaryModel

use of org.apache.airavata.model.experiment.ExperimentSummaryModel in project airavata by apache.

the class ExperimentRegistry method getExperimentStatistics.

public ExperimentStatistics getExperimentStatistics(Map<String, String> filters) throws RegistryException {
    try {
        ExperimentStatistics experimentStatistics = new ExperimentStatistics();
        ExperimentStatisticsResource experimentStatisticsResource = workerResource.getExperimentStatistics(filters.get(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID), new Timestamp(Long.parseLong(filters.get(Constants.FieldConstants.ExperimentConstants.FROM_DATE))), new Timestamp(Long.parseLong(filters.get(Constants.FieldConstants.ExperimentConstants.TO_DATE))), filters.get(Constants.FieldConstants.ExperimentConstants.USER_NAME), filters.get(Constants.FieldConstants.ExperimentConstants.EXECUTION_ID), filters.get(Constants.FieldConstants.ExperimentConstants.RESOURCE_HOST_ID));
        experimentStatistics.setAllExperimentCount(experimentStatisticsResource.getAllExperimentCount());
        experimentStatistics.setCreatedExperimentCount(experimentStatisticsResource.getCreatedExperimentCount());
        experimentStatistics.setRunningExperimentCount(experimentStatisticsResource.getRunningExperimentCount());
        experimentStatistics.setCompletedExperimentCount(experimentStatisticsResource.getCompletedExperimentCount());
        experimentStatistics.setFailedExperimentCount(experimentStatisticsResource.getFailedExperimentCount());
        experimentStatistics.setCancelledExperimentCount(experimentStatisticsResource.getCancelledExperimentCount());
        ArrayList<ExperimentSummaryModel> experimentSummaries = new ArrayList();
        for (ExperimentSummaryResource ex : experimentStatisticsResource.getAllExperiments()) {
            experimentSummaries.add(ThriftDataModelConversion.getExperimentSummary(ex));
        }
        experimentStatistics.setAllExperiments(experimentSummaries);
        experimentSummaries = new ArrayList();
        for (ExperimentSummaryResource ex : experimentStatisticsResource.getCreatedExperiments()) {
            experimentSummaries.add(ThriftDataModelConversion.getExperimentSummary(ex));
        }
        experimentStatistics.setCreatedExperiments(experimentSummaries);
        experimentSummaries = new ArrayList();
        for (ExperimentSummaryResource ex : experimentStatisticsResource.getRunningExperiments()) {
            experimentSummaries.add(ThriftDataModelConversion.getExperimentSummary(ex));
        }
        experimentStatistics.setRunningExperiments(experimentSummaries);
        experimentSummaries = new ArrayList();
        for (ExperimentSummaryResource ex : experimentStatisticsResource.getCompletedExperiments()) {
            experimentSummaries.add(ThriftDataModelConversion.getExperimentSummary(ex));
        }
        experimentStatistics.setCompletedExperiments(experimentSummaries);
        experimentSummaries = new ArrayList();
        for (ExperimentSummaryResource ex : experimentStatisticsResource.getFailedExperiments()) {
            experimentSummaries.add(ThriftDataModelConversion.getExperimentSummary(ex));
        }
        experimentStatistics.setFailedExperiments(experimentSummaries);
        experimentSummaries = new ArrayList();
        for (ExperimentSummaryResource ex : experimentStatisticsResource.getCancelledExperiments()) {
            experimentSummaries.add(ThriftDataModelConversion.getExperimentSummary(ex));
        }
        experimentStatistics.setCancelledExperiments(experimentSummaries);
        return experimentStatistics;
    } catch (RegistryException e) {
        logger.error("Error while retrieving experiment statistics from registry", e);
        throw new RegistryException(e);
    }
}
Also used : ExperimentSummaryModel(org.apache.airavata.model.experiment.ExperimentSummaryModel) ExperimentStatistics(org.apache.airavata.model.experiment.ExperimentStatistics) Timestamp(java.sql.Timestamp) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 2 with ExperimentSummaryModel

use of org.apache.airavata.model.experiment.ExperimentSummaryModel in project airavata by apache.

the class ExperimentRegistry method searchAllAccessibleExperiments.

public List<ExperimentSummaryModel> searchAllAccessibleExperiments(List<String> accessibleIds, 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(accessibleIds, new Timestamp(fromTime), new Timestamp(toTime), fil, limit, offset, orderByIdentifier, resultOrderType);
            } else {
                experimentSummaryResources = workerResource.searchExperiments(accessibleIds, 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;
}
Also used : ExperimentSummaryModel(org.apache.airavata.model.experiment.ExperimentSummaryModel) Timestamp(java.sql.Timestamp) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 3 with ExperimentSummaryModel

use of org.apache.airavata.model.experiment.ExperimentSummaryModel 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;
}
Also used : ExperimentSummaryModel(org.apache.airavata.model.experiment.ExperimentSummaryModel) Timestamp(java.sql.Timestamp) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 4 with ExperimentSummaryModel

use of org.apache.airavata.model.experiment.ExperimentSummaryModel in project airavata by apache.

the class ThriftDataModelConversion method getExperimentSummary.

public static ExperimentSummaryModel getExperimentSummary(ExperimentSummaryResource experimentSummaryResource) throws RegistryException {
    if (experimentSummaryResource != null) {
        ExperimentSummaryModel experimentSummary = new ExperimentSummaryModel();
        experimentSummary.setProjectId(experimentSummaryResource.getProjectId());
        experimentSummary.setExperimentId(experimentSummaryResource.getExperimentId());
        experimentSummary.setGatewayId(experimentSummaryResource.getGatewayId());
        experimentSummary.setExecutionId(experimentSummaryResource.getExecutionId());
        experimentSummary.setCreationTime(experimentSummaryResource.getCreationTime().getTime());
        experimentSummary.setUserName(experimentSummaryResource.getUserName());
        experimentSummary.setName(experimentSummaryResource.getExperimentName());
        experimentSummary.setDescription(experimentSummaryResource.getDescription());
        experimentSummary.setExperimentStatus(experimentSummaryResource.getState());
        experimentSummary.setResourceHostId(experimentSummaryResource.getResourceHostId());
        return experimentSummary;
    }
    return null;
}
Also used : ExperimentSummaryModel(org.apache.airavata.model.experiment.ExperimentSummaryModel)

Aggregations

ExperimentSummaryModel (org.apache.airavata.model.experiment.ExperimentSummaryModel)4 Timestamp (java.sql.Timestamp)3 RegistryException (org.apache.airavata.registry.cpi.RegistryException)3 ExperimentStatistics (org.apache.airavata.model.experiment.ExperimentStatistics)1