Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#707 fixing minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
harpatel1 committed Apr 28, 2021
1 parent cd77b92 commit d2c81a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ private List<Source> getSourcesFromExpressions(List<String> expressions, List<St
}

private List<Source> getSourcesFromExpressions(List<String> expressions) {
return expressions.parallelStream().map(m -> formatExpression(m).split(FS))
List<Source> sources =
expressions.parallelStream().map(m -> formatExpression(m).split(FS))
.map(m -> ownerType(m) + "|" + ownerId(m) + "|" + getSourceId(m) + "|" + getSourceVersion(m))
.distinct()
.map(m -> m.split("\\|"))
Expand All @@ -241,6 +242,7 @@ private List<Source> getSourcesFromExpressions(List<String> expressions) {
.map(Optional::get)
.sorted(Comparator.comparing(Source::getCanonicalUrl).thenComparing(Source::getCreatedAt).reversed())
.collect(Collectors.toList());
return sources;
}

private List<String> getAllExpressions(Collection collection) {
Expand Down Expand Up @@ -487,7 +489,7 @@ public ValueSet expand(Collection collection, IntegerType offset, IntegerType co
String conceptId = getConceptId(m);
String conceptVersion = getConceptVersion(m);
if (isValid(conceptId)) {
Optional<Concept> conceptOpt = oclFhirUtil.getSourceConcept(source, conceptId, conceptVersion);
Optional<Concept> conceptOpt = oclFhirUtil.getSourceConcept(source, conceptId, "");
conceptOpt.ifPresent(c -> {
// only return non retired concepts when activeOnly is True
if (c.getRetired() && activeOnly.booleanValue()) {
Expand Down Expand Up @@ -522,7 +524,7 @@ public ValueSet expand(Collection collection, IntegerType offset, IntegerType co
// sort based on canonical_url,version desc and code asc
List<ValueSet.ValueSetExpansionContainsComponent> sorted = expansion.getContains().stream()
.sorted(Comparator.comparing(ValueSet.ValueSetExpansionContainsComponent::getSystem)
.thenComparing(ValueSet.ValueSetExpansionContainsComponent::getVersion)
.thenComparing(Comparator.nullsLast(Comparator.comparing(ValueSet.ValueSetExpansionContainsComponent::getVersion)))
.reversed()
.thenComparing(ValueSet.ValueSetExpansionContainsComponent::getCode))
.collect(Collectors.toList());
Expand Down Expand Up @@ -615,7 +617,7 @@ public void createValueSet(ValueSet valueSet, String accessionId, String authTok
validatedConceptIds.putAll(validated);
expressions.addAll(toExpression(ownerType, owner, source.getMnemonic(), source.getVersion(), validated));
});
// save collection
// save
saveCollection(collection, validatedConceptIds, expressions);
// clear data
sourceToConceptMap.clear();
Expand Down Expand Up @@ -801,7 +803,6 @@ public void updateValueSet(final ValueSet valueSet, final Collection collection,
oclFhirUtil.updateIndex(getToken(), COLLECTIONS, collection.getMnemonic());
}

@Transactional
void update(final ValueSet valueSet, final Collection collection, final String accessionId, final String authToken) {
final OclEntity oclEntity = new OclEntity(valueSet, accessionId, authToken, false);
// update status
Expand Down Expand Up @@ -888,7 +889,8 @@ void update(final ValueSet valueSet, final Collection collection, final String a
newExpressions.clear();
}

private void saveCollection(Collection collection, Map<Long, String> validatedConceptIds, Set<String> expressions) {
@Transactional
protected void saveCollection(Collection collection, Map<Long, String> validatedConceptIds, Set<String> expressions) {
// save base collection
collectionRepository.saveAndFlush(collection);
// save collection reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public Class<? extends IBaseResource> getResourceType() {
}

@Create
@Transactional
public MethodOutcome createValueSet(@ResourceParam ValueSet valueSet, RequestDetails requestDetails) {
if (valueSet == null) {
throw new InvalidRequestException("The ValueSet can not be empty");
Expand All @@ -69,7 +68,6 @@ public MethodOutcome createValueSet(@ResourceParam ValueSet valueSet, RequestDet
}

@Update
@Transactional
public MethodOutcome updateValueSet(@IdParam IdType idType,
@ResourceParam ValueSet valueSet,
RequestDetails requestDetails) {
Expand Down

0 comments on commit d2c81a3

Please sign in to comment.