Search in sources :

Example 6 with ItemStructure

use of com.nedap.archie.rm.datastructures.ItemStructure in project openEHR_SDK by ehrbase.

the class DBEncodeTest method decodeOtherDetailsWithArchetypeNodeIdAndName.

@Test
public void decodeOtherDetailsWithArchetypeNodeIdAndName() {
    String dbEncoded = "{\"/name\": [{\"value\": \"family group\"}], \"/$CLASS$\": [\"ItemTree\"], \"/items[at0001]\": [{\"/name\": [{\"value\": \"family group id\"}], \"/value\": {\"id\": \"55175056\", \"type\": \"FAMILY_GROUP_ID\", \"issuer\": \"MoH\", \"assigner\": \"MoH\"}, \"/$PATH$\": \"/items[openEHR-EHR-ITEM_TREE.fake.v1 and name/value='family group']/items[at0001]\", \"/$CLASS$\": \"DvIdentifier\"}], \"/archetype_node_id\": [\"openEHR-EHR-ITEM_TREE.fake.v1\"]}";
    ItemStructure converted = new RawJson().unmarshal(dbEncoded, ItemStructure.class);
    assertNotNull(converted);
}
Also used : ItemStructure(com.nedap.archie.rm.datastructures.ItemStructure) Test(org.junit.Test)

Example 7 with ItemStructure

use of com.nedap.archie.rm.datastructures.ItemStructure in project openEHR_SDK by ehrbase.

the class FlattenerTest method testFlattenSingleEventIntervallEvent.

@Test
public void testFlattenSingleEventIntervallEvent() {
    Unflattener unflattener = new Unflattener(new TestDataTemplateProvider());
    KorpergrosseComposition dto = new KorpergrosseComposition();
    dto.setGrosseLange(new GrosseLangeObservation());
    dto.getGrosseLange().setGrosseLangeMagnitude(22d);
    Composition rmObject = (Composition) unflattener.unflatten(dto);
    Observation observation = (Observation) rmObject.getContent().get(0);
    Event<ItemStructure> event = observation.getData().getEvents().get(0);
    observation.getData().getEvents().remove(event);
    IntervalEvent<ItemStructure> intervalEvent = new IntervalEvent<>();
    intervalEvent.setData(event.getData());
    intervalEvent.setArchetypeNodeId(event.getArchetypeNodeId());
    intervalEvent.setSampleCount(10L);
    observation.getData().getEvents().add(intervalEvent);
    assertThat(rmObject).isNotNull();
    Flattener cut = new Flattener(new TestDataTemplateProvider());
    KorpergrosseComposition actual = cut.flatten(rmObject, KorpergrosseComposition.class);
    assertThat(actual.getGrosseLange().getGrosseLangeMagnitude()).isEqualTo(22d);
}
Also used : KorpergrosseComposition(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.KorpergrosseComposition) GrosseLangeObservation(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.definition.GrosseLangeObservation) Composition(com.nedap.archie.rm.composition.Composition) TestData.buildEpisodeOfCareComposition(org.ehrbase.client.TestData.buildEpisodeOfCareComposition) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) CoronaAnamneseComposition(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) EhrbaseMultiOccurrenceDeV1Composition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition) TestData.buildAlternativeEventsComposition(org.ehrbase.client.TestData.buildAlternativeEventsComposition) KorpergrosseComposition(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.KorpergrosseComposition) AlternativeEventsComposition(org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.AlternativeEventsComposition) Observation(com.nedap.archie.rm.composition.Observation) BodyTemperatureObservation(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition.BodyTemperatureObservation) GrosseLangeObservation(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.definition.GrosseLangeObservation) KorpergewichtAnyEventEnIntervalEvent(org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.definition.KorpergewichtAnyEventEnIntervalEvent) IntervalEvent(com.nedap.archie.rm.datastructures.IntervalEvent) ItemStructure(com.nedap.archie.rm.datastructures.ItemStructure) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) Test(org.junit.Test)

Example 8 with ItemStructure

use of com.nedap.archie.rm.datastructures.ItemStructure in project openEHR_SDK by ehrbase.

