private void checkResult(AnnotatedObject<?, ?> annotatedObject, String ac, String type) { if (annotatedObject == null) { throw new IntactException("No " + type + " found with: " + ac); } } }
public void rollback() throws IntactTransactionException { log.debug( "Rolling-back transaction" ); try { transaction.rollback(); } catch ( HibernateException e ) { throw new IntactTransactionException( "Rollback exception", e ); } }
public static <T> T newInstance(Class<T> clazz) { T instance; try { instance = clazz.newInstance(); } catch (Exception e) { throw new IntactException(e); } return instance; } }
public void commit() throws IntactTransactionException { log.debug( "Committing transaction" ); try { transaction.commit(); } catch ( HibernateException e ) { throw new IntactTransactionException( "Commit exception", e ); } assert ( wasCommitted() ); log.debug( "Transaction committed" ); }
public void addPackageWithEntities( String packageName ) { if ( isInitialized() ) { throw new IntactException( "Cannot add package after the sessionFactory has been initialized" ); } packagesWithEntities.add( packageName ); }
public void commitTransaction() throws IntactTransactionException { try { commitTransaction( getDefaultDataConfig().getName() ); } catch ( Exception e ) { throw new IntactTransactionException( e ); } }
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." ); } }
/** * Initialize the database, adding the institution and schema version, if necessary * @param context IntactContext */ public static void initializeDatabaseIfNecessary(IntactContext context) { try { persistInstitutionAndCvsIfNecessary( context ); } catch ( IntactTransactionException e ) { throw new IntactException( "Error while persisting institution.", e ); } persistSchemaVersionIfNecessary( context ); }
protected void commitTransaction() { try { getDataContext().commitTransaction(); } catch (IntactTransactionException e) { throw new IntactException(e); } }
protected void commitTransaction() { try { getDataContext().commitTransaction(); } catch (IntactTransactionException e) { throw new IntactException(e); } }
/** * Create a <code>SearchableQuery</code> from a String. Using a regex pattern, gets the properties * and values from the expression and creates the query object using reflection */ public static SearchableQuery parseSearchableQuery( String searchableQueryStr ) { if ( !isSearchableQuery( searchableQueryStr ) ) { throw new IntactException( "Not a parseable SearchableQuery: " + searchableQueryStr ); } SearchableQuery query = new SearchableQuery(); searchableQueryStr = searchableQueryStr.substring( 1, searchableQueryStr.length() - 1 ); String[] tokens = searchableQueryStr.split( ";" ); for ( String token : tokens ) { String[] propAndValue = token.split( "=" ); String propName = propAndValue[0]; String propValue = propAndValue[1]; // remove quotes if needed if ( propValue.startsWith( "'" ) && propValue.endsWith( "'" ) ) { propValue = propValue.substring( 1, propValue.length() - 1 ); } try { addPropertyWithReflection( query, propName, propValue ); } catch ( Exception e ) { throw new IntactException( "Exception parsing " + propName + "=" + propValue + " in SearchQuery from String: " + searchableQueryStr, e ); } } return query; }
/** * Initialize the database, adding the institution and schema version * @param context IntactContext */ public static void initializeDatabase(IntactContext context) { try { persistInstitution(context); } catch (IntactTransactionException e) { throw new IntactException("Error while persisting institution.", e); } persistSchemaVersion(context); persistBasicCvObjects(context); }
/** * This method gets a result map for a specific iql query. * * @param iqlQuery query string in the IQL syntax * @param numberOfResults maximum number of results * * @return a Map containing the results, the keys in the Map are the ac number of the search objects and the values * are the objclass * * @throws IntactException */ public Map findObjectByIQL( final String iqlQuery, final int numberOfResults ) throws IntactException { logger.info( "IQL query: " + iqlQuery ); String luceneQuery = null; try { // parse the IQL statement into an lucene statement luceneQuery = iqlParser.getLuceneQuery( iqlQuery ); logger.info( "got luceneQuery: " + luceneQuery ); } catch ( IntactException e ) { logger.error( "Problems with the IQL parsing \n" + e ); throw new IntactException( "Problems with the IQL parsing", e ); } logger.info( "lucene query: " + luceneQuery ); logger.info( "send to findObjectByLucene..." ); return this.findObjectByLucene( luceneQuery, numberOfResults ); }
private Map<Class<? extends CvObject>, Set<String>> getChildrenCvClassified( CvDagObject parentCv ) { if ( parentCv == null ) { throw new IntactException( "CvDagObject is null" ); } Map<Class<? extends CvObject>, Set<String>> cvsMap = new HashMap<Class<? extends CvObject>, Set<String>>(); List<CvDagObject> children = new ArrayList<CvDagObject>(); fillChildrenRecursively( parentCv, children ); for ( CvDagObject child : children ) { addCvObjectToMap( cvsMap, child.getClass(), child.getShortLabel() ); } return cvsMap; }
private Collection<Experiment> getExperiments( int firstResult, int maxResults ) { output.println( "Retrieving data from DB store, from " + firstResult ); if ( searchPattern.contains( "," ) ) { throw new IntactException( "Lists with comma-separated experiments are not accepted anymore" ); } Collection<Experiment> searchResults = getDaoFactory().getExperimentDao().getByShortLabelLike( searchPattern, true, firstResult, maxResults, true ); int resultSize = searchResults.size(); output.println( "done (retrieved " + resultSize + " experiment" + ( resultSize > 1 ? "s" : "" ) + ")" ); return searchResults; }
private Collection<Experiment> getExperiments( int firstResult, int maxResults ) { log.debug( "Retrieving data from DB store, from " + firstResult ); if ( searchPattern.contains( "," ) ) { throw new IntactException( "Lists with comma-separated experiments are not accepted anymore" ); } Collection<Experiment> searchResults = getDaoFactory().getExperimentDao().getByShortLabelLike( searchPattern, true, firstResult, maxResults, true ); int resultSize = searchResults.size(); log.debug( "done (retrieved " + resultSize + " experiment" + ( resultSize > 1 ? "s" : "" ) + ")" ); return searchResults; }
private Collection<Experiment> getExperiments( int firstResult, int maxResults ) { output.println( "Retrieving data from DB store, from " + firstResult ); if ( searchPattern.contains( "," ) ) { throw new IntactException( "Lists with comma-separated experiments are not accepted anymore" ); } Collection<Experiment> searchResults = getDaoFactory().getExperimentDao().getByShortLabelLike( searchPattern, true, firstResult, maxResults, true ); int resultSize = searchResults.size(); output.println( "done (retrieved " + resultSize + " experiment" + ( resultSize > 1 ? "s" : "" ) + ")" ); return searchResults; }
public static UserContext getCurrentInstance( IntactSession session ) { if ( !session.isRequestAvailable() ) { throw new IntactException( "Cannot get a UserContext if the IntactSession does not have request and session scope" ); } Object obj = session.getAttribute( SESSION_ATT_NAME ); if ( obj != null ) { return ( UserContext ) obj; } UserContext userContext = createDefaultUserContext( session ); session.setAttribute( SESSION_ATT_NAME, userContext ); return userContext; }
private <X extends Xref> X createPsiMiXref(Class<X> xrefClass, String psiMi, Institution institution) { if (xrefClass == null) { throw new NullPointerException("xrefClass"); } X xref; try { xref = xrefClass.newInstance(); } catch (Exception e) { throw new IntactException("Problems instantiating Xref of type: " + xrefClass.getName()); } xref.setOwner(institution); xref.setPrimaryId(psiMi); xref.setCvDatabase(createPsiMiCvDatabase(institution)); xref.setCvXrefQualifier(createIdentityCvXrefQualifier(institution)); return xref; }
public GeneratedEntry addInteractorWithUniprotId(String uniprotId) { List<ProteinImpl> interactors = intactContext.getDataContext().getDaoFactory() .getProteinDao().getByUniprotId(uniprotId); if (interactors.isEmpty()) { throw new IntactException("No interactors found with uniprot id: " + uniprotId); } for (Interactor interactor : interactors) { addInteractor(interactor); } return this; }