src/main/java/de/digitalcollections/iiif/model/jackson/serialization/ResourceDeserializer.java
private String getOnType(DeserializationContext ctxt) {
    // Easiest way: The parser has already constructed an annotation object with a motivation.
    // This is highly dependendant on the order of keys in the JSON, i.e. if "on" is the first key in the annotation
    // object, this won't work.
    Object curVal = ctxt.getParser().getCurrentValue();
    boolean isPaintingAnno = (curVal != null && curVal instanceof Annotation
                              && ((Annotation) curVal).getMotivation() != null
                              && ((Annotation) curVal).getMotivation().equals(Motivation.PAINTING));
    if (isPaintingAnno) {
      return "sc:Canvas";
    }
    // More reliable way: Walk up the parsing context until we hit a IIIF resource that we can deduce the type from
    // Usually this shouldn't be more than two levels up
    JsonStreamContext parent = ctxt.getParser().getParsingContext().getParent();
    while (parent != null && (parent.getCurrentValue() == null || !(parent.getCurrentValue() instanceof Resource))) {
      parent = parent.getParent();
    }
    if (parent != null) {
      Resource parentObj = (Resource) parent.getCurrentValue();
      return parentObj.getType();
    }
    return null;
  }
private String getOnType(DeserializationContext ctxt) {
    // Easiest way: The parser has already constructed an annotation object with a motivation.
    // This is highly dependendant on the order of keys in the JSON, i.e. if "on" is the first key in the annotation
    // object, this won't work.
    Object curVal = ctxt.getParser().getCurrentValue();
    boolean isPaintingAnno = (curVal != null && curVal instanceof Annotation
                              && ((Annotation) curVal).getMotivation() != null
                              && ((Annotation) curVal).getMotivation().equals(Motivation.PAINTING));
    if (isPaintingAnno) {
      return "sc:Canvas";
    }
    // More reliable way: Walk up the parsing context until we hit a IIIF resource that we can deduce the type from
    // Usually this shouldn't be more than two levels up
    JsonStreamContext parent = ctxt.getParser().getParsingContext().getParent();
    while (parent != null && (parent.getCurrentValue() == null || !(parent.getCurrentValue() instanceof Resource))) {
      parent = parent.getParent();
    }
    if (parent != null) {
      Resource parentObj = (Resource) parent.getCurrentValue();
      return parentObj.getType();
    }
    return null;
  }
private String getOnType ( DeserializationContext ctxt ) { // Easiest way: The parser has already constructed an annotation object with a motivation. // This is highly dependendant on the order of keys in the JSON, i.e. if "on" is the first key in the annotation // object, this won't work. Object curVal = ctxt . getParser ( ) . getCurrentValue ( ) ; boolean isPaintingAnno = ( curVal != null && curVal instanceof Annotation && ( ( Annotation ) curVal ) . getMotivation ( ) != null && ( ( Annotation ) curVal ) . getMotivation ( ) . equals ( Motivation . PAINTING ) ) ; if ( isPaintingAnno ) { return "sc:Canvas" ; } // More reliable way: Walk up the parsing context until we hit a IIIF resource that we can deduce the type from // Usually this shouldn't be more than two levels up JsonStreamContext parent = ctxt . getParser ( ) . getParsingContext ( ) . getParent ( ) ; while ( parent != null && ( parent . getCurrentValue ( ) == null || ! ( parent . getCurrentValue ( ) instanceof Resource ) ) ) { parent = parent . getParent ( ) ; } if ( parent != null ) { Resource parentObj = ( Resource ) parent . getCurrentValue ( ) ; return parentObj . getType ( ) ; } return null ; }
Get type for  "on" values that are plain URIs by deducing the type from their parent.
Get type for on values that are plain URIs by deducing the type from their parent .