/** * @deprecated The UI class {@link AnnotatorState} should not be passed here. Use * {@link #delete(SourceDocument, String, JCas, VID)} instead. */ @Deprecated default void delete(AnnotatorState aState, JCas aJCas, VID aVid) { delete(aState.getDocument(), aState.getUser().getUsername(), aJCas, aVid); }
public static List<Type> getEntryTypes(JCas mergeJCas, List<AnnotationLayer> aLayers, AnnotationSchemaService aAnnotationService) { List<Type> entryTypes = new LinkedList<>(); for (AnnotationLayer layer : aLayers) { if (layer.getName().equals(Token.class.getName())) { continue; } if (layer.getType().equals(WebAnnoConst.CHAIN_TYPE)) { continue; } entryTypes.add( aAnnotationService.getAdapter(layer).getAnnotationType(mergeJCas.getCas())); } return entryTypes; }
/** * Get the CAS type of the this {@link TypeAdapter} * * @return the type. */ default public String getAnnotationTypeName() { return getLayer().getName(); }
public static String getUiTypeName(TypeAdapter aAdapter) { return aAdapter.getTypeId() + "_" + aAdapter.getAnnotationTypeName(); }
@Override public List<Pair<LogMessage, AnnotationFS>> onValidate(TypeAdapter aAdapter, JCas aJCas) { if (aAdapter.getLayer().isCrossSentence()) { return emptyList(); } CAS cas = aJCas.getCas(); Type type = getType(cas, aAdapter.getAnnotationTypeName()); List<Pair<LogMessage, AnnotationFS>> messages = new ArrayList<>(); for (AnnotationFS fs : select(cas, type)) { if (!isBeginEndInSameSentence(aJCas, fs.getBegin(), fs.getEnd())) { messages.add(Pair.of( LogMessage.error(this, "Crossing sentence bounardies is not permitted."), fs)); } } return messages; } }
@Deprecated private static void deleteSpanAnnotation(TypeAdapter aAdapter, AnnotatorState aState, JCas aJCas, AnnotationFeature aFeature, int aBegin, int aEnd, Object aValue) { Type type = CasUtil.getType(aJCas.getCas(), aAdapter.getAnnotationTypeName()); for (AnnotationFS fs : CasUtil.selectCovered(aJCas.getCas(), type, aBegin, aEnd)) { if (fs.getBegin() == aBegin && fs.getEnd() == aEnd) { if (ObjectUtils.equals(aAdapter.getFeatureValue(aFeature, fs), aValue)) { aAdapter.delete(aState.getDocument(), aState.getUser().getUsername(), aJCas, new VID(getAddr(fs))); } } } }
AnnotationLayer layer = aAdapter.getLayer(); List<AnnotationFeature> features = annotationService.listAnnotationFeature(layer); for (AnnotationFS fs : select(editorCas, aAdapter.getAnnotationType(editorCas))) { for (AnnotationFeature f : features) { if (WebAnnoCasUtil.isRequiredFeatureMissing(f, fs)) {
List<LinkWithRoleModel> links = adapter.getFeatureValue(linkFeature, linkFS); Iterator<LinkWithRoleModel> i = links.iterator(); boolean modified = false; adapter.delete(state, jCas, state.getSelection().getAnnotation());
/** * @deprecated The UI class {@link AnnotatorState} should not be passed here. Use * {@link #delete(SourceDocument, String, JCas, VID)} instead. */ @Deprecated default void setFeatureValue(AnnotatorState aState, JCas aJCas, int aAddress, AnnotationFeature aFeature, Object aValue) { setFeatureValue(aState.getDocument(), aState.getUser().getUsername(), aJCas, aAddress, aFeature, aValue); }
value = adapter.getFeatureValue(feature, fs);
/** * Get the CAS type of the this {@link TypeAdapter} * * @param cas * the CAS. * @return the type. */ default Type getAnnotationType(CAS cas) { return CasUtil.getType(cas, getAnnotationTypeName()); }
@Override public List<Pair<LogMessage, AnnotationFS>> onValidate(TypeAdapter aAdapter, JCas aJCas) { if (aAdapter.getLayer().isAllowStacking()) { return emptyList(); } CAS cas = aJCas.getCas(); Type type = getType(cas, aAdapter.getAnnotationTypeName()); AnnotationFS prevFS = null; List<Pair<LogMessage, AnnotationFS>> messages = new ArrayList<>(); // Since the annotations are sorted, we can easily find stacked annotation by scanning // through the entire list and checking if two adjacent annotations have the same offsets for (AnnotationFS fs : select(cas, type)) { if (prevFS != null && prevFS.getBegin() == fs.getBegin() && prevFS.getEnd() == fs.getEnd()) { messages.add(Pair.of(LogMessage.error(this, "Stacked annotation at [%d-%d]", fs.getBegin(), fs.getEnd()), fs)); } prevFS = fs; } return messages; } }
@Deprecated private static void deleteSpanAnnotation(TypeAdapter aAdapter, AnnotatorState aState, JCas aJCas, AnnotationFeature aFeature, int aBegin, int aEnd, Object aValue) { Type type = CasUtil.getType(aJCas.getCas(), aAdapter.getAnnotationTypeName()); for (AnnotationFS fs : CasUtil.selectCovered(aJCas.getCas(), type, aBegin, aEnd)) { if (fs.getBegin() == aBegin && fs.getEnd() == aEnd) { if (ObjectUtils.equals(aAdapter.getFeatureValue(aFeature, fs), aValue)) { aAdapter.delete(aState.getDocument(), aState.getUser().getUsername(), aJCas, new VID(getAddr(fs))); } } } }
/** * @deprecated The UI class {@link AnnotatorState} should not be passed here. Use * {@link #delete(SourceDocument, String, JCas, VID)} instead. */ @Deprecated default void setFeatureValue(AnnotatorState aState, JCas aJCas, int aAddress, AnnotationFeature aFeature, Object aValue) { setFeatureValue(aState.getDocument(), aState.getUser().getUsername(), aJCas, aAddress, aFeature, aValue); }
value = adapter.getFeatureValue(feature, fs);
public static String getUiTypeName(TypeAdapter aAdapter) { return aAdapter.getTypeId() + "_" + aAdapter.getAnnotationTypeName(); }
/** * Get the CAS type of the this {@link TypeAdapter} * * @param cas * the CAS. * @return the type. */ default Type getAnnotationType(CAS cas) { return CasUtil.getType(cas, getAnnotationTypeName()); }
default long getTypeId() { return getLayer().getId(); }
@Override public List<Pair<LogMessage, AnnotationFS>> onValidate(TypeAdapter aAdapter, JCas aJCas) { if (aAdapter.getLayer().isAllowStacking()) { return emptyList(); } CAS cas = aJCas.getCas(); Type type = getType(cas, aAdapter.getAnnotationTypeName()); AnnotationFS prevFS = null; List<Pair<LogMessage, AnnotationFS>> messages = new ArrayList<>(); // Since the annotations are sorted, we can easily find stacked annotation by scanning // through the entire list and checking if two adjacent annotations have the same offsets for (AnnotationFS fs : select(cas, type)) { if (prevFS != null && prevFS.getBegin() == fs.getBegin() && prevFS.getEnd() == fs.getEnd()) { messages.add(Pair.of(LogMessage.error(this, "Stacked annotation at [%d-%d]", fs.getBegin(), fs.getEnd()), fs)); } prevFS = fs; } return messages; } }
/** * @deprecated The UI class {@link AnnotatorState} should not be passed here. Use * {@link #delete(SourceDocument, String, JCas, VID)} instead. */ @Deprecated default void delete(AnnotatorState aState, JCas aJCas, VID aVid) { delete(aState.getDocument(), aState.getUser().getUsername(), aJCas, aVid); }