Package fr.gouv.vitam.metadata.client
Class MetaDataClientMock
- java.lang.Object
-
- fr.gouv.vitam.common.client.AbstractMockClient
-
- fr.gouv.vitam.metadata.client.MetaDataClientMock
-
- All Implemented Interfaces:
BasicClient
,MockOrRestClient
,VitamAutoCloseable
,MetaDataClient
,java.lang.AutoCloseable
public class MetaDataClientMock extends AbstractMockClient implements MetaDataClient
Mock client implementation for metadata
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class fr.gouv.vitam.common.client.AbstractMockClient
AbstractMockClient.FakeInboundResponse
-
-
Field Summary
-
Fields inherited from interface fr.gouv.vitam.common.client.BasicClient
STATUS_URL
-
-
Constructor Summary
Constructors Constructor Description MetaDataClientMock()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestResponse<com.fasterxml.jackson.databind.JsonNode>
atomicUpdateBulk(java.util.List<com.fasterxml.jackson.databind.JsonNode> updateQueries)
Bulk Update units by a list of update query (DSL)GraphComputeResponse
computeGraph(com.fasterxml.jackson.databind.JsonNode queryDsl)
Compute graph of all Units/Got that match the given query dsl The returned number of treated object group is an estimation, as object group can be computed several timesGraphComputeResponse
computeGraph(GraphComputeResponse.GraphComputeAction action, java.util.Set<java.lang.String> ids)
Compute graph of all document match ids.com.fasterxml.jackson.databind.JsonNode
createAccessionRegisterSymbolic()
Creates the AccessionRegisterSymbolics from ElasticSearch aggregations and nested aggregation request.void
deleteObjectGroupBulk(java.util.Collection<java.lang.String> listIds)
Delete Object Group Bulkvoid
deleteUnitsBulk(java.util.Collection<java.lang.String> listIds)
delete UnitsBulkvoid
exportReclassificationChildNodes(java.util.Set<java.lang.String> ids, java.lang.String unitsToUpdateJsonLineFileName, java.lang.String objectGroupsToUpdateJsonLineFileName)
Export all units and object groups that are a descendants of the provided units to workspace for graph update.RequestResponse<com.fasterxml.jackson.databind.JsonNode>
getObjectGroupByIdRaw(java.lang.String objectGroupId)
Search object group by path unit idRequestResponse<com.fasterxml.jackson.databind.JsonNode>
getObjectGroupsByIdsRaw(java.util.Collection<java.lang.String> objectGroupIds)
Select raw object group by idsRequestResponse<com.fasterxml.jackson.databind.JsonNode>
getUnitByIdRaw(java.lang.String unitId)
Search units by path unit idRequestResponse<com.fasterxml.jackson.databind.JsonNode>
getUnitsByIdsRaw(java.util.Collection<java.lang.String> unitIds)
Select raw unis by idscom.fasterxml.jackson.databind.JsonNode
insertObjectGroup(com.fasterxml.jackson.databind.JsonNode insertQuery)
com.fasterxml.jackson.databind.JsonNode
insertObjectGroups(java.util.List<com.fasterxml.jackson.databind.JsonNode> insertQuery)
com.fasterxml.jackson.databind.JsonNode
insertUnitBulk(BulkUnitInsertRequest request)
boolean
refreshObjectGroups()
boolean
refreshUnits()
com.fasterxml.jackson.databind.JsonNode
reindex(IndexParameters indexParam)
Reindex a collection with parametersjava.util.List<ObjectGroupPerOriginatingAgency>
selectAccessionRegisterOnObjectByOperationId(java.lang.String operationId)
java.util.List<UnitPerOriginatingAgency>
selectAccessionRegisterOnUnitByOperationId(java.lang.String operationId)
com.fasterxml.jackson.databind.JsonNode
selectObjectGroups(com.fasterxml.jackson.databind.JsonNode selectQuery)
Search objectgroups by select query (DSL)com.fasterxml.jackson.databind.JsonNode
selectObjectGrouptbyId(com.fasterxml.jackson.databind.JsonNode selectQuery, java.lang.String objectGroupId)
Search Object Group by query (DSL) and path objectGroup idcom.fasterxml.jackson.databind.JsonNode
selectUnitbyId(com.fasterxml.jackson.databind.JsonNode selectQuery, java.lang.String unitId)
Search units by query (DSL) and path unit idcom.fasterxml.jackson.databind.JsonNode
selectUnits(com.fasterxml.jackson.databind.JsonNode selectQuery)
Search units by select query (DSL)java.util.List<RequestResponseOK<com.fasterxml.jackson.databind.JsonNode>>
selectUnitsBulk(java.util.List<com.fasterxml.jackson.databind.JsonNode> selectQueryBulk)
Bulk Search units by a list of select query (DSL)com.fasterxml.jackson.databind.JsonNode
selectUnitsWithInheritedRules(com.fasterxml.jackson.databind.JsonNode selectQuery)
Select units with inherited rules by select query (DSL)javax.ws.rs.core.Response
streamUnits(com.fasterxml.jackson.databind.JsonNode selectQuery)
SwitchIndexResult
switchIndexes(SwitchIndexParameters switchIndexParam)
Switch indexesvoid
updateObjectGroupById(com.fasterxml.jackson.databind.JsonNode objectGroup, java.lang.String objectGroupId)
Update ObjectGroupRequestResponse<com.fasterxml.jackson.databind.JsonNode>
updateUnitBulk(com.fasterxml.jackson.databind.JsonNode updateQuery)
Update units Bulk.com.fasterxml.jackson.databind.JsonNode
updateUnitById(com.fasterxml.jackson.databind.JsonNode updateQuery, java.lang.String unitId)
Update units by query (DSL) and path unit idRequestResponse<com.fasterxml.jackson.databind.JsonNode>
updateUnitsRulesBulk(java.util.List<java.lang.String> unitsIds, RuleActions actions, java.util.Map<java.lang.String,DurationData> rulesToDurationData)
Update units rules Bulk.-
Methods inherited from class fr.gouv.vitam.common.client.AbstractMockClient
checkStatus, checkStatus, close, consumeAnyEntityAndClose, getResourcePath, getServiceUrl
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface fr.gouv.vitam.common.client.MockOrRestClient
checkStatus, checkStatus, close, consumeAnyEntityAndClose, getResourcePath, getServiceUrl
-
-
-
-
Method Detail
-
insertUnitBulk
public com.fasterxml.jackson.databind.JsonNode insertUnitBulk(BulkUnitInsertRequest request) throws InvalidParseOperationException, MetaDataExecutionException, MetaDataNotFoundException, MetaDataDocumentSizeException, MetaDataClientServerException
-
selectUnits
public com.fasterxml.jackson.databind.JsonNode selectUnits(com.fasterxml.jackson.databind.JsonNode selectQuery) throws MetaDataExecutionException, MetaDataDocumentSizeException, InvalidParseOperationException, MetaDataClientServerException
Description copied from interface:MetaDataClient
Search units by select query (DSL)- Specified by:
selectUnits
in interfaceMetaDataClient
- Parameters:
selectQuery
- : select querySelectMultiQuery
as String
Null is not allowed- Returns:
- Json object {$hint:{},$result:[{},{}]}
- Throws:
MetaDataExecutionException
- thrown when internal Server Error (fatal technical exception thrown)MetaDataDocumentSizeException
- thrown when Query document Size is Too LargeInvalidParseOperationException
MetaDataClientServerException
-
selectUnitsBulk
public java.util.List<RequestResponseOK<com.fasterxml.jackson.databind.JsonNode>> selectUnitsBulk(java.util.List<com.fasterxml.jackson.databind.JsonNode> selectQueryBulk) throws MetaDataExecutionException, MetaDataDocumentSizeException, InvalidParseOperationException, MetaDataClientServerException
Description copied from interface:MetaDataClient
Bulk Search units by a list of select query (DSL)- Specified by:
selectUnitsBulk
in interfaceMetaDataClient
- Returns:
- RequestResponse object {$hint:{},$result:[{},{}]} containing a list of RequestResponse (RequestResponseOK or VitamError) as JsonNode linked to each selectQuery
- Throws:
MetaDataExecutionException
- thrown when internal Server Error (fatal technical exception thrown)MetaDataDocumentSizeException
- thrown when Query document Size is Too LargeInvalidParseOperationException
MetaDataClientServerException
-
selectUnitbyId
public com.fasterxml.jackson.databind.JsonNode selectUnitbyId(com.fasterxml.jackson.databind.JsonNode selectQuery, java.lang.String unitId) throws MetaDataExecutionException, MetaDataDocumentSizeException, InvalidParseOperationException, MetaDataClientServerException
Description copied from interface:MetaDataClient
Search units by query (DSL) and path unit id- Specified by:
selectUnitbyId
in interfaceMetaDataClient
- Parameters:
selectQuery
- : select querySelect
as JsonNode
Null is not allowedunitId
- : unit id
null and blank is not allowed- Returns:
- Json object {$hint:{},$result:[{},{}]}
- Throws:
MetaDataExecutionException
- thrown when internal Server Error (fatal technical exception thrown)MetaDataDocumentSizeException
- thrown when Query document Size is Too LargeInvalidParseOperationException
MetaDataClientServerException
-
selectObjectGrouptbyId
public com.fasterxml.jackson.databind.JsonNode selectObjectGrouptbyId(com.fasterxml.jackson.databind.JsonNode selectQuery, java.lang.String objectGroupId) throws MetaDataExecutionException, MetaDataDocumentSizeException, InvalidParseOperationException, MetadataInvalidSelectException, MetaDataClientServerException
Description copied from interface:MetaDataClient
Search Object Group by query (DSL) and path objectGroup id- Specified by:
selectObjectGrouptbyId
in interfaceMetaDataClient
- Parameters:
selectQuery
- : select querySelect
as JsonNode
Null is not allowedobjectGroupId
- : objectGroup id
null and blank is not allowed- Returns:
- Json object {$hint:{},$result:[{},{}]}
- Throws:
MetaDataExecutionException
- thrown when internal Server Error (fatal technical exception thrown)MetaDataDocumentSizeException
- thrown when Query document Size is Too LargeInvalidParseOperationException
- thrown when the Query is badly formatted or objectGroupId is emptyMetadataInvalidSelectException
- thrown when objectGroupId or selectQuery id is null or blankMetaDataClientServerException
-
updateUnitById
public com.fasterxml.jackson.databind.JsonNode updateUnitById(com.fasterxml.jackson.databind.JsonNode updateQuery, java.lang.String unitId) throws MetaDataExecutionException, MetaDataDocumentSizeException, InvalidParseOperationException, MetaDataClientServerException
Description copied from interface:MetaDataClient
Update units by query (DSL) and path unit id- Specified by:
updateUnitById
in interfaceMetaDataClient
- Parameters:
updateQuery
- update querySelect
as JsonNode
Null is not allowedunitId
- unit id
null and blank is not allowed- Returns:
- Json object {$hint:{},$result:[{},{}]}
- Throws:
MetaDataExecutionException
- thrown when internal Server Error (fatal technical exception thrown)MetaDataDocumentSizeException
- thrown when Query document Size is Too LargeInvalidParseOperationException
MetaDataClientServerException
-
insertObjectGroup
public com.fasterxml.jackson.databind.JsonNode insertObjectGroup(com.fasterxml.jackson.databind.JsonNode insertQuery) throws InvalidParseOperationException, MetaDataExecutionException, MetaDataNotFoundException, MetaDataDocumentSizeException, MetaDataClientServerException
- Specified by:
insertObjectGroup
in interfaceMetaDataClient
- Parameters:
insertQuery
- as String- Returns:
- response as JsonNode contains the request result
- Throws:
InvalidParseOperationException
MetaDataExecutionException
MetaDataNotFoundException
MetaDataDocumentSizeException
MetaDataClientServerException
-
insertObjectGroups
public com.fasterxml.jackson.databind.JsonNode insertObjectGroups(java.util.List<com.fasterxml.jackson.databind.JsonNode> insertQuery) throws InvalidParseOperationException, MetaDataExecutionException, MetaDataNotFoundException, MetaDataDocumentSizeException, MetaDataClientServerException
-
selectAccessionRegisterOnUnitByOperationId
public java.util.List<UnitPerOriginatingAgency> selectAccessionRegisterOnUnitByOperationId(java.lang.String operationId) throws MetaDataClientServerException
- Specified by:
selectAccessionRegisterOnUnitByOperationId
in interfaceMetaDataClient
- Returns:
- the list of UnitsPerOriginatingAgency
- Throws:
MetaDataClientServerException
-
selectAccessionRegisterOnObjectByOperationId
public java.util.List<ObjectGroupPerOriginatingAgency> selectAccessionRegisterOnObjectByOperationId(java.lang.String operationId) throws MetaDataClientServerException
- Specified by:
selectAccessionRegisterOnObjectByOperationId
in interfaceMetaDataClient
- Returns:
- the list of ObjectGroupPerOriginatingAgency
- Throws:
MetaDataClientServerException
-
selectObjectGroups
public com.fasterxml.jackson.databind.JsonNode selectObjectGroups(com.fasterxml.jackson.databind.JsonNode selectQuery) throws MetaDataExecutionException, MetaDataDocumentSizeException, InvalidParseOperationException, MetaDataClientServerException
Description copied from interface:MetaDataClient
Search objectgroups by select query (DSL)- Specified by:
selectObjectGroups
in interfaceMetaDataClient
- Parameters:
selectQuery
- : select querySelectMultiQuery
as String
Null is not allowed- Returns:
- Json object {$hint:{},$result:[{},{}]}
- Throws:
MetaDataExecutionException
- thrown when internal Server Error (fatal technical exception thrown)MetaDataDocumentSizeException
- thrown when Query document Size is Too LargeInvalidParseOperationException
MetaDataClientServerException
-
updateObjectGroupById
public void updateObjectGroupById(com.fasterxml.jackson.databind.JsonNode objectGroup, java.lang.String objectGroupId)
Description copied from interface:MetaDataClient
Update ObjectGroup- Specified by:
updateObjectGroupById
in interfaceMetaDataClient
-
refreshUnits
public boolean refreshUnits()
- Specified by:
refreshUnits
in interfaceMetaDataClient
- Returns:
- True if the Units index is refreshed
-
refreshObjectGroups
public boolean refreshObjectGroups()
- Specified by:
refreshObjectGroups
in interfaceMetaDataClient
- Returns:
- True if the ObjectGroups index is refreshed
-
reindex
public com.fasterxml.jackson.databind.JsonNode reindex(IndexParameters indexParam) throws InvalidParseOperationException
Description copied from interface:MetaDataClient
Reindex a collection with parameters- Specified by:
reindex
in interfaceMetaDataClient
- Parameters:
indexParam
- reindexation parameters- Returns:
- JsonObject containing information about the newly created index
- Throws:
InvalidParseOperationException
-
switchIndexes
public SwitchIndexResult switchIndexes(SwitchIndexParameters switchIndexParam) throws InvalidParseOperationException
Description copied from interface:MetaDataClient
Switch indexes- Specified by:
switchIndexes
in interfaceMetaDataClient
- Parameters:
switchIndexParam
- switch index parameters- Returns:
- JsonObject containing information about the newly created index
- Throws:
InvalidParseOperationException
-
getUnitByIdRaw
public RequestResponse<com.fasterxml.jackson.databind.JsonNode> getUnitByIdRaw(java.lang.String unitId) throws VitamClientException
Description copied from interface:MetaDataClient
Search units by path unit id- Specified by:
getUnitByIdRaw
in interfaceMetaDataClient
- Parameters:
unitId
- : unit id
null and blank is not allowed- Returns:
- Json object {$hint:{},$result:[{}]} or vitam error
- Throws:
VitamClientException
-
getObjectGroupByIdRaw
public RequestResponse<com.fasterxml.jackson.databind.JsonNode> getObjectGroupByIdRaw(java.lang.String objectGroupId) throws VitamClientException
Description copied from interface:MetaDataClient
Search object group by path unit id- Specified by:
getObjectGroupByIdRaw
in interfaceMetaDataClient
- Parameters:
objectGroupId
- : objectGroup id
null and blank is not allowed- Returns:
- Json object {$hint:{},$result:[{}]} or vitam error
- Throws:
VitamClientException
-
getUnitsByIdsRaw
public RequestResponse<com.fasterxml.jackson.databind.JsonNode> getUnitsByIdsRaw(java.util.Collection<java.lang.String> unitIds)
Description copied from interface:MetaDataClient
Select raw unis by ids- Specified by:
getUnitsByIdsRaw
in interfaceMetaDataClient
- Parameters:
unitIds
- : unit ids
null and blank is not allowed- Returns:
- Json object {$hint:{},$result:[{}]} or vitam error
-
getObjectGroupsByIdsRaw
public RequestResponse<com.fasterxml.jackson.databind.JsonNode> getObjectGroupsByIdsRaw(java.util.Collection<java.lang.String> objectGroupIds)
Description copied from interface:MetaDataClient
Select raw object group by ids- Specified by:
getObjectGroupsByIdsRaw
in interfaceMetaDataClient
- Parameters:
objectGroupIds
- : object group ids
null and blank is not allowed- Returns:
- Json object {$hint:{},$result:[{}]} or vitam error
-
computeGraph
public GraphComputeResponse computeGraph(com.fasterxml.jackson.databind.JsonNode queryDsl) throws VitamClientException
Description copied from interface:MetaDataClient
Compute graph of all Units/Got that match the given query dsl The returned number of treated object group is an estimation, as object group can be computed several times- Specified by:
computeGraph
in interfaceMetaDataClient
- Returns:
- GraphComputeResponse
- Throws:
VitamClientException
-
computeGraph
public GraphComputeResponse computeGraph(GraphComputeResponse.GraphComputeAction action, java.util.Set<java.lang.String> ids) throws VitamClientException
Description copied from interface:MetaDataClient
Compute graph of all document match ids. The document can be UNIT, OBJECTGROUP, or UNIT AND OBJECTGROUP In case of UNIT AND OBJECTGROUP, the ids set is id of UNITs- Specified by:
computeGraph
in interfaceMetaDataClient
- Returns:
- GraphComputeResponse
- Throws:
VitamClientException
-
updateUnitBulk
public RequestResponse<com.fasterxml.jackson.databind.JsonNode> updateUnitBulk(com.fasterxml.jackson.databind.JsonNode updateQuery) throws InvalidParseOperationException, MetaDataExecutionException, MetaDataNotFoundException, MetaDataDocumentSizeException, MetaDataClientServerException
Description copied from interface:MetaDataClient
Update units Bulk.- Specified by:
updateUnitBulk
in interfaceMetaDataClient
- Returns:
- Throws:
InvalidParseOperationException
MetaDataExecutionException
MetaDataNotFoundException
MetaDataDocumentSizeException
MetaDataClientServerException
-
atomicUpdateBulk
public RequestResponse<com.fasterxml.jackson.databind.JsonNode> atomicUpdateBulk(java.util.List<com.fasterxml.jackson.databind.JsonNode> updateQueries) throws InvalidParseOperationException, MetaDataExecutionException, MetaDataNotFoundException, MetaDataDocumentSizeException, MetaDataClientServerException
Description copied from interface:MetaDataClient
Bulk Update units by a list of update query (DSL)- Specified by:
atomicUpdateBulk
in interfaceMetaDataClient
- Parameters:
updateQueries
- : update queryUpdateMultiQuery
as String Null is not allowed List can be empty- Returns:
- RequestResponse object {$hint:{},$result:[{},{}]} containing a list of RequestResponse (RequestResponseOK or VitamError) as JsonNode linked to each updateQuery
- Throws:
InvalidParseOperationException
MetaDataExecutionException
MetaDataNotFoundException
MetaDataDocumentSizeException
MetaDataClientServerException
-
updateUnitsRulesBulk
public RequestResponse<com.fasterxml.jackson.databind.JsonNode> updateUnitsRulesBulk(java.util.List<java.lang.String> unitsIds, RuleActions actions, java.util.Map<java.lang.String,DurationData> rulesToDurationData) throws InvalidParseOperationException, MetaDataExecutionException, MetaDataNotFoundException, MetaDataDocumentSizeException, MetaDataClientServerException
Description copied from interface:MetaDataClient
Update units rules Bulk.- Specified by:
updateUnitsRulesBulk
in interfaceMetaDataClient
- Parameters:
unitsIds
- the bulk unit ids to update- Returns:
- Throws:
InvalidParseOperationException
MetaDataExecutionException
MetaDataNotFoundException
MetaDataDocumentSizeException
MetaDataClientServerException
-
exportReclassificationChildNodes
public void exportReclassificationChildNodes(java.util.Set<java.lang.String> ids, java.lang.String unitsToUpdateJsonLineFileName, java.lang.String objectGroupsToUpdateJsonLineFileName)
Description copied from interface:MetaDataClient
Export all units and object groups that are a descendants of the provided units to workspace for graph update.- Specified by:
exportReclassificationChildNodes
in interfaceMetaDataClient
- Parameters:
ids
- the unit ids for which all descendant nodes (units and object groups) are to be updated.
-
selectUnitsWithInheritedRules
public com.fasterxml.jackson.databind.JsonNode selectUnitsWithInheritedRules(com.fasterxml.jackson.databind.JsonNode selectQuery)
Description copied from interface:MetaDataClient
Select units with inherited rules by select query (DSL)- Specified by:
selectUnitsWithInheritedRules
in interfaceMetaDataClient
- Parameters:
selectQuery
- : select query- Returns:
- Json object
-
createAccessionRegisterSymbolic
public com.fasterxml.jackson.databind.JsonNode createAccessionRegisterSymbolic()
Description copied from interface:MetaDataClient
Creates the AccessionRegisterSymbolics from ElasticSearch aggregations and nested aggregation request. Because the AccessionRegisterSymbolic is not available from this package, it is a JsonNode which is returned.- Specified by:
createAccessionRegisterSymbolic
in interfaceMetaDataClient
- Returns:
- a list of AccessionRegisterSymbolic as JsonNode
-
deleteUnitsBulk
public void deleteUnitsBulk(java.util.Collection<java.lang.String> listIds)
Description copied from interface:MetaDataClient
delete UnitsBulk- Specified by:
deleteUnitsBulk
in interfaceMetaDataClient
- Parameters:
listIds
- list of id to delete
-
deleteObjectGroupBulk
public void deleteObjectGroupBulk(java.util.Collection<java.lang.String> listIds)
Description copied from interface:MetaDataClient
Delete Object Group Bulk- Specified by:
deleteObjectGroupBulk
in interfaceMetaDataClient
- Parameters:
listIds
- list of id to delete
-
streamUnits
public javax.ws.rs.core.Response streamUnits(com.fasterxml.jackson.databind.JsonNode selectQuery) throws MetaDataClientServerException
- Specified by:
streamUnits
in interfaceMetaDataClient
- Throws:
MetaDataClientServerException
-
-