Tabnine Logo
IntactContext.currentInstanceExists
Code IndexAdd Tabnine to your IDE (free)

How to use
currentInstanceExists
method
in
uk.ac.ebi.intact.core.context.IntactContext

Best Java code snippets using uk.ac.ebi.intact.core.context.IntactContext.currentInstanceExists (Showing top 16 results out of 315)

origin: uk.ac.ebi.intact.core/intact-core-readonly

/**
 * Gets the current (ThreadLocal) instance of {@code IntactContext}. If no such instance exist,
 * IntAct Core will be automatically initialized using JPA configurations in the classpath, configured
 * DataConfigs and, if these are not found, using a temporary database.
 *
 * @return the IntactContext instance
 */
public static IntactContext getCurrentInstance() {
  if (!currentInstanceExists()) {
    log.warn("Current instance of IntactContext is null. Initializing a context in memory.");
    initStandaloneContextInMemory();
  }
  return instance;
}
origin: uk.ac.ebi.intact.core/intact-core

/**
 * Gets the current (ThreadLocal) instance of {@code IntactContext}. If no such instance exist,
 * IntAct Core will be automatically initialized using JPA configurations in the classpath, configured
 * DataConfigs and, if these are not found, using a temporary database.
 *
 * @return the IntactContext instance
 */
public static IntactContext getCurrentInstance() {
  if (!currentInstanceExists()) {
    log.warn("Current instance of IntactContext is null. Initializing a context in memory.");
    initStandaloneContextInMemory();
  }
  return instance;
}
origin: uk.ac.ebi.intact.dataexchange/intact-cvutils

protected CvUpdater() throws IOException, OBOParseException {
  if (!IntactContext.currentInstanceExists()) {
    throw new IllegalStateException("To instantiate a CvUpdated using no arguments, an instance of IntactContext must exist");
  }
  this.processed = new HashMap<String, CvObject>();
  this.stats = new CvUpdaterStatistics();
  this.intactContext = IntactContext.getCurrentInstance();
  this.persisterHelper = intactContext.getPersisterHelper();
}
origin: uk.ac.ebi.intact.core/intact-core

/**
 * Update the shortlabel based on the data available in the database.
 */
public void synchronizeShortLabel() {
  if( IntactContext.currentInstanceExists() ) {
    if( IntactContext.getCurrentInstance().getConfig().isAutoUpdateInteractionLabel() ) {
      String shortLabel = getShortLabel();
      String newShortLabel = InteractionUtils.syncShortLabelWithDb(shortLabel);
      if (!shortLabel.equals(newShortLabel)) {
        if (log.isDebugEnabled()) log.debug("Interaction with label '"+shortLabel+"' renamed '"+newShortLabel+"'" );
        setShortLabel(newShortLabel);
      }
    }
  } else {
    log.warn( "There is no IntAct Context initialized, skipping interaction shortlabel synchronization." );
  }
}
origin: uk.ac.ebi.intact.core/intact-core-readonly

/**
 * Update the shortlabel based on the data available in the database.
 */
public void synchronizeShortLabel() {
  if( IntactContext.currentInstanceExists() ) {
    if( IntactContext.getCurrentInstance().getConfig().isAutoUpdateInteractionLabel() ) {
      String shortLabel = getShortLabel();
      String newShortLabel = InteractionUtils.syncShortLabelWithDb(shortLabel);
      if (!shortLabel.equals(newShortLabel)) {
        if (log.isDebugEnabled()) log.debug("Interaction with label '"+shortLabel+"' renamed '"+newShortLabel+"'" );
        setShortLabel(newShortLabel);
      }
    }
  } else {
    log.warn( "There is no IntAct Context initialized, skipping interaction shortlabel synchronization." );
  }
}
origin: uk.ac.ebi.intact.core/intact-core

