Search in sources :

Example 1 with SBOLDocument

use of org.sbolstandard.core.SBOLDocument in project ice by JBEI.

the class BulkFileSBOLUpload method processUpload.

public long processUpload() throws IOException {
    BulkUploadController controller = new BulkUploadController();
    long bulkUploadId = 0;
    SBOLDocument document = SBOLFactory.read(new FileInputStream(filePath.toFile()));
    try {
        // walk top level object
        for (SBOLRootObject rootObject : document.getContents()) {
            ICESBOLParserVisitor visitor = new ICESBOLParserVisitor(addType);
            rootObject.accept(visitor);
            BulkUploadAutoUpdate update = visitor.getUpdate();
            update.setBulkUploadId(bulkUploadId);
            Logger.info(userId + ": " + update.toString());
            update = controller.autoUpdateBulkUpload(userId, update, addType);
            if (bulkUploadId == 0)
                bulkUploadId = update.getBulkUploadId();
            // get "user sequence"
            String sequenceUser = getSequenceDocument(rootObject);
            long entryId = update.getEntryId();
            DNASequence dnaSequence = visitor.getFeaturedDNASequence();
            Sequence sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
            Entry entry = DAOFactory.getEntryDAO().get(entryId);
            sequence.setEntry(entry);
            if (sequenceUser != null)
                sequence.setSequenceUser(sequenceUser);
            new SequenceController().save(userId, sequence);
        }
    } catch (Exception e) {
        Logger.error(e);
        throw new IOException(e);
    }
    return bulkUploadId;
}
Also used : SBOLDocument(org.sbolstandard.core.SBOLDocument) ICESBOLParserVisitor(org.jbei.ice.lib.parsers.sbol.ICESBOLParserVisitor) DNASequence(org.jbei.ice.lib.dto.DNASequence) Sequence(org.jbei.ice.storage.model.Sequence) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) DNASequence(org.jbei.ice.lib.dto.DNASequence) Entry(org.jbei.ice.storage.model.Entry) SBOLRootObject(org.sbolstandard.core.SBOLRootObject) SequenceController(org.jbei.ice.lib.entry.sequence.SequenceController)

Example 2 with SBOLDocument

use of org.sbolstandard.core.SBOLDocument in project ice by JBEI.

the class SBOLFormatter method createXmlDocument.

private SBOLDocument createXmlDocument(DnaComponent dnaComponent) {
    SBOLDocument document = SBOLFactory.createDocument();
    document.addContent(dnaComponent);
    return document;
}
Also used : SBOLDocument(org.sbolstandard.core.SBOLDocument)

Example 3 with SBOLDocument

use of org.sbolstandard.core.SBOLDocument in project ice by JBEI.

the class SBOLFormatter method format.

@Override
public void format(Sequence sequence, OutputStream outputStream) throws FormatterException, IOException {
    SBOLVisitor visitor = new SBOLVisitor();
    visitor.visit(sequence);
    SBOLDocument sbolDocument = createXmlDocument(visitor.getDnaComponent());
    SBOLFactory.write(sbolDocument, outputStream);
}
Also used : SBOLDocument(org.sbolstandard.core.SBOLDocument)

Example 4 with SBOLDocument

use of org.sbolstandard.core.SBOLDocument in project ice by JBEI.

the class BulkFileSBOLUpload method getSequenceDocument.

protected String getSequenceDocument(SBOLRootObject component) {
    SBOLDocument document = SBOLFactory.createDocument();
    document.addContent(component);
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    try {
        SBOLFactory.write(document, stream);
    } catch (IOException e) {
        Logger.error(e);
        return null;
    }
    try {
        return stream.toString(StandardCharsets.UTF_8.name());
    } catch (IOException e) {
        Logger.error(e);
        return null;
    }
}
Also used : SBOLDocument(org.sbolstandard.core.SBOLDocument) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

SBOLDocument (org.sbolstandard.core.SBOLDocument)4 IOException (java.io.IOException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileInputStream (java.io.FileInputStream)1 DNASequence (org.jbei.ice.lib.dto.DNASequence)1 SequenceController (org.jbei.ice.lib.entry.sequence.SequenceController)1 ICESBOLParserVisitor (org.jbei.ice.lib.parsers.sbol.ICESBOLParserVisitor)1 Entry (org.jbei.ice.storage.model.Entry)1 Sequence (org.jbei.ice.storage.model.Sequence)1 SBOLRootObject (org.sbolstandard.core.SBOLRootObject)1