Skip to content

Commit 23b6ed2

Browse files
author
bot
committed
Merge branch 'release/v1.24.0'
2 parents cedacf7 + 5e42c46 commit 23b6ed2

File tree

78 files changed

+2659
-635
lines changed

Some content is hidden

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

78 files changed

+2659
-635
lines changed

.circleci/config.yml

Lines changed: 151 additions & 72 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
Note: version releases in the 0.x.y range may introduce breaking changes.
44

5+
## [1.24.0]
6+
### Added
7+
- Added client support for managing compositions trough contributions ([#406](https://github.com/ehrbase/openEHR_SDK/pull/406))
8+
- Added null verification and change gson to jackson ([#416](https://github.com/ehrbase/openEHR_SDK/pull/416))
9+
### Changed
10+
- Update libraries ([#422](https://github.com/ehrbase/openEHR_SDK/pull/422))
11+
12+
### Fixed
13+
514
## [1.23.0]
615
### Added
716
- Added handling of stored AQL query requests ([#384](https://github.com/ehrbase/openEHR_SDK/pull/384))
@@ -211,3 +220,4 @@ Note: version releases in the 0.x.y range may introduce breaking changes.
211220
[1.21.0]: https://github.com/ehrbase/openEHR_SDK/compare/v1.20.0...v1.21.0
212221
[1.22.0]: https://github.com/ehrbase/openEHR_SDK/compare/v1.21.0...v1.22.0
213222
[1.23.0]: https://github.com/ehrbase/openEHR_SDK/compare/v1.22.0...v1.23.0
223+
[1.24.0]: https://github.com/ehrbase/openEHR_SDK/compare/v1.23.0...v1.24.0

aql/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<parent>
2626
<groupId>org.ehrbase.openehr.sdk</groupId>
2727
<artifactId>root</artifactId>
28-
<version>1.23.0</version>
28+
<version>1.24.0</version>
2929
</parent>
3030

3131
<artifactId>aql</artifactId>

aql/src/main/antlr4/org/ehrbase/aql/parser/Aql.g4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,10 @@ identifiedEquality
135135
: OPEN_PAR* NOT? identifiedOperand COMPARABLEOPERATOR identifiedOperand CLOSE_PAR*
136136
| OPEN_PAR* NOT? identifiedOperand MATCHES OPEN_CURLY matchesOperand CLOSE_CURLY CLOSE_PAR*
137137
| OPEN_PAR* NOT? identifiedOperand MATCHES REGEXPATTERN CLOSE_PAR*
138-
| OPEN_PAR* NOT? identifiedOperand LIKE STRING CLOSE_PAR*
139-
| OPEN_PAR* NOT? identifiedOperand ILIKE STRING CLOSE_PAR*
138+
| OPEN_PAR* NOT? identifiedOperand LIKE likeOperand CLOSE_PAR*
140139
| OPEN_PAR* NOT? identifiedOperand SIMILARTO STRING CLOSE_PAR*
141140
| OPEN_PAR* identifiedOperand NOT? IN OPEN_PAR (identifiedOperand|matchesOperand) CLOSE_PAR CLOSE_PAR*
142-
| OPEN_PAR* NOT? identifiedOperand (COMPARABLEOPERATOR|LIKE|ILIKE) (ANY|ALL|SOME) OPEN_PAR (identifiedOperand|matchesOperand) CLOSE_PAR CLOSE_PAR*
141+
| OPEN_PAR* NOT? identifiedOperand (COMPARABLEOPERATOR|LIKE) (ANY|ALL|SOME) OPEN_PAR (identifiedOperand|matchesOperand) CLOSE_PAR CLOSE_PAR*
143142
| OPEN_PAR* identifiedOperand NOT? BETWEEN identifiedOperand AND identifiedOperand CLOSE_PAR*
144143
| OPEN_PAR* identifiedOperand IS NOT? NULL CLOSE_PAR*
145144
| OPEN_PAR* identifiedOperand IS NOT? UNKNOWN CLOSE_PAR*
@@ -149,6 +148,8 @@ identifiedEquality
149148
| OPEN_PAR* NOT? EXISTS identifiedPath CLOSE_PAR*
150149
| OPEN_PAR* NOT? EXISTS identifiedExpr CLOSE_PAR*;
151150

151+
likeOperand: STRING|PARAMETER;
152+
152153
identifiedOperand
153154
: operand
154155
| identifiedPath
@@ -289,7 +290,6 @@ IN : I N ;
289290
MATCHES : M A T C H E S ;
290291
TERMINOLOGY : T E R M I N O L O G Y ;
291292
LIKE : L I K E ;
292-
ILIKE : I L I K E ;
293293
SIMILARTO: S I M I L A R ' ' T O;
294294
SELECT : S E L E C T ;
295295
TOP : T O P ;

aql/src/main/java/org/ehrbase/aql/binder/WhereBinder.java

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,24 @@
1717
*/
1818
package org.ehrbase.aql.binder;
1919

20-
import java.lang.reflect.InvocationTargetException;
21-
import java.lang.reflect.Method;
2220
import java.util.ArrayList;
2321
import java.util.List;
2422
import java.util.Map;
23+
import java.util.Optional;
2524
import org.apache.commons.lang3.tuple.ImmutablePair;
2625
import org.apache.commons.lang3.tuple.Pair;
2726
import org.ehrbase.aql.dto.condition.ConditionComparisonOperatorDto;
2827
import org.ehrbase.aql.dto.condition.ConditionDto;
2928
import org.ehrbase.aql.dto.condition.ConditionLogicalOperatorDto;
3029
import org.ehrbase.aql.dto.condition.ConditionLogicalOperatorSymbol;
3130
import org.ehrbase.aql.dto.condition.ExistsConditionOperatorDto;
31+
import org.ehrbase.aql.dto.condition.LikeOperatorDto;
3232
import org.ehrbase.aql.dto.condition.MatchesOperatorDto;
3333
import org.ehrbase.aql.dto.condition.NotConditionOperatorDto;
3434
import org.ehrbase.aql.dto.condition.ParameterValue;
3535
import org.ehrbase.aql.dto.condition.SimpleValue;
36+
import org.ehrbase.aql.dto.select.SelectStatementDto;
37+
import org.ehrbase.client.aql.condition.ComparisonOperator;
3638
import org.ehrbase.client.aql.condition.Condition;
3739
import org.ehrbase.client.aql.containment.Containment;
3840
import org.ehrbase.client.aql.field.SelectAqlField;
@@ -46,22 +48,22 @@ public Pair<Condition, List<ParameterValue>> bind(ConditionDto dto, Map<Integer,
4648
Condition condition;
4749
List<ParameterValue> parameterList = new ArrayList<>();
4850
if (dto instanceof ConditionComparisonOperatorDto) {
49-
5051
Pair<Condition, List<ParameterValue>> pair =
5152
handleComparisonOperator((ConditionComparisonOperatorDto) dto, containmentMap);
5253
condition = pair.getLeft();
5354
parameterList.addAll(pair.getRight());
54-
} else if (dto instanceof ConditionLogicalOperatorDto) {
5555

56+
} else if (dto instanceof ConditionLogicalOperatorDto) {
5657
Pair<Condition, List<ParameterValue>> pair =
5758
handleConditionLogicalOperator((ConditionLogicalOperatorDto) dto, containmentMap);
5859
condition = pair.getLeft();
5960
parameterList.addAll(pair.getRight());
61+
6062
} else if (dto instanceof MatchesOperatorDto) {
6163
Object[] value = ((MatchesOperatorDto) dto)
6264
.getValues().stream()
6365
.filter(f -> f.getClass().equals(SimpleValue.class))
64-
.map(v -> (SimpleValue) v)
66+
.map(SimpleValue.class::cast)
6567
.map(SimpleValue::getValue)
6668
.toArray();
6769
if (value.length != ((MatchesOperatorDto) dto).getValues().size()) {
@@ -73,12 +75,19 @@ public Pair<Condition, List<ParameterValue>> bind(ConditionDto dto, Map<Integer,
7375
} else if (dto instanceof ExistsConditionOperatorDto) {
7476
condition =
7577
Condition.exists(selectBinder.bind(((ExistsConditionOperatorDto) dto).getValue(), containmentMap));
78+
7679
} else if (dto instanceof NotConditionOperatorDto) {
7780
condition = Condition.not(bind(((NotConditionOperatorDto) dto).getConditionDto(), containmentMap)
7881
.getLeft());
82+
83+
} else if (dto instanceof LikeOperatorDto) {
84+
Pair<Condition, List<ParameterValue>> pair = handleLikeOperator((LikeOperatorDto) dto, containmentMap);
85+
condition = pair.getLeft();
86+
parameterList.addAll(pair.getRight());
87+
7988
} else {
8089
throw new SdkException(
81-
String.format("Unexpected class: %s", dto.getClass().getSimpleName()));
90+
String.format("Unexpected class: %s", dto.getClass().getName()));
8291
}
8392

8493
return new ImmutablePair<>(condition, parameterList);
@@ -97,39 +106,50 @@ private Pair<Condition, List<ParameterValue>> handleConditionLogicalOperator(
97106
parameterList = subPair.getRight();
98107
}
99108

100-
return new ImmutablePair<>(condition, parameterList);
109+
return Pair.of(condition, parameterList);
101110
}
102111

103-
public Pair<Condition, List<ParameterValue>> handleComparisonOperator(
112+
private Pair<Condition, List<ParameterValue>> handleComparisonOperator(
104113
ConditionComparisonOperatorDto dto, Map<Integer, Containment> containmentMap) {
114+
return handleComparisonOperator(
115+
dto.getValue(), dto.getSymbol().getSymbol(), dto.getStatement(), dto.getClass(), containmentMap);
116+
}
117+
118+
private Pair<Condition, List<ParameterValue>> handleLikeOperator(
119+
LikeOperatorDto dto, Map<Integer, Containment> containmentMap) {
120+
return handleComparisonOperator(
121+
dto.getValue(), LikeOperatorDto.SYMBOL, dto.getStatement(), dto.getClass(), containmentMap);
122+
}
123+
124+
private Pair<Condition, List<ParameterValue>> handleComparisonOperator(
125+
Object value,
126+
String operatorSymbol,
127+
SelectStatementDto statement,
128+
Class<?> dtoClass,
129+
Map<Integer, Containment> containmentMap) {
130+
131+
final Condition condition;
132+
final List<ParameterValue> parameterList = new ArrayList<>();
133+
134+
SelectAqlField<Object> field = selectBinder.bind(statement, containmentMap);
135+
if (value instanceof SimpleValue) {
136+
SimpleValue simpleValue = (SimpleValue) value;
137+
Object conditionValue = simpleValue.getValue();
138+
condition = ComparisonOperator.valueComparison(field, operatorSymbol, conditionValue);
139+
140+
} else if (value instanceof ParameterValue) {
141+
ParameterValue parameterValue = (ParameterValue) value;
142+
Parameter<Object> conditionValue = new Parameter<>(parameterValue.getName());
143+
condition = ComparisonOperator.parameterComparison(field, operatorSymbol, conditionValue);
144+
parameterList.add(parameterValue);
105145

106-
Condition condition;
107-
final Class<?> valueClass;
108-
final Object value;
109-
List<ParameterValue> parameterList = new ArrayList<>();
110-
if (dto.getValue() instanceof SimpleValue) {
111-
valueClass = Object.class;
112-
value = ((SimpleValue) dto.getValue()).getValue();
113-
} else if (dto.getValue() instanceof ParameterValue) {
114-
valueClass = Parameter.class;
115-
value = new Parameter<>(((ParameterValue) dto.getValue()).getName());
116-
parameterList.add(((ParameterValue) dto.getValue()));
117146
} else {
118-
throw new SdkException(
119-
String.format("Unexpected class %s", dto.getClass().getSimpleName()));
120-
}
121-
Method method = null;
122-
try {
123-
method = Condition.class.getMethod(dto.getSymbol().getJavaName(), SelectAqlField.class, valueClass);
124-
} catch (NoSuchMethodException e) {
125-
throw new SdkException(e.getMessage(), e);
147+
throw new SdkException(String.format(
148+
"Unexpected value type %s in %s",
149+
Optional.of(value).map(Object::getClass).map(Class::getName).orElse("null"), dtoClass.getName()));
126150
}
127-
try {
128-
condition = (Condition) method.invoke(null, selectBinder.bind(dto.getStatement(), containmentMap), value);
129-
} catch (IllegalAccessException | InvocationTargetException e) {
130-
throw new SdkException(e.getMessage(), e);
131-
}
132-
return new ImmutablePair<>(condition, parameterList);
151+
152+
return Pair.of(condition, parameterList);
133153
}
134154

135155
private Pair<Condition, List<ParameterValue>> buildLogicalOperator(

aql/src/main/java/org/ehrbase/aql/dto/condition/ConditionComparisonOperatorSymbol.java

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,25 @@
2020
import java.util.NoSuchElementException;
2121

2222
public enum ConditionComparisonOperatorSymbol {
23-
EQ("equal", "="),
24-
NEQ("notEqual", "!="),
25-
GT_EQ("greaterOrEqual", ">="),
26-
GT("greaterThan", ">"),
27-
LT_EQ("lessOrEqual", "<="),
28-
LT("lessThan", "<");
23+
EQ("="),
24+
NEQ("!="),
25+
GT_EQ(">="),
26+
GT(">"),
27+
LT_EQ("<="),
28+
LT("<");
29+
private final String symbol;
2930

30-
private final String javaName;
31-
private final String symbole;
32-
33-
ConditionComparisonOperatorSymbol(String javaName, String symbole) {
34-
this.javaName = javaName;
35-
this.symbole = symbole;
36-
}
37-
38-
public String getJavaName() {
39-
return javaName;
31+
ConditionComparisonOperatorSymbol(String symbol) {
32+
this.symbol = symbol;
4033
}
4134

42-
public String getSymbole() {
43-
return symbole;
35+
public String getSymbol() {
36+
return symbol;
4437
}
4538

4639
public static ConditionComparisonOperatorSymbol fromSymbol(CharSequence symbol) {
4740
for (ConditionComparisonOperatorSymbol s : values()) {
48-
if (s.getSymbole().contentEquals(symbol)) {
41+
if (s.getSymbol().contentEquals(symbol)) {
4942
return s;
5043
}
5144
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (c) 2020 vitasystems GmbH and Hannover Medical School.
3+
*
4+
* This file is part of project openEHR_SDK
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.ehrbase.aql.dto.condition;
19+
20+
import org.ehrbase.aql.dto.select.SelectStatementDto;
21+
22+
public class LikeOperatorDto implements ConditionDto {
23+
24+
public static final String SYMBOL = "like";
25+
26+
private SelectStatementDto statement;
27+
28+
private Value value;
29+
30+
public SelectStatementDto getStatement() {
31+
return this.statement;
32+
}
33+
34+
public Value getValue() {
35+
return this.value;
36+
}
37+
38+
public void setStatement(SelectStatementDto statement) {
39+
this.statement = statement;
40+
}
41+
42+
public void setValue(Value value) {
43+
this.value = value;
44+
}
45+
46+
public boolean equals(final Object o) {
47+
if (o == this) return true;
48+
if (!(o instanceof LikeOperatorDto)) return false;
49+
final LikeOperatorDto other = (LikeOperatorDto) o;
50+
if (!other.canEqual((Object) this)) return false;
51+
final Object this$statement = this.getStatement();
52+
final Object other$statement = other.getStatement();
53+
if (this$statement == null ? other$statement != null : !this$statement.equals(other$statement)) return false;
54+
final Object this$value = this.getValue();
55+
final Object other$value = other.getValue();
56+
if (this$value == null ? other$value != null : !this$value.equals(other$value)) return false;
57+
return true;
58+
}
59+
60+
protected boolean canEqual(final Object other) {
61+
return other instanceof LikeOperatorDto;
62+
}
63+
64+
public int hashCode() {
65+
final int PRIME = 59;
66+
int result = 1;
67+
final Object $statement = this.getStatement();
68+
result = result * PRIME + ($statement == null ? 43 : $statement.hashCode());
69+
final Object $value = this.getValue();
70+
result = result * PRIME + ($value == null ? 43 : $value.hashCode());
71+
return result;
72+
}
73+
74+
public String toString() {
75+
return "LikeOperatorDto(statement=" + this.getStatement() + ", value=" + this.getValue() + ")";
76+
}
77+
}

aql/src/main/java/org/ehrbase/aql/dto/path/predicate/PredicateHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class PredicateHelper {
5252

5353
private static final AqlPathHelper.PrefixMatcher OPERATOR_SYMBOLS =
5454
AqlPathHelper.PrefixMatcher.forStrings(Arrays.stream(ConditionComparisonOperatorSymbol.values())
55-
.map(ConditionComparisonOperatorSymbol::getSymbole)
55+
.map(ConditionComparisonOperatorSymbol::getSymbol)
5656
.toArray(String[]::new));
5757

5858
private static final PredicateComparisonOperatorDto NO_PREDICATE =
@@ -265,7 +265,7 @@ private static void formatPredicateComparisonOperatorDto(
265265
format(predicateDto.getStatement(), sb, predicateDto.getValue());
266266
} else if (!isNone(predicateDto, otherPredicatesFormat)) {
267267
sb.append(predicateDto.getStatement())
268-
.append(predicateDto.getSymbol().getSymbole());
268+
.append(predicateDto.getSymbol().getSymbol());
269269
format(predicateDto.getStatement(), sb, predicateDto.getValue());
270270
}
271271
}

0 commit comments

Comments
 (0)