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;
}
Aggregations