Class MarkLogicTemplate
- java.lang.Object
-
- io.github.malteseduck.springframework.data.marklogic.core.MarkLogicTemplate
-
- All Implemented Interfaces:
MarkLogicOperations,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
public class MarkLogicTemplate extends Object implements MarkLogicOperations, org.springframework.context.ApplicationContextAware
-
-
Constructor Summary
Constructors Constructor Description MarkLogicTemplate(com.marklogic.client.DatabaseClient client)Create a template interface using the specified database client and the default entity converter and query conversion service.MarkLogicTemplate(com.marklogic.client.DatabaseClient client, MarkLogicConverter converter)Create a template interface using the specified database client and the default query conversion service.MarkLogicTemplate(com.marklogic.client.DatabaseClient client, MarkLogicConverter converter, QueryConversionService queryConversionService)Create a template interface using the specified database client.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(org.springframework.core.io.Resource configuration)Configures the connected database using the specified JSON information.longcount(com.marklogic.client.query.StructuredQueryDefinition query)Gives a count of the number of documents that would match the specified query.<T> longcount(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)Count the number of entities that would match the specified query.<T> longcount(Class<T> entityClass)Count the number of the specified entity that exist in the database.longcount(String... collections)Count the number of documents that exist in the database under the specified collections.<T> voiddelete(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)Delete entities of the specified type that match the specified query.<T> voiddelete(List<T> entities)Delete the specified entities from the database.<T> voiddeleteById(Object id, Class<T> entityClass)Deletes the entity with the specified ID.<T> voiddeleteByIds(List<?> ids, Class<T> entityClass)Deletes the entities which have one of the specified IDs.voiddeleteByUri(String... uris)Delete a document from the database that is stored under the specified urisvoiddeleteByUris(List<String> uris)Delete a set of documents from the database that are stored under one of the specified URIs<T> voiddropCollection(Class<T> entityClass)Deletes all the entities of the specified type.<T> voiddropCollections(Class<T>... entityClasses)Deletes all the entities of the specified types.voiddropCollections(String... collections)Delete documents that are under the specified collection URIs.<T> Texecute(DocumentCallback<T> action)Executes the specified action using aGenericDocumentManagerinterface.<T> TexecuteQuery(QueryCallback<T> action)Executes the specified action using aQueryManager.<T> TexecuteWithClient(ClientCallback<T> action)Executes the specified action using the fullDatabaseClient.<T> booleanexists(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)Check for existence of entities matching the specified structured query.<T> booleanexists(Object id, Class<T> entityClass)Check for existence of an entity in the database by using it's ID.booleanexists(String uri)Check for existence of a document by using the full URI under which the document is stored.<T> FacetedPage<T>facetedSearch(com.marklogic.client.query.StructuredQueryDefinition query, long start, int limit, Class<T> entityClass)Similar to a normal paged query, except also includes facets for the matched results.<T> FacetedPage<T>facetedSearch(com.marklogic.client.query.StructuredQueryDefinition query, long start, Class<T> entityClass)<T> FacetedPage<T>facetedSearch(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable, Class<T> entityClass)Same as faceted search with int bounds, but allows paging/sorting based off Spring Pageable.MarkLogicConvertergetConverter()Get the entity converter that is used to convert Java POJOs into a form with which they can be stored in the database.QueryConversionServicegetQueryConversionService()Get the query object convert service that is used to convert various Java types into their "correct" form for querying in MarkLogic.QueryMappergetQueryMapper()The query mapper is responsible for interpreting entity/query annotations and applying the information to a query before it is executed in MarkLogicTemplate.<T> com.marklogic.client.pojo.PojoQueryBuilder<T>qb(Class<T> entityClass)Get an instance of aPojoQueryBuilderfor the specified entity class.<T> Tread(Object id, Class<T> entityClass)Read a document with the specified ID from the database.List<com.marklogic.client.document.DocumentRecord>read(List<?> uris)Reads a list of documents from the database by their URIs instead of ids.<T> List<T>read(List<?> ids, Class<T> entityClass)Reads a set of documents that have the specified IDs.List<com.marklogic.client.document.DocumentRecord>search(com.marklogic.client.query.StructuredQueryDefinition query)Query for a list of documents using the specified structured query.com.marklogic.client.document.DocumentPagesearch(com.marklogic.client.query.StructuredQueryDefinition query, long start)Query for a page of documents using the specified structured query, starting at the specified item in the result set.com.marklogic.client.document.DocumentPagesearch(com.marklogic.client.query.StructuredQueryDefinition query, long start, int length)Query for a page of documents using the specified structured query.<T> org.springframework.data.domain.Page<T>search(com.marklogic.client.query.StructuredQueryDefinition query, long start, int limit, Class<T> entityClass)Queries for a page of documents of the specified type, using the specified structured query to constrain which documents are returned.<T> org.springframework.data.domain.Page<T>search(com.marklogic.client.query.StructuredQueryDefinition query, long start, Class<T> entityClass)Query for a page of of documents of the specified type using the specified structured query.<T> List<T>search(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)Query for a list of of documents of the specified type using the specified structured query.com.marklogic.client.document.DocumentPagesearch(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable)Same as search with int bounds, but allows paging/sorting based off Spring Pageable.<T> org.springframework.data.domain.Page<T>search(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable, Class<T> entityClass)Same as search with int bounds, but allows paging/sorting based off Spring Pageable.<T> List<T>search(Class<T> entityClass)Query for a list of of documents of the specified type.<T> TsearchOne(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)Query for a single entity using the specified structured query.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)com.marklogic.client.query.StructuredQueryDefinitionsortQuery(org.springframework.data.domain.Sort sort, com.marklogic.client.query.StructuredQueryDefinition query)Adds sorting configuration to the specified query.<T> com.marklogic.client.query.StructuredQueryDefinitionsortQuery(org.springframework.data.domain.Sort sort, com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)Add sorting configuration to the specified query.InputStreamstream(com.marklogic.client.query.StructuredQueryDefinition query)InputStreamstream(com.marklogic.client.query.StructuredQueryDefinition query, long start)InputStreamstream(com.marklogic.client.query.StructuredQueryDefinition query, long start, int length)<T> InputStreamstream(com.marklogic.client.query.StructuredQueryDefinition query, long start, int length, Class<T> entityClass)Queries just like theMarkLogicOperations.search(StructuredQueryDefinition, long, int, Class)method does, but instead of a page/list of documents it returns an input stream straight from the results of the REST call against the database.<T> InputStreamstream(com.marklogic.client.query.StructuredQueryDefinition query, long start, Class<T> entityClass)<T> InputStreamstream(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)InputStreamstream(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable)Same as method taking int bounds, but allows use of Pagable for paging/sorting.<T> InputStreamstream(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable, Class<T> entityClass)Same as method taking int bounds, but allows use of Pagable for paging/sorting.com.marklogic.client.query.StructuredQueryDefinitiontermQuery(String term, com.marklogic.client.query.StructuredQueryDefinition query)Add a search term to the specified query.protected <T> List<T>toEntityList(Class<T> entityClass, com.marklogic.client.document.DocumentPage page)protected List<com.marklogic.client.document.DocumentRecord>toRecordList(com.marklogic.client.document.DocumentPage page)<T> List<T>write(List<T> entities)Write the specified entities to the database into the default entity collection, without any transforms<T> List<T>write(List<T> entities, com.marklogic.client.document.ServerTransform transform)Write the specified entities to the database into the default entity collection using the specified transform.<T> List<T>write(List<T> entities, com.marklogic.client.document.ServerTransform transform, String... collections)Write the specified list of entities to the database.<T> List<T>write(List<T> entities, String... collections)Write the specified entities to the database into the specified collections, without any transforms.<T> Twrite(T entity)Write a single entity to the database into the default entity collection without any transforms.<T> Twrite(T entity, com.marklogic.client.document.ServerTransform transform)Write the specified entity to the database into the default entity collection using the specified transform.<T> Twrite(T entity, com.marklogic.client.document.ServerTransform transform, String... collections)Write the specified entity to the database into the specified collections with the specified transform.<T> Twrite(T entity, String... collections)Write a single entity to the database into the specified collections, without any transforms.
-
-
-
Constructor Detail
-
MarkLogicTemplate
public MarkLogicTemplate(com.marklogic.client.DatabaseClient client)
Create a template interface using the specified database client and the default entity converter and query conversion service.- Parameters:
client- The MarkLogic database client created from @seeDatabaseClientFactory
-
MarkLogicTemplate
public MarkLogicTemplate(com.marklogic.client.DatabaseClient client, MarkLogicConverter converter)Create a template interface using the specified database client and the default query conversion service.- Parameters:
client- The MarkLogic database client created from DatabaseClientFactory.converter- A custom entity converter.
-
MarkLogicTemplate
public MarkLogicTemplate(com.marklogic.client.DatabaseClient client, MarkLogicConverter converter, QueryConversionService queryConversionService)Create a template interface using the specified database client. Also provide a custom convert that handles the translation of entities between Java and MarkLogic. You can also provide a custom query conversion service that will handle the conversion of different types used in finder queries and @Query queries.- Parameters:
client- The MarkLogic database client created from @seeDatabaseClientFactory.converter- A custom entity converter.queryConversionService- A custom query object conversion service.
-
-
Method Detail
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
execute
public <T> T execute(DocumentCallback<T> action)
Description copied from interface:MarkLogicOperationsExecutes the specified action using aGenericDocumentManagerinterface. For all the basic operations this is sufficient.- Specified by:
executein interfaceMarkLogicOperations- Type Parameters:
T- The result type of the function.- Parameters:
action- A function to execute using the document manager. The active transaction is also provided so that the function can add additional operations to it.- Returns:
- The results of the document manager interactions (results of a query, etc.).
-
executeWithClient
public <T> T executeWithClient(ClientCallback<T> action)
Description copied from interface:MarkLogicOperationsExecutes the specified action using the fullDatabaseClient. This gives you full control of your interactions with the database with the full power of the MarkLogic Java Client Library, but it also requires you to do a lot of the busy work yourself. Should mainly be used for operations not supported currently in this template interface either through the helper methods, aGenericDocumentManager, or aQueryManager.- Specified by:
executeWithClientin interfaceMarkLogicOperations- Type Parameters:
T- The result type of the function.- Parameters:
action- A function to execute using the database client and active transaction.- Returns:
- The results of the function.
-
executeQuery
public <T> T executeQuery(QueryCallback<T> action)
Description copied from interface:MarkLogicOperationsExecutes the specified action using aQueryManager.- Specified by:
executeQueryin interfaceMarkLogicOperations- Type Parameters:
T- The result type of the function.- Parameters:
action- A function to execute using the query manager and active transaction.- Returns:
- The results from the query manager.
-
qb
public <T> com.marklogic.client.pojo.PojoQueryBuilder<T> qb(Class<T> entityClass)
Description copied from interface:MarkLogicOperationsGet an instance of aPojoQueryBuilderfor the specified entity class. This is a simplified interface for building structured queries against JSON objects in the database. For full control of all query options use theStructuredQueryBuilderinstead.- Specified by:
qbin interfaceMarkLogicOperations- Type Parameters:
T- The type of the entity.- Parameters:
entityClass- Type of Java entity being stored in the database.- Returns:
-
sortQuery
public com.marklogic.client.query.StructuredQueryDefinition sortQuery(org.springframework.data.domain.Sort sort, com.marklogic.client.query.StructuredQueryDefinition query)Description copied from interface:MarkLogicOperationsAdds sorting configuration to the specified query.- Specified by:
sortQueryin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.sortQuery(Sort, StructuredQueryDefinition, Class)
-
sortQuery
public <T> com.marklogic.client.query.StructuredQueryDefinition sortQuery(org.springframework.data.domain.Sort sort, com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)Description copied from interface:MarkLogicOperationsAdd sorting configuration to the specified query. The default sort algorithm will expect to use a path range index with specified sort properties, i.e. if sorting on "name" then a path index of "/name" should exist. Through use of theIndexedannotation you can indicate use of a different type of range index for the property sorting, or specify the full path that should be used in creation of the sort options. This requires that the entity type is specified.- Specified by:
sortQueryin interfaceMarkLogicOperations- Parameters:
sort- Sort information for the query, i.e. which properties and which orders.query- The structured query to "enhance".entityClass- The entity type.- Returns:
- The "enhanced" query definition for use in continued building.
-
termQuery
public com.marklogic.client.query.StructuredQueryDefinition termQuery(String term, com.marklogic.client.query.StructuredQueryDefinition query)
Description copied from interface:MarkLogicOperationsAdd a search term to the specified query. This is used for word searches across your entire document. For more fine-grained control useStructuredQueryBuilder.word(StructuredQueryBuilder.TextIndex, String...)to specify specific properties or fields into which to scope the word search.- Specified by:
termQueryin interfaceMarkLogicOperations- Parameters:
term- A search phrase.query- The structured query to "enhance".- Returns:
- The "enhanced" query definition for use in continued building.
-
configure
public void configure(org.springframework.core.io.Resource configuration) throws IOExceptionDescription copied from interface:MarkLogicOperationsConfigures the connected database using the specified JSON information. The format of the JSON is outlined at http://docs.marklogic.com/REST/PUT/manage/v2/databases/[id-or-name]/properties. This requires that the client was created with a user that has "admin" privileges.- Specified by:
configurein interfaceMarkLogicOperations- Parameters:
configuration- Resource pointing to a JSON document containing database configuration information.- Throws:
IOException
-
write
public <T> T write(T entity)
Description copied from interface:MarkLogicOperationsWrite a single entity to the database into the default entity collection without any transforms.- Specified by:
writein interfaceMarkLogicOperations- See Also:
MarkLogicOperations.write(List, ServerTransform, String...)
-
write
public <T> T write(T entity, String... collections)Description copied from interface:MarkLogicOperationsWrite a single entity to the database into the specified collections, without any transforms.- Specified by:
writein interfaceMarkLogicOperations- See Also:
MarkLogicOperations.write(List, ServerTransform, String...)
-
write
public <T> T write(T entity, @Nullable com.marklogic.client.document.ServerTransform transform)Description copied from interface:MarkLogicOperationsWrite the specified entity to the database into the default entity collection using the specified transform.- Specified by:
writein interfaceMarkLogicOperations- See Also:
MarkLogicOperations.write(List, ServerTransform, String...)
-
write
public <T> T write(T entity, @Nullable com.marklogic.client.document.ServerTransform transform, String... collections)Description copied from interface:MarkLogicOperationsWrite the specified entity to the database into the specified collections with the specified transform.- Specified by:
writein interfaceMarkLogicOperations- See Also:
MarkLogicOperations.write(List, ServerTransform, String...)
-
write
public <T> List<T> write(List<T> entities)
Description copied from interface:MarkLogicOperationsWrite the specified entities to the database into the default entity collection, without any transforms- Specified by:
writein interfaceMarkLogicOperations- See Also:
MarkLogicOperations.write(List, ServerTransform, String...)
-
write
public <T> List<T> write(List<T> entities, String... collections)
Description copied from interface:MarkLogicOperationsWrite the specified entities to the database into the specified collections, without any transforms.- Specified by:
writein interfaceMarkLogicOperations- See Also:
MarkLogicOperations.write(List, ServerTransform, String...)
-
write
public <T> List<T> write(List<T> entities, @Nullable com.marklogic.client.document.ServerTransform transform)
Description copied from interface:MarkLogicOperationsWrite the specified entities to the database into the default entity collection using the specified transform.- Specified by:
writein interfaceMarkLogicOperations- See Also:
MarkLogicOperations.write(List, ServerTransform, String...)
-
write
public <T> List<T> write(List<T> entities, @Nullable com.marklogic.client.document.ServerTransform transform, String... collections)
Description copied from interface:MarkLogicOperationsWrite the specified list of entities to the database. Using theDocumentannotation you can specify some information as to how it is persisted (i.e. whether or not to store it in a "type" collection, what path, etc.). If a transform is specified then before the entity is saved into the database they transform will be run against each entity. For more information see http://docs.marklogic.com/guide/java/transforms.- Specified by:
writein interfaceMarkLogicOperations- Type Parameters:
T- The type of entity- Parameters:
entities- A list of POJO entities you wish to save into the database.transform- The transform to use before finally persisting to the database.collections- Additional collections to which you want the document to be a part of inside the database.- Returns:
- The list of entities that were saved to the database. This is mainly for convenience as they are not modified through this process.
-
read
public <T> T read(Object id, Class<T> entityClass)
Description copied from interface:MarkLogicOperationsRead a document with the specified ID from the database.- Specified by:
readin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.read(List, Class)
-
read
public List<com.marklogic.client.document.DocumentRecord> read(List<?> uris)
Description copied from interface:MarkLogicOperationsReads a list of documents from the database by their URIs instead of ids. Since type information is not know a "raw"DocumentRecordis returned, and can be handled as desired.- Specified by:
readin interfaceMarkLogicOperations- Parameters:
uris- A list of database URIs of documents.- Returns:
- A list of
DocumentRecordobjects from the database.
-
read
public <T> List<T> read(List<?> ids, Class<T> entityClass)
Description copied from interface:MarkLogicOperationsReads a set of documents that have the specified IDs. The documents must match the specified type or they will not be included in the result set.- Specified by:
readin interfaceMarkLogicOperations- Type Parameters:
T- The type of the entity.- Parameters:
ids- A list of IDs of entities.entityClass- The Java type of the entity.- Returns:
- A list of all the entities that matched the specified IDs.
-
search
public List<com.marklogic.client.document.DocumentRecord> search(com.marklogic.client.query.StructuredQueryDefinition query)
Description copied from interface:MarkLogicOperationsQuery for a list of documents using the specified structured query.- Specified by:
searchin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.search(StructuredQueryDefinition, long, int)
-
search
public <T> List<T> search(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)
Description copied from interface:MarkLogicOperationsQuery for a list of of documents of the specified type using the specified structured query. Only the firstDocumentManagerImpl.DEFAULT_PAGE_LENGTHdocuments are returned.- Specified by:
searchin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.search(StructuredQueryDefinition, long, int, Class)
-
searchOne
public <T> T searchOne(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)Description copied from interface:MarkLogicOperationsQuery for a single entity using the specified structured query. If for some reason multiple results are matched then only the first is returned. This is a convenience method to get a single item when you "know" that is all there is.- Specified by:
searchOnein interfaceMarkLogicOperations- See Also:
MarkLogicOperations.search(StructuredQueryDefinition, long, int, Class)
-
search
public <T> List<T> search(Class<T> entityClass)
Query for a list of of documents of the specified type. As this returns all the documents for the type it can potentially take a long time to resolve pulling all of them back from the database. The query will be fast, but transmitting all the records could time out if the result set is sufficiently large. It is recommended that you page your results. This method is mainly created to accommodate creating an implementation for theCrudRepository.findAll()method.- Specified by:
searchin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.search(StructuredQueryDefinition, long, int, Class)
-
search
public com.marklogic.client.document.DocumentPage search(com.marklogic.client.query.StructuredQueryDefinition query, long start)Description copied from interface:MarkLogicOperationsQuery for a page of documents using the specified structured query, starting at the specified item in the result set.- Specified by:
searchin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.search(StructuredQueryDefinition, long, int)
-
search
public <T> org.springframework.data.domain.Page<T> search(com.marklogic.client.query.StructuredQueryDefinition query, long start, Class<T> entityClass)Description copied from interface:MarkLogicOperationsQuery for a page of of documents of the specified type using the specified structured query. Only a page of documents is returned, starting from the specified start index and containingDocumentManagerImpl.DEFAULT_PAGE_LENGTHentities.- Specified by:
searchin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.search(StructuredQueryDefinition, long, int, Class)
-
search
public com.marklogic.client.document.DocumentPage search(com.marklogic.client.query.StructuredQueryDefinition query, long start, int length)Description copied from interface:MarkLogicOperationsQuery for a page of documents using the specified structured query. Specify a start and length to get different "chunks" of data in the result set from the database. You seldom want to return all results, as this could be a very large number and will degrade the performance of your application. You instead should query out "pages" of data as needed.- Specified by:
searchin interfaceMarkLogicOperations- Parameters:
query- A structured query defining the constraints to use to match the desired documents.start- The start index within the result set that acts as the start of the "page".length- The number of items to include in the "page"- Returns:
- A
DocumentPagecontaining the records for this "chunk" of the result set.
-
search
public com.marklogic.client.document.DocumentPage search(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable)Description copied from interface:MarkLogicOperationsSame as search with int bounds, but allows paging/sorting based off Spring Pageable.- Specified by:
searchin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.search(StructuredQueryDefinition, long, int, Class)
-
search
public <T> org.springframework.data.domain.Page<T> search(com.marklogic.client.query.StructuredQueryDefinition query, long start, int limit, Class<T> entityClass)Description copied from interface:MarkLogicOperationsQueries for a page of documents of the specified type, using the specified structured query to constrain which documents are returned. Only a page is returned, starting from the specified index and containing the specified number of entries.- Specified by:
searchin interfaceMarkLogicOperations- Type Parameters:
T- The type of entity.- Parameters:
query- The structured query to use to match documents in the database.start- The starting index within the result set of matches.limit- The number of documents to return.entityClass- The entity type class.- Returns:
- A page of documents matching the specified parameters.
-
search
public <T> org.springframework.data.domain.Page<T> search(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable, Class<T> entityClass)Description copied from interface:MarkLogicOperationsSame as search with int bounds, but allows paging/sorting based off Spring Pageable.- Specified by:
searchin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.search(StructuredQueryDefinition, long, int, Class)
-
facetedSearch
public <T> FacetedPage<T> facetedSearch(com.marklogic.client.query.StructuredQueryDefinition query, long start, Class<T> entityClass)
- Specified by:
facetedSearchin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.facetedSearch(StructuredQueryDefinition, long, int, Class)
-
facetedSearch
public <T> FacetedPage<T> facetedSearch(com.marklogic.client.query.StructuredQueryDefinition query, long start, int limit, Class<T> entityClass)
Description copied from interface:MarkLogicOperationsSimilar to a normal paged query, except also includes facets for the matched results. In order for the facets to be generated you need to ensure the specified query has the name of persisted options that describe the facets, or the query is aCombinedQueryDefinitionthat includes the ad-hoc options definitions for them.- Specified by:
facetedSearchin interfaceMarkLogicOperations- Type Parameters:
T- The type of entity.- Parameters:
query- The structured query to use to match documents in the database.start- The starting index within the result set of matches.limit- The number of documents to return.entityClass- The entity type class.- Returns:
- A page of documents matching the specified parameters with the included facets.
-
facetedSearch
public <T> FacetedPage<T> facetedSearch(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable, Class<T> entityClass)
Description copied from interface:MarkLogicOperationsSame as faceted search with int bounds, but allows paging/sorting based off Spring Pageable.- Specified by:
facetedSearchin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.search(StructuredQueryDefinition, long, int, Class)
-
stream
public InputStream stream(com.marklogic.client.query.StructuredQueryDefinition query)
- Specified by:
streamin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.stream(StructuredQueryDefinition, long, int, Class)
-
stream
public <T> InputStream stream(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)
- Specified by:
streamin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.stream(StructuredQueryDefinition, long, int, Class)
-
stream
public InputStream stream(com.marklogic.client.query.StructuredQueryDefinition query, long start)
- Specified by:
streamin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.stream(StructuredQueryDefinition, long, int, Class)
-
stream
public <T> InputStream stream(com.marklogic.client.query.StructuredQueryDefinition query, long start, Class<T> entityClass)
- Specified by:
streamin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.stream(StructuredQueryDefinition, long, int, Class)
-
stream
public InputStream stream(com.marklogic.client.query.StructuredQueryDefinition query, long start, int length)
- Specified by:
streamin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.stream(StructuredQueryDefinition, long, int, Class)
-
stream
public InputStream stream(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable)
Description copied from interface:MarkLogicOperationsSame as method taking int bounds, but allows use of Pagable for paging/sorting.- Specified by:
streamin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.stream(StructuredQueryDefinition, long, int, Class)
-
stream
public <T> InputStream stream(com.marklogic.client.query.StructuredQueryDefinition query, long start, int length, Class<T> entityClass)
Description copied from interface:MarkLogicOperationsQueries just like theMarkLogicOperations.search(StructuredQueryDefinition, long, int, Class)method does, but instead of a page/list of documents it returns an input stream straight from the results of the REST call against the database. The purpose of these methods is to skip the serialization/deserialization process of your application layer and just return raw data. If you don't need to access any parts of the document and just need to return the raw JSON/XML then it is easier/faster to just copy the stream from the database into the HTTP response directly. Extractions or server-side transforms can still be used to change how the data is returned in cases where there are properties you don't want returned through a public API, etc.- Specified by:
streamin interfaceMarkLogicOperations- Returns:
- An input stream of all the documents that matched the specified parameters.
-
stream
public <T> InputStream stream(com.marklogic.client.query.StructuredQueryDefinition query, org.springframework.data.domain.Pageable pageable, Class<T> entityClass)
Description copied from interface:MarkLogicOperationsSame as method taking int bounds, but allows use of Pagable for paging/sorting.- Specified by:
streamin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.stream(StructuredQueryDefinition, long, int, Class)
-
exists
public boolean exists(String uri)
Description copied from interface:MarkLogicOperationsCheck for existence of a document by using the full URI under which the document is stored.- Specified by:
existsin interfaceMarkLogicOperations- Parameters:
uri- The full URI of the document, i.e. "/Person/my-id.json"- Returns:
- True if a document with the specified URI exists.
-
exists
public <T> boolean exists(Object id, Class<T> entityClass)
Description copied from interface:MarkLogicOperationsCheck for existence of an entity in the database by using it's ID.- Specified by:
existsin interfaceMarkLogicOperations- Type Parameters:
T- The type of an entity.- Parameters:
id- The ID value of an entity.entityClass- The type class of an entity.- Returns:
- True if an entity with the specified ID exists.
-
exists
public <T> boolean exists(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)Description copied from interface:MarkLogicOperationsCheck for existence of entities matching the specified structured query. This will not show which ones match, but is a way to do a quick estimate on whether or not any exist in the first place.- Specified by:
existsin interfaceMarkLogicOperations- Type Parameters:
T- The type of an entity.- Parameters:
query- The structured query to use to match documents in the database.entityClass- The type class of an entity.- Returns:
- True if there are any entities that match the query.
-
count
public long count(String... collections)
Description copied from interface:MarkLogicOperationsCount the number of documents that exist in the database under the specified collections.- Specified by:
countin interfaceMarkLogicOperations- Parameters:
collections- Collection URIs to which to scope the count.- Returns:
- The number of documents contained under the specified collections.
-
count
public <T> long count(Class<T> entityClass)
Description copied from interface:MarkLogicOperationsCount the number of the specified entity that exist in the database.- Specified by:
countin interfaceMarkLogicOperations- Type Parameters:
T- The type of an entity.- Parameters:
entityClass- The type class of an entity.- Returns:
- The number of the specified entity contained in the database.
-
count
public long count(com.marklogic.client.query.StructuredQueryDefinition query)
Description copied from interface:MarkLogicOperationsGives a count of the number of documents that would match the specified query.- Specified by:
countin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.count(StructuredQueryDefinition, Class)
-
count
public <T> long count(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)Description copied from interface:MarkLogicOperationsCount the number of entities that would match the specified query.- Specified by:
countin interfaceMarkLogicOperations- Type Parameters:
T- The type of an entity.- Parameters:
query- The structured query to use to match documents in the database.entityClass- The type class of an entity.- Returns:
- The count of entities that are in the database.
-
deleteByUri
public void deleteByUri(String... uris)
Description copied from interface:MarkLogicOperationsDelete a document from the database that is stored under the specified uris- Specified by:
deleteByUriin interfaceMarkLogicOperations- Parameters:
uris- The uris to delete, i.e. "/Person/my-id.json"
-
deleteByUris
public void deleteByUris(List<String> uris)
Description copied from interface:MarkLogicOperationsDelete a set of documents from the database that are stored under one of the specified URIs- Specified by:
deleteByUrisin interfaceMarkLogicOperations- Parameters:
uris- A list of uris to delete.
-
deleteById
public <T> void deleteById(Object id, Class<T> entityClass)
Description copied from interface:MarkLogicOperationsDeletes the entity with the specified ID.- Specified by:
deleteByIdin interfaceMarkLogicOperations- See Also:
MarkLogicOperations.deleteByIds(List, Class)
-
delete
public <T> void delete(List<T> entities)
Description copied from interface:MarkLogicOperationsDelete the specified entities from the database.- Specified by:
deletein interfaceMarkLogicOperations- Type Parameters:
T- The type of an entity.- Parameters:
entities- A list of entities.
-
delete
public <T> void delete(com.marklogic.client.query.StructuredQueryDefinition query, Class<T> entityClass)Description copied from interface:MarkLogicOperationsDelete entities of the specified type that match the specified query.- Specified by:
deletein interfaceMarkLogicOperations- Type Parameters:
T- The type of an entity.- Parameters:
query- The structured query to use to match documents in the database.entityClass- The type class of an entity.
-
deleteByIds
public <T> void deleteByIds(List<?> ids, Class<T> entityClass)
Description copied from interface:MarkLogicOperationsDeletes the entities which have one of the specified IDs.- Specified by:
deleteByIdsin interfaceMarkLogicOperations- Type Parameters:
T- The type of an entity.- Parameters:
ids- A list of entity IDs.entityClass- The type class of an entity.
-
dropCollections
public void dropCollections(String... collections)
Description copied from interface:MarkLogicOperationsDelete documents that are under the specified collection URIs.- Specified by:
dropCollectionsin interfaceMarkLogicOperations- Parameters:
collections- Collection URIs containing documents to delete.
-
dropCollection
public <T> void dropCollection(Class<T> entityClass)
Description copied from interface:MarkLogicOperationsDeletes all the entities of the specified type.- Specified by:
dropCollectionin interfaceMarkLogicOperations- Type Parameters:
T- The type of an entity.- Parameters:
entityClass- The type class of an entity.
-
dropCollections
public <T> void dropCollections(Class<T>... entityClasses)
Description copied from interface:MarkLogicOperationsDeletes all the entities of the specified types.- Specified by:
dropCollectionsin interfaceMarkLogicOperations- Type Parameters:
T- The type of an entity.- Parameters:
entityClasses- The type classes of entities.
-
getConverter
public MarkLogicConverter getConverter()
Description copied from interface:MarkLogicOperationsGet the entity converter that is used to convert Java POJOs into a form with which they can be stored in the database.- Specified by:
getConverterin interfaceMarkLogicOperations- Returns:
- The converter object.
-
getQueryMapper
public QueryMapper getQueryMapper()
Description copied from interface:MarkLogicOperationsThe query mapper is responsible for interpreting entity/query annotations and applying the information to a query before it is executed in MarkLogicTemplate. It also handles converting Query By Example objects into a MarkLogic query. The query mapper can be used when it is necessary to use the "execute" methods but you still want to take advantage of the annotations and other logic that is part of this framework.- Specified by:
getQueryMapperin interfaceMarkLogicOperations
-
getQueryConversionService
public QueryConversionService getQueryConversionService()
Description copied from interface:MarkLogicOperationsGet the query object convert service that is used to convert various Java types into their "correct" form for querying in MarkLogic.- Specified by:
getQueryConversionServicein interfaceMarkLogicOperations- Returns:
- The service object.
-
toEntityList
protected <T> List<T> toEntityList(Class<T> entityClass, com.marklogic.client.document.DocumentPage page)
-
toRecordList
protected List<com.marklogic.client.document.DocumentRecord> toRecordList(com.marklogic.client.document.DocumentPage page)
-
-