Search in sources :

Example 1 with ICESBOLParserVisitor

use of org.jbei.ice.lib.parsers.sbol.ICESBOLParserVisitor 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)

Aggregations

FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)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 SBOLDocument (org.sbolstandard.core.SBOLDocument)1 SBOLRootObject (org.sbolstandard.core.SBOLRootObject)1