public RuntimeConfig getConfig() { return RuntimeConfig.getCurrentInstance( session ); }
public boolean isReadOnly() { return RuntimeConfig.getCurrentInstance( session ).isReadOnlyApp(); }
public IntactTransaction( IntactSession session, Transaction transaction ) { this.transaction = transaction; log.debug( "Transaction started" ); if ( !RuntimeConfig.getCurrentInstance( session ).isDebugMode() ) { if ( log.isDebugEnabled() ) { log.debug( "Storing StackTrace on opening transaction, now the caller can be traced !!" ); } StackTraceElement[] elements = Thread.currentThread().getStackTrace(); stackTrace = new StackTraceElement[elements.length - 2]; for ( int i = 2; i < elements.length; i++ ) { stackTrace[i - 2] = elements[i]; } } this.id = String.valueOf("TR"+System.currentTimeMillis()); }
public void contextDestroyed( ServletContextEvent servletContextEvent ) { log.debug( "LogFactory.release and destroying application" ); LogFactory.release( Thread.currentThread().getContextClassLoader() ); log.debug( "Closing SessionFactory" ); IntactSession intactSession = new WebappSession( servletContextEvent.getServletContext(), null, null ); RuntimeConfig.getCurrentInstance( intactSession ).getDefaultDataConfig().closeSessionFactory(); }
protected void checkReadOnly() { boolean readOnly = RuntimeConfig.getCurrentInstance( intactSession ).isReadOnlyApp(); if ( readOnly ) { throw new IntactException( "This application is running on mode READ-ONLY, so it cannot persist or update " + "objects in the database. Set the init-param " + IntactEnvironment.READ_ONLY_APP + " to false if you want to " + "do that." ); } }
public MockIntactContext(DataContext dataContext, IntactSession session) { super(dataContext, session); this.dataContext = dataContext; this.session = session; runtimeConfig = RuntimeConfig.getCurrentInstance(session); cvContext = CvContext.getCurrentInstance(session); setCurrentInstance(this); }
private DataConfig getDefaultDataConfig() { DataConfig dataConfig = RuntimeConfig.getCurrentInstance( session ).getDefaultDataConfig(); if (dataConfig == null) { dataConfig = IntactContext.calculateDefaultDataConfig( session ); } return dataConfig; } }
public DaoFactory getDaoFactory() { DataConfig dataConfig = RuntimeConfig.getCurrentInstance( session ).getDefaultDataConfig(); return getDaoFactory( dataConfig ); }
public DaoFactory getDaoFactory( String dataConfigName ) { DataConfig dataConfig = RuntimeConfig.getCurrentInstance( session ).getDataConfig( dataConfigName ); return getDaoFactory( dataConfig ); }
private DaoFactory getDaoFactory() { return DaoFactory.getCurrentInstance( session, RuntimeConfig.getCurrentInstance( session ).getDefaultDataConfig() ); }
public static IntactContext createIntactContext( IntactSession session ) { if ( RuntimeConfig.getCurrentInstance( session ).getDataConfigs().isEmpty() ) { log.warn( "No data configs found. Re-initializing IntAct" ); initIntact( session ); } IntactContext context; log.debug( "Creating data context..." ); DataContext dataContext = new DataContext( session ); // start a context log.debug( "Creating IntactContext..." ); context = new IntactContextWrapper( dataContext, session ); initializeDatabaseIfNecessary(context); return context; }
public void flushSession() { DataConfig dataConfig = RuntimeConfig.getCurrentInstance( session ).getDefaultDataConfig(); dataConfig.flushSession(); // flush the CvContext in to avoid lazy initialization errors clearCvContext(); }
private static UserContext createDefaultUserContext( IntactSession session ) { if ( log.isDebugEnabled() ) { log.debug( "Creating UserContext..." ); } AbstractHibernateDataConfig defaultDataConfig = ( AbstractHibernateDataConfig ) RuntimeConfig.getCurrentInstance( session ).getDefaultDataConfig(); Configuration configuration = defaultDataConfig.getConfiguration(); //configuration.configure(); String currentUser = configuration.getProperty( Environment.USER ); String password = configuration.getProperty( Environment.PASS ); UserContext userContext = new UserContext( currentUser, password ); return userContext; }
private static DaoFactory getDefaultDaoFactory(IntactContext context) { IntactSession session = context.getSession(); return DaoFactory.getCurrentInstance(session, RuntimeConfig.getCurrentInstance(session).getDefaultDataConfig()); }
public Session getSession() { RuntimeConfig config = RuntimeConfig.getCurrentInstance( intactSession ); DaoFactory daoFactory = DaoFactory.getCurrentInstance( intactSession, config.getDefaultDataConfig() ); if ( !daoFactory.isTransactionActive() ) { if ( config.isAutoBeginTransaction() ) { log.debug( "Auto starting transaction" ); daoFactory.beginTransaction(); // starts or uses an existing transaction } else { throw new AutoBeginTransactionException( "You must begin a transaction manually." ); } } // invoking the method from the session factory because if the session is closed it will automatically // open one return session.getSessionFactory().getCurrentSession(); }
public void commitAllActiveTransactions() throws IntactTransactionException { Collection<DataConfig> dataConfigs = RuntimeConfig.getCurrentInstance( session ).getDataConfigs(); for ( DataConfig dataConfig : dataConfigs ) { DaoFactory daoFactory = getDaoFactory( dataConfig ); if ( daoFactory.isTransactionActive() ) { daoFactory.getCurrentTransaction().commit(); } } }
public void onPostInsert( PostInsertEvent postInsertEvent ) { if ( !RuntimeConfig.getCurrentInstance( intactSession ).isSynchronizedSearchItems() ) { return; } Object obj = postInsertEvent.getEntity(); if ( obj instanceof AnnotatedObject ) { insertSearchItemForAnnotatedObject( ( AnnotatedObject ) obj, false ); } else if ( obj instanceof Xref ) { insertSearchItemForXref( ( Xref ) obj ); } else if ( obj instanceof Alias ) { insertSearchItemForAlias( ( Alias ) obj ); } else { return; } }
public boolean onPreDelete( PreDeleteEvent preDeleteEvent ) { if ( !RuntimeConfig.getCurrentInstance( intactSession ).isSynchronizedSearchItems() ) { return false; } Object obj = preDeleteEvent.getEntity(); if ( obj instanceof AnnotatedObject ) { deleteSearchItemsForAnnotatedObject( ( AnnotatedObject ) obj ); } else if ( obj instanceof Xref ) { deleteSearchItemForXref( ( Xref ) obj ); } else if ( obj instanceof Alias ) { deleteSearchItemForAlias( ( Alias ) obj ); } else { return false; } return false; }
private static void persistSchemaVersion(IntactContext context) { IntactSession session = context.getSession(); SchemaVersion requiredVersion = context.getConfig().getDefaultDataConfig().getMinimumRequiredVersion(); DbInfo dbInfo = new DbInfo(DbInfo.SCHEMA_VERSION, requiredVersion.toString()); if (log.isDebugEnabled()) log.debug("Persisting schema version: " + requiredVersion.toString()); DaoFactory daoFactory = DaoFactory.getCurrentInstance(session, RuntimeConfig.getCurrentInstance(session).getDefaultDataConfig()); context.getDataContext().beginTransaction(); daoFactory.getDbInfoDao().persist(dbInfo); try { context.getDataContext().commitTransaction(); } catch (IntactTransactionException e) { log.error(e); } }
public void onPostUpdate( PostUpdateEvent postUpdateEvent ) { if ( !RuntimeConfig.getCurrentInstance( intactSession ).isSynchronizedSearchItems() ) { return; } Object obj = postUpdateEvent.getEntity(); if ( obj instanceof AnnotatedObject ) { AnnotatedObject ao = ( AnnotatedObject ) obj; deleteSearchItemsForAnnotatedObject( ao ); insertSearchItemForAnnotatedObject( ao, true ); } else if ( obj instanceof Alias ) { Alias alias = ( Alias ) obj; deleteSearchItemsForAnnotatedObject( alias.getParent() ); insertSearchItemForAnnotatedObject( alias.getParent(), true ); } else if ( obj instanceof Xref ) { Xref xref = ( Xref ) obj; deleteSearchItemsForAnnotatedObject( xref.getParent() ); insertSearchItemForAnnotatedObject( xref.getParent(), true ); } else { return; } }