Class TypeProjectionImpl

All Implemented Interfaces:
Serializable, Element, PropertyElement, SchemaMixedElement, ModelElement, Property, TypeProjection

public class TypeProjectionImpl extends PropertyElementImpl implements TypeProjection
The default implementation of the TypeProjection interface.
Author:
Luca Frosini (ISTI - CNR)
See Also:
  • Field Details

    • objectMapper

      protected org.gcube.com.fasterxml.jackson.databind.ObjectMapper objectMapper
      The object mapper, used to convert query to/from its string form.
    • metadata

      protected Metadata metadata
      The metadata of this projection.
    • query

      protected org.gcube.com.fasterxml.jackson.databind.JsonNode query
      The query defining this projection.
    • description

      protected String description
      The description of this projection.
    • source

      protected TypeProjection.Source source
      Whether this projection is auto-generated or custom.
  • Constructor Details

    • TypeProjectionImpl

      public TypeProjectionImpl()
      Default constructor.
  • Method Details

    • getMetadata

      public Metadata getMetadata()
      Returns the metadata associated with this projection (who generated or last changed it, and when). Declared directly here, not inherited from IdentifiableElement, since a TypeProjection has no id of its own.
      Specified by:
      getMetadata in interface TypeProjection
      Returns:
      the metadata
    • setMetadata

      public void setMetadata(Metadata metadata)
      Sets the metadata associated with this projection.
      Specified by:
      setMetadata in interface TypeProjection
      Parameters:
      metadata - the metadata
    • getQueryAsString

      public String getQueryAsString() throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException
      Returns the query body as a string.
      Specified by:
      getQueryAsString in interface TypeProjection
      Returns:
      the query as a string
      Throws:
      org.gcube.com.fasterxml.jackson.core.JsonProcessingException - if an error occurs during serialization
    • setQuery

      public void setQuery(String query) throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException, IOException
      Sets the query body from a string.
      Specified by:
      setQuery in interface TypeProjection
      Parameters:
      query - the query as a string
      Throws:
      org.gcube.com.fasterxml.jackson.core.JsonProcessingException - if an error occurs during JSON processing
      IOException - if an error occurs during parsing
    • getQuery

      public org.gcube.com.fasterxml.jackson.databind.JsonNode getQuery()
      Returns the query body as a JsonNode.
      Specified by:
      getQuery in interface TypeProjection
      Returns:
      the query as a JsonNode
    • setQuery

      public void setQuery(org.gcube.com.fasterxml.jackson.databind.JsonNode query)
      Sets the query body from a JsonNode.

      Deliberately typed as JsonNode, not a polymorphic Element reference — the query's content embeds its own "type" (e.g. "EService"), which describes what it queries, not a real instance to deserialize. Typing it as a plain JsonNode keeps Element's @JsonTypeInfo-driven polymorphic resolution from being triggered on that embedded discriminator — the exact same reason QueryTemplate.setTemplate(JsonNode) is typed the same way.

      Specified by:
      setQuery in interface TypeProjection
      Parameters:
      query - the query as a JsonNode
    • getDescription

      public String getDescription()
      Returns the description of this projection — which fields/columns it returns and why.
      Specified by:
      getDescription in interface TypeProjection
      Returns:
      the description
    • setDescription

      public void setDescription(String description)
      Sets the description of this projection.
      Specified by:
      setDescription in interface TypeProjection
      Parameters:
      description - the description
    • getSource

      public TypeProjection.Source getSource()
      Returns whether this projection is TypeProjection.Source.AUTO_GENERATED or TypeProjection.Source.CUSTOM. Never client-submittable: assigned by the server depending on whether the owning Type has an admin-defined projection.
      Specified by:
      getSource in interface TypeProjection
      Returns:
      the source
    • setSource

      public void setSource(TypeProjection.Source source)
      Sets the source of this projection.
      Specified by:
      setSource in interface TypeProjection
      Parameters:
      source - the source