Author: schor Date: Tue Dec 1 21:14:00 2015 New Revision: 1717535 URL: http://svn.apache.org/viewvc?rev=1717535&view=rev Log: [UIMA-4663] move toward eliminating AnnotationBase sofa ref - use instead the casView.
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/AnnotationBase.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java?rev=1717535&r1=1717534&r2=1717535&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java Tue Dec 1 21:14:00 2015 @@ -2374,17 +2374,20 @@ public class CASImpl extends AbstractCas final TypeImpl ti = ((FeatureStructureImplC)fs)._typeImpl; if (ti.isAnnotationBaseType()) { final AnnotationBase ab = (AnnotationBase) fs; - // only need to check one view - // get that view carefully, in case things are not yet properly initialized - Sofa sofa = ab.getSofa(); - if (null == sofa) { - return false; - } - CAS view = (sofa == this.getSofa()) ? this : getViewFromSofaNbr(sofa.getSofaNum()); - if (null == view) { - return false; - } - return removeAndRecord(fs, (FSIndexRepositoryImpl) view.getIndexRepository(), toBeAdded); + + // in v3, the fs points to the view + +// // only need to check one view +// // get that view carefully, in case things are not yet properly initialized +// Sofa sofa = ab.getSofa(); +// if (null == sofa) { +// return false; +// } +// CAS view = (sofa == this.getSofa()) ? this : getViewFromSofaNbr(sofa.getSofaNum()); +// if (null == view) { +// return false; +// } + return removeAndRecord(fs, (FSIndexRepositoryImpl) fs._casView.getIndexRepository(), toBeAdded); } // not a subtype of AnnotationBase, need to check all views (except base) @@ -3438,16 +3441,16 @@ public class CASImpl extends AbstractCas * @return the view associated with this FS where it could be indexed */ public CASImpl getSofaCasView(AnnotationBase fs) { - - Sofa sofa = fs.getSofa(); - - if (null != sofa && sofa != this.getSofa()) { - return (CASImpl) this.getView(sofa.getSofaNum()); - } - - /* Note: sofa == null means annotation created from low-level APIs, without setting sofa feature - * Ignore this for backwards compatibility */ - return this; + return fs._casView; +// Sofa sofa = fs.getSofa(); +// +// if (null != sofa && sofa != this.getSofa()) { +// return (CASImpl) this.getView(sofa.getSofaNum()); +// } +// +// /* Note: sofa == null means annotation created from low-level APIs, without setting sofa feature +// * Ignore this for backwards compatibility */ +// return this; } public CASImpl ll_getSofaCasView(int id) { Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java?rev=1717535&r1=1717534&r2=1717535&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java Tue Dec 1 21:14:00 2015 @@ -1087,13 +1087,12 @@ public class FSIndexRepositoryImpl imple if (!isAddback && (!IS_DISABLE_ENHANCED_WRONG_INDEX_CHECK) && ti.isAnnotationBaseType()) { // Check that the annotationBase FS is being added to the proper Cas View - AnnotationBase fsAnnotBase = (AnnotationBase) fs; - final Sofa sofa = fsAnnotBase.getSofa(); - if (cas.getSofa() != sofa) { + CASImpl indexView = fs._getView(); + if (indexView.getIndexRepository() != this) { /* Error - the Annotation "{0}" is over view "{1}" and cannot be added to indexes associated with * the different view "{2}" */ throw new CASRuntimeException(CASRuntimeException.ANNOTATION_IN_WRONG_INDEX, - fsAnnotBase.toString(), sofa.getSofaID(), cas.getSofa().getSofaID()); + fs.toString(), indexView.getViewName(), cas.getViewName()); } } Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/AnnotationBase.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/AnnotationBase.java?rev=1717535&r1=1717534&r2=1717535&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/AnnotationBase.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/AnnotationBase.java Tue Dec 1 21:14:00 2015 @@ -107,7 +107,7 @@ public class AnnotationBase extends TOP // The value is set and is fixed when this is created public CAS getView() { - return _casView.getSofaCasView(this); + return _casView; } }