@PrePersist
public void synchronizeShortLabel() {
  if( IntactContext.currentInstanceExists() ) {
    if( IntactContext.getCurrentInstance().getConfig().isAutoUpdateExperimentLabel() ) {
      String shortLabel = getShortLabel();
      String newShortLabel = shortLabel;
      try {
        newShortLabel = ExperimentUtils.syncShortLabelWithDb(shortLabel, ExperimentUtils.getPubmedId( this ));
      } catch (Exception e) {
        log.error("Exception synchronizing the label, probably due to an invalid format: "+newShortLabel, e);
      }
      if (!shortLabel.equals(newShortLabel)) {
        if (log.isDebugEnabled()) log.debug("Experiment with label '"+shortLabel+"' renamed '"+newShortLabel+"'" );
        setShortLabel(newShortLabel);
      }
    }
  } else {
    log.warn( "There is no IntAct Context initialized, skipping experiment shortlabel synchronization." );
  }
}
origin: uk.ac.ebi.intact.core/intact-core-readonly

@PrePersist
public void synchronizeShortLabel() {
  if( IntactContext.currentInstanceExists() ) {
    if( IntactContext.getCurrentInstance().getConfig().isAutoUpdateExperimentLabel() ) {
      String shortLabel = getShortLabel();
      String newShortLabel = shortLabel;
      try {
        newShortLabel = ExperimentUtils.syncShortLabelWithDb(shortLabel, ExperimentUtils.getPubmedId( this ));
      } catch (Exception e) {
        log.error("Exception synchronizing the label, probably due to an invalid format: "+newShortLabel, e);
      }
      if (!shortLabel.equals(newShortLabel)) {
        if (log.isDebugEnabled()) log.debug("Experiment with label '"+shortLabel+"' renamed '"+newShortLabel+"'" );
        setShortLabel(newShortLabel);
      }
    }
  } else {
    log.warn( "There is no IntAct Context initialized, skipping experiment shortlabel synchronization." );
  }
}
origin: uk.ac.ebi.intact.dataexchange.psimi/intact-psixml-converters

public Institution getDefaultInstitutionForAcs() {
  if (defaultInstitutionForAcs == null && IntactContext.currentInstanceExists()) {
    defaultInstitutionForAcs = IntactContext.getCurrentInstance().getInstitution();
    if (defaultInstitutionForAcs != null) {
      InstitutionXref xref = XrefUtils.getPsiMiIdentityXref(defaultInstitutionForAcs);
      if (xref != null) {
        defaultInstitutionPrimaryIdForAcs = xref.getPrimaryId();
      }
    }
  }
  return defaultInstitutionForAcs;
}
origin: uk.ac.ebi.intact.core/intact-core-readonly

/**
 * The ID is the concatenation of the prefix and a sequence provided by the database, separated
 * by a dash.
 *
 * @param sessionImplementor a hibernate session implementor
 * @param object             the object being persisted
 *
 * @return the new generated ID
 *
 * @throws HibernateException if something goes wrong
 */
@Override
public Serializable generate( SessionImplementor sessionImplementor, Object object ) throws HibernateException {
  String prefix;
  if (IntactContext.currentInstanceExists()) {
    prefix = IntactContext.getCurrentInstance().getConfig().getAcPrefix();
  } else {
    prefix = "UNK";
  }
  String id = prefix + "-" + super.generate( sessionImplementor, object );
  log.trace( "Assigning Id: " + id );
  return id;
}
origin: uk.ac.ebi.intact.core/intact-core

/**
 * The ID is the concatenation of the prefix and a sequence provided by the database, separated
 * by a dash.
 *
 * @param sessionImplementor a hibernate session implementor
 * @param object             the object being persisted
 *
 * @return the new generated ID
 *
 * @throws HibernateException if something goes wrong
 */
@Override
public Serializable generate( SessionImplementor sessionImplementor, Object object ) throws HibernateException {
  String prefix;
  if (IntactContext.currentInstanceExists()) {
    prefix = IntactContext.getCurrentInstance().getConfig().getAcPrefix();
  } else {
    prefix = "UNK";
  }
  String id = prefix + "-" + super.generate( sessionImplementor, object );
  log.trace( "Assigning Id: " + id );
  return id;
}
origin: uk.ac.ebi.intact.core/intact-core-readonly