the class HistoryPostprocessor method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(String term, History rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
    setValue(term + PATH_DIVIDER + "history_origin", null, values, s -> {
        if (s != null) {
            rmObject.setOrigin(new DvDateTime(s));
        }
    }, String.class, consumedPaths);
    if (rmObject.getOrigin() == null || rmObject.getOrigin().getValue() == null) {
        Optional<TemporalAccessor> first = ((History<ItemStructure>) rmObject).getEvents().stream().map(Event::getTime).filter(Objects::nonNull).map(DvDateTime::getValue).filter(Objects::nonNull).sorted().findFirst();
        first.ifPresent(temporalAccessor -> ((History<ItemStructure>) rmObject).setOrigin(new DvDateTime(temporalAccessor)));
    }
}
Also used : TemporalAccessor(java.time.temporal.TemporalAccessor) Objects(java.util.Objects) ItemStructure(com.nedap.archie.rm.datastructures.ItemStructure) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)

Example 9 with ItemStructure

use of com.nedap.archie.rm.datastructures.ItemStructure in project openEHR_SDK by ehrbase.

the class RawJsonTest method testMarshalItemStructure.

@Test
public void testMarshalItemStructure() throws IOException {
    String value = IOUtils.toString(ItemStruktureTestDataCanonicalJson.SIMPLE_EHR_OTHER_Details.getStream(), UTF_8);
    CanonicalJson canonicalJson = new CanonicalJson();
    ItemStructure itemTree = canonicalJson.unmarshal(value, ItemStructure.class);
    RawJson cut = new RawJson();
    String marshal = cut.marshal(itemTree);
    assertThat(marshal).isNotEmpty();
}
Also used : CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) ItemStruktureTestDataCanonicalJson(org.ehrbase.test_data.item_structure.ItemStruktureTestDataCanonicalJson) ItemStructure(com.nedap.archie.rm.datastructures.ItemStructure) Test(org.junit.Test)

Example 10 with ItemStructure

use of com.nedap.archie.rm.datastructures.ItemStructure in project ehrbase by ehrbase.

the class FolderAccessHistoryMockDataProvider method execute.

