@Override public ConceptAccession map ( S source, ONDEXConcept concept, ONDEXGraph graph ) { return CachedGraphWrapper .getInstance ( graph ) .getAccession ( this.getValue (), concept ); } }
@Override public ConceptClass map ( S source, ONDEXGraph graph ) { return CachedGraphWrapper.getInstance ( graph ).getConceptClass ( this.getValue () ); }
@Override public DataSource map ( S source, ONDEXGraph graph ) { return CachedGraphWrapper .getInstance ( graph ) .getDataSource ( this.getValue () ); } }
@Override public EvidenceType map ( S source, ONDEXGraph graph ) { return CachedGraphWrapper .getInstance ( graph ) .getEvidenceType ( this.getValue () ); } }
@Override public ONDEXRelation map ( ONDEXConcept c1, ONDEXConcept c2, ONDEXGraph graph ) { CachedGraphWrapper graphw = CachedGraphWrapper.getInstance ( graph ); RelationType relType = graphw.getRelationType ( this.getRelationTypePrototype () ); EvidenceType evidenceType = graphw.getEvidenceType ( this.getEvidenceTypePrototype () ); return graphw.getRelation ( c1, c2, relType, evidenceType ); }
public synchronized ConceptAccession getAccession ( AccessionPrototype proto, ONDEXConcept concept ) { // Let's see if it has a parent if ( proto.getDataSource () == null ) { // Or a prototype to build it. In case of loops, this will lead to stack overflow DataSourcePrototype dsProto = proto.getDataSourcePrototype (); if ( dsProto != null ) proto.setDataSource ( this.getDataSource ( dsProto ) ); } return this.getAccession ( proto.getAccession (), proto.getDataSource (), proto.isAmbiguous (), concept ); }
@Override public ONDEXConcept map ( S src, ConceptClass conceptClass, ONDEXGraph graph ) { CachedGraphWrapper graphw = CachedGraphWrapper.getInstance ( graph ); String id = this.getIdMapper ().map ( src, graph ); String descr = Optional.ofNullable ( this.getDescriptionMapper () ).map ( m -> m.map ( src, graph ) ).orElse ( "" ); String ann = Optional.ofNullable ( this.getAnnotationMapper () ).map ( m -> m.map ( src, graph ) ).orElse ( "" ); EvidenceType evidence = this.getEvidenceMapper ().map ( src, graph ); DataSource dataSrc = this.getDataSourceMapper ().map ( src, graph ); ONDEXConcept result = graphw.getConcept ( id, ann, descr, dataSrc, conceptClass, evidence ); if ( this.isVisited ( src ) ) return result; Optional .ofNullable ( this.getPreferredNameMapper () ) // if available, .map ( mapper -> mapper.map ( src, graph ) ) // get a value from it .ifPresent ( prefName -> result.createConceptName ( prefName, true ) ); // and use it to build a new name, if it's non-null // Same approach for names mapper, but this has multiple results. Optional.ofNullable ( this.getAltNamesMapper () ) .map ( mapper -> mapper.map ( src, graph ) ) .ifPresent ( names -> names.filter ( name -> name != null ) .forEach ( name -> result.createConceptName ( name, false ) ) ); Optional.ofNullable ( this.getAccessionsMapper () ) .ifPresent ( mapper -> mapper.map ( src, result, graph ).count () ); return result; }
public synchronized ConceptClass getConceptClass ( ConceptClassPrototype proto ) { try { // Let's see if it has a parent if ( proto.getParent () == null ) { // Or a prototype to build it. In case of loops, this will lead to stack overflow ConceptClassPrototype parentProto = proto.getParentPrototype (); if ( parentProto != null ) proto.setParent ( this.getConceptClass ( parentProto ) ); } return this.cacheGet ( ConceptClass.class, proto.getId (), () -> this.graph.getMetaData ().getFactory ().createConceptClass ( proto.getId (), proto.getFullName (), proto.getDescription (), proto.getParent () ) ); } catch ( StackOverflowError ex ) { log.error ( "Stackoverflow error while creating the concept class '{}'. Do you have circular references?", proto.getId () ); throw ex; } }
public synchronized RelationType getRelationType ( RelationTypePrototype proto ) { try { // Let's see if it has a parent if ( proto.getParent () == null ) { // Or a prototype to build it. In case of loops, this will lead to stack overflow RelationTypePrototype parentProto = proto.getParentPrototype (); if ( parentProto != null ) proto.setParent ( this.getRelationType ( parentProto ) ); } return this.cacheGet ( RelationType.class, proto.getId (), () -> this.graph.getMetaData ().getFactory ().createRelationType ( proto.getId (), proto.getFullName (), proto.getDescription (), proto.isAntisymmetric (), proto.isReflexive (), proto.isSymmetric (), proto.isTransitive (), proto.getParent () ) ); } catch ( StackOverflowError ex ) { log.error ( "Stack Overflow error while creating relation '{}'. Do you have circular references?", proto.getId () ); throw ex; } }
public synchronized ONDEXConcept getConcept ( String id ) { return this.cacheGet ( ONDEXConcept.class, id ); }
public CachedGraphWrapper getGraphWrapper () { return CachedGraphWrapper.getInstance ( this.getGraph () ); } }
public synchronized EvidenceType getEvidenceType ( EvidenceTypePrototype proto ) { return this.getEvidenceType ( proto.getId (), proto.getFullName (), proto.getDescription () ); }
public synchronized DataSource getDataSource ( DataSourcePrototype proto ) { return this.getDataSource ( proto.getId (), proto.getFullName (), proto.getDescription () ); }
/** * We recommend to use this to get a wrapper that caches this graph. * * @param graph */ public static synchronized CachedGraphWrapper getInstance ( ONDEXGraph graph ) { return instances.computeIfAbsent ( graph, g -> new CachedGraphWrapper ( g ) ); }
public synchronized ConceptAccession getAccession ( String accession, DataSource dataSrc, boolean isAmbiguous, ONDEXConcept concept ) { // TODO: is the ID unique? Is it concept-unique? return this.cacheGet ( ConceptAccession.class, accession, () -> concept.createConceptAccession ( accession, dataSrc, isAmbiguous ) ); }
@Override public ConceptClass map ( S src, ONDEXGraph graph ) { String id = this.getIdMapper ().map ( src ); String fullName = Optional.ofNullable ( this.getFullNameMapper () ).map ( m -> m.map ( src, graph ) ).orElse ( "" ); String description = Optional.ofNullable ( this.getDescriptionMapper () ).map ( m -> m.map ( src, graph ) ).orElse ( "" ); ConceptClass parent = Optional.ofNullable ( this.getParentMapper () ).map ( m -> m.map ( src, graph ) ).orElse ( null ); ConceptClass cc = CachedGraphWrapper.getInstance ( graph ).getConceptClass ( id, fullName, description, parent ); return cc; }
@Override public ConceptAccession map ( S src, ONDEXConcept concept, ONDEXGraph graph ) { String accession = this.getAccessionValueMapper ().map ( src, graph ); if ( accession == null ) return null; DataSource dataSrc = Optional.ofNullable ( this.getDataSourceMapper () ) .map ( m -> m.map ( src, graph ) ) .orElseThrow ( () -> new NullPointerException ( this.getClass ().getName () + " needs a data source mapper" ) ); boolean isAmbiguous = Optional.ofNullable ( this.getAmbiguityMapper () ) .map ( m -> m.map ( src, graph ) ) .map ( Boolean.TRUE::equals ) .orElseThrow ( () -> new NullPointerException ( this.getClass ().getName () + " needs an ambiguity mapper" ) ); return CachedGraphWrapper.getInstance ( graph ).getAccession ( accession, dataSrc, isAmbiguous, concept ); }
public synchronized DataSource getDataSource ( String id, String fullName, String description ) { return this.cacheGet ( DataSource.class, id, () -> this.graph.getMetaData ().createDataSource ( id, fullName, description ) ); }
public synchronized ConceptClass getConceptClass ( String id, String fullName, String description, ConceptClass specialisationOf ) { return this.cacheGet ( ConceptClass.class, id, () -> this.graph.getMetaData ().createConceptClass ( id, fullName, description, specialisationOf ) ); }
public synchronized ONDEXConcept getConcept ( String id, String annotation, String description, DataSource ds, ConceptClass conceptClass, EvidenceType evidence ) { return this.cacheGet ( ONDEXConcept.class, id, () -> this.graph.getFactory ().createConcept ( id, annotation, description, ds, conceptClass, evidence ) ); }