Search in sources :

Example 6 with ComponentNotFoundException

use of com.b2international.snowowl.core.exceptions.ComponentNotFoundException in project snow-owl by b2ihealthcare.

the class SnomedDescriptionCreateRequest method execute.

@Override
public String execute(TransactionContext context) {
    try {
        final String descriptionId = ((ConstantIdStrategy) getIdGenerationStrategy()).getId();
        final SnomedDescriptionIndexEntry description = SnomedComponents.newDescription().withId(descriptionId).withActive(isActive()).withModuleId(getModuleId()).withCaseSignificanceId(caseSignificanceId).withTerm(term).withType(typeId).withLanguageCode(languageCode).withConcept(conceptId).build(context);
        new SnomedDescriptionAcceptabilityUpdateRequest(description, acceptability, true).execute(context);
        // FIXME: Acceptability updates and member create requests can overlap
        convertMembers(context, descriptionId);
        context.add(description);
        // update inactivation reason members if the new description was immediately set to have an inactivation member
        if (inactivationIndicatorId != null) {
            final SnomedInactivationReasonUpdateRequest inactivationUpdate = new SnomedInactivationReasonUpdateRequest(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR, true);
            inactivationUpdate.setInactivationValueId(inactivationIndicatorId);
            inactivationUpdate.execute(context);
        }
        return description.getId();
    } catch (ComponentNotFoundException e) {
        throw e.toBadRequestException();
    }
}
Also used : ComponentNotFoundException(com.b2international.snowowl.core.exceptions.ComponentNotFoundException) ConstantIdStrategy(com.b2international.snowowl.snomed.core.domain.ConstantIdStrategy) SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry)

Example 7 with ComponentNotFoundException

use of com.b2international.snowowl.core.exceptions.ComponentNotFoundException in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberUpdateRequest method execute.

@Override
public Boolean execute(TransactionContext context) {
    SnomedRefSetMemberIndexEntry member = context.lookup(componentId(), SnomedRefSetMemberIndexEntry.class);
    SnomedRefSetMemberIndexEntry.Builder updatedMember = SnomedRefSetMemberIndexEntry.builder(member);
    /* 
		 * TODO: Generalize the logic below: any attempts of retrieving a missing component during component update
		 * (with the exception of the component that is being updated) should return a 400 response instead of a 404. 
		 */
    try {
        SnomedRefSetType type = member.getReferenceSetType();
        boolean changed = false;
        changed |= updateStatus(member, updatedMember);
        changed |= updateModule(member, updatedMember);
        changed |= updateEffectiveTime(member, updatedMember);
        SnomedRefSetMemberUpdateDelegate delegate = getDelegate(type);
        changed |= delegate.execute(member, updatedMember, context);
        if (changed) {
            if (!isEffectiveTimeUpdate()) {
                updatedMember.effectiveTime(EffectiveTimes.UNSET_EFFECTIVE_TIME);
            }
            context.update(member, updatedMember.build());
        }
        return changed;
    } catch (ComponentNotFoundException e) {
        throw e.toBadRequestException();
    }
}
Also used : SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry) ComponentNotFoundException(com.b2international.snowowl.core.exceptions.ComponentNotFoundException) SnomedRefSetType(com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType)

Example 8 with ComponentNotFoundException

use of com.b2international.snowowl.core.exceptions.ComponentNotFoundException in project snow-owl by b2ihealthcare.

the class SnomedRelationshipCreateRequest method execute.

@Override
public String execute(final TransactionContext context) {
    if (Strings.isNullOrEmpty(getSourceId())) {
        throw new BadRequestException("'sourceId' may not be empty");
    }
    if (Strings.isNullOrEmpty(getDestinationId()) && getValue() == null) {
        throw new BadRequestException("'destinationId' or 'value' should be specified");
    }
    if (!Strings.isNullOrEmpty(getDestinationId()) && getValue() != null) {
        throw new BadRequestException("'destinationId' and 'value' can not be set for the same relationship");
    }
    try {
        final String relationshipId = ((ConstantIdStrategy) getIdGenerationStrategy()).getId();
        final SnomedRelationshipIndexEntry relationship = SnomedComponents.newRelationship().withId(relationshipId).withActive(isActive()).withModuleId(getModuleId()).withSourceId(getSourceId()).withTypeId(getTypeId()).withDestinationId(getDestinationId()).withDestinationNegated(isDestinationNegated()).withValue(getValue()).withRelationshipGroup(getRelationshipGroup()).withUnionGroup(getUnionGroup()).withCharacteristicTypeId(getCharacteristicTypeId()).withModifierId(getModifierId()).build(context);
        convertMembers(context, relationshipId);
        context.add(relationship);
        return relationship.getId();
    } catch (final ComponentNotFoundException e) {
        throw e.toBadRequestException();
    }
}
Also used : ComponentNotFoundException(com.b2international.snowowl.core.exceptions.ComponentNotFoundException) SnomedRelationshipIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry) ConstantIdStrategy(com.b2international.snowowl.snomed.core.domain.ConstantIdStrategy) BadRequestException(com.b2international.commons.exceptions.BadRequestException)

Aggregations

ComponentNotFoundException (com.b2international.snowowl.core.exceptions.ComponentNotFoundException)8 BadRequestException (com.b2international.commons.exceptions.BadRequestException)3 SnomedReferenceSet (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSet)3 ConstantIdStrategy (com.b2international.snowowl.snomed.core.domain.ConstantIdStrategy)2 TransactionContext (com.b2international.snowowl.core.domain.TransactionContext)1 DelegatingRequest (com.b2international.snowowl.core.events.DelegatingRequest)1 Request (com.b2international.snowowl.core.events.Request)1 BulkRequest (com.b2international.snowowl.core.events.bulk.BulkRequest)1 ResourceDocument (com.b2international.snowowl.core.internal.ResourceDocument)1 DeleteRequest (com.b2international.snowowl.core.request.DeleteRequest)1 SnomedComponent (com.b2international.snowowl.snomed.core.domain.SnomedComponent)1 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)1 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)1 SnomedRelationship (com.b2international.snowowl.snomed.core.domain.SnomedRelationship)1 SnomedRefSetType (com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType)1 com.b2international.snowowl.snomed.datastore.index.entry (com.b2international.snowowl.snomed.datastore.index.entry)1 SnomedConceptDocument (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument)1 SnomedDescriptionIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry)1 SnomedRefSetMemberIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry)1 SnomedRelationshipIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRelationshipIndexEntry)1