[ 
https://issues.apache.org/jira/browse/UIMA-5601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16191293#comment-16191293
 ] 

Marshall Schor commented on UIMA-5601:
--------------------------------------

thank you for the thoughtful discussion :-)  

I thought of more use cases for the CAS Copier, for which the above suggestion 
might not be suitable.  They all involve using the cas copier to copy 
individual feature structures, rather than mass-copying of a whole CAS.  

If the sofa is copied, but not the document annotation (or its subtype), and 
the sofa copying in the casCopier impl change to no longer create a document 
annotation under the covers, then various subsequent operations in the target 
(like target.setDocumentLanguage) could nevertheless cause a default automatic 
creation of a document annotation instance. 

This could later be followed by an explicit call to copy the 
(subtype-of)-document-annotation, which might have updated begin/end values.

So, I think the following needs to be done:
# fix the implementation of isDocumentAnnotation to report true for subtypes of 
DocumentAnnotation, as Richard noted above.
# Change the impl of copying a (subtype-of-) DocumentAnnotation to first see if 
one exists, and if it does, remove it, and then add the copy.
# Don't change the sofa copying with String data value, to avoid creating a 
default document annotation if none exists in order to set the begin/end 
values.  This would no longer be necessary given (2) above.

I hope this covers all the cases; WDYT?

> uv3: CasCopier problems with custom subclasses of DocumentAnnotation
> --------------------------------------------------------------------
>
>                 Key: UIMA-5601
>                 URL: https://issues.apache.org/jira/browse/UIMA-5601
>             Project: UIMA
>          Issue Type: Bug
>          Components: Core Java Framework
>    Affects Versions: 3.0.0SDK-beta
>            Reporter: Richard Eckart de Castilho
>
> It seems as if there may be a bug in the way that CasCopier handles the 
> documen annotation. 
> Specifically, it seems as if the CasCopier incorrectly handles the case where 
> the target CAS already contains a document annotation. In my case, I do:
> * create the target CAS
> * add a document annotation (DocumentMetaData extends DocumentAnnotation) to 
> the target CAS
> * create the CasCopier with the source and target CAS
> * copy several FSes but *not* the document annotation
> Expected:
> * target CAS contains 1 DocumentMetaData annotation
> Actual
> * target CAS contains 2 DocumentMetaData annotation
> Also, it seems that `isDocumentAnnotation` may not able to handle it if a CAS 
> uses a custom subclass of DocumentAnnotation:
> {noformat}
>   private <T extends FeatureStructure> boolean isDocumentAnnotation(T aFS) {
>     if (((TOP)aFS)._getTypeCode() != TypeSystemConstants.docTypeCode) {
>       return false;
>     }
>     if (srcCasDocumentAnnotation == null) {
>       srcCasDocumentAnnotation = 
> srcCasViewImpl.getDocumentAnnotationNoCreate(); 
>     }
>     return aFS == srcCasDocumentAnnotation;
>   }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to