diff --git a/core/com.b2international.snowowl.core/src/com/b2international/snowowl/core/jobs/ScheduleJobRequest.java b/core/com.b2international.snowowl.core/src/com/b2international/snowowl/core/jobs/ScheduleJobRequest.java index 5736398954e..42e93353c5d 100644 --- a/core/com.b2international.snowowl.core/src/com/b2international/snowowl/core/jobs/ScheduleJobRequest.java +++ b/core/com.b2international.snowowl.core/src/com/b2international/snowowl/core/jobs/ScheduleJobRequest.java @@ -93,6 +93,7 @@ public String execute(ServiceProvider context) { final Optional existingJob = JobRequests.prepareSearch() .one() .filterById(id) + .setFields(RemoteJobEntry.Fields.ID, RemoteJobEntry.Fields.DELETED, RemoteJobEntry.Fields.STATE) .build() .execute(context) .first(); diff --git a/snomed/com.b2international.snowowl.snomed.core.rest.tests/src/com/b2international/snowowl/snomed/core/rest/SnomedRf2NextReleaseImportTest.java b/snomed/com.b2international.snowowl.snomed.core.rest.tests/src/com/b2international/snowowl/snomed/core/rest/SnomedRf2NextReleaseImportTest.java index ecc84e8fbe3..0be36849ddf 100644 --- a/snomed/com.b2international.snowowl.snomed.core.rest.tests/src/com/b2international/snowowl/snomed/core/rest/SnomedRf2NextReleaseImportTest.java +++ b/snomed/com.b2international.snowowl.snomed.core.rest.tests/src/com/b2international/snowowl/snomed/core/rest/SnomedRf2NextReleaseImportTest.java @@ -29,6 +29,7 @@ import com.b2international.snowowl.core.date.EffectiveTimes; import com.b2international.snowowl.core.jobs.JobRequests; import com.b2international.snowowl.core.jobs.RemoteJobEntry; +import com.b2international.snowowl.core.request.io.ImportResponse; import com.b2international.snowowl.core.util.PlatformUtil; import com.b2international.snowowl.core.version.Version; import com.b2international.snowowl.snomed.core.domain.Rf2ReleaseType; @@ -38,6 +39,7 @@ import com.b2international.snowowl.test.commons.Services; import com.b2international.snowowl.test.commons.SnomedContentRule; import com.b2international.snowowl.test.commons.codesystem.CodeSystemVersionRestRequests; +import com.fasterxml.jackson.databind.ObjectMapper; /** * @since 8.0 @@ -68,6 +70,9 @@ private void doImport(final String importFile, final String importUntil) { .getSync(1, TimeUnit.MINUTES); RemoteJobEntry job = JobRequests.waitForJob(Services.bus(), jobId, 2000 /* 2 seconds */); assertTrue("Failed to import RF2 archive", job.isSuccessful()); + ImportResponse response = job.getResultAs(Services.context().service(ObjectMapper.class), ImportResponse.class); + //assert that the previous import job didn't store all visited components + assertTrue("Import result of FULL RF2 import should not include any visited components", response.getVisitedComponents().isEmpty()); // assert that the version for importUntil is present in the system Version latestVersion = CodeSystemVersionRestRequests.getLatestVersion(SnomedContentRule.SNOMEDCT_ID).get(); assertEquals(importUntil, EffectiveTimes.format(latestVersion.getEffectiveTime(), DateFormats.SHORT)); diff --git a/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/SnomedRf2ImportRequest.java b/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/SnomedRf2ImportRequest.java index 91f27b5c32b..26bc83f79e9 100644 --- a/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/SnomedRf2ImportRequest.java +++ b/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/SnomedRf2ImportRequest.java @@ -15,6 +15,7 @@ */ package com.b2international.snowowl.snomed.datastore.request.rf2; +import static com.b2international.snowowl.snomed.core.domain.Rf2ReleaseType.DELTA; import static com.google.common.collect.Lists.newArrayList; import java.io.File; @@ -290,8 +291,9 @@ ImportResponse doImport(final BranchContext context, final File rf2Archive, fina // if not a dryRun, perform import if (!dryRun) { // Import effective time slices in chronological order + boolean collectVisitedComponents = DELTA == releaseType; for (Rf2EffectiveTimeSlice slice : orderedEffectiveTimeSlices) { - slice.doImport(context, codeSystemUri, importconfig, visitedComponents); + slice.doImport(context, codeSystemUri, importconfig, visitedComponents, collectVisitedComponents); } // Update locales registered on the code system diff --git a/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/importer/IgnoredRf2EffectiveTimeSlice.java b/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/importer/IgnoredRf2EffectiveTimeSlice.java index c2096ce3bc7..0baf2e3c5fd 100644 --- a/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/importer/IgnoredRf2EffectiveTimeSlice.java +++ b/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/importer/IgnoredRf2EffectiveTimeSlice.java @@ -76,7 +76,7 @@ public LongKeyMap> getMembersByReferencedComponent() { } @Override - public void doImport(BranchContext context, ResourceURI codeSystemUri, Rf2ImportConfiguration importConfig, Builder visitedComponents) throws Exception { + public void doImport(BranchContext context, ResourceURI codeSystemUri, Rf2ImportConfiguration importConfig, Builder visitedComponents, boolean collectVisitedComponents) throws Exception { context.log().info(message); } diff --git a/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/importer/MapDBRf2EffectiveTimeSlice.java b/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/importer/MapDBRf2EffectiveTimeSlice.java index 1a873b69c4d..a05f2a89df5 100644 --- a/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/importer/MapDBRf2EffectiveTimeSlice.java +++ b/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/importer/MapDBRf2EffectiveTimeSlice.java @@ -175,7 +175,8 @@ public void doImport( final BranchContext context, final ResourceURI codeSystemUri, final Rf2ImportConfiguration importConfig, - final ImmutableSet.Builder visitedComponents) throws Exception { + final ImmutableSet.Builder visitedComponents, + boolean collectVisitedComponents) throws Exception { final Stopwatch w = Stopwatch.createStarted(); final String importingMessage = isUnpublishedSlice() ? "Importing unpublished components" : String.format("Importing components from %s", getEffectiveTime()); @@ -213,7 +214,7 @@ public void doImport( // Register container concept as visited component final String conceptId = getConceptId(component); - visitedComponents.add(ComponentURI.of(codeSystemUri, SnomedConcept.TYPE, conceptId)); + addVisitedComponent(visitedComponents, ComponentURI.of(codeSystemUri, SnomedConcept.TYPE, conceptId), collectVisitedComponents); } // add all members of this component to this batch as well final Set containerComponents = membersByReferencedComponent.remove(componentToImportL); @@ -225,7 +226,7 @@ public void doImport( // Register reference set as visited component final String refSetId = containedComponent.getRefsetId(); - visitedComponents.add(ComponentURI.of(codeSystemUri, SnomedConcept.REFSET_TYPE, refSetId)); + addVisitedComponent(visitedComponents, ComponentURI.of(codeSystemUri, SnomedConcept.REFSET_TYPE, refSetId), collectVisitedComponents); } } } @@ -261,6 +262,12 @@ private TransactionContext openTransaction(final BranchContext context, final St // The default commit comment will not be used return context.openTransaction(context, author, null, DatastoreLockContextDescriptions.IMPORT); } + + private void addVisitedComponent(ImmutableSet.Builder visitedComponents, ComponentURI component, boolean collectVisitedComponents) { + if (collectVisitedComponents) { + visitedComponents.add(component); + } + } private LongSet collectAttributesWithRangeConstraint(final BranchContext context, final String rangeConstraint) { final LongSet typeIds = PrimitiveSets.newLongOpenHashSet(); diff --git a/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/importer/Rf2EffectiveTimeSlice.java b/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/importer/Rf2EffectiveTimeSlice.java index b74bf4fcf55..d78c9b35310 100644 --- a/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/importer/Rf2EffectiveTimeSlice.java +++ b/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/datastore/request/rf2/importer/Rf2EffectiveTimeSlice.java @@ -51,6 +51,6 @@ public interface Rf2EffectiveTimeSlice { LongKeyMap> getMembersByReferencedComponent(); - void doImport(BranchContext context, ResourceURI codeSystemUri, Rf2ImportConfiguration importConfig, Builder visitedComponents) throws Exception; + void doImport(BranchContext context, ResourceURI codeSystemUri, Rf2ImportConfiguration importConfig, Builder visitedComponents, boolean collectVisitedComponents) throws Exception; }