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