From 36cea0de10bcc70d32714c42857ca824c01cd342 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Wed, 19 Jun 2024 00:06:56 +0300 Subject: [PATCH] fix for #40 (cherry picked from commit 888ca64b097e3f302586344d8b86259c2336b455) --- .../ServiceSpecificationRepoService.java | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/main/java/org/etsi/osl/tmf/scm633/reposervices/ServiceSpecificationRepoService.java b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/ServiceSpecificationRepoService.java index 3ebca01..f2a5172 100644 --- a/src/main/java/org/etsi/osl/tmf/scm633/reposervices/ServiceSpecificationRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/ServiceSpecificationRepoService.java @@ -622,7 +622,7 @@ public class ServiceSpecificationRepoService { * Also, * we will add by default all the characteristics of this rSpec to the related bundle parent service */ - //serviceSpec = copyCharacteristicsOfResourceSpecId( ar.getId(), serviceSpec); + serviceSpec = copyCharacteristicsOfResourceSpecId( ar.getId(), serviceSpec); } } @@ -699,24 +699,24 @@ public class ServiceSpecificationRepoService { return targetServiceSpec; } -// private ServiceSpecification copyCharacteristicsOfResourceSpecId(String sourceResourceSpecid, ServiceSpecification targetServiceSpec) { -// -// ResourceSpecification rSpec = resourceSpecRepoService.findByUuid( sourceResourceSpecid ); -// -// if ( rSpec != null ) { -// for (ResourceSpecificationCharacteristic sourceChar : rSpec.getResourceSpecCharacteristic()) { -// ServiceSpecCharacteristic serviceSpecCharacteristicItem = copyResourceCharacteristic( sourceChar ); -// //serviceSpecCharacteristicItem.setName( rSpec.getName() + "::" +sourceChar.getName() ); -// serviceSpecCharacteristicItem.setName( sourceChar.getName() ); -// -// if ( targetServiceSpec.findSpecCharacteristicByName( serviceSpecCharacteristicItem.getName() ) == null ) { -// targetServiceSpec.getServiceSpecCharacteristic().add( serviceSpecCharacteristicItem ); -// } -// } -// } -// -// return targetServiceSpec; -// } + private ServiceSpecification copyCharacteristicsOfResourceSpecId(String sourceResourceSpecid, ServiceSpecification targetServiceSpec) { + + ResourceSpecification rSpec = resourceSpecRepoService.findByUuid( sourceResourceSpecid ); + + if ( rSpec != null ) { + for (ResourceSpecificationCharacteristic sourceChar : rSpec.getResourceSpecCharacteristic()) { + ServiceSpecCharacteristic serviceSpecCharacteristicItem = copyResourceCharacteristic( sourceChar ); + //serviceSpecCharacteristicItem.setName( rSpec.getName() + "::" +sourceChar.getName() ); + serviceSpecCharacteristicItem.setName( sourceChar.getName() ); + + if ( targetServiceSpec.findSpecCharacteristicByName( serviceSpecCharacteristicItem.getName() ) == null ) { + targetServiceSpec.getServiceSpecCharacteristic().add( serviceSpecCharacteristicItem ); + } + } + } + + return targetServiceSpec; + } public ServiceSpecification cloneServiceSpecification(String uuid) { ServiceSpecification source = this.findByUuid(uuid); @@ -1422,11 +1422,11 @@ public class ServiceSpecificationRepoService { -// for (ResourceSpecificationCharacteristic sourceChar : rSpec.getResourceSpecCharacteristic()) { -// ServiceSpecCharacteristic serviceSpecCharacteristicItem = copyResourceCharacteristic( sourceChar ); + for (ResourceSpecificationCharacteristic sourceChar : rSpec.getResourceSpecCharacteristic()) { + ServiceSpecCharacteristic serviceSpecCharacteristicItem = copyResourceCharacteristic( sourceChar ); // serviceSpecCharacteristicItem.setName( rSpec.getName() + "::" +sourceChar.getName() ); -// serviceSpec.addServiceSpecCharacteristicItem(serviceSpecCharacteristicItem ); -// } + serviceSpec.addServiceSpecCharacteristicItem(serviceSpecCharacteristicItem ); + } ResourceSpecificationRef resourceSpecRef = new ResourceSpecificationRef(); @@ -1439,25 +1439,25 @@ public class ServiceSpecificationRepoService { return serviceSpec; } -// private ServiceSpecCharacteristic copyResourceCharacteristic( ResourceSpecificationCharacteristic sourceChar ) { -// -// ServiceSpecCharacteristic serviceSpecCharacteristicItem = new ServiceSpecCharacteristic(); -// serviceSpecCharacteristicItem.setDescription( sourceChar.getDescription()); -// serviceSpecCharacteristicItem.valueType( sourceChar.getValueType() ); -// serviceSpecCharacteristicItem.configurable(sourceChar.isConfigurable()); -// serviceSpecCharacteristicItem.setMinCardinality( sourceChar.getMinCardinality() ); -// serviceSpecCharacteristicItem.setMaxCardinality( sourceChar.getMaxCardinality() ); -// serviceSpecCharacteristicItem.setValidFor( sourceChar.getValidFor() ); -// for (ResourceSpecificationCharacteristicValue cv : sourceChar.getResourceSpecCharacteristicValue()) { -// ServiceSpecCharacteristicValue serviceSpecCharacteristicValueItem = new ServiceSpecCharacteristicValue(); -// serviceSpecCharacteristicValueItem.setValue( new Any( cv.getValue().getValue(), cv.getValue().getAlias())); -// serviceSpecCharacteristicValueItem.isDefault( cv.isIsDefault() ); -// serviceSpecCharacteristicValueItem.setUnitOfMeasure( cv.getUnitOfMeasure() ); -// serviceSpecCharacteristicItem.addServiceSpecCharacteristicValueItem(serviceSpecCharacteristicValueItem ); -// } -// return serviceSpecCharacteristicItem; -// } -// + private ServiceSpecCharacteristic copyResourceCharacteristic( ResourceSpecificationCharacteristic sourceChar ) { + + ServiceSpecCharacteristic serviceSpecCharacteristicItem = new ServiceSpecCharacteristic(); + serviceSpecCharacteristicItem.setDescription( sourceChar.getDescription()); + serviceSpecCharacteristicItem.valueType( sourceChar.getValueType() ); + serviceSpecCharacteristicItem.configurable(sourceChar.isConfigurable()); + serviceSpecCharacteristicItem.setMinCardinality( sourceChar.getMinCardinality() ); + serviceSpecCharacteristicItem.setMaxCardinality( sourceChar.getMaxCardinality() ); + serviceSpecCharacteristicItem.setValidFor( sourceChar.getValidFor() ); + for (ResourceSpecificationCharacteristicValue cv : sourceChar.getResourceSpecCharacteristicValue()) { + ServiceSpecCharacteristicValue serviceSpecCharacteristicValueItem = new ServiceSpecCharacteristicValue(); + serviceSpecCharacteristicValueItem.setValue( new Any( cv.getValue().getValue(), cv.getValue().getAlias())); + serviceSpecCharacteristicValueItem.isDefault( cv.isIsDefault() ); + serviceSpecCharacteristicValueItem.setUnitOfMeasure( cv.getUnitOfMeasure() ); + serviceSpecCharacteristicItem.addServiceSpecCharacteristicValueItem(serviceSpecCharacteristicValueItem ); + } + return serviceSpecCharacteristicItem; + } + -- GitLab