Search in sources :

Example 6 with SnomedReferenceSet

use of com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSet in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberCreateRequest method getRefSet.

private SnomedReferenceSet getRefSet(TransactionContext context) {
    final SnomedReferenceSet refSet = new SnomedReferenceSetConverter(context, Options.builder().build(), Collections.emptyList()).convert(context.lookup(referenceSetId, SnomedConceptDocument.class));
    checkArgument(refSet.getType() != null, "Reference Set Properties are missing from identifier concept document: %s.", refSet.getId());
    return refSet;
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) SnomedReferenceSetConverter(com.b2international.snowowl.snomed.datastore.converter.SnomedReferenceSetConverter) SnomedReferenceSet(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSet)

Example 7 with SnomedReferenceSet

use of com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSet in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberCreateRequest method getRequiredComponentIds.

/**
 * @return the set of core component SCTIDs mentioned in any reference set member property
 */
@Override
public Set<String> getRequiredComponentIds(TransactionContext context) {
    try {
        SnomedReferenceSet refSet = getRefSet(context);
        SnomedRefSetMemberCreateDelegate delegate = getDelegate(refSet.getType());
        Builder<String> requiredComponentIds = ImmutableSet.<String>builder().addAll(delegate.getRequiredComponentIds());
        requiredComponentIds.add(referenceSetId);
        if (!Strings.isNullOrEmpty(referencedComponentId)) {
            requiredComponentIds.add(referencedComponentId);
        }
        if (!Strings.isNullOrEmpty(moduleId)) {
            requiredComponentIds.add(moduleId);
        }
        return requiredComponentIds.build();
    } catch (ComponentNotFoundException e) {
        throw e.toBadRequestException();
    }
}
Also used : SnomedReferenceSet(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSet) ComponentNotFoundException(com.b2international.snowowl.core.exceptions.ComponentNotFoundException)

Example 8 with SnomedReferenceSet

use of com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSet in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberCreateRequest method execute.

@Override
public String execute(TransactionContext context) {
    /* 
		 * TODO: Generalize the logic below: any attempts of retrieving a missing component during component creation
		 * should return a 400 response instead of a 404. 
		 */
    try {
        SnomedReferenceSet refSet = getRefSet(context);
        SnomedRefSetMemberCreateDelegate delegate = getDelegate(refSet.getType());
        return delegate.execute(refSet, context);
    } catch (ComponentNotFoundException e) {
        throw e.toBadRequestException();
    }
}
Also used : SnomedReferenceSet(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSet) ComponentNotFoundException(com.b2international.snowowl.core.exceptions.ComponentNotFoundException)

Example 9 with SnomedReferenceSet

use of com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSet in project snow-owl by b2ihealthcare.

the class SnomedDSVExportRequest method getRefSetExporter.

private IRefSetDSVExporter getRefSetExporter(BranchContext context) {
    final SnomedReferenceSet refSet = SnomedRequests.prepareGetReferenceSet(refSetId).build().execute(context);
    IRefSetDSVExporter exporter = null;
    if (SnomedRefSetType.SIMPLE.equals(refSet.getType())) {
        exporter = new SnomedSimpleTypeRefSetDSVExporter(context, toExportModel(context));
    } else if (SnomedRefSetUtil.isMapping(refSet.getType())) {
        exporter = new MapTypeRefSetDSVExporter(context, toExportModel(context));
    } else {
        throw new BadRequestException("Unsupported reference set '%s' with type '%s' in DSV export", refSetId, refSet.getType());
    }
    return exporter;
}
Also used : SnomedReferenceSet(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSet) BadRequestException(com.b2international.commons.exceptions.BadRequestException)

Aggregations

SnomedReferenceSet (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSet)9 ComponentNotFoundException (com.b2international.snowowl.core.exceptions.ComponentNotFoundException)4 BadRequestException (com.b2international.commons.exceptions.BadRequestException)3 EffectiveTimes (com.b2international.snowowl.core.date.EffectiveTimes)2 com.b2international.snowowl.snomed.datastore.index.entry (com.b2international.snowowl.snomed.datastore.index.entry)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 LocalDate (java.time.LocalDate)2 Collectors (java.util.stream.Collectors)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 ApiException (com.b2international.commons.exceptions.ApiException)1 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)1 Options (com.b2international.commons.options.Options)1 Query (com.b2international.index.query.Query)1 Commit (com.b2international.index.revision.Commit)1 RevisionSearcher (com.b2international.index.revision.RevisionSearcher)1 StagingArea (com.b2international.index.revision.StagingArea)1 ResourceURI (com.b2international.snowowl.core.ResourceURI)1 TerminologyResource (com.b2international.snowowl.core.TerminologyResource)1 SnowowlRuntimeException (com.b2international.snowowl.core.api.SnowowlRuntimeException)1