diff --git a/pom.xml b/pom.xml index 430af39a0d8ac6535f92d92c5a4b8f2188d2dfbf..6308aa4165a644ea5e9202bea4d8ee76537e5f64 100644 --- a/pom.xml +++ b/pom.xml @@ -305,7 +305,7 @@ com.h2database h2 - test + 2.3.232 org.apache.activemq diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductCatalogApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductCatalogApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..950a9a5404769089d9d59c56c82a2297ad33d066 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductCatalogApiRouteBuilder.java @@ -0,0 +1,132 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.io.IOException; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.camel.LoggingLevel; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.dataformat.JsonLibrary; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.pcm620.reposervices.ProductCatalogRepoService; +import org.etsi.osl.tmf.pcm620.reposervices.ProductCategoryRepoService; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationUpdate; +import org.etsi.osl.tmf.scm633.reposervices.CatalogRepoService; +import org.etsi.osl.tmf.scm633.reposervices.CategoryRepoService; +import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +@Configuration +//@RefreshScope +@Component +public class ProductCatalogApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(ProductCatalogApiRouteBuilder.class.getName()); + + + + @Value("${CATALOG_GET_PRODUCTCATALOGS}") + private String CATALOG_GET_PRODUCTCATALOGS = ""; + + @Value("${CATALOG_GET_PRODUCTCATALOG_BY_ID}") + private String CATALOG_GET_PRODUCTCATALOG_BY_ID = ""; + + @Value("${CATALOG_GET_PRODUCTCATALOG_BY_NAME}") + private String CATALOG_GET_PRODUCTCATALOG_BY_NAME = ""; + + @Value("${CATALOG_GET_PRODUCTCATEGORIES}") + private String CATALOG_GET_PRODUCTCATEGORIES = ""; + + @Value("${CATALOG_GET_PRODUCTCATEGORY_BY_ID}") + private String CATALOG_GET_PRODUCTCATEGORY_BY_ID = ""; + + + @Value("${CATALOG_GET_PRODUCTOFFERINGS_BYCATEGORY_ID}") + private String CATALOG_GET_PRODUCTOFFERINGS_BYCATEGORY_ID = ""; + + + @Autowired + ProductCatalogRepoService catalogRepoService; + + + @Autowired + ProductCategoryRepoService categoryRepoService; + + + @Override + public void configure() throws Exception { + + from( CATALOG_GET_PRODUCTCATALOG_BY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_PRODUCTCATALOG_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( catalogRepoService, "findByUuidEager(${header.catalogId})"); + + from( CATALOG_GET_PRODUCTCATALOGS ) + .log(LoggingLevel.INFO, log, CATALOG_GET_PRODUCTCATALOGS + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( catalogRepoService, "findAllEager()"); + + from( CATALOG_GET_PRODUCTCATALOG_BY_NAME ) + .log(LoggingLevel.INFO, log, CATALOG_GET_PRODUCTCATALOG_BY_NAME + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( catalogRepoService, "findByNameEager(${header.catalogName})") + .marshal().json( JsonLibrary.Jackson, String.class) + .convertBodyTo( String.class ); + + + from( CATALOG_GET_PRODUCTCATEGORIES ) + .log(LoggingLevel.INFO, log, CATALOG_GET_PRODUCTCATEGORIES + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( catalogRepoService, "findAllCategoriesByCatalogName(${header.catalogName})"); + + + from( CATALOG_GET_PRODUCTCATEGORY_BY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_PRODUCTCATEGORY_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( categoryRepoService, "findByIdEager(${header.catalogId})"); + + + from( CATALOG_GET_PRODUCTOFFERINGS_BYCATEGORY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_PRODUCTOFFERINGS_BYCATEGORY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( categoryRepoService, "findAllProductOfferingsByCategId(${header.categoryId})"); + + } + + + + + + static T toJsonObj(String content, Class valueType) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.readValue( content, valueType); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductSpecificationApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductSpecificationApiRouteBuilder.java index 07fe723d0e242df176992fc1729001098dd3427e..0c55c76983439e340b18b69c30807cfad260a407 100644 --- a/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductSpecificationApiRouteBuilder.java +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductSpecificationApiRouteBuilder.java @@ -1,5 +1,6 @@ package org.etsi.osl.tmf.pcm620.api; +import java.util.ArrayList; import org.apache.camel.LoggingLevel; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.model.dataformat.JsonLibrary; @@ -38,6 +39,10 @@ public class ProductSpecificationApiRouteBuilder extends RouteBuilder { @Value("${CATALOG_GET_PRODUCTOFFERING_BY_ID}") private String CATALOG_GET_PRODUCTOFFERING_BY_ID = ""; + + + @Value("${CATALOG_SEARCH_PRODUCTOFFERINGS}") + private String CATALOG_SEARCH_PRODUCTOFFERINGS = ""; @@ -90,6 +95,14 @@ public class ProductSpecificationApiRouteBuilder extends RouteBuilder { .marshal().json( JsonLibrary.Jackson, String.class) .convertBodyTo( String.class ); + + + from( CATALOG_SEARCH_PRODUCTOFFERINGS ) + .log(LoggingLevel.INFO, log, CATALOG_SEARCH_PRODUCTOFFERINGS + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ArrayList.class, true) + .bean( productOfferingRepoService, "searchProductOfferings( ${body} )"); + } } diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCatalogRepoService.java b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCatalogRepoService.java index 126999bd90598748e8c8d91146cb28b070f282ac..3f66f5c7686023d4734ae40376100f99e179e269 100644 --- a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCatalogRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCatalogRepoService.java @@ -21,8 +21,12 @@ package org.etsi.osl.tmf.pcm620.reposervices; import java.time.OffsetDateTime; import java.time.ZoneOffset; +import java.util.ArrayList; import java.util.List; import java.util.Optional; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule; import org.etsi.osl.tmf.common.model.ELifecycle; import org.etsi.osl.tmf.common.model.TimePeriod; import org.etsi.osl.tmf.pcm620.model.Catalog; @@ -31,11 +35,16 @@ import org.etsi.osl.tmf.pcm620.model.CatalogUpdate; import org.etsi.osl.tmf.pcm620.model.Category; import org.etsi.osl.tmf.pcm620.model.CategoryRef; import org.etsi.osl.tmf.pcm620.repo.ProductCatalogRepository; +import org.etsi.osl.tmf.scm633.model.ServiceCatalog; +import org.etsi.osl.tmf.scm633.model.ServiceCategory; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryRef; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import jakarta.validation.Valid; @Service +@Transactional public class ProductCatalogRepoService { @@ -80,6 +89,65 @@ public class ProductCatalogRepoService { return null; } + + public String findByUuidEager(String id) { + + Catalog sc = this.findById(id); + + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + String res; + try { + res = mapper.writeValueAsString( sc ); + } catch (JsonProcessingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return "{}"; + } + + return res; + } + + public String findAllEager() { + + List oids = (List) this.catalogRepo.findByOrderByName(); + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + String res; + try { + res = mapper.writeValueAsString( oids ); + } catch (JsonProcessingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return "{}"; + } + + return res; + } + + public String findByNameEager(String aname) { + Catalog sc = this.findByName(aname); + + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + String res; + try { + res = mapper.writeValueAsString( sc ); + } catch (JsonProcessingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return "{}"; + } + + return res; + + } public Catalog updateCatalog(String id, CatalogUpdate Catalog) { @@ -131,5 +199,64 @@ public class ProductCatalogRepoService { public Catalog updateCatalog(Catalog scatalog) { return this.catalogRepo.save(scatalog); } + + /** + * return recursively all categories in catalog + * @param catalogName + */ + @Transactional + public String findAllCategoriesByCatalogName(String catalogName) { + String res="[]"; + + Optional scopt = this.catalogRepo.findByName(catalogName); + + if (scopt.isEmpty() ) { + return res; + } + + Catalog sc = scopt.get(); + + sc.getCategoryRefs(); + + + List allcategories = this.getCategories( sc.getCategoryRefs()); + + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + + + try { + res = mapper.writeValueAsString( allcategories ); + } catch (JsonProcessingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + return res; + + } + + + @Transactional + private List getCategories( @Valid List list) { + List categories = new ArrayList(); + + for (CategoryRef c : list ) { + Category category = this.categRepoService.findByUuid( c.getId()); + categories.add(category); + + if (category.getCategoryRefs()!=null && category.getCategoryRefs().size()>0) { + List subcategories = this.getCategories( category.getCategoryRefs() ); + categories.addAll(subcategories );//add children + } + + } + + return categories; + } + } diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCategoryRepoService.java b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCategoryRepoService.java index 60ebcca044262ec1f144f26d8f63ca2e01d46891..c7e226c03bbea2d617b95b6c1c4dae13b8820053 100644 --- a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCategoryRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCategoryRepoService.java @@ -26,39 +26,41 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule; import org.etsi.osl.tmf.common.model.ELifecycle; import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; import org.etsi.osl.tmf.pcm620.model.Category; import org.etsi.osl.tmf.pcm620.model.CategoryCreate; import org.etsi.osl.tmf.pcm620.model.CategoryRef; import org.etsi.osl.tmf.pcm620.model.CategoryUpdate; import org.etsi.osl.tmf.pcm620.model.ProductOffering; import org.etsi.osl.tmf.pcm620.model.ProductOfferingRef; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationRef; import org.etsi.osl.tmf.pcm620.repo.ProductCatalogRepository; import org.etsi.osl.tmf.pcm620.repo.ProductCategoriesRepository; import org.etsi.osl.tmf.pcm620.repo.ProductOfferingRepository; +import org.etsi.osl.tmf.scm633.model.ServiceCandidate; +import org.etsi.osl.tmf.scm633.model.ServiceCategory; import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import jakarta.persistence.EntityManagerFactory; import jakarta.validation.Valid; @Service public class ProductCategoryRepoService { - @Autowired - ProductCategoriesRepository categsRepo; - - @Autowired - ProductCatalogRepository catalogRepo; + private final ProductCategoriesRepository categsRepo; - @Autowired - ProductOfferingRepository prodsOfferingRepo; - - private SessionFactory sessionFactory; + private final ProductOfferingRepository prodsOfferingRepo; /** * from @@ -67,11 +69,11 @@ public class ProductCategoryRepoService { * @param factory */ @Autowired - public ProductCategoryRepoService(EntityManagerFactory factory) { - if (factory.unwrap(SessionFactory.class) == null) { - throw new NullPointerException("factory is not a hibernate factory"); - } - this.sessionFactory = factory.unwrap(SessionFactory.class); + public ProductCategoryRepoService( ProductCategoriesRepository categsRepo, + ProductOfferingRepository prodsOfferingRepo) { + + this.categsRepo = categsRepo; + this.prodsOfferingRepo = prodsOfferingRepo; } @@ -100,28 +102,31 @@ public class ProductCategoryRepoService { } - public Category findByIdEager(String id) { -// Optional optionalCat = this.categsRepo.findByIdEager( id ); -// return optionalCat -// .orElse(null); - - Session session = sessionFactory.openSession(); - Transaction tx = session.beginTransaction(); - Category dd = null; - try { - dd = (Category) session.get(Category.class, id); - Hibernate.initialize( dd.getCategoryObj() ); - Hibernate.initialize( dd.getProductOfferingRefs() ); - for (ProductOfferingRef sc : dd.getProductOfferingRefs()) { - Hibernate.initialize(sc ); - } - - tx.commit(); - } finally { - session.close(); - } - return dd; - } + @Transactional + public String findByIdEager(String id) { + Category sc = this.findByUuid( id ); + + String res= "{}"; + + if ( sc == null ) { + return res; + } + + + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + + try { + res = mapper.writeValueAsString( sc ); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + + return res; + } @@ -321,4 +326,35 @@ public class ProductCategoryRepoService { return optionalCat .orElse(null); } + + @Transactional + public String findAllProductOfferingsByCategId(String categoryId) { + + + String res="[]"; + List productSpecificationRefList = new ArrayList<>(); + Category category = this.findByUuid(categoryId); + + if ( category == null ) { + return res; + } + + Set proffs = category.getProductOfferingObj(); + + + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + + try { + res = mapper.writeValueAsString( proffs ); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + + return res; + + } } diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductOfferingRepoService.java b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductOfferingRepoService.java index 40176d7b632d3795da8fa4b598a4fdfd4d25ea4c..942d0e7d91331ea7958797bf88af6814d2996736 100644 --- a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductOfferingRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductOfferingRepoService.java @@ -26,18 +26,20 @@ import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import org.etsi.osl.tmf.JsonUtils; +import java.util.StringJoiner; +import java.util.stream.Collectors; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule; import org.etsi.osl.tmf.am651.model.AgreementRef; import org.etsi.osl.tmf.common.model.Any; import org.etsi.osl.tmf.common.model.AttachmentRefOrValue; import org.etsi.osl.tmf.common.model.ELifecycle; import org.etsi.osl.tmf.common.model.TimePeriod; -import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; import org.etsi.osl.tmf.pcm620.model.BundledProductOffering; import org.etsi.osl.tmf.pcm620.model.ProductOffering; import org.etsi.osl.tmf.pcm620.model.ProductOfferingCreate; @@ -50,8 +52,6 @@ import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCharacteristicValueUse; import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCreate; import org.etsi.osl.tmf.pcm620.model.ProductSpecificationRef; import org.etsi.osl.tmf.pcm620.repo.ProductOfferingRepository; -import org.etsi.osl.tmf.pcm620.repo.ProductSpecificationRepository; -import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristicValue; import org.etsi.osl.tmf.scm633.model.ServiceSpecification; import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; import org.hibernate.Hibernate; @@ -142,15 +142,14 @@ public class ProductOfferingRepoService { } sql += " FROM ProductOffering s"; - if (allParams.size() > 0) { - sql += " WHERE "; - for (String pname : allParams.keySet()) { - sql += " " + pname + " LIKE "; - String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); - sql += "'" + pval + "'"; - } - - } + if (allParams.size() > 0) { + String items = allParams.entrySet() + .stream() + .map(entry -> "s." + entry.getKey() + " LIKE '%" + URLDecoder.decode( entry.getValue(), StandardCharsets.UTF_8 )+ "%'" ) + .collect(Collectors.joining(" OR ")); + sql += " WHERE " + items; + + } sql += " ORDER BY s.name"; @@ -632,5 +631,124 @@ public class ProductOfferingRepoService { return pOffer; } + + + @Transactional + public String searchProductOfferings(List searchText) { + String res = "[]"; + + try { + + List specs= this.searchOfferingsInCategories( searchText); + + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + res = mapper.writeValueAsString( specs ); + + + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + + return res; + } + + + /** + * + * This findAll is optimized on fields. + * @param fields + * @param allParams + * @return + * @throws UnsupportedEncodingException + */ + @Transactional + public List searchOfferingsInCategories( List searchList ) + throws UnsupportedEncodingException { + + if ( searchList == null || searchList.size() ==0) { + return new ArrayList<>(); + } + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + + try { + String sql = "SELECT p.id as productOfferingId, p.name as productName, p.description as productDescription"; + + + + sql += " FROM ProductCategory as pcateg JOIN pcateg.productOffObj as p "; + sql += " WHERE " ; + + + // Build the name LIKE clause + StringJoiner nameJoiner = new StringJoiner(" AND "); + for (String term : searchList) { + nameJoiner.add("p.name LIKE '%" + term + "%'"); + } + + // Build the description LIKE clause + StringJoiner descriptionJoiner = new StringJoiner(" AND "); + for (String term : searchList) { + descriptionJoiner.add("p.description LIKE '%" + term + "%'"); + } + + // Combine both clauses with OR + sql += "(" + nameJoiner.toString() + ") OR (" + descriptionJoiner.toString() + ")"; + + sql += " ORDER BY p.name"; + +// List specs = session +// .createQuery( sql, ServiceSpecification.class) +// .getResultList(); + + + List mapaEntity = session + .createQuery(sql ) + .setResultTransformer( new ResultTransformer() { + + @Override + public Object transformTuple(Object[] tuple, String[] aliases) { + Map result = new LinkedHashMap(tuple.length); + for (int i = 0; i < tuple.length; i++) { + String alias = aliases[i]; + if (alias != null) { + if (alias.equals("type")) { + alias = "@type"; + } + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + +// //this will fetch the whole object fields + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + + } } diff --git a/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCatalogApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCatalogApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..afa3892c5eaee8f732aab0b7e3a8d65b316de67d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCatalogApiRouteBuilder.java @@ -0,0 +1,135 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.scm633.api; + +import java.io.IOException; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.camel.LoggingLevel; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.dataformat.JsonLibrary; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationUpdate; +import org.etsi.osl.tmf.scm633.reposervices.CatalogRepoService; +import org.etsi.osl.tmf.scm633.reposervices.CategoryRepoService; +import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; +import org.etsi.osl.tmf.sim638.model.ServiceCreate; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; +import org.etsi.osl.tmf.so641.api.ServiceOrderApiRouteBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +@Configuration +//@RefreshScope +@Component +public class ServiceCatalogApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(ServiceCatalogApiRouteBuilder.class.getName()); + + + + @Value("${CATALOG_GET_SERVICECATALOGS}") + private String CATALOG_GET_SERVICECATALOGS = ""; + + @Value("${CATALOG_GET_SERVICECATALOG_BY_ID}") + private String CATALOG_GET_SERVICECATALOG_BY_ID = ""; + + @Value("${CATALOG_GET_SERVICECATALOG_BY_NAME}") + private String CATALOG_GET_SERVICECATALOG_BY_NAME = ""; + + @Value("${CATALOG_GET_SERVICECATEGORIES}") + private String CATALOG_GET_SERVICECATEGORIES = ""; + + @Value("${CATALOG_GET_SERVICECATEGORY_BY_ID}") + private String CATALOG_GET_SERVICECATEGORY_BY_ID = ""; + + + @Value("${CATALOG_GET_SERVICESPECREFS_BYCATEGORY_ID}") + private String CATALOG_GET_SERVICESPECREFS_BYCATEGORY_ID = ""; + + + + + @Autowired + CatalogRepoService catalogRepoService; + + + @Autowired + CategoryRepoService categoryRepoService; + + + @Override + public void configure() throws Exception { + + from( CATALOG_GET_SERVICECATALOG_BY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_SERVICECATALOG_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( catalogRepoService, "findByUuidEager(${header.catalogId})"); + + from( CATALOG_GET_SERVICECATALOGS ) + .log(LoggingLevel.INFO, log, CATALOG_GET_SERVICECATALOGS + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( catalogRepoService, "findAllEager()"); + + from( CATALOG_GET_SERVICECATALOG_BY_NAME ) + .log(LoggingLevel.INFO, log, CATALOG_GET_SERVICECATALOG_BY_NAME + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( catalogRepoService, "findByNameEager(${header.catalogName})") + .marshal().json( JsonLibrary.Jackson, String.class) + .convertBodyTo( String.class ); + + + from( CATALOG_GET_SERVICECATEGORIES ) + .log(LoggingLevel.INFO, log, CATALOG_GET_SERVICECATEGORIES + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( catalogRepoService, "findAllCategoriesByCatalogName(${header.catalogName})"); + + + from( CATALOG_GET_SERVICECATEGORY_BY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_SERVICECATEGORY_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( categoryRepoService, "findByIdEager(${header.catalogId})"); + + + from( CATALOG_GET_SERVICESPECREFS_BYCATEGORY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_SERVICESPECREFS_BYCATEGORY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( categoryRepoService, "findAllServiceSpecRefsByCategId(${header.categoryId})"); + + } + + + + + + static T toJsonObj(String content, Class valueType) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.readValue( content, valueType); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApiRouteBuilder.java index 8116a38c20479395b44ff0e2e7770f470f5c7f2f..ed5f01481ad6635cb123a3e33ffaeed08a49b6d6 100644 --- a/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApiRouteBuilder.java +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApiRouteBuilder.java @@ -20,7 +20,7 @@ package org.etsi.osl.tmf.scm633.api; import java.io.IOException; - +import java.util.ArrayList; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; @@ -46,7 +46,7 @@ import org.springframework.stereotype.Component; @Component public class ServiceSpecificationApiRouteBuilder extends RouteBuilder { - private static final transient Log logger = LogFactory.getLog(ServiceOrderApiRouteBuilder.class.getName()); + private static final transient Log logger = LogFactory.getLog(ServiceSpecificationApiRouteBuilder.class.getName()); @Value("${CATALOG_GET_SERVICESPEC_BY_ID}") private String CATALOG_GET_SERVICESPEC_BY_ID = ""; @@ -67,7 +67,14 @@ public class ServiceSpecificationApiRouteBuilder extends RouteBuilder { @Value("${CATALOG_UPD_EXTERNAL_SERVICESPEC}") private String CATALOG_UPD_EXTERNAL_SERVICESPEC = ""; - + + + @Value("${CATALOG_SEARCH_SERVICESPECREFS}") + private String CATALOG_SEARCH_SERVICESPECREFS = ""; + + + + @Autowired ServiceSpecificationRepoService serviceSpecificationRepoService; @@ -114,6 +121,16 @@ public class ServiceSpecificationApiRouteBuilder extends RouteBuilder { .bean( serviceSpecificationRepoService, "updateOrAddServiceSpecification(${header.serviceSpecId}, ${header.forceId}, ${body} )") .marshal().json( JsonLibrary.Jackson) .convertBodyTo( String.class ); + + + + from( CATALOG_SEARCH_SERVICESPECREFS ) + .log(LoggingLevel.INFO, log, CATALOG_SEARCH_SERVICESPECREFS + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ArrayList.class, true) + .bean( serviceSpecificationRepoService, "searchServiceSpecRefs( ${body} )"); + + } diff --git a/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CandidateRepoService.java b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CandidateRepoService.java index 872a8229686fa2cf112d5769db4efb4f29281068..24cd95d1a87309f68ffe1e02e081d30bc747b59b 100644 --- a/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CandidateRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CandidateRepoService.java @@ -39,18 +39,26 @@ import org.springframework.transaction.annotation.Transactional; import jakarta.validation.Valid; @Service +@Transactional public class CandidateRepoService { - @Autowired - CandidateRepository candidateRepo; + private final CandidateRepository candidateRepo; - @Autowired - CategoryRepoService categsRepoService; - + private final CategoryRepoService categoryRepoService; + private final ServiceSpecificationRepository serviceSpecificationRepo; + @Autowired - ServiceSpecificationRepository serviceSpecificationRepo; + public CandidateRepoService( + CandidateRepository candidateRepo, + CategoryRepoService categoryRepoService, + ServiceSpecificationRepository serviceSpecificationRepo + ) { + this.candidateRepo = candidateRepo; + this.categoryRepoService = categoryRepoService; + this.serviceSpecificationRepo = serviceSpecificationRepo; + } public ServiceCandidate addServiceCandidate( ServiceCandidate c) { @@ -153,11 +161,11 @@ public class CandidateRepoService { if ( serviceCandidateUpd.getCategory() !=null ){ for (ServiceCategoryRef sCategD : serviceCandidateUpd.getCategory()) { - ServiceCategory catObj = this.categsRepoService.findByIdEager(sCategD.getId()); + ServiceCategory catObj = this.categoryRepoService.findByUuid(sCategD.getId()); if ( catObj!=null){ catObj.getServiceCandidateObj().add(savedCand); //add candidate ref to category - catObj = this.categsRepoService.categsRepo.save(catObj); + catObj = this.categoryRepoService.getCategsRepo().save(catObj); } } diff --git a/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CatalogRepoService.java b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CatalogRepoService.java index db4c70237acaab21e585f1ce3e41a0fe10b98ec2..124f96125b32cb49a85d6e6f27c3be4e0e2bb342 100644 --- a/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CatalogRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CatalogRepoService.java @@ -21,8 +21,12 @@ package org.etsi.osl.tmf.scm633.reposervices; import java.time.OffsetDateTime; import java.time.ZoneOffset; +import java.util.ArrayList; import java.util.List; import java.util.Optional; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule; import org.etsi.osl.tmf.common.model.ELifecycle; import org.etsi.osl.tmf.common.model.TimePeriod; import org.etsi.osl.tmf.scm633.model.ServiceCatalog; @@ -30,12 +34,21 @@ import org.etsi.osl.tmf.scm633.model.ServiceCatalogCreate; import org.etsi.osl.tmf.scm633.model.ServiceCatalogUpdate; import org.etsi.osl.tmf.scm633.model.ServiceCategory; import org.etsi.osl.tmf.scm633.model.ServiceCategoryRef; +import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristic; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; import org.etsi.osl.tmf.scm633.repo.CatalogRepository; +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.persistence.EntityManagerFactory; import jakarta.validation.Valid; @Service +@Transactional public class CatalogRepoService { @@ -46,10 +59,8 @@ public class CatalogRepoService { CategoryRepoService categRepoService; @Autowired - ServiceSpecificationRepoService specRepoService; - - @Autowired - CandidateRepoService candidateRepoService; + ServiceSpecificationRepoService specRepoService; + public ServiceCatalog addCatalog(ServiceCatalog c) { @@ -64,10 +75,75 @@ public class CatalogRepoService { return this.catalogRepo.save(sc); } + public String findAllEager() { + + List oids = (List) this.catalogRepo.findByOrderByName(); + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + String res; + try { + res = mapper.writeValueAsString( oids ); + } catch (JsonProcessingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return "{}"; + } + + return res; + } + + + public List findAll() { return (List) this.catalogRepo.findByOrderByName(); } + + public String findByUuidEager(String id) { + + ServiceCatalog sc = this.findById(id); + + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + String res; + try { + res = mapper.writeValueAsString( sc ); + } catch (JsonProcessingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return "{}"; + } + + return res; + } + + + + public String findByNameEager(String aname) { + ServiceCatalog sc = this.findByName(aname); + + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + String res; + try { + res = mapper.writeValueAsString( sc ); + } catch (JsonProcessingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return "{}"; + } + + return res; + + } + + public ServiceCatalog findById(String id) { Optional optionalCat = this.catalogRepo.findByUuid(id); return optionalCat.orElse(null); @@ -136,6 +212,65 @@ public class CatalogRepoService { public ServiceCatalog updateCatalog(ServiceCatalog scatalog) { return this.catalogRepo.save(scatalog); } + + + /** + * return recursively all categories in catalog + * @param catalogName + */ + @Transactional + public String findAllCategoriesByCatalogName(String catalogName) { + String res="[]"; + + Optional scopt = this.catalogRepo.findByName(catalogName); + + if (scopt.isEmpty() ) { + return res; + } + + ServiceCatalog sc = scopt.get(); + + sc.getCategoryRefs(); + + + List allcategories = this.getCategories( sc.getCategoryRefs()); + + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + + + try { + res = mapper.writeValueAsString( allcategories ); + } catch (JsonProcessingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + return res; + + } + + + @Transactional + private List getCategories( @Valid List list) { + List categories = new ArrayList(); + + for (ServiceCategoryRef c : list ) { + ServiceCategory category = this.categRepoService.findByUuid( c.getId()); + categories.add(category); + + if (category.getCategoryRefs()!=null && category.getCategoryRefs().size()>0) { + List subcategories = this.getCategories( category.getCategoryRefs() ); + categories.addAll(subcategories );//add children + } + + } + + return categories; + } diff --git a/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CategoryRepoService.java b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CategoryRepoService.java index cb43791abb4ecb3c54a7414e80badeab7b6b20f6..2ebf74d01b9a64db3389e6f295fe90e46a60842b 100644 --- a/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CategoryRepoService.java +++ b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CategoryRepoService.java @@ -23,67 +23,49 @@ import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule; import org.etsi.osl.tmf.common.model.ELifecycle; import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; import org.etsi.osl.tmf.scm633.model.ServiceCandidate; import org.etsi.osl.tmf.scm633.model.ServiceCandidateRef; import org.etsi.osl.tmf.scm633.model.ServiceCategory; import org.etsi.osl.tmf.scm633.model.ServiceCategoryCreate; import org.etsi.osl.tmf.scm633.model.ServiceCategoryRef; import org.etsi.osl.tmf.scm633.model.ServiceCategoryUpdate; -import org.etsi.osl.tmf.scm633.model.ServiceSpecCharRelationship; -import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristic; -import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristicValue; import org.etsi.osl.tmf.scm633.repo.CandidateRepository; -import org.etsi.osl.tmf.scm633.repo.CatalogRepository; import org.etsi.osl.tmf.scm633.repo.CategoriesRepository; -import org.hibernate.Hibernate; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import jakarta.persistence.EntityManagerFactory; +import org.springframework.transaction.annotation.Transactional; import jakarta.validation.Valid; @Service +@Transactional public class CategoryRepoService { - @Autowired - CategoriesRepository categsRepo; - - - @Autowired - CandidateRepository candidateRepo; - - @Autowired - CatalogRepository catalogRepo; + private final CategoriesRepository categsRepo; + private final CandidateRepository candidateRepo; - private SessionFactory sessionFactory; - /** - * from https://stackoverflow.com/questions/25063995/spring-boot-handle-to-hibernate-sessionfactory - * @param factory - */ - @Autowired - public CategoryRepoService(EntityManagerFactory factory) { - if(factory.unwrap(SessionFactory.class) == null){ - throw new NullPointerException("factory is not a hibernate factory"); - } - this.sessionFactory = factory.unwrap(SessionFactory.class); - } - + @Autowired + public CategoryRepoService(CategoriesRepository categsRepo, CandidateRepository candidateRepo) { + this.categsRepo = categsRepo; + this.candidateRepo = candidateRepo; + } public ServiceCategory addCategory(ServiceCategory c) { - return this.categsRepo.save( c ); + return this.getCategsRepo().save( c ); } public ServiceCategory addCategory(@Valid ServiceCategoryCreate serviceCategory) { @@ -91,71 +73,99 @@ public class CategoryRepoService { ServiceCategory sc = new ServiceCategory() ; sc = updateCategoryDataFromAPICall(sc, serviceCategory); - return this.categsRepo.save( sc ); + return this.getCategsRepo().save( sc ); } + @Transactional public List findAll() { - return (List) this.categsRepo.findByOrderByName(); + return (List) this.getCategsRepo().findByOrderByName(); } + @Transactional public ServiceCategory findByUuid(String id) { - Optional optionalCat = this.categsRepo.findByUuid( id ); + Optional optionalCat = this.getCategsRepo().findByUuid( id ); return optionalCat .orElse(null); } - public ServiceCategory findByIdEager(String id) { -// Optional optionalCat = this.categsRepo.findByIdEager( id ); -// return optionalCat -// .orElse(null); + @Transactional + public String findByIdEager(String id) { + ServiceCategory sc = this.findByUuid( id ); + + String res= "{}"; + + if ( sc == null ) { + return res; + } + - Session session = sessionFactory.openSession(); - Transaction tx = session.beginTransaction(); - ServiceCategory dd = null; - try { - dd = (ServiceCategory) session.get(ServiceCategory.class, id); - Hibernate.initialize( dd.getCategoryObj() ); - Hibernate.initialize( dd.getServiceCandidateObj() ); - for (ServiceCandidate sc : dd.getServiceCandidateObj()) { - Hibernate.initialize(sc ); - Hibernate.initialize(sc.getCategoryObj() ); - Hibernate.initialize(sc.getServiceSpecificationObj() ); - Hibernate.initialize(sc.getServiceSpecificationObj().getServiceSpecCharacteristic() ); - for (ServiceSpecCharacteristic ssc : sc.getServiceSpecificationObj().getServiceSpecCharacteristic() ) { - Hibernate.initialize(ssc.getServiceSpecCharRelationship() ); - for (ServiceSpecCharRelationship srel : ssc.getServiceSpecCharRelationship() ) { - Hibernate.initialize( srel ); - } - Hibernate.initialize(ssc.getServiceSpecCharacteristicValue() ); - for (ServiceSpecCharacteristicValue srel : ssc.getServiceSpecCharacteristicValue() ) { - Hibernate.initialize( srel ); - } - } - Hibernate.initialize(sc.getServiceSpecificationObj().getServiceSpecRelationship() ); - } - - tx.commit(); - } finally { - session.close(); - } - return dd; + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + + try { + res = mapper.writeValueAsString( sc ); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + + return res; } - + + + @Transactional + public String findAllServiceSpecRefsByCategId(String categoryId) { + + + String res="[]"; + List serviceSpecificationRefList = new ArrayList<>(); + ServiceCategory category = this.findByUuid(categoryId); + + if ( category == null ) { + return res; + } + + Set serviceCands = category.getServiceCandidateObj(); + + for (ServiceCandidate serviceCandidate : serviceCands) { + @Valid + ServiceSpecificationRef specRef = serviceCandidate.getServiceSpecificationRef(); + serviceSpecificationRefList.add(specRef); + } + + + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + + try { + res = mapper.writeValueAsString( serviceSpecificationRefList ); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + + return res; + + } public boolean deleteById(String id) { - Optional optionalCat = this.categsRepo.findByUuid( id ); + Optional optionalCat = this.getCategsRepo().findByUuid( id ); if ( optionalCat.get().getCategoryObj().size()>0 ) { return false; //has children } if ( optionalCat.get().getParentId() != null ) { - ServiceCategory parentCat = (this.categsRepo.findByUuid( optionalCat.get().getParentId() )).get(); + ServiceCategory parentCat = (this.getCategsRepo().findByUuid( optionalCat.get().getParentId() )).get(); //remove from parent category for (ServiceCategory ss : parentCat.getCategoryObj()) { @@ -164,24 +174,24 @@ public class CategoryRepoService { break; } } - parentCat = this.categsRepo.save(parentCat); + parentCat = this.getCategsRepo().save(parentCat); } - this.categsRepo.delete( optionalCat.get()); + this.getCategsRepo().delete( optionalCat.get()); return true; } public ServiceCategory updateCategory(String id, @Valid ServiceCategoryUpdate serviceCategory) { - Optional optionalCat = this.categsRepo.findByUuid( id ); + Optional optionalCat = this.getCategsRepo().findByUuid( id ); if ( optionalCat == null ) { return null; } ServiceCategory sc = optionalCat.get(); sc = updateCategoryDataFromAPICall(sc, serviceCategory); - return this.categsRepo.save( sc ); + return this.getCategsRepo().save( sc ); } public ServiceCategory updateCategoryDataFromAPICall( ServiceCategory sc, ServiceCategoryUpdate serviceCatUpd ) @@ -227,14 +237,14 @@ public class CategoryRepoService { } } if (!idexists) { - Optional catToAdd = this.categsRepo.findByUuid( ref.getId() ); + Optional catToAdd = this.getCategsRepo().findByUuid( ref.getId() ); if ( catToAdd.isPresent() ) { ServiceCategory scatadd = catToAdd.get(); sc.getCategoryObj().add( scatadd ); idAddedUpdated.put( ref.getId(), true); scatadd.setParentId( sc.getUuid()); - scatadd = this.categsRepo.save( scatadd ); + scatadd = this.getCategsRepo().save( scatadd ); } } } @@ -292,10 +302,15 @@ public class CategoryRepoService { public ServiceCategory findByName(String aName) { - Optional optionalCat = this.categsRepo.findByName( aName ); + Optional optionalCat = this.getCategsRepo().findByName( aName ); return optionalCat .orElse(null); } + public CategoriesRepository getCategsRepo() { + return categsRepo; + + } + } 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 eb6ca09c1cf0d752a8a84412b2b5b054b6e2b2a5..9b3f2fdf4108328e2a9cfec761d327e04fb31863 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 @@ -34,10 +34,12 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.StringJoiner; import java.util.UUID; - +import java.util.stream.Collectors; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - +import com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.etsi.osl.tmf.common.model.Any; @@ -62,6 +64,7 @@ import org.etsi.osl.tmf.scm633.api.ServiceSpecificationApiRouteBuilderNSD; import org.etsi.osl.tmf.scm633.model.ServiceCandidate; import org.etsi.osl.tmf.scm633.model.ServiceCandidateCreate; import org.etsi.osl.tmf.scm633.model.ServiceCandidateUpdate; +import org.etsi.osl.tmf.scm633.model.ServiceCategory; import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristic; import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristicValue; import org.etsi.osl.tmf.scm633.model.ServiceSpecRelationship; @@ -208,13 +211,12 @@ public class ServiceSpecificationRepoService { } sql += " FROM ServiceSpecification s"; - if (allParams.size() > 0) { - sql += " WHERE "; - for (String pname : allParams.keySet()) { - sql += " " + pname + " LIKE "; - String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); - sql += "'" + pval + "'"; - } + if (allParams.size() > 0) { + String items = allParams.entrySet() + .stream() + .map(entry -> "s." + entry.getKey() + " LIKE '%" + URLDecoder.decode( entry.getValue(), StandardCharsets.UTF_8 )+ "%'" ) + .collect(Collectors.joining(" OR ")); + sql += " WHERE " + items; } sql += " ORDER BY s.name"; @@ -230,10 +232,10 @@ public class ServiceSpecificationRepoService { Map result = new LinkedHashMap(tuple.length); for (int i = 0; i < tuple.length; i++) { String alias = aliases[i]; - if (alias.equals("type")) { - alias = "@type"; - } if (alias != null) { + if (alias.equals("type")) { + alias = "@type"; + } result.put(alias, tuple[i]); } } @@ -271,7 +273,11 @@ public class ServiceSpecificationRepoService { } -// @Transactional(propagation=Propagation.REQUIRED , readOnly=true, + + + + + // @Transactional(propagation=Propagation.REQUIRED , readOnly=true, // noRollbackFor=Exception.class) public ServiceSpecification findByUuid(String id) { Optional optionalCat = this.serviceSpecificationRepo.findByUuid(id); @@ -1464,6 +1470,124 @@ public class ServiceSpecificationRepoService { } + @Transactional + public String searchServiceSpecRefs(List searchText) { + String res = "[]"; + + try { + + List specs= this.searchSpecsInCategories( searchText); + + ObjectMapper mapper = new ObjectMapper(); + // Registering Hibernate4Module to support lazy objects + // this will fetch all lazy objects before marshaling + mapper.registerModule(new Hibernate5JakartaModule()); + res = mapper.writeValueAsString( specs ); + + + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + + return res; + } + + + /** + * + * This findAll is optimized on fields. + * @param fields + * @param allParams + * @return + * @throws UnsupportedEncodingException + */ + @Transactional + public List searchSpecsInCategories( List searchList ) + throws UnsupportedEncodingException { + + if ( searchList == null || searchList.size() ==0) { + return new ArrayList<>(); + } + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + + try { + String sql = "SELECT s.id as serviceSpecificationId, s.name as serviceName, s.description as serviceDescription"; + + + + sql += " FROM ServiceCategory as scateg JOIN scateg.serviceCandidateObj as scandidate JOIN scandidate.serviceSpecificationObj as s "; + sql += " WHERE " ; + + + // Build the name LIKE clause + StringJoiner nameJoiner = new StringJoiner(" AND "); + for (String term : searchList) { + nameJoiner.add("s.name LIKE '%" + term + "%'"); + } + + // Build the description LIKE clause + StringJoiner descriptionJoiner = new StringJoiner(" AND "); + for (String term : searchList) { + descriptionJoiner.add("s.description LIKE '%" + term + "%'"); + } + + // Combine both clauses with OR + sql += "(" + nameJoiner.toString() + ") OR (" + descriptionJoiner.toString() + ")"; + + sql += " ORDER BY s.name"; + +// List specs = session +// .createQuery( sql, ServiceSpecification.class) +// .getResultList(); + + + List mapaEntity = session + .createQuery(sql ) + .setResultTransformer( new ResultTransformer() { + + @Override + public Object transformTuple(Object[] tuple, String[] aliases) { + Map result = new LinkedHashMap(tuple.length); + for (int i = 0; i < tuple.length; i++) { + String alias = aliases[i]; + if (alias != null) { + if (alias.equals("type")) { + alias = "@type"; + } + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + +// //this will fetch the whole object fields + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + + } + } diff --git a/src/main/resources/application-testing.yml b/src/main/resources/application-testing.yml index eb9bc5b6cb19c053865282a1df303ca9e603327c..8a937d2aa3b4b38199a50cff0345eccc1bd70f9c 100644 --- a/src/main/resources/application-testing.yml +++ b/src/main/resources/application-testing.yml @@ -80,15 +80,57 @@ oauthsign: key: "XXX" #QUEUE MESSAGES -CATALOG_GET_SERVICEORDERS: "jms:queue:CATALOG.GET.SERVICEORDERS" -CATALOG_GET_SERVICEORDER_BY_ID: "jms:queue:CATALOG.GET.SERVICEORDER_BY_ID" -CATALOG_ADD_SERVICEORDER: "jms:queue:CATALOG.ADD.SERVICEORDER" -CATALOG_UPD_SERVICEORDER_BY_ID: "jms:queue:CATALOG.UPD.SERVICEORDER_BY_ID" CATALOG_GET_SERVICESPEC_BY_ID: "jms:queue:CATALOG.GET.SERVICESPEC_BY_ID" CATALOG_ADD_SERVICESPEC: "jms:queue:CATALOG.ADD.SERVICESPEC" CATALOG_UPD_SERVICESPEC: "jms:queue:CATALOG.UPD.SERVICESPEC" CATALOG_UPDADD_SERVICESPEC: "jms:queue:CATALOG.UPDADD.SERVICESPEC" +CATALOG_SERVICE_QUEUE_ITEMS_GET: "jms:queue:CATALOG.SERVICEQUEUEITEMS.GET" +CATALOG_SERVICE_QUEUE_ITEM_UPD: "jms:queue:CATALOG.SERVICEQUEUEITEM.UPDATE" +CATALOG_SERVICE_QUEUE_ITEM_DELETE: "jms:queue:CATALOG.SERVICEQUEUEITEM.DELETE" +CATALOG_GET_PARTNER_ORGANIZATON_BY_ID: "jms:queue:CATALOG.GET.PARTNER_ORGANIZATION_BY_ID" +CATALOG_UPDATE_PARTNER_ORGANIZATION: "jms:queue:CATALOG.UPD.PARTNER_ORGANIZATION" +CATALOG_SERVICES_TO_TERMINATE: "jms:queue:CATALOG.GET.SERVICETOTERMINATE" +CATALOG_SERVICES_OF_PARTNERS: "jms:queue:CATALOG.GET.SERVICESOFPARTNERS" +CATALOG_GET_EXTERNAL_SERVICE_PARTNERS: "jms:queue:CATALOG.GET.EXTERNALSERVICEPARTNERS" +CATALOG_UPD_EXTERNAL_SERVICESPEC: "jms:queue:CATALOG.UPD.EXTERNAL_SERVICESPEC" + +#SERVICE_INVENTORY +CATALOG_ADD_SERVICE: "jms:queue:CATALOG.ADD.SERVICE" +CATALOG_UPD_SERVICE: "jms:queue:CATALOG.UPD.SERVICE" +CATALOG_GET_SERVICE_BY_ID: "jms:queue:CATALOG.GET.SERVICE" +CATALOG_GET_SERVICE_BY_ORDERID: "jms:queue:CATALOG.GET.SERVICE_BY_ORDERID" + + +#SERVICE ORDERS +CATALOG_GET_SERVICEORDERS: "jms:queue:CATALOG.GET.SERVICEORDERS" +CATALOG_GET_SERVICEORDER_BY_ID: "jms:queue:CATALOG.GET.SERVICEORDER_BY_ID" +CATALOG_ADD_SERVICEORDER: "jms:queue:CATALOG.ADD.SERVICEORDER" +CATALOG_UPD_SERVICEORDER_BY_ID: "jms:queue:CATALOG.UPD.SERVICEORDER_BY_ID" +CATALOG_GET_INITIAL_SERVICEORDERS_IDS: "jms:queue:CATALOG.GET.INITIAL_SERVICEORDERS" +CATALOG_GET_SERVICEORDER_IDS_BY_STATE: "jms:queue:CATALOG.GET.ACKNOWLEDGED_SERVICEORDERS" +CATALOG_GET_PRODUCTCATALOGS: "jms:queue:CATALOG.GET.PRODUCTCATALOGS" +CATALOG_GET_PRODUCTCATALOG_BY_ID: "jms:queue:CATALOG.GET.PRODUCTCATALOG_BY_ID" +CATALOG_GET_PRODUCTCATALOG_BY_NAME: "jms:queue:CATALOG.GET.PRODUCTCATALOG_BY_NAME" +CATALOG_GET_PRODUCTCATEGORIES: "jms:queue:CATALOG.GET.PRODUCTCATEGORIES" +CATALOG_GET_PRODUCTCATEGORY_BY_ID: "jms:queue:CATALOG.GET.PRODUCTCATEGORY_BY_ID" +CATALOG_GET_PRODUCTOFFERINGS_BYCATEGORY_ID: "jms:queue:CATALOG.GET.PRODUCTOFFERINGS.CATEGORY_ID" +CATALOG_SEARCH_PRODUCTOFFERINGS: "jms:queue:CATALOG.CATALOG_SEARCH_PRODUCTOFFERINGS" + + +#SERVICE CATALOGS, CATEGORIES +CATALOG_GET_SERVICECATALOGS: "jms:queue:CATALOG.GET.SERVICECATALOGS" +CATALOG_GET_SERVICECATALOG_BY_ID: "jms:queue:CATALOG.GET.SERVICECATALOG_BY_ID" +CATALOG_GET_SERVICECATALOG_BY_NAME: "jms:queue:CATALOG.GET.SERVICECATALOG_BY_NAME" + +CATALOG_GET_SERVICECATEGORIES: "jms:queue:CATALOG.GET.SERVICECATEGORIES" +CATALOG_GET_SERVICECATEGORY_BY_ID: "jms:queue:CATALOG.GET.SERVICECATEGORY_BY_ID" + +CATALOG_GET_SERVICESPECREFS_BYCATEGORY_ID: "jms:queue:CATALOG.GETSERVICESPECREFS.SERVICECATEGORY_BY_ID" +CATALOG_SEARCH_SERVICESPECREFS: "jms:queue:CATALOG.CATALOG_SEARCH_SERVICESPECREFS" + + +#PRODUCT CATALOGS CATALOG_GET_PRODUCTSPEC_BY_ID: "jms:queue:CATALOG.GET.PRODUCTSPEC_BY_ID" CATALOG_ADD_PRODUCTSPEC: "jms:queue:CATALOG.ADD.PRODUCTSPEC" CATALOG_UPD_PRODUCTSPEC: "jms:queue:CATALOG.UPD.PRODUCTSPEC" @@ -100,23 +142,11 @@ CATALOG_ADD_PRODUCTORDER: "jms:queue:CATALOG.ADD.PRODUCTORDER" CATALOG_UPD_PRODUCTORDER_BY_ID: "jms:queue:CATALOG.UPD.PRODUCTORDER_BY_ID" CATALOG_GET_INITIAL_PRODUCTORDERS_IDS: "jms:queue:CATALOG.GET.INITIAL_PRODUCTORDERS" CATALOG_GET_PRODUCTORDER_IDS_BY_STATE: "jms:queue:CATALOG.GET.ACKNOWLEDGED_PRODUCTORDERS" -CATALOG_GET_INITIAL_SERVICEORDERS_IDS: "jms:queue:CATALOG.GET.INITIAL_SERVICEORDERS" -CATALOG_GET_SERVICEORDER_IDS_BY_STATE: "jms:queue:CATALOG.GET.ACKNOWLEDGED_SERVICEORDERS" -CATALOG_ADD_SERVICE: "jms:queue:CATALOG.ADD.SERVICE" -CATALOG_UPD_SERVICE: "jms:queue:CATALOG.UPD.SERVICE" -CATALOG_GET_SERVICE_BY_ID: "jms:queue:CATALOG.GET.SERVICE" -CATALOG_GET_SERVICE_BY_ORDERID: "jms:queue:CATALOG.GET.SERVICE_BY_ORDERID" -CATALOG_SERVICE_QUEUE_ITEMS_GET: "jms:queue:CATALOG.SERVICEQUEUEITEMS.GET" -CATALOG_SERVICE_QUEUE_ITEM_UPD: "jms:queue:CATALOG.SERVICEQUEUEITEM.UPDATE" -CATALOG_SERVICE_QUEUE_ITEM_DELETE: "jms:queue:CATALOG.SERVICEQUEUEITEM.DELETE" -CATALOG_GET_PARTNER_ORGANIZATON_BY_ID: "jms:queue:CATALOG.GET.PARTNER_ORGANIZATION_BY_ID" -CATALOG_UPDATE_PARTNER_ORGANIZATION: "jms:queue:CATALOG.UPD.PARTNER_ORGANIZATION" -CATALOG_SERVICES_TO_TERMINATE: "jms:queue:CATALOG.GET.SERVICETOTERMINATE" -CATALOG_SERVICES_OF_PARTNERS: "jms:queue:CATALOG.GET.SERVICESOFPARTNERS" -CATALOG_GET_EXTERNAL_SERVICE_PARTNERS: "jms:queue:CATALOG.GET.EXTERNALSERVICEPARTNERS" -CATALOG_UPD_EXTERNAL_SERVICESPEC: "jms:queue:CATALOG.UPD.EXTERNAL_SERVICESPEC" + + +#PM_MEASUREMENT_COLLECTION PM_MEASUREMENT_COLLECTION_GET_JOB_BY_ID: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.GET_BY_ID" PM_MEASUREMENT_COLLECTION_JOBS_GET: "jms:queue:PM.MEASUREMENTCOLLECTIONJOBS.GET" PM_MEASUREMENT_COLLECTION_JOB_ADD: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.ADD" @@ -157,7 +187,9 @@ EVENT_PRODUCT_ORDER_ATTRIBUTE_VALUE_CHANGED: "jms:topic:EVENT.PRODUCTORDER.ATTRC #QUEUE MESSSAGES WITH VNFNSD CATALOG NFV_CATALOG_GET_NSD_BY_ID: "jms:queue:NFVCATALOG.GET.NSD_BY_ID" -GET_USER_BY_USERNAME: "direct:get_user_byusername" + +#MISC +GET_USER_BY_USERNAME: "jms:queue:GET.USER_BY_USERNAME" #RESOURCES MESSAGES CATALOG_ADD_RESOURCE: "jms:queue:CATALOG.ADD.RESOURCE" @@ -181,7 +213,6 @@ CATALOG_UPD_RESOURCEACTIVATION: "jms:queue:CATALOG.UPD.RESOURCEACTIVATION" CATALOG_UPDADD_RESOURCEACTIVATION: "jms:queue:CATALOG.UPDADD.RESOURCEACTIVATION" CATALOG_GET_RESOURCEACTIVATION_BY_ID: "jms:queue:CATALOG.GET.RESOURCEACTIVATION" - #LCM MESSAGES CATALOG_GET_LCMRULE_BY_ID: "jms:queue:CATALOG.GET.LCMRULE" CATALOG_GET_LCMRULES_BY_SPECID_PHASE: "jms:queue:CATALOG.GET.LCMRULES_BY_SPECID_PHASE" @@ -200,3 +231,8 @@ NFV_CATALOG_NS_LCMCHANGED: "jms:topic:NFV_CATALOG_NS_LCMCHANGED" #RESERVATION_API RESERVATION_CREATE: "jms:queue:RESERVATION.ADD" RESERVATION_AVAILABILITY_CHECK: "jms:queue:RESERVATION.AVAILABILITYCHECK" + + +--- + + diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b52100773ffd9fb2e3467c8aa1cafb165e543934..3509cc98d2f985e51f02c0455fe7633addb4d02a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -111,15 +111,46 @@ oauthsign: key: "EK97Y7Y9WPGG1MEG" #QUEUE MESSAGES -CATALOG_GET_SERVICEORDERS: "jms:queue:CATALOG.GET.SERVICEORDERS" -CATALOG_GET_SERVICEORDER_BY_ID: "jms:queue:CATALOG.GET.SERVICEORDER_BY_ID" -CATALOG_ADD_SERVICEORDER: "jms:queue:CATALOG.ADD.SERVICEORDER" -CATALOG_UPD_SERVICEORDER_BY_ID: "jms:queue:CATALOG.UPD.SERVICEORDER_BY_ID" CATALOG_GET_SERVICESPEC_BY_ID: "jms:queue:CATALOG.GET.SERVICESPEC_BY_ID" CATALOG_ADD_SERVICESPEC: "jms:queue:CATALOG.ADD.SERVICESPEC" CATALOG_UPD_SERVICESPEC: "jms:queue:CATALOG.UPD.SERVICESPEC" CATALOG_UPDADD_SERVICESPEC: "jms:queue:CATALOG.UPDADD.SERVICESPEC" +CATALOG_SERVICE_QUEUE_ITEMS_GET: "jms:queue:CATALOG.SERVICEQUEUEITEMS.GET" +CATALOG_SERVICE_QUEUE_ITEM_UPD: "jms:queue:CATALOG.SERVICEQUEUEITEM.UPDATE" +CATALOG_SERVICE_QUEUE_ITEM_DELETE: "jms:queue:CATALOG.SERVICEQUEUEITEM.DELETE" +CATALOG_GET_PARTNER_ORGANIZATON_BY_ID: "jms:queue:CATALOG.GET.PARTNER_ORGANIZATION_BY_ID" +CATALOG_UPDATE_PARTNER_ORGANIZATION: "jms:queue:CATALOG.UPD.PARTNER_ORGANIZATION" +CATALOG_SERVICES_TO_TERMINATE: "jms:queue:CATALOG.GET.SERVICETOTERMINATE" +CATALOG_SERVICES_OF_PARTNERS: "jms:queue:CATALOG.GET.SERVICESOFPARTNERS" +CATALOG_GET_EXTERNAL_SERVICE_PARTNERS: "jms:queue:CATALOG.GET.EXTERNALSERVICEPARTNERS" +CATALOG_UPD_EXTERNAL_SERVICESPEC: "jms:queue:CATALOG.UPD.EXTERNAL_SERVICESPEC" + +#SERVICE_INVENTORY +CATALOG_ADD_SERVICE: "jms:queue:CATALOG.ADD.SERVICE" +CATALOG_UPD_SERVICE: "jms:queue:CATALOG.UPD.SERVICE" +CATALOG_GET_SERVICE_BY_ID: "jms:queue:CATALOG.GET.SERVICE" +CATALOG_GET_SERVICE_BY_ORDERID: "jms:queue:CATALOG.GET.SERVICE_BY_ORDERID" + + +#SERVICE ORDERS +CATALOG_GET_SERVICEORDERS: "jms:queue:CATALOG.GET.SERVICEORDERS" +CATALOG_GET_SERVICEORDER_BY_ID: "jms:queue:CATALOG.GET.SERVICEORDER_BY_ID" +CATALOG_ADD_SERVICEORDER: "jms:queue:CATALOG.ADD.SERVICEORDER" +CATALOG_UPD_SERVICEORDER_BY_ID: "jms:queue:CATALOG.UPD.SERVICEORDER_BY_ID" +CATALOG_GET_INITIAL_SERVICEORDERS_IDS: "jms:queue:CATALOG.GET.INITIAL_SERVICEORDERS" +CATALOG_GET_SERVICEORDER_IDS_BY_STATE: "jms:queue:CATALOG.GET.ACKNOWLEDGED_SERVICEORDERS" + +#SERVICE CATALOGS, CATEGORIES +CATALOG_GET_SERVICECATALOGS: "jms:queue:CATALOG.GET.SERVICECATALOGS" +CATALOG_GET_SERVICECATALOG_BY_ID: "jms:queue:CATALOG.GET.SERVICECATALOG_BY_ID" +CATALOG_GET_SERVICECATALOG_BY_NAME: "jms:queue:CATALOG.GET.SERVICECATALOG_BY_NAME" +CATALOG_GET_SERVICECATEGORIES: "jms:queue:CATALOG.GET.SERVICECATEGORIES" +CATALOG_GET_SERVICECATEGORY_BY_ID: "jms:queue:CATALOG.GET.SERVICECATEGORY_BY_ID" +CATALOG_GET_SERVICESPECREFS_BYCATEGORY_ID: "jms:queue:CATALOG.GETSERVICESPECREFS.SERVICECATEGORY_BY_ID" +CATALOG_SEARCH_SERVICESPECREFS: "jms:queue:CATALOG.CATALOG_SEARCH_SERVICESPECREFS" + +#PRODUCT CATALOGS CATALOG_GET_PRODUCTSPEC_BY_ID: "jms:queue:CATALOG.GET.PRODUCTSPEC_BY_ID" CATALOG_ADD_PRODUCTSPEC: "jms:queue:CATALOG.ADD.PRODUCTSPEC" CATALOG_UPD_PRODUCTSPEC: "jms:queue:CATALOG.UPD.PRODUCTSPEC" @@ -131,25 +162,16 @@ CATALOG_ADD_PRODUCTORDER: "jms:queue:CATALOG.ADD.PRODUCTORDER" CATALOG_UPD_PRODUCTORDER_BY_ID: "jms:queue:CATALOG.UPD.PRODUCTORDER_BY_ID" CATALOG_GET_INITIAL_PRODUCTORDERS_IDS: "jms:queue:CATALOG.GET.INITIAL_PRODUCTORDERS" CATALOG_GET_PRODUCTORDER_IDS_BY_STATE: "jms:queue:CATALOG.GET.ACKNOWLEDGED_PRODUCTORDERS" -CATALOG_GET_INITIAL_SERVICEORDERS_IDS: "jms:queue:CATALOG.GET.INITIAL_SERVICEORDERS" -CATALOG_GET_SERVICEORDER_IDS_BY_STATE: "jms:queue:CATALOG.GET.ACKNOWLEDGED_SERVICEORDERS" -CATALOG_ADD_SERVICE: "jms:queue:CATALOG.ADD.SERVICE" -CATALOG_UPD_SERVICE: "jms:queue:CATALOG.UPD.SERVICE" -CATALOG_GET_SERVICE_BY_ID: "jms:queue:CATALOG.GET.SERVICE" -CATALOG_GET_SERVICE_BY_ORDERID: "jms:queue:CATALOG.GET.SERVICE_BY_ORDERID" -CATALOG_SERVICE_QUEUE_ITEMS_GET: "jms:queue:CATALOG.SERVICEQUEUEITEMS.GET" -CATALOG_SERVICE_QUEUE_ITEM_UPD: "jms:queue:CATALOG.SERVICEQUEUEITEM.UPDATE" -CATALOG_SERVICE_QUEUE_ITEM_DELETE: "jms:queue:CATALOG.SERVICEQUEUEITEM.DELETE" -CATALOG_GET_PARTNER_ORGANIZATON_BY_ID: "jms:queue:CATALOG.GET.PARTNER_ORGANIZATION_BY_ID" -CATALOG_UPDATE_PARTNER_ORGANIZATION: "jms:queue:CATALOG.UPD.PARTNER_ORGANIZATION" -CATALOG_SERVICES_TO_TERMINATE: "jms:queue:CATALOG.GET.SERVICETOTERMINATE" -CATALOG_SERVICES_OF_PARTNERS: "jms:queue:CATALOG.GET.SERVICESOFPARTNERS" - -CATALOG_GET_EXTERNAL_SERVICE_PARTNERS: "jms:queue:CATALOG.GET.EXTERNALSERVICEPARTNERS" -CATALOG_UPD_EXTERNAL_SERVICESPEC: "jms:queue:CATALOG.UPD.EXTERNAL_SERVICESPEC" - +CATALOG_GET_PRODUCTCATALOGS: "jms:queue:CATALOG.GET.PRODUCTCATALOGS" +CATALOG_GET_PRODUCTCATALOG_BY_ID: "jms:queue:CATALOG.GET.PRODUCTCATALOG_BY_ID" +CATALOG_GET_PRODUCTCATALOG_BY_NAME: "jms:queue:CATALOG.GET.PRODUCTCATALOG_BY_NAME" +CATALOG_GET_PRODUCTCATEGORIES: "jms:queue:CATALOG.GET.PRODUCTCATEGORIES" +CATALOG_GET_PRODUCTCATEGORY_BY_ID: "jms:queue:CATALOG.GET.PRODUCTCATEGORY_BY_ID" +CATALOG_GET_PRODUCTOFFERINGS_BYCATEGORY_ID: "jms:queue:CATALOG.GET.PRODUCTOFFERINGS.CATEGORY_ID" +CATALOG_SEARCH_PRODUCTOFFERINGS: "jms:queue:CATALOG.CATALOG_SEARCH_PRODUCTOFFERINGS" +#PM_MEASUREMENT_COLLECTION PM_MEASUREMENT_COLLECTION_GET_JOB_BY_ID: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.GET_BY_ID" PM_MEASUREMENT_COLLECTION_JOBS_GET: "jms:queue:PM.MEASUREMENTCOLLECTIONJOBS.GET" PM_MEASUREMENT_COLLECTION_JOB_ADD: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.ADD" @@ -235,6 +257,7 @@ NFV_CATALOG_NS_LCMCHANGED: "jms:topic:NFV_CATALOG_NS_LCMCHANGED" RESERVATION_CREATE: "jms:queue:RESERVATION.ADD" RESERVATION_AVAILABILITY_CHECK: "jms:queue:RESERVATION.AVAILABILITYCHECK" + --- diff --git a/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java index 807e356072382992b7e28cef11a50efe9ba29558..fdf65d7519654a24899e69f58d0f9765873d86a9 100644 --- a/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java +++ b/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java @@ -164,7 +164,7 @@ public class ServiceCatalogIntegrationTest { ServiceCategory categ = categRepoService.findByName( "Generic Services" ); assertThat( categ.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); - ServiceCategory categ2 = categRepoService.findByIdEager( categ.getId() ); + ServiceCategory categ2 = categRepoService.findByUuid( categ.getId() ); assertThat( categ2.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); boolean vinnisbFound = false; @@ -1014,7 +1014,7 @@ public class ServiceCatalogIntegrationTest { logger.info("Test: testGSTUpdate " ); ServiceCategory categ = categRepoService.findByName( "Generic Services" ); - ServiceCategory categ2 = categRepoService.findByIdEager( categ.getId() ); + ServiceCategory categ2 = categRepoService.findByUuid( categ.getId() ); assertThat( categ2.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); ServiceSpecification spec = this.specRepoService.findByNameAndVersion("A GST(NEST) Service Example", "5.0.0" );