use of com.b2international.snowowl.core.domain.TransactionContext in project snow-owl by b2ihealthcare.
the class TransactionalRequest method execute.
@Override
public CommitResult execute(BranchContext context) {
// final Metrics metrics = context.service(Metrics.class);
// metrics.setExternalValue("preRequest", preRequestPreparationTime);
TransactionContext tx = null;
try (final TransactionContext transaction = context.openTransaction(context, author, commitComment, parentLockContext)) {
tx = transaction;
transaction.setNotificationEnabled(notify);
final Object body = executeNext(transaction);
return commit(transaction, body);
} catch (ApiException e) {
if (tx != null) {
tx.rollback();
}
throw e;
} catch (Exception e) {
if (tx != null) {
tx.rollback();
}
throw SnowowlRuntimeException.wrap(e);
}
}
use of com.b2international.snowowl.core.domain.TransactionContext in project snow-owl by b2ihealthcare.
the class SnomedConceptApiTest method testConceptInactivationModuleChanges.
@Test
public void testConceptInactivationModuleChanges() {
final String conceptId = createNewConcept(branchPath);
final String moduleConceptId = createNewConcept(branchPath);
String sourceRelationshipId = createNewRelationship(branchPath, conceptId, Concepts.HAS_DOSE_FORM, Concepts.MODULE_SCT_MODEL_COMPONENT);
String destinationRelationshipId = createNewRelationship(branchPath, Concepts.MODULE_SCT_MODEL_COMPONENT, Concepts.HAS_DOSE_FORM, conceptId);
ResourceURI codeSystemURI = SnomedContentRule.SNOMEDCT.withPath(branchPath.getPath().replace(Branch.MAIN_PATH + "/", ""));
SnomedRelationship sourceRelationship = SnomedRequests.prepareGetRelationship(sourceRelationshipId).build(codeSystemURI).execute(getBus()).getSync();
SnomedRelationship destinationRelationship = SnomedRequests.prepareGetRelationship(destinationRelationshipId).build(codeSystemURI).execute(getBus()).getSync();
Request<TransactionContext, Boolean> request = SnomedRequests.prepareUpdateConcept(conceptId).setActive(false).build();
SnomedRequests.prepareCommit().setDefaultModuleId(moduleConceptId).setBody(request).setCommitComment("commit").build(codeSystemURI).execute(getBus()).getSync();
SnomedRelationship updatedSourceRelationship = SnomedRequests.prepareGetRelationship(sourceRelationshipId).build(codeSystemURI).execute(getBus()).getSync();
SnomedRelationship updatedDestinationRelationship = SnomedRequests.prepareGetRelationship(destinationRelationshipId).build(codeSystemURI).execute(getBus()).getSync();
// Before update
assertTrue(sourceRelationship.isActive());
assertTrue(destinationRelationship.isActive());
assertFalse(moduleConceptId.equals(sourceRelationship.getModuleId()));
assertFalse(moduleConceptId.equals(destinationRelationship.getModuleId()));
// After update
assertFalse(updatedSourceRelationship.isActive());
assertEquals(moduleConceptId, updatedSourceRelationship.getModuleId());
assertFalse(updatedDestinationRelationship.isActive());
assertEquals(moduleConceptId, updatedDestinationRelationship.getModuleId());
}
Aggregations