Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
391 commits
Select commit Hold shift + click to select a range
646964a
Merge.
dmdashenkov Sep 15, 2016
d29cc4d
Merge remote-tracking branch 'origin/stand-funnel-tests' into stand-f…
dmdashenkov Sep 15, 2016
6405863
Correct docs.
dmdashenkov Sep 15, 2016
1c78731
Merge pull request #174 from SpineEventEngine/stand-funnel-tests
dmdashenkov Sep 15, 2016
5e9077f
Create filter method "applyFieldMask" for Query execution.
dmdashenkov Sep 15, 2016
ae74d27
Use "equals" instead of "==" in InMemoryStorage::writeInternal.
dmdashenkov Sep 15, 2016
8037a41
Add test for retrieving all data from a query with empty field mask.
dmdashenkov Sep 15, 2016
5ba27cd
Rework SubscriptionService API and related Stand features:
Sep 15, 2016
d5248f2
Remove outdated StandShould test comments.
Sep 15, 2016
b17a1db
Fix basic field mask functionality.
dmdashenkov Sep 16, 2016
b089546
Fix basic field mask functionality test.
dmdashenkov Sep 16, 2016
7ef1d7a
Refactor field mask applying.
dmdashenkov Sep 16, 2016
49d09a2
Add tests for cases: several fields are requested; no fields are requ…
dmdashenkov Sep 19, 2016
f4f610a
Create filter method "applyFieldMask" for Query execution.
dmdashenkov Sep 15, 2016
79e723a
Use "equals" instead of "==" in InMemoryStorage::writeInternal.
dmdashenkov Sep 15, 2016
995f3a7
Add test for retrieving all data from a query with empty field mask.
dmdashenkov Sep 15, 2016
461d6b9
Fix basic field mask functionality.
dmdashenkov Sep 16, 2016
dd879bf
Fix basic field mask functionality test.
dmdashenkov Sep 16, 2016
9ab0bce
Refactor field mask applying.
dmdashenkov Sep 16, 2016
4b19a14
Add tests for cases: several fields are requested; no fields are requ…
dmdashenkov Sep 19, 2016
b6feb01
Merge remote-tracking branch 'origin/stand-query-impl' into stand-que…
dmdashenkov Sep 19, 2016
491ced2
Merge.
dmdashenkov Sep 19, 2016
e82f6e2
Move applying field mask logic to "FieldMasks" util class.
dmdashenkov Sep 19, 2016
b52fc7f
Add by-entity field mask applier.
dmdashenkov Sep 19, 2016
1f1b324
Apply field mask when fetching from in-stand storage.
dmdashenkov Sep 19, 2016
7a4da06
Generify "FieldMasks" util.
dmdashenkov Sep 19, 2016
e75ddf2
Change API to make field mask applying in storage possible.
dmdashenkov Sep 19, 2016
a7f715b
Create a small utility class for working with queries.
Sep 20, 2016
5261f5b
Add Target-related methods.
Sep 20, 2016
a8ae84d
* Improve readability of Target-related methods in the Queries utility.
Sep 20, 2016
327a436
Add simplified method "applyIfEffective" for applying field mask.
dmdashenkov Sep 20, 2016
c3f8468
Add suport for field masks applying in entity repo.
dmdashenkov Sep 20, 2016
1f2270a
Add support for by-FieldMask processing in stand storage.
dmdashenkov Sep 20, 2016
5531914
Rename test method to reflect its nature.
Sep 20, 2016
f2e79b4
Add required javadoc.
dmdashenkov Sep 20, 2016
8d06b0b
Optimize "readAll" operation in InMemoryRecordStorage for case with f…
dmdashenkov Sep 20, 2016
caa6c59
Merge branch 'stand-in-memory' into stand-query-impl
dmdashenkov Sep 20, 2016
bfb9e96
Merge.
dmdashenkov Sep 20, 2016
9b1d55b
* Add more subscription-related tests.
Sep 20, 2016
604265b
* Add more subscription-related tests.
Sep 20, 2016
65b04b0
Resolve some of comments, naming and API issues.
dmdashenkov Sep 20, 2016
ce9c2b4
Some more javadoc changes.
dmdashenkov Sep 20, 2016
727edd8
Specify failure handling policy for FieldMasks in javadoc.
dmdashenkov Sep 20, 2016
6efcf89
Move query composing to "Queries" util.
dmdashenkov Sep 20, 2016
e3f497a
Merge branch 'stand-in-memory' into stand-query-impl
dmdashenkov Sep 20, 2016
fb8a89d
Fix import issues.
dmdashenkov Sep 20, 2016
de6e6bd
* Implement the SubscriptionService;
Sep 20, 2016
c4a142d
Address issues form PR.
dmdashenkov Sep 20, 2016
062b6f8
Remove 'isValid(FieldMask)' method.
dmdashenkov Sep 20, 2016
1598bd6
Fix issues from PR.
dmdashenkov Sep 21, 2016
a37aaa9
Check stream observer methods are called.
dmdashenkov Sep 21, 2016
a015559
Remove redundant spy objects.
dmdashenkov Sep 21, 2016
f8db697
Ensure EOF.
dmdashenkov Sep 21, 2016
fde5d75
Remove redundant inspection suppress.
dmdashenkov Sep 21, 2016
1e417a9
Redefine the SubscriptionService typical flow to Subscribe -> Activat…
Sep 22, 2016
a12f5a0
Resolve the test compilation issues.
Sep 22, 2016
5fcdd2f
Rename ClientService to CommandService all over the project.
dmdashenkov Sep 22, 2016
ede4059
Fix Target issues (use oneof properly) and use it in Stand entity -> …
Sep 22, 2016
96df5a0
Add senseful invalid type url string.
dmdashenkov Sep 22, 2016
afe3725
Merge branch 'stand-in-memory' into stand-query-impl
dmdashenkov Sep 22, 2016
2eee97d
Merge pull request #175 from SpineEventEngine/stand-query-impl
dmdashenkov Sep 22, 2016
1989a93
Finish migration.
dmdashenkov Sep 22, 2016
8555920
Correct comment.
dmdashenkov Sep 22, 2016
a252995
Merge pull request #179 from SpineEventEngine/rename-clientservice-to…
dmdashenkov Sep 22, 2016
c3c046d
Fix concurrency issue in the StandFunnel test for executors.
dmdashenkov Sep 22, 2016
c196ec5
Fix throwable naming.
dmdashenkov Sep 22, 2016
3ddc163
Fix concurrency issue in the StandFunnel test for executors.
dmdashenkov Sep 22, 2016
a7ed2f5
Fix throwable naming.
dmdashenkov Sep 22, 2016
9e60556
Create class for subscription service tests.
dmdashenkov Sep 22, 2016
521145d
Add creation tests for subscription service.
dmdashenkov Sep 22, 2016
b6e841c
Merge pull request #181 from SpineEventEngine/fix-standfunnel-test
dmdashenkov Sep 22, 2016
ecc76ac
Add subscription test.
dmdashenkov Sep 22, 2016
b9971fc
Add activation test.
dmdashenkov Sep 23, 2016
128f50a
Add cancel subscription test.
dmdashenkov Sep 23, 2016
c8abf39
Resolve 'setUpdates' issue.
dmdashenkov Sep 23, 2016
bee4cf4
Correct some naming and builder check issues.
dmdashenkov Sep 23, 2016
f0047a6
Move bounded context creation into TestBoundedContextFactory.
dmdashenkov Sep 23, 2016
8854aa0
Male Stand AutoClosable.
dmdashenkov Sep 23, 2016
dcc7f86
Merge pull request #183 from SpineEventEngine/subscription-service-tests
dmdashenkov Sep 26, 2016
2e9857f
Male Stand AutoClosable.
dmdashenkov Sep 23, 2016
0f91aa7
Merge remote-tracking branch 'origin/make-stand-autoclosable' into ma…
dmdashenkov Sep 26, 2016
6d6f3c2
Close StandStorage in Stand::close.
dmdashenkov Sep 26, 2016
73e1d1e
Use milliseconds resolution for command scheduling; fix command sched…
Sep 26, 2016
10d63eb
Merge pull request #184 from SpineEventEngine/make-stand-autoclosable
dmdashenkov Sep 26, 2016
f0dcda5
Try to ensure correct test execution for async-based command scheduler.
Sep 26, 2016
311be3d
Merge branch 'master' into stand-in-memory
dmdashenkov Sep 26, 2016
9834f41
Merge remote-tracking branch 'origin/stand-in-memory' into stand-in-m…
dmdashenkov Sep 26, 2016
2b765fe
Update the Client -> Server example with the non-blocking Subscriptio…
Sep 26, 2016
50de0a9
Remove resolved todo item.
Sep 26, 2016
af7fc02
Add a short description for the StandStorage.
Sep 26, 2016
a4e8fd9
Omit extra `null` checks for EntityFilters and address a related todo…
Sep 26, 2016
1f3c4a0
Bump Spine version to 0.6.0-SNAPSHOT.
Sep 26, 2016
855f820
Add JavaDocs for Queries.
Sep 30, 2016
1cea140
Add JavaDocs for Queries.Targets.
Sep 30, 2016
80b710f
Fix typos in the JavaDocs for Queries.
Sep 30, 2016
fb20049
Remove the extra lines.
Sep 30, 2016
8bf368f
Improve readability of CommandService definition.
Sep 30, 2016
7525ce0
Document the QueryResponse proto.
Sep 30, 2016
021490c
Add test for searching by ids with field mask.
dmdashenkov Sep 30, 2016
0f1a1b0
Remove redundant line.
Sep 30, 2016
b450c9b
Improve readability of CommandService and QueryService.
Sep 30, 2016
179767e
Improve readability of SubscriptionService.
Sep 30, 2016
8840361
Turn on "Align multiline parameters" in the method declaration to imp…
Sep 30, 2016
be594a2
Remove redundant lines and improve the readability of EntityRepository.
Sep 30, 2016
1960f7f
Fix test for searching by ids with field mask.
dmdashenkov Oct 1, 2016
1c45f5c
Cover CommandService.Builder::removeBoundedContext with a test.
dmdashenkov Oct 1, 2016
76b1589
Fix naming and suppression issues.
dmdashenkov Oct 3, 2016
c4e31b2
Merge pull request #187 from SpineEventEngine/cover-queries-with-tests
dmdashenkov Oct 3, 2016
d804eca
Add common entity repository tests.
dmdashenkov Oct 4, 2016
73c6cbf
Add implementation for ProjectionRepository.
dmdashenkov Oct 4, 2016
6f8bd40
Fix nullable collection values issue.
dmdashenkov Oct 4, 2016
3f059a2
Add test for EntityRepository::findAll(EntityFilters, FieldMask).
dmdashenkov Oct 4, 2016
9d7c432
Clarify the behaviour of "readBulk(...)" method in the JavaDoc section.
Oct 4, 2016
8a10bab
Cleanup the QueryResponse documentation.
Oct 4, 2016
dc4dbaa
[Code style]: Adjust IDEA settings to keep 1 blank line max (in code …
Oct 4, 2016
4527a4f
Reformat CommandServiceShould code test.
Oct 4, 2016
9fb8748
[Code style]: allow 1 line max in declarations as well.
Oct 4, 2016
4927555
Remove the excessive blank line and reformat the QueryService code.
Oct 4, 2016
56b1745
Extract `stand` variables to make the potential debugging easier.
Oct 4, 2016
68d0da9
Clarify `EntityRepository#findBulk` documentation.
Oct 4, 2016
0f9ddb7
Mention field masks properly in method JavaDocs.
Oct 4, 2016
70c1180
Remove `EntityRepository#find(id)` in favour of `EntityRepository#loa…
Oct 4, 2016
e91e1e7
Rename `EntityRepository#findBulk(ids)` to `#loadAll(ids)` in order t…
Oct 4, 2016
447dbcd
Rename `EntityRepository#findAll()` to `#loadAll()` in order to make …
Oct 4, 2016
40c9a08
Update JavaDocs according to the renamed methods meaning.
Oct 4, 2016
d134c26
* Rename `EntityRepository#findAll(EntityFilters, FieldMask)` to `fin…
Oct 4, 2016
1f17a8d
Create a test for `Queries` utility class.
Oct 4, 2016
ffb4ce0
Use Guava's `Maps#newHashMap()` in favour of `new HashMap()` to keep …
Oct 4, 2016
ac7eefc
Cover `Queries#readAll()` with tests.
Oct 4, 2016
158ede1
Cover one of `Queries#readByIds()` cases with tests.
Oct 4, 2016
8956f6f
Add common entity repository tests.
dmdashenkov Oct 4, 2016
3a1a29b
Add implementation for ProjectionRepository.
dmdashenkov Oct 4, 2016
6514e04
Fix nullable collection values issue.
dmdashenkov Oct 4, 2016
9a1225c
Add test for EntityRepository::findAll(EntityFilters, FieldMask).
dmdashenkov Oct 4, 2016
ffb572a
Rename methods according to last changes in the base branch.
dmdashenkov Oct 5, 2016
55ba8d1
Merge remote-tracking branch 'origin/abstract-entity-repo-should' int…
dmdashenkov Oct 5, 2016
a3b01f4
Add clarifying comment and make assertion method static.
dmdashenkov Oct 5, 2016
a8f55d0
Extract common check method.
dmdashenkov Oct 5, 2016
48714b5
Create FieldMasks test class.
dmdashenkov Oct 5, 2016
cae736f
Clarify naming.
dmdashenkov Oct 5, 2016
76d236e
Add tests for FieldMasks.
dmdashenkov Oct 5, 2016
b812937
Remove redundant "given'.
dmdashenkov Oct 5, 2016
cd6ec22
Fix broken dependency.
dmdashenkov Oct 5, 2016
92f3369
Complete `Queries` and `Queries.Targets` test coverage.
Oct 5, 2016
2e1854d
Fix formatting issues.
dmdashenkov Oct 5, 2016
c799df9
Adjust code style and naming in `QueriesShould` tests.
Oct 5, 2016
81adba6
Correct comment.
dmdashenkov Oct 5, 2016
57eb094
Merge pull request #189 from SpineEventEngine/field-mask-tests
dmdashenkov Oct 5, 2016
b390ba3
Extract a resulting value before actual `return` into a separate vari…
Oct 5, 2016
b645edb
Extract a factory method for the "storage record to entity" transformer.
Oct 5, 2016
8b0e6cd
Improve `loadAll` documentation.
Oct 5, 2016
9be366a
* Avoid multiple @SuppressWarnings("unchecked") by generifying the ab…
Oct 6, 2016
d6a336f
Cover `EntityRepository#loadAll` with tests. Also remove some redunda…
Oct 6, 2016
07df1e5
Use `Preconditions.checkState` instead of explicit `throw new ...` to…
Oct 6, 2016
8e0ae41
Reformat `Stand` code and use `Preconditions.checkState` instead of t…
Oct 6, 2016
34bf838
Avoid warnings in FieldMasks due to ignored exception caught.
Oct 6, 2016
d6a4c05
Avoid warning suppression statements by refactoring the code of `Fiel…
Oct 6, 2016
f54def5
Remove redundant empty lines.
Oct 6, 2016
c9c97c5
Adjust code formatting and variable wrapping.
Oct 6, 2016
ba51276
Improve readability of the internal Query execution code.
Oct 6, 2016
1547d4e
* Add Query -> TypeUrl convenience extractor: use it in Stand for bet…
Oct 6, 2016
373c91b
Generate UUID with Spine utility.
Oct 6, 2016
f401855
Specify that `Subscription` instances should not be created in scope …
Oct 6, 2016
ddbf154
Add test for applying an empty field mask onto a collection of messages.
dmdashenkov Oct 7, 2016
21676be
Add test for selecting singleton list from stand with field mask appl…
dmdashenkov Oct 7, 2016
eede00d
Add exception logging for FiledMasks.
dmdashenkov Oct 7, 2016
d576b5f
Remove redundant commented code.
dmdashenkov Oct 7, 2016
baeddf5
Fix issues from PR.
dmdashenkov Oct 7, 2016
d8dad1a
Fix variable name.
dmdashenkov Oct 10, 2016
70b5d66
Merge branch 'fix-field-mask-cov' into stand-in-memory
dmdashenkov Oct 10, 2016
080ae9b
Merge.
dmdashenkov Oct 10, 2016
063200d
Trigger`onCompleted()` for the gRPC response observers in the expecte…
Oct 10, 2016
422b0c8
Document missing parameter.
Oct 10, 2016
00c0103
Rename the `getKnownAggregateTypes` to `getExposedAggregateTypes` to …
Oct 10, 2016
b5378ee
Rename the `Stand#getAvailableTypes` to `getExposedTypes` for consist…
Oct 10, 2016
b561938
Reformat test code to fit 120 symbols per line as much as possible.
Oct 10, 2016
f872c30
Extract query processing into a standalone helper class and ensure it…
Oct 10, 2016
b399298
Rename `StandUpdateCallback` to `EntityUpdateCallback` and its method…
Oct 10, 2016
bf86807
Remove unused test helper method.
Oct 10, 2016
b80b4df
Extract the subscription registry and subscription record to make Sta…
Oct 10, 2016
88240e1
Improve the StandFunnel behaviour description and add `@see` links to…
Oct 10, 2016
711d80e
Remove a redundant empty line.
Oct 10, 2016
a6342ef
Clarify the default value of the StandFunnel executor
Oct 10, 2016
176540f
Add better JavaDoc comments and refactor the code to avoid long chain…
Oct 10, 2016
75eab6a
Remove an empty line.
Oct 10, 2016
2d13933
Remove empty lines.
Oct 10, 2016
08fbc4c
Remove an empty line.
Oct 10, 2016
f5d4de0
Add tests for SubscriptionRecord.
dmdashenkov Oct 10, 2016
b098d69
Simplify `findBulkInternal` implementation and remove warning suppres…
Oct 10, 2016
63e7de5
Add dismatch tests for subscription record.
dmdashenkov Oct 10, 2016
f516e06
Simplify the implementation of `readAllInternal`.
Oct 10, 2016
bebaa50
Remove empty lines and fix typo.
dmdashenkov Oct 10, 2016
ccdaf70
Merge pull request #193 from SpineEventEngine/subscription-record-tests
dmdashenkov Oct 10, 2016
69ea772
Cover InMemoryRecordStorage#readAll(FieldMask) empty storage case wit…
dmdashenkov Oct 10, 2016
3e70827
Add read all tests for projection storage.
dmdashenkov Oct 10, 2016
1d8dd94
Fix RecordStorage#readAll(FieldMask) on empty storage test.
dmdashenkov Oct 11, 2016
8a9b2b5
Add empty read-all operations test for projection storage.
dmdashenkov Oct 11, 2016
fc84cd1
Add read-bulk tests for projection storage.
dmdashenkov Oct 11, 2016
ff19cc9
Add warnings supression.
dmdashenkov Oct 11, 2016
8c29176
Rework `QueryProcessor` from a utility class into the interface with …
Oct 11, 2016
2b03281
Fix copyright header through the codebase: leave the only empty line …
Oct 11, 2016
379ae60
Add `@Nullable` annotation to the `callback` and explain the data flow.
Oct 11, 2016
2250cf7
Align `/* package */` declaration properly in relation to its target.
Oct 11, 2016
035b118
Aling the class-level documentation properly and supply it with the `…
Oct 11, 2016
ea22f01
Extract some operations into separate methods and fix code style issues.
dmdashenkov Oct 11, 2016
550a303
Rename helper method.
dmdashenkov Oct 11, 2016
d10ca9c
Merge pull request #194 from SpineEventEngine/in-memory-storage-cov
dmdashenkov Oct 11, 2016
03ab9c1
Review the `@Internal` and `@SPI` annotation usages.
Oct 11, 2016
895b540
Rename the `...Storage` protected methods consistently (avoid `intern…
Oct 11, 2016
8b3534d
Update the Projection-related tests according to the storage method r…
Oct 11, 2016
b20a668
Add the `todo` items to reflect the latest SPI method review results …
Oct 11, 2016
0136ac0
Improve code readability: remove redundant empty lines and extract va…
Oct 11, 2016
ae25407
Align class-level JavaDocs properly.
Oct 11, 2016
782365b
Remove excessive empty lines.
Oct 11, 2016
a1cefab
Remove excessive empty lines.
Oct 11, 2016
f881b83
Remove excessive empty line.
Oct 11, 2016
b7a891f
Remove excessive empty lines.
Oct 11, 2016
4c11fea
Fix copyright header by removing the trailing empty line.
Oct 11, 2016
755436f
Make the customer names more neutral for tests.
Oct 11, 2016
79feace
Suppress a minor warning in the test codebase and explain why.
Oct 11, 2016
032e28e
Merge branch 'master' into stand-in-memory
Oct 11, 2016
ba08bbb
Add read-all tests for record storage.
dmdashenkov Oct 12, 2016
8a157f2
Extract stand storage tests into separate class.
dmdashenkov Oct 12, 2016
c3d6558
Fix ids check.
dmdashenkov Oct 12, 2016
e45dc75
Add readMultiple(ids) test.
dmdashenkov Oct 12, 2016
9b2d4da
Add Builder methods test.
dmdashenkov Oct 12, 2016
3d02a98
Add test for adding shutdown hook.
dmdashenkov Oct 12, 2016
371b5f3
Fix naming.
dmdashenkov Oct 12, 2016
7e97ee8
Fix minor issues.
dmdashenkov Oct 12, 2016
cb1f2c6
Merge pull request #196 from SpineEventEngine/stand-storage-cov
dmdashenkov Oct 12, 2016
e88cb1d
Add detailed comment on signature of field accessed from reflect API.
dmdashenkov Oct 12, 2016
0d398e2
Use another multiline ternary operation formatting approach: `condit…
Oct 12, 2016
a42031a
Move the `checkIsPositive` to the group of related `Precondition` che…
Oct 12, 2016
37eaef2
Rename `checkIsPositive` to `checkPositive` for timestamp Preconditio…
Oct 12, 2016
84c660d
Merge branch 'grpc-container-cov' into stand-in-memory
dmdashenkov Oct 12, 2016
5942815
Remove an empty line.
Oct 12, 2016
ea23468
Merge remote-tracking branch 'origin/stand-in-memory' into stand-in-m…
dmdashenkov Oct 12, 2016
b34a4ca
Resolve `FieldMasks` issues:
Oct 12, 2016
5ac35fb
Remove an empty line.
Oct 12, 2016
58c1cfd
Remove an empty line.
Oct 12, 2016
1bea96b
Simplify the `Stand#update()` signature, mark it as `@VisibleForTesti…
Oct 12, 2016
aede0ca
Expose`Stand#update()` as package-local method; use StandFunnel API f…
Oct 12, 2016
1689163
Do not call `onCompleted()` after `onError()`.
Oct 12, 2016
4e3b72b
Remove redundant check and fix typo.
dmdashenkov Oct 12, 2016
15696f5
Merge pull request #198 from SpineEventEngine/field-masks-cov
dmdashenkov Oct 12, 2016
e563e1a
Merge branch 'master' into stand-in-memory
Oct 12, 2016
0dae52e
Add exception handling test for SubscriptionService#subscribe.
dmdashenkov Oct 12, 2016
d78ea1b
Add exception handling test for SubscriptionService#activate.
dmdashenkov Oct 12, 2016
cd221cd
Add exception handling test for SubscriptionService#cancel.
dmdashenkov Oct 12, 2016
0d84014
Merge pull request #199 from SpineEventEngine/subscription-service-cov
dmdashenkov Oct 12, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ before_install:
after_success:
# See: https://github.com/codecov/example-java/blob/master/.travis.yml
- bash <(curl -s https://codecov.io/bash)

script: ./gradlew check --stacktrace
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ allprojects {
apply plugin: 'idea'

group = 'org.spine3'
version = '0.5.19-SNAPSHOT'
version = '0.6.0-SNAPSHOT'
}

ext {
Expand Down
4 changes: 2 additions & 2 deletions client/src/main/java/org/spine3/base/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import static org.spine3.base.CommandContext.newBuilder;
import static org.spine3.base.Identifiers.idToString;
import static org.spine3.protobuf.Timestamps.getCurrentTime;
import static org.spine3.validate.Validate.checkIsPositive;
import static org.spine3.validate.Validate.checkPositive;
import static org.spine3.validate.Validate.checkNotEmptyOrBlank;
import static org.spine3.validate.Validate.isNotDefault;

Expand Down Expand Up @@ -287,7 +287,7 @@ public static Command setSchedulingTime(Command command, Timestamp schedulingTim
*/
@Internal
public static Command setSchedule(Command command, Duration delay, Timestamp schedulingTime) {
checkIsPositive(schedulingTime, "command scheduling time");
checkPositive(schedulingTime, "command scheduling time");
final CommandContext context = command.getContext();
final CommandContext.Schedule scheduleUpdated = context.getSchedule()
.toBuilder()
Expand Down
226 changes: 226 additions & 0 deletions client/src/main/java/org/spine3/base/Queries.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
/*
* Copyright 2016, TeamDev Ltd. All rights reserved.
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.spine3.base;

import com.google.protobuf.Any;
import com.google.protobuf.FieldMask;
import com.google.protobuf.Message;
import org.spine3.client.EntityFilters;
import org.spine3.client.EntityId;
import org.spine3.client.EntityIdFilter;
import org.spine3.client.Query;
import org.spine3.client.Target;
import org.spine3.protobuf.AnyPacker;
import org.spine3.protobuf.KnownTypes;
import org.spine3.protobuf.TypeUrl;

import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Set;

import static org.spine3.base.Queries.Targets.allOf;
import static org.spine3.base.Queries.Targets.someOf;

/**
* Client-side utilities for working with queries.
*
* @author Alex Tymchenko
* @author Dmytro Dashenkov
*/
public class Queries {

private Queries() {
}

/**
* Create a {@link Query} to read certain entity states by IDs with the {@link FieldMask}
* applied to each of the results.
*
* <p>Allows to specify a set of identifiers to be used during the {@code Query} processing. The processing
* results will contain only the entities, which IDs are present among the {@code ids}.
*
* <p>Allows to set property paths for a {@link FieldMask}, applied to each of the query results.
* This processing is performed according to the
* <a href="https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask>FieldMask specs</a>.
*
* <p>In case the {@code paths} array contains entries inapplicable to the resulting entity
* (e.g. a {@code path} references a missing field), such invalid paths are silently ignored.
*
* @param entityClass the class of a target entity
* @param ids the entity IDs of interest
* @param paths the property paths for the {@code FieldMask} applied to each of results
* @return an instance of {@code Query} formed according to the passed parameters
*/
public static Query readByIds(Class<? extends Message> entityClass, Set<? extends Message> ids, String... paths) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add Javadocs for these methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

final FieldMask fieldMask = FieldMask.newBuilder()
.addAllPaths(Arrays.asList(paths))
.build();
final Query result = composeQuery(entityClass, ids, fieldMask);
return result;
}

/**
* Create a {@link Query} to read all entity states with the {@link FieldMask}
* applied to each of the results.
*
* <p>Allows to set property paths for a {@link FieldMask}, applied to each of the query results.
* This processing is performed according to the
* <a href="https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask>FieldMask specs</a>.
*
* <p>In case the {@code paths} array contains entries inapplicable to the resulting entity
* (e.g. a {@code path} references a missing field), such invalid paths are silently ignored.
*
* @param entityClass the class of a target entity
* @param paths the property paths for the {@code FieldMask} applied to each of results
* @return an instance of {@code Query} formed according to the passed parameters
*/
public static Query readAll(Class<? extends Message> entityClass, String... paths) {
final FieldMask fieldMask = FieldMask.newBuilder()
.addAllPaths(Arrays.asList(paths))
.build();
final Query result = composeQuery(entityClass, null, fieldMask);
return result;
}

/**
* Create a {@link Query} to read certain entity states by IDs.
*
* <p>Allows to specify a set of identifiers to be used during the {@code Query} processing. The processing
* results will contain only the entities, which IDs are present among the {@code ids}.
*
* <p>Unlike {@link Queries#readByIds(Class, Set, String...)}, the {@code Query} processing will not change
* the resulting entities.
*
* @param entityClass the class of a target entity
* @param ids the entity IDs of interest
* @return an instance of {@code Query} formed according to the passed parameters
*/
public static Query readByIds(Class<? extends Message> entityClass, Set<? extends Message> ids) {
return composeQuery(entityClass, ids, null);
}

/**
* Create a {@link Query} to read all states of a certain entity.
*
* <p>Unlike {@link Queries#readAll(Class, String...)}, the {@code Query} processing will not change
* the resulting entities.
*
* @param entityClass the class of a target entity
* @return an instance of {@code Query} formed according to the passed parameters
*/
public static Query readAll(Class<? extends Message> entityClass) {
return composeQuery(entityClass, null, null);
}

private static Query composeQuery(Class<? extends Message> entityClass, @Nullable Set<? extends Message> ids, @Nullable FieldMask fieldMask) {
final Target target = ids == null ? allOf(entityClass) : someOf(entityClass, ids);
final Query.Builder queryBuilder = Query.newBuilder()
.setTarget(target);
if (fieldMask != null) {
queryBuilder.setFieldMask(fieldMask);
}
final Query result = queryBuilder
.build();
return result;
}

/**
* Extract the type of {@link Target} for the given {@link Query}.
*
* <p>Returns null if the {@code Target} type is unknown to the application.
*
* @param query the query of interest.
* @return the type of the {@code Query#getTarget()} or null, if the type is unknown.
*/
@Nullable
public static TypeUrl typeOf(Query query) {
final Target target = query.getTarget();
final String typeAsString = target.getType();
final TypeUrl type = KnownTypes.getTypeUrl(typeAsString);
return type;
}

/**
* Client-side utilities for working with {@link Query} and {@link org.spine3.client.Subscription} targets.
*
* @author Alex Tymchenko
* @author Dmytro Dashenkov
*/
public static class Targets {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add Javadoc to this class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


private Targets() {
}

/**
* Create a {@link Target} for a subset of the entity states by specifying their IDs.
*
* @param entityClass the class of a target entity
* @param ids the IDs of interest
* @return the instance of {@code Target} assembled according to the parameters.
*/
public static Target someOf(Class<? extends Message> entityClass, Set<? extends Message> ids) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document public methods.

final Target result = composeTarget(entityClass, ids);
return result;
}

/**
* Create a {@link Target} for all of the specified entity states.
*
* @param entityClass the class of a target entity
* @return the instance of {@code Target} assembled according to the parameters.
*/
public static Target allOf(Class<? extends Message> entityClass) {
final Target result = composeTarget(entityClass, null);
return result;
}

/* package */
static Target composeTarget(Class<? extends Message> entityClass, @Nullable Set<? extends Message> ids) {
final TypeUrl type = TypeUrl.of(entityClass);

final boolean includeAll = ids == null;

final EntityIdFilter.Builder idFilterBuilder = EntityIdFilter.newBuilder();

if (!includeAll) {
for (Message rawId : ids) {
final Any packedId = AnyPacker.pack(rawId);
final EntityId entityId = EntityId.newBuilder()
.setId(packedId)
.build();
idFilterBuilder.addIds(entityId);
}
}
final EntityIdFilter idFilter = idFilterBuilder.build();
final EntityFilters filters = EntityFilters.newBuilder()
.setIdFilter(idFilter)
.build();
final Target.Builder builder = Target.newBuilder()
.setType(type.getTypeName());
if (includeAll) {
builder.setIncludeAll(true);
} else {
builder.setFilters(filters);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the redundant line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return builder.build();
}
}
}
48 changes: 26 additions & 22 deletions client/src/main/java/org/spine3/protobuf/KnownTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.spine3.protobuf.error.UnknownTypeException;
import org.spine3.type.ClassName;

import javax.annotation.Nullable;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
Expand Down Expand Up @@ -105,8 +106,8 @@ public class KnownTypes {
*/
private static final ImmutableMap<String, TypeUrl> typeNameToUrlMap = buildTypeToUrlMap(knownTypes);


private KnownTypes() {}
private KnownTypes() {
}

/** Retrieves Protobuf type URLs known to the application. */
public static ImmutableSet<TypeUrl> getTypeUrls() {
Expand Down Expand Up @@ -145,14 +146,16 @@ public static ClassName getClassName(TypeUrl typeUrl) throws UnknownTypeExceptio
* @throws IllegalStateException if there is no Protobuf type for the specified class
*/
public static TypeUrl getTypeUrl(ClassName className) {
final TypeUrl result = knownTypes.inverse().get(className);
final TypeUrl result = knownTypes.inverse()
.get(className);
if (result == null) {
throw new IllegalStateException("No Protobuf type URL found for the Java class " + className);
}
return result;
}

/** Returns a Protobuf type URL by Protobuf type name. */
@Nullable
public static TypeUrl getTypeUrl(String typeName) {
final TypeUrl typeUrl = typeNameToUrlMap.get(typeName);
return typeUrl;
Expand Down Expand Up @@ -203,7 +206,8 @@ private void putProperties(Properties properties) {
* <p>This method needs to be updated with introduction of new Google Protobuf types
* after they are used in the framework.
*/
@SuppressWarnings("OverlyLongMethod") // OK as there are many types in Protobuf and we want to keep this code in one place.
@SuppressWarnings("OverlyLongMethod")
// OK as there are many types in Protobuf and we want to keep this code in one place.
private Builder addStandardProtobufTypes() {
// Types from `any.proto`.
put(Any.class);
Expand All @@ -217,14 +221,14 @@ private Builder addStandardProtobufTypes() {
put(DescriptorProtos.FileDescriptorSet.class);
put(DescriptorProtos.FileDescriptorProto.class);
put(DescriptorProtos.DescriptorProto.class);
// Inner types of `DescriptorProto`
put(DescriptorProtos.DescriptorProto.ExtensionRange.class);
put(DescriptorProtos.DescriptorProto.ReservedRange.class);
// Inner types of `DescriptorProto`
put(DescriptorProtos.DescriptorProto.ExtensionRange.class);
put(DescriptorProtos.DescriptorProto.ReservedRange.class);

put(DescriptorProtos.FieldDescriptorProto.class);
putEnum(DescriptorProtos.FieldDescriptorProto.Type.getDescriptor(),
DescriptorProtos.FieldDescriptorProto.Type.class);
putEnum(DescriptorProtos.FieldDescriptorProto.Label.getDescriptor(),
putEnum(DescriptorProtos.FieldDescriptorProto.Type.getDescriptor(),
DescriptorProtos.FieldDescriptorProto.Type.class);
putEnum(DescriptorProtos.FieldDescriptorProto.Label.getDescriptor(),
DescriptorProtos.FieldDescriptorProto.Label.class);

put(DescriptorProtos.OneofDescriptorProto.class);
Expand All @@ -237,21 +241,21 @@ private Builder addStandardProtobufTypes() {
DescriptorProtos.FileOptions.OptimizeMode.class);
put(DescriptorProtos.MessageOptions.class);
put(DescriptorProtos.FieldOptions.class);
putEnum(DescriptorProtos.FieldOptions.CType.getDescriptor(),
DescriptorProtos.FieldOptions.CType.class);
putEnum(DescriptorProtos.FieldOptions.JSType.getDescriptor(),
DescriptorProtos.FieldOptions.JSType.class);
putEnum(DescriptorProtos.FieldOptions.CType.getDescriptor(),
DescriptorProtos.FieldOptions.CType.class);
putEnum(DescriptorProtos.FieldOptions.JSType.getDescriptor(),
DescriptorProtos.FieldOptions.JSType.class);
put(DescriptorProtos.EnumOptions.class);
put(DescriptorProtos.EnumValueOptions.class);
put(DescriptorProtos.ServiceOptions.class);
put(DescriptorProtos.MethodOptions.class);
put(DescriptorProtos.UninterpretedOption.class);
put(DescriptorProtos.SourceCodeInfo.class);
// Inner types of `SourceCodeInfo`.
put(DescriptorProtos.SourceCodeInfo.Location.class);
// Inner types of `SourceCodeInfo`.
put(DescriptorProtos.SourceCodeInfo.Location.class);
put(DescriptorProtos.GeneratedCodeInfo.class);
// Inner types of `GeneratedCodeInfo`.
put(DescriptorProtos.GeneratedCodeInfo.Annotation.class);
// Inner types of `GeneratedCodeInfo`.
put(DescriptorProtos.GeneratedCodeInfo.Annotation.class);

// Types from `duration.proto`.
put(Duration.class);
Expand All @@ -277,8 +281,8 @@ private Builder addStandardProtobufTypes() {
// Types from `type.proto`.
put(Type.class);
put(Field.class);
putEnum(Field.Kind.getDescriptor(), Field.Kind.class);
putEnum(Field.Cardinality.getDescriptor(), Field.Cardinality.class);
putEnum(Field.Kind.getDescriptor(), Field.Kind.class);
putEnum(Field.Cardinality.getDescriptor(), Field.Cardinality.class);
put(com.google.protobuf.Enum.class);
put(EnumValue.class);
put(Option.class);
Expand Down Expand Up @@ -313,8 +317,8 @@ private void putEnum(EnumDescriptor desc, Class<? extends EnumLite> enumClass) {
private void put(TypeUrl typeUrl, ClassName className) {
if (resultMap.containsKey(typeUrl)) {
log().warn("Duplicate key in the {} map: {}. " +
"It may be caused by the `task.descriptorSetOptions.includeImports` option " +
"set to `true` in the `build.gradle`.", KnownTypes.class.getName(), typeUrl);
"It may be caused by the `task.descriptorSetOptions.includeImports` option " +
"set to `true` in the `build.gradle`.", KnownTypes.class.getName(), typeUrl);
return;
}
resultMap.put(typeUrl, className);
Expand Down
Loading