daoFactory.getBaseDao().persist( ao ); } catch (Exception e) { throw new PersisterException("Problem persisting: "+ao, e); throw new IllegalStateException( "Object to persist should have an AC: " + DebugUtil.annotatedObjectToString(ao, true)); } else { daoFactory.getBaseDao().merge( ao ); if (statisticsEnabled) statistics.addMerged(ao);
System.out.println("Database instance: " + IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getBaseDao().getDbName()); System.out.println("User: " + IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getBaseDao().getDbUserName());
/** * Check if the object state is "new" or "managed". This check is useful in those * cases where we need to check if the collections (annotations, aliases and xrefs) are * accessible and won't throw a LazyInitializationException if accessed. * * @param annotatedObject The AnnotatedObject to check * @return True if is new or managed */ public static boolean isNewOrManaged(AnnotatedObject annotatedObject) { // is it new? if (annotatedObject.getAc() == null) return true; // is it transient? (as in opposition to managed) if (IntactContext.currentInstanceExists() && IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getBaseDao().isTransient(annotatedObject)) { return false; } return true; }
/** * Check if the object state is "new" or "managed". This check is useful in those * cases where we need to check if the collections (annotations, aliases and xrefs) are * accessible and won't throw a LazyInitializationException if accessed. * * @param annotatedObject The AnnotatedObject to check * @return True if is new or managed */ public static boolean isNewOrManaged(AnnotatedObject annotatedObject) { // is it new? if (annotatedObject.getAc() == null) return true; // is it transient? (as in opposition to managed) if (IntactContext.currentInstanceExists() && IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getBaseDao().isTransient(annotatedObject)) { return false; } return true; }
if ( baseDao.isTransient( ao )) {
daoFactory.getBaseDao().persist( ao ); } catch (Exception e) { throw new PersisterException("Problem persisting: "+ao, e); throw new IllegalStateException( "Object to persist should have an AC: " + DebugUtil.annotatedObjectToString(ao, true)); } else { daoFactory.getBaseDao().merge( ao ); if (statisticsEnabled) statistics.addMerged(ao);
System.out.println("Database instance: " + IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getBaseDao().getDbName()); System.out.println("User: " + IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getBaseDao().getDbUserName());
if ( baseDao.isTransient( ao )) {
System.out.println("Database instance: " + IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getBaseDao().getDbName()); System.out.println("User: " + IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getBaseDao().getDbUserName()); } catch (SQLException e) { System.out.println("ERROR: Could not get database information (instance name and username).");
private CvTopic createCvTopicObsolete() { final DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); if ( obsoleteTopic != null ) { if (daoFactory.getBaseDao().isTransient(obsoleteTopic) && obsoleteTopic.getAc() != null) { obsoleteTopic = daoFactory.getCvObjectDao( CvTopic.class ).getByAc( obsoleteTopic.getAc() ); } } else { obsoleteTopic = daoFactory.getCvObjectDao( CvTopic.class ).getByPsiMiRef( CvTopic.OBSOLETE_MI_REF ); } if ( obsoleteTopic == null ) { // create the obsolete term (which is obsolete too!) obsoleteTopic = CvObjectUtils.createCvObject( IntactContext.getCurrentInstance().getInstitution(), CvTopic.class, CvTopic.OBSOLETE_MI_REF, CvTopic.OBSOLETE ); obsoleteTopic.setFullName( "obsolete term" ); addObsoleteAnnotation( obsoleteTopic, "Deprecated CV term that should not be used to annotate entries" ); } return obsoleteTopic; }