diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java index 5aeac40e7a92eb8fcc4b1b984e01b0cdc1ecc3d5..d2ee32a5c4218e3b0723796d2272ce9622702d61 100644 --- a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java @@ -141,32 +141,43 @@ public class MetricoOrchestrationService implements JavaDelegate { dataAccessEndpoints.add(dataAccessEndpoint); mcjFVO.setDataAccessEndpoint(dataAccessEndpoints); - MeasurementCollectionJob mcj = serviceOrderManager.addMeasurementCollectionJob(mcjFVO); - - if (mcj != null){ - - ResourceSpecificationRef resourceSpecificationRef = spec.getResourceSpecification().stream().findFirst().get(); - Resource resourceMT = createRelatedResource( resourceSpecificationRef, sorder, aService, mcj ); - ResourceRef resourceRef = new ResourceRef(); - - resourceRef.setId( resourceMT.getId() ); - resourceRef.setName( resourceMT.getName()); - resourceRef.setType( resourceMT.getType()); - su.addSupportingResourceItem( resourceRef ); - su.setState(ServiceStateType.RESERVED); - Note successNoteItem = new Note(); - successNoteItem.setText(String.format("Requesting METRICO to create a new monitoring job")); - successNoteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); - successNoteItem.setAuthor(compname); - su.addNoteItem(successNoteItem); - - } else { - logger.error("Measurement Collection Job was not created."); - su.setState(ServiceStateType.TERMINATED); - } - - Service supd = serviceOrderManager.updateService(aService.getId(), su, false); + ResourceSpecificationRef resourceSpecificationRef = spec.getResourceSpecification().stream().findFirst().get(); + Resource resourceMT = createRelatedResource( resourceSpecificationRef, sorder, aService ); + ResourceRef resourceRef = new ResourceRef(); + + resourceRef.setId( resourceMT.getId() ); + resourceRef.setName( resourceMT.getName()); + resourceRef.setType( resourceMT.getType()); + su.addSupportingResourceItem( resourceRef ); + su.setState(ServiceStateType.RESERVED); + Note successNoteItem = new Note(); + successNoteItem.setText(String.format("Requesting METRICO to create a new monitoring job")); + successNoteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + successNoteItem.setAuthor(compname); + su.addNoteItem(successNoteItem); + + Service supd = serviceOrderManager.updateService(aService.getId(), su, false);//we nned first to create this in the db + + su = new ServiceUpdate();// the object to update the service + MeasurementCollectionJob mcj = serviceOrderManager.addMeasurementCollectionJob(mcjFVO); + if (mcj != null){ + logger.info("Measurement Collection Job was not created."); + + serviceCharacteristic = new Characteristic(); + serviceCharacteristic.setName( "_MT_MCJ_REFID" ); + serviceCharacteristic.setValueType( "TEXT" ); + Any val = new Any(); + val.setValue( mcj.getUuid() ); + val.setAlias( "" ); + serviceCharacteristic.setValue(val); + su.addServiceCharacteristicItem(serviceCharacteristic); + + } else { + logger.error("Measurement Collection Job was not created."); + su.setState(ServiceStateType.TERMINATED); + } + supd = serviceOrderManager.updateService(aService.getId(), su, false);//we nned first to create this in the db } @@ -233,7 +244,7 @@ public class MetricoOrchestrationService implements JavaDelegate { * @param aService * @return */ - private Resource createRelatedResource(ResourceSpecificationRef rSpecRef, ServiceOrder sOrder, Service aService, MeasurementCollectionJob mcj) { + private Resource createRelatedResource(ResourceSpecificationRef rSpecRef, ServiceOrder sOrder, Service aService) { ResourceCreate resCreate = new ResourceCreate(); resCreate.setName( rSpecRef.getName() + "-" + aService.getId() ); @@ -251,8 +262,8 @@ public class MetricoOrchestrationService implements JavaDelegate { resCharacteristicItem.setName( "_MT_MCJ_REF" ); resCharacteristicItem.setValueType( "TEXT" ); Any val = new Any(); - val.setValue( mcj.getUuid() ); - val.setAlias( mcj.getUuid() ); + val.setValue( "PENDING" ); + val.setAlias( "PENDING" ); resCharacteristicItem.setValue( val ); resCreate.addResourceCharacteristicItem( resCharacteristicItem );