Skip to content

Commit b5c0093

Browse files
authored
Merge pull request #5517 from Sage-Bionetworks/release-578
Release 578
2 parents 0eb38b1 + 2ab259d commit b5c0093

File tree

84 files changed

+2214
-746
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2214
-746
lines changed

lib/jdomodels/src/test/java/org/sagebionetworks/evaluation/dbo/grid/GridDaoImplTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.sagebionetworks.repo.model.grid.GridSession;
3939
import org.sagebionetworks.repo.model.grid.GridSnapshot;
4040
import org.sagebionetworks.repo.model.grid.PatchInfo;
41+
import org.sagebionetworks.repo.model.grid.RequestOrigin;
4142
import org.sagebionetworks.repo.model.grid.patch.LogicalTimestamp;
4243
import org.sagebionetworks.repo.model.jdo.KeyFactory;
4344
import org.sagebionetworks.repo.model.jdo.NodeTestUtils;
@@ -329,7 +330,7 @@ public void testConnectionCRUD(EventSource source) throws InterruptedException {
329330

330331
// call under test
331332
List<GridConnectionInfo> listed = dao.listConnections(session.getSessionId());
332-
List<GridConnectionInfo> expected = source == EventSource.WEBSOCKET ? List.of(f1, f2) : List.of(f2, f1);
333+
List<GridConnectionInfo> expected = source.getRequestOrigin() == RequestOrigin.USER ? List.of(f1, f2) : List.of(f2, f1);
333334
assertEquals(expected, listed);
334335

335336
// call under test

lib/lib-grid/src/main/java/org/sagebionetworks/repo/model/grid/EventSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public enum EventSource {
2323
* Agent driven updates to the grid. There can be many agents for a single
2424
* session.
2525
*/
26-
AGENT(false, RequestOrigin.SERVICE),
26+
AGENT(false, RequestOrigin.USER),
2727

2828
/*
2929
* Patches generated by the system on the user behalf.
Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.sagebionetworks.repo.model.grid;
22

3+
import org.sagebionetworks.util.ValidateArgument;
4+
35
public class GridConstants {
46

57
/**
@@ -9,16 +11,29 @@ public class GridConstants {
911
public static final Long MIN_REPICA_ID = (long) 0xffff;
1012

1113
/**
12-
* The starting user replica ID for a grid session. Client replicas will increment
13-
* this value.
14+
* The starting user replica ID for a grid session. Client replicas will
15+
* increment this value.
1416
*/
1517
public static final Long START_REPLICA_ID_CLIENT = MIN_REPICA_ID + 1001;
1618
/**
1719
* The starting internal replica ID for grid session. Service replicas will
18-
* decrement this value. This ensure all service replica ID are smaller than
19-
* all client replica ID. This means when an service and client replica have a
20+
* decrement this value. This ensure all service replica ID are smaller than all
21+
* client replica ID. This means when an service and client replica have a
2022
* conflict, the client's replica always wins.
2123
*/
2224
public static final Long START_REPLICA_ID_SERVICE = START_REPLICA_ID_CLIENT - 1;
2325

26+
/**
27+
* Returns true if the passed replica ID is a USER replica (clients or agents).
28+
* Returns false if the passed replica ID is a SERVICE (like internal replica or
29+
* validation replica)
30+
*
31+
* @param replicaId
32+
* @return
33+
*/
34+
public static boolean isUserReplica(Long replicaId) {
35+
ValidateArgument.required(replicaId, "replicaId");
36+
return replicaId >= START_REPLICA_ID_CLIENT;
37+
}
38+
2439
}

lib/lib-grid/src/main/java/org/sagebionetworks/repo/model/grid/patch/operation/builder/DeleteBuilder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,10 @@ public boolean equals(Object obj) {
4444
DeleteBuilder other = (DeleteBuilder) obj;
4545
return Objects.equals(nodeId, other.nodeId) && Objects.equals(timeSpans, other.timeSpans);
4646
}
47+
48+
@Override
49+
public String toString() {
50+
return "DeleteBuilder [nodeId=" + nodeId + ", timeSpans=" + timeSpans + "]";
51+
}
4752

4853
}

lib/lib-grid/src/main/java/org/sagebionetworks/repo/model/grid/patch/operation/builder/InsertObjectBuilder.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,11 @@ public boolean equals(Object o) {
4444
public int hashCode() {
4545
return Objects.hash(objectId, map);
4646
}
47+
48+
@Override
49+
public String toString() {
50+
return "InsertObjectBuilder [objectId=" + objectId + ", map=" + map + "]";
51+
}
52+
53+
4754
}

lib/lib-grid/src/main/java/org/sagebionetworks/repo/model/grid/patch/operation/builder/InsertVectorBuilder.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,10 @@ public boolean equals(Object o) {
4444
public int hashCode() {
4545
return Objects.hash(vectorId, map);
4646
}
47+
48+
@Override
49+
public String toString() {
50+
return "InsertVectorBuilder [vectorId=" + vectorId + ", map=" + map + "]";
51+
}
52+
4753
}

