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

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

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

origin: uk.ac.ebi.intact.dataexchange.uniprotexport/intact-uniprot-export

public List<String> getInteractionsFromExperimentExportSpecified() {
  DataContext dataContext = IntactContext.getCurrentInstance().getDataContext();
  TransactionStatus transactionStatus = dataContext.beginTransaction();
  Query query = IntactContext.getCurrentInstance().getDaoFactory().getEntityManager().createQuery(interactionsFromExperimentExportSpecified);
  query.setParameter("drExport", CvTopic.UNIPROT_DR_EXPORT);
  List<String> interactions = query.getResultList();
  dataContext.commitTransaction(transactionStatus);
  return interactions;
}
origin: uk.ac.ebi.intact.dataexchange/intact-cvutils

@PostConstruct
private void init() {
  this.nonMiCvDatabase = CvObjectUtils.createCvObject( IntactContext.getCurrentInstance().getInstitution(),
                             CvDatabase.class, CvDatabase.INTACT_MI_REF, CvDatabase.INTACT );
}
origin: uk.ac.ebi.intact.dbupdate/intact-cv-update

public static Annotation hideTerm(CvObject c, String message){
  DaoFactory factory = IntactContext.getCurrentInstance().getDaoFactory();
  CvTopic topicFromDb = factory.getCvObjectDao(CvTopic.class).getByShortLabel(CvTopic.HIDDEN);
  if (topicFromDb == null){
    topicFromDb = CvObjectUtils.createCvObject(IntactContext.getCurrentInstance().getInstitution(), CvTopic.class, null, CvTopic.HIDDEN);
    IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate(topicFromDb);
  }
  Annotation newAnnotation = new Annotation(topicFromDb, message);
  c.addAnnotation(newAnnotation);
  return newAnnotation;
}
origin: uk.ac.ebi.intact.core/intact-core-readonly

  @Deprecated
  public CorePersister getCorePersister() {
    return IntactContext.getCurrentInstance().getCorePersister();
  }
}
origin: uk.ac.ebi.intact.core/intact-core

/**
 * @since 2.4.0
 */
public CoreDeleter getCoreDeleter() {
  return (CoreDeleter) IntactContext.getCurrentInstance().getSpringContext().getBean("coreDeleter");
}
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.core/intact-core-readonly

public SearchableDao getDao() {
  if (searchableDao == null) {
    searchableDao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getSearchableDao();
  }
  return searchableDao;
}
origin: uk.ac.ebi.intact.core/intact-core

@Override
@Transactional
public Institution convertFromString(String str) {
  if (str == null) return null;
  return IntactContext.getCurrentInstance().getDaoFactory().getInstitutionDao().getByShortLabel(str);
}
origin: uk.ac.ebi.intact.dbupdate/intact-biosource-update

/**
 * Create a BioSource
 *
 * @param shortlabel shortlabel of the Biosource.
 * @param fullname   fullname of the Biosource.
 * @param taxid      taxid of the Biosource.
 * @return a persistent BioSource.
 */
private BioSource createBioSource(String shortlabel, String fullname, String taxid) throws BioSourceServiceException {
  if (log.isDebugEnabled()) {
    log.debug("Persisting BioSource(" + taxid + ", " + shortlabel + ", " + fullname + ")");
  }
  DataContext dataContext = IntactContext.getCurrentInstance().getDataContext();
  DaoFactory daoFactory = dataContext.getDaoFactory();
  if (institution == null) {
    institution = IntactContext.getCurrentInstance().getInstitution();
  }
  // Instanciate it
  BioSource bioSource = new BioSource(institution, shortlabel, taxid);
  bioSource.setFullName(fullname);
  return bioSource;
}
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

/**
 * The local identity is created using a sequence. If the sequence does not exist, a new one is created
 * with initial value calculated using the maximum integer for the existing local CV identifiers.
 * @return The next value available
 * @throws SequenceCreationException thrown if the sequence cannot be created.
 */
