Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit b89ac81c authored by Wylem Bars's avatar Wylem Bars

PATREG-33 | Sonar analysis

parent ed1866d5
Pipeline #138045 failed with stages
in 8 minutes and 54 seconds
......@@ -10,7 +10,6 @@ import net.ihe.gazelle.lib.searchmodelapi.business.searchcriterion.key.SearchCri
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.From;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
......@@ -22,8 +21,9 @@ import javax.persistence.metamodel.Metamodel;
*/
public class PatientSearchCriterionJPAMappingService implements SearchCriterionJPAMappingService {
private CriteriaBuilder criteriaBuilder;
private static final String PATIENT_IDENTIFIER_ATTRIBUTE = "patientIdentifiers";
private static final String DOMAIN_ATTRIBUTE = "domain";
private EntityManager entityManager;
/**
......@@ -32,7 +32,6 @@ public class PatientSearchCriterionJPAMappingService implements SearchCriterionJ
*/
@Inject
public PatientSearchCriterionJPAMappingService(@EntityManagerProducer.InjectEntityManager EntityManager entityManager) {
this.criteriaBuilder = entityManager.getCriteriaBuilder();
this.entityManager = entityManager;
}
......@@ -50,23 +49,24 @@ public class PatientSearchCriterionJPAMappingService implements SearchCriterionJ
} else if (PatientSearchCriterionKey.IDENTIFIER.equals(patientSearchCriterionKey)) {
From from2 = (From) from.getJoins().stream()
.filter(p ->
((Join) p).getAttribute().getName().equals("patientIdentifiers") &&
((Join) p).getAttribute().getName().equals(PATIENT_IDENTIFIER_ATTRIBUTE) &&
JoinType.LEFT.equals(((Join) p).getJoinType()))
.findAny().orElse(null);
return from2 != null ? from : from.join(entityType.getList("patientIdentifiers", PatientIdentifierDB.class), JoinType.LEFT);
return from2 != null ? from : from.join(entityType.getList(PATIENT_IDENTIFIER_ATTRIBUTE, PatientIdentifierDB.class), JoinType.LEFT);
} else if (PatientSearchCriterionKey.DOMAIN.equals(patientSearchCriterionKey)) {
From from2 = (From) from.getJoins().stream()
.filter(p ->
((Join) p).getAttribute().getName().equals("patientIdentifiers") &&
((Join) p).getAttribute().getName().equals(PATIENT_IDENTIFIER_ATTRIBUTE) &&
JoinType.LEFT.equals(((Join) p).getJoinType()))
.findAny().orElse(null);
from2 = from2 != null ? from2 : from.join(entityType.getList("patientIdentifiers", PatientIdentifierDB.class), JoinType.LEFT);
from2 = from2 != null ? from2 : from.join(entityType.getList(PATIENT_IDENTIFIER_ATTRIBUTE, PatientIdentifierDB.class), JoinType.LEFT);
From from3 = (From) from2.getJoins().stream()
.filter(p ->
((Join) p).getAttribute().getName().equals("domain") &&
((Join) p).getAttribute().getName().equals(DOMAIN_ATTRIBUTE) &&
JoinType.LEFT.equals(((Join) p).getJoinType()))
.findAny().orElse(null);
return from3 != null ? from3 : from2.join(entityTypeIdentifier.getSingularAttribute("domain", HierarchicDesignatorDB.class), JoinType.LEFT);
return from3 != null ? from3 : from2.join(entityTypeIdentifier.getSingularAttribute(DOMAIN_ATTRIBUTE, HierarchicDesignatorDB.class),
JoinType.LEFT);
} else {
throw new IllegalArgumentException("Unsupported test key : " + patientSearchCriterionKey);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment