java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.queries.ProjectionValueSerializer

public class ProjectionValueSerializer extends Object
Serializes the values projected by an _emit or a computing operator as a read does.

An embedded value is serialized by PropertyElementManagement.getJsonNode(ODocument): an Encrypted value is therefore returned encrypted with the key of the Context of the request. When the caller reads the sensitive metadata identity fields redacted, a projected Metadata value is redacted too. A Date is formatted by OrientDBUtility.formatDateTime(Date), a number and a boolean keep their JSON type, a collection is an array, a map an object and a null value is JSON null.

Author:
Luca Frosini (ISTI - CNR)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final boolean
    Whether the caller reads the sensitive metadata identity fields redacted.
    protected final org.gcube.com.fasterxml.jackson.databind.ObjectMapper
    In-use Jackson object mapper.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ProjectionValueSerializer(boolean maskMetadata)
  • Method Summary

    Modifier and Type
    Method
    Description
    org.gcube.com.fasterxml.jackson.databind.JsonNode
    Serializes a projected value.
    org.gcube.com.fasterxml.jackson.databind.node.ObjectNode
    serializeRow(com.orientechnologies.orient.core.sql.executor.OResult result, Collection<String> aliases)
    Serializes a row of projected values, one member per alias.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • objectMapper

      protected final org.gcube.com.fasterxml.jackson.databind.ObjectMapper objectMapper
      In-use Jackson object mapper.
    • maskMetadata

      protected final boolean maskMetadata
      Whether the caller reads the sensitive metadata identity fields redacted.
  • Constructor Details

    • ProjectionValueSerializer

      public ProjectionValueSerializer(boolean maskMetadata)
      Parameters:
      maskMetadata - true if the caller reads the sensitive metadata identity fields redacted
  • Method Details

    • serializeRow

      public org.gcube.com.fasterxml.jackson.databind.node.ObjectNode serializeRow(com.orientechnologies.orient.core.sql.executor.OResult result, Collection<String> aliases) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Serializes a row of projected values, one member per alias. The sensitive metadata identity fields need no handling here: the query itself returns them redacted to the callers who read them so.
      Parameters:
      result - the row
      aliases - the aliases of the projected values
      Returns:
      the JSON object of the row
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException - if a value is a record instead of a property value
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if a value cannot be serialized
    • serialize

      public org.gcube.com.fasterxml.jackson.databind.JsonNode serialize(Object value) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Serializes a projected value.
      Parameters:
      value - the projected value
      Returns:
      the JSON representation; JSON null if the value is null
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException - if the value is a record instead of a property value
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the value cannot be serialized