Skip to content

Commit

Permalink
MAINT-2106 Store conceptId instead ConceptMini object for IntegrityIs…
Browse files Browse the repository at this point in the history
…sueReport to prevent the Elastic Search issue: Limit of total fields [1000] has been exceeded
  • Loading branch information
QuyenLy87 authored and dmcgihtsdo committed Mar 23, 2023
1 parent 870d90f commit 9c8c141
Showing 1 changed file with 58 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.snomed.snowstorm.core.data.services;

import org.snomed.snowstorm.core.data.domain.ConceptMini;
import org.snomed.snowstorm.core.data.services.pojo.IntegrityIssueReport;

import java.util.HashMap;
Expand All @@ -8,8 +9,63 @@
public class ApiErrorFactory {

static ApiError createErrorForMergeConflicts(String message, IntegrityIssueReport integrityIssueReport) {
Map<String, Object> info = new HashMap<>();
info.put("integrityIssues", integrityIssueReport);
PersistedIntegrityIssueReport report = new PersistedIntegrityIssueReport();
report.setRelationshipsWithMissingOrInactiveDestination(integrityIssueReport.getRelationshipsWithMissingOrInactiveDestination());
report.setRelationshipsWithMissingOrInactiveSource(integrityIssueReport.getRelationshipsWithMissingOrInactiveSource());
report.setRelationshipsWithMissingOrInactiveType(integrityIssueReport.getRelationshipsWithMissingOrInactiveType());
if (integrityIssueReport.getAxiomsWithMissingOrInactiveReferencedConcept() != null) {
Map<String, Long> axiomsWithMissingOrInactiveReferencedConcept = new HashMap<>();
for (Map.Entry<String, ConceptMini> entry : integrityIssueReport.getAxiomsWithMissingOrInactiveReferencedConcept().entrySet()) {
axiomsWithMissingOrInactiveReferencedConcept.put(entry.getKey(), entry.getValue().getConceptIdAsLong());
}
report.setAxiomsWithMissingOrInactiveReferencedConcept(axiomsWithMissingOrInactiveReferencedConcept);
} else {
report.setAxiomsWithMissingOrInactiveReferencedConcept(null);
}

Map <String, Object> info = new HashMap <>();
info.put("integrityIssues", report);
return new ApiError(message, "The integrity check API can be used here.", info);
}

private static class PersistedIntegrityIssueReport {

private Map<String, Long> axiomsWithMissingOrInactiveReferencedConcept;
private Map<Long, Long> relationshipsWithMissingOrInactiveSource;
private Map<Long, Long> relationshipsWithMissingOrInactiveType;
private Map<Long, Long> relationshipsWithMissingOrInactiveDestination;


public Map<String, Long> getAxiomsWithMissingOrInactiveReferencedConcept() {
return axiomsWithMissingOrInactiveReferencedConcept;
}

public void setAxiomsWithMissingOrInactiveReferencedConcept(Map<String, Long> axiomsWithMissingOrInactiveReferencedConcept) {
this.axiomsWithMissingOrInactiveReferencedConcept = axiomsWithMissingOrInactiveReferencedConcept;
}

public Map<Long, Long> getRelationshipsWithMissingOrInactiveSource() {
return relationshipsWithMissingOrInactiveSource;
}

public void setRelationshipsWithMissingOrInactiveSource(Map<Long, Long> relationshipsWithMissingOrInactiveSource) {
this.relationshipsWithMissingOrInactiveSource = relationshipsWithMissingOrInactiveSource;
}

public Map<Long, Long> getRelationshipsWithMissingOrInactiveType() {
return relationshipsWithMissingOrInactiveType;
}

public void setRelationshipsWithMissingOrInactiveType(Map<Long, Long> relationshipsWithMissingOrInactiveType) {
this.relationshipsWithMissingOrInactiveType = relationshipsWithMissingOrInactiveType;
}

public Map<Long, Long> getRelationshipsWithMissingOrInactiveDestination() {
return relationshipsWithMissingOrInactiveDestination;
}

public void setRelationshipsWithMissingOrInactiveDestination(Map<Long, Long> relationshipsWithMissingOrInactiveDestination) {
this.relationshipsWithMissingOrInactiveDestination = relationshipsWithMissingOrInactiveDestination;
}
}
}

0 comments on commit 9c8c141

Please sign in to comment.