-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sync/cdr 423 enhance sdk parser #376
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
85a059c
update aql grammar
stefanspiska 5ba6ae5
add AqlExpressionTest
stefanspiska c09d7ea
move all aql stuff to aql module
stefanspiska 14c7671
new predate handler for aql
stefanspiska 7b228ff
fix formatting of predicate
stefanspiska b63ac7c
aql parser: parse ehr/id
stefanspiska 4700475
aql parser: parse predicate with other than equal
stefanspiska b7b3dd5
aql parser: parse functions
stefanspiska 1325c08
fix aql predicate value parsing
stefanspiska 33f27b3
aql parsing allow reference by name
stefanspiska 9bd352c
add aql path to dto modele
stefanspiska de986a3
add test cases
stefanspiska edbefc7
aql parser: parse not and exist in where
stefanspiska ee2c042
aql parser: support more functions
stefanspiska 3a75f38
aql parser: support distinct and correct limit
stefanspiska 1da2e02
aql parser: add test cases
stefanspiska 2dc6ba5
code cleanup
stefanspiska 0c8169a
[skip ci] update changelog
stefanspiska 42c7c27
Merge branch 'develop' into sync/CDR-423_enhance_sdk_parser
stefanspiska 01d0ace
fix review
stefanspiska File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,14 @@ | |
|
||
import java.util.Map; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.ehrbase.aql.dto.select.FunctionDto; | ||
import org.ehrbase.aql.dto.select.SelectFieldDto; | ||
import org.ehrbase.aql.dto.select.SelectStatementDto; | ||
import org.ehrbase.aql.parser.AqlParseException; | ||
import org.ehrbase.client.aql.containment.Containment; | ||
import org.ehrbase.client.aql.field.NativeSelectAqlField; | ||
import org.ehrbase.client.aql.field.SelectAqlField; | ||
import org.ehrbase.client.aql.funtion.Function; | ||
import org.ehrbase.util.exception.SdkException; | ||
|
||
public class SelectBinder { | ||
|
@@ -32,13 +35,32 @@ public SelectAqlField<Object> bind(SelectStatementDto dto, Map<Integer, Containm | |
SelectAqlField<Object> selectAqlField; | ||
if (dto instanceof SelectFieldDto) { | ||
selectAqlField = handleSelectFieldDto((SelectFieldDto) dto, containmentMap); | ||
} else if (dto instanceof FunctionDto) { | ||
selectAqlField = handleFunctionDto((FunctionDto) dto, containmentMap); | ||
} else { | ||
throw new SdkException( | ||
String.format("Unexpected class: %s", dto.getClass().getSimpleName())); | ||
} | ||
return selectAqlField; | ||
} | ||
|
||
private SelectAqlField<Object> handleFunctionDto(FunctionDto dto, Map<Integer, Containment> containmentMap) { | ||
|
||
switch (dto.getAqlFunction()) { | ||
case COUNT: | ||
return (SelectAqlField) Function.count(bind(dto.getParameters().get(0), containmentMap), dto.getName()); | ||
case MAX: | ||
return (SelectAqlField) Function.max(bind(dto.getParameters().get(0), containmentMap), dto.getName()); | ||
case MIN: | ||
return (SelectAqlField) Function.min(bind(dto.getParameters().get(0), containmentMap), dto.getName()); | ||
case AVG: | ||
return (SelectAqlField) Function.avg(bind(dto.getParameters().get(0), containmentMap), dto.getName()); | ||
default: | ||
throw new AqlParseException(String.format( | ||
"Unsupported Funktion %s", dto.getAqlFunction().name())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo "Unsupported Function" |
||
} | ||
} | ||
|
||
public SelectAqlField<Object> handleSelectFieldDto(SelectFieldDto dto, Map<Integer, Containment> containmentMap) { | ||
SelectAqlField<Object> selectAqlField; | ||
selectAqlField = new NativeSelectAqlField<>( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am aware it is from the other grammar, but this would also parse e.g.
CONCAT( , "x")
.How about
FUNCTION_IDENTIFIER OPEN_PAR ((IDENTIFIER|identifiedPath|operand) (COMMA (IDENTIFIER|identifiedPath|operand))*)? CLOSE_PAR
?