if (IntactContext.currentInstanceExists() && IntactContext.getCurrentInstance().getSpringContext().containsBean("userContext")) {
  UserContext userContext = (UserContext) IntactContext.getCurrentInstance().getSpringContext().getBean("userContext");
origin: uk.ac.ebi.intact.core/intact-core

if (IntactContext.currentInstanceExists() && IntactContext.getCurrentInstance().getSpringContext().containsBean("userContext")) {
  UserContext userContext = (UserContext) IntactContext.getCurrentInstance().getSpringContext().getBean("userContext");
origin: uk.ac.ebi.intact.core/intact-core

/**
 * 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;
}
origin: uk.ac.ebi.intact.core/intact-core-readonly

/**
 * 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;
}
origin: uk.ac.ebi.intact.core/intact-core

public static <X extends Xref> Collection<X> getIdentityXrefs(AnnotatedObject<X, ?> annotatedObject) {
  Collection<X> xrefs = new ArrayList<X>();
  Collection<X> allXrefs = annotatedObject.getXrefs();
  if (!IntactCore.isInitialized(annotatedObject.getXrefs()) && IntactContext.currentInstanceExists()) {
    EntityManager entityManager = IntactContext.getCurrentInstance().getDaoFactory().getEntityManager();
    // set the flush mode to manual to avoid hibernate trying to flush the session when querying the xrefs
    FlushModeType originalFlushMode = entityManager.getFlushMode();
    entityManager.setFlushMode(FlushModeType.COMMIT);
    Class xrefClass = AnnotatedObjectUtils.getXrefClassType(annotatedObject.getClass());
    allXrefs = IntactContext.getCurrentInstance().getDaoFactory().getXrefDao(xrefClass).getByParentAc(annotatedObject.getAc());
    entityManager.setFlushMode(originalFlushMode);
  }
  for (X xref : allXrefs) {
    CvXrefQualifier qualifier = xref.getCvXrefQualifier();
    String qualifierMi = null;
    if (qualifier != null && ((qualifierMi = qualifier.getIdentifier()) != null &&
        qualifierMi.equals(CvXrefQualifier.IDENTITY_MI_REF))) {
      xrefs.add(xref);
    }
  }
  return xrefs;
}
origin: uk.ac.ebi.intact.core/intact-core-readonly

public static <X extends Xref> Collection<X> getIdentityXrefs(AnnotatedObject<X, ?> annotatedObject) {
  Collection<X> xrefs = new ArrayList<X>();
  Collection<X> allXrefs = annotatedObject.getXrefs();
  if (!IntactCore.isInitialized(annotatedObject.getXrefs()) && IntactContext.currentInstanceExists()) {
    EntityManager entityManager = IntactContext.getCurrentInstance().getDaoFactory().getEntityManager();
    // set the flush mode to manual to avoid hibernate trying to flush the session when querying the xrefs
    FlushModeType originalFlushMode = entityManager.getFlushMode();
    entityManager.setFlushMode(FlushModeType.COMMIT);
    Class xrefClass = AnnotatedObjectUtils.getXrefClassType(annotatedObject.getClass());
    allXrefs = IntactContext.getCurrentInstance().getDaoFactory().getXrefDao(xrefClass).getByParentAc(annotatedObject.getAc());
    entityManager.setFlushMode(originalFlushMode);
  }
  for (X xref : allXrefs) {
    CvXrefQualifier qualifier = xref.getCvXrefQualifier();
    String qualifierMi = null;
    if (qualifier != null && ((qualifierMi = qualifier.getIdentifier()) != null &&
        qualifierMi.equals(CvXrefQualifier.IDENTITY_MI_REF))) {
      xrefs.add(xref);
    }
  }
  return xrefs;
}
uk.ac.ebi.intact.core.contextIntactContextcurrentInstanceExists

Javadoc

Checks if an instance already exists.

Popular methods of IntactContext

  • getCurrentInstance
    Gets the current (ThreadLocal) instance of IntactContext. If no such instance exist, IntAct Core wil
  • getDataContext
  • getInstitution
    Gets the institution from the RuntimeConfig object. In addition, tries to refresh the instance from
  • getDaoFactory
  • getCorePersister
  • getSpringContext
  • getLifecycleManager
    Gets the lifecycle manager for publications.
  • getPersisterHelper
  • initContext
    Initializes a standalone context.
  • bindToApplication
  • getApplication
  • getConfig
  • getApplication,
  • getConfig,
  • getConfigurationHandler,
  • getCoreDeleter,
  • getUserContext,
  • initStandaloneContextInMemory,
  • setApplication

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • putExtra (Intent)
  • getExternalFilesDir (Context)
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • JComboBox (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now