Commit a0ca826f authored by Kostis Trantzas's avatar Kostis Trantzas
Browse files

Merge branch...

Merge branch '94-error-starting-up-the-service-in-some-db-heavy-instances-develop-branch' into 'develop'

Resolve "Error starting up the service in some db-heavy instances (develop branch)"

See merge request !92
parents c7b4536e 02974da9
Loading
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -36,6 +36,7 @@ import org.etsi.osl.tmf.rcm634.model.ResourceSpecification;
import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate;
import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate;
import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef;
import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef;
import org.etsi.osl.tmf.rcm634.repo.ResourceCatalogRepository;
import org.etsi.osl.tmf.rcm634.repo.ResourceCatalogRepository;
import org.etsi.osl.tmf.rcm634.repo.ResourceCategoriesRepository;
import org.etsi.osl.tmf.rcm634.repo.ResourceSpecificationRepository;
import org.etsi.osl.tmf.rcm634.repo.ResourceSpecificationRepository;
import org.etsi.osl.tmf.rcm634.reposervices.ResourceCandidateRepoService;
import org.etsi.osl.tmf.rcm634.reposervices.ResourceCandidateRepoService;
import org.etsi.osl.tmf.rcm634.reposervices.ResourceCatalogRepoService;
import org.etsi.osl.tmf.rcm634.reposervices.ResourceCatalogRepoService;
@@ -71,6 +72,9 @@ public class BootstrapResources {
	@Autowired
	@Autowired
	ResourceSpecificationRepository resourceSpecificationRepo;
	ResourceSpecificationRepository resourceSpecificationRepo;


    @Autowired
	ResourceCategoriesRepository resourceCategoriesRepository;
	
	@Autowired
	@Autowired
	ObjectMapper objectMapper;
	ObjectMapper objectMapper;


@@ -249,6 +253,7 @@ public class BootstrapResources {
	}
	}
	
	


    @Transactional
	private void createBootResourceSpec( ResourceCategory scategory, String aname, String afile) {		 
	private void createBootResourceSpec( ResourceCategory scategory, String aname, String afile) {		 
		
		
		ResourceSpecificationCreate rsc = this.resourceSpecRepoService.readFromLocalLogicalResourceSpec( afile );
		ResourceSpecificationCreate rsc = this.resourceSpecRepoService.readFromLocalLogicalResourceSpec( afile );
@@ -259,6 +264,7 @@ public class BootstrapResources {
		
		
	}
	}


    @Transactional
	private void addToCategory(ResourceCategory scategory,  ResourceSpecification resourceSpecificationObj) {	
	private void addToCategory(ResourceCategory scategory,  ResourceSpecification resourceSpecificationObj) {	
		
		
		//Turn the ResourceSpecification to a ResourceCanditate to save it to the ResourceCatalogRepo			
		//Turn the ResourceSpecification to a ResourceCanditate to save it to the ResourceCatalogRepo			
+2 −2
Original line number Original line Diff line number Diff line
@@ -716,13 +716,13 @@ public class ProductOfferingRepoService {
          
          
                    
                    
          // Build the name LIKE clause
          // Build the name LIKE clause
          StringJoiner nameJoiner = new StringJoiner(" AND ");
          StringJoiner nameJoiner = new StringJoiner(" OR ");
          for (String term : searchList) {
          for (String term : searchList) {
              nameJoiner.add("p.name LIKE '%" + term + "%'");
              nameJoiner.add("p.name LIKE '%" + term + "%'");
          }
          }


          // Build the description LIKE clause
          // Build the description LIKE clause
          StringJoiner descriptionJoiner = new StringJoiner(" AND ");
          StringJoiner descriptionJoiner = new StringJoiner(" OR ");
          for (String term : searchList) {
          for (String term : searchList) {
              descriptionJoiner.add("p.description LIKE '%" + term + "%'");
              descriptionJoiner.add("p.description LIKE '%" + term + "%'");
          }
          }
+2 −1
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional;
import jakarta.validation.Valid;
import jakarta.validation.Valid;


@Service
@Service
@Transactional
public class ResourceCandidateRepoService {
public class ResourceCandidateRepoService {




@@ -157,7 +158,7 @@ public class ResourceCandidateRepoService {
	
	
				if ( catObj!=null){
				if ( catObj!=null){
					catObj.getResourceCandidateObj().add(savedCand); //add candidate ref to category
					catObj.getResourceCandidateObj().add(savedCand); //add candidate ref to category
					catObj = this.categsRepoService.categsRepo.save(catObj); 
					catObj = this.categsRepoService.categsRepoSave(catObj); 
					
					
				}
				}
			}
			}
+9 −4
Original line number Original line Diff line number Diff line
@@ -33,9 +33,11 @@ import org.etsi.osl.tmf.rcm634.model.ResourceCategoryRef;
import org.etsi.osl.tmf.rcm634.repo.ResourceCatalogRepository;
import org.etsi.osl.tmf.rcm634.repo.ResourceCatalogRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.validation.Valid;
import jakarta.validation.Valid;


@Service
@Service
@Transactional
public class ResourceCatalogRepoService {
public class ResourceCatalogRepoService {


	@Autowired
	@Autowired
@@ -90,9 +92,11 @@ public class ResourceCatalogRepoService {
		return this.catalogRepo.save(sc);
		return this.catalogRepo.save(sc);
	}
	}


	public ResourceCatalog updateCatalog(ResourceCatalog serviceCatalog) {
	@Transactional
	public ResourceCatalog updateCatalog(ResourceCatalog resourceCatalog) {
		
		
		return this.catalogRepo.save(serviceCatalog);
	    resourceCatalog.getCategoryObj().size();
		return this.catalogRepo.save(resourceCatalog);
	}
	}


	public ResourceCatalog updateCatalogDataFromAPICall(ResourceCatalog rc, ResourceCatalogUpdate resCatalog) {
	public ResourceCatalog updateCatalogDataFromAPICall(ResourceCatalog rc, ResourceCatalogUpdate resCatalog) {
@@ -173,6 +177,7 @@ public class ResourceCatalogRepoService {
---------------------------------------------------------------------------------------------------------------*/
---------------------------------------------------------------------------------------------------------------*/
	
	


	@Transactional
	public ResourceCatalog findByName(String aName) {
	public ResourceCatalog findByName(String aName) {
		Optional<ResourceCatalog> optionalCat = this.catalogRepo.findByName( aName );
		Optional<ResourceCatalog> optionalCat = this.catalogRepo.findByName( aName );
		if ( optionalCat.isPresent()) {
		if ( optionalCat.isPresent()) {
+8 −0
Original line number Original line Diff line number Diff line
@@ -43,10 +43,12 @@ import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.Transaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.EntityManagerFactory;
import jakarta.validation.Valid;
import jakarta.validation.Valid;


@Service
@Service
@Transactional
public class ResourceCategoryRepoService {
public class ResourceCategoryRepoService {




@@ -91,6 +93,7 @@ public class ResourceCategoryRepoService {
		
		
	}
	}


    @Transactional
	public List<ResourceCategory> findAll() {
	public List<ResourceCategory> findAll() {
		return (List<ResourceCategory>) this.categsRepo.findAll();
		return (List<ResourceCategory>) this.categsRepo.findAll();
	}
	}
@@ -294,4 +297,9 @@ public class ResourceCategoryRepoService {
	}
	}




  public ResourceCategory categsRepoSave(ResourceCategory catObj) {
    return categsRepo.save(catObj); 
  }


}
}
Loading