Search in sources :

Example 1 with AutoWhereCondition

use of org.ehrbase.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto.AutoWhereCondition in project openEHR_SDK by ehrbase.

the class TestQueryEngine method checkAutoWhereQuery.

protected void checkAutoWhereQuery(String csvPath, String rootPath, String contains, RMObject referenceNode) throws FileNotFoundException {
    SimplePathExpressionSettings simplePathExpressionSettings = new SimplePathExpressionSettings();
    CsvParser csvParser = new CsvParser(simplePathExpressionSettings.settings());
    csvParser.parse(new FileReader(csvPath));
    List<PathExpression> attributeDefinitions = simplePathExpressionSettings.getPathExpressionRow().getBeans();
    for (PathExpression pathExpression : attributeDefinitions) {
        if (pathExpression.getComment() == null) {
            // conventionally, if params[1] exists, this means skip the test
            String attributePath = pathExpression.getPath();
            QueryResponseData result = performQueryWithWhere(rootPath, attributePath, contains, new AutoWhereCondition(rootPath, attributePath, referenceNode).condition());
            if (result.getRows().isEmpty())
                fail(rootPath + "/" + attributePath + ": no result");
            List<Object> objectList = result.getRows().get(0);
            assertThat(valueObject(objectList.get(0))).as(rootPath + "/" + attributePath).isEqualTo(attributeValueAt(referenceNode, attributePath));
        }
    }
}
Also used : SimplePathExpressionSettings(org.ehrbase.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.simple.SimplePathExpressionSettings) PathExpression(org.ehrbase.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.simple.PathExpression) AutoWhereCondition(org.ehrbase.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto.AutoWhereCondition) CsvParser(org.junit.jupiter.params.shadow.com.univocity.parsers.csv.CsvParser) FileReader(java.io.FileReader) QueryResponseData(org.ehrbase.response.openehr.QueryResponseData) RMObject(com.nedap.archie.rm.RMObject)

Example 2 with AutoWhereCondition

use of org.ehrbase.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto.AutoWhereCondition in project openEHR_SDK by ehrbase.

the class TestQueryEngine method performEhrStatusQueryWithAutoWhere.

private QueryResponseData performEhrStatusQueryWithAutoWhere(String rootPath, String attributePath, RMObject referenceNode) {
    String whereCondition = new AutoWhereCondition(rootPath, attributePath, referenceNode).condition();
    Query<Record1<Map>> query = Query.buildNativeQuery(new AqlExpressionBuilder(rootPath, attributePath).ehrStatus(whereCondition), Map.class);
    try {
        return openEhrClient.aqlEndpoint().executeRaw(query, new ParameterValue("ehr_id", ehrUUID));
    } catch (WrongStatusCodeException e) {
        fail("path:" + rootPath + "/" + attributePath + ", error" + e.getMessage());
    }
    return null;
}
Also used : ParameterValue(org.ehrbase.client.aql.parameter.ParameterValue) AutoWhereCondition(org.ehrbase.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto.AutoWhereCondition) WrongStatusCodeException(org.ehrbase.client.exception.WrongStatusCodeException) Record1(org.ehrbase.client.aql.record.Record1)

Aggregations

AutoWhereCondition (org.ehrbase.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto.AutoWhereCondition)2 RMObject (com.nedap.archie.rm.RMObject)1 FileReader (java.io.FileReader)1 ParameterValue (org.ehrbase.client.aql.parameter.ParameterValue)1 Record1 (org.ehrbase.client.aql.record.Record1)1 WrongStatusCodeException (org.ehrbase.client.exception.WrongStatusCodeException)1 PathExpression (org.ehrbase.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.simple.PathExpression)1 SimplePathExpressionSettings (org.ehrbase.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.simple.SimplePathExpressionSettings)1 QueryResponseData (org.ehrbase.response.openehr.QueryResponseData)1 CsvParser (org.junit.jupiter.params.shadow.com.univocity.parsers.csv.CsvParser)1