use of org.jbei.ice.lib.entry.EntryLinks in project ice by JBEI.
the class SBOLParser method createICEComponentDefinitionRecord.
protected void createICEComponentDefinitionRecord(SBOLDocument document, ComponentDefinition componentDefinition) throws SBOLValidationException {
SBOLDocument rootedDocument = document.createRecursiveCopy(componentDefinition);
String identity = componentDefinition.getIdentity().toString();
Long partId = identityEntryMap.get(identity);
if (partId == null) {
createNewEntry(componentDefinition, rootedDocument);
}
// Add rootedDocument as the SBOL associated with this record
for (Component component : componentDefinition.getComponents()) {
if (component.getDefinition() == null)
continue;
Long componentId = identityEntryMap.get(component.getDefinition().getIdentity().toString());
if (componentId == null) {
SBOLDocument sbolDocument = document.createRecursiveCopy(component.getDefinition());
componentId = createNewEntry(component.getDefinition(), sbolDocument);
}
EntryLinks links = new EntryLinks(userId, componentId.toString());
links.addLink(this.partData, LinkType.PARENT);
Logger.debug(" Link to ComponentDefinition: " + component.getDefinition().getIdentity());
}
}
use of org.jbei.ice.lib.entry.EntryLinks in project ice by JBEI.
the class BulkUploadEntries method doUpdate.
private PartData doUpdate(String userId, Entry entry, PartData data) {
if (entry == null)
return null;
Entries entries = new Entries(userId);
entries.update(entry.getId(), data);
// check if there is any linked parts. update if so (expect a max of 1)
if (data.getLinkedParts() == null || data.getLinkedParts().isEmpty())
return data;
// retrieve the entry (this is the only time you can create another entry on update)
// bulk upload can only link 1
PartData linkedPartData = data.getLinkedParts().get(0);
Entry linkedEntry = entryDAO.get(linkedPartData.getId());
if (linkedEntry == null && !StringUtils.isEmpty(linkedPartData.getPartId())) {
// try partId
linkedEntry = entryDAO.getByPartNumber(linkedPartData.getPartId());
if (linkedEntry != null)
linkedPartData.setId(linkedEntry.getId());
}
if (linkedEntry == null) {
// create new object for linked entry
linkedEntry = InfoToModelFactory.infoToEntry(linkedPartData);
if (linkedEntry != null) {
linkedEntry.setVisibility(Visibility.DRAFT.getValue());
Account account = accountController.getByEmail(userId);
linkedEntry.setOwner(account.getFullName());
linkedEntry.setOwnerEmail(account.getEmail());
linkedEntry = entryDAO.create(linkedEntry);
entry.getLinkedEntries().add(linkedEntry);
entryDAO.update(linkedEntry);
linkedPartData.setId(linkedEntry.getId());
}
} else {
// linking to existing
EntryLinks entryLinks = new EntryLinks(userId, Long.toString(entry.getId()));
entryLinks.addLink(linkedPartData, LinkType.CHILD);
}
// recursively update
PartData linked = doUpdate(userId, linkedEntry, linkedPartData);
data.getLinkedParts().clear();
if (linked != null)
data.getLinkedParts().add(linked);
return data;
}
use of org.jbei.ice.lib.entry.EntryLinks in project ice by JBEI.
the class SBOLParser method createICEModuleDefinitionRecord.
protected void createICEModuleDefinitionRecord(SBOLDocument document, ModuleDefinition moduleDefinition) throws SBOLValidationException {
SBOLDocument rootedDocument = document.createRecursiveCopy(moduleDefinition);
Logger.debug("Creating ICE record for ModuleDefinition: " + moduleDefinition.getIdentity());
String identity = moduleDefinition.getIdentity().toString();
Long partId = identityEntryMap.get(identity);
if (partId == null) {
Logger.debug("Creating " + moduleDefinition.getDisplayId());
createNewEntry(moduleDefinition, rootedDocument);
}
for (FunctionalComponent functionalComponent : moduleDefinition.getFunctionalComponents()) {
ComponentDefinition componentDefinition = functionalComponent.getDefinition();
// Note: record may not exist yet, so you might need to create it now too
if (componentDefinition == null)
continue;
Long componentId = identityEntryMap.get(componentDefinition.getIdentity().toString());
if (componentId == null) {
SBOLDocument sbolDocument = document.createRecursiveCopy(componentDefinition);
componentId = createNewEntry(componentDefinition, sbolDocument);
}
EntryLinks links = new EntryLinks(userId, componentId.toString());
links.addLink(this.partData, LinkType.PARENT);
}
// Note: record may not exist yet, so you might need to create it now too
for (Module module : moduleDefinition.getModules()) {
if (module.getDefinition() == null)
continue;
Long moduleId = identityEntryMap.get(module.getDefinition().getIdentity().toString());
if (moduleId == null) {
SBOLDocument moduleDocument = document.createRecursiveCopy(module.getDefinition());
moduleId = createNewEntry(module.getDefinition(), moduleDocument);
}
EntryLinks links = new EntryLinks(userId, moduleId.toString());
links.addLink(this.partData, LinkType.PARENT);
Logger.debug(" Link to ModuleDefinition: " + module.getDefinition().getIdentity());
}
}