@Override protected Institution fetchFromDataSource(Institution intactObject) { InstitutionXref idXref = null; for (InstitutionXref xref : intactObject.getXrefs()) { if (CvObjectUtils.getPsiMiIdentityXref(xref.getCvDatabase()).getPrimaryId() .equals(CvDatabase.PSI_MI_MI_REF)) { idXref = xref; } } if (idXref != null) { return IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getInstitutionDao().getByXref(idXref.getPrimaryId()); } return IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getInstitutionDao().getByShortLabel(intactObject.getShortLabel()); }
log.debug( "\t\tReplicating " + institution.getClass().getSimpleName() + ": " + institution.getShortLabel()+ " (AC:"+ institution.getAc() +")" ); getDaoFactory().getInstitutionDao().replicate(institution); } else { if ( log.isDebugEnabled() ) { log.debug( "\t\tPersisting " + institution.getClass().getSimpleName() + ": " + institution.getShortLabel() ); getDaoFactory().getInstitutionDao().persist(institution);
/** * Import a testDataset into the database * @param testDataset the dataset to use */ public void importTestDataset(DbUnitTestDataset testDataset) { if (testDataset == null) { throw new NullPointerException("testDataset"); } try { IDataSet dbUnitDataSet = convertTestDatasetToDbUnit(testDataset); DatabaseOperation.INSERT.execute(getDatabaseConnection(), dbUnitDataSet); } catch (Exception e) { throw new IntactException("Exception importing dataset: "+testDataset.getId(), e); } // reset institution List<Institution> institutions = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getInstitutionDao().getAll(); if (!institutions.isEmpty()) { IntactContext.getCurrentInstance().getConfig().setInstitution(institutions.get(0)); } }
.getInstitutionDao().getByShortLabel( institutionLabel ); try { tx.commit();
private static void persistInstitution(IntactContext context) throws IntactTransactionException { Institution institution = context.getConfig().getInstitution(); if (institution == null) { throw new NullPointerException("Institution is null. Set an institution to the RuntimeConfig first"); } // remove ac, it should not have one at this point to be persisted correctly if (institution.getAc() != null) institution.setAc(null); log.debug("Persisting institution: " + institution.getShortLabel()); DaoFactory daoFactory = getDefaultDaoFactory(context); daoFactory.beginTransaction(); daoFactory.getInstitutionDao().persist(institution); context.getDataContext().commitTransaction(); }
institution = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getInstitutionDao().getByShortLabel(intactObject.getShortLabel());