From 7032b1d1396adaa3e9b4ff3322eaadd9cb97a8b1 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Wed, 30 Aug 2023 00:09:53 +1200 Subject: [PATCH] [15x] Remove ElasticSearch support --- .../src/main/java/io/ebean/Database.java | 5 - .../java/io/ebean/DocStoreQueueEntry.java | 94 ----- .../src/main/java/io/ebean/DocumentStore.java | 312 -------------- .../main/java/io/ebean/ExpressionFactory.java | 27 -- .../main/java/io/ebean/ExpressionList.java | 99 ----- ebean-api/src/main/java/io/ebean/Query.java | 66 --- .../src/main/java/io/ebean/Transaction.java | 25 -- .../java/io/ebean/config/DatabaseConfig.java | 51 --- .../java/io/ebean/config/DocStoreConfig.java | 320 -------------- .../java/io/ebean/docstore/DocMapping.java | 7 - .../io/ebean/docstore/DocQueryContext.java | 7 - .../io/ebean/docstore/DocUpdateContext.java | 7 - .../main/java/io/ebean/docstore/RawDoc.java | 102 ----- .../java/io/ebean/plugin/BeanDocType.java | 72 ---- .../main/java/io/ebean/plugin/BeanType.java | 25 -- .../main/java/io/ebean/plugin/SpiServer.java | 5 - .../java/io/ebean/search/AbstractMatch.java | 98 ----- .../src/main/java/io/ebean/search/Match.java | 117 ----- .../main/java/io/ebean/search/MultiMatch.java | 148 ------- .../java/io/ebean/search/TextCommonTerms.java | 139 ------ .../java/io/ebean/search/TextQueryString.java | 398 ------------------ .../main/java/io/ebean/search/TextSimple.java | 193 --------- .../java/io/ebean/search/package-info.java | 4 - ebean-api/src/main/java/module-info.java | 2 - ebean-core/pom.xml | 19 - .../io/ebeaninternal/api/LoadManyBuffer.java | 1 - .../io/ebeaninternal/api/LoadManyRequest.java | 2 +- .../io/ebeaninternal/api/SpiEbeanServer.java | 5 - .../io/ebeaninternal/api/SpiExpression.java | 13 - .../ebeaninternal/api/SpiExpressionList.java | 6 - .../io/ebeaninternal/api/SpiJunction.java | 7 - .../java/io/ebeaninternal/api/SpiQuery.java | 21 - .../io/ebeaninternal/api/SpiTransaction.java | 19 - .../api/SpiTransactionProxy.java | 28 -- .../ebeaninternal/api/TransactionEvent.java | 13 - .../server/core/DefaultContainer.java | 16 +- .../server/core/DefaultServer.java | 46 +- .../server/core/InternalConfiguration.java | 31 +- .../server/core/OrmQueryRequest.java | 23 - .../server/core/PersistRequestBean.java | 122 +----- .../server/core/SpiOrmQueryRequest.java | 8 +- .../server/deploy/BeanDescriptor.java | 120 ------ .../server/deploy/BeanDescriptorManager.java | 17 - .../server/deploy/BeanDescriptorMap.java | 6 - .../server/deploy/BeanProperty.java | 34 -- .../server/deploy/BeanPropertyAssoc.java | 59 --- .../server/deploy/BeanPropertyAssocMany.java | 18 +- .../deploy/DeployDocPropertyOptions.java | 78 ---- .../deploy/meta/DeployBeanDescriptor.java | 90 ---- .../deploy/meta/DeployBeanProperty.java | 19 - .../deploy/meta/DeployBeanPropertyAssoc.java | 12 - .../deploy/parse/AnnotationAssocOnes.java | 3 - .../server/deploy/parse/AnnotationClass.java | 1 - .../server/deploy/parse/AnnotationFields.java | 29 +- .../server/expression/AbstractExpression.java | 16 - .../expression/AllEqualsExpression.java | 10 - .../expression/ArrayContainsExpression.java | 17 - .../expression/ArrayIsEmptyExpression.java | 7 - .../server/expression/BetweenExpression.java | 7 - .../expression/BetweenPropertyExpression.java | 21 - .../server/expression/BitwiseExpression.java | 5 - .../CaseInsensitiveEqualExpression.java | 11 - .../expression/DefaultExampleExpression.java | 17 - .../expression/DefaultExpressionFactory.java | 26 -- .../expression/DefaultExpressionList.java | 214 ---------- .../server/expression/DocQueryContext.java | 177 -------- .../expression/ExistsQueryExpression.java | 10 - .../expression/ExistsSqlQueryExpression.java | 10 - .../server/expression/IdExpression.java | 12 - .../server/expression/IdInExpression.java | 11 - .../server/expression/InExpression.java | 8 - .../server/expression/InPairsExpression.java | 5 - .../server/expression/InRangeExpression.java | 7 - .../server/expression/InTuplesExpression.java | 5 - .../server/expression/IsEmptyExpression.java | 28 -- .../server/expression/JsonPathExpression.java | 11 - .../server/expression/JunctionExpression.java | 91 ---- .../server/expression/LikeExpression.java | 7 - .../server/expression/LogicExpression.java | 32 -- .../expression/NativeILikeExpression.java | 7 - .../NestedPathWrapperExpression.java | 110 ----- .../server/expression/NoopExpression.java | 9 - .../server/expression/NotExpression.java | 14 - .../server/expression/NullExpression.java | 8 - .../server/expression/PrepareDocNested.java | 159 ------- .../server/expression/RawExpression.java | 11 - .../server/expression/SimpleExpression.java | 21 - .../server/expression/SubQueryExpression.java | 5 - .../expression/SubQueryRawExpression.java | 5 - .../expression/TextCommonTermsExpression.java | 26 -- .../expression/TextMatchExpression.java | 26 -- .../expression/TextMultiMatchExpression.java | 26 -- .../expression/TextQueryStringExpression.java | 26 -- .../expression/TextSimpleExpression.java | 26 -- .../server/loadcontext/DLoadBeanContext.java | 2 +- .../server/loadcontext/DLoadContext.java | 8 +- .../server/loadcontext/DLoadManyContext.java | 9 +- .../persist/dml/DmlBeanPersisterFactory.java | 2 +- .../persist/dml/DocStoreBeanPersister.java | 37 -- .../server/query/DefaultFetchGroupQuery.java | 15 - .../server/querydefn/DefaultOrmQuery.java | 59 +-- .../server/transaction/DeleteByIdMap.java | 27 -- .../transaction/DocStoreOnlyTransaction.java | 54 --- .../DocStoreTransactionManager.java | 35 -- .../ImplicitReadOnlyTransaction.java | 26 -- .../server/transaction/JdbcTransaction.java | 38 -- .../server/transaction/NoTransaction.java | 26 -- .../transaction/PostCommitProcessing.java | 35 -- .../transaction/TransactionManager.java | 23 - .../TransactionManagerOptions.java | 5 +- .../docstore/api/DocQueryRequest.java | 38 -- .../docstore/api/DocStoreBeanAdapter.java | 128 ------ .../docstore/api/DocStoreFactory.java | 22 - .../docstore/api/DocStoreIntegration.java | 20 - .../docstore/api/DocStoreQueryUpdate.java | 23 - .../docstore/api/DocStoreTransaction.java | 29 -- .../docstore/api/DocStoreUpdate.java | 19 - .../docstore/api/DocStoreUpdateContext.java | 13 - .../docstore/api/DocStoreUpdateProcessor.java | 46 -- .../docstore/api/DocStoreUpdates.java | 115 ----- .../api/DocumentNotFoundException.java | 17 - .../api/mapping/DocMappingBuilder.java | 129 ------ .../api/mapping/DocPropertyAdapter.java | 47 --- .../api/mapping/DocPropertyMapping.java | 128 ------ .../api/mapping/DocPropertyOptions.java | 247 ----------- .../api/mapping/DocPropertyVisitor.java | 43 -- .../docstore/api/mapping/DocumentMapping.java | 98 ----- .../docstore/api/mapping/package-info.java | 4 - .../docstore/api/package-info.java | 4 - .../api/support/DocStoreBeanBaseAdapter.java | 333 --------------- .../api/support/DocStoreDeleteEvent.java | 38 -- .../support/DocStoreEmbeddedInvalidation.java | 22 - ...ocStoreEmbeddedInvalidationProperties.java | 30 -- .../api/support/DocStoreIndexEvent.java | 40 -- .../docstore/api/support/DocStructure.java | 94 ----- .../docstore/api/support/package-info.java | 4 - .../docstore/none/NoneDocStore.java | 111 ----- .../none/NoneDocStoreBeanAdapter.java | 50 --- .../docstore/none/NoneDocStoreFactory.java | 39 -- .../none/NoneDocStoreUpdateProcessor.java | 35 -- .../docstore/none/package-info.java | 8 - ebean-core/src/main/java/module-info.java | 5 - .../server/deploy/BeanDescriptorTest.java | 2 - .../BeanDescriptor_documentMappingTest.java | 84 ---- .../expression/LogicExpressionTest.java | 49 --- .../expression/PrepareDocNestedTest.java | 148 ------- .../server/querydefn/OrmQueryPlanKeyTest.java | 8 - .../java/io/ebean/typequery/PBaseString.java | 12 - .../main/java/io/ebean/typequery/PString.java | 12 - .../java/io/ebean/typequery/TQRootBean.java | 202 +-------- .../xtest/base/TextExpressionListTest.java | 81 ---- .../xtest/config/DocStoreConfigTest.java | 76 ---- .../docstore/DocStoreBeanBaseAdapterTest.java | 70 --- .../docstore/DocStoreDeleteEventTest.java | 63 --- .../docstore/DocStoreIndexEventTest.java | 67 --- .../xtest/internal/api/TDSpiEbeanServer.java | 10 - .../ebean/xtest/internal/api/TDSpiServer.java | 10 - .../io/ebean/xtest/plugin/BeanTypeTest.java | 93 ---- .../query/other/TestManyLazyLoadingQuery.java | 2 +- 159 files changed, 34 insertions(+), 7768 deletions(-) delete mode 100644 ebean-api/src/main/java/io/ebean/DocStoreQueueEntry.java delete mode 100644 ebean-api/src/main/java/io/ebean/DocumentStore.java delete mode 100644 ebean-api/src/main/java/io/ebean/config/DocStoreConfig.java delete mode 100644 ebean-api/src/main/java/io/ebean/docstore/DocMapping.java delete mode 100644 ebean-api/src/main/java/io/ebean/docstore/DocQueryContext.java delete mode 100644 ebean-api/src/main/java/io/ebean/docstore/DocUpdateContext.java delete mode 100644 ebean-api/src/main/java/io/ebean/docstore/RawDoc.java delete mode 100644 ebean-api/src/main/java/io/ebean/plugin/BeanDocType.java delete mode 100644 ebean-api/src/main/java/io/ebean/search/AbstractMatch.java delete mode 100644 ebean-api/src/main/java/io/ebean/search/Match.java delete mode 100644 ebean-api/src/main/java/io/ebean/search/MultiMatch.java delete mode 100644 ebean-api/src/main/java/io/ebean/search/TextCommonTerms.java delete mode 100644 ebean-api/src/main/java/io/ebean/search/TextQueryString.java delete mode 100644 ebean-api/src/main/java/io/ebean/search/TextSimple.java delete mode 100644 ebean-api/src/main/java/io/ebean/search/package-info.java delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/deploy/DeployDocPropertyOptions.java delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/expression/DocQueryContext.java delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/expression/NestedPathWrapperExpression.java delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/expression/PrepareDocNested.java delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/expression/TextCommonTermsExpression.java delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/expression/TextMatchExpression.java delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/expression/TextMultiMatchExpression.java delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/expression/TextQueryStringExpression.java delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/expression/TextSimpleExpression.java delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/persist/dml/DocStoreBeanPersister.java delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/transaction/DocStoreOnlyTransaction.java delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/transaction/DocStoreTransactionManager.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/DocQueryRequest.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreBeanAdapter.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreFactory.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreIntegration.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreQueryUpdate.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreTransaction.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdate.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdateContext.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdateProcessor.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdates.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/DocumentNotFoundException.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocMappingBuilder.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyAdapter.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyMapping.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyOptions.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyVisitor.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocumentMapping.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/package-info.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/package-info.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreDeleteEvent.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreEmbeddedInvalidation.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreEmbeddedInvalidationProperties.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreIndexEvent.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStructure.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/api/support/package-info.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStore.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStoreBeanAdapter.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStoreFactory.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStoreUpdateProcessor.java delete mode 100644 ebean-core/src/main/java/io/ebeanservice/docstore/none/package-info.java delete mode 100644 ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptor_documentMappingTest.java delete mode 100644 ebean-core/src/test/java/io/ebeaninternal/server/expression/PrepareDocNestedTest.java delete mode 100644 ebean-test/src/test/java/io/ebean/xtest/base/TextExpressionListTest.java delete mode 100644 ebean-test/src/test/java/io/ebean/xtest/config/DocStoreConfigTest.java delete mode 100644 ebean-test/src/test/java/io/ebean/xtest/docstore/DocStoreBeanBaseAdapterTest.java delete mode 100644 ebean-test/src/test/java/io/ebean/xtest/docstore/DocStoreDeleteEventTest.java delete mode 100644 ebean-test/src/test/java/io/ebean/xtest/docstore/DocStoreIndexEventTest.java diff --git a/ebean-api/src/main/java/io/ebean/Database.java b/ebean-api/src/main/java/io/ebean/Database.java index 5f84af1671..1c9e8a7476 100644 --- a/ebean-api/src/main/java/io/ebean/Database.java +++ b/ebean-api/src/main/java/io/ebean/Database.java @@ -1321,11 +1321,6 @@ public interface Database { */ ScriptRunner script(); - /** - * Return the Document store. - */ - DocumentStore docStore(); - /** * Returns the set of properties/paths that are unknown (do not map to known properties or paths). *

diff --git a/ebean-api/src/main/java/io/ebean/DocStoreQueueEntry.java b/ebean-api/src/main/java/io/ebean/DocStoreQueueEntry.java deleted file mode 100644 index 9d631ce19e..0000000000 --- a/ebean-api/src/main/java/io/ebean/DocStoreQueueEntry.java +++ /dev/null @@ -1,94 +0,0 @@ -package io.ebean; - -/** - * Bean holding the details to update the document store. - */ -public final class DocStoreQueueEntry { - - /** - * Action to either update or delete a document from the index. - */ - public enum Action { - - /** - * Action is to update a document in the doc store. - */ - INDEX(1), - - /** - * Action is to delete a document from the doc store.. - */ - DELETE(2), - - /** - * An update is required based on a change to a nested/embedded object at a given path. - */ - NESTED(3); - - int value; - - Action(int value) { - this.value = value; - } - - /** - * Return the value associated with this action type. - */ - public int getValue() { - return value; - } - } - - private final Action type; - - private final String queueId; - - private final String path; - - private final Object beanId; - - /** - * Construct for an INDEX or DELETE action. - */ - public DocStoreQueueEntry(Action type, String queueId, Object beanId) { - this(type, queueId, null, beanId); - } - - /** - * Construct for an NESTED/embedded path invalidation action. - */ - public DocStoreQueueEntry(Action type, String queueId, String path, Object beanId) { - this.type = type; - this.queueId = queueId; - this.path = path; - this.beanId = beanId; - } - - /** - * Return the event type. - */ - public Action getType() { - return type; - } - - /** - * Return the associate queueId. - */ - public String getQueueId() { - return queueId; - } - - /** - * Return the path if this is a nested update. - */ - public String getPath() { - return path; - } - - /** - * Return the bean id (which matches the document id). - */ - public Object getBeanId() { - return beanId; - } -} diff --git a/ebean-api/src/main/java/io/ebean/DocumentStore.java b/ebean-api/src/main/java/io/ebean/DocumentStore.java deleted file mode 100644 index 7b5a6c481c..0000000000 --- a/ebean-api/src/main/java/io/ebean/DocumentStore.java +++ /dev/null @@ -1,312 +0,0 @@ -package io.ebean; - -import io.avaje.lang.NonNullApi; -import io.avaje.lang.Nullable; -import io.ebean.docstore.DocQueryContext; -import io.ebean.docstore.RawDoc; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; -import java.util.function.Predicate; - -/** - * Document storage operations. - */ -@NonNullApi -public interface DocumentStore { - - /** - * Update the associated document store using the result of the query. - *

- * This will execute the query against the database creating a document for each - * bean graph and sending this to the document store. - *

- *

- * Note that the select and fetch paths of the query is set for you to match the - * document structure needed based on @DocStore and @DocStoreEmbedded - * so what this query requires is the predicates only. - *

- *

- * This query will be executed using findEach so it is safe to use a query - * that will fetch a lot of beans. The default bulkBatchSize is used. - *

- * - * @param query The query that selects object to send to the document store. - */ - void indexByQuery(Query query); - - /** - * Update the associated document store index using the result of the query additionally specifying a - * bulkBatchSize to use for sending the messages to ElasticSearch. - * - * @param query The query that selects object to send to the document store. - * @param bulkBatchSize The batch size to use when bulk sending to the document store. - */ - void indexByQuery(Query query, int bulkBatchSize); - - /** - * Update the document store for all beans of this type. - *

- * This is the same as indexByQuery where the query has no predicates and so fetches all rows. - *

- */ - void indexAll(Class beanType); - - /** - * Return the bean by fetching it's content from the document store. - * If the document is not found null is returned. - *

- * Typically this is called indirectly by findOne() on the query. - *

- *
{@code
-   *
-   * Customer customer =
-   *   database.find(Customer.class)
-   *     .setUseDocStore(true)
-   *     .setId(42)
-   *     .findOne();
-   *
-   * }
- */ - @Nullable - T find(DocQueryContext request); - - /** - * Execute the find list query. This request is prepared to execute secondary queries. - *

- * Typically this is called indirectly by findList() on the query that has setUseDocStore(true). - *

- *
{@code
-   *
-   * List newCustomers =
-   *  database.find(Customer.class)
-   *    .setUseDocStore(true)
-   *    .where().eq("status, Customer.Status.NEW)
-   *    .findList();
-   *
-   * }
- */ - List findList(DocQueryContext request); - - /** - * Execute the query against the document store returning the paged list. - *

- * The query should have firstRow or maxRows set prior to calling this method. - *

- *

- * Typically this is called indirectly by findPagedList() on the query that has setUseDocStore(true). - *

- *
{@code
-   *
-   * PagedList newCustomers =
-   *  database.find(Customer.class)
-   *    .setUseDocStore(true)
-   *    .where().eq("status, Customer.Status.NEW)
-   *    .setMaxRows(50)
-   *    .findPagedList();
-   *
-   * }
- */ - PagedList findPagedList(DocQueryContext request); - - /** - * Execute the query against the document store with the expectation of a large set of results - * that are processed in a scrolling resultSet fashion. - *

- * For example, with the ElasticSearch doc store this uses SCROLL. - *

- *

- * Typically this is called indirectly by findEach() on the query that has setUseDocStore(true). - *

- *
{@code
-   *
-   *  database.find(Order.class)
-   *    .setUseDocStore(true)
-   *    .where()... // perhaps add predicates
-   *    .findEach((Order order) -> {
-   *      // process the bean ...
-   *    });
-   *
-   * }
- */ - void findEach(DocQueryContext query, Consumer consumer); - - /** - * Execute the query against the document store with the expectation of a large set of results - * that are processed in a scrolling resultSet fashion. - *

- * Unlike findEach() this provides the opportunity to stop iterating through the large query. - *

- *

- * For example, with the ElasticSearch doc store this uses SCROLL. - *

- *

- * Typically this is called indirectly by findEachWhile() on the query that has setUseDocStore(true). - *

- *
{@code
-   *
-   *  database.find(Order.class)
-   *    .setUseDocStore(true)
-   *    .where()... // perhaps add predicates
-   *    .findEachWhile(new Predicate() {
-   *      @Override
-   *      public void accept(Order bean) {
-   *        // process the bean
-   *
-   *        // return true to continue, false to stop
-   *        // boolean shouldContinue = ...
-   *        return shouldContinue;
-   *      }
-   *    });
-   *
-   * }
- */ - void findEachWhile(DocQueryContext query, Predicate consumer); - - /** - * Find each processing raw documents. - * - * @param indexNameType The full index name and type - * @param rawQuery The query to execute - * @param consumer Consumer to process each document - */ - void findEach(String indexNameType, String rawQuery, Consumer consumer); - - /** - * Find each processing raw documents stopping when the predicate returns false. - * - * @param indexNameType The full index name and type - * @param rawQuery The query to execute - * @param consumer Consumer to process each document until false is returned - */ - void findEachWhile(String indexNameType, String rawQuery, Predicate consumer); - - /** - * Process the queue entries sending updates to the document store or queuing them for later processing. - */ - long process(List queueEntries) throws IOException; - - /** - * Drop the index from the document store (similar to DDL drop table). - *
{@code
-   *
-   *   DocumentStore documentStore = database.docStore();
-   *
-   *   documentStore.dropIndex("product_copy");
-   *
-   * }
- */ - void dropIndex(String indexName); - - /** - * Create an index given a mapping file as a resource in the classPath (similar to DDL create table). - *
{@code
-   *
-   *   DocumentStore documentStore = database.docStore();
-   *
-   *   // uses product_copy.mapping.json resource
-   *   // ... to define mappings for the index
-   *
-   *   documentStore.createIndex("product_copy", null);
-   *
-   * }
- * - * @param indexName the name of the new index - * @param alias the alias of the index - */ - void createIndex(String indexName, String alias); - - /** - * Modify the settings on an index. - *

- * For example, this can be used be used to set elasticSearch refresh_interval - * on an index before a bulk update. - *

- *
{@code
-   *
-   *   // refresh_interval -1 ... disable refresh while bulk loading
-   *
-   *   Map settings = new LinkedHashMap<>();
-   *   settings.put("refresh_interval", "-1");
-   *
-   *   documentStore.indexSettings("product", settings);
-   *
-   * }
- *
{@code
-   *
-   *   // refresh_interval 1s ... restore after bulk loading
-   *
-   *   Map settings = new LinkedHashMap<>();
-   *   settings.put("refresh_interval", "1s");
-   *
-   *   documentStore.indexSettings("product", settings);
-   *
-   * }
- * - * @param indexName the name of the index to update settings on - * @param settings the settings to set on the index - */ - void indexSettings(String indexName, Map settings); - - /** - * Copy the index to a new index. - *

- * This copy process does not use the database but instead will copy from the source index to a destination index. - *

- *
{@code
-   *
-   *  long copyCount = documentStore.copyIndex(Product.class, "product_copy");
-   *
-   * }
- * - * @param beanType The bean type of the source index - * @param newIndex The name of the index to copy to - * @return the number of documents copied to the new index - */ - long copyIndex(Class beanType, String newIndex); - - /** - * Copy entries from an index to a new index but limiting to documents that have been - * modified since the sinceEpochMillis time. - *

- * To support this the document needs to have a @WhenModified property. - *

- *
{@code
-   *
-   *  long copyCount = documentStore.copyIndex(Product.class, "product_copy", sinceMillis);
-   *
-   * }
- * - * @param beanType The bean type of the source index - * @param newIndex The name of the index to copy to - * @return the number of documents copied to the new index - */ - long copyIndex(Class beanType, String newIndex, long sinceEpochMillis); - - /** - * Copy from a source index to a new index taking only the documents - * matching the given query. - *
{@code
-   *
-   *  // predicates to select the source documents to copy
-   *  Query query = database.find(Product.class)
-   *    .where()
-   *      .ge("whenModified", new Timestamp(since))
-   *      .ge("name", "A")
-   *      .lt("name", "D")
-   *      .query();
-   *
-   *  // copy from the source index to "product_copy" index
-   *  long copyCount = documentStore.copyIndex(query, "product_copy", 1000);
-   *
-   * }
- * - * @param query The query to select the source documents to copy - * @param newIndex The target index to copy the documents to - * @param bulkBatchSize The ElasticSearch bulk batch size, if 0 uses the default. - * @return The number of documents copied to the new index. - */ - long copyIndex(Query query, String newIndex, int bulkBatchSize); -} diff --git a/ebean-api/src/main/java/io/ebean/ExpressionFactory.java b/ebean-api/src/main/java/io/ebean/ExpressionFactory.java index dd30ec96e0..d8f39ad920 100644 --- a/ebean-api/src/main/java/io/ebean/ExpressionFactory.java +++ b/ebean-api/src/main/java/io/ebean/ExpressionFactory.java @@ -1,7 +1,5 @@ package io.ebean; -import io.ebean.search.*; - import java.util.Collection; import java.util.Map; @@ -625,31 +623,6 @@ public interface ExpressionFactory { */ Expression raw(String raw); - /** - * Create a Text Match expression (currently doc store/Elastic only). - */ - Expression textMatch(String propertyName, String search, Match options); - - /** - * Create a Text Multi match expression (currently doc store/Elastic only). - */ - Expression textMultiMatch(String query, MultiMatch options); - - /** - * Create a text simple query expression (currently doc store/Elastic only). - */ - Expression textSimple(String search, TextSimple options); - - /** - * Create a text query string expression (currently doc store/Elastic only). - */ - Expression textQueryString(String search, TextQueryString options); - - /** - * Create a text common terms expression (currently doc store/Elastic only). - */ - Expression textCommonTerms(String search, TextCommonTerms options); - /** * And - join two expressions with a logical and. */ diff --git a/ebean-api/src/main/java/io/ebean/ExpressionList.java b/ebean-api/src/main/java/io/ebean/ExpressionList.java index d5d4003ccb..9852b2a32b 100644 --- a/ebean-api/src/main/java/io/ebean/ExpressionList.java +++ b/ebean-api/src/main/java/io/ebean/ExpressionList.java @@ -2,7 +2,6 @@ import io.avaje.lang.NonNullApi; import io.avaje.lang.Nullable; -import io.ebean.search.*; import javax.persistence.NonUniqueResultException; import java.sql.Connection; @@ -553,19 +552,6 @@ default A findSingleAttribute() { */ Query setDistinct(boolean distinct); - /** - * Set the index(es) to search for a document store which uses partitions. - *

- * For example, when executing a query against ElasticSearch with daily indexes we can - * explicitly specify the indexes to search against. - *

- * - * @param indexName The index or indexes to search against - * @return This query - * @see Query#setDocIndexName(String) - */ - Query setDocIndexName(String indexName); - /** * Set the first row to fetch. * @@ -649,14 +635,6 @@ default Query setUseQueryCache(boolean enabled) { return setUseQueryCache(enabled ? CacheMode.ON : CacheMode.OFF); } - /** - * Set to true if this query should execute against the doc store. - *

- * When setting this you may also consider disabling lazy loading. - *

- */ - Query setUseDocStore(boolean useDocsStore); - /** * Set true if you want to disable lazy loading. *

@@ -1578,47 +1556,6 @@ default ExpressionList isIn(String propertyName, Collection values) { */ ExpressionList rawOrEmpty(String raw, Collection values); - /** - * Add a match expression. - * - * @param propertyName The property name for the match - * @param search The search value - */ - ExpressionList match(String propertyName, String search); - - /** - * Add a match expression with options. - * - * @param propertyName The property name for the match - * @param search The search value - */ - ExpressionList match(String propertyName, String search, Match options); - - /** - * Add a multi-match expression. - */ - ExpressionList multiMatch(String search, String... properties); - - /** - * Add a multi-match expression using options. - */ - ExpressionList multiMatch(String search, MultiMatch options); - - /** - * Add a simple query string expression. - */ - ExpressionList textSimple(String search, TextSimple options); - - /** - * Add a query string expression. - */ - ExpressionList textQueryString(String search, TextQueryString options); - - /** - * Add common terms expression. - */ - ExpressionList textCommonTerms(String search, TextCommonTerms options); - /** * And - join two expressions with a logical and. */ @@ -1761,42 +1698,6 @@ default ExpressionList isIn(String propertyName, Collection values) { */ Junction disjunction(); - /** - * Start a list of expressions that will be joined by MUST. - *

- * This automatically makes the query a useDocStore(true) query that - * will execute against the document store (ElasticSearch etc). - *

- *

- * This is logically similar to and(). - *

- */ - Junction must(); - - /** - * Start a list of expressions that will be joined by SHOULD. - *

- * This automatically makes the query a useDocStore(true) query that - * will execute against the document store (ElasticSearch etc). - *

- *

- * This is logically similar to or(). - *

- */ - Junction should(); - - /** - * Start a list of expressions that will be joined by MUST NOT. - *

- * This automatically makes the query a useDocStore(true) query that - * will execute against the document store (ElasticSearch etc). - *

- *

- * This is logically similar to not(). - *

- */ - Junction mustNot(); - /** * End a junction returning the parent expression list. *

diff --git a/ebean-api/src/main/java/io/ebean/Query.java b/ebean-api/src/main/java/io/ebean/Query.java index 49f2b96003..514f83691d 100644 --- a/ebean-api/src/main/java/io/ebean/Query.java +++ b/ebean-api/src/main/java/io/ebean/Query.java @@ -316,43 +316,6 @@ enum LockWait { */ Query setPersistenceContextScope(PersistenceContextScope scope); - /** - * Set the index(es) to search for a document store which uses partitions. - *

- * For example, when executing a query against ElasticSearch with daily indexes we can - * explicitly specify the indexes to search against. - *

- *
{@code
-   *
-   *   // explicitly specify the indexes to search
-   *   query.setDocIndexName("logstash-2016.11.5,logstash-2016.11.6")
-   *
-   *   // search today's index
-   *   query.setDocIndexName("$today")
-   *
-   *   // search the last 3 days
-   *   query.setDocIndexName("$last-3")
-   *
-   * }
- *

- * If the indexName is specified with ${daily} e.g. "logstash-${daily}" ... then we can use - * $today and $last-x as the search docIndexName like the examples below. - *

- *
{@code
-   *
-   *   // search today's index
-   *   query.setDocIndexName("$today")
-   *
-   *   // search the last 3 days
-   *   query.setDocIndexName("$last-3")
-   *
-   * }
- * - * @param indexName The index or indexes to search against - * @return This query - */ - Query setDocIndexName(String indexName); - /** * Return the ExpressionFactory used by this query. */ @@ -1288,27 +1251,6 @@ enum LockWait { */ ExpressionList where(); - /** - * Add Full text search expressions for Document store queries. - *

- * This is currently ElasticSearch only and provides the full text - * expressions such as Match and Multi-Match. - *

- *

- * This automatically makes this query a "Doc Store" query and will execute - * against the document store (ElasticSearch). - *

- *

- * Expressions added here are added to the "query" section of an ElasticSearch - * query rather than the "filter" section. - *

- *

- * Expressions added to the where() are added to the "filter" section of an - * ElasticSearch query. - *

- */ - ExpressionList text(); - /** * This applies a filter on the 'many' property list rather than the root * level objects. @@ -1567,14 +1509,6 @@ default Query setUseQueryCache(boolean enabled) { */ Query setLabel(String label); - /** - * Set to true if this query should execute against the doc store. - *

- * When setting this you may also consider disabling lazy loading. - *

- */ - Query setUseDocStore(boolean useDocStore); - /** * When set to true when you want the returned beans to be read only. */ diff --git a/ebean-api/src/main/java/io/ebean/Transaction.java b/ebean-api/src/main/java/io/ebean/Transaction.java index 065396a925..e7777d09c4 100644 --- a/ebean-api/src/main/java/io/ebean/Transaction.java +++ b/ebean-api/src/main/java/io/ebean/Transaction.java @@ -1,9 +1,7 @@ package io.ebean; -import io.ebean.annotation.DocStoreMode; import io.ebean.annotation.PersistBatch; import io.ebean.config.DatabaseConfig; -import io.ebean.config.DocStoreConfig; import javax.persistence.PersistenceException; import java.sql.Connection; @@ -211,29 +209,6 @@ static Transaction current() { */ boolean isActive(); - /** - * Set the behavior for document store updates on this transaction. - *

- * For example, set the mode to DocStoreEvent.IGNORE for this transaction and - * then any changes via this transaction are not sent to the doc store. This - * would be used when doing large bulk inserts into the database and we want - * to control how that is sent to the document store. - *

- */ - void setDocStoreMode(DocStoreMode mode); - - /** - * Set the batch size to use for sending messages to the document store. - *

- * You might set this if you know the changes in this transaction result in especially large or - * especially small payloads and want to adjust the batch size to match. - *

- *

- * Setting this overrides the default of {@link DocStoreConfig#getBulkBatchSize()} - *

- */ - void setDocStoreBatchSize(int batchSize); - /** * Explicitly turn off or on the cascading nature of save() and delete(). This * gives the developer exact control over what beans are saved and deleted diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java index 0ab6ce115d..3fac20203b 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java @@ -132,16 +132,6 @@ public class DatabaseConfig { */ private List packages = new ArrayList<>(); - /** - * Configuration for the ElasticSearch integration. - */ - private DocStoreConfig docStoreConfig = new DocStoreConfig(); - - /** - * Set to true when the Database only uses Document store. - */ - private boolean docStoreOnly; - /** * This is used to populate @WhoCreated, @WhoModified and * support other audit features (who executed a query etc). @@ -1561,34 +1551,6 @@ private void adjustNamingConventionForAllQuoted() { } } - /** - * Return true if this Database is a Document store only instance (has no JDBC DB). - */ - public boolean isDocStoreOnly() { - return docStoreOnly; - } - - /** - * Set to true if this Database is Document store only instance (has no JDBC DB). - */ - public void setDocStoreOnly(boolean docStoreOnly) { - this.docStoreOnly = docStoreOnly; - } - - /** - * Return the configuration for the ElasticSearch integration. - */ - public DocStoreConfig getDocStoreConfig() { - return docStoreConfig; - } - - /** - * Set the configuration for the ElasticSearch integration. - */ - public void setDocStoreConfig(DocStoreConfig docStoreConfig) { - this.docStoreConfig = docStoreConfig; - } - /** * Return the constraint naming convention used in DDL generation. */ @@ -2771,13 +2733,6 @@ protected void loadDataSourceSettings(PropertiesWrapper p) { readOnlyDataSourceConfig.loadSettings(p.properties, name + "-ro"); } - /** - * This is broken out to allow overridden behaviour. - */ - protected void loadDocStoreSettings(PropertiesWrapper p) { - docStoreConfig.loadSettings(p); - } - /** * This is broken out to allow overridden behaviour. */ @@ -2809,11 +2764,6 @@ protected void loadSettings(PropertiesWrapper p) { } loadDataSourceSettings(p); - if (docStoreConfig == null) { - docStoreConfig = new DocStoreConfig(); - } - loadDocStoreSettings(p); - defaultServer = p.getBoolean("defaultServer", defaultServer); autoPersistUpdates = p.getBoolean("autoPersistUpdates", autoPersistUpdates); loadModuleInfo = p.getBoolean("loadModuleInfo", loadModuleInfo); @@ -2828,7 +2778,6 @@ protected void loadSettings(PropertiesWrapper p) { queryPlanCapturePeriodSecs = p.getLong("queryPlan.capturePeriodSecs", queryPlanCapturePeriodSecs); queryPlanCaptureMaxTimeMillis = p.getLong("queryPlan.captureMaxTimeMillis", queryPlanCaptureMaxTimeMillis); queryPlanCaptureMaxCount = p.getInt("queryPlan.captureMaxCount", queryPlanCaptureMaxCount); - docStoreOnly = p.getBoolean("docStoreOnly", docStoreOnly); disableL2Cache = p.getBoolean("disableL2Cache", disableL2Cache); localOnlyL2Cache = p.getBoolean("localOnlyL2Cache", localOnlyL2Cache); enabledL2Regions = p.get("enabledL2Regions", enabledL2Regions); diff --git a/ebean-api/src/main/java/io/ebean/config/DocStoreConfig.java b/ebean-api/src/main/java/io/ebean/config/DocStoreConfig.java deleted file mode 100644 index d83f677496..0000000000 --- a/ebean-api/src/main/java/io/ebean/config/DocStoreConfig.java +++ /dev/null @@ -1,320 +0,0 @@ -package io.ebean.config; - -import io.ebean.Transaction; -import io.ebean.annotation.DocStoreMode; - -/** - * Configuration for the Document store integration (e.g. ElasticSearch). - */ -public class DocStoreConfig { - - /** - * True when the Document store integration is active/on. - */ - protected boolean active; - - /** - * Set to true means Ebean will generate mapping files on startup. - */ - protected boolean generateMapping; - - /** - * When true the Document store should drop and re-create document indexes. - */ - protected boolean dropCreate; - - /** - * When true the Document store should create any document indexes that don't already exist. - */ - protected boolean create; - - /** - * The URL of the Document store. For example: http://localhost:9200. - */ - protected String url; - - /** - * Credential that be used for authentication to document store. - */ - protected String username; - - /** - * Password credential that be used for authentication to document store. - */ - protected String password; - - /** - * Set to true such that the client allows connections to invalid/self signed SSL certificates. - */ - protected boolean allowAllCertificates; - - /** - * The default mode used by indexes. - */ - protected DocStoreMode persist = DocStoreMode.UPDATE; - - /** - * The default batch size to use for the Bulk API calls. - */ - protected int bulkBatchSize = 1000; - - /** - * Resource path for the Document store mapping files. - */ - protected String mappingPath; - - /** - * Suffix used for mapping files. - */ - protected String mappingSuffix; - - /** - * Location of resources that mapping files are generated into. - */ - protected String pathToResources = "src/main/resources"; - - /** - * Return true if the Document store (ElasticSearch) integration is active. - */ - public boolean isActive() { - String systemValue = System.getProperty("ebean.docstore.active"); - if (systemValue != null) { - return Boolean.parseBoolean(systemValue); - } - return active; - } - - /** - * Set to true to make the Document store (ElasticSearch) integration active. - */ - public void setActive(boolean active) { - this.active = active; - } - - /** - * Return the URL to the Document store. - */ - public String getUrl() { - String systemValue = System.getProperty("ebean.docstore.url"); - if (systemValue != null) { - return systemValue; - } - return url; - } - - /** - * Return the user credential for connecting to the document store. - */ - public String getUsername() { - return username; - } - - /** - * Set the user credential for connecting to the document store. - */ - public void setUsername(String username) { - this.username = username; - } - - /** - * Return the password credential for connecting to the document store. - */ - public String getPassword() { - return password; - } - - /** - * Set the password credential for connecting to the document store. - */ - public void setPassword(String password) { - this.password = password; - } - - /** - * Set the URL to the Document store. - *

- * For a local ElasticSearch server this would be: http://localhost:9200 - */ - public void setUrl(String url) { - this.url = url; - } - - /** - * Return true if Ebean should generate mapping files on server startup. - */ - public boolean isGenerateMapping() { - String systemValue = System.getProperty("ebean.docstore.generateMapping"); - if (systemValue != null) { - return Boolean.parseBoolean(systemValue); - } - return generateMapping; - } - - /** - * Set to true if Ebean should generate mapping files on server startup. - */ - public void setGenerateMapping(boolean generateMapping) { - this.generateMapping = generateMapping; - } - - /** - * Return true if the document store should recreate mapped indexes. - */ - public boolean isDropCreate() { - String systemValue = System.getProperty("ebean.docstore.dropCreate"); - if (systemValue != null) { - return Boolean.parseBoolean(systemValue); - } - return dropCreate; - } - - /** - * Set to true if the document store should recreate mapped indexes. - */ - public void setDropCreate(boolean dropCreate) { - this.dropCreate = dropCreate; - } - - /** - * Create true if the document store should create mapped indexes that don't yet exist. - * This is only used if dropCreate is false. - */ - public boolean isCreate() { - String systemValue = System.getProperty("ebean.docstore.create"); - if (systemValue != null) { - return Boolean.parseBoolean(systemValue); - } - return create; - } - - /** - * Set to true if the document store should create mapped indexes that don't yet exist. - * This is only used if dropCreate is false. - */ - public void setCreate(boolean create) { - this.create = create; - } - - /** - * Return true if the client allows connections to invalid/self signed SSL certificates. - */ - public boolean isAllowAllCertificates() { - return allowAllCertificates; - } - - /** - * Set to true such that the client allows connections to invalid/self signed SSL certificates. - */ - public void setAllowAllCertificates(boolean allowAllCertificates) { - this.allowAllCertificates = allowAllCertificates; - } - - /** - * Return the default batch size to use for calls to the Bulk API. - */ - public int getBulkBatchSize() { - return bulkBatchSize; - } - - /** - * Set the default batch size to use for calls to the Bulk API. - *

- * The batch size can be set on a transaction via {@link Transaction#setDocStoreBatchSize(int)}. - *

- */ - public void setBulkBatchSize(int bulkBatchSize) { - this.bulkBatchSize = bulkBatchSize; - } - - /** - * Return the mapping path. - */ - public String getMappingPath() { - return mappingPath; - } - - /** - * Set the mapping path. - */ - public void setMappingPath(String mappingPath) { - this.mappingPath = mappingPath; - } - - /** - * Return the mapping suffix. - */ - public String getMappingSuffix() { - return mappingSuffix; - } - - /** - * Set the mapping suffix. - */ - public void setMappingSuffix(String mappingSuffix) { - this.mappingSuffix = mappingSuffix; - } - - /** - * Return the relative file system path to resources when generating mapping files. - */ - public String getPathToResources() { - return pathToResources; - } - - /** - * Set the relative file system path to resources when generating mapping files. - */ - public void setPathToResources(String pathToResources) { - this.pathToResources = pathToResources; - } - - /** - * Return the default behavior for when Insert, Update and Delete events occur on beans that have an associated - * Document store. - */ - public DocStoreMode getPersist() { - return persist; - } - - /** - * Set the default behavior for when Insert, Update and Delete events occur on beans that have an associated - * Document store. - *
    - *
  • DocStoreEvent.UPDATE - build and send message to Bulk API
  • - *
  • DocStoreEvent.QUEUE - add an entry with the index type and id only into a queue for later processing
  • - *
  • DocStoreEvent.IGNORE - ignore. Most likely used when some scheduled batch job handles updating the index
  • - *
- *

- * You might choose to use QUEUE if that particular index data is updating very frequently or the cost of indexing - * is expensive. Setting it to QUEUE can mean many changes can be batched together potentially coalescing multiple - * updates for an index entry into a single update. - *

- *

- * You might choose to use IGNORE when you have your own external process for updating the indexes. In this case - * you don't want Ebean to do anything when the data changes. - *

- */ - public void setPersist(DocStoreMode persist) { - this.persist = persist; - } - - /** - * Load settings specified in properties files. - */ - public void loadSettings(PropertiesWrapper properties) { - - active = properties.getBoolean("docstore.active", active); - url = properties.get("docstore.url", url); - username = properties.get("docstore.username", url); - password = properties.get("docstore.password", url); - persist = properties.getEnum(DocStoreMode.class, "docstore.persist", persist); - bulkBatchSize = properties.getInt("docstore.bulkBatchSize", bulkBatchSize); - generateMapping = properties.getBoolean("docstore.generateMapping", generateMapping); - dropCreate = properties.getBoolean("docstore.dropCreate", dropCreate); - create = properties.getBoolean("docstore.create", create); - allowAllCertificates = properties.getBoolean("docstore.allowAllCertificates", allowAllCertificates); - mappingPath = properties.get("docstore.mappingPath", mappingPath); - mappingSuffix = properties.get("docstore.mappingSuffix", mappingSuffix); - pathToResources = properties.get("docstore.pathToResources", pathToResources); - } -} diff --git a/ebean-api/src/main/java/io/ebean/docstore/DocMapping.java b/ebean-api/src/main/java/io/ebean/docstore/DocMapping.java deleted file mode 100644 index 9d8d4f3e08..0000000000 --- a/ebean-api/src/main/java/io/ebean/docstore/DocMapping.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.ebean.docstore; - -/** - * Document Mapping for a bean marker interface. - */ -public interface DocMapping { -} diff --git a/ebean-api/src/main/java/io/ebean/docstore/DocQueryContext.java b/ebean-api/src/main/java/io/ebean/docstore/DocQueryContext.java deleted file mode 100644 index 5e17189924..0000000000 --- a/ebean-api/src/main/java/io/ebean/docstore/DocQueryContext.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.ebean.docstore; - -/** - * Document query request context marker interface. - */ -public interface DocQueryContext { -} diff --git a/ebean-api/src/main/java/io/ebean/docstore/DocUpdateContext.java b/ebean-api/src/main/java/io/ebean/docstore/DocUpdateContext.java deleted file mode 100644 index 37fc7bf880..0000000000 --- a/ebean-api/src/main/java/io/ebean/docstore/DocUpdateContext.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.ebean.docstore; - -/** - * Document update context marker interface. - */ -public interface DocUpdateContext { -} diff --git a/ebean-api/src/main/java/io/ebean/docstore/RawDoc.java b/ebean-api/src/main/java/io/ebean/docstore/RawDoc.java deleted file mode 100644 index 282ab6f77b..0000000000 --- a/ebean-api/src/main/java/io/ebean/docstore/RawDoc.java +++ /dev/null @@ -1,102 +0,0 @@ -package io.ebean.docstore; - -import java.util.Map; - -/** - * Raw document. - */ -public class RawDoc { - - private Map source; - private String id; - private double score; - private String index; - private String type; - - /** - * Construct the document with all the meta data. - */ - public RawDoc(Map source, String id, double score, String index, String type) { - this.source = source; - this.id = id; - this.score = score; - this.index = index; - this.type = type; - } - - /** - * Construct empty (typically for JSON marshalling). - */ - public RawDoc() { - } - - /** - * Return the source document as a Map. - */ - public Map getSource() { - return source; - } - - /** - * Return the Id value. - */ - public String getId() { - return id; - } - - /** - * Return the score. - */ - public double getScore() { - return score; - } - - /** - * Return the index name. - */ - public String getIndex() { - return index; - } - - /** - * Return the index type. - */ - public String getType() { - return type; - } - - /** - * Set the source document. - */ - public void setSource(Map source) { - this.source = source; - } - - /** - * Set the id value. - */ - public void setId(String id) { - this.id = id; - } - - /** - * Set the score. - */ - public void setScore(double score) { - this.score = score; - } - - /** - * Set the index name. - */ - public void setIndex(String index) { - this.index = index; - } - - /** - * Set the index type. - */ - public void setType(String type) { - this.type = type; - } -} diff --git a/ebean-api/src/main/java/io/ebean/plugin/BeanDocType.java b/ebean-api/src/main/java/io/ebean/plugin/BeanDocType.java deleted file mode 100644 index 55e7c146b2..0000000000 --- a/ebean-api/src/main/java/io/ebean/plugin/BeanDocType.java +++ /dev/null @@ -1,72 +0,0 @@ -package io.ebean.plugin; - -import io.ebean.FetchPath; -import io.ebean.Query; -import io.ebean.docstore.DocUpdateContext; - -import java.io.IOException; - -/** - * Doc store functions for a specific entity bean type. - * - * @param The type of entity bean - */ -public interface BeanDocType { - - /** - * Return the doc store index type for this bean type. - */ - String indexType(); - - /** - * Return the doc store index name for this bean type. - */ - String indexName(); - - /** - * Apply the appropriate fetch path to the query such that the query returns beans matching - * the document store structure with the expected embedded properties. - */ - void applyPath(Query spiQuery); - - /** - * Return the FetchPath for the embedded document. - */ - FetchPath embedded(String path); - - /** - * For embedded 'many' properties we need a FetchPath relative to the root which is used to - * build and replace the embedded list. - */ - FetchPath embeddedManyRoot(String path); - - /** - * Return a 'raw' property mapped for the given property. - * If none exists the given property is returned. - */ - String rawProperty(String property); - - /** - * Store the bean in the doc store index. - *

- * This somewhat assumes the bean is fetched with appropriate path properties - * to match the expected document structure. - */ - void index(Object idValue, T bean, DocUpdateContext txn) throws IOException; - - /** - * Add a delete by Id to the doc store. - */ - void deleteById(Object idValue, DocUpdateContext txn) throws IOException; - - /** - * Add a embedded document update to the doc store. - * - * @param idValue the Id value of the bean holding the embedded document - * @param embeddedProperty the embedded property - * @param embeddedRawContent the content of the embedded document in JSON form - * @param txn the doc store transaction to add the update to - */ - void updateEmbedded(Object idValue, String embeddedProperty, String embeddedRawContent, DocUpdateContext txn) throws IOException; - -} diff --git a/ebean-api/src/main/java/io/ebean/plugin/BeanType.java b/ebean-api/src/main/java/io/ebean/plugin/BeanType.java index 762f077f49..0401711f06 100644 --- a/ebean-api/src/main/java/io/ebean/plugin/BeanType.java +++ b/ebean-api/src/main/java/io/ebean/plugin/BeanType.java @@ -2,7 +2,6 @@ import io.ebean.Query; import io.ebean.config.dbplatform.IdType; -import io.ebean.docstore.DocMapping; import io.ebean.event.BeanFindController; import io.ebean.event.BeanPersistController; import io.ebean.event.BeanPersistListener; @@ -145,30 +144,6 @@ public interface BeanType { */ IdType idType(); - /** - * Return true if this bean type has doc store backing. - */ - boolean isDocStoreMapped(); - - /** - * Return the DocumentMapping for this bean type. - *

- * This is the document structure and mapping options for how this bean type is mapped - * for the document store. - *

- */ - DocMapping docMapping(); - - /** - * Return the doc store queueId for this bean type. - */ - String docStoreQueueId(); - - /** - * Return the doc store support for this bean type.\ - */ - BeanDocType docStore(); - /** * Add the discriminator value to the query if needed. */ diff --git a/ebean-api/src/main/java/io/ebean/plugin/SpiServer.java b/ebean-api/src/main/java/io/ebean/plugin/SpiServer.java index f12869b7a6..0da3e6bd44 100644 --- a/ebean-api/src/main/java/io/ebean/plugin/SpiServer.java +++ b/ebean-api/src/main/java/io/ebean/plugin/SpiServer.java @@ -38,11 +38,6 @@ public interface SpiServer extends Database { */ List> beanTypes(String baseTableName); - /** - * Return the bean type for a given doc store queueId. - */ - BeanType beanTypeForQueueId(String queueId); - /** * Return a BeanLoader. */ diff --git a/ebean-api/src/main/java/io/ebean/search/AbstractMatch.java b/ebean-api/src/main/java/io/ebean/search/AbstractMatch.java deleted file mode 100644 index 1f922701bf..0000000000 --- a/ebean-api/src/main/java/io/ebean/search/AbstractMatch.java +++ /dev/null @@ -1,98 +0,0 @@ -package io.ebean.search; - -/** - * Options for the text match and multi match expressions. - */ -public abstract class AbstractMatch { - - protected boolean operatorAnd; - - protected String analyzer; - - protected double boost; - - protected String minShouldMatch; - - protected int maxExpansions; - - protected String zeroTerms; - - protected double cutoffFrequency; - - protected String fuzziness; - - protected int prefixLength; - - protected String rewrite; - - /** - * Return true if using the AND operator otherwise using the OR operator. - */ - public boolean isOperatorAnd() { - return operatorAnd; - } - - /** - * Return the boost. - */ - public double getBoost() { - return boost; - } - - /** - * Return the minimum should match. - */ - public String getMinShouldMatch() { - return minShouldMatch; - } - - /** - * Return the zero terms option. - */ - public String getZeroTerms() { - return zeroTerms; - } - - /** - * Return the cutoff frequency. - */ - public double getCutoffFrequency() { - return cutoffFrequency; - } - - /** - * Return the max expansions. - */ - public int getMaxExpansions() { - return maxExpansions; - } - - /** - * Return the analyzer. - */ - public String getAnalyzer() { - return analyzer; - } - - /** - * Return the fuzziness. - */ - public String getFuzziness() { - return fuzziness; - } - - /** - * Return the prefix length. - */ - public int getPrefixLength() { - return prefixLength; - } - - /** - * Return the rewrite option. - */ - public String getRewrite() { - return rewrite; - } - -} diff --git a/ebean-api/src/main/java/io/ebean/search/Match.java b/ebean-api/src/main/java/io/ebean/search/Match.java deleted file mode 100644 index 3ca4a5da82..0000000000 --- a/ebean-api/src/main/java/io/ebean/search/Match.java +++ /dev/null @@ -1,117 +0,0 @@ -package io.ebean.search; - -/** - * Options for the text match expression. - */ -public class Match extends AbstractMatch { - - protected boolean phrase; - - protected boolean phrasePrefix; - - public Match() { - } - - /** - * Set this to be a "Phrase" type expression. - */ - public Match phrase() { - phrase = true; - return this; - } - - /** - * Set this to be a "Phrase Prefix" type expression. - */ - public Match phrasePrefix() { - phrasePrefix = true; - return this; - } - - /** - * Use the AND operator (rather than OR). - */ - public Match opAnd() { - operatorAnd = true; - return this; - } - - /** - * Use the OR operator (rather than AND). - */ - public Match opOr() { - operatorAnd = false; - return this; - } - - /** - * Set the zero terms. - */ - public Match zeroTerms(String zeroTerms) { - this.zeroTerms = zeroTerms; - return this; - } - - /** - * Set the cutoff frequency. - */ - public Match cutoffFrequency(double cutoffFrequency) { - this.cutoffFrequency = cutoffFrequency; - return this; - } - - /** - * Set the max expansions (for phrase prefix only). - */ - public Match maxExpansions(int maxExpansions) { - this.maxExpansions = maxExpansions; - return this; - } - - /** - * Set the Analyzer to use for this expression. - */ - public Match analyzer(String analyzer) { - this.analyzer = analyzer; - return this; - } - - /** - * Set the boost. - */ - public Match boost(double boost) { - this.boost = boost; - return this; - } - - /** - * Set the rewrite to use. - */ - public Match minShouldMatch(String minShouldMatch) { - this.minShouldMatch = minShouldMatch; - return this; - } - - /** - * Set the rewrite to use. - */ - public Match rewrite(String rewrite) { - this.rewrite = rewrite; - return this; - } - - /** - * Return true if this is a phrase query. - */ - public boolean isPhrase() { - return phrase; - } - - /** - * Return true if this is a phrase prefix query. - */ - public boolean isPhrasePrefix() { - return phrasePrefix; - } - -} diff --git a/ebean-api/src/main/java/io/ebean/search/MultiMatch.java b/ebean-api/src/main/java/io/ebean/search/MultiMatch.java deleted file mode 100644 index 0293b59476..0000000000 --- a/ebean-api/src/main/java/io/ebean/search/MultiMatch.java +++ /dev/null @@ -1,148 +0,0 @@ -package io.ebean.search; - -/** - * Options for the text match expression. - */ -public class MultiMatch extends AbstractMatch { - - /** - * The MultiMatch type. - */ - public enum Type { - BEST_FIELDS, - MOST_FIELDS, - CROSS_FIELDS, - PHRASE, - PHRASE_PREFIX - } - - protected final String[] fields; - - protected Type type = Type.BEST_FIELDS; - - protected double tieBreaker; - - /** - * Create with the given fields. - */ - public static MultiMatch fields(String... fields) { - return new MultiMatch(fields); - } - - /** - * Construct with a set of fields. - */ - public MultiMatch(String... fields) { - this.fields = fields; - } - - /** - * Set the type of query. - */ - public MultiMatch type(Type type) { - this.type = type; - return this; - } - - /** - * Set the tieBreaker to use. - */ - public MultiMatch tieBreaker(double tieBreaker) { - this.tieBreaker = tieBreaker; - return this; - } - - /** - * Use the AND operator (rather than OR). - */ - public MultiMatch opAnd() { - operatorAnd = true; - return this; - } - - /** - * Use the OR operator (rather than AND). - */ - public MultiMatch opOr() { - operatorAnd = false; - return this; - } - - /** - * Set the minimum should match value. - */ - public MultiMatch minShouldMatch(String minShouldMatch) { - this.minShouldMatch = minShouldMatch; - return this; - } - - /** - * Set the boost. - */ - public MultiMatch boost(double boost) { - this.boost = boost; - return this; - } - - /** - * Set the zero terms. - */ - public MultiMatch zeroTerms(String zeroTerms) { - this.zeroTerms = zeroTerms; - return this; - } - - /** - * Set the cutoff frequency. - */ - public MultiMatch cutoffFrequency(double cutoffFrequency) { - this.cutoffFrequency = cutoffFrequency; - return this; - } - - /** - * Set the max expansions (for phrase prefix only). - */ - public MultiMatch maxExpansions(int maxExpansions) { - this.maxExpansions = maxExpansions; - return this; - } - - /** - * Set the Analyzer to use for this expression. - */ - public MultiMatch analyzer(String analyzer) { - this.analyzer = analyzer; - return this; - } - - /** - * Set the rewrite to use. - */ - public MultiMatch rewrite(String rewrite) { - this.rewrite = rewrite; - return this; - } - - /** - * Return the type. - */ - public Type getType() { - return type; - } - - /** - * Return the fields to search. - */ - public String[] getFields() { - return fields; - } - - /** - * Return the tie breaker. - */ - public double getTieBreaker() { - return tieBreaker; - } - -} diff --git a/ebean-api/src/main/java/io/ebean/search/TextCommonTerms.java b/ebean-api/src/main/java/io/ebean/search/TextCommonTerms.java deleted file mode 100644 index 435e17a32f..0000000000 --- a/ebean-api/src/main/java/io/ebean/search/TextCommonTerms.java +++ /dev/null @@ -1,139 +0,0 @@ -package io.ebean.search; - -/** - * Text common terms query. - *

- * This maps to an ElasticSearch "common terms query". - *

- *
{@code
- *
- *  TextCommonTerms options = new TextCommonTerms()
- *    .cutoffFrequency(0.001)
- *    .minShouldMatch("50%")
- *    .lowFreqOperatorAnd(true)
- *    .highFreqOperatorAnd(true);
- *
- *  List customers = database.find(Customer.class)
- *    .text()
- *    .textCommonTerms("the brown", options)
- *    .findList();
- *
- * }
- *
{@code
- *
- *   // ElasticSearch expression
- *
- *   "common": {
- *     "body": {
- *       "query": "the brown",
- *       "cutoff_frequency": 0.001,
- *       "low_freq_operator": "and",
- *       "high_freq_operator": "and",
- *       "minimum_should_match": "50%"
- *     }
- *   }
- *
- * }
- */ -public class TextCommonTerms { - - protected double cutoffFrequency; - - protected boolean lowFreqOperatorAnd; - protected boolean highFreqOperatorAnd; - - protected String minShouldMatch; - protected String minShouldMatchLowFreq; - protected String minShouldMatchHighFreq; - - /** - * Set the cutoff frequency. - */ - public TextCommonTerms cutoffFrequency(double cutoffFrequency) { - this.cutoffFrequency = cutoffFrequency; - return this; - } - - /** - * Set to true if low frequency terms should use AND operator. - */ - public TextCommonTerms lowFreqOperatorAnd(boolean opAnd) { - this.lowFreqOperatorAnd = opAnd; - return this; - } - - /** - * Set to true if high frequency terms should use AND operator. - */ - public TextCommonTerms highFreqOperatorAnd(boolean opAnd) { - this.highFreqOperatorAnd = opAnd; - return this; - } - - /** - * Set the minimum should match. - */ - public TextCommonTerms minShouldMatch(String minShouldMatch) { - this.minShouldMatch = minShouldMatch; - return this; - } - - /** - * Set the minimum should match for low frequency terms. - */ - public TextCommonTerms minShouldMatchLowFreq(String minShouldMatchLowFreq) { - this.minShouldMatchLowFreq = minShouldMatchLowFreq; - return this; - } - - /** - * Set the minimum should match for high frequency terms. - */ - public TextCommonTerms minShouldMatchHighFreq(String minShouldMatchHighFreq) { - this.minShouldMatchHighFreq = minShouldMatchHighFreq; - return this; - } - - /** - * Return true if low freq should use the AND operator. - */ - public boolean isLowFreqOperatorAnd() { - return lowFreqOperatorAnd; - } - - /** - * Return true if high freq should use the AND operator. - */ - public boolean isHighFreqOperatorAnd() { - return highFreqOperatorAnd; - } - - /** - * Return the cutoff frequency. - */ - public double getCutoffFrequency() { - return cutoffFrequency; - } - - /** - * Return the minimum to match. - */ - public String getMinShouldMatch() { - return minShouldMatch; - } - - /** - * Return the minimum to match for high frequency. - */ - public String getMinShouldMatchHighFreq() { - return minShouldMatchHighFreq; - } - - /** - * Return the minimum to match for low frequency. - */ - public String getMinShouldMatchLowFreq() { - return minShouldMatchLowFreq; - } - -} diff --git a/ebean-api/src/main/java/io/ebean/search/TextQueryString.java b/ebean-api/src/main/java/io/ebean/search/TextQueryString.java deleted file mode 100644 index 7e70732e03..0000000000 --- a/ebean-api/src/main/java/io/ebean/search/TextQueryString.java +++ /dev/null @@ -1,398 +0,0 @@ -package io.ebean.search; - -/** - * Text query string options. - *

- * This maps to an ElasticSearch "query string query". - *

- *
{@code
- *
- *  TextQueryString options = new TextQueryString()
- *       .analyzeWildcard(true)
- *       .fields("name")
- *       .lenient(true)
- *       .opAnd();
- *
- *   List customers = database.find(Customer.class)
- *       .text()
- *       .textSimple("quick brown", options)
- *       .findList();
- *
- * }
- *
{@code
- *
- *  // just use default options
- *  TextQueryString options = new TextQueryString();
- *
- *   List customers = database.find(Customer.class)
- *       .text()
- *       .textSimple("quick brown", options)
- *       .findList();
- *
- * }
- */ -public class TextQueryString { - - public static final int DEFAULT_FUZZY_MAX_EXPANSIONS = 50; - - protected final String[] fields; - - /** - * Only used when multiple fields set. - */ - protected boolean useDisMax = true; - - /** - * Only used when multiple fields set. - */ - protected double tieBreaker; - - protected String defaultField; - - protected boolean operatorAnd; - - protected String analyzer; - - protected boolean allowLeadingWildcard = true; - - protected boolean lowercaseExpandedTerms = true; - - protected int fuzzyMaxExpansions = DEFAULT_FUZZY_MAX_EXPANSIONS; - - protected String fuzziness; - - protected int fuzzyPrefixLength; - - protected double phraseSlop; - - protected double boost; - - protected boolean analyzeWildcard; - - protected boolean autoGeneratePhraseQueries; - - protected String minShouldMatch; - - protected boolean lenient; - - protected String locale; - - protected String timeZone; - - protected String rewrite; - - /** - * Create with given fields. - */ - public static TextQueryString fields(String... fields) { - return new TextQueryString(fields); - } - - /** - * Construct with the fields to use. - */ - public TextQueryString(String... fields) { - this.fields = fields; - } - - /** - * Use the AND operator (rather than OR). - */ - public TextQueryString opAnd() { - this.operatorAnd = true; - return this; - } - - /** - * Use the OR operator (rather than AND). - */ - public TextQueryString opOr() { - this.operatorAnd = false; - return this; - } - - /** - * Set the locale. - */ - public TextQueryString locale(String locale) { - this.locale = locale; - return this; - } - - /** - * Set lenient mode. - */ - public TextQueryString lenient(boolean lenient) { - this.lenient = lenient; - return this; - } - - /** - * Set the minimum should match. - */ - public TextQueryString minShouldMatch(String minShouldMatch) { - this.minShouldMatch = minShouldMatch; - return this; - } - - /** - * Set the analyzer. - */ - public TextQueryString analyzer(String analyzer) { - this.analyzer = analyzer; - return this; - } - - /** - * Set useDisMax option (when multiple fields only). - */ - public TextQueryString useDisMax(boolean useDisMax) { - this.useDisMax = useDisMax; - return this; - } - - /** - * Set tieBreaker option (when multiple fields only). - */ - public TextQueryString tieBreaker(double tieBreaker) { - this.tieBreaker = tieBreaker; - return this; - } - - /** - * Set the default field. - */ - public TextQueryString defaultField(String defaultField) { - this.defaultField = defaultField; - return this; - } - - /** - * Set allow leading wildcard mode. - */ - public TextQueryString allowLeadingWildcard(boolean allowLeadingWildcard) { - this.allowLeadingWildcard = allowLeadingWildcard; - return this; - } - - /** - * Set lowercase expanded terms mode. - */ - public TextQueryString lowercaseExpandedTerms(boolean lowercaseExpandedTerms) { - this.lowercaseExpandedTerms = lowercaseExpandedTerms; - return this; - } - - /** - * Set fuzzy max expansions. - */ - public TextQueryString fuzzyMaxExpansions(int fuzzyMaxExpansions) { - this.fuzzyMaxExpansions = fuzzyMaxExpansions; - return this; - } - - /** - * Set fuzziness. - */ - public TextQueryString fuzziness(String fuzziness) { - this.fuzziness = fuzziness; - return this; - } - - /** - * Set the fuzzy prefix length. - */ - public TextQueryString fuzzyPrefixLength(int fuzzyPrefixLength) { - this.fuzzyPrefixLength = fuzzyPrefixLength; - return this; - } - - /** - * Set the phrase slop. - */ - public TextQueryString phraseSlop(double phraseSlop) { - this.phraseSlop = phraseSlop; - return this; - } - - /** - * Set the boost. - */ - public TextQueryString boost(double boost) { - this.boost = boost; - return this; - } - - /** - * Set the analyze wildcard mode. - */ - public TextQueryString analyzeWildcard(boolean analyzeWildcard) { - this.analyzeWildcard = analyzeWildcard; - return this; - } - - /** - * Set the auto generate phrase queries mode. - */ - public TextQueryString autoGeneratePhraseQueries(boolean autoGeneratePhraseQueries) { - this.autoGeneratePhraseQueries = autoGeneratePhraseQueries; - return this; - } - - /** - * Set the time zone. - */ - public TextQueryString timeZone(String timeZone) { - this.timeZone = timeZone; - return this; - } - - /** - * Set the rewrite option. - */ - public TextQueryString rewrite(String rewrite) { - this.rewrite = rewrite; - return this; - } - - /** - * Return the rewrite option. - */ - public String getRewrite() { - return rewrite; - } - - /** - * Return the fields. - */ - public String[] getFields() { - return fields; - } - - /** - * Return true if AND is the default operator. - */ - public boolean isOperatorAnd() { - return operatorAnd; - } - - /** - * Return the analyzer. - */ - public String getAnalyzer() { - return analyzer; - } - - /** - * Return the locale. - */ - public String getLocale() { - return locale; - } - - /** - * Return lenient mode. - */ - public boolean isLenient() { - return lenient; - } - - /** - * Return the minimum should match. - */ - public String getMinShouldMatch() { - return minShouldMatch; - } - - /** - * Return the useDixMax mode. - */ - public boolean isUseDisMax() { - return useDisMax; - } - - /** - * Return the tie breaker. - */ - public double getTieBreaker() { - return tieBreaker; - } - - /** - * Return the default field. - */ - public String getDefaultField() { - return defaultField; - } - - /** - * Return the allow leading wildcard mode. - */ - public boolean isAllowLeadingWildcard() { - return allowLeadingWildcard; - } - - /** - * Return the lowercase expanded terms mode. - */ - public boolean isLowercaseExpandedTerms() { - return lowercaseExpandedTerms; - } - - /** - * Return the fuzzy max expansions. - */ - public int getFuzzyMaxExpansions() { - return fuzzyMaxExpansions; - } - - /** - * Return the fuzziness. - */ - public String getFuzziness() { - return fuzziness; - } - - /** - * Return the fuzzy prefix length. - */ - public int getFuzzyPrefixLength() { - return fuzzyPrefixLength; - } - - /** - * Return the phrase slop. - */ - public double getPhraseSlop() { - return phraseSlop; - } - - /** - * Return the analyze wildcard mode. - */ - public boolean isAnalyzeWildcard() { - return analyzeWildcard; - } - - /** - * Return the boost. - */ - public double getBoost() { - return boost; - } - - /** - * Return the auto generate phase queries mode. - */ - public boolean isAutoGeneratePhraseQueries() { - return autoGeneratePhraseQueries; - } - - /** - * Return the time zone. - */ - public String getTimeZone() { - return timeZone; - } - -} diff --git a/ebean-api/src/main/java/io/ebean/search/TextSimple.java b/ebean-api/src/main/java/io/ebean/search/TextSimple.java deleted file mode 100644 index 97dca17ae9..0000000000 --- a/ebean-api/src/main/java/io/ebean/search/TextSimple.java +++ /dev/null @@ -1,193 +0,0 @@ -package io.ebean.search; - -/** - * Simple text query options. - *

- * This maps to an ElasticSearch "simple text query". - *

- *
{@code
- *
- *  TextSimple options = new TextSimple()
- *       .analyzeWildcard(true)
- *       .fields("name")
- *       .lenient(true)
- *       .opAnd();
- *
- *   List customers = database.find(Customer.class)
- *       .text()
- *       .textSimple("quick brown", options)
- *       .findList();
- *
- * }
- */ -public class TextSimple { - - protected String[] fields; - - protected boolean operatorAnd; - - protected String analyzer; - - protected String flags; - - protected boolean lowercaseExpandedTerms = true; - - protected boolean analyzeWildcard; - - protected String locale; - - protected boolean lenient; - - protected String minShouldMatch; - - /** - * Construct - */ - public TextSimple() { - } - - /** - * Set the fields. - */ - public TextSimple fields(String... fields) { - this.fields = fields; - return this; - } - - /** - * Use AND as the default operator. - */ - public TextSimple opAnd() { - this.operatorAnd = true; - return this; - } - - /** - * Use OR as the default operator. - */ - public TextSimple opOr() { - this.operatorAnd = false; - return this; - } - - /** - * Set the analyzer - */ - public TextSimple analyzer(String analyzer) { - this.analyzer = analyzer; - return this; - } - - /** - * Set the flags. - */ - public TextSimple flags(String flags) { - this.flags = flags; - return this; - } - - - /** - * Set the false to not use lowercase expanded terms. - */ - public TextSimple lowercaseExpandedTerms(boolean lowercaseExpandedTerms) { - this.lowercaseExpandedTerms = lowercaseExpandedTerms; - return this; - } - - /** - * Set to true to use analyze wildcard. - */ - public TextSimple analyzeWildcard(boolean analyzeWildcard) { - this.analyzeWildcard = analyzeWildcard; - return this; - } - - /** - * Set the locale. - */ - public TextSimple locale(String locale) { - this.locale = locale; - return this; - } - - /** - * Set the lenient mode. - */ - public TextSimple lenient(boolean lenient) { - this.lenient = lenient; - return this; - } - - /** - * Set the minimum should match. - */ - public TextSimple minShouldMatch(String minShouldMatch) { - this.minShouldMatch = minShouldMatch; - return this; - } - - /** - * Return lenient mode. - */ - public boolean isLenient() { - return lenient; - } - - /** - * Return true to analyse wildcard. - */ - public boolean isAnalyzeWildcard() { - return analyzeWildcard; - } - - /** - * Return lowercase expanded terms mode. - */ - public boolean isLowercaseExpandedTerms() { - return lowercaseExpandedTerms; - } - - /** - * Return true if the default operator should be AND. - */ - public boolean isOperatorAnd() { - return operatorAnd; - } - - /** - * Return the analyzer to use. - */ - public String getAnalyzer() { - return analyzer; - } - - /** - * Return the fields. - */ - public String[] getFields() { - return fields; - } - - /** - * Return the locale. - */ - public String getLocale() { - return locale; - } - - /** - * Return the flags. - */ - public String getFlags() { - return flags; - } - - /** - * Return the minimum should match. - */ - public String getMinShouldMatch() { - return minShouldMatch; - } - -} diff --git a/ebean-api/src/main/java/io/ebean/search/package-info.java b/ebean-api/src/main/java/io/ebean/search/package-info.java deleted file mode 100644 index 1fab5cb0ae..0000000000 --- a/ebean-api/src/main/java/io/ebean/search/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides text search expressions like Match, TextQueryString etc. - */ -package io.ebean.search; diff --git a/ebean-api/src/main/java/module-info.java b/ebean-api/src/main/java/module-info.java index 18dbab729b..073a04fc9e 100644 --- a/ebean-api/src/main/java/module-info.java +++ b/ebean-api/src/main/java/module-info.java @@ -32,10 +32,8 @@ exports io.ebean.event; exports io.ebean.event.changelog; exports io.ebean.common; - exports io.ebean.docstore; exports io.ebean.plugin; exports io.ebean.metric; - exports io.ebean.search; exports io.ebean.service; exports io.ebean.text; exports io.ebean.text.json; diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index ffe6e4f209..d72caf9c8a 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -230,25 +230,6 @@ - - org.apache.maven.plugins - maven-javadoc-plugin - - Ebean 12 - src/main/java/io/ebean/overview.html - io.ebeaninternal.*:io.ebeanservice:io.ebean.common:io.ebean.bean:io.ebean.service:io.ebean.metric:io.ebean.util:io.ebean.config.properties:io.ebean.config.dbplatform - true - src/main/java/com/avaje/ebean/overview.html - - - - attach-javadocs - - jar - - - - diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyBuffer.java b/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyBuffer.java index ccd7e9c88c..70199947e5 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyBuffer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyBuffer.java @@ -43,5 +43,4 @@ public interface LoadManyBuffer { void configureQuery(SpiQuery query); - boolean isUseDocStore(); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyRequest.java b/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyRequest.java index 0fdb582167..d0a4a4530c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyRequest.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyRequest.java @@ -99,7 +99,7 @@ public SpiQuery createQuery(SpiEbeanServer server) { query.where().raw(extraWhere.replace("${ta}", "t0").replace("${mta}", "int_")); } query.setLazyLoadForParents(many); - many.addWhereParentIdIn(query, parentIdList(server), loadContext.isUseDocStore()); + many.addWhereParentIdIn(query, parentIdList(server)); query.setPersistenceContext(loadContext.persistenceContext()); query.setLoadDescription(lazy ? "+lazy" : "+query", description()); if (lazy) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiEbeanServer.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiEbeanServer.java index 2e790ebe1c..e4ed3a2f81 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiEbeanServer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiEbeanServer.java @@ -99,11 +99,6 @@ public interface SpiEbeanServer extends SpiServer, ExtendedServer, BeanCollectio */ BeanDescriptor descriptorById(String className); - /** - * Return BeanDescriptor using it's unique doc store queueId. - */ - BeanDescriptor descriptorByQueueId(String queueId); - /** * Return BeanDescriptors mapped to this table. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpression.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpression.java index 030042d96b..e4d85aa0ec 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpression.java @@ -3,9 +3,6 @@ import io.ebean.Expression; import io.ebean.event.BeanQueryRequest; import io.ebeaninternal.server.deploy.BeanDescriptor; -import io.ebeaninternal.server.expression.DocQueryContext; - -import java.io.IOException; /** @@ -21,16 +18,6 @@ public interface SpiExpression extends Expression { */ void simplify(); - /** - * Write the expression as an elastic search expression. - */ - void writeDocQuery(DocQueryContext context) throws IOException; - - /** - * Return the nested path for this expression. - */ - String nestedPath(BeanDescriptor desc); - /** * Process "Many" properties populating ManyWhereJoins. *

diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionList.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionList.java index 15fa906f6d..3bf9d26a90 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionList.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionList.java @@ -2,7 +2,6 @@ import io.ebean.ExpressionList; import io.ebean.Junction; -import io.ebeaninternal.server.expression.DocQueryContext; import java.io.IOException; import java.util.List; @@ -32,11 +31,6 @@ public interface SpiExpressionList extends ExpressionList, SpiExpression { */ boolean isEmpty(); - /** - * Write the top level where expressions taking into account possible extra idEquals expression. - */ - void writeDocQuery(DocQueryContext context, SpiExpression idEquals) throws IOException; - /** * Apply firstRow maxRows limits on the filterMany query. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiJunction.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiJunction.java index 59bc0cc06f..78c32925e3 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiJunction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiJunction.java @@ -1,17 +1,10 @@ package io.ebeaninternal.api; import io.ebean.Junction; -import io.ebeaninternal.server.expression.DocQueryContext; - -import java.io.IOException; /** * SPI methods for Junction. */ public interface SpiJunction extends Junction { - /** - * Write the Junction taking into account it is implied. - */ - void writeDocQueryJunction(DocQueryContext context) throws IOException; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiQuery.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiQuery.java index b8b0a37a2b..d8f1bcd470 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiQuery.java @@ -285,17 +285,6 @@ public static TemporalMode of(SpiQuery query) { */ SpiRawSql rawSql(); - /** - * Return true if this query should be executed against the doc store. - */ - boolean isUseDocStore(); - - /** - * For doc store query return the document index name to search against. - * This is for partitioned indexes (like daily logstash indexes etc). - */ - String getDocIndexName(); - /** * Return the PersistenceContextScope that this query should use. *

@@ -498,11 +487,6 @@ public static TemporalMode of(SpiQuery query) { */ NaturalKeyBindParam naturalKeyBindParam(); - /** - * Prepare the query for docstore execution with nested paths. - */ - void prepareDocNested(); - /** * Set the query to be a delete query. */ @@ -708,11 +692,6 @@ public static TemporalMode of(SpiQuery query) { */ SpiExpressionList havingExpressions(); - /** - * Return the text expressions. - */ - SpiExpressionList textExpression(); - /** * Returns true if either firstRow or maxRows has been set. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java index e15b51298b..c7e862ecc8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java @@ -9,7 +9,6 @@ import io.ebeaninternal.server.core.PersistRequestBean; import io.ebeaninternal.server.persist.BatchControl; import io.ebeaninternal.server.transaction.ProfileStream; -import io.ebeanservice.docstore.api.DocStoreTransaction; import javax.persistence.PersistenceException; import java.sql.Connection; @@ -103,19 +102,6 @@ public interface SpiTransaction extends Transaction { */ Boolean isUpdateAllLoadedProperties(); - /** - * Return the batchSize specifically set for this transaction or 0. - *

- * Returning 0 implies to use the system wide default batch size. - */ - DocStoreMode docStoreMode(); - - /** - * Return the batch size to us for ElasticSearch Bulk API calls - * as a result of this transaction. - */ - int getDocStoreBatchSize(); - /** * Return the batchSize specifically set for this transaction or 0. *

@@ -287,11 +273,6 @@ default int depth() { */ void sendChangeLog(ChangeSet changeSet); - /** - * Return a document store transaction. - */ - DocStoreTransaction docStoreTransaction(); - /** * Set the current Tenant Id. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java index bb738cb5ad..1304d813e8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java @@ -2,14 +2,12 @@ import io.ebean.ProfileLocation; import io.ebean.TransactionCallback; -import io.ebean.annotation.DocStoreMode; import io.ebean.event.changelog.BeanChange; import io.ebean.event.changelog.ChangeSet; import io.ebeaninternal.server.core.PersistDeferredRelationship; import io.ebeaninternal.server.core.PersistRequestBean; import io.ebeaninternal.server.persist.BatchControl; import io.ebeaninternal.server.transaction.ProfileStream; -import io.ebeanservice.docstore.api.DocStoreTransaction; import javax.persistence.PersistenceException; import java.sql.Connection; @@ -112,32 +110,6 @@ public Object tenantId() { return transaction.tenantId(); } - @Override - public DocStoreTransaction docStoreTransaction() { - return transaction.docStoreTransaction(); - } - - @Override - public DocStoreMode docStoreMode() { - return transaction.docStoreMode(); - } - - @Override - public void setDocStoreMode(DocStoreMode mode) { - transaction.setDocStoreMode(mode); - } - - @Override - public int getDocStoreBatchSize() { - return transaction.getDocStoreBatchSize(); - } - - @Override - public void setDocStoreBatchSize(int batchSize) { - transaction.setDocStoreBatchSize(batchSize); - } - - @Override public boolean isLogSql() { return transaction.isLogSql(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/TransactionEvent.java b/ebean-core/src/main/java/io/ebeaninternal/api/TransactionEvent.java index c1fc45f304..538bdafc97 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/TransactionEvent.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/TransactionEvent.java @@ -6,7 +6,6 @@ import io.ebeaninternal.server.deploy.BeanDescriptorManager; import io.ebeaninternal.server.transaction.DeleteByIdMap; import io.ebeaninternal.server.transaction.TransactionManager; -import io.ebeanservice.docstore.api.DocStoreUpdates; import java.io.Serializable; import java.util.ArrayList; @@ -125,18 +124,6 @@ public CacheChangeSet buildCacheChanges(TransactionManager manager) { return changeSet; } - /** - * Add any relevant PersistRequestBean's to DocStoreUpdates for later processing. - */ - public void addDocStoreUpdates(DocStoreUpdates docStoreUpdates) { - List> requests = listenerNotify(); - if (requests != null) { - for (PersistRequestBean persistRequestBean : requests) { - persistRequestBean.addDocStoreUpdates(docStoreUpdates); - } - } - } - /** * Return the CacheChangeSet that we add cache notification messages to. *

diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java index d90cb0f089..29ab6a4068 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java @@ -78,16 +78,12 @@ public SpiEbeanServer createServer(DatabaseConfig config) { BootupClasses bootupClasses = bootupClasses(config); boolean online = true; - if (config.isDocStoreOnly()) { - config.setDatabasePlatform(new DatabasePlatform()); - } else { - TenantMode tenantMode = config.getTenantMode(); - if (TenantMode.DB != tenantMode) { - setDataSource(config); - if (!tenantMode.isDynamicDataSource()) { - // check the autoCommit and Transaction Isolation - online = checkDataSource(config); - } + TenantMode tenantMode = config.getTenantMode(); + if (TenantMode.DB != tenantMode) { + setDataSource(config); + if (!tenantMode.isDynamicDataSource()) { + // check the autoCommit and Transaction Isolation + online = checkDataSource(config); } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java index 20a1006ed3..aa53501d9b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java @@ -40,7 +40,6 @@ import io.ebeaninternal.server.transaction.TransactionManager; import io.ebeaninternal.util.ParamTypeHelper; import io.ebeaninternal.util.ParamTypeHelper.TypeInfo; -import io.ebeanservice.docstore.api.DocStoreIntegration; import javax.persistence.EntityNotFoundException; import javax.persistence.NonUniqueResultException; @@ -99,7 +98,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { private final DefaultBeanLoader beanLoader; private final EncryptKeyManager encryptKeyManager; private final SpiJsonContext jsonContext; - private final DocumentStore documentStore; private final MetaInfoManager metaInfoManager; private final CurrentTenantProvider currentTenantProvider; private final SpiLogManager logManager; @@ -146,9 +144,7 @@ public DefaultServer(InternalConfiguration config, ServerCacheManager cache) { this.dataTimeZone = config.getDataTimeZone(); this.clockService = config.getClockService(); - DocStoreIntegration docStoreComponents = config.createDocStoreIntegration(this); - this.transactionManager = config.createTransactionManager(this, docStoreComponents.updateProcessor()); - this.documentStore = docStoreComponents.documentStore(); + this.transactionManager = config.createTransactionManager(this); this.queryPlanManager = config.initQueryPlanManager(transactionManager); this.metaInfoManager = new DefaultMetaInfoManager(this, this.config.getMetricNaming()); this.serverPlugins = config.getPlugins(); @@ -182,9 +178,7 @@ private void configureServerPlugins() { * Execute all the plugins with an online flag indicating the DB is up or not. */ public void executePlugins(boolean online) { - if (!config.isDocStoreOnly()) { - ddlGenerator.execute(online); - } + ddlGenerator.execute(online); for (Plugin plugin : serverPlugins) { plugin.online(online); } @@ -992,9 +986,6 @@ private T findId(SpiQuery query) { } SpiOrmQueryRequest request = buildQueryRequest(query); request.prepareQuery(); - if (request.isUseDocStore()) { - return docStore().find(request); - } try { request.initTransIfRequired(); return (T) request.findId(); @@ -1282,9 +1273,6 @@ public PagedList findPagedList(SpiQuery query) { if (maxRows == 0) { throw new PersistenceException("maxRows must be specified for findPagedList() query"); } - if (query.isUseDocStore()) { - return docStore().findPagedList(createQueryRequest(Type.LIST, query)); - } return new LimitOffsetPagedList<>(this, query); } @@ -1312,10 +1300,6 @@ private Stream toStream(QueryIterator queryIterator) { @Override public void findEach(SpiQuery query, Consumer consumer) { SpiOrmQueryRequest request = createQueryRequest(Type.ITERATE, query); - if (request.isUseDocStore()) { - docStore().findEach(request, consumer); - return; - } request.initTransIfRequired(); request.findEach(consumer); // no try finally - findEach guarantee's cleanup of the transaction if required @@ -1324,10 +1308,6 @@ public void findEach(SpiQuery query, Consumer consumer) { @Override public void findEach(SpiQuery query, int batch, Consumer> consumer) { SpiOrmQueryRequest request = createQueryRequest(Type.ITERATE, query); -// if (request.isUseDocStore()) { -// docStore().findEach(request, consumer); -// return; -// } request.initTransIfRequired(); request.findEach(batch, consumer); // no try finally - findEach guarantee's cleanup of the transaction if required @@ -1336,10 +1316,6 @@ public void findEach(SpiQuery query, int batch, Consumer> consume @Override public void findEachWhile(SpiQuery query, Predicate consumer) { SpiOrmQueryRequest request = createQueryRequest(Type.ITERATE, query); - if (request.isUseDocStore()) { - docStore().findEachWhile(request, consumer); - return; - } request.initTransIfRequired(); request.findEachWhile(consumer); // no try finally - findEachWhile guarantee's cleanup of the transaction if required @@ -1374,9 +1350,6 @@ private List findList(SpiQuery query, boolean findOne) { if (result != null) { return (List) result; } - if (request.isUseDocStore()) { - return docStore().findList(request); - } try { request.initTransIfRequired(); return request.findList(); @@ -1944,16 +1917,6 @@ public List> beanTypes(String tableName) { return descriptorManager.beanTypes(tableName); } - @Override - public BeanType beanTypeForQueueId(String queueId) { - return descriptorByQueueId(queueId); - } - - @Override - public BeanDescriptor descriptorByQueueId(String queueId) { - return descriptorManager.descriptorByQueueId(queueId); - } - /** * Return the SPI bean types for the given bean class. */ @@ -2060,11 +2023,6 @@ public CallOrigin createCallOrigin() { return callStackFactory.createCallOrigin(); } - @Override - public DocumentStore docStore() { - return documentStore; - } - @Override public JsonContext json() { // immutable thread safe so return shared instance diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java index 578586b0c3..611d9ce913 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java @@ -46,10 +46,6 @@ import io.ebeaninternal.server.transaction.*; import io.ebeaninternal.server.type.DefaultTypeManager; import io.ebeaninternal.server.type.TypeManager; -import io.ebeanservice.docstore.api.DocStoreFactory; -import io.ebeanservice.docstore.api.DocStoreIntegration; -import io.ebeanservice.docstore.api.DocStoreUpdateProcessor; -import io.ebeanservice.docstore.none.NoneDocStoreFactory; import java.util.*; @@ -85,7 +81,6 @@ public final class InternalConfiguration { private final ExpressionFactory expressionFactory; private final SpiBackgroundExecutor backgroundExecutor; private final JsonFactory jsonFactory; - private final DocStoreFactory docStoreFactory; private final List plugins = new ArrayList<>(); private final MultiValueBind multiValueBind; private final SpiLogManager logManager; @@ -102,7 +97,6 @@ public final class InternalConfiguration { this.clockService = new ClockService(config.getClock()); this.tableModState = new TableModState(); this.logManager = initLogManager(); - this.docStoreFactory = initDocStoreFactory(service(DocStoreFactory.class)); this.jsonFactory = config.getJsonFactory(); this.clusterManager = clusterManager; this.backgroundExecutor = backgroundExecutor; @@ -159,17 +153,6 @@ private ExpressionFactory initExpressionFactory(DatabaseConfig config) { return new DefaultExpressionFactory(config.isExpressionEqualsWithNullAsNoop(), nativeIlike); } - private DocStoreFactory initDocStoreFactory(DocStoreFactory service) { - return service == null ? new NoneDocStoreFactory() : service; - } - - /** - * Return the doc store factory. - */ - public DocStoreFactory getDocStoreFactory() { - return docStoreFactory; - } - ClockService getClockService() { return clockService; } @@ -337,29 +320,19 @@ public GeneratedPropertyFactory getGeneratedPropertyFactory() { return new GeneratedPropertyFactory(offlineMode, config, bootupClasses.getIdGenerators()); } - /** - * Create the DocStoreIntegration components for the given server. - */ - DocStoreIntegration createDocStoreIntegration(SpiServer server) { - return plugin(docStoreFactory.create(server)); - } - /** * Create the TransactionManager taking into account autoCommit mode. */ - TransactionManager createTransactionManager(SpiServer server, DocStoreUpdateProcessor indexUpdateProcessor) { + TransactionManager createTransactionManager(SpiServer server) { TransactionScopeManager scopeManager = createTransactionScopeManager(); boolean notifyL2CacheInForeground = cacheManager.isLocalL2Caching() || config.isNotifyL2CacheInForeground(); TransactionManagerOptions options = new TransactionManagerOptions(server, notifyL2CacheInForeground, config, scopeManager, clusterManager, backgroundExecutor, - indexUpdateProcessor, beanDescriptorManager, dataSource(), profileHandler(), logManager, + beanDescriptorManager, dataSource(), profileHandler(), logManager, tableModState, cacheNotify, clockService); - if (config.isDocStoreOnly()) { - return new DocStoreTransactionManager(options); - } return new TransactionManager(options); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java index 473e6315c8..9a83635bad 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java @@ -116,7 +116,6 @@ public String escapeLikeString(String value) { return server.databasePlatform().escapeLikeString(value); } - @Override public void executeSecondaryQueries(boolean forEach) { // disable lazy loading leaves loadContext null if (loadContext != null) { @@ -157,11 +156,6 @@ public LoadContext loadContext() { return loadContext; } - @Override - public boolean isUseDocStore() { - return query.isUseDocStore(); - } - /** * Run BeanQueryAdapter preQuery() if needed. */ @@ -257,23 +251,6 @@ public void rollbackTransIfRequired() { } } - /** - * Return the JsonReadOptions taking into account lazy loading and persistence context. - */ - @Override - public JsonReadOptions createJsonReadOptions() { - persistenceContext = persistenceContext(query, transaction); - if (query.persistenceContext() == null) { - query.setPersistenceContext(persistenceContext); - } - JsonReadOptions jsonRead = new JsonReadOptions(); - jsonRead.setPersistenceContext(persistenceContext); - if (!query.isDisableLazyLoading()) { - loadContext = new DLoadContext(this, secondaryQueries); - jsonRead.setLoadContext(loadContext); - } - return jsonRead; - } /** * Get the TransactionContext either explicitly set on the query or diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java index b622b679ca..2facba1a1f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java @@ -16,9 +16,6 @@ import io.ebeaninternal.server.deploy.id.ImportedId; import io.ebeaninternal.server.persist.*; import io.ebeaninternal.server.transaction.BeanPersistIdMap; -import io.ebeanservice.docstore.api.DocStoreUpdate; -import io.ebeanservice.docstore.api.DocStoreUpdateContext; -import io.ebeanservice.docstore.api.DocStoreUpdates; import javax.persistence.EntityNotFoundException; import javax.persistence.OptimisticLockException; @@ -30,7 +27,7 @@ /** * PersistRequest for insert update or delete of a bean. */ -public final class PersistRequestBean extends PersistRequest implements BeanPersistRequest, DocStoreUpdate, PreGetterCallback, SpiProfileTransactionEvent { +public final class PersistRequestBean extends PersistRequest implements BeanPersistRequest, PreGetterCallback, SpiProfileTransactionEvent { private final BeanManager beanManager; private final BeanDescriptor beanDescriptor; @@ -46,7 +43,6 @@ public final class PersistRequestBean extends PersistRequest implements BeanP private final boolean dirty; private int flags; private boolean saveRecurse; - private DocStoreMode docStoreMode; private final ConcurrencyMode concurrencyMode; /** * The unique id used for logging summary. @@ -136,7 +132,6 @@ public PersistRequestBean(SpiEbeanServer server, T bean, Object parentBean, Bean this.parentBean = parentBean; this.controller = beanDescriptor.persistController(); this.type = type; - this.docStoreMode = calcDocStoreMode(transaction, type); this.flags = flags; if (Flags.isRecurse(flags)) { this.persistCascade = t.isPersistCascade(); @@ -180,17 +175,6 @@ public void profile(long offset, int flushCount) { profileBase(type.profileEventId, offset, beanDescriptor.name(), flushCount); } - /** - * Return the document store event that should be used for this request. - *

- * Used to check if the Transaction has set the mode to IGNORE when doing large batch inserts that we - * don't want to send to the doc store. - */ - private DocStoreMode calcDocStoreMode(SpiTransaction txn, Type type) { - DocStoreMode txnMode = (txn == null) ? null : txn.docStoreMode(); - return beanDescriptor.docStoreMode(type, txnMode); - } - @Override public boolean isCascade() { return Flags.isRecurse(flags); @@ -210,9 +194,7 @@ public void setTrans(SpiTransaction transaction) { * Init the transaction and also check for batch on cascade escalation. */ public void initTransIfRequiredWithBatchCascade() { - if (createImplicitTransIfRequired()) { - docStoreMode = calcDocStoreMode(transaction, type); - } + createImplicitTransIfRequired(); checkBatchEscalationOnCascade(); } @@ -412,15 +394,9 @@ private void setNotifyCache() { * Return true if this change should notify persist listener or doc store (and keep the request). */ private boolean isNotifyListeners() { - return isNotifyPersistListener() || isDocStoreNotify(); + return isNotifyPersistListener(); } - /** - * Return true if this request should update the document store. - */ - private boolean isDocStoreNotify() { - return docStoreMode != DocStoreMode.IGNORE; - } private boolean isNotifyPersistListener() { return beanPersistListener != null; @@ -448,46 +424,6 @@ private void notifyCache(CacheChangeSet changeSet) { } } - /** - * Process the persist request updating the document store. - */ - @Override - public void docStoreUpdate(DocStoreUpdateContext txn) throws IOException { - switch (type) { - case INSERT: - beanDescriptor.docStoreInsert(idValue, this, txn); - break; - case UPDATE: - case DELETE_SOFT: - beanDescriptor.docStoreUpdate(idValue, this, txn); - break; - case DELETE: - beanDescriptor.docStoreDeleteById(idValue, txn); - break; - default: - throw new IllegalStateException("Invalid type " + type); - } - } - - /** - * Add this event to the queue entries in IndexUpdates. - */ - @Override - public void addToQueue(DocStoreUpdates docStoreUpdates) { - switch (type) { - case INSERT: - case UPDATE: - case DELETE_SOFT: - docStoreUpdates.queueIndex(beanDescriptor.docStoreQueueId(), idValue); - break; - case DELETE: - docStoreUpdates.queueDelete(beanDescriptor.docStoreQueueId(), idValue); - break; - default: - throw new IllegalStateException("Invalid type " + type); - } - } - public void addToPersistMap(BeanPersistIdMap beanPersistMap) { beanPersistMap.add(beanDescriptor, type, idValue); } @@ -821,7 +757,7 @@ public void postExecute() { } setNotifyCache(); boolean isChangeLog = beanDescriptor.isChangeLog(); - if (type == Type.UPDATE && (isChangeLog || notifyCache || docStoreMode == DocStoreMode.UPDATE)) { + if (type == Type.UPDATE && (isChangeLog || notifyCache)) { // get the dirty properties for update notification to the doc store dirtyProperties = intercept.dirtyProperties(); } @@ -1030,32 +966,6 @@ private void notifyCacheOnComplete() { } } - /** - * For requests that update document store add this event to either the list - * of queue events or list of update events. - */ - public void addDocStoreUpdates(DocStoreUpdates docStoreUpdates) { - if (type == Type.UPDATE) { - beanDescriptor.docStoreUpdateEmbedded(this, docStoreUpdates); - } - switch (docStoreMode) { - case UPDATE: { - docStoreUpdates.addPersist(this); - return; - } - case QUEUE: { - if (type == Type.DELETE) { - docStoreUpdates.queueDelete(beanDescriptor.docStoreQueueId(), idValue); - } else { - docStoreUpdates.queueIndex(beanDescriptor.docStoreQueueId(), idValue); - } - } - break; - default: - break; - } - } - /** * Determine if all loaded properties should be used for an update. *

@@ -1173,30 +1083,6 @@ private int executeDelete() { return 0; } - /** - * Persist to the document store now (via buffer, not post commit). - */ - public void docStorePersist() { - idValue = beanDescriptor.getId(entityBean); - if (type == Type.UPDATE) { - dirtyProperties = intercept.dirtyProperties(); - } - // processing now so set IGNORE (unlike DB + DocStore processing with post-commit) - docStoreMode = DocStoreMode.IGNORE; - try { - docStoreUpdate(transaction.docStoreTransaction().obtain()); - postExecute(); - if (type == Type.UPDATE - && beanDescriptor.isDocStoreEmbeddedInvalidation() - && transaction.isPersistCascade()) { - // queue embedded/nested updates for later processing - beanDescriptor.docStoreUpdateEmbedded(this, transaction.docStoreTransaction().queue()); - } - } catch (IOException e) { - throw new PersistenceException("Error persisting doc store bean", e); - } - } - /** * Use a common 'now' value across both when created and when updated etc. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/SpiOrmQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/SpiOrmQueryRequest.java index e81da64f54..7ed38524d9 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/SpiOrmQueryRequest.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/SpiOrmQueryRequest.java @@ -5,7 +5,6 @@ import io.ebean.event.BeanQueryRequest; import io.ebeaninternal.api.SpiQuery; import io.ebeaninternal.server.deploy.BeanDescriptor; -import io.ebeanservice.docstore.api.DocQueryRequest; import java.util.Collection; import java.util.List; @@ -17,7 +16,7 @@ /** * Defines the ORM query request api. */ -public interface SpiOrmQueryRequest extends BeanQueryRequest, DocQueryRequest { +public interface SpiOrmQueryRequest extends BeanQueryRequest { /** * Return the query. @@ -178,11 +177,6 @@ public interface SpiOrmQueryRequest extends BeanQueryRequest, DocQueryRequ */ void markNotQueryOnly(); - /** - * Return true if this query is expected to use the doc store. - */ - boolean isUseDocStore(); - /** * Return true if delete by statement is allowed for this type given cascade rules etc. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java index ade52548eb..d354cf7d4b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java @@ -17,7 +17,6 @@ import io.ebean.meta.MetaQueryPlan; import io.ebean.meta.MetricVisitor; import io.ebean.meta.QueryPlanInit; -import io.ebean.plugin.BeanDocType; import io.ebean.plugin.BeanType; import io.ebean.plugin.ExpressionPath; import io.ebean.plugin.Property; @@ -44,12 +43,6 @@ import io.ebeaninternal.server.querydefn.OrmQueryProperties; import io.ebeaninternal.util.SortByClause; import io.ebeaninternal.util.SortByClauseParser; -import io.ebeanservice.docstore.api.DocStoreBeanAdapter; -import io.ebeanservice.docstore.api.DocStoreUpdateContext; -import io.ebeanservice.docstore.api.DocStoreUpdates; -import io.ebeanservice.docstore.api.mapping.DocMappingBuilder; -import io.ebeanservice.docstore.api.mapping.DocPropertyMapping; -import io.ebeanservice.docstore.api.mapping.DocumentMapping; import javax.persistence.PersistenceException; import java.io.IOException; @@ -210,12 +203,8 @@ public enum EntityType { private final String name; private final String baseTableAlias; private final boolean cacheSharableBeans; - private final String docStoreQueueId; private final BeanDescriptorCacheHelp cacheHelp; private final BeanDescriptorJsonHelp jsonHelp; - private DocStoreBeanAdapter docStoreAdapter; - private DocumentMapping docMapping; - private boolean docStoreEmbeddedInvalidation; private final String defaultSelectClause; private SpiEbeanServer ebeanServer; @@ -297,8 +286,6 @@ public BeanDescriptor(BeanDescriptorMap owner, DeployBeanDescriptor deploy) { this.cacheSharableBeans = noRelationships && deploy.getCacheOptions().isReadOnly(); this.cacheHelp = new BeanDescriptorCacheHelp<>(this, owner.cacheManager(), deploy.getCacheOptions(), cacheSharableBeans, propertiesOneImported); this.jsonHelp = initJsonHelp(); - this.docStoreAdapter = owner.createDocStoreBeanAdapter(this, deploy); - this.docStoreQueueId = docStoreAdapter.queueId(); // Check if there are no cascade save associated beans ( subject to change // in initialiseOther()). Note that if we are in an inheritance hierarchy // then we also need to check every BeanDescriptors in the InheritInfo as @@ -576,7 +563,6 @@ void initLast() { } } } - docStoreEmbeddedInvalidation = docStoreAdapter.hasEmbeddedInvalidation(); } private void addUniqueColumns(IndexDefinition indexDef) { @@ -612,11 +598,6 @@ void initialiseDocMapping() { for (BeanPropertyAssocOne one : propertiesOne) { one.initialisePostTarget(); } - if (inheritInfo != null && !inheritInfo.isRoot()) { - docStoreAdapter = (DocStoreBeanAdapter) inheritInfo.getRoot().desc().docStoreAdapter(); - } - docMapping = docStoreAdapter.createDocMapping(); - docStoreAdapter.registerPaths(); cacheHelp.deriveNotifyFlags(); } @@ -903,77 +884,6 @@ public boolean isInheritanceRoot() { return inheritInfo == null || inheritInfo.isRoot(); } - /** - * Return true if this type maps to a root type of a doc store document (not embedded or ignored). - */ - @Override - public boolean isDocStoreMapped() { - return docStoreAdapter.mapped(); - } - - /** - * Return true if this bean type has embedded doc store invalidation. - */ - public boolean isDocStoreEmbeddedInvalidation() { - return docStoreEmbeddedInvalidation; - } - - /** - * Return the queueId used to uniquely identify this type when queuing an index updateAdd. - */ - @Override - public String docStoreQueueId() { - return docStoreQueueId; - } - - @Override - public DocumentMapping docMapping() { - return docMapping; - } - - /** - * Return the doc store helper for this bean type. - */ - @Override - public BeanDocType docStore() { - return docStoreAdapter; - } - - /** - * Return doc store adapter for internal use for processing persist requests. - */ - public DocStoreBeanAdapter docStoreAdapter() { - return docStoreAdapter; - } - - /** - * Build the Document mapping recursively with the given prefix relative to the root of the document. - */ - public void docStoreMapping(final DocMappingBuilder mapping, final String prefix) { - if (prefix != null && idProperty != null) { - // id property not included in the - idProperty.docStoreMapping(mapping, prefix); - } - if (inheritInfo != null) { - String discCol = inheritInfo.getDiscriminatorColumn(); - if (Types.VARCHAR == inheritInfo.getDiscriminatorType()) { - mapping.add(new DocPropertyMapping(discCol, DocPropertyType.ENUM)); - } else { - mapping.add(new DocPropertyMapping(discCol, DocPropertyType.INTEGER)); - } - } - for (BeanProperty prop : propertiesNonTransient) { - prop.docStoreMapping(mapping, prefix); - } - if (inheritInfo != null) { - inheritInfo.visitChildren(inheritInfo1 -> { - for (BeanProperty localProperty : inheritInfo1.localProperties()) { - localProperty.docStoreMapping(mapping, prefix); - } - }); - } - } - /** * Return the root bean type if part of inheritance hierarchy. */ @@ -995,33 +905,6 @@ public String rootName() { return name; } - /** - * Return the type of DocStoreMode that should occur for this type of persist request - * given the transactions requested mode. - */ - public DocStoreMode docStoreMode(PersistRequest.Type persistType, DocStoreMode txnMode) { - return docStoreAdapter.mode(persistType, txnMode); - } - - public void docStoreInsert(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext bulkUpdate) throws IOException { - docStoreAdapter.insert(idValue, persistRequest, bulkUpdate); - } - - public void docStoreUpdate(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext bulkUpdate) throws IOException { - docStoreAdapter.update(idValue, persistRequest, bulkUpdate); - } - - /** - * Check if this update invalidates an embedded part of a doc store document. - */ - public void docStoreUpdateEmbedded(PersistRequestBean request, DocStoreUpdates docStoreUpdates) { - docStoreAdapter.updateEmbedded(request, docStoreUpdates); - } - - public void docStoreDeleteById(Object idValue, DocStoreUpdateContext txn) throws IOException { - docStoreAdapter.deleteById(idValue, txn); - } - /** * Prepare the query for multi-tenancy check for document store only use. */ @@ -1032,9 +915,6 @@ public void prepareQuery(SpiQuery query) { tenant.addTenant(query, tenantId); } } - if (isDocStoreOnly()) { - query.setUseDocStore(true); - } } /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java index e647aee934..942dd00c0b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -34,8 +34,6 @@ import io.ebeaninternal.server.properties.BeanPropertyAccess; import io.ebeaninternal.server.properties.EnhanceBeanPropertyAccess; import io.ebeaninternal.server.type.TypeManager; -import io.ebeanservice.docstore.api.DocStoreBeanAdapter; -import io.ebeanservice.docstore.api.DocStoreFactory; import javax.persistence.MappedSuperclass; import javax.persistence.PersistenceException; @@ -77,7 +75,6 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy private final ChangeLogListener changeLogListener; private final ChangeLogRegister changeLogRegister; private final ChangeLogPrepare changeLogPrepare; - private final DocStoreFactory docStoreFactory; private final MultiValueBind multiValueBind; private final TypeManager typeManager; private final BootupClasses bootupClasses; @@ -85,7 +82,6 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy private final List> elementDescriptors = new ArrayList<>(); private final Map, BeanTable> beanTableMap = new HashMap<>(); private final Map> descMap = new HashMap<>(); - private final Map> descQueueMap = new HashMap<>(); private final Map> beanManagerMap = new HashMap<>(); private final Map>> tableToDescMap = new HashMap<>(); private final Map>> tableToViewDescMap = new HashMap<>(); @@ -119,7 +115,6 @@ public BeanDescriptorManager(InternalConfiguration config) { this.config = config.getConfig(); this.serverName = InternString.intern(this.config.getName()); this.cacheManager = config.getCacheManager(); - this.docStoreFactory = config.getDocStoreFactory(); this.backgroundExecutor = config.getBackgroundExecutor(); this.dataSource = this.config.getDataSource(); this.encryptKeyManager = this.config.getEncryptKeyManager(); @@ -211,15 +206,6 @@ public DatabaseConfig config() { return config; } - @Override - public DocStoreBeanAdapter createDocStoreBeanAdapter(BeanDescriptor descriptor, DeployBeanDescriptor deploy) { - return docStoreFactory.createAdapter(descriptor, deploy); - } - - public BeanDescriptor descriptorByQueueId(String queueId) { - return descQueueMap.get(queueId); - } - @Override public SpiBeanType beanType(Class entityType) { return descriptor(entityType); @@ -553,9 +539,6 @@ public DeployBeanInfo deploy(Class cls) { private void registerDescriptor(DeployBeanInfo info) { BeanDescriptor desc = new BeanDescriptor<>(this, info.getDescriptor()); descMap.put(desc.type().getName(), desc); - if (desc.isDocStoreMapped()) { - descQueueMap.put(desc.docStoreQueueId(), desc); - } for (BeanPropertyAssocMany many : desc.propertiesMany()) { if (many.isElementCollection()) { elementDescriptors.add(many.elementDescriptor()); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorMap.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorMap.java index e5ba635210..57e6dbeaf6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorMap.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorMap.java @@ -7,7 +7,6 @@ import io.ebeaninternal.server.cache.SpiCacheManager; import io.ebeaninternal.server.deploy.id.IdBinder; import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; -import io.ebeanservice.docstore.api.DocStoreBeanAdapter; /** * Provides a method to find a BeanDescriptor. @@ -57,11 +56,6 @@ public interface BeanDescriptorMap { */ IdBinder createIdBinder(BeanProperty id); - /** - * Create a doc store specific adapter for this bean type. - */ - DocStoreBeanAdapter createDocStoreBeanAdapter(BeanDescriptor descriptor, DeployBeanDescriptor deploy); - /** * Return the scalarType for the given JDBC type. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java index 2d1e74edff..b830ebef13 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java @@ -36,10 +36,6 @@ import io.ebeaninternal.server.query.SqlJoinType; import io.ebeaninternal.server.type.*; import io.ebeaninternal.util.ValueUtil; -import io.ebeanservice.docstore.api.mapping.DocMappingBuilder; -import io.ebeanservice.docstore.api.mapping.DocPropertyMapping; -import io.ebeanservice.docstore.api.mapping.DocPropertyOptions; -import io.ebeanservice.docstore.api.support.DocStructure; import javax.persistence.PersistenceException; import java.io.DataInput; @@ -143,7 +139,6 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty { @SuppressWarnings("rawtypes") final ScalarType scalarType; - private final DocPropertyOptions docOptions; /** * The length or precision for DB column. */ @@ -235,7 +230,6 @@ public BeanProperty(BeanDescriptor descriptor, DeployBeanProperty deploy) { this.lob = isLobType(dbType); this.propertyType = deploy.getPropertyType(); this.field = deploy.getField(); - this.docOptions = deploy.getDocPropertyOptions(); this.elPlaceHolder = tableAliasIntern(descriptor, deploy.getElPlaceHolder(), false, null); this.elPlaceHolderEncrypted = tableAliasIntern(descriptor, deploy.getElPlaceHolder(), dbEncrypted, dbColumn); this.elPrefix = deploy.getElPrefix(); @@ -326,7 +320,6 @@ protected BeanProperty(BeanProperty source, BeanPropertyOverride override) { this.lob = isLobType(dbType); this.propertyType = source.type(); this.field = source.field(); - this.docOptions = source.docOptions; this.unmappedJson = source.unmappedJson; this.elPrefix = override.replace(source.elPrefix, source.dbColumn); this.elPlaceHolder = override.replace(source.elPlaceHolder, source.dbColumn); @@ -1283,15 +1276,6 @@ public String toString() { return name; } - /** - * Append this property to the document store based on includeByDefault setting. - */ - public void docStoreInclude(boolean includeByDefault, DocStructure docStructure) { - if (includeByDefault) { - docStructure.addProperty(name); - } - } - public boolean isJsonSerialize() { return jsonSerialize; } @@ -1401,24 +1385,6 @@ void diffVal(String prefix, Map map, Object newVal, Object ol } } - /** - * Add to the document mapping if this property is included for this index. - */ - public void docStoreMapping(DocMappingBuilder mapping, String prefix) { - if (mapping.includesProperty(prefix, name)) { - DocPropertyType type = scalarType.docType(); - DocPropertyOptions options = docOptions.copy(); - if (isKeywordType(type, options)) { - type = DocPropertyType.KEYWORD; - } - mapping.add(new DocPropertyMapping(name, type, options)); - } - } - - private boolean isKeywordType(DocPropertyType type, DocPropertyOptions docOptions) { - return type == DocPropertyType.TEXT && (docOptions.isCode() || id || discriminator); - } - public void merge(EntityBean bean, EntityBean existing) { // do nothing unless Many property } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java index b7434b0c10..966ef21774 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java @@ -24,9 +24,6 @@ import io.ebeaninternal.server.query.STreeType; import io.ebeaninternal.server.query.SqlJoinType; import io.ebeaninternal.server.querydefn.DefaultOrmQuery; -import io.ebeanservice.docstore.api.mapping.DocMappingBuilder; -import io.ebeanservice.docstore.api.mapping.DocPropertyMapping; -import io.ebeanservice.docstore.api.support.DocStructure; import javax.persistence.PersistenceException; import java.util.ArrayList; @@ -69,7 +66,6 @@ public abstract class BeanPropertyAssoc extends BeanProperty implements STree */ final BeanTable beanTable; final String mappedBy; - private final String docStoreDoc; private final String extraWhere; private final int fetchPreference; private boolean saveRecurseSkippable; @@ -83,7 +79,6 @@ public abstract class BeanPropertyAssoc extends BeanProperty implements STree this.extraWhere = InternString.intern(deploy.getExtraWhere()); this.beanTable = deploy.getBeanTable(); this.mappedBy = InternString.intern(deploy.getMappedBy()); - this.docStoreDoc = deploy.getDocStoreDoc(); this.tableJoin = new TableJoin(deploy.getTableJoin()); this.targetType = deploy.getTargetType(); this.cascadeInfo = deploy.getCascadeInfo(); @@ -100,7 +95,6 @@ public abstract class BeanPropertyAssoc extends BeanProperty implements STree extraWhere = source.extraWhere; beanTable = source.beanTable; mappedBy = source.mappedBy; - docStoreDoc = source.docStoreDoc; targetType = source.targetType; cascadeInfo = source.cascadeInfo; fetchPreference = source.fetchPreference; @@ -310,59 +304,6 @@ public String extraWhere() { return extraWhere; } - /** - * Return the elastic search doc for this embedded property. - */ - private String docStoreDoc() { - return docStoreDoc; - } - - /** - * Determine if and how the associated bean is included in the doc store document. - */ - @Override - public void docStoreInclude(boolean includeByDefault, DocStructure docStructure) { - String embeddedDoc = docStoreDoc(); - if (embeddedDoc == null) { - // not annotated so use include by default - // which is *ToOne included and *ToMany excluded - if (includeByDefault) { - docStoreIncludeByDefault(docStructure.doc()); - } - } else { - // explicitly annotated to be included - if (embeddedDoc.isEmpty()) { - embeddedDoc = "*"; - } - // add in a nested way - PathProperties embDoc = PathProperties.parse(embeddedDoc); - docStructure.addNested(name, embDoc); - } - } - - /** - * Include the property in the document store by default. - */ - void docStoreIncludeByDefault(PathProperties pathProps) { - pathProps.addToPath(null, name); - } - - @Override - public void docStoreMapping(DocMappingBuilder mapping, String prefix) { - if (mapping.includesPath(prefix, name)) { - String fullName = SplitName.add(prefix, name); - - DocPropertyType type = isMany() ? DocPropertyType.LIST : DocPropertyType.OBJECT; - DocPropertyMapping nested = new DocPropertyMapping(name, type); - mapping.push(nested); - targetDescriptor.docStoreMapping(mapping, fullName); - mapping.pop(); - if (!nested.children().isEmpty()) { - mapping.add(nested); - } - } - } - /** * Return true if this association is updateable. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java index f349ea253f..062af1529b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java @@ -177,11 +177,6 @@ public boolean isManyToManyWithHistory() { return manyToMany && !excludedFromHistory && descriptor.isHistorySupport(); } - @Override - protected void docStoreIncludeByDefault(PathProperties pathProps) { - // by default not including "Many" properties in document store - } - @Override public void registerColumn(BeanDescriptor desc, String prefix) { if (targetDescriptor != null) { @@ -343,13 +338,8 @@ public void lazyLoadMany(EntityBean current) { } } - public void addWhereParentIdIn(SpiQuery query, List parentIds, boolean useDocStore) { - if (useDocStore) { - // assumes the ManyToOne property is included - query.where().in(childMasterIdProperty, parentIds); - } else { - sqlHelp.addWhereParentIdIn(query, parentIds); - } + public void addWhereParentIdIn(SpiQuery query, List parentIds) { + sqlHelp.addWhereParentIdIn(query, parentIds); } /** @@ -873,10 +863,6 @@ public SpiSqlUpdate insertElementCollection() { return sqlHelp.insertElementCollection(); } - public boolean isTargetDocStoreMapped() { - return targetDescriptor.isDocStoreMapped(); - } - void jsonWriteMapEntry(SpiJsonWriter ctx, Map.Entry entry) throws IOException { if (elementDescriptor != null) { elementDescriptor.jsonWriteMapEntry(ctx, entry); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/DeployDocPropertyOptions.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/DeployDocPropertyOptions.java deleted file mode 100644 index 0ce3a87a52..0000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/DeployDocPropertyOptions.java +++ /dev/null @@ -1,78 +0,0 @@ -package io.ebeaninternal.server.deploy; - -import io.ebean.annotation.DocCode; -import io.ebean.annotation.DocProperty; -import io.ebean.annotation.DocSortable; -import io.ebeanservice.docstore.api.mapping.DocPropertyOptions; - -/** - * The options for document property collected when reading deployment mapping. - */ -public final class DeployDocPropertyOptions { - - private static final DocPropertyOptions EMPTY = new DocPropertyOptions(); - - private DocPropertyOptions mapping; - - private void createOptions() { - if (mapping == null) { - mapping = new DocPropertyOptions(); - } - } - - /** - * Read the DocProperty deployment options. - */ - public void setDocProperty(DocProperty doc) { - createOptions(); - mapping.apply(doc); - } - - /** - * Read the DocSortable deployment options. - */ - public void setDocSortable(DocSortable doc) { - createOptions(); - mapping.sortable(true); - setStore(doc.store()); - setBoost(doc.boost()); - setNullValue(doc.nullValue()); - } - - /** - * Read the DocCode deployment options. - */ - public void setDocCode(DocCode doc) { - createOptions(); - mapping.code(true); - setStore(doc.store()); - setBoost(doc.boost()); - setNullValue(doc.nullValue()); - } - - private void setNullValue(String value) { - if (!value.isEmpty()) { - mapping.nullValue(value); - } - } - - private void setBoost(float boost) { - if (Float.compare(boost, 1.0F) != 0) { - mapping.boost(boost); - } - } - - private void setStore(boolean store) { - if (store) { - mapping.store(true); - } - } - - /** - * Return the DocPropertyOptions with the collected options. - */ - public DocPropertyOptions create() { - return (mapping == null) ? EMPTY : mapping; - } - -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java index 45361f9e94..af8582dae3 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java @@ -102,19 +102,6 @@ public int compare(DeployBeanProperty o1, DeployBeanProperty o2) { private String dbComment; private PartitionMeta partitionMeta; private TablespaceMeta tablespaceMeta; - /** - * One of NONE, INDEX or EMBEDDED. - */ - private boolean docStoreMapped; - private DocStore docStore; - private PathProperties docStorePathProperties; - private String docStoreQueueId; - private String docStoreIndexName; - private String docStoreIndexType; - private DocStoreMode docStorePersist; - private DocStoreMode docStoreInsert; - private DocStoreMode docStoreUpdate; - private DocStoreMode docStoreDelete; private DeployBeanProperty idProperty; private TableJoin primaryKeyJoin; @@ -213,26 +200,6 @@ public TablespaceMeta getTablespaceMeta() { return tablespaceMeta; } - /** - * Read the top level doc store deployment information. - */ - public void readDocStore(DocStore docStore) { - - this.docStore = docStore; - docStoreMapped = true; - docStoreQueueId = docStore.queueId(); - docStoreIndexName = docStore.indexName(); - docStoreIndexType = docStore.indexType(); - docStorePersist = docStore.persist(); - docStoreInsert = docStore.insert(); - docStoreUpdate = docStore.update(); - docStoreDelete = docStore.delete(); - String doc = docStore.doc(); - if (!doc.isEmpty()) { - docStorePathProperties = PathProperties.parse(doc); - } - } - public boolean isScalaObject() { Class[] interfaces = beanType.getInterfaces(); for (Class anInterface : interfaces) { @@ -915,63 +882,6 @@ private void checkInheritance(Class beanType) { } } - public PathProperties getDocStorePathProperties() { - return docStorePathProperties; - } - - /** - * Return true if this type is mapped for a doc store. - */ - public boolean isDocStoreMapped() { - return docStoreMapped; - } - - public String getDocStoreQueueId() { - return docStoreQueueId; - } - - public String getDocStoreIndexName() { - return docStoreIndexName; - } - - public String getDocStoreIndexType() { - return docStoreIndexType; - } - - public DocStore getDocStore() { - return docStore; - } - - /** - * Return the DocStore index behavior for bean inserts. - */ - public DocStoreMode getDocStoreInsertEvent() { - return getDocStoreIndexEvent(docStoreInsert); - } - - /** - * Return the DocStore index behavior for bean updates. - */ - public DocStoreMode getDocStoreUpdateEvent() { - return getDocStoreIndexEvent(docStoreUpdate); - } - - /** - * Return the DocStore index behavior for bean deletes. - */ - public DocStoreMode getDocStoreDeleteEvent() { - return getDocStoreIndexEvent(docStoreDelete); - } - - private DocStoreMode getDocStoreIndexEvent(DocStoreMode mostSpecific) { - if (!docStoreMapped) { - return DocStoreMode.IGNORE; - } - if (mostSpecific != DocStoreMode.DEFAULT) return mostSpecific; - if (docStorePersist != DocStoreMode.DEFAULT) return docStorePersist; - return config.getDocStoreConfig().getPersist(); - } - /** * Parse the aggregation formula into expressions with table alias placeholders. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java index 9f517a7984..c0ab839d61 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java @@ -10,13 +10,11 @@ import io.ebeaninternal.server.core.InternString; import io.ebeaninternal.server.deploy.BeanProperty; import io.ebeaninternal.server.deploy.DbMigrationInfo; -import io.ebeaninternal.server.deploy.DeployDocPropertyOptions; import io.ebeaninternal.server.deploy.generatedproperty.GeneratedProperty; import io.ebeaninternal.server.el.ElPropertyValue; import io.ebeaninternal.server.properties.BeanPropertyGetter; import io.ebeaninternal.server.properties.BeanPropertySetter; import io.ebeaninternal.server.type.ScalarTypeWrapper; -import io.ebeanservice.docstore.api.mapping.DocPropertyOptions; import javax.persistence.EmbeddedId; import javax.persistence.FetchType; @@ -145,7 +143,6 @@ public class DeployBeanProperty { * The jdbc data type this maps to. */ private int dbType; - private final DeployDocPropertyOptions docMapping = new DeployDocPropertyOptions(); private int propertyIndex; private BeanPropertyGetter getter; private BeanPropertySetter setter; @@ -939,22 +936,6 @@ public String getDbComment() { return dbComment; } - public void setDocProperty(DocProperty docProperty) { - docMapping.setDocProperty(docProperty); - } - - public void setDocSortable(DocSortable docSortable) { - docMapping.setDocSortable(docSortable); - } - - public void setDocCode(DocCode docCode) { - docMapping.setDocCode(docCode); - } - - public DocPropertyOptions getDocPropertyOptions() { - return docMapping.create(); - } - /** * Return the DB Column default taking into account literal translation. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssoc.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssoc.java index 3461be3bd8..6ad7e33693 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssoc.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssoc.java @@ -33,7 +33,6 @@ public abstract class DeployBeanPropertyAssoc extends DeployBeanProperty { * From the deployment mappedBy attribute. */ private String mappedBy; - private String docStoreDoc; private int fetchPreference = 1000; private PropertyForeignKey foreignKey; boolean orphanRemoval; @@ -150,17 +149,6 @@ public boolean isOrphanRemoval() { return orphanRemoval; } - /** - * Set DocStoreEmbedded deployment information. - */ - public void setDocStoreEmbedded(String embeddedDoc) { - this.docStoreDoc = embeddedDoc; - } - - public String getDocStoreDoc() { - return docStoreDoc; - } - public int getFetchPreference() { return fetchPreference; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java index 97e3c3c8fb..028d132640 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java @@ -227,9 +227,6 @@ private void readPrimaryKeyJoin(PrimaryKeyJoinColumn primaryKeyJoin, DeployBeanP } private void readEmbedded(DeployBeanPropertyAssocOne prop, Embedded embedded) { - if (descriptor.isDocStoreOnly() && prop.getDocStoreDoc() == null) { - prop.setDocStoreEmbedded(""); - } prop.setEmbedded(); prop.setDbInsertable(true); prop.setDbUpdateable(true); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java index 1364f0c89c..1acee6f298 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java @@ -83,7 +83,6 @@ private void read(Class cls) { // maybe doc store only so check for this before @Entity DocStore docStore = typeGet(cls, DocStore.class); if (docStore != null) { - descriptor.readDocStore(docStore); descriptor.setEntityType(EntityType.DOC); descriptor.setName(cls.getSimpleName()); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java index d3f9c6a7dc..85991ddaad 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java @@ -78,17 +78,8 @@ private void readAssocOne(DeployBeanPropertyAssoc prop) { prop.setEmbedded(); info.setEmbeddedId(prop); } - DocEmbedded docEmbedded = get(prop, DocEmbedded.class); - if (docEmbedded != null) { - prop.setDocStoreEmbedded(docEmbedded.doc()); - if (descriptor.isDocStoreOnly()) { - if (has(prop, ManyToOne.class)) { - prop.setEmbedded(); - prop.setDbInsertable(true); - prop.setDbUpdateable(true); - } - } - } + // TODO: Not Supported - DocEmbedded docEmbedded = get(prop, DocEmbedded.class); + if (prop instanceof DeployBeanPropertyAssocOne) { if (prop.isId() && !prop.isEmbedded()) { prop.setEmbedded(); @@ -241,18 +232,10 @@ private void initDbJson(DeployBeanProperty prop) { } private void initFormula(DeployBeanProperty prop) { - DocCode docCode = get(prop, DocCode.class); - if (docCode != null) { - prop.setDocCode(docCode); - } - DocSortable docSortable = get(prop, DocSortable.class); - if (docSortable != null) { - prop.setDocSortable(docSortable); - } - DocProperty docProperty = get(prop, DocProperty.class); - if (docProperty != null) { - prop.setDocProperty(docProperty); - } + // TODO: Not Supported - DocCode docCode = get(prop, DocCode.class); + //DocSortable docSortable = get(prop, DocSortable.class); + //DocProperty docProperty = get(prop, DocProperty.class); + Formula formula = prop.getMetaAnnotationFormula(platform); if (formula != null) { prop.setSqlFormula(processFormula(formula.select()), processFormula(formula.join())); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractExpression.java index 08deef5ea2..dd74b230a7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractExpression.java @@ -1,7 +1,6 @@ package io.ebeaninternal.server.expression; import io.ebean.event.BeanQueryRequest; -import io.ebean.util.SplitName; import io.ebeaninternal.api.*; import io.ebeaninternal.server.deploy.BeanDescriptor; import io.ebeaninternal.server.el.ElPropertyDeploy; @@ -45,21 +44,6 @@ public SpiExpression copyForPlanKey() { return this; } - @Override - public String nestedPath(BeanDescriptor desc) { - return propertyNestedPath(propName, desc); - } - - protected String propertyNestedPath(String propertyName, BeanDescriptor desc) { - if (propertyName != null) { - ElPropertyDeploy elProp = desc.elPropertyDeploy(propertyName); - if (elProp != null && elProp.containsMany()) { - return SplitName.begin(propName); - } - } - return null; - } - @Override public void containsMany(BeanDescriptor desc, ManyWhereJoins manyWhereJoin) { propertyContainsMany(propName, desc, manyWhereJoin); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/AllEqualsExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/AllEqualsExpression.java index 4742f4c87c..2fa4fe9cd6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/AllEqualsExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/AllEqualsExpression.java @@ -21,16 +21,6 @@ String name(String propName) { return propName; } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeAllEquals(propMap); - } - - @Override - public String nestedPath(BeanDescriptor desc) { - return null; - } - @Override public void containsMany(BeanDescriptor desc, ManyWhereJoins manyWhereJoin) { if (propMap != null) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayContainsExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayContainsExpression.java index a50b484694..6633294d2f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayContainsExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayContainsExpression.java @@ -23,23 +23,6 @@ final class ArrayContainsExpression extends AbstractExpression { } } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - if (values.length == 1) { - context.writeEqualTo(propName, values[0]); - } else { - if (contains) { - context.startBoolMust(); - } else { - context.startBoolMustNot(); - } - for (Object value : values) { - context.writeEqualTo(propName, value); - } - context.endBool(); - } - } - @Override public void queryPlanHash(StringBuilder builder) { builder.append("ArrayContains[").append(propName) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayIsEmptyExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayIsEmptyExpression.java index 5c031f78ec..0a5d03549b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayIsEmptyExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayIsEmptyExpression.java @@ -4,8 +4,6 @@ import io.ebeaninternal.api.SpiExpression; import io.ebeaninternal.api.SpiExpressionRequest; -import java.io.IOException; - /** * IsEmpty expression for ARRAY type. */ @@ -18,11 +16,6 @@ final class ArrayIsEmptyExpression extends AbstractExpression { this.empty = empty; } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeExists(!empty, propName); - } - @Override public void queryPlanHash(StringBuilder builder) { if (empty) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenExpression.java index c2fd447790..80f5074194 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenExpression.java @@ -5,8 +5,6 @@ import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.el.ElPropertyValue; -import java.io.IOException; - final class BetweenExpression extends AbstractExpression { private static final String _BETWEEN = " between ? and ?"; @@ -28,11 +26,6 @@ private Object high() { return NamedParamHelp.value(valueHigh); } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeRange(propName, Op.GT_EQ, low(), Op.LT_EQ, high()); - } - @Override public void addBindValues(SpiExpressionRequest request) { ElPropertyValue prop = getElProp(request); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenPropertyExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenPropertyExpression.java index fed80ff635..e54ba41fb3 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenPropertyExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenPropertyExpression.java @@ -1,12 +1,9 @@ package io.ebeaninternal.server.expression; -import io.ebean.util.SplitName; import io.ebeaninternal.api.*; import io.ebeaninternal.server.deploy.BeanDescriptor; import io.ebeaninternal.server.el.ElPropertyDeploy; -import java.io.IOException; - /** * Between expression where a value is between two properties. */ @@ -38,24 +35,6 @@ private Object val() { return NamedParamHelp.value(value); } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.startBoolMust(); - context.writeSimple(Op.LT_EQ, lowProperty, val()); - context.writeSimple(Op.GT_EQ, highProperty, val()); - context.endBool(); - } - - @Override - public String nestedPath(BeanDescriptor desc) { - ElPropertyDeploy elProp = desc.elPropertyDeploy(name(lowProperty)); - if (elProp != null && elProp.containsMany()) { - // assumes highProperty is also nested property which seems reasonable - return SplitName.begin(lowProperty); - } - return null; - } - @Override public void containsMany(BeanDescriptor desc, ManyWhereJoins manyWhereJoin) { ElPropertyDeploy elProp = desc.elPropertyDeploy(name(lowProperty)); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BitwiseExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BitwiseExpression.java index 0f93dc73f8..b48319f5e8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BitwiseExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BitwiseExpression.java @@ -22,11 +22,6 @@ final class BitwiseExpression extends AbstractExpression { this.match = match; } - @Override - public void writeDocQuery(DocQueryContext context) { - throw new IllegalStateException("Not supported for document queries"); - } - @Override public void queryPlanHash(StringBuilder builder) { builder.append("Bitwise["); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/CaseInsensitiveEqualExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/CaseInsensitiveEqualExpression.java index ac98f1824b..0f7bcf7ba5 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/CaseInsensitiveEqualExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/CaseInsensitiveEqualExpression.java @@ -5,8 +5,6 @@ import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.el.ElPropertyValue; -import java.io.IOException; - final class CaseInsensitiveEqualExpression extends AbstractValueExpression { private final boolean not; @@ -23,15 +21,6 @@ private String val() { return strValue().toLowerCase(); } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - if (not) { - context.writeINotEqualTo(propName, val()); - } else { - context.writeIEqualTo(propName, val()); - } - } - @Override public void addBindValues(SpiExpressionRequest request) { ElPropertyValue prop = getElProp(request); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExampleExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExampleExpression.java index 7483a33358..dcad4745b9 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExampleExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExampleExpression.java @@ -15,7 +15,6 @@ import io.ebeaninternal.server.deploy.BeanProperty; import io.ebeaninternal.server.deploy.BeanPropertyAssocOne; -import java.io.IOException; import java.util.ArrayList; /** @@ -107,17 +106,6 @@ public void simplify() { // do nothing } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - if (!list.isEmpty()) { - context.startBoolMust(); - for (SpiExpression expr : list) { - expr.writeDocQuery(context); - } - context.endBool(); - } - } - @Override public Object getIdEqualTo(String idName) { // always return null for this expression @@ -129,11 +117,6 @@ public SpiExpression copyForPlanKey() { return new DefaultExampleExpression(list); } - @Override - public String nestedPath(BeanDescriptor desc) { - return null; - } - @Override public void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins) { list = buildExpressions(desc); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionFactory.java index 0a27709416..688b69dc4a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionFactory.java @@ -2,7 +2,6 @@ import io.ebean.*; import io.ebean.bean.EntityBean; -import io.ebean.search.*; import io.ebeaninternal.api.SpiExpressionFactory; import io.ebeaninternal.api.SpiQuery; @@ -40,31 +39,6 @@ public ExpressionList expressionList() { return new DefaultExpressionList<>(this); } - @Override - public Expression textMatch(String propertyName, String search, Match options) { - return new TextMatchExpression(propertyName, search, options); - } - - @Override - public Expression textMultiMatch(String query, MultiMatch options) { - return new TextMultiMatchExpression(query, options); - } - - @Override - public Expression textSimple(String search, TextSimple options) { - return new TextSimpleExpression(search, options); - } - - @Override - public Expression textQueryString(String search, TextQueryString options) { - return new TextQueryStringExpression(search, options); - } - - @Override - public Expression textCommonTerms(String search, TextCommonTerms options) { - return new TextCommonTermsExpression(search, options); - } - @Override public Expression jsonExists(String propertyName, String path) { return new JsonPathExpression(propertyName, path, Op.EXISTS, null); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java index 9d31c2aafe..0c34f48450 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java @@ -4,11 +4,9 @@ import io.avaje.lang.Nullable; import io.ebean.*; import io.ebean.event.BeanQueryRequest; -import io.ebean.search.*; import io.ebeaninternal.api.*; import io.ebeaninternal.server.deploy.BeanDescriptor; -import java.io.IOException; import java.sql.Connection; import java.sql.Timestamp; import java.util.*; @@ -27,29 +25,12 @@ public class DefaultExpressionList implements SpiExpressionList { protected final Query query; private final ExpressionList parentExprList; protected final ExpressionFactory expr; - String allDocNestedPath; - /** - * Set to true for the "Text" root expression list. - */ - private final boolean textRoot; - - /** - * Construct for Text root expression list - this handles implicit Bool Should, Must etc. - */ - public DefaultExpressionList(Query query) { - this(query, query.getExpressionFactory(), null, new ArrayList<>(), true); - } public DefaultExpressionList(Query query, ExpressionList parentExprList) { this(query, query.getExpressionFactory(), parentExprList, new ArrayList<>()); } DefaultExpressionList(Query query, ExpressionFactory expr, ExpressionList parentExprList, List list) { - this(query, expr, parentExprList, list, false); - } - - private DefaultExpressionList(Query query, ExpressionFactory expr, ExpressionList parentExprList, List list, boolean textRoot) { - this.textRoot = textRoot; this.list = list; this.query = query; this.expr = expr; @@ -64,23 +45,6 @@ private DefaultExpressionList() { this(null, null, null, new ArrayList<>()); } - /** - * Wrap the expression list as a Junction or top level DefaultExpressionList. - * - * @param list The list of expressions grouped by nested path - * @param nestedPath The doc store nested path - * @param type The junction type (or null for top level expression list). - * @return A single SpiExpression that has the nestedPath set - */ - SpiExpression wrap(List list, String nestedPath, Junction.Type type) { - DefaultExpressionList wrapper = new DefaultExpressionList<>(query, expr, null, list, false); - wrapper.setAllDocNested(nestedPath); - if (type != null) { - return new JunctionExpression<>(type, wrapper); - } else { - return wrapper; - } - } void simplifyEntries() { for (SpiExpression expr : list) { @@ -111,90 +75,6 @@ public void simplify() { simplifyEntries(); } - /** - * Write being aware if it is the Top level "text" expressions. - *

- * If this is the Top level "text" expressions then it detects if explicit or implicit Bool Should, Must etc is required - * to wrap the expressions. - *

- * If implicit Bool is required SHOULD is used. - */ - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - if (!textRoot) { - writeDocQuery(context, null); - - } else { - // this is a Top level "text" expressions, so we may need to wrap in Bool SHOULD etc. - if (list.isEmpty()) { - throw new IllegalStateException("empty expression list?"); - } - - if (allDocNestedPath != null) { - context.startNested(allDocNestedPath); - } - int size = list.size(); - SpiExpression first = list.get(0); - boolean explicitBool = first instanceof SpiJunction; - boolean implicitBool = !explicitBool && size > 1; - - if (implicitBool || explicitBool) { - context.startBoolGroup(); - } - if (implicitBool) { - context.startBoolGroupList(Junction.Type.SHOULD); - } - for (SpiExpression expr : list) { - if (explicitBool) { - try { - ((SpiJunction) expr).writeDocQueryJunction(context); - } catch (ClassCastException e) { - throw new IllegalStateException("The top level text() expressions should be all be 'Must', 'Should' or 'Must Not' or none of them should be.", e); - } - } else { - expr.writeDocQuery(context); - } - } - if (implicitBool) { - context.endBoolGroupList(); - } - if (implicitBool || explicitBool) { - context.endBoolGroup(); - } - if (allDocNestedPath != null) { - context.endNested(); - } - } - } - - @Override - public void writeDocQuery(DocQueryContext context, SpiExpression idEquals) throws IOException { - if (allDocNestedPath != null) { - context.startNested(allDocNestedPath); - } - int size = list.size(); - if (size == 1 && idEquals == null) { - // only 1 expression - skip bool - list.get(0).writeDocQuery(context); - } else if (size == 0 && idEquals != null) { - // only idEquals - skip bool - idEquals.writeDocQuery(context); - } else { - // bool must wrap all the children - context.startBoolMust(); - if (idEquals != null) { - idEquals.writeDocQuery(context); - } - for (SpiExpression expr : list) { - expr.writeDocQuery(context); - } - context.endBool(); - } - if (allDocNestedPath != null) { - context.endNested(); - } - } - @Override public SpiExpressionList trimPath(int prefixTrim) { throw new IllegalStateException("Only allowed on FilterExpressionList"); @@ -479,11 +359,6 @@ public Query setDistinct(boolean distinct) { return query.setDistinct(distinct); } - @Override - public Query setDocIndexName(String indexName) { - return query.setDocIndexName(indexName); - } - @Override public ExpressionList setFirstRow(int firstRow) { query.setFirstRow(firstRow); @@ -521,11 +396,6 @@ public Query setCountDistinct(CountDistinctOrder orderBy) { return query.setCountDistinct(orderBy); } - @Override - public Query setUseDocStore(boolean useDocsStore) { - return query.setUseDocStore(useDocsStore); - } - @Override public Query setDisableLazyLoading(boolean disableLazyLoading) { return query.setDisableLazyLoading(disableLazyLoading); @@ -596,12 +466,6 @@ public void prepareExpression(BeanQueryRequest request) { @Override public void queryPlanHash(StringBuilder builder) { builder.append("List["); - if (textRoot) { - builder.append("textRoot:true "); - } - if (allDocNestedPath != null) { - builder.append("path:").append(allDocNestedPath).append(' '); - } for (SpiExpression expr : list) { expr.queryPlanHash(builder); builder.append(','); @@ -1133,46 +997,6 @@ public ExpressionList startsWith(String propertyName, String value) { return add(expr.startsWith(propertyName, value)); } - @Override - public ExpressionList match(String propertyName, String search) { - return match(propertyName, search, null); - } - - @Override - public ExpressionList match(String propertyName, String search, Match options) { - setUseDocStore(true); - return add(expr.textMatch(propertyName, search, options)); - } - - @Override - public ExpressionList multiMatch(String query, String... fields) { - return multiMatch(query, MultiMatch.fields(fields)); - } - - @Override - public ExpressionList multiMatch(String query, MultiMatch options) { - setUseDocStore(true); - return add(expr.textMultiMatch(query, options)); - } - - @Override - public ExpressionList textSimple(String search, TextSimple options) { - setUseDocStore(true); - return add(expr.textSimple(search, options)); - } - - @Override - public ExpressionList textQueryString(String search, TextQueryString options) { - setUseDocStore(true); - return add(expr.textQueryString(search, options)); - } - - @Override - public ExpressionList textCommonTerms(String search, TextCommonTerms options) { - setUseDocStore(true); - return add(expr.textCommonTerms(search, options)); - } - protected Junction junction(Junction.Type type) { Junction junction = expr.junction(type, query, this); add(junction); @@ -1224,37 +1048,6 @@ public Junction disjunction() { return junction(Junction.Type.OR); } - @Override - public Junction must() { - setUseDocStore(true); - return junction(Junction.Type.MUST); - } - - @Override - public Junction should() { - setUseDocStore(true); - return junction(Junction.Type.SHOULD); - } - - @Override - public Junction mustNot() { - setUseDocStore(true); - return junction(Junction.Type.MUST_NOT); - } - - @Override - public String nestedPath(BeanDescriptor desc) { - // effectively handled by JunctionExpression - return null; - } - - /** - * Set the nested path that all contained expressions share. - */ - public void setAllDocNested(String allDocNestedPath) { - this.allDocNestedPath = allDocNestedPath; - } - /** * Replace the underlying expression list with one organised by nested path. */ @@ -1262,13 +1055,6 @@ public void setUnderlying(List groupedByNesting) { this.list = groupedByNesting; } - /** - * Prepare expressions for document store nested path handling. - */ - public void prepareDocNested(BeanDescriptor beanDescriptor) { - PrepareDocNested.prepare(this, beanDescriptor); - } - public Object idEqualTo(String idName) { if (idName == null) { return null; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DocQueryContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DocQueryContext.java deleted file mode 100644 index 4833534a11..0000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DocQueryContext.java +++ /dev/null @@ -1,177 +0,0 @@ -package io.ebeaninternal.server.expression; - -import io.ebean.Junction; -import io.ebean.LikeType; -import io.ebean.plugin.ExpressionPath; -import io.ebean.search.Match; -import io.ebean.search.MultiMatch; -import io.ebean.search.TextCommonTerms; -import io.ebean.search.TextQueryString; -import io.ebean.search.TextSimple; - -import java.io.IOException; -import java.util.Collection; -import java.util.Map; - -/** - * Context for writing a doc store query. - */ -public interface DocQueryContext { - - /** - * Start a junction. - */ - void startBool(Junction.Type type) throws IOException; - - /** - * Start a conjunction. - */ - void startBoolMust() throws IOException; - - /** - * Start a boolean NOT. - */ - void startBoolMustNot() throws IOException; - - /** - * End a bool expression/group. - */ - void endBool() throws IOException; - - /** - * Write a equalTo expression. - */ - void writeEqualTo(String propertyName, Object value) throws IOException; - - /** - * Write a case insensitive equalTo expression. - */ - void writeIEqualTo(String propName, String value) throws IOException; - - /** - * Write a case insensitive notEqualTo expression. - */ - default void writeINotEqualTo(String propName, String value) throws IOException { - throw new AbstractMethodError("writeINotEqualTo not implemented"); - } - - /** - * Write a range operation with one value. - */ - void writeRange(String propertyName, String rangeType, Object value) throws IOException; - - /** - * Write a range operation with a lower and upper values. - */ - void writeRange(String propertyName, Op lowOp, Object valueLow, Op highOp, Object valueHigh) throws IOException; - - /** - * Write an In expression. - */ - void writeIn(String propertyName, Object[] values, boolean not) throws IOException; - - /** - * Write an ID in expression. - */ - void writeIds(Collection idCollection) throws IOException; - - /** - * Write an Id equals expression. - */ - void writeId(Object value) throws IOException; - - /** - * Write a raw expression with bind values (might not be supported). - */ - void writeRaw(String raw, Object[] values) throws IOException; - - /** - * Write an exists expression. - */ - void writeExists(boolean notNull, String propertyName) throws IOException; - - /** - * Write one of the base expressions. - */ - void writeSimple(Op type, String propertyName, Object value) throws IOException; - - /** - * Write an all equals expression. - */ - void writeAllEquals(Map propMap) throws IOException; - - /** - * Write a Like expression. - */ - void writeLike(String propName, String val, LikeType type, boolean caseInsensitive) throws IOException; - - /** - * Write a Match expression. - */ - void writeMatch(String propName, String search, Match options) throws IOException; - - /** - * Write a Multi-match expression. - */ - void writeMultiMatch(String search, MultiMatch options) throws IOException; - - /** - * Write a simple expression. - */ - void writeTextSimple(String search, TextSimple options) throws IOException; - - /** - * Write a common terms expression. - */ - void writeTextCommonTerms(String search, TextCommonTerms options) throws IOException; - - /** - * Write a query string expression. - */ - void writeTextQueryString(String search, TextQueryString options) throws IOException; - - /** - * Start a Bool which may contain Must, Must Not, Should. - */ - void startBoolGroup() throws IOException; - - /** - * Start a Must, Must Not or Should list. - */ - void startBoolGroupList(Junction.Type type) throws IOException; - - /** - * End a Must, Must Not or Should list. - */ - void endBoolGroupList() throws IOException; - - /** - * End the Bool group. - */ - void endBoolGroup() throws IOException; - - /** - * Return the expression path for the given property path. - */ - ExpressionPath getExpressionPath(String propName); - - /** - * Start nested path expressions. - */ - void startNested(String nestedPath) throws IOException; - - /** - * End nested path expressions. - */ - void endNested() throws IOException; - - /** - * Start a not wrapping an expression. - */ - void startNot() throws IOException; - - /** - * End a not wrapper. - */ - void endNot() throws IOException; -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsQueryExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsQueryExpression.java index 81f00e49d5..fc51132a66 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsQueryExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsQueryExpression.java @@ -48,11 +48,6 @@ public void simplify() { // do nothing } - @Override - public void writeDocQuery(DocQueryContext context) { - throw new IllegalStateException("Not supported"); - } - @Override public Object getIdEqualTo(String idName) { // always return null for this expression @@ -119,11 +114,6 @@ public boolean isSameByBind(SpiExpression other) { return true; } - @Override - public String nestedPath(BeanDescriptor desc) { - return null; - } - @Override public void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins) { // Nothing to do for exists expression diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsSqlQueryExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsSqlQueryExpression.java index 497c417c69..9886f6872f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsSqlQueryExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsSqlQueryExpression.java @@ -34,11 +34,6 @@ public void simplify() { // do nothing } - @Override - public void writeDocQuery(DocQueryContext context) { - throw new IllegalStateException("Not supported"); - } - @Override public Object getIdEqualTo(String idName) { // always return null for this expression @@ -89,11 +84,6 @@ public boolean isSameByBind(SpiExpression other) { return Arrays.equals(bindParams, that.bindParams); } - @Override - public String nestedPath(BeanDescriptor desc) { - return null; - } - @Override public void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins) { // Nothing to do for exists expression diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdExpression.java index f66ecd0ab1..c5acd13094 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdExpression.java @@ -3,8 +3,6 @@ import io.ebeaninternal.api.*; import io.ebeaninternal.server.deploy.BeanDescriptor; -import java.io.IOException; - /** * Slightly redundant as Query.setId() ultimately also does the same job. */ @@ -21,16 +19,6 @@ public void prefixProperty(String path) { throw new IllegalStateException("Not allowed?"); } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeId(value); - } - - @Override - public String nestedPath(BeanDescriptor desc) { - return null; - } - /** * Always returns false. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdInExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdInExpression.java index 41805a82b5..587ea1722a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdInExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdInExpression.java @@ -6,7 +6,6 @@ import io.ebeaninternal.server.deploy.BeanDescriptor; import io.ebeaninternal.server.deploy.id.IdBinder; -import java.io.IOException; import java.util.*; /** @@ -41,20 +40,10 @@ public void prepareExpression(BeanQueryRequest request) { } } - @Override - public String nestedPath(BeanDescriptor desc) { - return null; - } - @Override public void containsMany(BeanDescriptor desc, ManyWhereJoins manyWhereJoin) { } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeIds(idCollection); - } - @Override public void validate(SpiExpressionValidation validation) { // always valid diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InExpression.java index e47fcf9258..648b4b5fc6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InExpression.java @@ -9,7 +9,6 @@ import io.ebeaninternal.server.el.ElPropertyValue; import io.ebeaninternal.server.persist.MultiValueWrapper; -import java.io.IOException; import java.util.*; public final class InExpression extends AbstractExpression implements IdInCommon { @@ -95,13 +94,6 @@ public void prepareExpression(BeanQueryRequest request) { } } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - if (!empty) { - context.writeIn(propName, values().toArray(), not); - } - } - @Override public void addBindValues(SpiExpressionRequest request) { if (empty) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InPairsExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InPairsExpression.java index e0c975ffe2..2296f69764 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InPairsExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InPairsExpression.java @@ -52,11 +52,6 @@ public void prepareExpression(BeanQueryRequest request) { multiValueSupported = request.isMultiValueSupported(String.class); } - @Override - public void writeDocQuery(DocQueryContext context) { - throw new RuntimeException("Not supported with document query"); - } - @Override public void addBindValues(SpiExpressionRequest request) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InRangeExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InRangeExpression.java index 47b5e6f4aa..11a48e377d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InRangeExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InRangeExpression.java @@ -5,8 +5,6 @@ import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.el.ElPropertyValue; -import java.io.IOException; - final class InRangeExpression extends AbstractExpression { private final Object valueHigh; @@ -26,11 +24,6 @@ private Object high() { return NamedParamHelp.value(valueHigh); } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeRange(propName, Op.GT_EQ, low(), Op.LT, high()); - } - @Override public void addBindValues(SpiExpressionRequest request) { ElPropertyValue prop = getElProp(request); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InTuplesExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InTuplesExpression.java index 8fa2fb8cbc..5662a2dc1f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InTuplesExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InTuplesExpression.java @@ -31,11 +31,6 @@ public boolean naturalKey(NaturalKeyQueryData data) { return false; } - @Override - public void writeDocQuery(DocQueryContext context) { - throw new RuntimeException("Not supported with document query"); - } - @Override public void addBindValues(SpiExpressionRequest request) { for (Object[] entry : entries) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IsEmptyExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IsEmptyExpression.java index 299961da92..0c79c43a5d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IsEmptyExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IsEmptyExpression.java @@ -8,8 +8,6 @@ import io.ebeaninternal.server.deploy.BeanDescriptor; import io.ebeaninternal.server.el.ElPropertyValue; -import java.io.IOException; - final class IsEmptyExpression extends AbstractExpression { private final boolean empty; @@ -22,32 +20,6 @@ final class IsEmptyExpression extends AbstractExpression { this.propertyPath = SplitName.split(propertyName)[0]; } - @Override - public String nestedPath(BeanDescriptor desc) { - if (empty) { - // capture the nestedPath as we want to put wrap - // a NOT around the outer of the nested path exists - this.nestedPath = propertyNestedPath(propName, desc); - return null; - } else { - return super.nestedPath(desc); - } - } - - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - if (nestedPath == null) { - context.writeExists(!empty, propName); - } else { - // wrap bool must not around the outside of nested path exists expression - context.startBoolMustNot(); - context.startNested(nestedPath); - context.writeExists(empty, propName); - context.endNested(); - context.endBool(); - } - } - public String getPropName() { return propName; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JsonPathExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JsonPathExpression.java index 07876e629a..7d343285b8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JsonPathExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JsonPathExpression.java @@ -4,7 +4,6 @@ import io.ebeaninternal.api.SpiExpression; import io.ebeaninternal.api.SpiExpressionRequest; -import java.io.IOException; import java.util.Objects; /** @@ -60,16 +59,6 @@ final class JsonPathExpression extends AbstractExpression { this.upperValue = upperValue; } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - String fullName = propName + "." + path; - if (operator == Op.BETWEEN) { - context.writeRange(fullName, Op.GT_EQ, value, Op.LT_EQ, upperValue); - } else { - context.writeSimple(operator, fullName, value); - } - } - @Override public void queryPlanHash(StringBuilder builder) { builder.append("JsonPath["); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java index fc88a030ba..acc26befce 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java @@ -4,7 +4,6 @@ import io.avaje.lang.Nullable; import io.ebean.*; import io.ebean.event.BeanQueryRequest; -import io.ebean.search.*; import io.ebeaninternal.api.*; import io.ebeaninternal.server.deploy.BeanDescriptor; @@ -81,24 +80,6 @@ public SpiExpression copyForPlanKey() { return new JunctionExpression<>(type, exprList.copyForPlanKey()); } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.startBool(type); - for (SpiExpression expr : exprList.internalList()) { - expr.writeDocQuery(context); - } - context.endBool(); - } - - @Override - public void writeDocQueryJunction(DocQueryContext context) throws IOException { - context.startBoolGroupList(type); - for (SpiExpression expr : exprList.internalList()) { - expr.writeDocQuery(context); - } - context.endBoolGroupList(); - } - @Override public Object getIdEqualTo(String idName) { // always null for this expression @@ -197,41 +178,6 @@ public boolean isSameByBind(SpiExpression other) { return type == that.type && exprList.isSameByBind(that.exprList); } - @Override - public ExpressionList match(String propertyName, String search) { - return match(propertyName, search, null); - } - - @Override - public ExpressionList match(String propertyName, String search, Match options) { - return exprList.match(propertyName, search, options); - } - - @Override - public ExpressionList multiMatch(String query, String... properties) { - return exprList.multiMatch(query, properties); - } - - @Override - public ExpressionList multiMatch(String query, MultiMatch options) { - return exprList.multiMatch(query, options); - } - - @Override - public ExpressionList textSimple(String search, TextSimple options) { - return exprList.textSimple(search, options); - } - - @Override - public ExpressionList textQueryString(String search, TextQueryString options) { - return exprList.textQueryString(search, options); - } - - @Override - public ExpressionList textCommonTerms(String search, TextCommonTerms options) { - return exprList.textCommonTerms(search, options); - } - @Override public ExpressionList allEq(Map propertyMap) { return exprList.allEq(propertyMap); @@ -945,11 +891,6 @@ public Query setDistinct(boolean distinct) { return exprList.setDistinct(distinct); } - @Override - public Query setDocIndexName(String indexName) { - return exprList.setDocIndexName(indexName); - } - @Override public ExpressionList setFirstRow(int firstRow) { return exprList.setFirstRow(firstRow); @@ -980,11 +921,6 @@ public Query setUseQueryCache(CacheMode useCache) { return exprList.setUseQueryCache(useCache); } - @Override - public Query setUseDocStore(boolean useDocsStore) { - return exprList.setUseDocStore(useDocsStore); - } - @Override public Query setDisableLazyLoading(boolean disableLazyLoading) { return exprList.setDisableLazyLoading(disableLazyLoading); @@ -1035,21 +971,6 @@ public Junction disjunction() { return exprList.disjunction(); } - @Override - public Junction must() { - return exprList.must(); - } - - @Override - public Junction should() { - return exprList.should(); - } - - @Override - public Junction mustNot() { - return exprList.mustNot(); - } - @Override public ExpressionList endJunction() { return exprList.endJunction(); @@ -1070,18 +991,6 @@ public ExpressionList endNot() { return endJunction(); } - @Override - public String nestedPath(BeanDescriptor desc) { - PrepareDocNested.prepare(exprList, desc, type); - String nestedPath = exprList.allDocNestedPath; - if (nestedPath != null) { - // push the nestedPath up to parent - exprList.setAllDocNested(null); - return nestedPath; - } - return null; - } - @Override public ExpressionList clear() { return exprList.clear(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/LikeExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/LikeExpression.java index c99c648aa7..a9c8137177 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/LikeExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/LikeExpression.java @@ -6,8 +6,6 @@ import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.el.ElPropertyValue; -import java.io.IOException; - final class LikeExpression extends AbstractValueExpression { private final boolean caseInsensitive; @@ -19,11 +17,6 @@ final class LikeExpression extends AbstractValueExpression { this.type = type; } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeLike(propName, strValue(), type, caseInsensitive); - } - @Override public void addBindValues(SpiExpressionRequest request) { ElPropertyValue prop = getElProp(request); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/LogicExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/LogicExpression.java index a98ac8166c..38128b8588 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/LogicExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/LogicExpression.java @@ -1,7 +1,6 @@ package io.ebeaninternal.server.expression; import io.ebean.Expression; -import io.ebean.Junction; import io.ebean.event.BeanQueryRequest; import io.ebeaninternal.api.BindValuesKey; import io.ebeaninternal.api.ManyWhereJoins; @@ -11,8 +10,6 @@ import io.ebeaninternal.api.SpiExpressionValidation; import io.ebeaninternal.server.deploy.BeanDescriptor; -import java.io.IOException; - /** * A logical And or, Or for joining two expressions. */ @@ -73,35 +70,6 @@ public void simplify() { // do nothing } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - - context.startBool(conjunction ? Junction.Type.AND : Junction.Type.OR); - expOne.writeDocQuery(context); - expTwo.writeDocQuery(context); - context.endBool(); - } - - @Override - public String nestedPath(BeanDescriptor desc) { - - String pathOne = expOne.nestedPath(desc); - String pathTwo = expTwo.nestedPath(desc); - - if (pathOne == null && pathTwo == null) { - return null; - } - if (pathOne != null && pathOne.equals(pathTwo)) { - return pathOne; - } - if (pathOne != null) { - expOne = new NestedPathWrapperExpression(pathOne, expOne); - } - if (pathTwo != null) { - expTwo = new NestedPathWrapperExpression(pathTwo, expTwo); - } - return null; - } @Override public Object getIdEqualTo(String idName) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NativeILikeExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NativeILikeExpression.java index ce960c3f4d..20692db75a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NativeILikeExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NativeILikeExpression.java @@ -6,8 +6,6 @@ import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.el.ElPropertyValue; -import java.io.IOException; - final class NativeILikeExpression extends AbstractExpression { private final String val; @@ -17,11 +15,6 @@ final class NativeILikeExpression extends AbstractExpression { this.val = value; } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeLike(propName, val, LikeType.RAW, true); - } - @Override public void addBindValues(SpiExpressionRequest request) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NestedPathWrapperExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NestedPathWrapperExpression.java deleted file mode 100644 index 72a495fd93..0000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NestedPathWrapperExpression.java +++ /dev/null @@ -1,110 +0,0 @@ -package io.ebeaninternal.server.expression; - -import io.ebean.event.BeanQueryRequest; -import io.ebeaninternal.api.BindValuesKey; -import io.ebeaninternal.api.ManyWhereJoins; -import io.ebeaninternal.api.SpiExpression; -import io.ebeaninternal.api.SpiExpressionRequest; -import io.ebeaninternal.api.SpiExpressionValidation; -import io.ebeaninternal.server.deploy.BeanDescriptor; -import io.ebeaninternal.api.NaturalKeyQueryData; - -import java.io.IOException; - -/** - * Wraps a single expression with nestedPath for document queries. - */ -final class NestedPathWrapperExpression implements SpiExpression { - - final String nestedPath; - final SpiExpression delegate; - - NestedPathWrapperExpression(String nestedPath, SpiExpression delegate) { - this.nestedPath = nestedPath; - this.delegate = delegate; - } - - @Override - public void prefixProperty(String path) { - // do nothing - } - - @Override - public boolean naturalKey(NaturalKeyQueryData data) { - // can't use naturalKey cache - return false; - } - - @Override - public void simplify() { - // do nothing - } - - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.startNested(nestedPath); - delegate.writeDocQuery(context); - context.endNested(); - } - - @Override - public Object getIdEqualTo(String idName) { - // always return null for this expression - return null; - } - - @Override - public String nestedPath(BeanDescriptor desc) { - return nestedPath; - } - - @Override - public void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins) { - delegate.containsMany(desc, whereManyJoins); - } - - @Override - public void prepareExpression(BeanQueryRequest request) { - delegate.prepareExpression(request); - } - - @Override - public void queryPlanHash(StringBuilder builder) { - builder.append("NestedPath["); - if (nestedPath != null) { - builder.append("path:").append(nestedPath).append(' '); - } - delegate.queryPlanHash(builder); - builder.append(']'); - } - - @Override - public void queryBindKey(BindValuesKey key) { - delegate.queryBindKey(key); - } - - @Override - public boolean isSameByBind(SpiExpression other) { - return delegate.isSameByBind(other); - } - - @Override - public void addSql(SpiExpressionRequest request) { - delegate.addSql(request); - } - - @Override - public void addBindValues(SpiExpressionRequest request) { - delegate.addBindValues(request); - } - - @Override - public void validate(SpiExpressionValidation validation) { - delegate.validate(validation); - } - - @Override - public SpiExpression copyForPlanKey() { - return new NestedPathWrapperExpression(nestedPath, delegate.copyForPlanKey()); - } -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NoopExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NoopExpression.java index da009c90e8..88f066ffdd 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NoopExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NoopExpression.java @@ -32,21 +32,12 @@ public SpiExpression copyForPlanKey() { return this; } - @Override - public void writeDocQuery(DocQueryContext context) { - } - @Override public Object getIdEqualTo(String idName) { // always return null for this expression return null; } - @Override - public String nestedPath(BeanDescriptor desc) { - return null; - } - @Override public void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins) { // nothing to do diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NotExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NotExpression.java index 6eae8b1fa1..5067bb856e 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NotExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NotExpression.java @@ -10,8 +10,6 @@ import io.ebeaninternal.api.SpiExpressionValidation; import io.ebeaninternal.server.deploy.BeanDescriptor; -import java.io.IOException; - final class NotExpression implements SpiExpression { private static final String NOT_START = "not ("; @@ -39,13 +37,6 @@ public void simplify() { // do nothing } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.startBoolMustNot(); - exp.writeDocQuery(context); - context.endBool(); - } - @Override public Object getIdEqualTo(String idName) { // always return null for this expression @@ -57,11 +48,6 @@ public SpiExpression copyForPlanKey() { return new NotExpression(exp.copyForPlanKey()); } - @Override - public String nestedPath(BeanDescriptor desc) { - return exp.nestedPath(desc); - } - @Override public void containsMany(BeanDescriptor desc, ManyWhereJoins manyWhereJoin) { exp.containsMany(desc, manyWhereJoin); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NullExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NullExpression.java index 7168f61c81..6bca006752 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NullExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NullExpression.java @@ -8,9 +8,6 @@ import io.ebeaninternal.server.deploy.BeanDescriptor; import io.ebeaninternal.server.el.ElPropertyValue; -import java.io.IOException; - - /** * Null / Not Null expression. *

@@ -45,11 +42,6 @@ public void containsMany(BeanDescriptor desc, ManyWhereJoins manyWhereJoin) { } } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeExists(notNull, propName); - } - @Override public void addBindValues(SpiExpressionRequest request) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/PrepareDocNested.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/PrepareDocNested.java deleted file mode 100644 index 2a73d64b30..0000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/PrepareDocNested.java +++ /dev/null @@ -1,159 +0,0 @@ -package io.ebeaninternal.server.expression; - -import io.ebean.Junction; -import io.ebeaninternal.api.SpiExpression; -import io.ebeaninternal.server.deploy.BeanDescriptor; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * Prepare nested path expressions for - */ -final class PrepareDocNested { - - /** - * Prepare the top level expressions for nested path handling. - */ - static void prepare(DefaultExpressionList expressions, BeanDescriptor beanDescriptor) { - new PrepareDocNested(expressions, beanDescriptor, null).process(); - } - - /** - * Prepare the Junction expressions for nested path handling. - */ - static void prepare(DefaultExpressionList expressions, BeanDescriptor beanDescriptor, Junction.Type type) { - new PrepareDocNested(expressions, beanDescriptor, type).process(); - } - - enum Mode { - NONE, - SINGLE, - MIXED - } - - private final Junction.Type type; - private final DefaultExpressionList original; - private final BeanDescriptor beanDescriptor; - private final List origUnderlying; - private final int origSize; - - private boolean hasNesting; - private boolean hasMixedNesting; - private String firstNestedPath; - - - PrepareDocNested(DefaultExpressionList original, BeanDescriptor beanDescriptor, Junction.Type type) { - this.type = type; - this.beanDescriptor = beanDescriptor; - this.original = original; - this.origUnderlying = original.underlyingList(); - this.origSize = origUnderlying.size(); - } - - void process() { - - PrepareDocNested.Mode mode = determineMode(); - if (mode == PrepareDocNested.Mode.SINGLE) { - original.setAllDocNested(firstNestedPath); - - } else if (mode == PrepareDocNested.Mode.MIXED) { - original.setUnderlying(group()); - } - - } - - /** - * Reorganise the flat list of expressions into a tree grouping expressions by nested path. - *

- * Returns the new top level list of expressions. - */ - private List group() { - - Map groups = new LinkedHashMap<>(); - - // organise expressions by nestedPath - for (int i = 0; i < origSize; i++) { - SpiExpression expr = origUnderlying.get(i); - String nestedPath = expr.nestedPath(beanDescriptor); - Group group = groups.computeIfAbsent(nestedPath, Group::new); - group.list.add(expr); - } - - List newList = new ArrayList<>(); - Collection values = groups.values(); - for (Group group : values) { - group.addTo(newList); - } - return newList; - } - - /** - * Determined the nested path mode. - */ - private Mode determineMode() { - - if (!hasNesting()) { - // no nested paths at all - return Mode.NONE; - } - if (!hasMixedNesting) { - // single nested path for all expressions - return Mode.SINGLE; - } - // mixed nested paths to underlying expression list needs re-organising by nested path - return Mode.MIXED; - } - - /** - * Return true if the expressions have nested paths. - */ - private boolean hasNesting() { - - for (int i = 0; i < origSize; i++) { - SpiExpression expr = origUnderlying.get(i); - String nestedPath = expr.nestedPath(beanDescriptor); - if (nestedPath == null) { - hasMixedNesting = true; - } - if (nestedPath != null) { - hasNesting = true; - if (firstNestedPath == null) { - firstNestedPath = nestedPath; - } else if (hasMixedNesting || !firstNestedPath.equals(nestedPath)) { - hasMixedNesting = true; - return true; - } - } - } - - return hasNesting; - } - - - /** - * List of SpiExpression grouped by nested path. - */ - class Group { - - final String nestedPath; - - final List list = new ArrayList<>(); - - Group(String nestedPath) { - this.nestedPath = nestedPath; - } - - void addTo(List newList) { - if (nestedPath == null) { - newList.addAll(list); - } else { - newList.add(original.wrap(list, nestedPath, type)); - } - } - } - -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/RawExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/RawExpression.java index db64b2ea7f..24312d9670 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/RawExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/RawExpression.java @@ -7,7 +7,6 @@ import io.ebeaninternal.server.deploy.DeployPropertyParser; import io.ebeaninternal.server.persist.MultiValueWrapper; -import java.io.IOException; import java.util.Collection; final class RawExpression extends NonPrepareExpression { @@ -21,16 +20,6 @@ final class RawExpression extends NonPrepareExpression { this.values = values; } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeRaw(sql, values); - } - - @Override - public String nestedPath(BeanDescriptor desc) { - return null; - } - @Override public void containsMany(BeanDescriptor desc, ManyWhereJoins manyWhereJoin) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/SimpleExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/SimpleExpression.java index 59bc76d039..7e8bab2370 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/SimpleExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/SimpleExpression.java @@ -8,9 +8,6 @@ import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.el.ElPropertyValue; -import java.io.IOException; -import java.util.Arrays; - public final class SimpleExpression extends AbstractValueExpression { private final Op type; @@ -37,24 +34,6 @@ public boolean naturalKey(NaturalKeyQueryData data) { return data.matchEq(propName, bindValue); } - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - if (type == Op.BETWEEN) { - throw new IllegalStateException("BETWEEN Not expected in SimpleExpression?"); - } - ExpressionPath prop = context.getExpressionPath(propName); - if (prop != null && prop.isAssocId()) { - String idName = prop.assocIdExpression(propName, ""); - Object[] ids = prop.assocIdValues((EntityBean) value()); - if (ids == null || ids.length != 1) { - throw new IllegalArgumentException("Expecting 1 Id value for " + idName + " but got " + Arrays.toString(ids)); - } - context.writeSimple(type, idName, ids[0]); - } else { - context.writeSimple(type, propName, value()); - } - } - public String getPropName() { return propName; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryExpression.java index 44adcbeb51..b4e240bcaf 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryExpression.java @@ -41,11 +41,6 @@ public void simplify() { // do nothing } - @Override - public void writeDocQuery(DocQueryContext context) { - throw new IllegalStateException("Not supported"); - } - @Override public void prepareExpression(BeanQueryRequest request) { CQuery subQuery = compileSubQuery(request); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryRawExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryRawExpression.java index d69cdc1bf8..7b2272bbc7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryRawExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryRawExpression.java @@ -22,11 +22,6 @@ final class SubQueryRawExpression extends AbstractExpression implements Unsuppor this.bindParams = bindParams; } - @Override - public void writeDocQuery(DocQueryContext context) { - throw new IllegalStateException("Not supported"); - } - @Override public void queryPlanHash(StringBuilder builder) { builder.append("SubQueryRaw[").append(propName).append(op.expression) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextCommonTermsExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextCommonTermsExpression.java deleted file mode 100644 index 3f289edb51..0000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextCommonTermsExpression.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.ebeaninternal.server.expression; - -import io.ebean.search.TextCommonTerms; - -import java.io.IOException; - -/** - * Full text common terms expression. - */ -final class TextCommonTermsExpression extends AbstractTextExpression { - - private final String search; - private final TextCommonTerms options; - - public TextCommonTermsExpression(String search, TextCommonTerms options) { - super(null); - this.search = search; - this.options = options; - } - - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeTextCommonTerms(search, options); - } - -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextMatchExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextMatchExpression.java deleted file mode 100644 index f7cb06e6a1..0000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextMatchExpression.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.ebeaninternal.server.expression; - -import io.ebean.search.Match; - -import java.io.IOException; - -/** - * Full text MATCH expression. - */ -final class TextMatchExpression extends AbstractTextExpression { - - private final String search; - private final Match options; - - TextMatchExpression(String propertyName, String search, Match options) { - super(propertyName); - this.search = search; - this.options = options; - } - - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeMatch(propName, search, options); - } - -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextMultiMatchExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextMultiMatchExpression.java deleted file mode 100644 index f9fe1e9093..0000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextMultiMatchExpression.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.ebeaninternal.server.expression; - -import io.ebean.search.MultiMatch; - -import java.io.IOException; - -/** - * Full text Multi-Match expression. - */ -final class TextMultiMatchExpression extends AbstractTextExpression { - - private final String search; - private final MultiMatch options; - - TextMultiMatchExpression(String search, MultiMatch options) { - super(null); - this.search = search; - this.options = options; - } - - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeMultiMatch(search, options); - } - -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextQueryStringExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextQueryStringExpression.java deleted file mode 100644 index dcd46a2404..0000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextQueryStringExpression.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.ebeaninternal.server.expression; - -import io.ebean.search.TextQueryString; - -import java.io.IOException; - -/** - * Full text query string expression. - */ -final class TextQueryStringExpression extends AbstractTextExpression { - - private final String search; - private final TextQueryString options; - - TextQueryStringExpression(String search, TextQueryString options) { - super(null); - this.search = search; - this.options = options; - } - - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeTextQueryString(search, options); - } - -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextSimpleExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextSimpleExpression.java deleted file mode 100644 index ec6702c2aa..0000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/TextSimpleExpression.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.ebeaninternal.server.expression; - -import io.ebean.search.TextSimple; - -import java.io.IOException; - -/** - * Full text Multi-Match expression. - */ -final class TextSimpleExpression extends AbstractTextExpression { - - private final String search; - private final TextSimple options; - - TextSimpleExpression(String search, TextSimple options) { - super(null); - this.search = search; - this.options = options; - } - - @Override - public void writeDocQuery(DocQueryContext context) throws IOException { - context.writeTextSimple(search, options); - } - -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java index 4b8e3d8dcd..444b6f9885 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java @@ -60,7 +60,7 @@ private void configureQuery(SpiQuery query, String lazyLoadProperty) { query.setBeanCacheMode(CacheMode.ON); } setLabel(query); - parent.propagateQueryState(query, desc.isDocStoreMapped()); + parent.propagateQueryState(query); query.setParentNode(objectGraphNode); query.setLazyLoadProperty(lazyLoadProperty); if (queryProps != null) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java index a74281a5aa..25626b9a91 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java @@ -31,7 +31,6 @@ public final class DLoadContext implements LoadContext { private final int defaultBatchSize; private final boolean disableLazyLoading; private final boolean includeSoftDeletes; - final boolean useDocStore; /** * The path relative to the root of the object graph. @@ -51,7 +50,6 @@ public final class DLoadContext implements LoadContext { * Construct for use with JSON marshalling (doc store). */ public DLoadContext(BeanDescriptor rootDescriptor, PersistenceContext persistenceContext) { - this.useDocStore = true; this.rootDescriptor = rootDescriptor; this.ebeanServer = rootDescriptor.ebeanServer(); this.persistenceContext = persistenceContext; @@ -82,7 +80,6 @@ public DLoadContext(OrmQueryRequest request, SpiQuerySecondary secondaryQueri this.rootDescriptor = request.descriptor(); SpiQuery query = request.query(); - this.useDocStore = query.isUseDocStore(); this.asOf = query.getAsOf(); this.includeSoftDeletes = query.isIncludeSoftDeletes() && query.mode() == SpiQuery.Mode.NORMAL; this.readOnly = query.isReadOnly(); @@ -310,10 +307,7 @@ private BeanProperty beanProperty(BeanDescriptor desc, String path) { /** * Propagate the original query settings (draft, asOf etc) to the secondary queries. */ - void propagateQueryState(SpiQuery query, boolean docStoreMapped) { - if (useDocStore && docStoreMapped) { - query.setUseDocStore(true); - } + void propagateQueryState(SpiQuery query) { if (readOnly != null) { query.setReadOnly(readOnly); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java index 945c77ec81..af7f7d52a7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java @@ -23,14 +23,12 @@ final class DLoadManyContext extends DLoadBaseContext implements LoadManyContext { private final BeanPropertyAssocMany property; - private final boolean docStoreMapped; private List bufferList; private LoadBuffer currentBuffer; DLoadManyContext(DLoadContext parent, BeanPropertyAssocMany property, String path, OrmQueryProperties queryProps) { super(parent, property.descriptor(), path, queryProps); this.property = property; - this.docStoreMapped = property.isTargetDocStoreMapped(); // bufferList only required when using query joins (queryFetch) this.bufferList = (!queryFetch) ? null : new ArrayList<>(); this.currentBuffer = createBuffer(batchSize); @@ -56,7 +54,7 @@ private void clear() { private void configureQuery(SpiQuery query) { setLabel(query); - parent.propagateQueryState(query, docStoreMapped); + parent.propagateQueryState(query); query.setParentNode(objectGraphNode); if (queryProps != null) { queryProps.configureBeanQuery(query); @@ -129,11 +127,6 @@ static abstract class LoadBuffer implements BeanCollectionLoader, LoadManyBuffer this.batchSize = batchSize; } - @Override - public boolean isUseDocStore() { - return context.parent.useDocStore && context.docStoreMapped; - } - @Override public int batchSize() { return batchSize; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/dml/DmlBeanPersisterFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/dml/DmlBeanPersisterFactory.java index c9b4cadea5..776f049f25 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/dml/DmlBeanPersisterFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/dml/DmlBeanPersisterFactory.java @@ -24,7 +24,7 @@ public DmlBeanPersisterFactory(DatabasePlatform dbPlatform) { @Override public BeanPersister create(BeanDescriptor desc) { if (desc.isDocStoreOnly()) { - return new DocStoreBeanPersister(GeneratedProperties.of(desc)); + return null; } UpdateMeta updMeta = metaFactory.createUpdate(desc); DeleteMeta delMeta = metaFactory.createDelete(desc); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/dml/DocStoreBeanPersister.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/dml/DocStoreBeanPersister.java deleted file mode 100644 index b805da26e0..0000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/dml/DocStoreBeanPersister.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.ebeaninternal.server.persist.dml; - -import io.ebeaninternal.server.core.PersistRequestBean; -import io.ebeaninternal.server.persist.BeanPersister; - -import javax.persistence.PersistenceException; - -/** - * Document store based BeanPersister. - */ -final class DocStoreBeanPersister implements BeanPersister { - - private final GeneratedProperties generatedProperties; - - DocStoreBeanPersister(GeneratedProperties generatedProperties) { - this.generatedProperties = generatedProperties; - } - - @Override - public void insert(PersistRequestBean request) throws PersistenceException { - //request.setIdValueForDocStore(); - generatedProperties.preInsert(request.entityBean(), request.now()); - request.docStorePersist(); - } - - @Override - public void update(PersistRequestBean request) throws PersistenceException { - generatedProperties.preUpdate(request.entityBean(), request.now()); - request.docStorePersist(); - } - - @Override - public int delete(PersistRequestBean request) throws PersistenceException { - request.docStorePersist(); - return 0; - } -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java index a6c7b54162..db78d2ccb3 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java @@ -170,11 +170,6 @@ public Query setPersistenceContextScope(PersistenceContextScope scope) { throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); } - @Override - public Query setDocIndexName(String indexName) { - throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); - } - @Override public ExpressionFactory getExpressionFactory() { throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); @@ -411,11 +406,6 @@ public ExpressionList where() { throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); } - @Override - public ExpressionList text() { - throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); - } - @Override public ExpressionList filterMany(String propertyName) { throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); @@ -491,11 +481,6 @@ public Query setUseQueryCache(CacheMode queryCacheMode) { throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); } - @Override - public Query setUseDocStore(boolean useDocStore) { - throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); - } - @Override public Query setReadOnly(boolean readOnly) { throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java index c82dde777d..f4614c1999 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -103,7 +103,6 @@ public class DefaultOrmQuery extends AbstractQuery implements SpiQuery { * Bind parameters when using the query language. */ private BindParams bindParams; - private DefaultExpressionList textExpressions; private DefaultExpressionList whereExpressions; private DefaultExpressionList havingExpressions; private boolean asOfBaseTable; @@ -147,8 +146,6 @@ public class DefaultOrmQuery extends AbstractQuery implements SpiQuery { private PersistenceContext persistenceContext; private ManyWhereJoins manyWhereJoins; private SpiRawSql rawSql; - private boolean useDocStore; - private String docIndexName; private OrmUpdateProperties updateProperties; private String nativeSql; private boolean orderById; @@ -255,17 +252,6 @@ public final boolean isAutoTunable() { return nativeSql == null && beanDescriptor.isAutoTunable(); } - @Override - public final Query setUseDocStore(boolean useDocStore) { - this.useDocStore = useDocStore; - return this; - } - - @Override - public final boolean isUseDocStore() { - return useDocStore; - } - @Override public final Query apply(FetchPath fetchPath) { fetchPath.apply(this); @@ -342,18 +328,6 @@ public final Query setIncludeSoftDeletes() { return this; } - @Override - public final Query setDocIndexName(String indexName) { - this.docIndexName = indexName; - this.useDocStore = true; - return this; - } - - @Override - public final String getDocIndexName() { - return docIndexName; - } - @Override public final SpiRawSql rawSql() { return rawSql; @@ -477,9 +451,7 @@ public final void setLazyLoadManyPath(String lazyLoadManyPath) { @Override public final SpiQuerySecondary convertJoins() { - if (!useDocStore) { - createExtraJoinsToSupportManyWhereClause(); - } + createExtraJoinsToSupportManyWhereClause(); markQueryJoins(); return new OrmQuerySecondary(removeQueryJoins(), removeLazyJoins()); } @@ -549,16 +521,6 @@ public final void setFilterMany(String prop, ExpressionList filterMany) { } } - @Override - public final void prepareDocNested() { - if (textExpressions != null) { - textExpressions.prepareDocNested(beanDescriptor); - } - if (whereExpressions != null) { - whereExpressions.prepareDocNested(beanDescriptor); - } - } - /** * Setup to be a delete or update query. */ @@ -1008,9 +970,6 @@ private String planDescription() { if (type != null) { sb.append(type.ordinal()); } - if (useDocStore) { - sb.append("/ds"); - } if (beanDescriptor.discValue() != null) { sb.append("/dv").append(beanDescriptor.discValue()); } @@ -1586,7 +1545,7 @@ public final void setArrayParameter(String name, Collection values) { @Override public final boolean checkPagingOrderBy() { - return orderById && !useDocStore; + return orderById; } @Override @@ -1783,15 +1742,6 @@ public final Query where(Expression expression) { return this; } - @Override - public final ExpressionList text() { - if (textExpressions == null) { - useDocStore = true; - textExpressions = new DefaultExpressionList<>(this); - } - return textExpressions; - } - @Override public final ExpressionList where() { if (whereExpressions == null) { @@ -1831,11 +1781,6 @@ public final SpiExpressionList whereExpressions() { return whereExpressions; } - @Override - public final SpiExpressionList textExpression() { - return textExpressions; - } - @Override public final String getGeneratedSql() { return generatedSql; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DeleteByIdMap.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DeleteByIdMap.java index 06b78861e6..a6c1348563 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DeleteByIdMap.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DeleteByIdMap.java @@ -1,11 +1,8 @@ package io.ebeaninternal.server.transaction; -import io.ebean.annotation.DocStoreMode; import io.ebeaninternal.server.cache.CacheChangeSet; import io.ebeaninternal.server.core.PersistRequest; import io.ebeaninternal.server.deploy.BeanDescriptor; -import io.ebeanservice.docstore.api.DocStoreUpdates; -import io.ebeanservice.docstore.api.support.DocStoreDeleteEvent; import java.util.Collection; import java.util.LinkedHashMap; @@ -67,28 +64,4 @@ private BeanPersistIds getPersistIds(BeanDescriptor desc) { return beanMap.computeIfAbsent(beanType, k -> new BeanPersistIds(desc)); } - /** - * Add the deletes to the DocStoreUpdates. - */ - void addDocStoreUpdates(DocStoreUpdates docStoreUpdates, DocStoreMode txnIndexMode) { - for (BeanPersistIds deleteIds : beanMap.values()) { - BeanDescriptor desc = deleteIds.getBeanDescriptor(); - DocStoreMode mode = desc.docStoreMode(PersistRequest.Type.DELETE, txnIndexMode); - if (DocStoreMode.IGNORE != mode) { - // Add to queue or bulk update entries - boolean queue = (DocStoreMode.QUEUE == mode); - String queueId = desc.docStoreQueueId(); - List idValues = deleteIds.getIds(); - if (idValues != null) { - for (Object idValue : idValues) { - if (queue) { - docStoreUpdates.queueDelete(queueId, idValue); - } else { - docStoreUpdates.addDelete(new DocStoreDeleteEvent(desc, idValue)); - } - } - } - } - } - } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DocStoreOnlyTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DocStoreOnlyTransaction.java deleted file mode 100644 index 03756be484..0000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DocStoreOnlyTransaction.java +++ /dev/null @@ -1,54 +0,0 @@ -package io.ebeaninternal.server.transaction; - -import java.sql.Connection; - -/** - * Document store only transaction. - */ -public final class DocStoreOnlyTransaction extends JdbcTransaction { - - /** - * Create a new DocStore only Transaction. - */ - public DocStoreOnlyTransaction(boolean explicit, TransactionManager manager) { - super(explicit, null, manager); - } - - @Override - public boolean isReadOnly() { - return false; - } - - @Override - public void setReadOnly(boolean readOnly) { - // do nothing - } - - @Override - protected void deactivate() { - // do nothing - } - - @Override - public Connection internalConnection() { - throw new RuntimeException("not supported on DocStoreTransaction"); - } - - @Override - public Connection connection() { - throw new RuntimeException("not supported on DocStoreTransaction"); - } - - @Override - protected void performRollback() { - // do nothing (could perhaps throw not supported exception) - } - - @Override - protected void performCommit() { - if (docStoreTxn != null) { - manager.docStoreUpdateProcessor.commit(docStoreTxn); - } - } - -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DocStoreTransactionManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DocStoreTransactionManager.java deleted file mode 100644 index 1e32c46ea7..0000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DocStoreTransactionManager.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.ebeaninternal.server.transaction; - -import io.ebeaninternal.api.SpiTransaction; - -import java.sql.Connection; - -/** - * Transaction manager used for doc store only EbeanServer instance. - *

- * There is no underlying JDBC DataSource etc - */ -public final class DocStoreTransactionManager extends TransactionManager { - - /** - * Create the TransactionManager - */ - public DocStoreTransactionManager(TransactionManagerOptions options) { - super(options); - } - - @Override - public SpiTransaction createTransaction(boolean explicit, int isolationLevel) { - return createTransaction(explicit, null); - } - - @Override - public SpiTransaction createReadOnlyTransaction(Object tenantId, boolean useMaster) { - return new DocStoreOnlyTransaction(false, this); - } - - @Override - protected SpiTransaction createTransaction(boolean explicit, Connection c) { - return new DocStoreOnlyTransaction(explicit, this); - } -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java index fd721e6c27..340aee829f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java @@ -9,7 +9,6 @@ import io.ebeaninternal.server.core.PersistDeferredRelationship; import io.ebeaninternal.server.core.PersistRequestBean; import io.ebeaninternal.server.persist.BatchControl; -import io.ebeanservice.docstore.api.DocStoreTransaction; import javax.persistence.PersistenceException; import java.sql.Connection; @@ -173,26 +172,6 @@ public void register(TransactionCallback callback) { throw new IllegalStateException(notExpectedMessage); } - @Override - public int getDocStoreBatchSize() { - return 0; - } - - @Override - public void setDocStoreBatchSize(int docStoreBatchSize) { - throw new IllegalStateException(notExpectedMessage); - } - - @Override - public DocStoreMode docStoreMode() { - return null; - } - - @Override - public void setDocStoreMode(DocStoreMode docStoreMode) { - throw new IllegalStateException(notExpectedMessage); - } - @Override public void registerDeferred(PersistDeferredRelationship derived) { throw new IllegalStateException(notExpectedMessage); @@ -631,11 +610,6 @@ public void addModification(String tableName, boolean inserts, boolean updates, throw new IllegalStateException(notExpectedMessage); } - @Override - public DocStoreTransaction docStoreTransaction() { - throw new IllegalStateException(notExpectedMessage); - } - @Override public void putUserObject(String name, Object value) { if (userObjects == null) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java index aa8a3b3572..0a2dda4e07 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java @@ -2,7 +2,6 @@ import io.ebean.ProfileLocation; import io.ebean.TransactionCallback; -import io.ebean.annotation.DocStoreMode; import io.ebean.config.DatabaseConfig; import io.ebean.event.changelog.BeanChange; import io.ebean.event.changelog.ChangeSet; @@ -11,7 +10,6 @@ import io.ebeaninternal.server.core.PersistRequestBean; import io.ebeaninternal.server.persist.BatchControl; import io.ebeaninternal.server.persist.BatchedSqlException; -import io.ebeanservice.docstore.api.DocStoreTransaction; import javax.persistence.PersistenceException; import javax.persistence.RollbackException; @@ -74,12 +72,6 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { private boolean batchOnCascadeSet; private TChangeLogHolder changeLogHolder; private List deferredList; - /** - * The mode for updating doc store indexes for this transaction. - * Only set when you want to override the default behavior. - */ - private DocStoreMode docStoreMode; - private int docStoreBatchSize; /** * Explicit control over skipCache. */ @@ -88,7 +80,6 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { * Default skip cache behavior from {@link DatabaseConfig#isSkipCacheAfterWrite()}. */ private final boolean skipCacheAfterWrite; - DocStoreTransaction docStoreTxn; private ProfileStream profileStream; private ProfileLocation profileLocation; private final long startNanos; @@ -298,26 +289,6 @@ private void firePostCommit() { } } - @Override - public final int getDocStoreBatchSize() { - return docStoreBatchSize; - } - - @Override - public final void setDocStoreBatchSize(int docStoreBatchSize) { - this.docStoreBatchSize = docStoreBatchSize; - } - - @Override - public final DocStoreMode docStoreMode() { - return docStoreMode; - } - - @Override - public final void setDocStoreMode(DocStoreMode docStoreMode) { - this.docStoreMode = docStoreMode; - } - @Override public final void registerDeferred(PersistDeferredRelationship derived) { if (deferredList == null) { @@ -1097,15 +1068,6 @@ public final void addModification(String tableName, boolean inserts, boolean upd event().add(tableName, inserts, updates, deletes); } - @Override - public final DocStoreTransaction docStoreTransaction() { - if (docStoreTxn == null) { - queryOnly = false; - docStoreTxn = manager.createDocStoreTransaction(docStoreBatchSize); - } - return docStoreTxn; - } - @Override public final void putUserObject(String name, Object value) { if (userObjects == null) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java index 76228f1f1a..84fe18d2fd 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java @@ -2,7 +2,6 @@ import io.ebean.ProfileLocation; import io.ebean.TransactionCallback; -import io.ebean.annotation.DocStoreMode; import io.ebean.event.changelog.BeanChange; import io.ebean.event.changelog.ChangeSet; import io.ebeaninternal.api.SpiPersistenceContext; @@ -12,7 +11,6 @@ import io.ebeaninternal.server.core.PersistDeferredRelationship; import io.ebeaninternal.server.core.PersistRequestBean; import io.ebeaninternal.server.persist.BatchControl; -import io.ebeanservice.docstore.api.DocStoreTransaction; import javax.persistence.PersistenceException; import java.sql.Connection; @@ -177,16 +175,6 @@ public Boolean isUpdateAllLoadedProperties() { return null; } - @Override - public DocStoreMode docStoreMode() { - return null; - } - - @Override - public int getDocStoreBatchSize() { - return 0; - } - @Override public void register(TransactionCallback callback) { } @@ -209,15 +197,6 @@ public boolean isRollbackOnly() { return false; } - - @Override - public void setDocStoreMode(DocStoreMode mode) { - } - - @Override - public void setDocStoreBatchSize(int batchSize) { - } - @Override public void setPersistCascade(boolean persistCascade) { } @@ -397,11 +376,6 @@ public void addBeanChange(BeanChange beanChange) { public void sendChangeLog(ChangeSet changeSet) { } - @Override - public DocStoreTransaction docStoreTransaction() { - return null; - } - @Override public void setTenantId(Object tenantId) { } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/PostCommitProcessing.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/PostCommitProcessing.java index ae9cd2ba20..abbe96b5c0 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/PostCommitProcessing.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/PostCommitProcessing.java @@ -1,6 +1,5 @@ package io.ebeaninternal.server.transaction; -import io.ebean.annotation.DocStoreMode; import io.ebeaninternal.api.CoreLog; import io.ebeaninternal.api.SpiTransaction; import io.ebeaninternal.api.TransactionEvent; @@ -9,7 +8,6 @@ import io.ebeaninternal.server.cache.CacheChangeSet; import io.ebeaninternal.server.cluster.ClusterManager; import io.ebeaninternal.server.core.PersistRequestBean; -import io.ebeanservice.docstore.api.DocStoreUpdates; import java.util.List; import java.util.Set; @@ -33,8 +31,6 @@ final class PostCommitProcessing { private final List> listenerNotify; private final RemoteTransactionEvent remoteTransactionEvent; private final DeleteByIdMap deleteByIdMap; - private final DocStoreMode txnDocStoreMode; - private final int txnDocStoreBatchSize; /** * Create for an external modification. @@ -43,8 +39,6 @@ final class PostCommitProcessing { this.clusterManager = clusterManager; this.manager = manager; this.serverName = manager.name(); - this.txnDocStoreMode = DocStoreMode.IGNORE; - this.txnDocStoreBatchSize = 0; this.event = event; this.deleteByIdMap = event.deleteByIdMap(); this.listenerNotify = event.listenerNotify(); @@ -58,8 +52,6 @@ final class PostCommitProcessing { this.clusterManager = clusterManager; this.manager = manager; this.serverName = manager.name(); - this.txnDocStoreMode = transaction.docStoreMode(); - this.txnDocStoreBatchSize = transaction.getDocStoreBatchSize(); this.event = transaction.event(); this.deleteByIdMap = event.deleteByIdMap(); this.listenerNotify = event.listenerNotify(); @@ -76,32 +68,6 @@ void notifyLocalCache() { } } - /** - * Process any document store updates. - */ - private void processDocStoreUpdates() { - if (isDocStoreUpdate()) { - // collect 'bulk update' and 'queue' events - DocStoreUpdates docStoreUpdates = new DocStoreUpdates(); - event.addDocStoreUpdates(docStoreUpdates); - if (deleteByIdMap != null) { - deleteByIdMap.addDocStoreUpdates(docStoreUpdates, txnDocStoreMode); - } - - if (!docStoreUpdates.isEmpty()) { - // send to docstore / ElasticSearch and/or queue - manager.processDocStoreUpdates(docStoreUpdates, txnDocStoreBatchSize); - } - } - } - - /** - * Return true if updates to the document store occur for this transaction. - */ - private boolean isDocStoreUpdate() { - return manager.isDocStoreActive() && (txnDocStoreMode == null || txnDocStoreMode != DocStoreMode.IGNORE); - } - private void notifyCluster() { if (remoteTransactionEvent != null && !remoteTransactionEvent.isEmpty()) { // send the interesting events to the cluster @@ -122,7 +88,6 @@ Runnable backgroundNotify() { } localPersistListenersNotify(); notifyCluster(); - processDocStoreUpdates(); }; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java index c0b0610fa2..214bcae46d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java @@ -25,9 +25,6 @@ import io.ebeaninternal.server.deploy.BeanDescriptorManager; import io.ebeaninternal.server.profile.TimedProfileLocation; import io.ebeaninternal.server.profile.TimedProfileLocationRegistry; -import io.ebeanservice.docstore.api.DocStoreTransaction; -import io.ebeanservice.docstore.api.DocStoreUpdateProcessor; -import io.ebeanservice.docstore.api.DocStoreUpdates; import javax.persistence.PersistenceException; import javax.sql.DataSource; @@ -75,12 +72,9 @@ public class TransactionManager implements SpiTransactionManager { private final BackgroundExecutor backgroundExecutor; private final ClusterManager clusterManager; private final String serverName; - private final boolean docStoreActive; - /** * The elastic search index update processor. */ - final DocStoreUpdateProcessor docStoreUpdateProcessor; private final boolean autoPersistUpdates; private final boolean persistBatch; private final boolean persistBatchOnCascade; @@ -130,8 +124,6 @@ public TransactionManager(TransactionManagerOptions options) { this.cacheNotify = options.cacheNotify; this.backgroundExecutor = options.backgroundExecutor; this.dataSourceSupplier = options.dataSourceSupplier; - this.docStoreActive = options.config.getDocStoreConfig().isActive(); - this.docStoreUpdateProcessor = options.docStoreUpdateProcessor; this.profileHandler = options.profileHandler; this.bulkEventListenerMap = new BulkEventListenerMap(options.config.getBulkTableEventListeners()); this.prefix = ""; @@ -210,14 +202,6 @@ final boolean isSupportsSavepointId() { return supportsSavepointId; } - final boolean isDocStoreActive() { - return docStoreActive; - } - - final DocStoreTransaction createDocStoreTransaction(int docStoreBatchSize) { - return docStoreUpdateProcessor.createTransaction(docStoreBatchSize); - } - final boolean isSkipCacheAfterWrite() { return skipCacheAfterWrite; } @@ -379,13 +363,6 @@ public final void remoteTransactionEvent(RemoteTransactionEvent remoteEvent) { changeSet.apply(); } - /** - * Process the docstore / ElasticSearch updates. - */ - final void processDocStoreUpdates(DocStoreUpdates docStoreUpdates, int bulkBatchSize) { - docStoreUpdateProcessor.process(docStoreUpdates, bulkBatchSize); - } - /** * Prepare and then send/log the changeSet. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java index b7d54b37e7..183a9ad540 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java @@ -9,7 +9,6 @@ import io.ebeaninternal.server.cluster.ClusterManager; import io.ebeaninternal.server.core.ClockService; import io.ebeaninternal.server.deploy.BeanDescriptorManager; -import io.ebeanservice.docstore.api.DocStoreUpdateProcessor; /** * Objects supplied for constructing the TransactionManager. @@ -22,7 +21,6 @@ public final class TransactionManagerOptions { final ClusterManager clusterManager; final BackgroundExecutor backgroundExecutor; - final DocStoreUpdateProcessor docStoreUpdateProcessor; final BeanDescriptorManager descMgr; final DataSourceSupplier dataSourceSupplier; final SpiProfileHandler profileHandler; @@ -34,7 +32,7 @@ public final class TransactionManagerOptions { public TransactionManagerOptions(SpiServer server, boolean notifyL2CacheInForeground, DatabaseConfig config, TransactionScopeManager scopeManager, ClusterManager clusterManager, - BackgroundExecutor backgroundExecutor, DocStoreUpdateProcessor docStoreUpdateProcessor, + BackgroundExecutor backgroundExecutor, BeanDescriptorManager descMgr, DataSourceSupplier dataSourceSupplier, SpiProfileHandler profileHandler, SpiLogManager logManager, TableModState tableModState, ServerCacheNotify cacheNotify, ClockService clockService) { this.server = server; @@ -43,7 +41,6 @@ public TransactionManagerOptions(SpiServer server, boolean notifyL2CacheInForegr this.scopeManager = scopeManager; this.clusterManager = clusterManager; this.backgroundExecutor = backgroundExecutor; - this.docStoreUpdateProcessor = docStoreUpdateProcessor; this.descMgr = descMgr; this.dataSourceSupplier = dataSourceSupplier; this.profileHandler = profileHandler; diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocQueryRequest.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocQueryRequest.java deleted file mode 100644 index d8548d1b2a..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocQueryRequest.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.ebeanservice.docstore.api; - -import io.ebean.docstore.DocQueryContext; -import io.ebean.text.json.JsonReadOptions; -import io.ebeaninternal.api.SpiQuery; -import io.ebeaninternal.api.SpiTransaction; - -/** - * A Query request for the document store. - */ -public interface DocQueryRequest extends DocQueryContext { - - /** - * Return the transaction for this request (can be null for document store only queries). - */ - SpiTransaction transaction(); - - /** - * Set the (document store) transaction to use for this query. - */ - void transaction(SpiTransaction transaction); - - /** - * Return the query for this request. - */ - SpiQuery query(); - - /** - * Create JsonReadOptions taking into account persistence context and lazy loading support. - */ - JsonReadOptions createJsonReadOptions(); - - /** - * Execute secondary queries. - */ - void executeSecondaryQueries(boolean forEach); - -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreBeanAdapter.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreBeanAdapter.java deleted file mode 100644 index a649dbf8f1..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreBeanAdapter.java +++ /dev/null @@ -1,128 +0,0 @@ -package io.ebeanservice.docstore.api; - -import io.ebean.Query; -import io.ebean.annotation.DocStoreMode; -import io.ebean.docstore.DocUpdateContext; -import io.ebean.plugin.BeanDocType; -import io.ebeaninternal.server.core.PersistRequest; -import io.ebeaninternal.server.core.PersistRequestBean; -import io.ebeanservice.docstore.api.mapping.DocumentMapping; - -import java.io.IOException; -import java.util.Set; - -/** - * Doc store specific adapter to process doc store events for a given bean type. - */ -public interface DocStoreBeanAdapter extends BeanDocType { - - /** - * In deployment phase read the embedded/nested document information. - */ - void registerPaths(); - - /** - * Register invalidation events for embedded/nested documents the given path and properties. - */ - void registerInvalidationPath(String queueId, String path, Set properties); - - /** - * Apply the document structure to the query so that it fetches the required properties to build - * the document (typically in JSON form). - */ - @Override - void applyPath(Query query); - - /** - * Return true if this type is mapped for doc storage. - */ - boolean mapped(); - - /** - * Return the unique queueId for this bean type. This is expected to be a relatively short unique - * string (rather than a fully qualified class name). - */ - String queueId(); - - /** - * Determine and return how this persist type will be processed given the transaction mode. - *

- * Some transactions (like bulk updates) might specifically turn off indexing for example. - */ - DocStoreMode mode(PersistRequest.Type persistType, DocStoreMode txnMode); - - /** - * Return the index type for this bean type. - */ - String indexType(); - - /** - * Return the index name for this bean type. - */ - @Override - String indexName(); - - /** - * Process a delete by id of a given document. - */ - @Override - void deleteById(Object idValue, DocUpdateContext txn) throws IOException; - - /** - * Process an index event which is effectively an insert or update (or put). - */ - @Override - void index(Object idValue, T entityBean, DocUpdateContext txn) throws IOException; - - /** - * Process an insert persist request. - */ - void insert(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext txn) throws IOException; - - /** - * Process an update persist request. - */ - void update(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext txn) throws IOException; - - /** - * Process the persist request adding any embedded/nested document invalidation to the docStoreUpdates. - *

- * This is expected to check the specific properties to see what other documents they are nested in - * and register invalidation events based on that. - * - * @param request The persist request - * @param docStoreUpdates Invalidation events are registered to this docStoreUpdates - */ - void updateEmbedded(PersistRequestBean request, DocStoreUpdates docStoreUpdates); - - /** - * Process an update of an embedded document. - * - * @param idValue the id of the bean effected by an embedded document update - * @param embeddedProperty the path of the property - * @param embeddedRawContent the embedded content for this property in JSON form - * @param txn the doc store transaction to use to process the update - */ - @Override - void updateEmbedded(Object idValue, String embeddedProperty, String embeddedRawContent, DocUpdateContext txn) throws IOException; - - /** - * Create the document mapping. - */ - DocumentMapping createDocMapping(); - - /** - * Return an un-analysed property to use instead of the given property. - *

- * For analysed properties that we want to sort on we will map the property to an additional - * 'raw' property that we can use for sorting etc. - *

- */ - @Override - String rawProperty(String property); - - /** - * Return true if this bean type as embedded invalidate registered. - */ - boolean hasEmbeddedInvalidation(); -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreFactory.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreFactory.java deleted file mode 100644 index 676fe3f103..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.ebeanservice.docstore.api; - -import io.ebean.plugin.SpiServer; -import io.ebeaninternal.server.deploy.BeanDescriptor; -import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; - -/** - * Creates the integration components for DocStore integration. - */ -public interface DocStoreFactory { - - /** - * Create and return the DocStore integration components. - */ - DocStoreIntegration create(SpiServer server); - - /** - * Create the doc store specific adapter for the given bean type. - */ - DocStoreBeanAdapter createAdapter(BeanDescriptor desc, DeployBeanDescriptor deploy); - -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreIntegration.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreIntegration.java deleted file mode 100644 index f4ed229a49..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreIntegration.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.ebeanservice.docstore.api; - -import io.ebean.DocumentStore; - -/** - * All the required features for DocStore integration. - */ -public interface DocStoreIntegration { - - /** - * Return the DocStoreUpdateProcessor to use. - */ - DocStoreUpdateProcessor updateProcessor(); - - /** - * Return the DocStore. - */ - DocumentStore documentStore(); - -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreQueryUpdate.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreQueryUpdate.java deleted file mode 100644 index 5d86fe050d..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreQueryUpdate.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.ebeanservice.docstore.api; - -import java.io.IOException; - -/** - * Update the document store using a Ebean ORM query. - *

- * Executes a forEach query and updates the document store with the bean object graph returned by the query. - *

- */ -public interface DocStoreQueryUpdate { - - /** - * Process the bean storing in the document store. - */ - void store(Object idValue, T bean) throws IOException; - - /** - * Flush the changes to the document store. - */ - void flush() throws IOException; - -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreTransaction.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreTransaction.java deleted file mode 100644 index a0f22f35da..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreTransaction.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.ebeanservice.docstore.api; - -/** - * A document store transaction. - *

- * This might just be a buffer to batch persist requests to the document store and may not - * support transactional semantics (like rollback). - */ -public interface DocStoreTransaction { - - /** - * Obtain a context to persist to (like a buffer). - */ - DocStoreUpdateContext obtain(); - - /** - * Add changes that should be queued to the DocStoreUpdates. - *

- * This mostly means nested/embedded updates that need to be processed after the source - * persist event has propagated. - *

- */ - DocStoreUpdates queue(); - - /** - * Flush all changes to the document store. - */ - void flush(); -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdate.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdate.java deleted file mode 100644 index 3408e47e24..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdate.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.ebeanservice.docstore.api; - -import java.io.IOException; - -/** - * For persist events that know how to publish or queue their change to the Document store. - */ -public interface DocStoreUpdate { - - /** - * Add the event to the doc store bulk update. - */ - void docStoreUpdate(DocStoreUpdateContext txn) throws IOException; - - /** - * Add to the queue for deferred processing. - */ - void addToQueue(DocStoreUpdates docStoreUpdates); -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdateContext.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdateContext.java deleted file mode 100644 index d04c4fdcd7..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdateContext.java +++ /dev/null @@ -1,13 +0,0 @@ -package io.ebeanservice.docstore.api; - -import io.ebean.docstore.DocUpdateContext; - -/** - * The doc store specific context/transaction used to collect updates to send to the document store. - *

- * Doc store specific implementations gather changes and bulk update the document store. - *

- */ -public interface DocStoreUpdateContext extends DocUpdateContext { - -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdateProcessor.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdateProcessor.java deleted file mode 100644 index 8f0d0b9ef6..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdateProcessor.java +++ /dev/null @@ -1,46 +0,0 @@ -package io.ebeanservice.docstore.api; - -import io.ebean.Transaction; -import io.ebean.plugin.BeanType; - -import java.io.IOException; - -/** - * Processes index updates. - *

- * This involves sending updates directly to ElasticSearch via it's Bulk API or - * queuing events for future processing. - *

- */ -public interface DocStoreUpdateProcessor { - - /** - * Create a processor to handle updates per bean via a findEach query. - */ - DocStoreQueryUpdate createQueryUpdate(BeanType beanType, int bulkBatchSize) throws IOException; - - /** - * Process all the updates for a transaction. - *

- * Typically this makes calls to the Bulk API of the document store or simply adds entries - * to a queue for future processing. - *

- * - * @param docStoreUpdates The 'Bulk' and 'Queue' updates to the indexes for the transaction. - * @param bulkBatchSize The batch size to use for Bulk API calls specified on the transaction. - * If this is 0 then the default batch size is used. - */ - void process(DocStoreUpdates docStoreUpdates, int bulkBatchSize); - - /** - * Create a document store transaction hinting at the batch size. - *

- * The batch size can be set via {@link Transaction#setDocStoreBatchSize(int)} - */ - DocStoreTransaction createTransaction(int batchSize); - - /** - * Perform commit/flush of the changes made via the document store transaction. - */ - void commit(DocStoreTransaction docStoreTransaction); -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdates.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdates.java deleted file mode 100644 index 5f8219077a..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocStoreUpdates.java +++ /dev/null @@ -1,115 +0,0 @@ -package io.ebeanservice.docstore.api; - -import io.ebean.DocStoreQueueEntry; -import io.ebean.DocStoreQueueEntry.Action; - -import java.util.ArrayList; -import java.util.List; - -/** - * Collection of document store updates that are either sent to the document store - * or queued for future processing - */ -public final class DocStoreUpdates { - - /** - * Persist inserts and updates. - */ - private final List persistEvents = new ArrayList<>(); - - /** - * Delete by Id. - */ - private final List deleteEvents = new ArrayList<>(); - - /** - * Nested updates. - */ - private final List nestedEvents = new ArrayList<>(); - - /** - * Entries sent to the queue for later processing. - */ - private final List queueEntries = new ArrayList<>(); - - public DocStoreUpdates() { - } - - /** - * Return true if there are no events to process. - */ - public boolean isEmpty() { - return persistEvents.isEmpty() && deleteEvents.isEmpty() && nestedEvents.isEmpty() && queueEntries.isEmpty(); - } - - /** - * Add a persist request. - */ - public void addPersist(DocStoreUpdate bulkRequest) { - persistEvents.add(bulkRequest); - } - - /** - * Add a delete request. - */ - public void addDelete(DocStoreUpdate bulkRequest) { - deleteEvents.add(bulkRequest); - } - - /** - * Add a nested update. - */ - public void addNested(String queueId, String path, Object beanId) { - nestedEvents.add(new DocStoreQueueEntry(Action.NESTED, queueId, path, beanId)); - } - - /** - * Queue an 'index' request. - */ - public void queueIndex(String queueId, Object beanId) { - queueEntries.add(new DocStoreQueueEntry(Action.INDEX, queueId, beanId)); - } - - /** - * Queue a 'delete' request. - */ - public void queueDelete(String queueId, Object beanId) { - queueEntries.add(new DocStoreQueueEntry(Action.DELETE, queueId, beanId)); - } - - /** - * Queue an update to a nested/embedded object. - */ - public void queueNested(String queueId, String path, Object beanId) { - queueEntries.add(new DocStoreQueueEntry(Action.NESTED, queueId, path, beanId)); - } - - /** - * Return the persist insert and update requests to be sent to the document store. - */ - public List persistEvents() { - return persistEvents; - } - - /** - * Return delete events. - */ - public List deleteEvents() { - return deleteEvents; - } - - /** - * Return the list of nested update events. - */ - public List nestedEvents() { - return nestedEvents; - } - - /** - * Return the entries for sending to the queue. - */ - public List queueEntries() { - return queueEntries; - } - -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocumentNotFoundException.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocumentNotFoundException.java deleted file mode 100644 index 0a926e42c2..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/DocumentNotFoundException.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.ebeanservice.docstore.api; - -/** - * Can be thrown when a document is unexpectedly not found in a document store. - */ -public class DocumentNotFoundException extends RuntimeException { - - private static final long serialVersionUID = 2066138180892685276L; - - /** - * Construct with a message. - */ - public DocumentNotFoundException(String message) { - super(message); - } - -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocMappingBuilder.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocMappingBuilder.java deleted file mode 100644 index c00de4be1d..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocMappingBuilder.java +++ /dev/null @@ -1,129 +0,0 @@ -package io.ebeanservice.docstore.api.mapping; - -import io.ebean.annotation.DocMapping; -import io.ebean.annotation.DocStore; -import io.ebean.text.PathProperties; -import io.ebean.util.SplitName; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Stack; - -/** - * Builds the DocumentMapping for a given bean type. - */ -public final class DocMappingBuilder { - - private final PathProperties paths; - private final DocStore docStore; - private final Stack properties = new Stack<>(); - private final Map map = new LinkedHashMap<>(); - - /** - * Create with the document structure paths and docStore deployment annotation. - */ - public DocMappingBuilder(PathProperties paths, DocStore docStore) { - this.paths = paths; - this.docStore = docStore; - this.properties.push(new DocPropertyMapping()); - } - - /** - * Return true if the property is included in the document. - */ - public boolean includesProperty(String prefix, String name) { - return paths.includesProperty(prefix, name); - } - - /** - * Return true if the path is included in the document. - */ - public boolean includesPath(String prefix, String name) { - return paths.includesProperty(prefix, name); - } - - /** - * Add the property mapping. - */ - public void add(DocPropertyMapping docMapping) { - DocPropertyMapping currentParent = properties.peek(); - currentParent.addChild(docMapping); - - String parentName = currentParent.name(); - String fullName = SplitName.add(parentName, docMapping.name()); - map.put(fullName, docMapping); - } - - /** - * Push the nested object or list onto the properties stack. - */ - public void push(DocPropertyMapping nested) { - properties.push(nested); - } - - /** - * Pop the nested object or list off the properties stack. - */ - public void pop() { - properties.pop(); - } - - /** - * Apply any override mappings from the top level docStore annotation. - */ - public void applyMapping() { - for (DocMapping docMapping : docStore.mapping()) { - applyFieldMapping(docMapping); - } - } - - private void applyFieldMapping(DocMapping docMapping) { - DocPropertyMapping mapping = map.get(docMapping.name()); - if (mapping == null) { - throw new IllegalStateException("DocMapping for [" + docMapping.name() + "] but property not included in document?"); - } - mapping.apply(docMapping); - } - - /** - * Collect the mapping of properties to 'raw' properties for those marked as sortable. - */ - public Map collectSortable() { - DocPropertyMapping peek = properties.peek(); - SortableVisitor visitor = new SortableVisitor(); - peek.visit(visitor); - return visitor.sortableMap(); - } - - /** - * Create the document mapping. - */ - public DocumentMapping create(String queueId, String indexName, String indexType) { - int shards = docStore.shards(); - int replicas = docStore.replicas(); - DocPropertyMapping root = properties.peek(); - return new DocumentMapping(queueId, indexName, indexType, paths, root, shards, replicas); - } - - - /** - * Find sortable properties to build the mapping to 'raw' properties. - */ - private static class SortableVisitor extends DocPropertyAdapter { - - private final Map sortableMap = new LinkedHashMap<>(); - - @Override - public void visitProperty(DocPropertyMapping property) { - DocPropertyOptions options = property.options(); - if (options != null && options.isSortable()) { - String fullPath = pathStack.peekFullPath(property.name()); - sortableMap.put(fullPath, fullPath + ".raw"); - } - } - - private Map sortableMap() { - return sortableMap; - } - } -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyAdapter.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyAdapter.java deleted file mode 100644 index 64b112c913..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyAdapter.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.ebeanservice.docstore.api.mapping; - -import io.ebeaninternal.server.json.PathStack; - -/** - * Adapter for DocPropertyVisitor that does not do anything. - * Used to extend and implement only the desired methods. - */ -public abstract class DocPropertyAdapter implements DocPropertyVisitor { - - protected final PathStack pathStack = new PathStack(); - - @Override - public void visitProperty(DocPropertyMapping property) { - // do nothing - } - - @Override - public void visitBegin() { - // do nothing - } - - @Override - public void visitEnd() { - // do nothing - } - - @Override - public void visitBeginObject(DocPropertyMapping property) { - pathStack.push(property.name()); - } - - @Override - public void visitEndObject(DocPropertyMapping property) { - pathStack.pop(); - } - - @Override - public void visitBeginList(DocPropertyMapping property) { - pathStack.push(property.name()); - } - - @Override - public void visitEndList(DocPropertyMapping property) { - pathStack.pop(); - } -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyMapping.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyMapping.java deleted file mode 100644 index 125616071c..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyMapping.java +++ /dev/null @@ -1,128 +0,0 @@ -package io.ebeanservice.docstore.api.mapping; - -import io.ebean.annotation.DocMapping; -import io.ebean.core.type.DocPropertyType; - -import java.util.ArrayList; -import java.util.List; - -/** - * Property mapping in a doc store document structure. - */ -public final class DocPropertyMapping { - - private String name; - private DocPropertyType type; - private DocPropertyOptions options; - private final List children = new ArrayList<>(); - - /** - * Construct ROOT. - */ - public DocPropertyMapping() { - this.type = DocPropertyType.ROOT; - } - - /** - * Construct property mapping. - */ - public DocPropertyMapping(String name, DocPropertyType type) { - this.type = type; - this.name = name; - this.options = new DocPropertyOptions(); - } - - /** - * Construct property mapping with options. - */ - public DocPropertyMapping(String name, DocPropertyType type, DocPropertyOptions options) { - this.name = name; - this.type = type; - this.options = options; - } - - /** - * Visit this property and any nested children. - */ - public void visit(DocPropertyVisitor visitor) { - switch (type) { - case ROOT: - visitor.visitBegin(); - visitChildren(visitor); - visitor.visitEnd(); - break; - case OBJECT: - visitor.visitBeginObject(this); - visitChildren(visitor); - visitor.visitEndObject(this); - break; - case LIST: - visitor.visitBeginList(this); - visitChildren(visitor); - visitor.visitEndList(this); - break; - default: - visitor.visitProperty(this); - } - } - - private void visitChildren(DocPropertyVisitor visitor) { - for (DocPropertyMapping property : children) { - property.visit(visitor); - } - } - - @Override - public String toString() { - return "name:" + name + " type:" + type + " options:" + options; - } - - /** - * Return the type of the property. - */ - public DocPropertyType type() { - return type; - } - - /** - * Set the type of the property. - */ - public void type(DocPropertyType type) { - this.type = type; - } - - /** - * Return the property name. - */ - public String name() { - return name; - } - - /** - * Return the property options. - */ - public DocPropertyOptions options() { - return options; - } - - /** - * Return the child nested properties. - */ - public List children() { - return children; - } - - /** - * Add a child property. - */ - public void addChild(DocPropertyMapping docMapping) { - children.add(docMapping); - } - - /** - * Apply mapping options to this property. - */ - public void apply(DocMapping docMapping) { - options.apply(docMapping); - } -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyOptions.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyOptions.java deleted file mode 100644 index 323cb80cd9..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyOptions.java +++ /dev/null @@ -1,247 +0,0 @@ -package io.ebeanservice.docstore.api.mapping; - -import io.ebean.annotation.DocMapping; -import io.ebean.annotation.DocProperty; - -/** - * Options for mapping a property for document storage. - */ -public final class DocPropertyOptions { - - private Boolean code; - private Boolean sortable; - private Boolean store; - private Float boost; - private String nullValue; - private Boolean includeInAll; - private Boolean enabled; - private Boolean norms; - private Boolean docValues; - private String analyzer; - private String searchAnalyzer; - private String copyTo; - private DocProperty.Option options; - - /** - * Construct with no values set. - */ - public DocPropertyOptions() { - } - - /** - * Construct as a copy of the source options. - */ - DocPropertyOptions(DocPropertyOptions source) { - this.code = source.code; - this.sortable = source.sortable; - this.store = source.store; - this.boost = source.boost; - this.nullValue = source.nullValue; - this.includeInAll = source.includeInAll; - this.analyzer = source.analyzer; - this.searchAnalyzer = source.searchAnalyzer; - this.options = source.options; - this.docValues = source.docValues; - this.norms = source.norms; - this.copyTo = source.copyTo; - this.enabled = source.enabled; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - if (code != null) { - sb.append("code:").append(code).append(' '); - } - if (sortable != null) { - sb.append("sortable:").append(sortable).append(' '); - } - if (store != null) { - sb.append("store:").append(store).append(' '); - } - if (boost != null) { - sb.append("boost:").append(boost).append(' '); - } - if (nullValue != null) { - sb.append("nullValue:").append(nullValue).append(' '); - } - return sb.toString(); - } - - public boolean isCode() { - return Boolean.TRUE.equals(code); - } - - public Boolean code() { - return code; - } - - public void code(Boolean code) { - this.code = code; - } - - public boolean isSortable() { - return Boolean.TRUE.equals(sortable); - } - - public Boolean sortable() { - return sortable; - } - - public void sortable(Boolean sortable) { - this.sortable = sortable; - } - - public Float boost() { - return boost; - } - - public void boost(Float boost) { - this.boost = boost; - } - - public String nullValue() { - return nullValue; - } - - public void nullValue(String nullValue) { - this.nullValue = nullValue; - } - - public Boolean store() { - return store; - } - - public void store(Boolean store) { - this.store = store; - } - - public Boolean includeInAll() { - return includeInAll; - } - - public void includeInAll(Boolean includeInAll) { - this.includeInAll = includeInAll; - } - - public Boolean docValues() { - return docValues; - } - - public void docValues(Boolean docValues) { - this.docValues = docValues; - } - - public String analyzer() { - return analyzer; - } - - public void analyzer(String analyzer) { - this.analyzer = analyzer; - } - - public String searchAnalyzer() { - return searchAnalyzer; - } - - public void searchAnalyzer(String searchAnalyzer) { - this.searchAnalyzer = searchAnalyzer; - } - - public String copyTo() { - return copyTo; - } - - public void copyTo(String copyTo) { - this.copyTo = copyTo; - } - - public Boolean enabled() { - return enabled; - } - - public void enabled(Boolean enabled) { - this.enabled = enabled; - } - - public Boolean norms() { - return norms; - } - - public void norms(Boolean norms) { - this.norms = norms; - } - - /** - * Return true if the index options is set to a non-default value. - */ - public boolean isOptionsSet() { - return options != null && options != DocProperty.Option.DEFAULT; - } - - public DocProperty.Option options() { - return options; - } - - public void options(DocProperty.Option options) { - this.options = options; - } - - /** - * Create a copy of this such that it can be overridden on a per index basis. - */ - public DocPropertyOptions copy() { - return new DocPropertyOptions(this); - } - - /** - * Apply override mapping from the document level or embedded property level. - */ - public void apply(DocMapping docMapping) { - apply(docMapping.options()); - } - - /** - * Apply the property level mapping options. - */ - public void apply(DocProperty docMapping) { - options = docMapping.options(); - if (docMapping.code()) { - code = true; - } - if (docMapping.sortable()) { - sortable = true; - } - if (docMapping.store()) { - store = true; - } - if (Float.compare(docMapping.boost(), 1.0F) != 0) { - boost = docMapping.boost(); - } - if (!"".equals(docMapping.nullValue())) { - nullValue = docMapping.nullValue(); - } - if (!docMapping.includeInAll()) { - includeInAll = false; - } - if (!docMapping.docValues()) { - docValues = false; - } - if (!docMapping.enabled()) { - enabled = false; - } - if (!docMapping.norms()) { - norms = false; - } - if (!"".equals(docMapping.analyzer())) { - analyzer = docMapping.analyzer(); - } - if (!"".equals(docMapping.searchAnalyzer())) { - searchAnalyzer = docMapping.searchAnalyzer(); - } - if (!"".equals(docMapping.copyTo())) { - copyTo = docMapping.copyTo(); - } - } - -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyVisitor.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyVisitor.java deleted file mode 100644 index dafdf4ebdd..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocPropertyVisitor.java +++ /dev/null @@ -1,43 +0,0 @@ -package io.ebeanservice.docstore.api.mapping; - -/** - * Used to visit the properties in a document structure. - */ -public interface DocPropertyVisitor { - - /** - * Begin visiting the document structure. - */ - void visitBegin(); - - /** - * Visit a property. - */ - void visitProperty(DocPropertyMapping property); - - /** - * Start visiting a nested object. - */ - void visitBeginObject(DocPropertyMapping property); - - /** - * End visiting a nested object. - */ - void visitEndObject(DocPropertyMapping property); - - /** - * Start visiting a nested list. - */ - void visitBeginList(DocPropertyMapping property); - - /** - * End visiting a nested list. - */ - void visitEndList(DocPropertyMapping property); - - /** - * Finished visiting the document structure. - */ - void visitEnd(); - -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocumentMapping.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocumentMapping.java deleted file mode 100644 index 533769ce56..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/DocumentMapping.java +++ /dev/null @@ -1,98 +0,0 @@ -package io.ebeanservice.docstore.api.mapping; - -import io.ebean.FetchPath; -import io.ebean.docstore.DocMapping; - -/** - * Mapping for a document stored in a doc store (like ElasticSearch). - */ -public final class DocumentMapping implements DocMapping { - - private final String queueId; - private final String name; - private final String type; - private final FetchPath paths; - private final DocPropertyMapping properties; - private int shards; - private int replicas; - - public DocumentMapping(String queueId, String name, String type, FetchPath paths, DocPropertyMapping properties, int shards, int replicas) { - this.queueId = queueId; - this.name = name; - this.type = type; - this.paths = paths; - this.properties = properties; - this.shards = shards; - this.replicas = replicas; - } - - /** - * Visit all the properties in the document structure. - */ - public void visit(DocPropertyVisitor visitor) { - properties.visit(visitor); - } - - /** - * Return the queueId. - */ - public String queueId() { - return queueId; - } - - /** - * Return the name. - */ - public String name() { - return name; - } - - /** - * Return the type. - */ - public String type() { - return type; - } - - /** - * Return the document structure as PathProperties. - */ - public FetchPath paths() { - return paths; - } - - /** - * Return the document structure with mapping details. - */ - public DocPropertyMapping properties() { - return properties; - } - - /** - * Return the number of shards. - */ - public int shards() { - return shards; - } - - /** - * Set the number of shards. - */ - public void shards(int shards) { - this.shards = shards; - } - - /** - * Return the number of replicas. - */ - public int replicas() { - return replicas; - } - - /** - * Set the number of replicas. - */ - public void replicas(int replicas) { - this.replicas = replicas; - } -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/package-info.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/package-info.java deleted file mode 100644 index 165d43611b..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/mapping/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Mapping for document store integration. - */ -package io.ebeanservice.docstore.api.mapping; diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/package-info.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/package-info.java deleted file mode 100644 index cb715c72d0..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * The service API for document store integration. - */ -package io.ebeanservice.docstore.api; diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java deleted file mode 100644 index 3fddd23cbc..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java +++ /dev/null @@ -1,333 +0,0 @@ -package io.ebeanservice.docstore.api.support; - -import io.ebean.FetchPath; -import io.ebean.Query; -import io.ebean.annotation.DocStore; -import io.ebean.annotation.DocStoreMode; -import io.ebean.docstore.DocUpdateContext; -import io.ebean.plugin.BeanType; -import io.ebean.text.PathProperties; -import io.ebeaninternal.api.SpiEbeanServer; -import io.ebeaninternal.server.core.PersistRequest; -import io.ebeaninternal.server.core.PersistRequestBean; -import io.ebeaninternal.server.deploy.BeanDescriptor; -import io.ebeaninternal.server.deploy.BeanProperty; -import io.ebeaninternal.server.deploy.InheritInfo; -import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; -import io.ebeanservice.docstore.api.DocStoreBeanAdapter; -import io.ebeanservice.docstore.api.DocStoreUpdateContext; -import io.ebeanservice.docstore.api.DocStoreUpdates; -import io.ebeanservice.docstore.api.mapping.DocMappingBuilder; -import io.ebeanservice.docstore.api.mapping.DocumentMapping; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Base implementation for much of DocStoreBeanAdapter. - */ -public abstract class DocStoreBeanBaseAdapter implements DocStoreBeanAdapter { - - protected final SpiEbeanServer server; - - /** - * The associated BeanDescriptor. - */ - protected final BeanDescriptor desc; - - /** - * The type of index. - */ - protected final boolean mapped; - - /** - * Identifier used in the queue system to identify the index. - */ - protected final String queueId; - - /** - * ElasticSearch index type. - */ - protected final String indexType; - - /** - * ElasticSearch index name. - */ - protected final String indexName; - - /** - * Doc store deployment annotation. - */ - private final DocStore docStore; - - /** - * Behavior on insert. - */ - protected final DocStoreMode insert; - - /** - * Behavior on update. - */ - protected DocStoreMode update; - - /** - * Behavior on delete. - */ - protected final DocStoreMode delete; - - /** - * List of embedded paths from other documents that include this document type. - * As such an update to this doc type means that those embedded documents need to be updated. - */ - protected final List embeddedInvalidation = new ArrayList<>(); - - protected final PathProperties pathProps; - - /** - * Map of properties to 'raw' properties. - */ - protected Map sortableMap; - - /** - * Nested path properties defining the doc structure for indexing. - */ - protected DocStructure docStructure; - - protected DocumentMapping documentMapping; - - private boolean registerPaths; - - public DocStoreBeanBaseAdapter(BeanDescriptor desc, DeployBeanDescriptor deploy) { - this.desc = desc; - this.server = desc.ebeanServer(); - this.mapped = deploy.isDocStoreMapped(); - this.pathProps = deploy.getDocStorePathProperties(); - this.docStore = deploy.getDocStore(); - this.queueId = derive(desc, deploy.getDocStoreQueueId()); - this.indexName = derive(desc, deploy.getDocStoreIndexName()); - this.indexType = derive(desc, deploy.getDocStoreIndexType()); - this.insert = deploy.getDocStoreInsertEvent(); - this.update = deploy.getDocStoreUpdateEvent(); - this.delete = deploy.getDocStoreDeleteEvent(); - } - - @Override - public boolean hasEmbeddedInvalidation() { - return !embeddedInvalidation.isEmpty(); - } - - @Override - public DocumentMapping createDocMapping() { - if (documentMapping != null) { - return documentMapping; - } - - if (!mapped) return null; - - this.docStructure = derivePathProperties(pathProps); - - DocMappingBuilder mappingBuilder = new DocMappingBuilder(docStructure.doc(), docStore); - desc.docStoreMapping(mappingBuilder, null); - mappingBuilder.applyMapping(); - - sortableMap = mappingBuilder.collectSortable(); - docStructure.prepareMany(desc); - documentMapping = mappingBuilder.create(queueId, indexName, indexType); - return documentMapping; - } - - @Override - public String indexType() { - return indexType; - } - - @Override - public String indexName() { - return indexName; - } - - @Override - public void applyPath(Query query) { - query.apply(docStructure.doc()); - } - - @Override - public String rawProperty(String property) { - String rawProperty = sortableMap.get(property); - return rawProperty == null ? property : rawProperty; - } - - /** - * Register invalidation paths for embedded documents. - */ - @Override - public void registerPaths() { - if (mapped && !registerPaths) { - Collection pathProps = docStructure.doc().getPathProps(); - for (PathProperties.Props pathProp : pathProps) { - String path = pathProp.getPath(); - if (path != null) { - BeanDescriptor targetDesc = desc.descriptor(path); - BeanProperty idProperty = targetDesc.idProperty(); - if (idProperty != null) { - // embedded beans don't have id property - String fullPath = path + "." + idProperty.name(); - targetDesc.docStoreAdapter().registerInvalidationPath(desc.docStoreQueueId(), fullPath, pathProp.getProperties()); - } - } - } - registerPaths = true; - } - } - - /** - * Register a doc store invalidation listener for the given bean type, path and properties. - */ - @Override - public void registerInvalidationPath(String queueId, String path, Set properties) { - if (!mapped) { - if (update == DocStoreMode.IGNORE) { - // bean type not mapped but is included as nested document - // in a doc store index so we need to update - update = DocStoreMode.UPDATE; - } - } - embeddedInvalidation.add(embeddedInvalidation(queueId, path, properties)); - } - - /** - * Return the DsInvalidationListener based on the properties, path. - */ - protected DocStoreEmbeddedInvalidation embeddedInvalidation(String queueId, String path, Set properties) { - if (properties.contains("*")) { - return new DocStoreEmbeddedInvalidation(queueId, path); - } else { - return new DocStoreEmbeddedInvalidationProperties(queueId, path, propertyPositions(properties)); - } - } - - /** - * Return the property names as property index positions. - */ - protected int[] propertyPositions(Set properties) { - List posList = new ArrayList<>(); - for (String property : properties) { - BeanProperty prop = desc.beanProperty(property); - if (prop != null) { - posList.add(prop.propertyIndex()); - } - } - int[] pos = new int[posList.size()]; - for (int i = 0; i < pos.length; i++) { - pos[i] = posList.get(i); - } - return pos; - } - - @Override - public void updateEmbedded(PersistRequestBean request, DocStoreUpdates docStoreUpdates) { - for (DocStoreEmbeddedInvalidation anEmbeddedInvalidation : embeddedInvalidation) { - anEmbeddedInvalidation.embeddedInvalidate(request, docStoreUpdates); - } - } - - /** - * Return the pathProperties which defines the JSON document to index. - * This can add derived/embedded/nested parts to the document. - */ - protected DocStructure derivePathProperties(PathProperties pathProps) { - boolean includeByDefault = (pathProps == null); - if (pathProps == null) { - pathProps = new PathProperties(); - } - return docStructure(pathProps, includeByDefault); - } - - protected DocStructure docStructure(PathProperties pathProps, final boolean includeByDefault) { - final DocStructure docStructure = new DocStructure(pathProps); - BeanProperty[] properties = desc.propertiesNonTransient(); - for (BeanProperty property : properties) { - property.docStoreInclude(includeByDefault, docStructure); - } - - InheritInfo inheritInfo = desc.inheritInfo(); - if (inheritInfo != null) { - inheritInfo.visitChildren(inheritInfo1 -> { - for (BeanProperty localProperty : inheritInfo1.localProperties()) { - localProperty.docStoreInclude(includeByDefault, docStructure); - } - }); - } - return docStructure; - } - - @Override - public FetchPath embedded(String path) { - return docStructure.embedded(path); - } - - @Override - public FetchPath embeddedManyRoot(String path) { - return docStructure.embeddedManyRoot(path); - } - - @Override - public boolean mapped() { - return mapped; - } - - @Override - public String queueId() { - return queueId; - } - - @Override - public DocStoreMode mode(PersistRequest.Type persistType, DocStoreMode txnMode) { - if (txnMode == null) { - return mode(persistType); - } else if (txnMode == DocStoreMode.IGNORE) { - return DocStoreMode.IGNORE; - } - return mapped ? txnMode : mode(persistType); - } - - private DocStoreMode mode(PersistRequest.Type persistType) { - switch (persistType) { - case INSERT: - return insert; - case UPDATE: - return update; - case DELETE: - return delete; - default: - return DocStoreMode.IGNORE; - } - } - - /** - * Return the supplied value or default to the bean name lower case. - */ - protected String derive(BeanType desc, String suppliedValue) { - return (suppliedValue != null && !suppliedValue.isEmpty()) ? suppliedValue : desc.name().toLowerCase(); - } - - @Override - public abstract void deleteById(Object idValue, DocUpdateContext txn) throws IOException; - - @Override - public abstract void index(Object idValue, T entityBean, DocUpdateContext txn) throws IOException; - - @Override - public abstract void insert(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext txn) throws IOException; - - @Override - public abstract void update(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext txn) throws IOException; - - @Override - public abstract void updateEmbedded(Object idValue, String embeddedProperty, String embeddedRawContent, DocUpdateContext txn) throws IOException; - -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreDeleteEvent.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreDeleteEvent.java deleted file mode 100644 index f5be5e6c9b..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreDeleteEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.ebeanservice.docstore.api.support; - -import io.ebean.plugin.BeanType; -import io.ebeanservice.docstore.api.DocStoreUpdate; -import io.ebeanservice.docstore.api.DocStoreUpdateContext; -import io.ebeanservice.docstore.api.DocStoreUpdates; - -import java.io.IOException; - -/** - * A 'Delete by Id' request that is send to the document store. - */ -public final class DocStoreDeleteEvent implements DocStoreUpdate { - - private final BeanType beanType; - private final Object idValue; - - public DocStoreDeleteEvent(BeanType beanType, Object idValue) { - this.beanType = beanType; - this.idValue = idValue; - } - - /** - * Add appropriate JSON content for sending to the ElasticSearch Bulk API. - */ - @Override - public void docStoreUpdate(DocStoreUpdateContext txn) throws IOException { - beanType.docStore().deleteById(idValue, txn); - } - - /** - * Add this event to the queue (for queue delayed processing). - */ - @Override - public void addToQueue(DocStoreUpdates docStoreUpdates) { - docStoreUpdates.queueDelete(beanType.docStoreQueueId(), idValue); - } -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreEmbeddedInvalidation.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreEmbeddedInvalidation.java deleted file mode 100644 index b96f1f8392..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreEmbeddedInvalidation.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.ebeanservice.docstore.api.support; - -import io.ebeaninternal.server.core.PersistRequestBean; -import io.ebeanservice.docstore.api.DocStoreUpdates; - -/** - * Checks if a persist request means an embedded/nested object in another document needs updating. - */ -public class DocStoreEmbeddedInvalidation { - - protected final String queueId; - protected final String path; - - public DocStoreEmbeddedInvalidation(String queueId, String path) { - this.queueId = queueId; - this.path = path; - } - - public void embeddedInvalidate(PersistRequestBean request, DocStoreUpdates docStoreUpdates) { - docStoreUpdates.addNested(queueId, path, request.beanId()); - } -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreEmbeddedInvalidationProperties.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreEmbeddedInvalidationProperties.java deleted file mode 100644 index 38f93a8a8a..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreEmbeddedInvalidationProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.ebeanservice.docstore.api.support; - -import io.ebeaninternal.server.core.PersistRequestBean; -import io.ebeanservice.docstore.api.DocStoreUpdates; - -/** - * Checks if a persist request means an embedded/nested object in another document needs updating. - *

- * This has specific properties to check (so not all properties invalidate). - */ -public final class DocStoreEmbeddedInvalidationProperties extends DocStoreEmbeddedInvalidation { - - /** - * Properties that trigger invalidation. - */ - private final int[] properties; - - public DocStoreEmbeddedInvalidationProperties(String queueId, String path, int[] properties) { - super(queueId, path); - this.properties = properties; - } - - @Override - public void embeddedInvalidate(PersistRequestBean request, DocStoreUpdates docStoreUpdates) { - if (request.hasDirtyProperty(properties)) { - docStoreUpdates.addNested(queueId, path, request.beanId()); - } - } - -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreIndexEvent.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreIndexEvent.java deleted file mode 100644 index e5df3e2acc..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStoreIndexEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.ebeanservice.docstore.api.support; - -import io.ebean.plugin.BeanType; -import io.ebeanservice.docstore.api.DocStoreUpdate; -import io.ebeanservice.docstore.api.DocStoreUpdateContext; -import io.ebeanservice.docstore.api.DocStoreUpdates; - -import java.io.IOException; - -/** - * A 'Delete by Id' request that is send to the document store. - */ -public final class DocStoreIndexEvent implements DocStoreUpdate { - - private final BeanType beanType; - private final Object idValue; - private final T bean; - - public DocStoreIndexEvent(BeanType beanType, Object idValue, T bean) { - this.beanType = beanType; - this.idValue = idValue; - this.bean = bean; - } - - /** - * Add appropriate JSON content for sending to the ElasticSearch Bulk API. - */ - @Override - public void docStoreUpdate(DocStoreUpdateContext txn) throws IOException { - beanType.docStore().index(idValue, bean, txn); - } - - /** - * Add this event to the queue (for queue delayed processing). - */ - @Override - public void addToQueue(DocStoreUpdates docStoreUpdates) { - docStoreUpdates.queueIndex(beanType.docStoreQueueId(), idValue); - } -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStructure.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStructure.java deleted file mode 100644 index ffc0942d99..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/DocStructure.java +++ /dev/null @@ -1,94 +0,0 @@ -package io.ebeanservice.docstore.api.support; - -import io.ebean.FetchPath; -import io.ebean.text.PathProperties; -import io.ebeaninternal.server.deploy.BeanDescriptor; -import io.ebeaninternal.server.deploy.BeanPropertyAssoc; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * Document structure for mapping to document store. - */ -public final class DocStructure { - - /** - * The full document structure. - */ - private final PathProperties doc; - - /** - * The embedded document structures by path. - */ - private final Map embedded = new HashMap<>(); - - private final Map manyRoot = new HashMap<>(); - - /** - * Create given an initial deployment doc mapping. - */ - public DocStructure(PathProperties pathProps) { - this.doc = pathProps; - } - - /** - * Add a property at the root level. - */ - public void addProperty(String name) { - doc.addToPath(null, name); - } - - /** - * Add an embedded property with it's document structure. - */ - public void addNested(String path, PathProperties embeddedDoc) { - doc.addNested(path, embeddedDoc); - embedded.put(path, embeddedDoc); - } - - /** - * Return the document structure. - */ - public PathProperties doc() { - return doc; - } - - /** - * Return the document structure for an embedded path. - */ - public FetchPath embedded(String path) { - return embedded.get(path); - } - - public FetchPath embeddedManyRoot(String path) { - return manyRoot.get(path); - } - - /** - * For 'many' nested properties we need an additional root based graph to fetch and update. - */ - public void prepareMany(BeanDescriptor desc) { - Set strings = embedded.keySet(); - for (String prop : strings) { - BeanPropertyAssoc embProp = (BeanPropertyAssoc) desc.findProperty(prop); - if (embProp.isMany()) { - prepare(prop, embProp); - } - } - } - - /** - * Add a PathProperties for an embedded 'many' property (at the root level). - */ - private void prepare(String prop, BeanPropertyAssoc embProp) { - BeanDescriptor targetDesc = embProp.targetDescriptor(); - - PathProperties manyRootPath = new PathProperties(); - manyRootPath.addToPath(null, targetDesc.idProperty().name()); - manyRootPath.addNested(prop, embedded.get(prop)); - - manyRoot.put(prop, manyRootPath); - } -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/package-info.java b/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/package-info.java deleted file mode 100644 index b2aa41e8e0..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/api/support/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Support objects for implementing integration. - */ -package io.ebeanservice.docstore.api.support; diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStore.java b/ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStore.java deleted file mode 100644 index a93f202bff..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStore.java +++ /dev/null @@ -1,111 +0,0 @@ -package io.ebeanservice.docstore.none; - -import io.avaje.lang.NonNullApi; -import io.ebean.DocStoreQueueEntry; -import io.ebean.DocumentStore; -import io.ebean.PagedList; -import io.ebean.Query; -import io.ebean.docstore.DocQueryContext; -import io.ebean.docstore.RawDoc; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; -import java.util.function.Predicate; - -/** - * DocumentStore that barfs it is used. - */ -@NonNullApi -public final class NoneDocStore implements DocumentStore { - - public static IllegalStateException implementationNotInClassPath() { - throw new IllegalStateException("DocStore implementation not included in the classPath. You need to add the maven dependency for io.ebean:ebean-elastic"); - } - - @Override - public void indexSettings(String indexName, Map settings) { - throw implementationNotInClassPath(); - } - - @Override - public void dropIndex(String newIndex) { - throw implementationNotInClassPath(); - } - - @Override - public void createIndex(String indexName, String alias) { - throw implementationNotInClassPath(); - } - - @Override - public void indexAll(Class countryClass) { - throw implementationNotInClassPath(); - } - - @Override - public long copyIndex(Class beanType, String newIndex) { - throw implementationNotInClassPath(); - } - - @Override - public long copyIndex(Class beanType, String newIndex, long epochMillis) { - throw implementationNotInClassPath(); - } - - @Override - public long copyIndex(Query query, String newIndex, int bulkBatchSize) { - throw implementationNotInClassPath(); - } - - @Override - public void indexByQuery(Query query) { - throw implementationNotInClassPath(); - } - - @Override - public void indexByQuery(Query query, int bulkBatchSize) { - throw implementationNotInClassPath(); - } - - @Override - public T find(DocQueryContext request) { - throw implementationNotInClassPath(); - } - - @Override - public PagedList findPagedList(DocQueryContext request) { - throw implementationNotInClassPath(); - } - - @Override - public List findList(DocQueryContext request) { - throw implementationNotInClassPath(); - } - - @Override - public void findEach(DocQueryContext query, Consumer consumer) { - throw implementationNotInClassPath(); - } - - @Override - public void findEachWhile(DocQueryContext query, Predicate consumer) { - throw implementationNotInClassPath(); - } - - @Override - public void findEach(String indexNameType, String rawQuery, Consumer consumer) { - throw implementationNotInClassPath(); - } - - @Override - public void findEachWhile(String indexNameType, String rawQuery, Predicate consumer) { - throw implementationNotInClassPath(); - } - - @Override - public long process(List queueEntries) throws IOException { - throw implementationNotInClassPath(); - } -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStoreBeanAdapter.java b/ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStoreBeanAdapter.java deleted file mode 100644 index 4449a91a80..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStoreBeanAdapter.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.ebeanservice.docstore.none; - -import io.ebean.docstore.DocUpdateContext; -import io.ebeaninternal.server.core.PersistRequestBean; -import io.ebeaninternal.server.deploy.BeanDescriptor; -import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; -import io.ebeanservice.docstore.api.DocStoreUpdateContext; -import io.ebeanservice.docstore.api.support.DocStoreBeanBaseAdapter; - -import java.io.IOException; - -/** - * DocStoreBeanBaseAdapter that barfs if it is used. - */ -public final class NoneDocStoreBeanAdapter extends DocStoreBeanBaseAdapter { - - public NoneDocStoreBeanAdapter(BeanDescriptor desc, DeployBeanDescriptor deploy) { - super(desc, deploy); - } - - @Override - public boolean mapped() { - return false; - } - - @Override - public void deleteById(Object idValue, DocUpdateContext txn) throws IOException { - throw NoneDocStore.implementationNotInClassPath(); - } - - @Override - public void index(Object idValue, T entityBean, DocUpdateContext txn) throws IOException { - throw NoneDocStore.implementationNotInClassPath(); - } - - @Override - public void insert(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext txn) throws IOException { - throw NoneDocStore.implementationNotInClassPath(); - } - - @Override - public void update(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext txn) throws IOException { - throw NoneDocStore.implementationNotInClassPath(); - } - - @Override - public void updateEmbedded(Object idValue, String embeddedProperty, String embeddedRawContent, DocUpdateContext txn) throws IOException { - throw NoneDocStore.implementationNotInClassPath(); - } -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStoreFactory.java b/ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStoreFactory.java deleted file mode 100644 index 8f0244cb59..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStoreFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.ebeanservice.docstore.none; - -import io.ebean.DocumentStore; -import io.ebean.plugin.SpiServer; -import io.ebeaninternal.server.deploy.BeanDescriptor; -import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; -import io.ebeanservice.docstore.api.DocStoreBeanAdapter; -import io.ebeanservice.docstore.api.DocStoreFactory; -import io.ebeanservice.docstore.api.DocStoreIntegration; -import io.ebeanservice.docstore.api.DocStoreUpdateProcessor; - -/** - * A stub implementation of DocStoreFactory that will barf if the docStore features are used. - */ -public final class NoneDocStoreFactory implements DocStoreFactory { - - @Override - public DocStoreIntegration create(SpiServer server) { - return new NoneIntegration(); - } - - @Override - public DocStoreBeanAdapter createAdapter(BeanDescriptor desc, DeployBeanDescriptor deploy) { - return new NoneDocStoreBeanAdapter<>(desc, deploy); - } - - static final class NoneIntegration implements DocStoreIntegration { - - @Override - public DocStoreUpdateProcessor updateProcessor() { - return new NoneDocStoreUpdateProcessor(); - } - - @Override - public DocumentStore documentStore() { - return new NoneDocStore(); - } - } -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStoreUpdateProcessor.java b/ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStoreUpdateProcessor.java deleted file mode 100644 index b6a642718c..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/none/NoneDocStoreUpdateProcessor.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.ebeanservice.docstore.none; - -import io.ebean.plugin.BeanType; -import io.ebeanservice.docstore.api.DocStoreQueryUpdate; -import io.ebeanservice.docstore.api.DocStoreTransaction; -import io.ebeanservice.docstore.api.DocStoreUpdateProcessor; -import io.ebeanservice.docstore.api.DocStoreUpdates; - -import java.io.IOException; - -/** - * DocStoreUpdateProcessor that barfs if it is used. - */ -final class NoneDocStoreUpdateProcessor implements DocStoreUpdateProcessor { - - @Override - public DocStoreQueryUpdate createQueryUpdate(BeanType beanType, int bulkBatchSize) throws IOException { - throw NoneDocStore.implementationNotInClassPath(); - } - - @Override - public void process(DocStoreUpdates docStoreUpdates, int bulkBatchSize) { - throw NoneDocStore.implementationNotInClassPath(); - } - - @Override - public DocStoreTransaction createTransaction(int batchSize) { - throw NoneDocStore.implementationNotInClassPath(); - } - - @Override - public void commit(DocStoreTransaction docStoreTransaction) { - throw NoneDocStore.implementationNotInClassPath(); - } -} diff --git a/ebean-core/src/main/java/io/ebeanservice/docstore/none/package-info.java b/ebean-core/src/main/java/io/ebeanservice/docstore/none/package-info.java deleted file mode 100644 index 1fc269f3bd..0000000000 --- a/ebean-core/src/main/java/io/ebeanservice/docstore/none/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * "No op" implementation of document store. - *

- * This is 'placeholder' implementation used if there is no document store service found - * and if there is an attempt to use the document store features an error will be thrown. - *

- */ -package io.ebeanservice.docstore.none; diff --git a/ebean-core/src/main/java/module-info.java b/ebean-core/src/main/java/module-info.java index 1911da3549..3e7932e0f9 100644 --- a/ebean-core/src/main/java/module-info.java +++ b/ebean-core/src/main/java/module-info.java @@ -10,7 +10,6 @@ uses io.ebean.core.type.ExtraTypeFactory; uses io.ebean.core.type.ScalarTypeSetFactory; uses io.ebean.core.type.ScalarJsonMapper; - uses io.ebeanservice.docstore.api.DocStoreFactory; uses io.ebean.migration.auto.AutoMigrationRunner; uses io.avaje.classpath.scanner.ClassPathScannerFactory; uses io.ebeaninternal.api.SpiLoggerFactory; @@ -40,10 +39,6 @@ exports io.ebeaninternal.server.cache; - exports io.ebeanservice.docstore.api; - exports io.ebeanservice.docstore.api.support to io.ebean.elastic, io.ebean.test; - exports io.ebeanservice.docstore.api.mapping to io.ebean.elastic; - exports io.ebeaninternal.api to io.ebean.ddl.generator, io.ebean.querybean, io.ebean.autotune, io.ebean.postgis, io.ebean.test, io.ebean.elastic, io.ebean.spring.txn; exports io.ebeaninternal.api.json to io.ebean.test; exports io.ebeaninternal.json to io.ebean.test; diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptorTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptorTest.java index 89f77d70b6..29c1e19140 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptorTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptorTest.java @@ -6,7 +6,6 @@ import io.ebeaninternal.server.core.CacheOptions; import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; import io.ebeaninternal.server.deploy.meta.DeployIdentityMode; -import io.ebeanservice.docstore.api.DocStoreBeanAdapter; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.tests.model.basic.*; @@ -123,7 +122,6 @@ private DeployBeanDescriptor mockDeployCustomer() { private BeanDescriptorMap mockOwner() { BeanDescriptorMap owner = mock(BeanDescriptorMap.class); - when(owner.createDocStoreBeanAdapter(any(), any())).thenReturn(mock(DocStoreBeanAdapter.class)); return owner; } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptor_documentMappingTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptor_documentMappingTest.java deleted file mode 100644 index b8a3bcced0..0000000000 --- a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptor_documentMappingTest.java +++ /dev/null @@ -1,84 +0,0 @@ -package io.ebeaninternal.server.deploy; - -import io.ebeanservice.docstore.api.mapping.DocPropertyAdapter; -import io.ebeanservice.docstore.api.mapping.DocPropertyMapping; -import io.ebeanservice.docstore.api.mapping.DocumentMapping; -import org.junit.jupiter.api.Test; -import org.tests.model.basic.Order; - -import static org.assertj.core.api.Assertions.assertThat; - -public class BeanDescriptor_documentMappingTest extends BaseTest { - - - @Test - public void docMapping() { - - BeanDescriptor desc = getBeanDescriptor(Order.class); - - DocumentMapping documentMapping = desc.docMapping(); - - DocPropertyMapping properties = documentMapping.properties(); - - assertThat(properties).isNotNull(); - } - - @Test - public void docMapping_visitor() { - - BeanDescriptor desc = getBeanDescriptor(Order.class); - - DocumentMapping documentMapping = desc.docMapping(); - - DocPropertyMapping properties = documentMapping.properties(); - - assertThat(properties).isNotNull(); - - TDVisitor tdVisitor = new TDVisitor(); - documentMapping.visit(tdVisitor); - - assertThat(tdVisitor.sb.toString()).isEqualTo("{status,orderDate,shipDate, object{customer:id,name,}customerName, nested{details: [id,orderQty,shipQty,unitPrice,cretime,updtime,]}cretime,updtime,}"); - } - - class TDVisitor extends DocPropertyAdapter { - - StringBuilder sb = new StringBuilder(); - - @Override - public void visitProperty(DocPropertyMapping property) { - sb.append(property.name() + ","); - } - - @Override - public void visitBegin() { - - sb.append('{'); - } - - @Override - public void visitEnd() { - sb.append('}'); - } - - @Override - public void visitBeginObject(DocPropertyMapping property) { - sb.append(" object{" + property.name() + ":"); - } - - @Override - public void visitEndObject(DocPropertyMapping property) { - sb.append('}'); - } - - @Override - public void visitBeginList(DocPropertyMapping property) { - sb.append(" nested{" + property.name() + ": ["); - } - - @Override - public void visitEndList(DocPropertyMapping property) { - sb.append("]}"); - } - } - -} diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/expression/LogicExpressionTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/expression/LogicExpressionTest.java index b4c7b910f5..bba52f0a0b 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/expression/LogicExpressionTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/expression/LogicExpressionTest.java @@ -88,53 +88,4 @@ public void isSameByBind_when_diffBindValues() { .isSameByBind(and(eq("a", 10), eq("c", 20)))).isFalse(); } - @Test - public void nestedPath_when_notNested() { - - LogicExpression and = and(eq("orderDate", 10), eq("shipDate", 10)); - - and.nestedPath(getBeanDescriptor(Order.class)); - - assertThat(and.expOne).isInstanceOf(SimpleExpression.class); - assertThat(and.expTwo).isInstanceOf(SimpleExpression.class); - } - - @Test - public void nestedPath_when_nestedSame() { - - LogicExpression and = and(eq("details.orderQty", 10), eq("details.unitPrice", 10)); - - String path = and.nestedPath(getBeanDescriptor(Order.class)); - - assertThat(path).isEqualTo("details"); - assertThat(and.expOne).isInstanceOf(SimpleExpression.class); - assertThat(and.expTwo).isInstanceOf(SimpleExpression.class); - } - - @Test - public void nestedPath_when_nestedDifferent() { - - LogicExpression and = and(eq("details.orderQty", 10), eq("shipments.shipTime", 10)); - - String path = and.nestedPath(getBeanDescriptor(Order.class)); - - assertThat(path).isNull(); - assertThat(and.expOne).isInstanceOf(NestedPathWrapperExpression.class); - assertThat(((NestedPathWrapperExpression) and.expOne).nestedPath).isEqualTo("details"); - assertThat(and.expTwo).isInstanceOf(NestedPathWrapperExpression.class); - assertThat(((NestedPathWrapperExpression) and.expTwo).nestedPath).isEqualTo("shipments"); - } - - @Test - public void nestedPath_when_oneNested() { - - LogicExpression and = and(eq("details.orderQty", 10), eq("orderDate", 10)); - - String path = and.nestedPath(getBeanDescriptor(Order.class)); - - assertThat(path).isNull(); - assertThat(and.expOne).isInstanceOf(NestedPathWrapperExpression.class); - assertThat(((NestedPathWrapperExpression) and.expOne).nestedPath).isEqualTo("details"); - assertThat(and.expTwo).isInstanceOf(SimpleExpression.class); - } } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/expression/PrepareDocNestedTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/expression/PrepareDocNestedTest.java deleted file mode 100644 index fbe4866e30..0000000000 --- a/ebean-core/src/test/java/io/ebeaninternal/server/expression/PrepareDocNestedTest.java +++ /dev/null @@ -1,148 +0,0 @@ -package io.ebeaninternal.server.expression; - -import io.ebean.DB; -import io.ebean.ExpressionList; -import io.ebeaninternal.api.SpiExpression; -import io.ebeaninternal.server.deploy.BaseTest; -import org.junit.jupiter.api.Test; -import org.tests.model.basic.Order; - -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - -public class PrepareDocNestedTest extends BaseTest { - @Test - public void prepare() throws Exception { - - ExpressionList where = DB.find(Order.class) - .where() - .gt("details.orderQty", 1) - .query().where(); - - - DefaultExpressionList exp = (DefaultExpressionList) where; - PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class)); - - List underlyingList = exp.underlyingList(); - assertEquals(underlyingList.size(), 1); - assertEquals(exp.allDocNestedPath, "details"); - } - - @Test - public void prepare_when_multipleOfSamePath() throws Exception { - - ExpressionList where = DB.find(Order.class) - .where() - .gt("details.orderQty", 1) - .gt("details.unitPrice", 1) - .query().where(); - - - DefaultExpressionList exp = (DefaultExpressionList) where; - PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class)); - - List underlyingList = exp.underlyingList(); - assertEquals(underlyingList.size(), 2); - assertEquals(exp.allDocNestedPath, "details"); - } - - @Test - public void prepare_when_mixed() throws Exception { - - ExpressionList where = DB.find(Order.class) - .where() - .gt("customer.id", 1) - .gt("details.orderQty", 1) - .gt("details.unitPrice", 1) - .query().where(); - - - DefaultExpressionList exp = (DefaultExpressionList) where; - PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class)); - - List underlyingList = exp.underlyingList(); - assertEquals(underlyingList.size(), 2); - assertNull(exp.allDocNestedPath); - - DefaultExpressionList second = (DefaultExpressionList) underlyingList.get(1); - assertEquals(second.allDocNestedPath, "details"); - } - - @Test - public void prepare_when_nestedJunction() throws Exception { - - ExpressionList where = DB.find(Order.class) - .where() - .not() - .gt("customer.id", 1) - .gt("details.orderQty", 1) - .gt("details.unitPrice", 1) - .query().where(); - - DefaultExpressionList exp = (DefaultExpressionList) where; - PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class)); - - List underlyingList = exp.underlyingList(); - assertEquals(underlyingList.size(), 1); - assertNull(exp.allDocNestedPath); - - JunctionExpression junction = (JunctionExpression) underlyingList.get(0); - List junctionUnderlying = junction.exprList.underlyingList(); - JunctionExpression nestedNestedPath = (JunctionExpression) junctionUnderlying.get(1); - assertEquals(nestedNestedPath.exprList.allDocNestedPath, "details"); - } - - @Test - public void prepare_when_nestedMultiple() throws Exception { - - ExpressionList where = DB.find(Order.class) - .where() - .isNotNull("shipments.shipTime") - .gt("details.orderQty", 1) - .gt("details.unitPrice", 1) - .query().where(); - - DefaultExpressionList exp = (DefaultExpressionList) where; - PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class)); - - List underlyingList = exp.underlyingList(); - assertEquals(underlyingList.size(), 2); - assertNull(exp.allDocNestedPath); - - DefaultExpressionList shipExpr = (DefaultExpressionList) underlyingList.get(0); - assertEquals(shipExpr.allDocNestedPath, "shipments"); - - DefaultExpressionList detailsExpr = (DefaultExpressionList) underlyingList.get(1); - assertEquals(detailsExpr.allDocNestedPath, "details"); - } - - - @Test - public void prepare_when_manyMixed() throws Exception { - - ExpressionList where = DB.find(Order.class) - .where() - .gt("customer.id", 1) // 0 - .isNotNull("shipments.shipTime") // shipments 0 - .isNotNull("status") // 1 - .gt("details.orderQty", 1) // details 0 - .isNotNull("orderDate") // 2 - .gt("details.unitPrice", 1) // details 1 - .query().where(); - - DefaultExpressionList exp = (DefaultExpressionList) where; - PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class)); - - List underlyingList = exp.underlyingList(); - assertEquals(underlyingList.size(), 5); - assertNull(exp.allDocNestedPath); - - DefaultExpressionList shipExpr = (DefaultExpressionList) underlyingList.get(3); - assertEquals(shipExpr.allDocNestedPath, "shipments"); - - DefaultExpressionList detailsExpr = (DefaultExpressionList) underlyingList.get(4); - assertEquals(detailsExpr.allDocNestedPath, "details"); - } -} diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java index 306697f10a..bc2e58a40c 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java @@ -163,14 +163,6 @@ public void equals_when_sameDistinct() { assertSame(key1, key2); } - @Test - public void equals_when_useDocStore() { - CQueryPlanKey key1 = planKey(query().setUseDocStore(true)); - CQueryPlanKey key2 = planKey(query()); - - assertDifferent(key1, key2); - } - @Test public void equals_when_diffMapKey() { diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/PBaseString.java b/ebean-querybean/src/main/java/io/ebean/typequery/PBaseString.java index aaf62c6bbd..ac2b8df591 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/PBaseString.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/PBaseString.java @@ -303,16 +303,4 @@ public final R icontains(String value) { return _root; } - /** - * Add a full text "Match" expression. - *

- * This means the query will automatically execute against the document store (ElasticSearch). - *

- * - * @param value the match expression - */ - public final R match(String value) { - expr().match(_name, value); - return _root; - } } diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/PString.java b/ebean-querybean/src/main/java/io/ebean/typequery/PString.java index 5903ae827d..33f3050900 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/PString.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/PString.java @@ -134,16 +134,4 @@ public R icontains(String value) { return _root; } - /** - * Add a full text "Match" expression. - *

- * This means the query will automatically execute against the document store (ElasticSearch). - *

- * - * @param value the match expression - */ - public R match(String value) { - expr().match(_name, value); - return _root; - } } diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java index a073abcca0..af7c878943 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java @@ -3,10 +3,6 @@ import io.avaje.lang.NonNullApi; import io.avaje.lang.Nullable; import io.ebean.*; -import io.ebean.search.MultiMatch; -import io.ebean.search.TextCommonTerms; -import io.ebean.search.TextQueryString; -import io.ebean.search.TextSimple; import io.ebean.service.SpiFetchGroupQuery; import io.ebean.text.PathProperties; import io.ebeaninternal.api.SpiQueryFetch; @@ -73,17 +69,6 @@ public abstract class TQRootBean { */ private ArrayStack> whereStack; - /** - * Stack of Text expressions ("query" section of ElasticSearch query rather than "filter" section). - */ - private ArrayStack> textStack; - - /** - * When true expressions should be added to the "text" stack - ElasticSearch "query" section - * rather than the "where" stack. - */ - private boolean textMode; - /** * The root query bean instance. Used to provide fluid query construction. */ @@ -628,46 +613,6 @@ public R setDistinct(boolean distinct) { return root; } - /** - * Set the index(es) to search for a document store which uses partitions. - *

- * For example, when executing a query against ElasticSearch with daily indexes we can - * explicitly specify the indexes to search against. - *

- *
{@code
-   *
-   *   // explicitly specify the indexes to search
-   *   query.setDocIndexName("logstash-2016.11.5,logstash-2016.11.6")
-   *
-   *   // search today's index
-   *   query.setDocIndexName("$today")
-   *
-   *   // search the last 3 days
-   *   query.setDocIndexName("$last-3")
-   *
-   * }
- *

- * If the indexName is specified with ${daily} e.g. "logstash-${daily}" ... then we can use - * $today and $last-x as the search docIndexName like the examples below. - *

- *
{@code
-   *
-   *   // search today's index
-   *   query.setDocIndexName("$today")
-   *
-   *   // search the last 3 days
-   *   query.setDocIndexName("$last-3")
-   *
-   * }
- * - * @param indexName The index or indexes to search against - * @return This query - */ - public R setDocIndexName(String indexName) { - query.setDocIndexName(indexName); - return root; - } - /** * Restrict the query to only return subtypes of the given inherit type. *
{@code
@@ -1018,17 +963,6 @@ public R setBeanCacheMode(CacheMode beanCacheMode) {
     return root;
   }
 
-  /**
-   * Set to true if this query should execute against the doc store.
-   * 

- * When setting this you may also consider disabling lazy loading. - *

- */ - public R setUseDocStore(boolean useDocStore) { - query.setUseDocStore(useDocStore); - return root; - } - /** * Set true if you want to disable lazy loading. *

@@ -1375,55 +1309,11 @@ public R not() { return root; } - /** - * Begin a list of expressions added by MUST. - *

- * This automatically makes this query a document store query. - *

- *

- * Use endJunction() to stop added to MUST and 'pop' to the parent expression list. - *

- */ - public R must() { - pushExprList(peekExprList().must()); - return root; - } - - /** - * Begin a list of expressions added by MUST NOT. - *

- * This automatically makes this query a document store query. - *

- *

- * Use endJunction() to stop added to MUST NOT and 'pop' to the parent expression list. - *

- */ - public R mustNot() { - return pushExprList(peekExprList().mustNot()); - } - - /** - * Begin a list of expressions added by SHOULD. - *

- * This automatically makes this query a document store query. - *

- *

- * Use endJunction() to stop added to SHOULD and 'pop' to the parent expression list. - *

- */ - public R should() { - return pushExprList(peekExprList().should()); - } - /** * End a list of expressions added by 'OR'. */ public R endJunction() { - if (textMode) { - textStack.pop(); - } else { - whereStack.pop(); - } + whereStack.pop(); return root; } @@ -1452,11 +1342,7 @@ public R endNot() { * Push the expression list onto the appropriate stack. */ private R pushExprList(ExpressionList list) { - if (textMode) { - textStack.push(list); - } else { - whereStack.push(list); - } + whereStack.push(list); return root; } @@ -1473,77 +1359,6 @@ private R pushExprList(ExpressionList list) { *

*/ public R where() { - textMode = false; - return root; - } - - /** - * Begin added expressions to the 'Text' expression list. - *

- * This automatically makes the query a document store query. - *

- *

- * For ElasticSearch expressions added to 'text' go into the ElasticSearch 'query context' - * and expressions added to 'where' go into the ElasticSearch 'filter context'. - *

- */ - public R text() { - textMode = true; - return root; - } - - /** - * Add a Text Multi-match expression (document store only). - *

- * This automatically makes the query a document store query. - *

- */ - public R multiMatch(String query, MultiMatch multiMatch) { - peekExprList().multiMatch(query, multiMatch); - return root; - } - - /** - * Add a Text Multi-match expression (document store only). - *

- * This automatically makes the query a document store query. - *

- */ - public R multiMatch(String query, String... properties) { - peekExprList().multiMatch(query, properties); - return root; - } - - /** - * Add a Text common terms expression (document store only). - *

- * This automatically makes the query a document store query. - *

- */ - public R textCommonTerms(String query, TextCommonTerms options) { - peekExprList().textCommonTerms(query, options); - return root; - } - - /** - * Add a Text simple expression (document store only). - *

- * This automatically makes the query a document store query. - *

- */ - public R textSimple(String query, TextSimple options) { - peekExprList().textSimple(query, options); - return root; - } - - /** - * Add a Text query string expression (document store only). - *

- * This automatically makes the query a document store query. - *

- */ - public R textQueryString(String query, TextQueryString options) { - peekExprList().textQueryString(query, options); return root; } @@ -2137,10 +1952,6 @@ public ExpressionList havingClause() { * Return the current expression list that expressions should be added to. */ protected ExpressionList peekExprList() { - if (textMode) { - // return the current text expression list - return _peekText(); - } if (whereStack == null) { whereStack = new ArrayStack<>(); whereStack.push(query.where()); @@ -2149,13 +1960,4 @@ protected ExpressionList peekExprList() { return whereStack.peek(); } - protected ExpressionList _peekText() { - if (textStack == null) { - textStack = new ArrayStack<>(); - // empty so push on the queries base expression list - textStack.push(query.text()); - } - // return the current expression list - return textStack.peek(); - } } diff --git a/ebean-test/src/test/java/io/ebean/xtest/base/TextExpressionListTest.java b/ebean-test/src/test/java/io/ebean/xtest/base/TextExpressionListTest.java deleted file mode 100644 index d409628d6f..0000000000 --- a/ebean-test/src/test/java/io/ebean/xtest/base/TextExpressionListTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package io.ebean.xtest.base; - - -import io.ebean.DB; -import io.ebean.search.Match; -import io.ebean.search.MultiMatch; -import org.junit.jupiter.api.Test; -import org.tests.model.basic.Order; - -public class TextExpressionListTest { - - @Test - public void syntax() { - - DB.find(Order.class) - .text().match("name", "rob"); - - - DB.find(Order.class) - .text().should() - .match("name", "rob") - .match("note", "war and peace"); - - - DB.find(Order.class) - .text() - .should() - .match("title", "war and peace") - .match("author", "leo tolstoy") - .should() - .match("translator", "Constance Garnett") - .match("translator", "Louise Maude"); - - - DB.find(Order.class) - .text() - .should() - .match("title", "war and peace") - .match("author", "leo tolstoy") - .should() - .match("translator", "Constance Garnett", new Match().opAnd().boost(2).minShouldMatch("75%")) - .match("translator", "Louise Maude") - .where() - .gt("reviewDate", 12345); - - - DB.find(Order.class) - .text() - .must() - .match("title", "quick") - .endJunction() - .should() - .match("title", "brown") - .match("title", "dog") - .endJunction() - .mustNot() - .match("title", "lazy") - .endJunction() - .where() - .gt("reviewDate", 12345); - - - } - - @Test - public void syntax_multiMatch() { - - DB.find(Order.class) - .text() - .multiMatch("Will Smith", "title", "*name"); - - MultiMatch match = MultiMatch.fields("title", "*name") - .opAnd() - .type(MultiMatch.Type.PHRASE_PREFIX); - - DB.find(Order.class) - .text() - .multiMatch("Will Smith", match); - - } -} diff --git a/ebean-test/src/test/java/io/ebean/xtest/config/DocStoreConfigTest.java b/ebean-test/src/test/java/io/ebean/xtest/config/DocStoreConfigTest.java deleted file mode 100644 index c567b79317..0000000000 --- a/ebean-test/src/test/java/io/ebean/xtest/config/DocStoreConfigTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.ebean.xtest.config; - -import io.ebean.annotation.DocStoreMode; -import io.ebean.config.DocStoreConfig; -import io.ebean.config.PropertiesWrapper; -import org.junit.jupiter.api.Test; - -import java.util.Properties; - -import static org.junit.jupiter.api.Assertions.*; - -public class DocStoreConfigTest { - - @Test - public void loadSettings() throws Exception { - - DocStoreConfig config = new DocStoreConfig(); - - Properties properties = new Properties(); - properties.setProperty("ebean.docstore.active", "true"); - properties.setProperty("ebean.docstore.bulkBatchSize", "99"); - properties.setProperty("ebean.docstore.url", "http://foo:9800"); - properties.setProperty("ebean.docstore.persist", "IGNORE"); - properties.setProperty("ebean.docstore.allowAllCertificates", "true"); - properties.setProperty("ebean.docstore.username", "fred"); - properties.setProperty("ebean.docstore.password", "rock"); - - PropertiesWrapper wrapper = new PropertiesWrapper("ebean", null, properties, null); - - config.loadSettings(wrapper); - - assertTrue(config.isActive()); - assertTrue(config.isAllowAllCertificates()); - assertFalse(config.isGenerateMapping()); - assertFalse(config.isDropCreate()); - assertEquals("http://foo:9800", config.getUrl()); - assertEquals("fred", config.getUsername()); - assertEquals("rock", config.getPassword()); - assertEquals(DocStoreMode.IGNORE, config.getPersist()); - assertEquals(99, config.getBulkBatchSize()); - } - - @Test - public void loadSettings_generateMapping_dropCreate() throws Exception { - - DocStoreConfig config = new DocStoreConfig(); - - Properties properties = new Properties(); - properties.setProperty("ebean.docstore.generateMapping", "true"); - properties.setProperty("ebean.docstore.dropCreate", "true"); - - PropertiesWrapper wrapper = new PropertiesWrapper("ebean", null, properties, null); - config.loadSettings(wrapper); - - assertTrue(config.isGenerateMapping()); - assertTrue(config.isDropCreate()); - assertFalse(config.isCreate()); - } - - @Test - public void loadSettings_generateMapping_create() throws Exception { - - DocStoreConfig config = new DocStoreConfig(); - - Properties properties = new Properties(); - properties.setProperty("ebean.docstore.generateMapping", "true"); - properties.setProperty("ebean.docstore.create", "true"); - - PropertiesWrapper wrapper = new PropertiesWrapper("ebean", null, properties, null); - config.loadSettings(wrapper); - - assertTrue(config.isGenerateMapping()); - assertTrue(config.isCreate()); - assertFalse(config.isDropCreate()); - } -} diff --git a/ebean-test/src/test/java/io/ebean/xtest/docstore/DocStoreBeanBaseAdapterTest.java b/ebean-test/src/test/java/io/ebean/xtest/docstore/DocStoreBeanBaseAdapterTest.java deleted file mode 100644 index 76d35ac6c1..0000000000 --- a/ebean-test/src/test/java/io/ebean/xtest/docstore/DocStoreBeanBaseAdapterTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package io.ebean.xtest.docstore; - - -import io.ebean.xtest.BaseTestCase; -import io.ebean.Query; -import io.ebean.docstore.DocUpdateContext; -import io.ebeaninternal.api.SpiEbeanServer; -import io.ebeaninternal.server.core.PersistRequestBean; -import io.ebeaninternal.server.deploy.BeanDescriptor; -import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; -import io.ebeanservice.docstore.api.DocStoreUpdateContext; -import io.ebeanservice.docstore.api.support.DocStoreBeanBaseAdapter; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Test; -import org.tests.model.basic.Order; - -import java.io.IOException; - -import static org.mockito.Mockito.mock; - -public class DocStoreBeanBaseAdapterTest extends BaseTestCase { - - - @Test - @SuppressWarnings("unchecked") - public void test_basic_construction() throws Exception { - - SpiEbeanServer server = spiEbeanServer(); - BeanDescriptor orderDesc = server.descriptor(Order.class); - - DeployBeanDescriptor deployDesc = (DeployBeanDescriptor) mock(DeployBeanDescriptor.class); - - TDAdapter adapter = new TDAdapter<>(orderDesc, deployDesc); - - Assertions.assertThat(adapter.indexName()).isEqualTo("order"); - Assertions.assertThat(adapter.indexType()).isEqualTo("order"); - Assertions.assertThat(adapter.queueId()).isEqualTo("order"); - } - - static class TDAdapter extends DocStoreBeanBaseAdapter { - - TDAdapter(BeanDescriptor desc, DeployBeanDescriptor deploy) { - super(desc, deploy); - } - - @Override - public void applyPath(Query query) { - } - - @Override - public void deleteById(Object idValue, DocUpdateContext txn) throws IOException { - } - - @Override - public void index(Object idValue, Object entityBean, DocUpdateContext txn) throws IOException { - } - - @Override - public void insert(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext txn) throws IOException { - } - - @Override - public void update(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext txn) throws IOException { - } - - @Override - public void updateEmbedded(Object idValue, String embeddedProperty, String embeddedRawContent, DocUpdateContext txn) throws IOException { - } - } -} diff --git a/ebean-test/src/test/java/io/ebean/xtest/docstore/DocStoreDeleteEventTest.java b/ebean-test/src/test/java/io/ebean/xtest/docstore/DocStoreDeleteEventTest.java deleted file mode 100644 index 1cb3af85fa..0000000000 --- a/ebean-test/src/test/java/io/ebean/xtest/docstore/DocStoreDeleteEventTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package io.ebean.xtest.docstore; - -import io.ebean.DB; -import io.ebean.Database; -import io.ebean.DocStoreQueueEntry; -import io.ebean.plugin.BeanDocType; -import io.ebean.plugin.BeanType; -import io.ebeanservice.docstore.api.DocStoreUpdates; -import io.ebeanservice.docstore.api.support.DocStoreDeleteEvent; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.tests.model.basic.Order; - -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.*; - -public class DocStoreDeleteEventTest { - - static Database server = DB.getDefault(); - - BeanType beanType(Class cls) { - return server.pluginApi().beanType(cls); - } - - BeanType orderType() { - return beanType(Order.class); - } - - @Test - @SuppressWarnings("unchecked") - public void docStoreUpdate() throws Exception { - - BeanType mock = (BeanType) Mockito.mock(BeanType.class); - BeanDocType mockDocType = (BeanDocType) Mockito.mock(BeanDocType.class); - when(mock.docStore()).thenReturn(mockDocType); - - DocStoreDeleteEvent event = new DocStoreDeleteEvent(mock, 42); - event.docStoreUpdate(null); - - verify(mock, times(1)).docStore(); - verify(mockDocType, times(1)).deleteById(42, null); - } - - @Test - public void addToQueue() { - - DocStoreDeleteEvent event = new DocStoreDeleteEvent(orderType(), 42); - - DocStoreUpdates updates = new DocStoreUpdates(); - event.addToQueue(updates); - - List queueEntries = updates.queueEntries(); - assertThat(queueEntries).hasSize(1); - - DocStoreQueueEntry entry = queueEntries.get(0); - assertThat(entry.getBeanId()).isEqualTo(42); - assertThat(entry.getQueueId()).isEqualTo("order"); - assertThat(entry.getPath()).isNull(); - assertThat(entry.getType()).isEqualTo(DocStoreQueueEntry.Action.DELETE); - } -} diff --git a/ebean-test/src/test/java/io/ebean/xtest/docstore/DocStoreIndexEventTest.java b/ebean-test/src/test/java/io/ebean/xtest/docstore/DocStoreIndexEventTest.java deleted file mode 100644 index 5b08603923..0000000000 --- a/ebean-test/src/test/java/io/ebean/xtest/docstore/DocStoreIndexEventTest.java +++ /dev/null @@ -1,67 +0,0 @@ -package io.ebean.xtest.docstore; - -import io.ebean.DB; -import io.ebean.Database; -import io.ebean.DocStoreQueueEntry; -import io.ebean.plugin.BeanDocType; -import io.ebean.plugin.BeanType; -import io.ebeanservice.docstore.api.DocStoreUpdates; -import io.ebeanservice.docstore.api.support.DocStoreIndexEvent; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.tests.model.basic.Order; - -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.*; - -public class DocStoreIndexEventTest { - - static Database server = DB.getDefault(); - - BeanType beanType(Class cls) { - return server.pluginApi().beanType(cls); - } - - BeanType orderType() { - return beanType(Order.class); - } - - @Test - @SuppressWarnings("unchecked") - public void docStoreUpdate() throws Exception { - - BeanType mock = (BeanType) Mockito.mock(BeanType.class); - BeanDocType mockDocType = (BeanDocType) Mockito.mock(BeanDocType.class); - when(mock.docStore()).thenReturn(mockDocType); - - Order bean = new Order(); - DocStoreIndexEvent event = new DocStoreIndexEvent<>(mock, 42, bean); - - event.docStoreUpdate(null); - - verify(mock, times(1)).docStore(); - verify(mockDocType, times(1)).index(42, bean, null); - } - - @Test - public void addToQueue() throws Exception { - - Order bean = new Order(); - - DocStoreIndexEvent event = new DocStoreIndexEvent<>(orderType(), 42, bean); - - DocStoreUpdates updates = new DocStoreUpdates(); - event.addToQueue(updates); - - List queueEntries = updates.queueEntries(); - assertThat(queueEntries).hasSize(1); - - DocStoreQueueEntry entry = queueEntries.get(0); - assertThat(entry.getBeanId()).isEqualTo(42); - assertThat(entry.getQueueId()).isEqualTo("order"); - assertThat(entry.getPath()).isNull(); - assertThat(entry.getType()).isEqualTo(DocStoreQueueEntry.Action.INDEX); - } -} diff --git a/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiEbeanServer.java b/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiEbeanServer.java index e5039d9b81..9135cb113f 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiEbeanServer.java +++ b/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiEbeanServer.java @@ -143,21 +143,11 @@ public PersistenceContextScope persistenceContextScope(SpiQuery query) { return null; } - @Override - public DocumentStore docStore() { - return null; - } - @Override public void clearQueryStatistics() { } - @Override - public BeanDescriptor descriptorByQueueId(String queueId) { - return null; - } - @Override public SpiTransactionManager transactionManager() { return null; diff --git a/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiServer.java b/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiServer.java index b0cab546d0..4066e4b34a 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiServer.java +++ b/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiServer.java @@ -503,11 +503,6 @@ public ScriptRunner script() { return null; } - @Override - public DocumentStore docStore() { - return null; - } - @Override public Set validateQuery(Query query) { return null; @@ -548,11 +543,6 @@ public List> beanTypes(String baseTableName) { return null; } - @Override - public BeanType beanTypeForQueueId(String queueId) { - return null; - } - @Override public BeanLoader beanLoader() { return null; diff --git a/ebean-test/src/test/java/io/ebean/xtest/plugin/BeanTypeTest.java b/ebean-test/src/test/java/io/ebean/xtest/plugin/BeanTypeTest.java index d088740510..9e087dac17 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/plugin/BeanTypeTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/plugin/BeanTypeTest.java @@ -2,14 +2,9 @@ import io.ebean.DB; import io.ebean.Database; -import io.ebean.FetchPath; import io.ebean.Query; -import io.ebean.plugin.BeanDocType; import io.ebean.plugin.BeanType; import io.ebean.plugin.Property; -import io.ebean.text.PathProperties; -import io.ebeaninternal.api.SpiQuery; -import io.ebeaninternal.server.querydefn.OrmQueryDetail; import org.junit.jupiter.api.Test; import org.tests.inheritance.Stockforecast; import org.tests.model.basic.*; @@ -97,94 +92,6 @@ public void setBeanId() { assertThat(42).isEqualTo(order.getId()); } - @Test - public void isDocStoreIndex() { - - assertThat(beanType(Order.class).isDocStoreMapped()).isFalse(); - assertThat(beanType(Person.class).isDocStoreMapped()).isFalse(); - - assertThat(beanType(Order.class).docMapping()).isNotNull(); - assertThat(beanType(Person.class).docMapping()).isNull(); - } - - @Test - public void docStore_getEmbedded() { - - BeanDocType orderDocType = beanType(Order.class).docStore(); - FetchPath customer = orderDocType.embedded("customer"); - assertThat(customer).isNotNull(); - assertThat(customer.getProperties(null)).contains("id", "name"); - } - - @Test - public void docStore_getEmbeddedManyRoot() { - - BeanDocType orderDocType = beanType(Order.class).docStore(); - - FetchPath detailsPath = orderDocType.embedded("details"); - assertThat(detailsPath).isNotNull(); - - FetchPath detailsRoot = orderDocType.embeddedManyRoot("details"); - assertThat(detailsRoot).isNotNull(); - assertThat(detailsRoot.getProperties(null)).containsExactly("id", "details"); - assertThat(detailsRoot.hasPath("details")).isTrue(); - } - - @Test - public void getDocStoreQueueId() { - - assertThat(beanType(Order.class).docStoreQueueId()).isEqualTo("order"); - assertThat(beanType(Customer.class).docStoreQueueId()).isEqualTo("customer"); - } - - @Test - public void getDocStoreIndexType() { - - assertThat(beanType(Order.class).docStore().indexType()).isEqualTo("order"); - assertThat(beanType(Customer.class).docStore().indexType()).isEqualTo("customer"); - } - - @Test - public void getDocStoreIndexName() { - - assertThat(beanType(Order.class).docStore().indexType()).isEqualTo("order"); - assertThat(beanType(Customer.class).docStore().indexType()).isEqualTo("customer"); - } - - @Test - public void docStoreNested() { - - FetchPath parse = PathProperties.parse("id,name"); - - FetchPath nestedCustomer = beanType(Order.class).docStore().embedded("customer"); - assertThat(nestedCustomer.toString()).isEqualTo(parse.toString()); - } - - @Test - public void docStoreApplyPath() { - - SpiQuery orderQuery = (SpiQuery) db.find(Order.class); - beanType(Order.class).docStore().applyPath(orderQuery); - - OrmQueryDetail detail = orderQuery.detail(); - assertThat(detail.getChunk("customer", false).getIncluded()).containsExactly("id", "name"); - } - - @Test - public void docStoreIndex() { - assertThrows(IllegalStateException.class, () -> beanType(Order.class).docStore().index(1, new Order(), null)); - } - - @Test - public void docStoreDeleteById() { - assertThrows(IllegalStateException.class, () -> beanType(Order.class).docStore().deleteById(1, null)); - } - - @Test - public void docStoreUpdateEmbedded() { - assertThrows(IllegalStateException.class, () -> beanType(Order.class).docStore().updateEmbedded(1, "customer", "someJson", null)); - } - @Test public void hasInheritance_when_not() { assertFalse(beanType(Order.class).hasInheritance()); diff --git a/ebean-test/src/test/java/org/tests/query/other/TestManyLazyLoadingQuery.java b/ebean-test/src/test/java/org/tests/query/other/TestManyLazyLoadingQuery.java index cbbba65dd4..2c6193de8f 100644 --- a/ebean-test/src/test/java/org/tests/query/other/TestManyLazyLoadingQuery.java +++ b/ebean-test/src/test/java/org/tests/query/other/TestManyLazyLoadingQuery.java @@ -52,7 +52,7 @@ public void test() { query0.setLazyLoadForParents(beanProperty); - beanProperty.addWhereParentIdIn(query0, parentIds, false); + beanProperty.addWhereParentIdIn(query0, parentIds); query0.findList(); assertThat(query0.getGeneratedSql()).contains(" from o_order_detail t0 where (t0.order_id) ");