use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.
the class SnomedSimpleTypeRefSetDSVExporter method computeHeader.
private void computeHeader(SnomedConcepts chunk) {
for (SnomedConcept concept : chunk) {
for (AbstractSnomedDsvExportItem exportItem : exportItems) {
switch(exportItem.getType()) {
case DESCRIPTION:
ComponentIdSnomedDsvExportItem descriptionItem = (ComponentIdSnomedDsvExportItem) exportItem;
String descriptionTypeId = descriptionItem.getComponentId();
Integer matchingDescriptions = concept.getDescriptions().stream().filter(d -> descriptionTypeId.equals(d.getTypeId())).collect(Collectors.reducing(0, description -> 1, Integer::sum));
descriptionCount.merge(descriptionTypeId, matchingDescriptions, Math::max);
break;
case RELATIONSHIP:
ComponentIdSnomedDsvExportItem relationshipItem = (ComponentIdSnomedDsvExportItem) exportItem;
String relationshipTypeId = relationshipItem.getComponentId();
Map<Integer, Integer> matchingRelationships = concept.getRelationships().stream().filter(r -> relationshipTypeId.equals(r.getTypeId()) && (Concepts.INFERRED_RELATIONSHIP.equals(r.getCharacteristicTypeId()) || Concepts.ADDITIONAL_RELATIONSHIP.equals(r.getCharacteristicTypeId()))).collect(Collectors.groupingBy(SnomedRelationship::getRelationshipGroup, Collectors.reducing(0, relationship -> 1, Integer::sum)));
matchingRelationships.entrySet().stream().forEach(entry -> {
propertyCountByGroup.compute(entry.getKey(), (key, oldValue) -> {
Map<String, Integer> propertyCountForGroup = ofNullable(oldValue).orElseGet(HashMap::new);
propertyCountForGroup.merge(relationshipTypeId, entry.getValue(), Math::max);
return propertyCountForGroup;
});
});
break;
case DATAYPE:
ComponentIdSnomedDsvExportItem dataTypeItem = (ComponentIdSnomedDsvExportItem) exportItem;
String dataTypeId = dataTypeItem.getComponentId();
Map<Integer, Integer> matchingMembers = concept.getMembers().stream().filter(m -> SnomedRefSetType.CONCRETE_DATA_TYPE.equals(m.type()) && m.isActive() && dataTypeId.equals(m.getProperties().get(SnomedRf2Headers.FIELD_TYPE_ID)) && (Concepts.INFERRED_RELATIONSHIP.equals(m.getProperties().get(SnomedRf2Headers.FIELD_CHARACTERISTIC_TYPE_ID)) || Concepts.ADDITIONAL_RELATIONSHIP.equals(m.getProperties().get(SnomedRf2Headers.FIELD_CHARACTERISTIC_TYPE_ID)))).collect(Collectors.groupingBy(m -> (Integer) m.getProperties().get(SnomedRf2Headers.FIELD_RELATIONSHIP_GROUP), Collectors.reducing(0, relationship -> 1, Integer::sum)));
matchingMembers.entrySet().stream().forEach(entry -> {
propertyCountByGroup.compute(entry.getKey(), (key, oldValue) -> {
Map<String, Integer> propertyCountForGroup = ofNullable(oldValue).orElseGet(HashMap::new);
propertyCountForGroup.merge(dataTypeId, entry.getValue(), Math::max);
return propertyCountForGroup;
});
});
break;
default:
// Single-use fields don't need to be counted in advance
break;
}
}
}
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.
the class Rf2OwlExpressionRefSetContentType method resolve.
@Override
public void resolve(SnomedReferenceSetMember component, String[] values) {
component.setRefsetId(values[4]);
if (Concepts.REFSET_OWL_AXIOM.equals(component.getRefsetId())) {
component.setType(SnomedRefSetType.OWL_AXIOM);
} else if (Concepts.REFSET_OWL_ONTOLOGY.equals(component.getRefsetId())) {
component.setType(SnomedRefSetType.OWL_ONTOLOGY);
} else {
throw new UnsupportedOperationException("Unrecognized OWL Reference Set " + component.getRefsetId());
}
// XXX actual type is not relevant here
component.setReferencedComponent(new SnomedConcept(values[5]));
component.setProperties(ImmutableMap.of(FIELD_OWL_EXPRESSION, values[6]));
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.
the class Rf2SimpleRefSetContentType method resolve.
@Override
public void resolve(SnomedReferenceSetMember component, String[] values) {
component.setType(SnomedRefSetType.SIMPLE);
component.setRefsetId(values[4]);
// XXX actual type is not relevant here
component.setReferencedComponent(new SnomedConcept(values[5]));
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.
the class SnomedQueryMemberCreateDelegate method createWithNewRefSet.
private String createWithNewRefSet(SnomedReferenceSet refSet, TransactionContext context) {
checkNonEmptyProperty(REFERENCED_COMPONENT);
checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_MODULE_ID, getModuleId());
// create new simple type reference set
final SnomedConcept referencedComponent = getProperty(REFERENCED_COMPONENT, SnomedConcept.class);
final String referencedComponentId = new IdRequest<>(referencedComponent.toCreateRequest()).execute(context);
// write the generated ID back to the request
setReferencedComponentId(referencedComponentId);
// add all matching members
final SnomedConcepts queryResults = SnomedRequests.prepareSearchConcept().all().filterByEcl(getProperty(SnomedRf2Headers.FIELD_QUERY)).build().execute(context);
for (SnomedConcept queryResult : queryResults) {
SnomedComponents.newSimpleMember().withActive(isActive()).withReferencedComponent(queryResult.getId()).withModuleId(getModuleId()).withRefSet(referencedComponentId).addTo(context);
}
return createWithExistingRefSet(refSet, context);
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.
the class Rf2AttributeValueRefSetContentType method resolve.
@Override
public void resolve(SnomedReferenceSetMember component, String[] values) {
component.setType(SnomedRefSetType.ATTRIBUTE_VALUE);
component.setRefsetId(values[4]);
// XXX actual type is not relevant here
component.setReferencedComponent(new SnomedConcept(values[5]));
component.setProperties(ImmutableMap.of(SnomedRf2Headers.FIELD_VALUE_ID, values[6]));
}
Aggregations