Skip to content

Commit 1b4ec7e

Browse files
author
Burak Serdar
committed
Rename ifSame to ifCurrent
1 parent 9ef0728 commit 1b4ec7e

File tree

8 files changed

+35
-58
lines changed

8 files changed

+35
-58
lines changed

crud/src/main/java/com/redhat/lightblue/crud/DeleteRequest.java

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,10 @@
2929
/**
3030
* Request to delete documents matching a query
3131
*/
32-
public class DeleteRequest extends Request implements WithQuery, WithIfSame {
32+
public class DeleteRequest extends Request implements WithQuery {
3333

3434
private QueryExpression query;
35-
private boolean ifSameOnly;
36-
private List<String> documentVersions;
3735

38-
@Override
39-
public boolean isIfSameOnly() {
40-
return ifSameOnly;
41-
}
42-
43-
@Override
44-
public void setIfSameOnly(boolean b) {
45-
ifSameOnly=b;
46-
}
47-
48-
@Override
49-
public List<String> getDocumentVersions() {
50-
return documentVersions;
51-
}
52-
53-
@Override
54-
public void setDocumentVersions(List<String> s) {
55-
documentVersions=s;
56-
}
5736

5837
/**
5938
* The query whose result set will be deleted
@@ -84,7 +63,6 @@ public JsonNode toJson() {
8463
if (query != null) {
8564
node.set("query", query.toJson());
8665
}
87-
WithIfSame.toJson(this,node);
8866
return node;
8967
}
9068

@@ -100,7 +78,6 @@ public static DeleteRequest fromJson(ObjectNode node) {
10078
if (x != null) {
10179
req.query = QueryExpression.fromJson(x);
10280
}
103-
WithIfSame.fromJson(req,node);
10481
return req;
10582
}
10683
}

crud/src/main/java/com/redhat/lightblue/crud/SaveRequest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@
2727
/**
2828
* Request to save documents
2929
*/
30-
public class SaveRequest extends DocRequest implements WithRange, WithProjection, WithIfSame {
30+
public class SaveRequest extends DocRequest implements WithRange, WithProjection, WithIfCurrent {
3131

3232
private Projection returnFields;
3333
private boolean upsert;
3434
private Long from;
3535
private Long to;
36-
private boolean ifSameOnly;
36+
private boolean ifCurrentOnly;
3737
private List<String> documentVersions;
3838

3939
@Override
40-
public boolean isIfSameOnly() {
41-
return ifSameOnly;
40+
public boolean isIfCurrentOnly() {
41+
return ifCurrentOnly;
4242
}
4343

4444
@Override
45-
public void setIfSameOnly(boolean b) {
46-
ifSameOnly=b;
45+
public void setIfCurrentOnly(boolean b) {
46+
ifCurrentOnly=b;
4747
}
4848

4949
@Override
@@ -124,7 +124,7 @@ public JsonNode toJson() {
124124
node.set("projection", returnFields.toJson());
125125
}
126126
node.put("upsert", upsert);
127-
WithIfSame.toJson(this,node);
127+
WithIfCurrent.toJson(this,node);
128128
WithRange.toJson(this, getFactory(), node);
129129
return node;
130130
}
@@ -143,7 +143,7 @@ public static SaveRequest fromJson(ObjectNode node) {
143143
if (x != null) {
144144
req.upsert = x.asBoolean();
145145
}
146-
WithIfSame.fromJson(req,node);
146+
WithIfCurrent.fromJson(req,node);
147147
Range r = WithRange.fromJson(node);
148148
req.setFrom(r.from);
149149
req.setTo(r.to);

crud/src/main/java/com/redhat/lightblue/crud/UpdateRequest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@
3030
/**
3131
* Request to update documents based on a query
3232
*/
33-
public class UpdateRequest extends Request implements WithQuery, WithProjection, WithRange, WithIfSame {
33+
public class UpdateRequest extends Request implements WithQuery, WithProjection, WithRange, WithIfCurrent {
3434

3535
private QueryExpression query;
3636
private UpdateExpression updateExpression;
3737
private Projection returnFields;
3838
private Long from;
3939
private Long to;
40-
private boolean ifSameOnly;
40+
private boolean ifCurrentOnly;
4141
private List<String> documentVersions;
4242

4343
@Override
44-
public boolean isIfSameOnly() {
45-
return ifSameOnly;
44+
public boolean isIfCurrentOnly() {
45+
return ifCurrentOnly;
4646
}
4747

4848
@Override
49-
public void setIfSameOnly(boolean b) {
50-
ifSameOnly=b;
49+
public void setIfCurrentOnly(boolean b) {
50+
ifCurrentOnly=b;
5151
}
5252

5353
@Override
@@ -146,7 +146,7 @@ public JsonNode toJson() {
146146
if (returnFields != null) {
147147
node.set("projection", returnFields.toJson());
148148
}
149-
WithIfSame.toJson(this,node);
149+
WithIfCurrent.toJson(this,node);
150150
WithRange.toJson(this, getFactory(), node);
151151
return node;
152152
}
@@ -169,7 +169,7 @@ public static UpdateRequest fromJson(ObjectNode node) {
169169
if (x != null) {
170170
req.returnFields = Projection.fromJson(x);
171171
}
172-
WithIfSame.fromJson(req,node);
172+
WithIfCurrent.fromJson(req,node);
173173
Range r = WithRange.fromJson(node);
174174
req.setFrom(r.from);
175175
req.setTo(r.to);

crud/src/main/java/com/redhat/lightblue/crud/WithIfSame.java renamed to crud/src/main/java/com/redhat/lightblue/crud/WithIfCurrent.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,25 @@
3333
/**
3434
* Marker interface for requests containing if-same flag, and doc versions
3535
*/
36-
public interface WithIfSame {
36+
public interface WithIfCurrent {
3737

3838
/**
3939
* Returns true if the is-samne-only flag is set.
4040
*/
41-
boolean isIfSameOnly();
42-
void setIfSameOnly(boolean b);
41+
boolean isIfCurrentOnly();
42+
void setIfCurrentOnly(boolean b);
4343

4444
/**
45-
* The list of document versions. If isIfSameOnly()==true, then,
45+
* The list of document versions. If isIfCurrentOnly()==true, then,
4646
* only the documents that are in this list will be updated, and
4747
* only if their versions are the same.
4848
*/
4949
List<String> getDocumentVersions();
5050
void setDocumentVersions(List<String> s);
5151

52-
public static void toJson(WithIfSame w,ObjectNode parent) {
53-
if(w!=null&&w.isIfSameOnly()) {
54-
parent.set("onlyIfSame",JsonNodeFactory.instance.booleanNode(true));
52+
public static void toJson(WithIfCurrent w,ObjectNode parent) {
53+
if(w!=null&&w.isIfCurrentOnly()) {
54+
parent.set("onlyIfCurrent",JsonNodeFactory.instance.booleanNode(true));
5555
List<String> versions=w.getDocumentVersions();
5656
if(versions!=null&&!versions.isEmpty()) {
5757
ArrayNode arr=JsonNodeFactory.instance.arrayNode();
@@ -62,10 +62,10 @@ public static void toJson(WithIfSame w,ObjectNode parent) {
6262
}
6363
}
6464

65-
public static void fromJson(WithIfSame dest,ObjectNode node) {
66-
JsonNode x=node.get("onlyIfSame");
65+
public static void fromJson(WithIfCurrent dest,ObjectNode node) {
66+
JsonNode x=node.get("onlyIfCurrent");
6767
if(x instanceof ValueNode && x.booleanValue()) {
68-
dest.setIfSameOnly(true);
68+
dest.setIfCurrentOnly(true);
6969
x=node.get("documentVersions");
7070
if(x instanceof ArrayNode) {
7171
List<String> versions=new ArrayList<>(x.size());
@@ -78,7 +78,7 @@ public static void fromJson(WithIfSame dest,ObjectNode node) {
7878
dest.setDocumentVersions(versions);
7979
}
8080
} else {
81-
dest.setIfSameOnly(false);
81+
dest.setIfCurrentOnly(false);
8282
}
8383
}
8484
}

crud/src/main/java/com/redhat/lightblue/mediator/Mediator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
import com.redhat.lightblue.crud.UpdateRequest;
5454
import com.redhat.lightblue.crud.WithQuery;
5555
import com.redhat.lightblue.crud.WithRange;
56-
import com.redhat.lightblue.crud.WithIfSame;
56+
import com.redhat.lightblue.crud.WithIfCurrent;
5757
import com.redhat.lightblue.assoc.AnalyzeQuery;
5858
import com.redhat.lightblue.assoc.QueryFieldInfo;
5959
import com.redhat.lightblue.eval.FieldAccessRoleEvaluator;
@@ -670,9 +670,9 @@ public BulkResponse bulkRequest(BulkRequest requests) {
670670

671671
protected OperationContext newCtx(Request request, CRUDOperation CRUDOperation) {
672672
OperationContext ctx=new OperationContext(request, metadata, factory, CRUDOperation);
673-
if(request instanceof WithIfSame) {
674-
WithIfSame wif=(WithIfSame)request;
675-
if(wif.isIfSameOnly()) {
673+
if(request instanceof WithIfCurrent) {
674+
WithIfCurrent wif=(WithIfCurrent)request;
675+
if(wif.isIfCurrentOnly()) {
676676
ctx.setUpdateIfCurrent(true);
677677
List<String> list=wif.getDocumentVersions();
678678
if(list!=null)

crud/src/main/resources/json-schema/deleteRequest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"query": {
3535
"$ref": "/json-schema/crudCommon.json#/definitions/query"
3636
},
37-
"onlyIfSame":{
37+
"onlyIfCurrent":{
3838
"type":"boolean",
3939
"description":"If true, perform the operation only if document version is unchanged"
4040
},

crud/src/main/resources/json-schema/saveRequest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"type": "boolean",
4646
"default": false
4747
},
48-
"onlyIfSame":{
48+
"onlyIfCurrent":{
4949
"type":"boolean",
5050
"description":"If true, perform the operation only if document version is unchanged"
5151
},

crud/src/main/resources/json-schema/updateRequest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
}
4949
]
5050
},
51-
"onlyIfSame":{
51+
"onlyIfCurrent":{
5252
"type":"boolean",
5353
"description":"If true, perform the operation only if document version is unchanged"
5454
},

0 commit comments

Comments
 (0)