Search in sources :

Example 6 with Attachment

use of com.b2international.snowowl.core.attachments.Attachment in project snow-owl by b2ihealthcare.

the class SnomedContentRule method before.

@Override
protected void before() throws Throwable {
    createCodeSystemIfNotExist();
    Attachment attachment = Attachment.upload(Services.context(), importArchive);
    String jobId = SnomedRequests.rf2().prepareImport().setRf2Archive(attachment).setReleaseType(contentType).setCreateVersions(true).setImportUntil(importUntil).build(codeSystemId).runAsJobWithRestart(SnomedRf2Requests.importJobKey(codeSystemId), "Importing RF2 content into " + codeSystemId).execute(Services.bus()).getSync(1, TimeUnit.MINUTES);
    RemoteJobEntry job = JobRequests.waitForJob(Services.bus(), jobId, 2000);
    assertTrue("Failed to import RF2 archive", job.isSuccessful());
}
Also used : Attachment(com.b2international.snowowl.core.attachments.Attachment) RemoteJobEntry(com.b2international.snowowl.core.jobs.RemoteJobEntry)

Example 7 with Attachment

use of com.b2international.snowowl.core.attachments.Attachment in project snow-owl by b2ihealthcare.

the class SnomedImportRowValidatorTest method importArchive.

private ImportResponse importArchive(String archiveFilePath, Rf2ReleaseType releaseType) throws FileNotFoundException {
    final String codeSystemId = branchPath.lastSegment();
    try {
        CodeSystemRequests.prepareGetCodeSystem(codeSystemId).buildAsync().execute(getBus()).getSync(1L, TimeUnit.MINUTES);
    } catch (NotFoundException e) {
        CodeSystemRequests.prepareNewCodeSystem().setBranchPath(branchPath.getPath()).setId(codeSystemId).setToolingId(SnomedTerminologyComponentConstants.TOOLING_ID).setUrl(SnomedTerminologyComponentConstants.SNOMED_URI_SCT + "/" + codeSystemId).setTitle(codeSystemId).build("info@b2international.com", "Created new code system " + codeSystemId).execute(getBus()).getSync(1L, TimeUnit.MINUTES);
    }
    Attachment attachment = Attachment.upload(Services.context(), PlatformUtil.toAbsolutePath(this.getClass(), archiveFilePath));
    return SnomedRequests.rf2().prepareImport().setCreateVersions(false).setReleaseType(releaseType).setRf2Archive(attachment).build(branchPath.getPath()).execute(getBus()).getSync();
}
Also used : FileNotFoundException(java.io.FileNotFoundException) NotFoundException(com.b2international.commons.exceptions.NotFoundException) Attachment(com.b2international.snowowl.core.attachments.Attachment)

Aggregations

Attachment (com.b2international.snowowl.core.attachments.Attachment)7 AttachmentRegistry (com.b2international.snowowl.core.attachments.AttachmentRegistry)2 InternalAttachmentRegistry (com.b2international.snowowl.core.attachments.InternalAttachmentRegistry)2 CodeSystem (com.b2international.snowowl.core.codesystem.CodeSystem)2 RemoteJobEntry (com.b2international.snowowl.core.jobs.RemoteJobEntry)2 Version (com.b2international.snowowl.core.version.Version)2 Operation (io.swagger.v3.oas.annotations.Operation)2 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)2 File (java.io.File)2 IOException (java.io.IOException)2 Pair (com.b2international.commons.Pair)1 BadRequestException (com.b2international.commons.exceptions.BadRequestException)1 NotFoundException (com.b2international.commons.exceptions.NotFoundException)1 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)1 Json (com.b2international.commons.json.Json)1 RevisionIndex (com.b2international.index.revision.RevisionIndex)1 ApplicationContext (com.b2international.snowowl.core.ApplicationContext)1 ResourceURI (com.b2international.snowowl.core.ResourceURI)1 TerminologyResource (com.b2international.snowowl.core.TerminologyResource)1 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)1