Class TypeQueryExecutor
java.lang.Object
org.gcube.informationsystem.resourceregistry.queries.json.TypeQueryExecutor
Executes a JSON Query-By-Example against the Types collection (schema definitions).
Wraps a JsonQuery builder to obtain the SQL query text (query-text generation
is generic across collections; execution is not), then opens the shared TypeEnvironment,
runs the query, and serializes each matched record via the appropriate concrete
*SchemaDefinitionManagement class, resolved from the literal type name declared in the
query (e.g. ResourceSchema, FacetSchema, IsRelatedToSchema,
ConsistsOfSchema, PropertySchema).
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IntegerThe descendant-closure depth for Type-name matching (0 = exact name only, N = N levels of descendants, -1 = all descendants recursively).protected final JsonQueryThe underlying query-text builder.protected IntegerThe pagination limit for the query.protected booleanWhether privacy-sensitive metadata values must be masked.protected org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicyThe metadata inclusion policy.protected com.orientechnologies.orient.core.db.document.ODatabaseDocumentThe active OrientDB database session.protected IntegerThe pagination offset for the query.protected booleanWhether the last query returned_emitprojection rows. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReports whether the last query returned flat_emitprojection rows.query()Executes the JSON query against the Types collection.voidSets the descendant-closure depth for Type-name matching.voidsetJsonQuery(String jsonQuery) Parses and sets the input JSON query string.voidSets the pagination limit.voidsetMaskMetadata(boolean maskMetadata) Configures privacy masking for full Type representations and_emitaliases.voidsetMetadataPolicy(org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy) Sets the metadata inclusion policy.voidSets the pagination offset.
-
Field Details
-
jsonQueryBuilder
The underlying query-text builder. -
oDatabaseDocument
protected com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocumentThe active OrientDB database session. -
limit
The pagination limit for the query. -
offset
The pagination offset for the query. -
metadataPolicy
protected org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicyThe metadata inclusion policy. -
depth
The descendant-closure depth for Type-name matching (0 = exact name only, N = N levels of descendants, -1 = all descendants recursively). -
maskMetadata
protected boolean maskMetadataWhether privacy-sensitive metadata values must be masked. -
projection
protected boolean projectionWhether the last query returned_emitprojection rows.
-
-
Constructor Details
-
TypeQueryExecutor
public TypeQueryExecutor()Creates a newTypeQueryExecutorinstance with default configuration.
-
-
Method Details
-
setJsonQuery
public void setJsonQuery(String jsonQuery) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException Parses and sets the input JSON query string.- Parameters:
jsonQuery- the JSON query string- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the JSON string is invalid
-
setLimit
Sets the pagination limit.- Parameters:
limit- the limit to set
-
setOffset
Sets the pagination offset.- Parameters:
offset- the offset to set
-
setMetadataPolicy
public void setMetadataPolicy(org.gcube.informationsystem.resourceregistry.api.rest.MetadataPolicy metadataPolicy) Sets the metadata inclusion policy.- Parameters:
metadataPolicy- the metadata policy to set
-
setDepth
Sets the descendant-closure depth for Type-name matching.- Parameters:
depth- 0 = exact name only, N = N levels of descendants, -1 = all descendants recursively
-
setMaskMetadata
public void setMaskMetadata(boolean maskMetadata) Configures privacy masking for full Type representations and_emitaliases.- Parameters:
maskMetadata-trueto redact sensitive metadata identity fields
-
isProjection
public boolean isProjection()Reports whether the last query returned flat_emitprojection rows.- Returns:
truewhen the executed query contained an_emitprojection
-
query
public String query() throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionExecutes the JSON query against the Types collection.- Returns:
- JSON array string of matching Type definitions
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the query is invalid, syntactically incorrect, or targets a Type category that is not queryableorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-