Changeset 163

Show
Ignore:
Timestamp:
08/19/09 13:33:04 (2 years ago)
Author:
martijn
Message:

Started implementation of transitive stack
Unfinished methods will return UnsupportedOperationException?

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/corelib/src/org/bridgedb/IDMapperStack.java

    r157 r163  
    6666    } 
    6767     
     68    private boolean isTransitive = false; 
     69     
     70    /** 
     71     * Set Transitivity mode, where all mappings are combined to infer 
     72     * second degree mappings. 
     73     * @param value true or false 
     74     */ 
     75    public void setTransitive(boolean value) 
     76    { 
     77        isTransitive = value; 
     78    } 
     79     
     80    /** 
     81     * @return true if the stack is in transitive mode 
     82     */ 
     83    public boolean getTransitive() 
     84    { 
     85        return isTransitive; 
     86    } 
     87     
    6888        /** 
    6989         * Remove an idMapper from the stack. 
     
    244264                        Set<DataSource> tgtDataSources) throws IDMapperException  
    245265        { 
     266                if (isTransitive) 
     267                { 
     268                        return mapIDtransitive(srcXrefs, tgtDataSources); 
     269                } 
     270                else 
     271                { 
     272                        return mapIDnormal(srcXrefs, tgtDataSources); 
     273                } 
     274        } 
     275 
     276        /** 
     277         * helper method to map Id's in non-transitive mode. 
     278         * @param srcXrefs mapping source 
     279         * @param tgtDataSources target data sources 
     280         * @return mapping result 
     281         * @throws IDMapperException if one of the children fail 
     282         */ 
     283        private Map<Xref, Set<Xref>> mapIDnormal(Set<Xref> srcXrefs, 
     284                        Set<DataSource> tgtDataSources) throws IDMapperException  
     285        { 
    246286                Map<Xref, Set<Xref>> result = new HashMap<Xref, Set<Xref>>(); 
    247287                 
     
    265305        } 
    266306 
     307        /** 
     308         * helper method to map Id's in transitive mode. 
     309         * @param srcXrefs mapping source 
     310         * @param tgtDataSources target data sources 
     311         * @return mapping result 
     312         * @throws IDMapperException if one of the children fail 
     313         */ 
     314        private Map<Xref, Set<Xref>> mapIDtransitive(Set<Xref> srcXrefs, 
     315                        Set<DataSource> tgtDataSources) throws IDMapperException  
     316        { 
     317                throw new UnsupportedOperationException(); 
     318        } 
     319 
    267320        /** {@inheritDoc} */ 
    268321        public Set<String> getAttributes(Xref ref, String attrname) 
     
    325378        public Set<Xref> mapID(Xref ref, Set<DataSource> resultDs) throws IDMapperException  
    326379        { 
     380                if (isTransitive) 
     381                { 
     382                        return mapIDtransitive (ref, resultDs); 
     383                } 
     384                else 
     385                { 
     386                        return mapIDnormal (ref, resultDs); 
     387                } 
     388        } 
     389         
     390         
     391        /** 
     392         * helper method to map Id's in transitive mode. 
     393         * @param ref Xref to map 
     394         * @param resultDs target data sources 
     395         * @return mapping result 
     396         * @throws IDMapperException if one of the children fail 
     397         */ 
     398        private Set<Xref> mapIDtransitive(Xref ref, Set<DataSource> resultDs) throws IDMapperException  
     399        { 
     400                throw new UnsupportedOperationException(); 
     401        } 
     402         
     403        /** 
     404         * helper method to map Id's in transitive mode. 
     405         * @param ref Xref to map 
     406         * @param resultDs target data sources 
     407         * @return mapping result 
     408         * @throws IDMapperException if one of the children fail 
     409         */ 
     410        private Set<Xref> mapIDnormal(Xref ref, Set<DataSource> resultDs) throws IDMapperException  
     411        { 
    327412                Set<Xref> result = new HashSet<Xref>(); 
    328413                for (IDMapper child : gdbs) 
    329414                { 
    330                         if (child != null && child instanceof AttributeMapper && child.isConnected()) 
     415                        if (child != null && child.isConnected()) 
    331416                        { 
    332417                                result.addAll (child.mapID(ref, resultDs)); 
     
    336421        } 
    337422         
    338          
    339423}