use of gov.nih.nci.ctd2.dashboard.model.DashboardEntity in project nci-ctd2-dashboard by CBIIT.
the class DashboardDaoImpl method batchSave.
@Override
public void batchSave(Collection<? extends DashboardEntity> entities, int batchSize) {
if (entities == null || entities.isEmpty())
return;
Session session = getSessionFactory().openSession();
session.beginTransaction();
int i = 0;
for (DashboardEntity entity : entities) {
if (entity instanceof Subject) {
Subject subject = (Subject) entity;
for (Xref x : subject.getXrefs()) {
session.save(x);
}
for (Synonym x : subject.getSynonyms()) {
session.save(x);
}
}
session.save(entity);
i++;
if (batchSize != 0 && i % batchSize == 0) {
session.flush();
session.clear();
}
}
session.flush();
session.clear();
session.getTransaction().commit();
session.close();
}
use of gov.nih.nci.ctd2.dashboard.model.DashboardEntity in project nci-ctd2-dashboard by CBIIT.
the class ProteinDataWriter method write.
public void write(List<? extends ProteinData> items) throws Exception {
ArrayList<DashboardEntity> entities = new ArrayList<DashboardEntity>();
for (ProteinData proteinData : items) {
Set<Transcript> transcripts = proteinData.transcripts;
for (Transcript tra : transcripts) {
String traStableURL = new StableURL().createURLWithPrefix("transcript", tra.getRefseqId());
tra.setStableURL(traStableURL);
}
entities.addAll(proteinData.transcripts);
log.info("Storing protein: " + proteinData.protein.getDisplayName());
String stableURL = new StableURL().createURLWithPrefix("protein", proteinData.protein.getUniprotId());
proteinData.protein.setStableURL(stableURL);
entities.add(proteinData.protein);
}
dashboardDao.batchSave(entities, batchSize);
}
use of gov.nih.nci.ctd2.dashboard.model.DashboardEntity in project nci-ctd2-dashboard by CBIIT.
the class ControlledVocabularyPerColumnWriter method write.
public void write(List<? extends ControlledVocabulary> items) throws Exception {
if (entityCache == null)
entityCache = new HashSet<DashboardEntity>();
if (entities == null)
entities = new ArrayList<DashboardEntity>();
for (ControlledVocabulary controlledVocabulary : items) {
String observedRoleName = "";
if (controlledVocabulary.observedRole instanceof ObservedSubjectRole) {
observedRoleName = ((ObservedSubjectRole) controlledVocabulary.observedRole).getColumnName();
} else if (controlledVocabulary.observedRole instanceof ObservedEvidenceRole) {
observedRoleName = ((ObservedEvidenceRole) controlledVocabulary.observedRole).getColumnName();
}
log.info("Storing Observed Role: " + observedRoleName);
if (!entityCache.contains(controlledVocabulary.role)) {
entityCache.add(controlledVocabulary.role);
entities.add(controlledVocabulary.role);
}
ObservationTemplate ot = (ObservationTemplate) controlledVocabulary.observationTemplate;
if (!entityCache.contains(ot.getSubmissionCenter())) {
SubmissionCenter submissionCenter = dashboardDao.findSubmissionCenterByName(ot.getSubmissionCenter().getDisplayName());
if (submissionCenter == null) {
entities.add(ot.getSubmissionCenter());
}
entityCache.add(ot.getSubmissionCenter());
}
if (!entityCache.contains(controlledVocabulary.observationTemplate)) {
entityCache.add(controlledVocabulary.observationTemplate);
entities.add(controlledVocabulary.observationTemplate);
}
if (!entityCache.contains(controlledVocabulary.observedRole)) {
entityCache.add(controlledVocabulary.observedRole);
entities.add(controlledVocabulary.observedRole);
}
}
dashboardDao.batchSave(entities, batchSize);
}
use of gov.nih.nci.ctd2.dashboard.model.DashboardEntity in project nci-ctd2-dashboard by CBIIT.
the class CellLineDataWriter method execute.
public RepeatStatus execute(StepContribution arg0, ChunkContext arg1) throws Exception {
ArrayList<DashboardEntity> entities = new ArrayList<DashboardEntity>();
for (CellSample cellSample : cellSampleMap.values()) {
entities.addAll(cellSample.getAnnotations());
String stableURL = new StableURL().createURLWithPrefix("cell-sample", cellSample.getDisplayName());
cellSample.setStableURL(stableURL);
entities.add(cellSample);
}
dashboardDao.batchSave(entities, batchSize);
return RepeatStatus.FINISHED;
}
Aggregations