Class DbRequest
- java.lang.Object
-
- fr.gouv.vitam.metadata.core.database.collections.DbRequest
-
public class DbRequest extends java.lang.Object
DB Request using MongoDB only
-
-
Constructor Summary
Constructors Constructor Description DbRequest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Set<java.lang.String>
aggregateUnitDepths(java.util.Collection<java.lang.String> ids, int relativeDepth)
Aggregate Unit Depths according to parent relative Depthvoid
deleteObjectGroups(java.util.List<java.lang.String> documentsToDelete)
Delete object groupsvoid
deleteUnits(java.util.List<java.lang.String> documentsToDelete)
Delete unitsprotected Result<MetadataDocument<?>>
exactDepthUnitQuery(Query realQuery, Result<MetadataDocument<?>> previous, int exactDepth, java.lang.Integer tenantId, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, int limit, java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder> facets, java.lang.String scrollId, java.lang.Integer scrollTimeout, DynamicParserTokens parserTokens, boolean trackTotalHits)
Execute one Unit Query using exact Depthvoid
execInsertObjectGroupRequests(java.util.List<InsertParserMultiple> requestParsers)
Inserts an object groupvoid
execInsertUnitRequest(InsertParserMultiple requestParser)
Inserts a unitvoid
execInsertUnitRequests(BulkUnitInsertRequest request)
Inserts a unitResult<MetadataDocument<?>>
execRequest(RequestParserMultiple requestParser, java.util.List<OntologyModel> ontologies)
The request should be already analyzed.UpdatedDocument
execRuleRequest(java.lang.String documentId, RuleActions ruleActions, java.util.Map<java.lang.String,DurationData> bindRuleToDuration, OntologyValidator ontologyValidator, UnitValidator unitValidator, java.util.List<OntologyModel> ontologyModels)
Execute rule action on unitUpdatedDocument
execUpdateRequest(RequestParserMultiple requestParser, java.lang.String documentId, MetadataCollections metadataCollection, OntologyValidator ontologyValidator, UnitValidator unitValidator, java.util.List<OntologyModel> ontologyModels, boolean forceUpdate)
protected Result<MetadataDocument<?>>
executeQuery(RequestParserMultiple requestParser, RequestToAbstract requestToMongodb, int rank, Result<MetadataDocument<?>> previous, DynamicParserTokens parserTokens)
Execute one requestprotected Result<MetadataDocument<?>>
lastDeleteFilterProjection(DeleteToMongodb requestToMongodb, Result<MetadataDocument<?>> last)
Finalize the queries with last True Deleteprotected Result<MetadataDocument<?>>
lastSelectFilterProjection(SelectToMongodb requestToMongodb, Result<MetadataDocument<?>> last, boolean checkConsistency)
Finalize the queries with last True Selectprotected Result<MetadataDocument<?>>
objectGroupQuery(Query realQuery, Result<MetadataDocument<?>> previous, java.lang.Integer tenantId, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, int limit, java.lang.String scrollId, java.lang.Integer scrollTimeout, java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder> facets, DynamicParserTokens parserTokens, boolean trackTotalHits)
Execute one relative Depth ObjectGroup Queryprotected Result<MetadataDocument<?>>
relativeDepthUnitQuery(Query realQuery, Result<MetadataDocument<?>> previous, int relativeDepth, java.lang.Integer tenantId, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, int limit, java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder> facets, java.lang.String scrollId, java.lang.Integer scrollTimeout, DynamicParserTokens parserTokens, boolean trackTotalHits)
Execute one relative Depth Unit Queryprotected Result<MetadataDocument<?>>
sameDepthUnitQuery(Query realQuery, Result<MetadataDocument<?>> previous, java.lang.Integer tenantId, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, int limit, java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder> facets, java.lang.String scrollId, java.lang.Integer scrollTimeout, DynamicParserTokens parserTokens, boolean trackTotalHits)
Execute one relative Depth Unit Query
-
-
-
Method Detail
-
execRuleRequest
public UpdatedDocument execRuleRequest(java.lang.String documentId, RuleActions ruleActions, java.util.Map<java.lang.String,DurationData> bindRuleToDuration, OntologyValidator ontologyValidator, UnitValidator unitValidator, java.util.List<OntologyModel> ontologyModels) throws InvalidParseOperationException, MetaDataExecutionException, InvalidCreateOperationException, MetaDataNotFoundException, MetadataValidationException
Execute rule action on unit- Parameters:
ontologyModels
-documentId
- the unitIdruleActions
- the list of ruleAction (by category)- Throws:
InvalidParseOperationException
MetaDataExecutionException
InvalidCreateOperationException
MetaDataNotFoundException
MetadataValidationException
-
execRequest
public Result<MetadataDocument<?>> execRequest(RequestParserMultiple requestParser, java.util.List<OntologyModel> ontologies) throws MetaDataExecutionException, InvalidParseOperationException, BadRequestException, VitamDBException
The request should be already analyzed.- Parameters:
requestParser
- the RequestParserMultiple to execute- Returns:
- the Result
- Throws:
MetaDataExecutionException
- when select/update/delete on metadata collection exception occurredInvalidParseOperationException
- when json data exception occurredBadRequestException
VitamDBException
-
execUpdateRequest
public UpdatedDocument execUpdateRequest(RequestParserMultiple requestParser, java.lang.String documentId, MetadataCollections metadataCollection, OntologyValidator ontologyValidator, UnitValidator unitValidator, java.util.List<OntologyModel> ontologyModels, boolean forceUpdate) throws MetaDataExecutionException, InvalidParseOperationException, MetaDataNotFoundException, MetadataValidationException
-
executeQuery
protected Result<MetadataDocument<?>> executeQuery(RequestParserMultiple requestParser, RequestToAbstract requestToMongodb, int rank, Result<MetadataDocument<?>> previous, DynamicParserTokens parserTokens) throws MetaDataExecutionException, InvalidParseOperationException, BadRequestException
Execute one request- Parameters:
requestToMongodb
-rank
- current rank queryprevious
- previous Result from previous level (except in level == 0 where it is the subset of valid roots)- Returns:
- the new Result from this request
- Throws:
MetaDataExecutionException
InvalidParseOperationException
BadRequestException
-
exactDepthUnitQuery
protected Result<MetadataDocument<?>> exactDepthUnitQuery(Query realQuery, Result<MetadataDocument<?>> previous, int exactDepth, java.lang.Integer tenantId, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, int limit, java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder> facets, java.lang.String scrollId, java.lang.Integer scrollTimeout, DynamicParserTokens parserTokens, boolean trackTotalHits) throws InvalidParseOperationException, MetaDataExecutionException, BadRequestException
Execute one Unit Query using exact Depth- Parameters:
realQuery
-previous
-exactDepth
-tenantId
-sorts
-offset
-limit
-facets
-trackTotalHits
-- Returns:
- the associated Result
- Throws:
InvalidParseOperationException
MetaDataExecutionException
BadRequestException
-
relativeDepthUnitQuery
protected Result<MetadataDocument<?>> relativeDepthUnitQuery(Query realQuery, Result<MetadataDocument<?>> previous, int relativeDepth, java.lang.Integer tenantId, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, int limit, java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder> facets, java.lang.String scrollId, java.lang.Integer scrollTimeout, DynamicParserTokens parserTokens, boolean trackTotalHits) throws InvalidParseOperationException, MetaDataExecutionException, BadRequestException
Execute one relative Depth Unit Query- Parameters:
realQuery
-previous
-relativeDepth
-tenantId
-sorts
-offset
-limit
-facets
-trackTotalHits
-- Returns:
- the associated Result
- Throws:
InvalidParseOperationException
MetaDataExecutionException
BadRequestException
-
aggregateUnitDepths
protected java.util.Set<java.lang.String> aggregateUnitDepths(java.util.Collection<java.lang.String> ids, int relativeDepth)
Aggregate Unit Depths according to parent relative Depth- Parameters:
ids
-relativeDepth
-- Returns:
- the aggregate set of multi level parents for this relativeDepth
-
sameDepthUnitQuery
protected Result<MetadataDocument<?>> sameDepthUnitQuery(Query realQuery, Result<MetadataDocument<?>> previous, java.lang.Integer tenantId, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, int limit, java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder> facets, java.lang.String scrollId, java.lang.Integer scrollTimeout, DynamicParserTokens parserTokens, boolean trackTotalHits) throws InvalidParseOperationException, MetaDataExecutionException, BadRequestException
Execute one relative Depth Unit Query- Parameters:
realQuery
-previous
-tenantId
-sorts
-offset
-limit
-facets
-trackTotalHits
-- Returns:
- the associated Result
- Throws:
InvalidParseOperationException
MetaDataExecutionException
BadRequestException
-
objectGroupQuery
protected Result<MetadataDocument<?>> objectGroupQuery(Query realQuery, Result<MetadataDocument<?>> previous, java.lang.Integer tenantId, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, int limit, java.lang.String scrollId, java.lang.Integer scrollTimeout, java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder> facets, DynamicParserTokens parserTokens, boolean trackTotalHits) throws InvalidParseOperationException, MetaDataExecutionException, BadRequestException
Execute one relative Depth ObjectGroup Query- Parameters:
realQuery
-previous
- units, Note: only immediate Unit parents are allowedtenantId
-sorts
-offset
-limit
-trackTotalHits
-- Returns:
- the associated Result
- Throws:
InvalidParseOperationException
MetaDataExecutionException
BadRequestException
-
lastSelectFilterProjection
protected Result<MetadataDocument<?>> lastSelectFilterProjection(SelectToMongodb requestToMongodb, Result<MetadataDocument<?>> last, boolean checkConsistency) throws InvalidParseOperationException, VitamDBException
Finalize the queries with last True Select- Parameters:
requestToMongodb
-last
-- Returns:
- the final Result
- Throws:
InvalidParseOperationException
VitamDBException
-
execInsertUnitRequest
public void execInsertUnitRequest(InsertParserMultiple requestParser) throws MetaDataExecutionException, MetaDataNotFoundException
Inserts a unit- Parameters:
requestParser
- the InsertParserMultiple to execute- Throws:
MetaDataExecutionException
- when insert on metadata collection exception occurredMetaDataNotFoundException
- when metadata not found exception
-
execInsertObjectGroupRequests
public void execInsertObjectGroupRequests(java.util.List<InsertParserMultiple> requestParsers) throws MetaDataExecutionException, InvalidParseOperationException
Inserts an object group- Parameters:
requestParsers
- the list of InsertParserMultiple to execute- Throws:
MetaDataExecutionException
- when insert on metadata collection exception occurredInvalidParseOperationException
- when json data exception occurredMetaDataAlreadyExistException
- when insert metadata exception
-
lastDeleteFilterProjection
protected Result<MetadataDocument<?>> lastDeleteFilterProjection(DeleteToMongodb requestToMongodb, Result<MetadataDocument<?>> last) throws MetaDataExecutionException
Finalize the queries with last True Delete- Parameters:
requestToMongodb
-last
-- Returns:
- the final Result
- Throws:
InvalidParseOperationException
MetaDataExecutionException
-
execInsertUnitRequests
public void execInsertUnitRequests(BulkUnitInsertRequest request) throws MetaDataExecutionException, MetaDataNotFoundException
Inserts a unit- Parameters:
request
- list of unit insert requests- Throws:
MetaDataExecutionException
- when insert on metadata collection exception occurredMetaDataNotFoundException
- when metadata not found exception
-
deleteUnits
public void deleteUnits(java.util.List<java.lang.String> documentsToDelete) throws MetaDataExecutionException
Delete units- Throws:
MetaDataExecutionException
-
deleteObjectGroups
public void deleteObjectGroups(java.util.List<java.lang.String> documentsToDelete) throws MetaDataExecutionException
Delete object groups- Throws:
MetaDataExecutionException
-
-