Skip to content

Commit

Permalink
Merge pull request ehrbase#250 from ehrbase/feature/PEA-163_fix_hande…
Browse files Browse the repository at this point in the history
…ling_of_etag

Feature/pea 163 fix handeling of etag
  • Loading branch information
stefanspiska authored Aug 19, 2021
2 parents 78e84f6 + b3f6560 commit 11674b6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.util.UUID;
import java.util.WeakHashMap;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
Expand Down Expand Up @@ -139,7 +140,11 @@ protected VersionUid httpPost(URI uri, RMObject body, Map<String, String> header
ContentType.APPLICATION_JSON,
ContentType.APPLICATION_JSON.getMimeType());
Header eTag = response.getFirstHeader(HttpHeaders.ETAG);
return new VersionUid(eTag.getValue().replace("\"", ""));
return buildVersionUidFromETag(eTag);
}

private VersionUid buildVersionUidFromETag(Header eTag) {
return new VersionUid(StringUtils.unwrap(StringUtils.removeStart( eTag.getValue(),"W/"),'"'));
}

protected HttpResponse internalPost(
Expand Down Expand Up @@ -188,7 +193,7 @@ protected VersionUid httpPut(
throw new OptimisticLockException("Entity outdated");
}
Header eTag = response.getFirstHeader(HttpHeaders.ETAG);
return new VersionUid(eTag.getValue().replace("\"", ""));
return buildVersionUidFromETag(eTag);
} catch (IOException e) {
throw new ClientException(e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.nedap.archie.rm.datastructures.History;
import com.nedap.archie.rm.datastructures.ItemList;
import com.nedap.archie.rm.datavalues.quantity.DvQuantity;
import com.nedap.archie.rm.ehr.EhrStatus;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.assertj.core.groups.Tuple;
Expand All @@ -40,6 +41,7 @@
import org.ehrbase.client.aql.query.EntityQuery;
import org.ehrbase.client.aql.query.Query;
import org.ehrbase.client.aql.record.Record2;
import org.ehrbase.client.aql.record.Record3;
import org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition;
import org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition;
import org.ehrbase.client.exception.ClientException;
Expand Down Expand Up @@ -97,15 +99,15 @@ public void testExecute() {
pressureSimple2.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1);
openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple2);

Query<Record2<UUID, Double>> query = Query.buildNativeQuery(
"select e/ehr_id/value,o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude " +
Query<Record3<UUID, Double,EhrStatus>> query = Query.buildNativeQuery(
"select e/ehr_id/value,o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude,e/ehr_status " +
"from EHR e[ehr_id/value = $ehr_id] " +
"contains COMPOSITION a [openEHR-EHR-COMPOSITION.sample_encounter.v1] contains Observation o[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]" +
"where o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude = 1.1"
, UUID.class, Double.class
, UUID.class, Double.class, EhrStatus.class
);

List<Record2<UUID, Double>> result = openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehr));
List<Record3<UUID, Double,EhrStatus>> result = openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehr));
assertThat(result).isNotNull().hasSize(2);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.ehrbase.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto.AutoWhereQuery;
import org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

Expand Down Expand Up @@ -54,6 +55,7 @@ public void testActionAutoWhere() throws IOException {
}

@Test
@Ignore
public void testCompositionAutoWhere() throws IOException {
String rootPath = "c";
RMObject referenceNode = aComposition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.ehrbase.response.openehr.QueryResponseData;
import org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.params.shadow.com.univocity.parsers.csv.CsvParser;
Expand All @@ -47,6 +48,7 @@ public void setUp() throws IOException {
}

@Test
@Ignore
public void testCompositionAttributeQuery() throws IOException {
String rootPath = "c";
RMObject referenceNode = aComposition;
Expand Down

0 comments on commit 11674b6

Please sign in to comment.