use of org.jbei.ice.storage.hibernate.dao.SequenceDAO in project ice by JBEI.
the class BulkUploadController method setFileData.
protected PartData setFileData(String userId, Entry entry, PartData partData) {
SequenceDAO sequenceDAO = DAOFactory.getSequenceDAO();
if (sequenceDAO.hasSequence(entry.getId())) {
partData.setHasSequence(true);
String name = sequenceDAO.getSequenceFilename(entry);
partData.setSequenceFileName(name);
}
// check attachment
if (attachmentController.hasAttachment(entry)) {
partData.setHasAttachment(true);
partData.setAttachments(attachmentController.getByEntry(userId, entry.getId()));
}
return partData;
}
use of org.jbei.ice.storage.hibernate.dao.SequenceDAO in project ice by JBEI.
the class AnnotationsTest method testCurate.
@Test
public void testCurate() throws Exception {
Account account = AccountCreator.createTestAccount("AnnotationsTest.testCurate", true);
Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
SequenceDAO sequenceDAO = new SequenceDAO();
Assert.assertFalse(sequenceDAO.hasSequence(plasmid.getId()));
DNASequence dnaSequence = GeneralParser.getInstance().parse(sequenceString);
Sequence sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
sequence.setEntry(plasmid);
sequence = sequenceDAO.saveSequence(sequence);
Assert.assertNotNull(sequence);
SequenceFeatureDAO sequenceFeatureDAO = new SequenceFeatureDAO();
List<SequenceFeature> sequenceFeatures = sequenceFeatureDAO.getEntrySequenceFeatures(plasmid);
Assert.assertEquals(1, sequenceFeatures.size());
Feature feature = sequenceFeatures.get(0).getFeature();
DNAFeature dnaFeature = feature.toDataTransferObject();
Curation curation = new Curation();
curation.setExclude(true);
dnaFeature.setCuration(curation);
List<DNAFeature> features = new ArrayList<>();
features.add(dnaFeature);
Annotations annotations = new Annotations(account.getEmail());
annotations.curate(features);
sequenceFeatures = sequenceFeatureDAO.getEntrySequenceFeatures(plasmid);
feature = sequenceFeatures.get(0).getFeature();
Assert.assertTrue(feature.getCuration().isExclude());
}
use of org.jbei.ice.storage.hibernate.dao.SequenceDAO in project ice by JBEI.
the class ModelToInfoFactory method createTableViewData.
public static PartData createTableViewData(String userId, Entry entry, boolean includeOwnerInfo) {
if (entry == null)
return null;
EntryType type = EntryType.nameToType(entry.getRecordType());
PartData view = new PartData(type);
view.setId(entry.getId());
view.setRecordId(entry.getRecordId());
view.setPartId(entry.getPartNumber());
view.setName(entry.getName());
view.setShortDescription(entry.getShortDescription());
view.setCreationTime(entry.getCreationTime().getTime());
view.setStatus(entry.getStatus());
view.setAlias(entry.getAlias());
// view.setOwnerEmail(entry.getOwnerEmail());
Visibility visibility = Visibility.valueToEnum(entry.getVisibility());
// information about the owner and creator
if (includeOwnerInfo) {
view.setOwner(entry.getOwner());
view.setOwnerId(getAccountId(entry.getOwnerEmail()));
// creator
view.setCreator(entry.getCreator());
view.setCreatorEmail(entry.getCreatorEmail());
view.setCreatorId(getAccountId(entry.getCreatorEmail()));
}
// has sample
view.setHasSample(DAOFactory.getSampleDAO().hasSample(entry));
// has sequence
if (visibility == Visibility.REMOTE) {
view.setHasSequence(entry.getLongDescriptionType().equalsIgnoreCase("sequence"));
} else {
SequenceDAO sequenceDAO = DAOFactory.getSequenceDAO();
view.setHasSequence(sequenceDAO.hasSequence(entry.getId()));
view.setHasOriginalSequence(sequenceDAO.hasOriginalSequence(entry.getId()));
}
// has parents
for (Entry linkedEntry : entry.getLinkedEntries()) {
// todo : authorization
// if (!authorization.canRead(userId, parent))
// continue;
PartData linkedPartData = new PartData(EntryType.nameToType(linkedEntry.getRecordType()));
linkedPartData.setId(linkedEntry.getId());
view.getLinkedParts().add(linkedPartData);
}
List<Entry> parents = DAOFactory.getEntryDAO().getParents(entry.getId());
if (parents != null) {
for (Entry parentEntry : parents) {
PartData partData = new PartData(EntryType.nameToType(parentEntry.getRecordType()));
partData.setId(parentEntry.getId());
view.getParents().add(partData);
}
}
// entry count
view.setViewCount(DAOFactory.getAuditDAO().getHistoryCount(entry));
return view;
}
use of org.jbei.ice.storage.hibernate.dao.SequenceDAO in project ice by JBEI.
the class Collection method setFileData.
protected PartData setFileData(String userId, Entry entry, PartData partData) {
SequenceDAO sequenceDAO = DAOFactory.getSequenceDAO();
if (sequenceDAO.hasSequence(entry.getId())) {
partData.setHasSequence(true);
String name = sequenceDAO.getSequenceFilename(entry);
partData.setSequenceFileName(name);
}
AttachmentController attachmentController = new AttachmentController();
// check attachment
if (attachmentController.hasAttachment(entry)) {
partData.setHasAttachment(true);
partData.setAttachments(attachmentController.getByEntry(userId, entry.getId()));
}
return partData;
}
use of org.jbei.ice.storage.hibernate.dao.SequenceDAO in project ice by JBEI.
the class RemoteEntriesAsCSV method writeLocalEntries.
protected void writeLocalEntries(List<Entry> entries, List<EntryField> fields, CSVWriter writer, ZipOutputStream zos) {
if (entries == null)
return;
SequenceDAO sequenceDAO = DAOFactory.getSequenceDAO();
Configuration configuration = DAOFactory.getConfigurationDAO().get(ConfigurationKey.URI_PREFIX);
String thisUrl = configuration == null ? "" : configuration.getValue();
for (Entry entry : entries) {
String[] line = new String[fields.size() + 4];
line[0] = thisUrl;
line[1] = entry.getCreationTime().toString();
line[2] = entry.getPartNumber();
int i = 2;
for (EntryField field : fields) {
line[i + 1] = EntryUtil.entryFieldToValue(entry, field);
i += 1;
}
// write sequence to zip file
long entryId = entry.getId();
if (sequenceDAO.hasSequence(entryId)) {
String name = entry.getPartNumber() + ".gb";
try {
Sequence sequence = sequenceDAO.getByEntry(entry);
line[i + 1] = name;
GenbankFormatter genbankFormatter = new GenbankFormatter(name);
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
genbankFormatter.format(sequence, byteStream);
ByteArrayWrapper wrapper = new ByteArrayWrapper(byteStream.toByteArray(), name);
putZipEntry(wrapper, zos);
} catch (Exception e) {
line[i + 1] = "";
}
} else {
line[i + 1] = "";
}
writer.writeNext(line);
}
}
Aggregations