Loading src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java +119 −64 Original line number Diff line number Diff line Loading @@ -1118,8 +1118,14 @@ public class ServiceRepoService { public void updateServicesHavingThisSupportingResource(@Valid Resource res) { try { if (res.getResourceStatus()==null){ logger.debug("================> updateServicesHavingThisSupportingResource resource status NULL"); return; } logger.debug("================> Will update services related to this resource with id = " + res.getId() ); var aservices = findServicesHavingThisSupportingResourceID( res.getId() ); logger.debug("================> Services found = " + aservices.size() ); for (Service as : aservices) { Loading @@ -1131,6 +1137,10 @@ public class ServiceRepoService { Optional<Resource> result = resourceRepo.findByUuid(rref.getId()); if (result.isPresent()) { rlist.add( result.get() ); if ( result.get().getResourceStatus()==null){ logger.debug("================> updateServicesHavingThisSupportingResource resource status NULL for resource: "+ result.get().getName() ); return; } } } Loading @@ -1139,6 +1149,96 @@ public class ServiceRepoService { /* * Construct characteristic name */ Boolean stateChaged = false; ServiceUpdate supd = new ServiceUpdate(); nextState = aService.findNextStateBasedOnResourceList(rlist); supd.setState(nextState); String stateText=""; if ( !aService.getState().equals(nextState)) { stateChaged = true; stateText = "State changed from " + aService.getState() + " to " + nextState + "."; logger.debug("====================> stateText = " + stateText); } for (Resource r : rlist) { logger.debug("==================> state: ="+ r.getResourceStatus().name() + ", "+ r.getName() ); } //adding all characteristics from service for (Characteristic ch : aService.getServiceCharacteristic()) { supd.addServiceCharacteristicItem(ch); } CharCopyResult result = new CharCopyResult(supd, false); if ( nextState == ServiceStateType.ACTIVE) { if ( !aService.equals(nextState) && nextState == ServiceStateType.ACTIVE) { result = copyCharacteristicsFromAllResources(aService, supd, rlist); } else { result = copyCharacteristicsFromResource(aService, supd, res); } } if ( stateChaged || result.characteristicFoundDifferent) { Characteristic noteCheck = as.getServiceCharacteristicByName("_DETAILED_NOTES_"); if ( noteCheck!= null && noteCheck.getValue() != null && noteCheck.getValue().getValue() != null && !noteCheck.getValue().getValue().equals("")) { Note n = new Note(); n.setText(stateText + "Supporting Resource changed with id: " + res.getId()); n.setAuthor( "SIM638-API" ); n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); result.supd.addNoteItem( n ); } this.updateService( aService.getId(), result.supd , true, null, null); //update the service } } }catch (Exception e) { e.printStackTrace(); } } private record CharCopyResult(ServiceUpdate supd, Boolean characteristicFoundDifferent) { } private CharCopyResult copyCharacteristicsFromAllResources(Service aService, ServiceUpdate supd, List<Resource> rlist) { Boolean characteristicFoundDifferent = false; CharCopyResult copyresult = new CharCopyResult(supd, characteristicFoundDifferent); for (Resource r : rlist) { copyresult = copyCharacteristicsFromResource(aService, copyresult.supd, r); characteristicFoundDifferent = characteristicFoundDifferent || copyresult.characteristicFoundDifferent; } CharCopyResult result = new CharCopyResult(copyresult.supd, copyresult.characteristicFoundDifferent); return result ; } private CharCopyResult copyCharacteristicsFromResource( @Valid Service aService, @Valid ServiceUpdate supd, @Valid Resource res) { Boolean characteristicFoundDifferent = false; String kind = ""; String resourcename = res.getName() ; Loading Loading @@ -1169,30 +1269,6 @@ public class ServiceRepoService { resourcename = resourcename + "."; } Boolean stateChaged = false; ServiceUpdate supd = new ServiceUpdate(); nextState = aService.findNextStateBasedOnResourceList(rlist); supd.setState(nextState); String stateText=""; if ( !aService.getState().equals(nextState)) { stateChaged = true; stateText = "State changed from " + aService.getState() + " to " + nextState + "."; logger.debug("====================> stateText = " + stateText); for (Resource r : rlist) { logger.debug("==================> r:{}, state:{} ="+ r.getName() + ", "+ r.getResourceStatus().name()); } } //adding all characteristics from service for (Characteristic ch : aService.getServiceCharacteristic()) { supd.addServiceCharacteristicItem(ch); } Boolean characteristicFoundDifferent =false; String dontCopyChars = "clusterMasterURL,currentContextCluster,fullResourceName,Kind,apiGroup,UID,metadata"; String[] arrayDontCopyChars = dontCopyChars.split(","); Set<String> setB = new HashSet<>(Arrays.asList(arrayDontCopyChars)); Loading Loading @@ -1222,36 +1298,15 @@ public class ServiceRepoService { } } } }; if ( stateChaged || characteristicFoundDifferent) { Characteristic noteCheck = as.getServiceCharacteristicByName("_DETAILED_NOTES_"); if ( noteCheck!= null && noteCheck.getValue() != null && noteCheck.getValue().getValue() != null && !noteCheck.getValue().getValue().equals("")) { Note n = new Note(); n.setText(stateText + "Supporting Resource changed with id: " + res.getId()); n.setAuthor( "SIM638-API" ); n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); supd.addNoteItem( n ); } this.updateService( aService.getId(), supd , true, null, null); //update the service } } CharCopyResult result = new CharCopyResult(supd, characteristicFoundDifferent); return result ; }catch (Exception e) { e.printStackTrace(); } } @Transactional Loading src/main/java/org/etsi/osl/tmf/so641/reposervices/ServiceOrderRepoService.java +5 −8 Original line number Diff line number Diff line Loading @@ -914,14 +914,11 @@ public class ServiceOrderRepoService { for (ServiceRef specRel : aService.getSupportingService() ) { result += "\""+ aService.getId() + "\""+ " -> " + "\""+ specRel.getId() +"\" "+";\r\n"; result += "\""+ specRel.getId() + "\""+ " [label = \"" + specRel.getName() + "\", color = \"#2596be\"];\r\n"; } for (ResourceRef resRel : aService.getSupportingResource()) { result += "\""+ aService.getId() + "\""+ " -> " + "\""+ resRel.getId() + "\""+ ";\r\n"; result += "\""+ resRel.getId() + "\""+ " [ label = \"" + resRel.getName() +"\", shape = roundedbox, color = \"#e28743\"]; \r\n"; } } Loading Loading
src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java +119 −64 Original line number Diff line number Diff line Loading @@ -1118,8 +1118,14 @@ public class ServiceRepoService { public void updateServicesHavingThisSupportingResource(@Valid Resource res) { try { if (res.getResourceStatus()==null){ logger.debug("================> updateServicesHavingThisSupportingResource resource status NULL"); return; } logger.debug("================> Will update services related to this resource with id = " + res.getId() ); var aservices = findServicesHavingThisSupportingResourceID( res.getId() ); logger.debug("================> Services found = " + aservices.size() ); for (Service as : aservices) { Loading @@ -1131,6 +1137,10 @@ public class ServiceRepoService { Optional<Resource> result = resourceRepo.findByUuid(rref.getId()); if (result.isPresent()) { rlist.add( result.get() ); if ( result.get().getResourceStatus()==null){ logger.debug("================> updateServicesHavingThisSupportingResource resource status NULL for resource: "+ result.get().getName() ); return; } } } Loading @@ -1139,6 +1149,96 @@ public class ServiceRepoService { /* * Construct characteristic name */ Boolean stateChaged = false; ServiceUpdate supd = new ServiceUpdate(); nextState = aService.findNextStateBasedOnResourceList(rlist); supd.setState(nextState); String stateText=""; if ( !aService.getState().equals(nextState)) { stateChaged = true; stateText = "State changed from " + aService.getState() + " to " + nextState + "."; logger.debug("====================> stateText = " + stateText); } for (Resource r : rlist) { logger.debug("==================> state: ="+ r.getResourceStatus().name() + ", "+ r.getName() ); } //adding all characteristics from service for (Characteristic ch : aService.getServiceCharacteristic()) { supd.addServiceCharacteristicItem(ch); } CharCopyResult result = new CharCopyResult(supd, false); if ( nextState == ServiceStateType.ACTIVE) { if ( !aService.equals(nextState) && nextState == ServiceStateType.ACTIVE) { result = copyCharacteristicsFromAllResources(aService, supd, rlist); } else { result = copyCharacteristicsFromResource(aService, supd, res); } } if ( stateChaged || result.characteristicFoundDifferent) { Characteristic noteCheck = as.getServiceCharacteristicByName("_DETAILED_NOTES_"); if ( noteCheck!= null && noteCheck.getValue() != null && noteCheck.getValue().getValue() != null && !noteCheck.getValue().getValue().equals("")) { Note n = new Note(); n.setText(stateText + "Supporting Resource changed with id: " + res.getId()); n.setAuthor( "SIM638-API" ); n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); result.supd.addNoteItem( n ); } this.updateService( aService.getId(), result.supd , true, null, null); //update the service } } }catch (Exception e) { e.printStackTrace(); } } private record CharCopyResult(ServiceUpdate supd, Boolean characteristicFoundDifferent) { } private CharCopyResult copyCharacteristicsFromAllResources(Service aService, ServiceUpdate supd, List<Resource> rlist) { Boolean characteristicFoundDifferent = false; CharCopyResult copyresult = new CharCopyResult(supd, characteristicFoundDifferent); for (Resource r : rlist) { copyresult = copyCharacteristicsFromResource(aService, copyresult.supd, r); characteristicFoundDifferent = characteristicFoundDifferent || copyresult.characteristicFoundDifferent; } CharCopyResult result = new CharCopyResult(copyresult.supd, copyresult.characteristicFoundDifferent); return result ; } private CharCopyResult copyCharacteristicsFromResource( @Valid Service aService, @Valid ServiceUpdate supd, @Valid Resource res) { Boolean characteristicFoundDifferent = false; String kind = ""; String resourcename = res.getName() ; Loading Loading @@ -1169,30 +1269,6 @@ public class ServiceRepoService { resourcename = resourcename + "."; } Boolean stateChaged = false; ServiceUpdate supd = new ServiceUpdate(); nextState = aService.findNextStateBasedOnResourceList(rlist); supd.setState(nextState); String stateText=""; if ( !aService.getState().equals(nextState)) { stateChaged = true; stateText = "State changed from " + aService.getState() + " to " + nextState + "."; logger.debug("====================> stateText = " + stateText); for (Resource r : rlist) { logger.debug("==================> r:{}, state:{} ="+ r.getName() + ", "+ r.getResourceStatus().name()); } } //adding all characteristics from service for (Characteristic ch : aService.getServiceCharacteristic()) { supd.addServiceCharacteristicItem(ch); } Boolean characteristicFoundDifferent =false; String dontCopyChars = "clusterMasterURL,currentContextCluster,fullResourceName,Kind,apiGroup,UID,metadata"; String[] arrayDontCopyChars = dontCopyChars.split(","); Set<String> setB = new HashSet<>(Arrays.asList(arrayDontCopyChars)); Loading Loading @@ -1222,36 +1298,15 @@ public class ServiceRepoService { } } } }; if ( stateChaged || characteristicFoundDifferent) { Characteristic noteCheck = as.getServiceCharacteristicByName("_DETAILED_NOTES_"); if ( noteCheck!= null && noteCheck.getValue() != null && noteCheck.getValue().getValue() != null && !noteCheck.getValue().getValue().equals("")) { Note n = new Note(); n.setText(stateText + "Supporting Resource changed with id: " + res.getId()); n.setAuthor( "SIM638-API" ); n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); supd.addNoteItem( n ); } this.updateService( aService.getId(), supd , true, null, null); //update the service } } CharCopyResult result = new CharCopyResult(supd, characteristicFoundDifferent); return result ; }catch (Exception e) { e.printStackTrace(); } } @Transactional Loading
src/main/java/org/etsi/osl/tmf/so641/reposervices/ServiceOrderRepoService.java +5 −8 Original line number Diff line number Diff line Loading @@ -914,14 +914,11 @@ public class ServiceOrderRepoService { for (ServiceRef specRel : aService.getSupportingService() ) { result += "\""+ aService.getId() + "\""+ " -> " + "\""+ specRel.getId() +"\" "+";\r\n"; result += "\""+ specRel.getId() + "\""+ " [label = \"" + specRel.getName() + "\", color = \"#2596be\"];\r\n"; } for (ResourceRef resRel : aService.getSupportingResource()) { result += "\""+ aService.getId() + "\""+ " -> " + "\""+ resRel.getId() + "\""+ ";\r\n"; result += "\""+ resRel.getId() + "\""+ " [ label = \"" + resRel.getName() +"\", shape = roundedbox, color = \"#e28743\"]; \r\n"; } } Loading