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