protected String nextLocalIdentifier() throws SequenceCreationException {
  final IntactContext context = IntactContext.getCurrentInstance();
  String prefix = context.getConfig().getLocalCvPrefix();
  Integer max = context.getDataContext().getDaoFactory()
      .getCvObjectDao().getLastCvIdentifierWithPrefix(prefix);
  if (max == null) max = 0;
  SequenceManager seqManager = (SequenceManager) context.getSpringContext().getBean("sequenceManager");
  seqManager.createSequenceIfNotExists(IntactAuxiliaryConfigurator.CV_LOCAL_SEQ, max+1);
  String nextIntegerAsString = String.valueOf(seqManager.getNextValueForSequence(IntactAuxiliaryConfigurator.CV_LOCAL_SEQ));
  return prefix+":" + StringUtils.leftPad(nextIntegerAsString, 4, "0");
}
origin: uk.ac.ebi.intact.dbupdate/protein-mapping

/**
 * Create a new InteractorXref for the protein
 * @param uniprotAc : the uniprot accession
 * @return the InteractorXref with the uniprot ac and qualifier identity
 */
private InteractorXref createIdentityInteractorXrefForUniprotAc(String uniprotAc){
  IntactContext intactContext = IntactContext.getCurrentInstance();
  if (uniprotAc == null){
    return null;
  }
  final CvDatabase uniprot = intactContext.getDaoFactory().getCvObjectDao(CvDatabase.class).getByPsiMiRef( CvDatabase.UNIPROT_MI_REF );
  final CvXrefQualifier identity = intactContext.getDaoFactory().getCvObjectDao(CvXrefQualifier.class).getByPsiMiRef(CvXrefQualifier.IDENTITY_MI_REF);
  InteractorXref xRef = new InteractorXref(intactContext.getInstitution(), uniprot, uniprotAc, identity);
  return xRef;
}
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.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

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.dbupdate/intact-cv-update

@Transactional(propagation = Propagation.REQUIRED)
public void updateChildrenHavingMissingParent(String child, String parent) {
  CvObjectDao<CvDagObject> cvDao = IntactContext.getCurrentInstance().getDaoFactory().getCvObjectDao(CvDagObject.class);
  CvDagObject reloadedChild = cvDao.getByAc(child);
  CvDagObject reloadedParent = cvDao.getByAc(parent);
  if (reloadedChild != null){
    reloadedChild.addParent(reloadedParent);
    IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate(reloadedChild);
  }
  else {
    log.warn("Cv object " + child + " cannot be updated because does not exist anymore");
  }
}
origin: uk.ac.ebi.intact.dbupdate/intact-biosource-update

private static CvAliasType getOrCreateSynonymType( DaoFactory daoFactory ) {
  final Institution owner = IntactContext.getCurrentInstance().getInstitution();
  IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate( synonymType );
  System.out.println( "CvAliasType( 'synonym', 'MI:1041' ) was persisted." );
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

public GeneratedEntry addInteractionWithAc(String ac) {
  Interaction interaction = intactContext.getDataContext().getDaoFactory()
      .getInteractionDao().getByAc(ac);
  checkResult(interaction, ac, "interaction");
  return addInteraction(interaction);
}
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();
}
uk.ac.ebi.intact.core.contextIntactContext

Javadoc

The IntactContext class is the central point of access to the IntAct Core API.

Most used methods

  • 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
  • currentInstanceExists
    Checks if an instance already exists.
  • getSpringContext
  • getLifecycleManager
    Gets the lifecycle manager for publications.
  • getPersisterHelper
  • initContext
    Initializes a standalone context.
  • bindToApplication
  • getApplication
  • bindToApplication,
  • getApplication,
  • getConfig,
  • getConfigurationHandler,
  • getCoreDeleter,
  • getUserContext,
  • initStandaloneContextInMemory,
  • setApplication

Popular in Java

  • Reading from database using SQL prepared statement
  • getApplicationContext (Context)
  • setScale (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Top Sublime Text plugins
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