diff --git a/src/main/java/org/etsi/osl/metrico/mapper/JobMapper.java b/src/main/java/org/etsi/osl/metrico/mapper/JobMapper.java index 63230d843d30b9dc01cc4bc403fbbf9607331fc1..f2c95a4b1eac3042202f26d23a7647f77c4ea071 100644 --- a/src/main/java/org/etsi/osl/metrico/mapper/JobMapper.java +++ b/src/main/java/org/etsi/osl/metrico/mapper/JobMapper.java @@ -20,45 +20,41 @@ 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 ) { + } else if (dataAccessEndpoint.getApiType() == null) { throw new IllegalArgumentException("API type needs to be defined"); - }else{ + } else { throw new IllegalArgumentException("API type " + dataAccessEndpoint.getApiType() + " not supported"); } - if(dataAccessEndpoint.getUri()!=null){ + + 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(); + if(measurementCollectionJob.getJobCollectionFilter().getMappings().size() == 1){ + DataFilterMap query = measurementCollectionJob.getJobCollectionFilter(); // String stringQuery = measurementCollectionJob.getJobCollectionFilter().getMappings().get(0).getFilterTemplate().getDescription(); - job.setQuery(query); - } else { - throw new IllegalArgumentException("There should be exactly one query"); - } - - + job.setQuery(query); + } else { + 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(); return job; }