lib/lib-grid/src/main/java/org/sagebionetworks/repo/model/grid/patch/operation/builder/NewConstantBuilder.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,10 @@ public boolean equals(Object o) {
3434
public int hashCode() {
3535
return Objects.hashCode(value);
3636
}
37+
38+
@Override
39+
public String toString() {
40+
return "NewConstantBuilder [value=" + value + "]";
41+
}
42+
3743
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.sagebionetworks.repo.model.grid;
2+
3+
import static org.junit.Assert.assertFalse;
4+
import static org.junit.Assert.assertTrue;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
import static org.junit.jupiter.api.Assertions.assertThrows;
7+
8+
import org.junit.jupiter.api.Test;
9+
10+
public class GridConstantsTest {
11+
12+
@Test
13+
public void testIsUserReplica() {
14+
assertTrue(GridConstants.isUserReplica(GridConstants.START_REPLICA_ID_CLIENT));
15+
assertTrue(GridConstants.isUserReplica(GridConstants.START_REPLICA_ID_CLIENT + 1L));
16+
assertFalse(GridConstants.isUserReplica(GridConstants.START_REPLICA_ID_SERVICE));
17+
assertFalse(GridConstants.isUserReplica(GridConstants.START_REPLICA_ID_SERVICE - 1));
18+
}
19+
20+
@Test
21+
public void testIsUserReplciaWithNullId() {
22+
23+
String message = assertThrows(IllegalArgumentException.class, () -> {
24+
// call under test
25+
GridConstants.isUserReplica(null);
26+
27+
}).getMessage();
28+
assertEquals("replicaId is required.", message);
29+
}
30+
31+
}

services/repository-managers/src/main/java/org/sagebionetworks/repo/manager/evaluation/EvaluationPermissionsManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.sagebionetworks.evaluation.dao.SubmissionDAO;
2121
import org.sagebionetworks.evaluation.model.Evaluation;
2222
import org.sagebionetworks.evaluation.model.UserEvaluationPermissions;
23-
import org.sagebionetworks.repo.manager.AccessControlListManager;;
23+
import org.sagebionetworks.repo.manager.AccessControlListManager;
2424
import org.sagebionetworks.repo.manager.UserManager;
2525
import org.sagebionetworks.repo.model.ACCESS_TYPE;
2626
import org.sagebionetworks.repo.model.AccessControlList;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package org.sagebionetworks.repo.manager.grid;
2+
3+
/**
4+
* Constants for the Grid document schema.
5+
*
6+
* @see <a href=
7+
* "https://sagebionetworks.jira.com/wiki/spaces/PLFM/pages/4123361355/Grid+Implementation+Using+JSON+Joy">Grid
8+
* Implementation Using JSON Joy</a>
9+
*/
10+
public class DocumentConstants {
11+
12+
/**
13+
* The semantic version of the document schema. This value will change anytime
14+
* the schema changes.
15+
*/
16+
public static final String DOC_VERSION = "doc_version";
17+
18+
/**
19+
* Vector that captures the name of columns in their natural order (order they
20+
* were added). Vectors are append-only (up to 256 values) and allow LWW changes
21+
* to each index.
22+
*/
23+
public static final String COLUMN_NAMES = "columnNames";
24+
25+
/**
26+
* Array that defines the order columns should be displayed. Each value is an
27+
* index into columnNames. The array can be reordered.
28+
*/
29+
public static final String COLUMN_ORDER = "columnOrder";
30+
31+
/**
32+
* Array of row objects. Each row contains data and metadata properties. The
33+
* array represents the mutable row order.
34+
*/
35+
public static final String ROWS = "rows";
36+
37+
/**
38+
* The row data vector represents the data in a row. The order matches the
39+
* columnNames vector. Each cell can be changed to a new constant. Cells with
40+
* identical values typically share a reference.
41+
*/
42+
public static final String DATA = "data";
43+
44+
/**
45+
* Reference to a constant containing JSON serialization of [rowId, rowVersion,
46+
* etag]. Maps a row back to its source from a Synapse Table or View. Omitted if
47+
* items are not defined.
48+
*/
49+
public static final String SYNAPSE_ROW = "synapseRow";
50+
51+
/**
52+
* Object containing supplemental information about the row. Should be treated
53+
* as read-only for all replicas other than the hub. May be omitted if no
54+
* additional information is included.
55+
*/
56+
public static final String METADATA = "metadata";
57+
58+
/**
59+
* Reference to a constant containing JSON serialization of the ValidationResult
60+
* object. The ValidationResult is identical to results provided for Entity
61+
* Validation.
62+
*/
63+
public static final String ROW_VALIDATION = "rowValidation";
64+
}

0 commit comments

Comments
 (0)