Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions client-js/main/client/actor-request-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@ import {FieldMask} from '../proto/google/protobuf/field_mask_pb';
import {isProtobufMessage, Type, TypedMessage} from './typed-message';
import {AnyPacker} from './any-packer';
import {FieldPaths} from './field-paths';
import {EnumValue} from 'google-protobuf/google/protobuf/type_pb';

/**
* Wraps the passed enum value as Protobuf `EnumValue` so it can be correctly processed by the
* server.
*
* As enums in Protobuf JS are declared as plain `number`s, their values can be passed to this
* method as-is, for example: `enumValueOf(Task.Severity.HIGH)`.
*
* @param {!number} value the enum value
* @returns {EnumValue} the `EnumValue` instance
*/
export function enumValueOf(value) {
const result = new EnumValue();
result.setNumber(value);
return result;
}

const ENUM_VALUE_TYPE_URL = 'type.googleapis.com/google.protobuf.EnumValue';

// TODO:2019-06-07:yegor.udovchenko: Cover `Filters` class with the unit tests
// https://github.com/SpineEventEngine/web/issues/100
Expand Down Expand Up @@ -166,6 +185,9 @@ export class Filters {
typedValue = TypedMessage.bool(value);
} else if (value instanceof Date) {
typedValue = TypedMessage.timestamp(value);
} else if (value instanceof EnumValue) {
const type = Type.of(EnumValue, ENUM_VALUE_TYPE_URL);
typedValue = new TypedMessage(value, type);
} else if (value instanceof TypedMessage) {
typedValue = value;
} else if(isProtobufMessage(value)) {
Expand Down
2 changes: 1 addition & 1 deletion client-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spine-web",
"version": "1.2.9",
"version": "1.2.10",
"license": "Apache-2.0",
"description": "A JS client for interacting with Spine applications.",
"homepage": "https://spine.io",
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/js-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "client-js-tests",
"version": "1.2.9",
"version": "1.2.10",
"license": "Apache-2.0",
"description": "Tests of a `spine-web` JS library against the Spine-based application.",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import assert from 'assert';
import {ensureUserTasks, fail} from '../test-helpers';
import {UserTasksTestEnvironment as TestEnvironment} from '../given/users-test-environment';
import {client} from './given/firebase-client';
import {Filters} from '@lib/client/actor-request-factory';
import {enumValueOf, Filters} from '@lib/client/actor-request-factory';
import {TypedMessage} from '@lib/client/typed-message';
import {BoolValue} from '@testProto/google/protobuf/wrappers_pb';
import {UserTasks} from '@testProto/spine/web/test/given/user_tasks_pb';
Expand Down Expand Up @@ -101,6 +101,13 @@ describe('FirebaseClient executes query built', function () {
],
expectedUsers: () => users.filter(user => user.tasks.length === 3)
},
{
message: 'with `eq` filter targeting a enum column',
filters: [
Filters.eq('load', enumValueOf(UserTasks.Load.VERY_HIGH))
],
expectedUsers: () => users.filter(user => user.tasks.length > 1)
},
{
message: 'with `lt` filter',
filters: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

import java.util.List;

import static io.spine.web.test.given.UserTasks.Load.HIGH;
import static io.spine.web.test.given.UserTasks.Load.LOW;
import static io.spine.web.test.given.UserTasks.Load.VERY_HIGH;

/**
* A projection representing a user and a list of {@link TaskId tasks} assigned to him.
*
Expand Down Expand Up @@ -81,6 +85,17 @@ public boolean getIsOverloaded() {
return state().getTasksCount() > 1;
}

@Override
public UserTasks.Load getLoad() {
if (getTaskCount() == 0) {
return LOW;
} else if (getTaskCount() == 1) {
return HIGH;
} else {
return VERY_HIGH;
}
}

private boolean reassignedFromThisUser(TaskReassigned event) {
return event.hasFrom() && event.getFrom().equals(id());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@ message UserTasks {
int32 task_count = 4 [(column) = true];

bool is_overloaded = 5 [(column) = true];

Load load = 6 [(column) = true];

enum Load {
LOW = 0;
HIGH = 1;
VERY_HIGH = 2;
}
}
395 changes: 202 additions & 193 deletions license-report.md

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject.

<groupId>io.spine</groupId>
<artifactId>spine-web</artifactId>
<version>1.2.9</version>
<version>1.2.10</version>

<inceptionYear>2015</inceptionYear>

Expand Down Expand Up @@ -76,7 +76,7 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine</groupId>
<artifactId>spine-server</artifactId>
<version>1.2.9</version>
<version>1.2.10</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -100,13 +100,13 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine</groupId>
<artifactId>spine-testutil-client</artifactId>
<version>1.2.9</version>
<version>1.2.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-mute-logging</artifactId>
<version>1.2.3</version>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -168,17 +168,17 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine</groupId>
<artifactId>spine-client</artifactId>
<version>1.2.9</version>
<version>1.2.10</version>
</dependency>
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-errorprone-checks</artifactId>
<version>1.2.3</version>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-protoc-plugin</artifactId>
<version>1.2.3</version>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
Expand Down
6 changes: 3 additions & 3 deletions version.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
*/

ext {
spineVersion = '1.2.9'
spineBaseVersion = '1.2.3'
spineVersion = '1.2.10'
spineBaseVersion = '1.2.4'

versionToPublish = '1.2.9'
versionToPublish = '1.2.10'
versionToPublishJs = versionToPublish

servletApiVersion = '3.1.0'
Expand Down