Loading pom.xml +29 −0 Original line number Original line Diff line number Diff line Loading @@ -75,6 +75,11 @@ <type>pom</type> <type>pom</type> <scope>import</scope> <scope>import</scope> </dependency> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20210307</version> </dependency> </dependencies> </dependencies> </dependencyManagement> </dependencyManagement> Loading Loading @@ -415,6 +420,30 @@ <classifier>exec</classifier> <classifier>exec</classifier> </configuration> </configuration> </plugin> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.2.5</version> </plugin> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.12</version> <executions> <execution> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>report</id> <phase>prepare-package</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin> </plugins> </plugins> </build> </build> Loading src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java +74 −5 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ package org.etsi.osl.tmf.sim638.service; import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException; import java.time.OffsetDateTime; import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.ArrayList; import java.util.Iterator; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashMap; Loading @@ -29,6 +30,7 @@ import java.util.List; import java.util.Map; import java.util.Map; import java.util.Optional; import java.util.Optional; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule; import com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule; import org.apache.commons.logging.Log; import org.apache.commons.logging.Log; Loading Loading @@ -192,7 +194,7 @@ public class ServiceRepoService { result.put("serviceOrder", new ArrayList<Object>() ) ; result.put("serviceOrder", new ArrayList<Object>() ) ; } } ArrayList< Object> rpList = (ArrayList< Object>) result.get( "serviceOrder" ); ArrayList< Object> rpList = (ArrayList< Object>) result.get( "serviceOrder" ); LinkedHashMap<String, Object> rp = new LinkedHashMap<String, Object>(); LinkedHashMap<String, Object> rp = new LinkedHashMap<>(); rp.put("id", tuple[i]); rp.put("id", tuple[i]); rpList.add(rp); rpList.add(rp); } } Loading Loading @@ -464,6 +466,7 @@ public class ServiceRepoService { boolean serviceCharacteristicChanged = false; boolean serviceCharacteristicChanged = false; boolean serviceCharacteristicChangedContainsPrimitive = false; boolean serviceCharacteristicChangedContainsPrimitive = false; boolean serviceCharacteristicChangedContainsNSLCM; String charChangedForNotes = ""; String charChangedForNotes = ""; //List<Characteristic> childCharacteristicsChanged = new ArrayList<>(); //List<Characteristic> childCharacteristicsChanged = new ArrayList<>(); Loading @@ -474,6 +477,7 @@ public class ServiceRepoService { if ( servUpd.getServiceCharacteristic()!=null ) { if ( servUpd.getServiceCharacteristic()!=null ) { for (Characteristic n : servUpd.getServiceCharacteristic()) { for (Characteristic n : servUpd.getServiceCharacteristic()) { serviceCharacteristicChangedContainsNSLCM = false; if ( service.getServiceCharacteristicByName( n.getName() )!= null ) { if ( service.getServiceCharacteristicByName( n.getName() )!= null ) { Loading @@ -494,12 +498,26 @@ public class ServiceRepoService { serviceCharacteristicChangedContainsPrimitive = true; serviceCharacteristicChangedContainsPrimitive = true; } } // Check if the name contains "NSLCM" if (n.getName().toUpperCase().contains("NSLCM")) { // Flag to indicate that service characteristic with NSLCM is present serviceCharacteristicChangedContainsNSLCM = true; // Update the NSLCM Characteristic updateNSLCMCharacteristic(service, n); } } } } } // As the NSLCM Characteristic was already updated, skip that one if (!serviceCharacteristicChangedContainsNSLCM) { service.getServiceCharacteristicByName( n.getName() ).setValue( service.getServiceCharacteristicByName( n.getName() ).setValue( new Any( n.getValue().getValue(), n.getValue().getAlias() ) new Any( n.getValue().getValue(), n.getValue().getAlias() ) ); ); } } else { } else { service.addServiceCharacteristicItem(n); service.addServiceCharacteristicItem(n); if ( !n.getName().contains("::") ) { //it is not a child characteristic if ( !n.getName().contains("::") ) { //it is not a child characteristic Loading Loading @@ -731,6 +749,57 @@ public class ServiceRepoService { return service; return service; } } /** * Updates the NSLCM characteristic within a given service. * * @param service The service object containing the characteristics. * @param n The characteristic object to be checked and potentially updated. */ public Service updateNSLCMCharacteristic(Service service, Characteristic n) { // Create an object mapper for JSON serialization/deserialization ObjectMapper primitivesObjectMapper = new ObjectMapper(); // Retrieve the service characteristic based on the name Characteristic aNSLCMCharacteristic = service.getServiceCharacteristicByName(n.getName()); // Retrieve the current value as a string directly from the service characteristic String aNSLCMCharacteristicValue = service.getServiceCharacteristicByName(n.getName()).getValue().getValue(); // Check if the current service characteristic value is null or explicitly "null" and initialize if needed if (aNSLCMCharacteristicValue == null || "null".equals(aNSLCMCharacteristicValue) || aNSLCMCharacteristicValue.equals("")) { service.getServiceCharacteristicByName(n.getName()).getValue().setValue("[]"); } // Check if the current characteristic value is not null and not explicitly "null" if (n.getValue().getValue() != null || !"null".equals(n.getValue().getValue())) { aNSLCMCharacteristicValue = service.getServiceCharacteristicByName(n.getName()).getValue().getValue(); ArrayList<String> arrayList = null; // Deserialize the current value back to an array list try { arrayList = primitivesObjectMapper.readValue(aNSLCMCharacteristicValue, new TypeReference<ArrayList<String>>() {}); } catch (JsonProcessingException e) { e.printStackTrace(); } // Add the new value to the list if it's not already present and is not null if (!arrayList.contains(n.getValue().getValue()) && n.getValue().getValue() != null) { arrayList.add(n.getValue().getValue()); } // Update the characteristic with the newly modified list try { aNSLCMCharacteristic.setValue(new Any(primitivesObjectMapper.writeValueAsString(arrayList), n.getValue().getAlias())); } catch (JsonProcessingException e) { e.printStackTrace(); } } return service; } /** /** * @param service * @param service * @param parentService * @param parentService Loading Loading
pom.xml +29 −0 Original line number Original line Diff line number Diff line Loading @@ -75,6 +75,11 @@ <type>pom</type> <type>pom</type> <scope>import</scope> <scope>import</scope> </dependency> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20210307</version> </dependency> </dependencies> </dependencies> </dependencyManagement> </dependencyManagement> Loading Loading @@ -415,6 +420,30 @@ <classifier>exec</classifier> <classifier>exec</classifier> </configuration> </configuration> </plugin> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.2.5</version> </plugin> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.12</version> <executions> <execution> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>report</id> <phase>prepare-package</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin> </plugins> </plugins> </build> </build> Loading
src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java +74 −5 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ package org.etsi.osl.tmf.sim638.service; import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException; import java.time.OffsetDateTime; import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.ArrayList; import java.util.Iterator; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashMap; Loading @@ -29,6 +30,7 @@ import java.util.List; import java.util.Map; import java.util.Map; import java.util.Optional; import java.util.Optional; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule; import com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule; import org.apache.commons.logging.Log; import org.apache.commons.logging.Log; Loading Loading @@ -192,7 +194,7 @@ public class ServiceRepoService { result.put("serviceOrder", new ArrayList<Object>() ) ; result.put("serviceOrder", new ArrayList<Object>() ) ; } } ArrayList< Object> rpList = (ArrayList< Object>) result.get( "serviceOrder" ); ArrayList< Object> rpList = (ArrayList< Object>) result.get( "serviceOrder" ); LinkedHashMap<String, Object> rp = new LinkedHashMap<String, Object>(); LinkedHashMap<String, Object> rp = new LinkedHashMap<>(); rp.put("id", tuple[i]); rp.put("id", tuple[i]); rpList.add(rp); rpList.add(rp); } } Loading Loading @@ -464,6 +466,7 @@ public class ServiceRepoService { boolean serviceCharacteristicChanged = false; boolean serviceCharacteristicChanged = false; boolean serviceCharacteristicChangedContainsPrimitive = false; boolean serviceCharacteristicChangedContainsPrimitive = false; boolean serviceCharacteristicChangedContainsNSLCM; String charChangedForNotes = ""; String charChangedForNotes = ""; //List<Characteristic> childCharacteristicsChanged = new ArrayList<>(); //List<Characteristic> childCharacteristicsChanged = new ArrayList<>(); Loading @@ -474,6 +477,7 @@ public class ServiceRepoService { if ( servUpd.getServiceCharacteristic()!=null ) { if ( servUpd.getServiceCharacteristic()!=null ) { for (Characteristic n : servUpd.getServiceCharacteristic()) { for (Characteristic n : servUpd.getServiceCharacteristic()) { serviceCharacteristicChangedContainsNSLCM = false; if ( service.getServiceCharacteristicByName( n.getName() )!= null ) { if ( service.getServiceCharacteristicByName( n.getName() )!= null ) { Loading @@ -494,12 +498,26 @@ public class ServiceRepoService { serviceCharacteristicChangedContainsPrimitive = true; serviceCharacteristicChangedContainsPrimitive = true; } } // Check if the name contains "NSLCM" if (n.getName().toUpperCase().contains("NSLCM")) { // Flag to indicate that service characteristic with NSLCM is present serviceCharacteristicChangedContainsNSLCM = true; // Update the NSLCM Characteristic updateNSLCMCharacteristic(service, n); } } } } } // As the NSLCM Characteristic was already updated, skip that one if (!serviceCharacteristicChangedContainsNSLCM) { service.getServiceCharacteristicByName( n.getName() ).setValue( service.getServiceCharacteristicByName( n.getName() ).setValue( new Any( n.getValue().getValue(), n.getValue().getAlias() ) new Any( n.getValue().getValue(), n.getValue().getAlias() ) ); ); } } else { } else { service.addServiceCharacteristicItem(n); service.addServiceCharacteristicItem(n); if ( !n.getName().contains("::") ) { //it is not a child characteristic if ( !n.getName().contains("::") ) { //it is not a child characteristic Loading Loading @@ -731,6 +749,57 @@ public class ServiceRepoService { return service; return service; } } /** * Updates the NSLCM characteristic within a given service. * * @param service The service object containing the characteristics. * @param n The characteristic object to be checked and potentially updated. */ public Service updateNSLCMCharacteristic(Service service, Characteristic n) { // Create an object mapper for JSON serialization/deserialization ObjectMapper primitivesObjectMapper = new ObjectMapper(); // Retrieve the service characteristic based on the name Characteristic aNSLCMCharacteristic = service.getServiceCharacteristicByName(n.getName()); // Retrieve the current value as a string directly from the service characteristic String aNSLCMCharacteristicValue = service.getServiceCharacteristicByName(n.getName()).getValue().getValue(); // Check if the current service characteristic value is null or explicitly "null" and initialize if needed if (aNSLCMCharacteristicValue == null || "null".equals(aNSLCMCharacteristicValue) || aNSLCMCharacteristicValue.equals("")) { service.getServiceCharacteristicByName(n.getName()).getValue().setValue("[]"); } // Check if the current characteristic value is not null and not explicitly "null" if (n.getValue().getValue() != null || !"null".equals(n.getValue().getValue())) { aNSLCMCharacteristicValue = service.getServiceCharacteristicByName(n.getName()).getValue().getValue(); ArrayList<String> arrayList = null; // Deserialize the current value back to an array list try { arrayList = primitivesObjectMapper.readValue(aNSLCMCharacteristicValue, new TypeReference<ArrayList<String>>() {}); } catch (JsonProcessingException e) { e.printStackTrace(); } // Add the new value to the list if it's not already present and is not null if (!arrayList.contains(n.getValue().getValue()) && n.getValue().getValue() != null) { arrayList.add(n.getValue().getValue()); } // Update the characteristic with the newly modified list try { aNSLCMCharacteristic.setValue(new Any(primitivesObjectMapper.writeValueAsString(arrayList), n.getValue().getAlias())); } catch (JsonProcessingException e) { e.printStackTrace(); } } return service; } /** /** * @param service * @param service * @param parentService * @param parentService Loading