Commit e569205a authored by George Tziavas's avatar George Tziavas
Browse files

Refined JobMapper.java

parent a36e1377
Loading
Loading
Loading
Loading
Loading
+15 −19
Original line number Diff line number Diff line
@@ -20,23 +20,26 @@ public class JobMapper {

        job.setMeasurementCollectionJobRef(UUID.fromString(measurementCollectionJob.getUuid()));

        if(measurementCollectionJob.getDataAccessEndpoint().size()!=1){
        if(measurementCollectionJob.getDataAccessEndpoint().size()!=1){    // DataAccessEndpoint will provide the Monitoring API IP
            throw new IllegalArgumentException("DataAccessEndpoint should be exactly one");
        }else {
            DataAccessEndpoint dataAccessEndpoint = measurementCollectionJob.getDataAccessEndpoint().get(0);
            job.setDataAccessEndPointRef(UUID.fromString(dataAccessEndpoint.getUuid()));
            if(SupportedDataAccessEndpoints.contains(dataAccessEndpoint.getApiType())){

            if (SupportedDataAccessEndpoints.contains(dataAccessEndpoint.getApiType())) {   // SupportedDataAccessEndpoints is an ENUM with all the supported API types
                job.setApiType(dataAccessEndpoint.getApiType());
            } else if (dataAccessEndpoint.getApiType() == null) {
                throw new IllegalArgumentException("API type needs to be defined");
            } else {
                throw new IllegalArgumentException("API type " + dataAccessEndpoint.getApiType() + " not supported");
            }

            if (dataAccessEndpoint.getUri() != null) {
                job.setDataAccessEndPointUri(dataAccessEndpoint.getUri());
            } else {
                throw new IllegalArgumentException("DataAccessEndpointUri cannot be null");
            }
        }

        if(measurementCollectionJob.getJobCollectionFilter().getMappings().size() == 1){
            DataFilterMap query = measurementCollectionJob.getJobCollectionFilter();
@@ -46,17 +49,10 @@ public class JobMapper {
            throw new IllegalArgumentException("There should be exactly one query");
        }

            
        }
        job.setStartDateTime(measurementCollectionJob.getScheduleDefinition().get(0).getScheduleDefinitionStartTime());
        job.setEndDateTime(measurementCollectionJob.getScheduleDefinition().get(0).getScheduleDefinitionEndTime());



      //  job.setStartDateTime(measurementCollectionJob.getReportingPeriod());

        @Valid Granularity granularity = measurementCollectionJob.getGranularity();

        job.setExecutionInterval(convertGranularityToSeconds(measurementCollectionJob.getGranularity().getValue()));
        
        logger.atDebug().setMessage("Received MeasurementCollectionJob:\n" + measurementCollectionJob + "\nConverted it to Job:\n" + job).log();