public class DocumentSearch extends Object
operations
that search documents.
This is the entry point for searching documents. DocumentSearch provides a DSL for querying documents in a Saperion
system.
To use this one will need a working classic connector
first.
It is expected to be already logged in:
SaClassicConnector connector = new SaClassicConnector();
connector.logon("name", "password", type, "tenant");
DocumentSearch.newInstance(connector)
After that one has to specify the document definition (ddc) to search in. This is done with
in(String)
:
DocumentSearch.newInstance(connector).in("ddc_name")
Now it is possible to execute a search for every document in the given ddc with DocumentSearch.QueryBuilder.all()
:
List<DocumentRevisionId> allDocuments = DocumentSearch.newInstance(connector).in("ddc_name").all();
This will execute the search and return the ids
of every document in the given ddc.
Alternatively one may specify a condition that every returned document must meet:
DocumentSearch.newInstance(connector).in("ddc_name").where().field("field", String.class).equalTo().
value("value").holds()
Several conditions may be connected with "and" and "or":
DocumentSearch.newInstance(connector).in("ddc_name").where().field("field", String.class).equalTo().
value("value").and().field("int_field", Integer.class).equalTo().value(77).or().not().
comparable().field("float_field", Double.class).lessThan().value(5.6666).holds()
Whatever the conditions, they are finished with BooleanOperationBuilder.holds()
and after that one can
decide to list all documents that satisfy the conditions:
List<DocumentRevisionId> allDocuments = DocumentSearch.newInstance(connector).in("ddc_name").where().
field("field", String.class).equalTo().value("value").holds().list();
This will execute the search and return a list containing the id
of every document in
the given definition that meets the given condition.
Alternatively one can indicate that the given conditions should be satisfied by one and only one document:
DocumentSearch.newInstance(connector).in("ddc_name").where().field("field", String.class).equalTo().
value("value").holds().uniqueResult()
In that case it is necessary to determine whether the document should be loaded completely or without content,
since the corresponding calls will return the document instead of its id (like the calls above):
DocumentRevision document = DocumentSearch.newInstance(connector).in("ddc_name").where().
field("field", String.class).equalTo().value("value").holds().uniqueResult().complete();
DocumentRevision document = DocumentSearch.newInstance(connector).in("ddc_name").where().
field("field", String.class).equalTo().value("value").holds().uniqueResult().withoutContent();
Modifier and Type | Class and Description |
---|---|
static interface |
DocumentSearch.LoadDecision
Decides whether a document should be loaded with or without content.
|
static interface |
DocumentSearch.QueryBuilder
Decides search condition.
|
static interface |
DocumentSearch.ResultDecision
Decides the quantity kind of result and executes the search.
|
Modifier and Type | Method and Description |
---|---|
DocumentSearch.QueryBuilder |
in(String definitionName)
Defines the definition to search in.
|
static DocumentSearch |
newInstance(com.lexmark.saperion.remote.common.Connection connection)
Initiates a new search on a given connection.
|
public static DocumentSearch newInstance(com.lexmark.saperion.remote.common.Connection connection)
connection
- a valid connection to a Saperion systempublic DocumentSearch.QueryBuilder in(String definitionName)
definitionName
- The name of the definition to search in.DocumentSearch.QueryBuilder
to decide the search conditionCopyright © 2020 Hyland Software Germany GmbH. All rights reserved.