Class RdfTypeMap

All Implemented Interfaces:
RdfType

public class RdfTypeMap extends RdfTypeComplexBase
Issue: How to give property access to key/value attributes of the entries? JPA models map-typed attributes using MapAttribute which derives from PluralAttribute A map can be modeled as a set (collection) of entry objects. Under this view, a Map is a collection attribute, which has an item type of Entry. But then again, this is not how JPA does it: A map is a PluralAttribute, which in addition to the value type also has a key type - so its not a collection of entries, but a collection of values with an additional key type. The essence is, that it should be possible to resolve access to 'key' and 'value' attributes
Author:
raven
  • Field Details

    • entry

      public static final org.apache.jena.rdf.model.Property entry
    • key

      public static final org.apache.jena.rdf.model.Property key
    • value

      public static final org.apache.jena.rdf.model.Property value
    • keyRdfType

      protected RdfType keyRdfType
    • valueRdfType

      protected RdfType valueRdfType
    • keyClazz

      protected Class<?> keyClazz
    • valueClazz

      protected Class<?> valueClazz
    • createMapView

      protected Function<Object,Map> createMapView
  • Constructor Details

  • Method Details

    • exposeShape

      public void exposeShape(ResourceShapeBuilder shapeBuilder)
    • exposeFragment

      public void exposeFragment(ResourceFragment out, org.apache.jena.rdf.model.Resource priorState, Object entity)
    • populate

      public EntityFragment populate(org.apache.jena.rdf.model.Resource shape, Object entity)
      The fragment will contain information about which nodes need to be resolved. Once everything is resolved, there needs to be a function that carries out the actualy population - so its more like Populator populator = exposePopulator(shape, entity) // Maybe the entity is not needed at this stage populator.refs.forEach((key, class, node) -> context.put(key, rdfMapperEngine.resolve(class, node))) populator.resolve(context)
    • getEntityClass

      public Class<?> getEntityClass()
      Description copied from interface: RdfType
      Return the Java class corresponding to this type (maybe it should be Type instead of Class)
      Returns:
    • getRootNode

      public org.apache.jena.graph.Node getRootNode(Object obj)
      Description copied from interface: RdfType
      Return the root node that corresponds to the given object in regard to this RdfType. In the case of classes, this is an IRI node, whereas for literals this is either a plain or typed literal node. Note, that the following condition is expected to hold: getRootNode(createJavaObject(node)).equals(node) For types mapping to plain literals, this method should (must?) never return null. Note that certain Java types may not have capabilities assigned for returning a node for a given object. In this case, the result will be null.
      Returns:
    • createJavaObject

      public Object createJavaObject(org.apache.jena.rdf.model.RDFNode node)
      Description copied from interface: RdfType
      Extract a Java (literal) object from a given node. Note: Creating a *non-primitive* java object is not a concern of RdfType which only *MAPS* between a java object and its corresponding triples. The reason is, that via the RdfType's entity class the association to a newInstance method can be indirectly made on the outside, without RdfType having to be aware of it. Also, an RdfType reading a collection may be capable of reading and writing to any collection type, regardless of the concrete sub-type (list, set, etc). Create an empty java object (i.e. no properties set) based on the given node. In the case of primitive types (e.g. String, Long, etc), the object will already carry the correct value. In the case of classes, the result may either be a Java object regardless of the node argument, or a proxy to such java object that holds the node
      Returns:
    • hasIdentity

      public boolean hasIdentity()
      Description copied from interface: RdfType
      Flag to indicate whether entities created from this mapping have their own identity. If not, ids are usually derived from the parent object
      Returns:
    • resolve

      public PathFragment resolve(String propertyName)
      Specified by:
      resolve in interface RdfType
      Overrides:
      resolve in class RdfTypeBase