@Override
public MockResult[] execute(MockExecuteContext ctx) throws SQLException {
    DSLContext create = DSL.using(SQLDialect.POSTGRES);
    MockResult[] mock = new MockResult[1];
    String sql2 = ctx.sql();
    if (sql2.toUpperCase().startsWith("DROP")) {
        throw new SQLException("Statement not supported: " + sql2);
    } else if (sql2.toUpperCase().startsWith("CREATE")) {
        throw new SQLException("Statement not supported: " + sql2);
    } else if (sql2.toUpperCase().contains("DELETE")) {
        throw new SQLException("Statement not supported: " + sql2);
    } else if (sql2.toLowerCase().contains("select \"alias_90044192\".\"folder_id\", \"alias_90044192\".\"item_object_ref_id\", \"alias_90044192\".\"item_in_contribution\"")) {
        if (((UUID) ctx.bindings()[1]).equals(UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"))) {
            if (((UUID) ctx.bindings()[0]).equals(UUID.fromString("129dc79c-e0bc-4946-bfa6-28ce609bbd2c"))) {
                MockResult[] mock2 = new MockResult[1];
                Result<Record11<UUID, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>, String, String, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>>> result2 = create.newResult(FOLDER_ITEMS.FOLDER_ID, FOLDER_ITEMS.OBJECT_REF_ID.as("item_object_ref_id"), FOLDER_ITEMS.IN_CONTRIBUTION.as("item_in_contribution"), FOLDER_ITEMS.SYS_TRANSACTION, FOLDER_ITEMS.SYS_PERIOD, OBJECT_REF.ID_NAMESPACE, OBJECT_REF.TYPE, OBJECT_REF.ID.as("obj_ref_id"), OBJECT_REF.IN_CONTRIBUTION.as("obj_ref_in_cont"), OBJECT_REF.SYS_TRANSACTION.as("objRefSysTran"), OBJECT_REF.SYS_PERIOD.as("oref_sysperiod"));
                mock2[0] = new MockResult(0, result2);
                return mock2;
            } else if (((UUID) ctx.bindings()[0]).equals(UUID.fromString("eda6951b-5506-4726-89dc-7032872997ce"))) {
                MockResult[] mock2 = new MockResult[1];
                Result<Record11<UUID, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>, String, String, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>>> result2 = create.newResult(FOLDER_ITEMS.FOLDER_ID, FOLDER_ITEMS.OBJECT_REF_ID.as("item_object_ref_id"), FOLDER_ITEMS.IN_CONTRIBUTION.as("item_in_contribution"), FOLDER_ITEMS.SYS_TRANSACTION, FOLDER_ITEMS.SYS_PERIOD, OBJECT_REF.ID_NAMESPACE, OBJECT_REF.TYPE, OBJECT_REF.ID.as("obj_ref_id"), OBJECT_REF.IN_CONTRIBUTION.as("obj_ref_in_cont"), OBJECT_REF.SYS_TRANSACTION.as("objRefSysTran"), OBJECT_REF.SYS_PERIOD.as("oref_sysperiod"));
                result2.add(create.newRecord(FOLDER_ITEMS.FOLDER_ID, FOLDER_ITEMS.OBJECT_REF_ID.as("item_object_ref_id"), FOLDER_ITEMS.IN_CONTRIBUTION.as("item_in_contribution"), FOLDER_ITEMS.SYS_TRANSACTION, FOLDER_ITEMS.SYS_PERIOD, OBJECT_REF.ID_NAMESPACE, OBJECT_REF.TYPE, OBJECT_REF.ID.as("obj_ref_id"), OBJECT_REF.IN_CONTRIBUTION.as("obj_ref_in_cont"), OBJECT_REF.SYS_TRANSACTION.as("objRefSysTran"), OBJECT_REF.SYS_PERIOD.as("oref_sysperiod")).values(UUID.fromString("eda6951b-5506-4726-89dc-7032872997ce"), UUID.fromString("88282ddd-4c7d-444a-8159-458a03c9827f"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), Timestamp.valueOf("2019-12-05 19:00:00.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T11:32:47.013378+00"), OffsetDateTime.parse("2020-01-09T11:39:00.898947+00")), "namespace leave", "COMPOSITION", UUID.fromString("88282ddd-4c7d-444a-8159-458a03c9827f"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), Timestamp.valueOf("2019-12-05 19:00:00.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T11:32:47.013378+00"), OffsetDateTime.parse("2020-01-09T11:39:00.898947+00"))));
                mock2[0] = new MockResult(1, result2);
                return mock2;
            } else {
                MockResult[] mock2 = new MockResult[1];
                Result<Record11<UUID, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>, String, String, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>>> result2 = create.newResult(FOLDER_ITEMS.FOLDER_ID, FOLDER_ITEMS.OBJECT_REF_ID.as("item_object_ref_id"), FOLDER_ITEMS.IN_CONTRIBUTION.as("item_in_contribution"), FOLDER_ITEMS.SYS_TRANSACTION, FOLDER_ITEMS.SYS_PERIOD, OBJECT_REF.ID_NAMESPACE, OBJECT_REF.TYPE, OBJECT_REF.ID.as("obj_ref_id"), OBJECT_REF.IN_CONTRIBUTION.as("obj_ref_in_cont"), OBJECT_REF.SYS_TRANSACTION.as("objRefSysTran"), OBJECT_REF.SYS_PERIOD.as("oref_sysperiod"));
                mock2[0] = new MockResult(0, result2);
                return mock2;
            }
        } else {
            MockResult[] mock2 = new MockResult[1];
            Result<Record11<UUID, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>, String, String, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>>> result2 = create.newResult(FOLDER_ITEMS.FOLDER_ID, FOLDER_ITEMS.OBJECT_REF_ID.as("item_object_ref_id"), FOLDER_ITEMS.IN_CONTRIBUTION.as("item_in_contribution"), FOLDER_ITEMS.SYS_TRANSACTION, FOLDER_ITEMS.SYS_PERIOD, OBJECT_REF.ID_NAMESPACE, OBJECT_REF.TYPE, OBJECT_REF.ID.as("obj_ref_id"), OBJECT_REF.IN_CONTRIBUTION.as("obj_ref_in_cont"), OBJECT_REF.SYS_TRANSACTION.as("objRefSysTran"), OBJECT_REF.SYS_PERIOD.as("oref_sysperiod"));
            result2.add(create.newRecord(FOLDER_ITEMS.FOLDER_ID, FOLDER_ITEMS.OBJECT_REF_ID.as("item_object_ref_id"), FOLDER_ITEMS.IN_CONTRIBUTION.as("item_in_contribution"), FOLDER_ITEMS.SYS_TRANSACTION, FOLDER_ITEMS.SYS_PERIOD, OBJECT_REF.ID_NAMESPACE, OBJECT_REF.TYPE, OBJECT_REF.ID.as("obj_ref_id"), OBJECT_REF.IN_CONTRIBUTION.as("obj_ref_in_cont"), OBJECT_REF.SYS_TRANSACTION.as("objRefSysTran"), OBJECT_REF.SYS_PERIOD.as("oref_sysperiod")).values(UUID.fromString("129dc79c-e0bc-4946-bfa6-28ce609bbd2c"), UUID.fromString("44282ddd-4c7d-444a-8159-458a03c9827f"), UUID.fromString("af550555-ec91-4025-838d-09ddb4e473cb"), Timestamp.valueOf("2020-01-15 22:22:22.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T15:43:18.213207+00"), null), "middle leave UPDATED", "COMPOSITION", UUID.fromString("44282ddd-4c7d-444a-8159-458a03c9827f"), UUID.fromString("af550555-ec91-4025-838d-09ddb4e473cb"), Timestamp.valueOf("2020-01-15 22:22:22.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T15:43:11.287968+00"), null)));
            mock2[0] = new MockResult(1, result2);
            return mock2;
        }
    } else if (sql2.toLowerCase().contains("select \"folder_union_fol_hist\".\"id\", \"folder_union_fol_hist\".\"in_contribution\", \"folder_union_fol_hist\".\"name\", \"folder_union_fol_hist\".\"archetype_node_id\"")) {
        if (((UUID) ctx.bindings()[1]).equals(UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"))) {
            MockResult[] mock2 = new MockResult[1];
            Result<Record9<UUID, UUID, String, String, Boolean, ItemStructure, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>, UUID>> result2 = create.newResult(FOLDER.ID, FOLDER.IN_CONTRIBUTION, FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS, FOLDER.SYS_TRANSACTION, FOLDER.SYS_PERIOD, FOLDER.HAS_AUDIT);
            result2.add(create.newRecord(FOLDER.ID, FOLDER.IN_CONTRIBUTION, FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS, FOLDER.SYS_TRANSACTION, FOLDER.SYS_PERIOD, FOLDER.HAS_AUDIT).values(UUID.fromString("eda6951b-5506-4726-89dc-7032872997ce"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), "folder_archetype_nameLeave1", "folder_archetypeLeave.v1", true, null, Timestamp.valueOf("2019-12-05 19:00:00.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T15:43:11.287968+00"), null), UUID.fromString("52318267-b056-47d1-af18-6cd42ca028b6")));
            mock2[0] = new MockResult(1, result2);
            return mock2;
        } else {
            MockResult[] mock2 = new MockResult[1];
            Result<Record9<UUID, UUID, String, String, Boolean, ItemStructure, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>, UUID>> result2 = create.newResult(FOLDER.ID, FOLDER.IN_CONTRIBUTION, FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS, FOLDER.SYS_TRANSACTION, FOLDER.SYS_PERIOD, FOLDER.HAS_AUDIT);
            result2.add(create.newRecord(FOLDER.ID, FOLDER.IN_CONTRIBUTION, FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS, FOLDER.SYS_TRANSACTION, FOLDER.SYS_PERIOD, FOLDER.HAS_AUDIT).values(UUID.fromString("eda6951b-5506-4726-89dc-7032872997ce"), UUID.fromString("af550555-ec91-4025-838d-09ddb4e473cb"), "folder_archetype_nameLeave1", "folder_archetypeLeave.v1", true, null, Timestamp.valueOf("2020-01-15 22:22:22.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T11:28:06.7612+00"), OffsetDateTime.parse("2020-01-09T11:39:00.898947+00")), UUID.fromString("52318267-b056-47d1-af18-6cd42ca028b6")));
            mock2[0] = new MockResult(1, result2);
            return mock2;
        }
    } else if (sql2.toLowerCase().contains("with")) {
        if (((Timestamp) ctx.bindings()[0]).before(Timestamp.valueOf("2020-01-15 22:22:22.688"))) {
            // TABLE RETURNED FOR DELETE FOLDER TEST
            if (sql2.toLowerCase().contains("with recursive \"subfolders\" as ((select \"alias_12246427\".\"parent_folder\", \"alias_12246427\".\"child_folder\"")) {
                // if(((UUID)ctx.bindings()[0]).compareTo(UUID.fromString("7f069129-7312-447b-bd71-567305a9a871"))==0) {
                DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("YYYY-MM-dd HH:mm:ss.SSS");
                DateTime expected = DateTime.parse("2019-06-13 18:10:33.76", dateTimeFormatter);
                TimeZone.getTimeZone("UTC");
                MockResult[] mock2 = new MockResult[1];
                Result<Record15<UUID, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>, UUID, Timestamp, UUID, UUID, String, String, Boolean, ItemStructure, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>>> result2 = create.newResult(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER, FOLDER_HIERARCHY.IN_CONTRIBUTION, FOLDER_HIERARCHY.SYS_TRANSACTION, FOLDER_HIERARCHY.SYS_PERIOD, FOLDER_HIERARCHY.PARENT_FOLDER.as("parent_folder_id"), FOLDER_HIERARCHY.SYS_TRANSACTION.as("latest_sys_transaction"), FOLDER_HIERARCHY.PARENT_FOLDER.as("id"), FOLDER_HIERARCHY.IN_CONTRIBUTION.as("in_contribution_folder_info"), FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS.as("details"), FOLDER.SYS_TRANSACTION.as("sys_transaction_folder"), FOLDER.SYS_PERIOD.as("sys_period_folder"));
                result2.add(create.newRecord(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER, FOLDER_HIERARCHY.IN_CONTRIBUTION, FOLDER_HIERARCHY.SYS_TRANSACTION, FOLDER_HIERARCHY.SYS_PERIOD, FOLDER_HIERARCHY.PARENT_FOLDER.as("parent_folder_id"), FOLDER_HIERARCHY.SYS_TRANSACTION.as("latest_sys_transaction"), FOLDER_HIERARCHY.PARENT_FOLDER.as("id"), FOLDER_HIERARCHY.IN_CONTRIBUTION.as("in_contribution_folder_info"), FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS.as("details"), FOLDER.SYS_TRANSACTION.as("sys_transaction_folder"), FOLDER.SYS_PERIOD.as("sys_period_folder")).values(UUID.fromString("7f069129-7312-447b-bd71-567305a9a871"), UUID.fromString("129dc79c-e0bc-4946-bfa6-28ce609bbd2c"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), Timestamp.valueOf("2019-12-05 19:00:00.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T11:28:32.089794+00"), null), UUID.fromString("7f069129-7312-447b-bd71-567305a9a871"), Timestamp.valueOf("2019-12-05 19:00:00.688"), UUID.fromString("7f069129-7312-447b-bd71-567305a9a871"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), "folder_archetype_root init", "folder_archetypeRoot.v1", true, null, Timestamp.valueOf("2019-12-05 19:00:00.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T11:27:53.370395+00"), null)));
                result2.add(create.newRecord(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER, FOLDER_HIERARCHY.IN_CONTRIBUTION, FOLDER_HIERARCHY.SYS_TRANSACTION, FOLDER_HIERARCHY.SYS_PERIOD, FOLDER_HIERARCHY.PARENT_FOLDER.as("parent_folder_id"), FOLDER_HIERARCHY.SYS_TRANSACTION.as("latest_sys_transaction"), FOLDER_HIERARCHY.PARENT_FOLDER.as("id"), FOLDER_HIERARCHY.IN_CONTRIBUTION.as("in_contribution_folder_info"), FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS.as("details"), FOLDER.SYS_TRANSACTION.as("sys_transaction_folder"), FOLDER.SYS_PERIOD.as("sys_period_folder")).values(UUID.fromString("129dc79c-e0bc-4946-bfa6-28ce609bbd2c"), UUID.fromString("eda6951b-5506-4726-89dc-7032872997ce"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), Timestamp.valueOf("2019-12-05 19:00:00.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T11:44:43.712587+00"), null), UUID.fromString("129dc79c-e0bc-4946-bfa6-28ce609bbd2c"), Timestamp.valueOf("2019-12-05 19:00:00.688"), UUID.fromString("129dc79c-e0bc-4946-bfa6-28ce609bbd2c"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), "folder_archetype_middle1", "folder_archetypemiddle.v1", true, null, Timestamp.valueOf("2019-12-05 19:00:00.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T11:27:53.370395+00"), null)));
                mock2[0] = new MockResult(5, result2);
                return mock2;
            // }
            }
            throw new SQLException("SQL statement not expected. Consider enhancing or revising the FolderMockDataProvider in order to ensure the controlled behaviour of your code: " + sql2);
        } else {
            // TABLE RETURNED FOR DELETE FOLDER TEST
            if (sql2.toLowerCase().contains("with recursive \"subfolders\" as ((select \"alias_12246427\".\"parent_folder\", \"alias_12246427\".\"child_folder\"")) {
                DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("YYYY-MM-dd HH:mm:ss.SSS");
                DateTime expected = DateTime.parse("2019-06-13 18:10:33.76", dateTimeFormatter);
                TimeZone.getTimeZone("UTC");
                MockResult[] mock2 = new MockResult[1];
                Result<Record16<UUID, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>, UUID, Timestamp, UUID, UUID, String, String, Boolean, ItemStructure, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>, UUID>> result2 = create.newResult(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER, FOLDER_HIERARCHY.IN_CONTRIBUTION, FOLDER_HIERARCHY.SYS_TRANSACTION, FOLDER_HIERARCHY.SYS_PERIOD, FOLDER_HIERARCHY.PARENT_FOLDER.as("parent_folder_id"), FOLDER_HIERARCHY.SYS_TRANSACTION.as("latest_sys_transaction"), FOLDER_HIERARCHY.PARENT_FOLDER.as("id"), FOLDER_HIERARCHY.IN_CONTRIBUTION.as("in_contribution_folder_info"), FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS.as("details"), FOLDER.SYS_TRANSACTION.as("sys_transaction_folder"), FOLDER.SYS_PERIOD.as("sys_period_folder"), FOLDER.HAS_AUDIT);
                result2.add(create.newRecord(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER, FOLDER_HIERARCHY.IN_CONTRIBUTION, FOLDER_HIERARCHY.SYS_TRANSACTION, FOLDER_HIERARCHY.SYS_PERIOD, FOLDER_HIERARCHY.PARENT_FOLDER.as("parent_folder_id"), FOLDER_HIERARCHY.SYS_TRANSACTION.as("latest_sys_transaction"), FOLDER_HIERARCHY.PARENT_FOLDER.as("id"), FOLDER_HIERARCHY.IN_CONTRIBUTION.as("in_contribution_folder_info"), FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS.as("details"), FOLDER.SYS_TRANSACTION.as("sys_transaction_folder"), FOLDER.SYS_PERIOD.as("sys_period_folder"), FOLDER.HAS_AUDIT).values(UUID.fromString("7f069129-7312-447b-bd71-567305a9a871"), UUID.fromString("129dc79c-e0bc-4946-bfa6-28ce609bbd2c"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), Timestamp.valueOf("2019-12-05 19:00:00.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T11:28:32.089794+00"), null), UUID.fromString("7f069129-7312-447b-bd71-567305a9a871"), Timestamp.valueOf("2019-12-05 19:00:00.688"), UUID.fromString("7f069129-7312-447b-bd71-567305a9a871"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), "folder_archetype_root init", "folder_archetypeRoot.v1", true, null, Timestamp.valueOf("2019-12-05 19:00:00.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T11:27:53.370395+00"), null), UUID.fromString("52318267-b056-47d1-af18-6cd42ca028b6")));
                result2.add(create.newRecord(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER, FOLDER_HIERARCHY.IN_CONTRIBUTION, FOLDER_HIERARCHY.SYS_TRANSACTION, FOLDER_HIERARCHY.SYS_PERIOD, FOLDER_HIERARCHY.PARENT_FOLDER.as("parent_folder_id"), FOLDER_HIERARCHY.SYS_TRANSACTION.as("latest_sys_transaction"), FOLDER_HIERARCHY.PARENT_FOLDER.as("id"), FOLDER_HIERARCHY.IN_CONTRIBUTION.as("in_contribution_folder_info"), FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS.as("details"), FOLDER.SYS_TRANSACTION.as("sys_transaction_folder"), FOLDER.SYS_PERIOD.as("sys_period_folder"), FOLDER.HAS_AUDIT).values(UUID.fromString("129dc79c-e0bc-4946-bfa6-28ce609bbd2c"), UUID.fromString("eda6951b-5506-4726-89dc-7032872997ce"), UUID.fromString("af550555-ec91-4025-838d-09ddb4e473cb"), Timestamp.valueOf("2020-01-15 22:22:22.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T11:44:43.712587+00"), null), UUID.fromString("129dc79c-e0bc-4946-bfa6-28ce609bbd2c"), Timestamp.valueOf("2020-01-15 22:22:22.688"), UUID.fromString("129dc79c-e0bc-4946-bfa6-28ce609bbd2c"), UUID.fromString("af550555-ec91-4025-838d-09ddb4e473cb"), "folder_archetype_middle1", "folder_archetypemiddle.v1", true, null, Timestamp.valueOf("2020-01-15 22:22:22.688"), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2020-01-09T11:27:53.370395+00"), null), UUID.fromString("52318267-b056-47d1-af18-6cd42ca028b6")));
                mock2[0] = new MockResult(5, result2);
                return mock2;
            }
            throw new SQLException("SQL statement not expected. Consider enhancing or revising the FolderMockDataProvider in order to ensure the controlled behaviour of your code: " + sql2);
        }
    }
    throw new SQLException("Statement not currently supported. Consider enhancing or revising the FolderMockDataProvider: " + sql2);
}
Also used : MockResult(org.jooq.tools.jdbc.MockResult) SQLException(java.sql.SQLException) ItemStructure(com.nedap.archie.rm.datastructures.ItemStructure) Timestamp(java.sql.Timestamp) DateTime(org.joda.time.DateTime) OffsetDateTime(java.time.OffsetDateTime) MockResult(org.jooq.tools.jdbc.MockResult) OffsetDateTime(java.time.OffsetDateTime) DateTimeFormatter(org.joda.time.format.DateTimeFormatter)

Aggregations

ItemStructure (com.nedap.archie.rm.datastructures.ItemStructure)11 Test (org.junit.Test)7 Item (com.nedap.archie.rm.datastructures.Item)4 DvText (com.nedap.archie.rm.datavalues.DvText)4 ArrayList (java.util.ArrayList)4 Timestamp (java.sql.Timestamp)3 I_FolderAccess (org.ehrbase.dao.access.interfaces.I_FolderAccess)3 Ignore (org.junit.Ignore)3 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)2 Folder (com.nedap.archie.rm.directory.Folder)2 ObjectVersionId (com.nedap.archie.rm.support.identification.ObjectVersionId)2 UIDBasedId (com.nedap.archie.rm.support.identification.UIDBasedId)2 PrintWriter (java.io.PrintWriter)2 StringWriter (java.io.StringWriter)2 SQLException (java.sql.SQLException)2 OffsetDateTime (java.time.OffsetDateTime)2 UUID (java.util.UUID)2 DateTime (org.joda.time.DateTime)2 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)2 MockResult (org.jooq.tools.jdbc.MockResult)2