Loading src/main/java/org/etsi/osl/hypo/api/tmf/agreement/api/services/AgreementService.java +17 −18 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import jakarta.transaction.Transactional; import java.util.List; import java.util.Map; import java.util.Optional; import org.apache.commons.collections4.CollectionUtils; import org.etsi.osl.hypo.api.tmf.agreement.api.repository.AgreementRepository; import org.etsi.osl.hypo.api.tmf.agreement.schema.Agreement; import org.etsi.osl.hypo.api.tmf.common.api.mapper.UpdateMapper; Loading Loading @@ -70,26 +71,24 @@ public class AgreementService { @Transactional public Agreement createAgreement(Agreement agreement) { checkIfTmfIdExists(agreement.getTmfId()); if (agreement.getEngagedParty() != null && !agreement.getEngagedParty().isEmpty()) { agreement = findRelatedPartyAndAddItToResource(agreement); } checkIfIdExists(agreement.getId()); findRelatedPartyAndAddItToResource(agreement); agreementRepository.persist(agreement); return agreement; } private Agreement findRelatedPartyAndAddItToResource(Agreement agreement) { List<String> partyIds = agreement.getEngagedParty().stream().map(RelatedPartyEntity::getTmfId).toList(); private void findRelatedPartyAndAddItToResource(Agreement agreement) { List<RelatedPartyEntity> engagedParty = agreement.getEngagedParty(); if (CollectionUtils.isNotEmpty(engagedParty)) { List<String> partyIds = engagedParty.stream().map(RelatedPartyEntity::getId).toList(); // find and relate parties List<RelatedPartyEntity> relatedPartyEntities = relatedPartyRepository.findByIdsList(partyIds); List<RelatedPartyEntity> relatedPartyEntities = relatedPartyRepository.findByIdsList(partyIds); agreement.getEngagedParty().clear(); agreement.getEngagedParty().addAll(relatedPartyEntities); return agreement; engagedParty.clear(); engagedParty.addAll(relatedPartyEntities); } } @Transactional Loading Loading @@ -117,13 +116,13 @@ public class AgreementService { return agreement; } private void checkIfTmfIdExists(String tmfId) { if (tmfIdExists(tmfId)) { throw new DuplicateKeyException(AGREEMENT_WITH_ID + tmfId + " already exists"); private void checkIfIdExists(String id) { if (iddExists(id)) { throw new DuplicateKeyException(AGREEMENT_WITH_ID + id + " already exists"); } } public boolean tmfIdExists(String id) { public boolean iddExists(String id) { return agreementRepository.findById(id).isPresent(); } } src/main/java/org/etsi/osl/hypo/api/tmf/agreement/api/services/AgreementSpecificationService.java +17 −20 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import jakarta.transaction.Transactional; import java.util.List; import java.util.Map; import java.util.Optional; import org.apache.commons.collections4.CollectionUtils; import org.etsi.osl.hypo.api.tmf.agreement.api.repository.AgreementSpecificationRepository; import org.etsi.osl.hypo.api.tmf.agreement.schema.AgreementSpecification; import org.etsi.osl.hypo.api.tmf.common.api.mapper.UpdateMapper; Loading Loading @@ -76,30 +77,26 @@ public class AgreementSpecificationService { @Transactional public AgreementSpecification createAgreementSpecification( AgreementSpecification agreementSpecification) { checkIfTmfIdExists(agreementSpecification.getTmfId()); checkIfIdExists(agreementSpecification.getId()); if (agreementSpecification.getRelatedParty() != null && !agreementSpecification.getRelatedParty().isEmpty()) { agreementSpecification = findRelatedPartyAndAddItToResource(agreementSpecification); } findRelatedPartyAndAddItToResource(agreementSpecification); agreementSpecificationRepository.persist(agreementSpecification); return agreementSpecification; } private AgreementSpecification findRelatedPartyAndAddItToResource( AgreementSpecification agreementSpecification) { List<String> partyIds = agreementSpecification.getRelatedParty().stream() .map(RelatedPartyEntity::getTmfId) .toList(); private void findRelatedPartyAndAddItToResource(AgreementSpecification agreementSpecification) { List<RelatedPartyEntity> relatedParty = agreementSpecification.getRelatedParty(); if (CollectionUtils.isNotEmpty(relatedParty)) { List<String> partyIds = relatedParty.stream().map(RelatedPartyEntity::getId).toList(); // find and relate parties List<RelatedPartyEntity> relatedPartyEntities = relatedPartyRepository.findByIdsList(partyIds); List<RelatedPartyEntity> relatedPartyEntities = relatedPartyRepository.findByIdsList(partyIds); agreementSpecification.getRelatedParty().clear(); agreementSpecification.getRelatedParty().addAll(relatedPartyEntities); return agreementSpecification; relatedParty.clear(); relatedParty.addAll(relatedPartyEntities); } } @Transactional Loading Loading @@ -130,13 +127,13 @@ public class AgreementSpecificationService { return agreementSpecification; } private void checkIfTmfIdExists(String tmfId) { if (tmfIdExists(tmfId)) { throw new DuplicateKeyException(AGREEMENT_SPECIFICATION_WITH_ID + tmfId + " already exists"); private void checkIfIdExists(String id) { if (idExists(id)) { throw new DuplicateKeyException(AGREEMENT_SPECIFICATION_WITH_ID + id + " already exists"); } } public boolean tmfIdExists(String id) { public boolean idExists(String id) { return agreementSpecificationRepository.findById(id).isPresent(); } } src/main/java/org/etsi/osl/hypo/api/tmf/common/api/helpers/ServiceSpecificationHelpers.java +6 −7 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ public class ServiceSpecificationHelpers { private void hasPeeredServiceSpecification( ServiceSpecificationRef serviceSpecificationRef, AtomicReference<Boolean> hasPeeredOrganization) { final String serviceSpecificationId = serviceSpecificationRef.getTmfId(); final String serviceSpecificationId = serviceSpecificationRef.getId(); Optional<ServiceSpecificationEntity> serviceSpecificationEntity = serviceSpecificationService.getSpecificationById(serviceSpecificationId); Loading Loading @@ -170,23 +170,22 @@ public class ServiceSpecificationHelpers { ServiceRefOrValue serviceRefOrValue) { return serviceSpecificationEntity -> serviceSpecificationEntity .getTmfId() .equals(serviceRefOrValue.getServiceSpecification().getTmfId()); .getId() .equals(serviceRefOrValue.getServiceSpecification().getId()); } private Predicate<ServiceSpecificationEntity> getServiceSpecificationEntityPredicate( ServiceSpecificationEntity serviceSpecificationEntityProvided) { return serviceSpecificationEntity -> serviceSpecificationEntity.getTmfId().equals(serviceSpecificationEntityProvided.getTmfId()); serviceSpecificationEntity.getId().equals(serviceSpecificationEntityProvided.getId()); } private Predicate<ServiceSpecificationEntity> getServiceSpecificationEntityPredicate( Service service) { return serviceSpecificationEntity -> service.getServiceSpecification() != null && service.getServiceSpecification().getTmfId() != null && service.getServiceSpecification().getId() != null && StringUtils.equals( serviceSpecificationEntity.getTmfId(), service.getServiceSpecification().getTmfId()); serviceSpecificationEntity.getId(), service.getServiceSpecification().getId()); } } src/main/java/org/etsi/osl/hypo/api/tmf/common/api/kafka/peering/api/incoming/deserializers/ServiceSpecificationDeserializer.java +1 −1 Original line number Diff line number Diff line Loading @@ -8,6 +8,6 @@ import org.etsi.osl.hypo.api.tmf.services.catalog.schema.ServiceSpecificationEnt public class ServiceSpecificationDeserializer extends ObjectMapperDeserializer<List<ServiceSpecificationEntity>> { public ServiceSpecificationDeserializer() { super(new TypeReference<List<ServiceSpecificationEntity>>() {}); super(new TypeReference<>() {}); } } src/main/java/org/etsi/osl/hypo/api/tmf/common/api/kafka/peering/api/incoming/helper/PeeringHelper.java +4 −4 Original line number Diff line number Diff line Loading @@ -113,7 +113,7 @@ public class PeeringHelper { existingSpecs.forEach( serviceSpecificationEntity -> serviceSpecificationService.updateServiceSpecificationViaPeering( serviceSpecificationEntity.getTmfId(), serviceSpecificationEntity)); serviceSpecificationEntity.getId(), serviceSpecificationEntity)); } List<ServiceSpecificationEntity> notPersistedSpecs = Loading Loading @@ -208,7 +208,7 @@ public class PeeringHelper { ServiceSpecificationEntity serviceSpecificationEntity) { ServiceCandidateEntity serviceCandidateEntity = new ServiceCandidateEntity(); serviceCandidateEntity.setName(serviceSpecificationEntity.getName()); serviceCandidateEntity.setTmfId(serviceSpecificationEntity.getTmfId()); serviceCandidateEntity.setId(serviceSpecificationEntity.getId()); serviceCandidateEntity.setServiceSpecification(serviceSpecificationEntity); return serviceCandidateEntity; } Loading Loading @@ -261,7 +261,7 @@ public class PeeringHelper { return serviceCandidateEntitySet.stream() .filter(specificationMatchesName(serviceSpecificationNames)) .map(BaseEntity::getTmfId) .map(BaseEntity::getId) .toList(); } Loading Loading @@ -319,7 +319,7 @@ public class PeeringHelper { String name = serviceCategory.getName(); return name.equalsIgnoreCase(serviceCategoryEntity.getName()); })) .map(BaseEntity::getTmfId) .map(BaseEntity::getId) .toList(); } } Loading
src/main/java/org/etsi/osl/hypo/api/tmf/agreement/api/services/AgreementService.java +17 −18 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import jakarta.transaction.Transactional; import java.util.List; import java.util.Map; import java.util.Optional; import org.apache.commons.collections4.CollectionUtils; import org.etsi.osl.hypo.api.tmf.agreement.api.repository.AgreementRepository; import org.etsi.osl.hypo.api.tmf.agreement.schema.Agreement; import org.etsi.osl.hypo.api.tmf.common.api.mapper.UpdateMapper; Loading Loading @@ -70,26 +71,24 @@ public class AgreementService { @Transactional public Agreement createAgreement(Agreement agreement) { checkIfTmfIdExists(agreement.getTmfId()); if (agreement.getEngagedParty() != null && !agreement.getEngagedParty().isEmpty()) { agreement = findRelatedPartyAndAddItToResource(agreement); } checkIfIdExists(agreement.getId()); findRelatedPartyAndAddItToResource(agreement); agreementRepository.persist(agreement); return agreement; } private Agreement findRelatedPartyAndAddItToResource(Agreement agreement) { List<String> partyIds = agreement.getEngagedParty().stream().map(RelatedPartyEntity::getTmfId).toList(); private void findRelatedPartyAndAddItToResource(Agreement agreement) { List<RelatedPartyEntity> engagedParty = agreement.getEngagedParty(); if (CollectionUtils.isNotEmpty(engagedParty)) { List<String> partyIds = engagedParty.stream().map(RelatedPartyEntity::getId).toList(); // find and relate parties List<RelatedPartyEntity> relatedPartyEntities = relatedPartyRepository.findByIdsList(partyIds); List<RelatedPartyEntity> relatedPartyEntities = relatedPartyRepository.findByIdsList(partyIds); agreement.getEngagedParty().clear(); agreement.getEngagedParty().addAll(relatedPartyEntities); return agreement; engagedParty.clear(); engagedParty.addAll(relatedPartyEntities); } } @Transactional Loading Loading @@ -117,13 +116,13 @@ public class AgreementService { return agreement; } private void checkIfTmfIdExists(String tmfId) { if (tmfIdExists(tmfId)) { throw new DuplicateKeyException(AGREEMENT_WITH_ID + tmfId + " already exists"); private void checkIfIdExists(String id) { if (iddExists(id)) { throw new DuplicateKeyException(AGREEMENT_WITH_ID + id + " already exists"); } } public boolean tmfIdExists(String id) { public boolean iddExists(String id) { return agreementRepository.findById(id).isPresent(); } }
src/main/java/org/etsi/osl/hypo/api/tmf/agreement/api/services/AgreementSpecificationService.java +17 −20 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import jakarta.transaction.Transactional; import java.util.List; import java.util.Map; import java.util.Optional; import org.apache.commons.collections4.CollectionUtils; import org.etsi.osl.hypo.api.tmf.agreement.api.repository.AgreementSpecificationRepository; import org.etsi.osl.hypo.api.tmf.agreement.schema.AgreementSpecification; import org.etsi.osl.hypo.api.tmf.common.api.mapper.UpdateMapper; Loading Loading @@ -76,30 +77,26 @@ public class AgreementSpecificationService { @Transactional public AgreementSpecification createAgreementSpecification( AgreementSpecification agreementSpecification) { checkIfTmfIdExists(agreementSpecification.getTmfId()); checkIfIdExists(agreementSpecification.getId()); if (agreementSpecification.getRelatedParty() != null && !agreementSpecification.getRelatedParty().isEmpty()) { agreementSpecification = findRelatedPartyAndAddItToResource(agreementSpecification); } findRelatedPartyAndAddItToResource(agreementSpecification); agreementSpecificationRepository.persist(agreementSpecification); return agreementSpecification; } private AgreementSpecification findRelatedPartyAndAddItToResource( AgreementSpecification agreementSpecification) { List<String> partyIds = agreementSpecification.getRelatedParty().stream() .map(RelatedPartyEntity::getTmfId) .toList(); private void findRelatedPartyAndAddItToResource(AgreementSpecification agreementSpecification) { List<RelatedPartyEntity> relatedParty = agreementSpecification.getRelatedParty(); if (CollectionUtils.isNotEmpty(relatedParty)) { List<String> partyIds = relatedParty.stream().map(RelatedPartyEntity::getId).toList(); // find and relate parties List<RelatedPartyEntity> relatedPartyEntities = relatedPartyRepository.findByIdsList(partyIds); List<RelatedPartyEntity> relatedPartyEntities = relatedPartyRepository.findByIdsList(partyIds); agreementSpecification.getRelatedParty().clear(); agreementSpecification.getRelatedParty().addAll(relatedPartyEntities); return agreementSpecification; relatedParty.clear(); relatedParty.addAll(relatedPartyEntities); } } @Transactional Loading Loading @@ -130,13 +127,13 @@ public class AgreementSpecificationService { return agreementSpecification; } private void checkIfTmfIdExists(String tmfId) { if (tmfIdExists(tmfId)) { throw new DuplicateKeyException(AGREEMENT_SPECIFICATION_WITH_ID + tmfId + " already exists"); private void checkIfIdExists(String id) { if (idExists(id)) { throw new DuplicateKeyException(AGREEMENT_SPECIFICATION_WITH_ID + id + " already exists"); } } public boolean tmfIdExists(String id) { public boolean idExists(String id) { return agreementSpecificationRepository.findById(id).isPresent(); } }
src/main/java/org/etsi/osl/hypo/api/tmf/common/api/helpers/ServiceSpecificationHelpers.java +6 −7 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ public class ServiceSpecificationHelpers { private void hasPeeredServiceSpecification( ServiceSpecificationRef serviceSpecificationRef, AtomicReference<Boolean> hasPeeredOrganization) { final String serviceSpecificationId = serviceSpecificationRef.getTmfId(); final String serviceSpecificationId = serviceSpecificationRef.getId(); Optional<ServiceSpecificationEntity> serviceSpecificationEntity = serviceSpecificationService.getSpecificationById(serviceSpecificationId); Loading Loading @@ -170,23 +170,22 @@ public class ServiceSpecificationHelpers { ServiceRefOrValue serviceRefOrValue) { return serviceSpecificationEntity -> serviceSpecificationEntity .getTmfId() .equals(serviceRefOrValue.getServiceSpecification().getTmfId()); .getId() .equals(serviceRefOrValue.getServiceSpecification().getId()); } private Predicate<ServiceSpecificationEntity> getServiceSpecificationEntityPredicate( ServiceSpecificationEntity serviceSpecificationEntityProvided) { return serviceSpecificationEntity -> serviceSpecificationEntity.getTmfId().equals(serviceSpecificationEntityProvided.getTmfId()); serviceSpecificationEntity.getId().equals(serviceSpecificationEntityProvided.getId()); } private Predicate<ServiceSpecificationEntity> getServiceSpecificationEntityPredicate( Service service) { return serviceSpecificationEntity -> service.getServiceSpecification() != null && service.getServiceSpecification().getTmfId() != null && service.getServiceSpecification().getId() != null && StringUtils.equals( serviceSpecificationEntity.getTmfId(), service.getServiceSpecification().getTmfId()); serviceSpecificationEntity.getId(), service.getServiceSpecification().getId()); } }
src/main/java/org/etsi/osl/hypo/api/tmf/common/api/kafka/peering/api/incoming/deserializers/ServiceSpecificationDeserializer.java +1 −1 Original line number Diff line number Diff line Loading @@ -8,6 +8,6 @@ import org.etsi.osl.hypo.api.tmf.services.catalog.schema.ServiceSpecificationEnt public class ServiceSpecificationDeserializer extends ObjectMapperDeserializer<List<ServiceSpecificationEntity>> { public ServiceSpecificationDeserializer() { super(new TypeReference<List<ServiceSpecificationEntity>>() {}); super(new TypeReference<>() {}); } }
src/main/java/org/etsi/osl/hypo/api/tmf/common/api/kafka/peering/api/incoming/helper/PeeringHelper.java +4 −4 Original line number Diff line number Diff line Loading @@ -113,7 +113,7 @@ public class PeeringHelper { existingSpecs.forEach( serviceSpecificationEntity -> serviceSpecificationService.updateServiceSpecificationViaPeering( serviceSpecificationEntity.getTmfId(), serviceSpecificationEntity)); serviceSpecificationEntity.getId(), serviceSpecificationEntity)); } List<ServiceSpecificationEntity> notPersistedSpecs = Loading Loading @@ -208,7 +208,7 @@ public class PeeringHelper { ServiceSpecificationEntity serviceSpecificationEntity) { ServiceCandidateEntity serviceCandidateEntity = new ServiceCandidateEntity(); serviceCandidateEntity.setName(serviceSpecificationEntity.getName()); serviceCandidateEntity.setTmfId(serviceSpecificationEntity.getTmfId()); serviceCandidateEntity.setId(serviceSpecificationEntity.getId()); serviceCandidateEntity.setServiceSpecification(serviceSpecificationEntity); return serviceCandidateEntity; } Loading Loading @@ -261,7 +261,7 @@ public class PeeringHelper { return serviceCandidateEntitySet.stream() .filter(specificationMatchesName(serviceSpecificationNames)) .map(BaseEntity::getTmfId) .map(BaseEntity::getId) .toList(); } Loading Loading @@ -319,7 +319,7 @@ public class PeeringHelper { String name = serviceCategory.getName(); return name.equalsIgnoreCase(serviceCategoryEntity.getName()); })) .map(BaseEntity::getTmfId) .map(BaseEntity::getId) .toList(); } }