use of com.nedap.archie.rm.datastructures.ItemStructure in project ehrbase by ehrbase.
the class FolderAccessTest method shouldUpdateExistingFolder.
@Test
@Ignore
public void shouldUpdateExistingFolder() throws Exception {
// 1-retrieve a DAO for an existing folder in the DB
FolderAccess fa1 = new FolderAccess(testDomainAccess);
FolderAccess fa2 = (FolderAccess) FolderAccess.retrieveInstanceForExistingFolder(fa1, UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb"));
assertEquals("folder_archetype.v1", fa2.getFolderRecord().getArchetypeNodeId());
assertEquals("folder_archetype_name_1", fa2.getFolderRecord().getName());
// 2-perform update and persist changes with the previously retrieved DAO
fa2.setFolderName("modifiedName");
fa2.setFolderNArchetypeNodeId("modifiedArchetypeNodeId");
fa2.setIsFolderActive(false);
ItemStructure is = new ItemStructure() {
@Override
public List getItems() {
Item item = new Item() {
@Override
public DvText getName() {
return new DvText("modifiedValue");
}
};
List<Item> items = new ArrayList<>();
items.add(item);
return items;
}
};
// fa2.setFolderDetails(DSL.field(DSL.val("{\"s\": \"modifiedValue\"}") + "::jsonb"));
fa2.setFolderDetails(is);
fa2.setFolderSysTransaction(new Timestamp(DateTime.now().getMillis()));
fa2.setFolderSysPeriod(new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2019-07-26 11:28:11.631959+02"), null));
// perform updates in a second level subfolder
I_FolderAccess fa3 = fa2.getSubfoldersList().get(UUID.fromString("99550555-ec91-4025-838d-09ddb4e999cb"));
fa3.setFolderName("new name of folder 2");
// perform update second level subfolder
I_FolderAccess fa4 = fa3.getSubfoldersList().get(UUID.fromString("33550555-ec91-4025-838d-09ddb4e999cb"));
fa4.setFolderNArchetypeNodeId("new archetype node id");
// perform update in a third level subforlder
I_FolderAccess fa5 = fa4.getSubfoldersList().get(UUID.fromString("8701233c-c8fd-47ba-91b5-ef9ff23c259b"));
fa5.setIsFolderActive(false);
// the mock data provider checks the UPDATE SQL code generated and returns 1 simulating the update of one row in the FOLDER table.
// this way the correct sql generation is checked indirectly.
boolean updated = false;
updated = fa2.update(LocalDateTime.now(), UUID.randomUUID());
// assertEquals(true, updated);// could not manage to mock the result "Affected row(s) : 1" from updates" for the UPDATEE statement. The mock data provider returns 0 irrespectively of weather the record is modified in the DB or not. As a consequence this always is false in the mocked version.
}
use of com.nedap.archie.rm.datastructures.ItemStructure in project ehrbase by ehrbase.
the class FolderAccessTest method shouldInsertFolderWithSubfolders.
@Test
@Ignore
public void shouldInsertFolderWithSubfolders() throws Exception {
// the creation and commit returning valid ids implies that the FolderMockDataProvider.java has provided the corresponding result for each SQL generated when inserting
// create folder to insert
Folder folder = new Folder();
UIDBasedId uid = new ObjectVersionId("f8a2af65-fe89-45a4-9456-07c5e17b1634");
ObjectVersionId uidim = new ObjectVersionId("f8a2af65-fe89-45a4-9456-07c5e17b1634");
folder.setUid(uid);
DvText name = new DvText();
name.setValue("nameOfFolder1");
folder.setName(name);
folder.setArchetypeNodeId("archetype_1");
ItemStructure is = new ItemStructure() {
@Override
public List getItems() {
Item item = new Item() {
@Override
public DvText getName() {
return new DvText("fol1");
}
};
List<Item> items = new ArrayList<>();
items.add(item);
return items;
}
};
folder.setDetails(is);
// create subfolder
Folder folder2 = new Folder();
UIDBasedId uid2 = new ObjectVersionId("f0a2af65-fe89-45a4-9456-07c5e17b1634");
ObjectVersionId uidim2 = new ObjectVersionId("f0a2af65-fe89-45a4-9456-07c5e17b1634");
folder2.setUid(uid2);
DvText name2 = new DvText();
name2.setValue("nameOfFolder2");
folder2.setName(name2);
folder2.setArchetypeNodeId("archetype_2");
ItemStructure is2 = new ItemStructure() {
@Override
public List getItems() {
Item item = new Item() {
@Override
public DvText getName() {
return new DvText("fol2");
}
};
List<Item> items = new ArrayList<>();
items.add(item);
return items;
}
};
folder2.setDetails(is2);
// create subfolder (grandson)
Folder folder3 = new Folder();
UIDBasedId uid3 = new ObjectVersionId("f4a2af65-fe89-45a4-9456-07c5e17b1634");
ObjectVersionId uidim3 = new ObjectVersionId("f4a2af65-fe89-45a4-9456-07c5e17b1634");
folder3.setUid(uid3);
DvText name3 = new DvText();
name3.setValue("nameOfFolder3");
folder3.setName(name3);
folder3.setArchetypeNodeId("archetype_3");
ItemStructure is3 = new ItemStructure() {
@Override
public List getItems() {
Item item = new Item() {
@Override
public DvText getName() {
return super.getName();
}
};
List<Item> items = new ArrayList<>();
items.add(item);
return items;
}
};
folder3.setDetails(is3);
// add subfolders
folder.getFolders().add(folder2);
folder2.addFolder(folder3);
// insert folder
FolderAccess fa1 = new FolderAccess(testDomainAccess);
FolderAccess fa2 = (FolderAccess) FolderAccess.getNewFolderAccessInstance(fa1, folder, DateTime.now(), UUID.fromString("f6a2af65-fe89-45a4-9456-07c5e17b1634"));
assertEquals("f8a2af65-fe89-45a4-9456-07c5e17b1634", fa2.getFolderRecord().getId().toString());
assertEquals("archetype_1", fa2.getFolderRecord().getArchetypeNodeId());
assertEquals("nameOfFolder1", fa2.getFolderRecord().getName());
String expected = ("'{\n" + " \"_type\" : \"\",\n" + " \"items\" : [ {\n" + " \"name\" : {\n" + " \"_type\" : \"DV_TEXT\",\n" + " \"value\" : \"fol1\"\n" + " }\n" + " } ]\n" + "}'::jsonb").replaceAll("\\n|\\r\\n", // avoids problems amond different platforms due to different representations of line change.
System.getProperty("line.separator"));
// avoids problems amond different platforms due to different representations of line change.
;
StringWriter expectedStringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(expectedStringWriter);
// avoids problems amond different platforms due to different representations of line change.
printWriter.print(expected);
printWriter.close();
assertEquals(expectedStringWriter.toString(), fa2.getFolderRecord().getDetails().toString());
assertEquals("f0a2af65-fe89-45a4-9456-07c5e17b1634", ((FolderAccess) fa2.getSubfoldersList().get(UUID.fromString("f0a2af65-fe89-45a4-9456-07c5e17b1634"))).getFolderRecord().getId().toString());
assertEquals("archetype_2", ((FolderAccess) fa2.getSubfoldersList().get(UUID.fromString("f0a2af65-fe89-45a4-9456-07c5e17b1634"))).getFolderRecord().getArchetypeNodeId());
assertEquals("nameOfFolder2", ((FolderAccess) fa2.getSubfoldersList().get(UUID.fromString("f0a2af65-fe89-45a4-9456-07c5e17b1634"))).getFolderRecord().getName());
String expected2 = ("'{\n" + " \"_type\" : \"\",\n" + " \"items\" : [ {\n" + " \"name\" : {\n" + " \"_type\" : \"DV_TEXT\",\n" + " \"value\" : \"fol2\"\n" + " }\n" + " } ]\n" + "}'::jsonb").replaceAll("\\n|\\r\\n", // avoids problems amond different platforms due to different representations of line change.
System.getProperty("line.separator"));
expectedStringWriter = new StringWriter();
// avoids problems amond different platforms due to different representations of line change.
printWriter = new PrintWriter(expectedStringWriter);
printWriter.print(expected2);
printWriter.close();
assertEquals(expectedStringWriter.toString(), ((FolderAccess) fa2.getSubfoldersList().get(UUID.fromString("f0a2af65-fe89-45a4-9456-07c5e17b1634"))).getFolderRecord().getDetails().toString());
assertEquals("f4a2af65-fe89-45a4-9456-07c5e17b1634", ((FolderAccess) ((FolderAccess) fa2.getSubfoldersList().get(UUID.fromString("f0a2af65-fe89-45a4-9456-07c5e17b1634"))).getSubfoldersList().get(UUID.fromString("f4a2af65-fe89-45a4-9456-07c5e17b1634"))).getFolderRecord().getId().toString());
assertEquals("archetype_3", ((FolderAccess) ((FolderAccess) fa2.getSubfoldersList().get(UUID.fromString("f0a2af65-fe89-45a4-9456-07c5e17b1634"))).getSubfoldersList().get(UUID.fromString("f4a2af65-fe89-45a4-9456-07c5e17b1634"))).getFolderRecord().getArchetypeNodeId());
assertEquals("nameOfFolder3", ((FolderAccess) ((FolderAccess) fa2.getSubfoldersList().get(UUID.fromString("f0a2af65-fe89-45a4-9456-07c5e17b1634"))).getSubfoldersList().get(UUID.fromString("f4a2af65-fe89-45a4-9456-07c5e17b1634"))).getFolderRecord().getName());
String expected3 = ("'{\n" + " \"_type\" : \"\",\n" + " \"items\" : [ { } ]\n" + "}'::jsonb").replaceAll("\\n|\\r\\n", // avoids problems amond different platforms due to different representations of line change.
System.getProperty("line.separator"));
expectedStringWriter = new StringWriter();
printWriter = new PrintWriter(expectedStringWriter);
// avoids problems amond different platforms due to different representations of line change.
printWriter.print(expected3);
assertEquals(expectedStringWriter.toString(), ((FolderAccess) ((FolderAccess) fa2.getSubfoldersList().get(UUID.fromString("f0a2af65-fe89-45a4-9456-07c5e17b1634"))).getSubfoldersList().get(UUID.fromString("f4a2af65-fe89-45a4-9456-07c5e17b1634"))).getFolderRecord().getDetails().toString());
expectedStringWriter.flush();
printWriter.flush();
printWriter.close();
UUID storedFolderUid = fa2.commit(LocalDateTime.now(), UUID.randomUUID());
// commit should return the top level folderId
assertEquals("f8a2af65-fe89-45a4-9456-07c5e17b1634", storedFolderUid.toString());
}
use of com.nedap.archie.rm.datastructures.ItemStructure in project ehrbase by ehrbase.
the class FolderMockDataProvider 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 FROM \"EHR\".\"FOLDER_ITEMS\" WHERE (\"EHR\".\"FOLDER_ITEMS\".\"FOLDER_ID\" = ? AND \"EHR\".\"FOLDER_ITEMS\".\"IN_CONTRIBUTION\" = ?)")) {
mock[0] = new MockResult(1, create.newResult(FOLDER_ITEMS));
return mock;
} else if (sql2.toUpperCase().contains("INSERT INTO \"EHR\".\"FOLDER_ITEMS\" (\"FOLDER_ID\", \"OBJECT_REF_ID\", \"IN_CONTRIBUTION\", \"SYS_TRANSACTION\", \"SYS_PERIOD\")")) {
mock[0] = new MockResult(1, create.newResult(FOLDER_ITEMS));
return mock;
} else if (sql2.toUpperCase().contains("INSERT INTO \"EHR\".\"OBJECT_REF\" (\"ID_NAMESPACE\", \"TYPE\", \"ID\", \"IN_CONTRIBUTION\", \"SYS_TRANSACTION\", \"SYS_PERIOD")) {
mock[0] = new MockResult(1, create.newResult(OBJECT_REF));
return mock;
} else if (sql2.toLowerCase().contains("select \"ehr\".\"folder\".\"id\", \"ehr\".\"folder\".\"in_contribution\", \"ehr\".\"folder\".\"name\", \"ehr\".\"folder\".\"archetype_node_id\", \"ehr\".\"folder\".\"active\", \"ehr\".\"folder\".\"details\", \"ehr\".\"folder\".\"sys_transaction\", \"ehr\".\"folder\".\"sys_period\" from \"ehr\".\"folder\" where \"ehr\".\"folder\".\"id\" = ?")) {
if (((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("77750555-ec91-4025-838d-09ddb4e999cb")) == 0) {
DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("YYYY-MM-dd HH:mm:ss.SSS");
DateTime expected = DateTime.parse("2019-06-13 18:10:33.76", dateTimeFormatter);
MockResult[] mock2 = new MockResult[1];
Result<Record8<UUID, UUID, String, String, Boolean, ItemStructure, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>>> result2 = create.newResult(FOLDER.ID, FOLDER.IN_CONTRIBUTION, FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS, FOLDER.SYS_TRANSACTION, FOLDER.SYS_PERIOD);
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).values(UUID.fromString("77750555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb"), "folder_archetype_name_4", "folder_archetype.v1", true, // "{\"details\": \"xxx4\"}",
new ItemStructure() {
@Override
public List getItems() {
Item item = new Item() {
@Override
public DvText getName() {
return new DvText("xxx4");
}
};
List<Item> items = new ArrayList<>();
items.add(item);
return items;
}
}, new Timestamp(expected.getMillis()), new AbstractMap.SimpleEntry<>(OffsetDateTime.now(), null)));
// no rows returned
mock2[0] = new MockResult(1, result2);
return mock2;
} else if (((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("8701233c-c8fd-47ba-91b5-ef9ff23c259b")) == 0) {
DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("YYYY-MM-dd HH:mm:ss.SSS");
DateTime expected = DateTime.parse("2019-06-13 18:10:33.76", dateTimeFormatter);
MockResult[] mock2 = new MockResult[1];
Result<Record8<UUID, UUID, String, String, Boolean, ItemStructure, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>>> result2 = create.newResult(FOLDER.ID, FOLDER.IN_CONTRIBUTION, FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS, FOLDER.SYS_TRANSACTION, FOLDER.SYS_PERIOD);
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).values(UUID.fromString("8701233c-c8fd-47ba-91b5-ef9ff23c259b"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb"), "folder_archetype_name_5", "folder_archetype.v1", true, // "{\"details\": \"xxx5\"}",
new ItemStructure() {
@Override
public List getItems() {
Item item = new Item() {
@Override
public DvText getName() {
return new DvText("xxx5");
}
};
List<Item> items = new ArrayList<>();
items.add(item);
return items;
}
}, new Timestamp(expected.getMillis()), /*new Timestamp(expected.getMillis())*/
null));
// no rows returned
mock2[0] = new MockResult(1, 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 if (sql2.toUpperCase().startsWith("SELECT \"EHR\".\"CONTRIBUTION\".\"EHR_ID\" FROM \"EHR\".\"CONTRIBUTION\" WHERE \"EHR\".\"CONTRIBUTION\".\"ID\" =")) {
Result<Record1<UUID>> result2 = create.newResult(EHR_.ID);
result2.add(create.newRecord(EHR_.ID).values(UUID.fromString("f6a2af65-fe89-45a4-9456-07c5e17b1634")));
mock[0] = new MockResult(1, result2);
return mock;
} else if (sql2.toLowerCase().contains("with")) {
// TABLE RETURNED FOR DELETE FOLDER TEST
if (sql2.toUpperCase().contains("WITH RECURSIVE \"SUBFOLDERS\" AS ((SELECT \"ALIAS_70689680\".\"PARENT_FOLDER\", \"ALIAS_70689680\".\"CHILD_FOLDER\", \"ALIAS_70689680\".\"IN_CONTRIBUTION\", \"ALIAS_70689680\".\"SYS_TRANSACTION\", \"ALIAS_70689680\".\"SYS_PERIOD\" FROM (SELECT \"EHR\".\"FOLDER_HIERARCHY\".\"PARENT_FOLDER\", \"EHR\".\"FOLDER_HIERARCHY\".\"CHILD_FOLDER\", \"EHR\".\"FOLDER_HIERARCHY\".\"IN_CONTRIBUTION\", \"EHR\".\"FOLDER_HIERARCHY\".\"SYS_TRANSACTION\", \"EHR\".\"FOLDER_HIERARCHY\".\"SYS_PERIOD\" FROM \"EHR\".\"FOLDER_HIERARCHY\" WHERE \"EHR\".\"FOLDER_HIERARCHY\".\"PARENT_FOLDER\" = ?) AS \"ALIAS_70689680\") UNION (SELECT \"ALIAS_133512525\".\"PARENT_FOLDER\", \"ALIAS_133512525\".\"CHILD_FOLDER\", \"ALIAS_133512525\".\"IN_CONTRIBUTION\", \"ALIAS_133512525\".\"SYS_TRANSACTION\", \"ALIAS_133512525\".\"SYS_PERIOD\" FROM (SELECT \"EHR\".\"FOLDER_HIERARCHY\".\"PARENT_FOLDER\", \"EHR\".\"FOLDER_HIERARCHY\".\"CHILD_FOLDER\", \"EHR\".\"FOLDER_HIERARCHY\".\"IN_CONTRIBUTION\", \"EHR\".\"FOLDER_HIERARCHY\".\"SYS_TRANSACTION\", \"EHR\".\"FOLDER_HIERARCHY\".\"SYS_PERIOD\" FROM \"EHR\".\"FOLDER_HIERARCHY\") AS \"ALIAS_133512525\" JOIN SUBFOLDERS ON \"ALIAS_133512525\".\"PARENT_FOLDER\" = SUBFOLDERS.\"CHILD_FOLDER\")) SELECT * FROM \"SUBFOLDERS\"")) {
if (((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb")) == 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<Record4<UUID, UUID, UUID, Timestamp>> result2 = create.newResult(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER, FOLDER_HIERARCHY.IN_CONTRIBUTION, FOLDER_HIERARCHY.SYS_TRANSACTION);
result2.add(create.newRecord(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER, FOLDER_HIERARCHY.IN_CONTRIBUTION, FOLDER_HIERARCHY.SYS_TRANSACTION).values(UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("99550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), new Timestamp(expected.getMillis())));
result2.add(create.newRecord(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER, FOLDER_HIERARCHY.IN_CONTRIBUTION, FOLDER_HIERARCHY.SYS_TRANSACTION).values(UUID.fromString("99550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("33550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), new Timestamp(expected.getMillis())));
result2.add(create.newRecord(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER, FOLDER_HIERARCHY.IN_CONTRIBUTION, FOLDER_HIERARCHY.SYS_TRANSACTION).values(UUID.fromString("33550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("77750555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), new Timestamp(expected.getMillis())));
result2.add(create.newRecord(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER, FOLDER_HIERARCHY.IN_CONTRIBUTION, FOLDER_HIERARCHY.SYS_TRANSACTION).values(UUID.fromString("33550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("8701233c-c8fd-47ba-91b5-ef9ff23c259b"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), new Timestamp(expected.getMillis())));
mock2[0] = new MockResult(5, result2);
return mock2;
}
} else if (sql2.toUpperCase().contains("WITH RECURSIVE \"SUBFOLDERS\" AS ((SELECT \"ALIAS_70689680\".\"PARENT_FOLDER\", \"ALIAS_70689680\".\"CHILD_FOLDER\", \"ALIAS_70689680\".\"IN_CONTRIBUTION\", \"ALIAS_70689680\".\"SYS_TRANSACTION\", \"ALIAS_70689680\".\"SYS_PERIOD\" FROM (SELECT \"EHR\".\"FOLDER_HIERARCHY\".\"PARENT_FOLDER\", \"EHR\".\"FOLDER_HIERARCHY\".\"CHILD_FOLDER\", \"EHR\".\"FOLDER_HIERARCHY\".\"IN_CONTRIBUTION\", \"EHR\".\"FOLDER_HIERARCHY\".\"SYS_TRANSACTION\", \"EHR\".\"FOLDER_HIERARCHY\".\"SYS_PERIOD\" FROM \"EHR\".\"FOLDER_HIERARCHY\" WHERE \"EHR\".\"FOLDER_HIERARCHY\".\"PARENT_FOLDER\" = CAST(? AS UUID)) AS \"ALIAS_70689680\") UNION (SELECT \"ALIAS_133512525\".\"PARENT_FOLDER\", \"ALIAS_133512525\".\"CHILD_FOLDER\", \"ALIAS_133512525\".\"IN_CONTRIBUTION\", \"ALIAS_133512525\".\"SYS_TRANSACTION\", \"ALIAS_133512525\".\"SYS_PERIOD\" FROM (SELECT \"EHR\".\"FOLDER_HIERARCHY\".\"PARENT_FOLDER\", \"EHR\".\"FOLDER_HIERARCHY\".\"CHILD_FOLDER\", \"EHR\".\"FOLDER_HIERARCHY\".\"IN_CONTRIBUTION\", \"EHR\".\"FOLDER_HIERARCHY\".\"SYS_TRANSACTION\", \"EHR\".\"FOLDER_HIERARCHY\".\"SYS_PERIOD\" FROM \"EHR\".\"FOLDER_HIERARCHY\") AS \"ALIAS_133512525\" JOIN SUBFOLDERS ON \"ALIAS_133512525\".\"PARENT_FOLDER\" = SUBFOLDERS.\"CHILD_FOLDER\")) SELECT * FROM \"SUBFOLDERS\"")) {
if (((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb")) == 0) {
// TABLE FOR THE RETRIEVE FOLDER ACCESS FOR EXISTING 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<Record13<UUID, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>, 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.ID, FOLDER.IN_CONTRIBUTION, FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS, FOLDER.SYS_TRANSACTION, FOLDER.SYS_PERIOD);
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.ID, FOLDER.IN_CONTRIBUTION, FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS, FOLDER.SYS_TRANSACTION, FOLDER.SYS_PERIOD).values(UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("99550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), new Timestamp(expected.getMillis()), // was "xxx1",
new AbstractMap.SimpleEntry<>(OffsetDateTime.now(), null), UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb"), "folder_archetype_name_1", "folder_archetype.v1", true, // "{\"details\": \"xxx1\"}",
new ItemStructure() {
@Override
public List getItems() {
Item item = new Item() {
@Override
public DvText getName() {
return new DvText("xxx1");
}
};
List<Item> items = new ArrayList<>();
items.add(item);
return items;
}
}, new Timestamp(expected.getMillis()), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2019-08-09T09:56:52.464799+02"), 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.ID, FOLDER.IN_CONTRIBUTION, FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS, FOLDER.SYS_TRANSACTION, FOLDER.SYS_PERIOD).values(UUID.fromString("99550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("33550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), new Timestamp(expected.getMillis()), // was "xxx2",
new AbstractMap.SimpleEntry<>(OffsetDateTime.now(), null), UUID.fromString("99550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb"), "folder_archetype_name_2", "folder_archetype.v1", true, // "{\"details\": \"xxx2\"}",
new ItemStructure() {
@Override
public List getItems() {
Item item = new Item() {
@Override
public DvText getName() {
return new DvText("xxx2");
}
};
List<Item> items = new ArrayList<>();
items.add(item);
return items;
}
}, new Timestamp(expected.getMillis()), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2019-08-09T09:56:52.464799+02"), 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.ID, FOLDER.IN_CONTRIBUTION, FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS, FOLDER.SYS_TRANSACTION, FOLDER.SYS_PERIOD).values(UUID.fromString("33550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("77750555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), new Timestamp(expected.getMillis()), // was "xxx3",
new AbstractMap.SimpleEntry<>(OffsetDateTime.now(), null), UUID.fromString("33550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb"), "folder_archetype_name_3", "folder_archetype.v1", true, // "{\"details\": \"xxx3\"}",
new ItemStructure() {
@Override
public List getItems() {
Item item = new Item() {
@Override
public DvText getName() {
return new DvText("xxx3");
}
};
List<Item> items = new ArrayList<>();
items.add(item);
return items;
}
}, new Timestamp(expected.getMillis()), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2019-08-09T09:56:52.464799+02"), 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.ID, FOLDER.IN_CONTRIBUTION, FOLDER.NAME, FOLDER.ARCHETYPE_NODE_ID, FOLDER.ACTIVE, FOLDER.DETAILS, FOLDER.SYS_TRANSACTION, FOLDER.SYS_PERIOD).values(UUID.fromString("33550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("8701233c-c8fd-47ba-91b5-ef9ff23c259b"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), new Timestamp(expected.getMillis()), // was "xxx3",
new AbstractMap.SimpleEntry<>(OffsetDateTime.now(), null), UUID.fromString("33550555-ec91-4025-838d-09ddb4e999cb"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb"), "folder_archetype_name_3", "folder_archetype.v1", true, // "{\"details\": \"xxx3\"}",
new ItemStructure() {
@Override
public List getItems() {
Item item = new Item() {
@Override
public DvText getName() {
return new DvText("xxx3");
}
};
List<Item> items = new ArrayList<>();
items.add(item);
return items;
}
}, new Timestamp(expected.getMillis()), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2019-08-09T09:56:52.464799+02"), null)));
// no rows returned
mock2[0] = new MockResult(1, result2);
return mock2;
}
} else if (sql2.toUpperCase().contains("WITH \"FOLDERITEMSSELECT\" AS (SELECT \"EHR\".\"FOLDER_ITEMS\".\"OBJECT_REF_ID\" AS \"OBJECT_REF_ID\", \"EHR\".\"FOLDER_ITEMS\".\"IN_CONTRIBUTION\" AS \"ITEM_IN_CONTRIBUTION\" FROM \"EHR\".\"FOLDER_ITEMS\" WHERE \"EHR\".\"FOLDER_ITEMS\".\"FOLDER_ID\" = ?) SELECT * FROM \"EHR\".\"OBJECT_REF\", \"FOLDERITEMSSELECT\" WHERE (\"OBJECT_REF_ID\" = \"EHR\".\"OBJECT_REF\".\"ID\" AND \"ITEM_IN_CONTRIBUTION\" = \"EHR\".\"OBJECT_REF\".\"IN_CONTRIBUTION\")")) {
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<Record8<String, String, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>, UUID, UUID>> result2 = create.newResult(OBJECT_REF.ID_NAMESPACE, OBJECT_REF.TYPE, OBJECT_REF.ID, OBJECT_REF.IN_CONTRIBUTION, OBJECT_REF.SYS_TRANSACTION, OBJECT_REF.SYS_PERIOD, FOLDER_ITEMS.OBJECT_REF_ID, FOLDER_ITEMS.IN_CONTRIBUTION);
if (((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb")) == 0) {
result2.add(create.newRecord(OBJECT_REF.ID_NAMESPACE, OBJECT_REF.TYPE, OBJECT_REF.ID, OBJECT_REF.IN_CONTRIBUTION, OBJECT_REF.SYS_TRANSACTION, OBJECT_REF.SYS_PERIOD, FOLDER_ITEMS.OBJECT_REF_ID, FOLDER_ITEMS.IN_CONTRIBUTION).values("namespace", "FOLDER", UUID.fromString("48282ddd-4c7d-444a-8159-458a03c9827f"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), new Timestamp(expected.getMillis()), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2019-08-09T09:56:52.464799+02"), null), UUID.fromString("48282ddd-4c7d-444a-8159-458a03c9827f"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb")));
mock2[0] = new MockResult(1, result2);
return mock2;
} else if (((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("33550555-ec91-4025-838d-09ddb4e999cb")) == 0) {
result2.add(create.newRecord(OBJECT_REF.ID_NAMESPACE, OBJECT_REF.TYPE, OBJECT_REF.ID, OBJECT_REF.IN_CONTRIBUTION, OBJECT_REF.SYS_TRANSACTION, OBJECT_REF.SYS_PERIOD, FOLDER_ITEMS.OBJECT_REF_ID, FOLDER_ITEMS.IN_CONTRIBUTION).values("namespace2", "COMPOSITION", UUID.fromString("076f09ee-8da3-ae1b-0072-3ee18965fbb9"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), new Timestamp(expected.getMillis()), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2019-08-09T09:56:52.464799+02"), null), UUID.fromString("076f09ee-8da3-ae1b-0072-3ee18965fbb9"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb")));
result2.add(create.newRecord(OBJECT_REF.ID_NAMESPACE, OBJECT_REF.TYPE, OBJECT_REF.ID, OBJECT_REF.IN_CONTRIBUTION, OBJECT_REF.SYS_TRANSACTION, OBJECT_REF.SYS_PERIOD, FOLDER_ITEMS.OBJECT_REF_ID, FOLDER_ITEMS.IN_CONTRIBUTION).values("namespace3", "EHR", UUID.fromString("5bf07118-e22e-e233-35c9-78820d76627c"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e473cb"), new Timestamp(expected.getMillis()), new AbstractMap.SimpleEntry<>(OffsetDateTime.parse("2019-08-09T09:56:52.464799+02"), null), UUID.fromString("5bf07118-e22e-e233-35c9-78820d76627c"), UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb")));
mock2[0] = new MockResult(2, result2);
return mock2;
}
// return empty, i.e. no rows
mock2[0] = new MockResult(0, 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 if (sql2.toUpperCase().contains("SELECT 1 AS \"ONE\"")) {
// query needed for mocking initialization of the system
Field<Integer> c = DSL.count();
Result<Record1<Integer>> result2 = create.newResult(c);
result2.add(create.newRecord(c).values(1));
mock[0] = new MockResult(1, result2);
return mock;
} else if (sql2.toUpperCase().contains("SELECT \"EHR\".\"PARTY_IDENTIFIED\"")) {
// query needed for mocking initialization of the system
System.out.println("SQL2 is: " + sql2.toUpperCase());
System.out.println("PARTY_IDENTIFIED hist selected");
Result<Record6<UUID, String, String, String, String, String>> result2 = create.newResult(PARTY_IDENTIFIED.ID, PARTY_IDENTIFIED.NAME, PARTY_IDENTIFIED.PARTY_REF_VALUE, PARTY_IDENTIFIED.PARTY_REF_SCHEME, PARTY_IDENTIFIED.PARTY_REF_NAMESPACE, PARTY_IDENTIFIED.PARTY_REF_TYPE);
result2.add(create.newRecord(PARTY_IDENTIFIED.ID, PARTY_IDENTIFIED.NAME, PARTY_IDENTIFIED.PARTY_REF_VALUE, PARTY_IDENTIFIED.PARTY_REF_SCHEME, PARTY_IDENTIFIED.PARTY_REF_NAMESPACE, PARTY_IDENTIFIED.PARTY_REF_TYPE).values(UUID.fromString(TEST_PARTY_IDENTIFIED_ID), "Dr Tony Blegon", null, null, null, null));
mock[0] = new MockResult(1, result2);
return mock;
} else if (sql2.toUpperCase().contains("SELECT \"EHR\".\"SYSTEM\".\"ID\" FROM \"EHR\".\"SYSTEM\" WHERE \"EHR\".\"SYSTEM\".\"SETTINGS\" =")) {
// query needed for mocking initialization of the system
Result<Record1<UUID>> result2 = create.newResult(SYSTEM.ID);
result2.add(create.newRecord(SYSTEM.ID).values(UUID.fromString(TEST_SYSTEM_ID)));
mock[0] = new MockResult(1, result2);
return mock;
} else if (sql2.toUpperCase().contains("SELECT \"EHR\".\"CONCEPT\".\"ID\", \"EHR\".\"CONCEPT\".\"CONCEPTID\", \"EHR\".\"CONCEPT\".\"LANGUAGE\", \"EHR\".\"CONCEPT\".\"DESCRIPTION\"")) {
// query needed for mocking initialization of the system
Result<Record4<UUID, Integer, String, String>> result2 = create.newResult(CONCEPT.ID, CONCEPT.CONCEPTID, CONCEPT.LANGUAGE, CONCEPT.DESCRIPTION);
result2.add(create.newRecord(CONCEPT.ID, CONCEPT.CONCEPTID, CONCEPT.LANGUAGE, CONCEPT.DESCRIPTION).values(UUID.fromString("dcd3b8c5-36e3-4ac7-83aa-7e9068f443d8"), new Integer(249), "en", "creation"));
mock[0] = new MockResult(1, result2);
return mock;
} else if (sql2.toUpperCase().startsWith("INSERT INTO \"EHR\".\"CONTRIBUTION")) {
if (((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("f6a2af65-fe89-45a4-9456-07c5e17b1634")) == 0) {
Result<Record1<UUID>> result2 = create.newResult(CONTRIBUTION.ID);
result2.add(create.newRecord(CONTRIBUTION.ID).values(UUID.fromString("3e2fcd27-d846-4a0d-888a-47b2da9e5cbb")));
mock[0] = new MockResult(1, result2);
return mock;
}
throw new SQLException("Statement not currently supported. Consider enhancing or revising the FolderMockDataProvider: " + sql2);
} else if (sql2.toUpperCase().startsWith("INSERT INTO \"EHR\".\"FOLDER\" (\"ID\", \"IN_CONTRIBUTION\",")) {
if (sql2.toUpperCase().startsWith(("INSERT INTO \"EHR\".\"FOLDER\" (\"ID\", \"IN_CONTRIBUTION\", \"NAME\", \"ARCHETYPE_NODE_ID\", \"ACTIVE\", \"DETAILS\", \"SYS_TRANSACTION\") VALUES (?, ?, ?, ?, ?, '{\n" + " \"_TYPE\" : \"\",\n" + " \"ITEMS\" : [ {\n" + " \"NAME\" : {\n" + " \"_TYPE\" : \"DV_TEXT\",\n" + " \"VALUE\" : \"FOL2\"\n" + " }\n" + " } ]\n" + "}'::JSONB, CAST(? AS TIMESTAMP)) RETURNING \"EHR\".\"FOLDER\".\"ID\""))) {
if (((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("f0a2af65-fe89-45a4-9456-07c5e17b1634")) == 0) {
Result<Record1<UUID>> result2 = create.newResult(FOLDER.ID);
result2.add(create.newRecord(FOLDER.ID).values(UUID.fromString("f0a2af65-fe89-45a4-9456-07c5e17b1634")));
mock[0] = new MockResult(1, result2);
return mock;
}
} else if (sql2.toUpperCase().startsWith(("INSERT INTO \"EHR\".\"FOLDER\" (\"ID\", \"IN_CONTRIBUTION\", \"NAME\", \"ARCHETYPE_NODE_ID\", \"ACTIVE\", \"DETAILS\", \"SYS_TRANSACTION\") VALUES (?, ?, ?, ?, ?, '{\n" + " \"_TYPE\" : \"\",\n" + " \"ITEMS\" : [ {\n" + " \"NAME\" : {\n" + " \"_TYPE\" : \"DV_TEXT\",\n" + " \"VALUE\" : \"FOL1\"\n" + " }\n" + " } ]\n" + "}'::JSONB, CAST(? AS TIMESTAMP)) RETURNING \"EHR\".\"FOLDER\".\"ID\""))) {
if (((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("f8a2af65-fe89-45a4-9456-07c5e17b1634")) == 0) {
Result<Record1<UUID>> result2 = create.newResult(FOLDER.ID);
result2.add(create.newRecord(FOLDER.ID).values(UUID.fromString("f8a2af65-fe89-45a4-9456-07c5e17b1634")));
mock[0] = new MockResult(1, result2);
return mock;
}
} else if (sql2.toUpperCase().startsWith(("INSERT INTO \"EHR\".\"FOLDER\" (\"ID\", \"IN_CONTRIBUTION\", \"NAME\", \"ARCHETYPE_NODE_ID\", \"ACTIVE\", \"DETAILS\", \"SYS_TRANSACTION\") VALUES (?, ?, ?, ?, ?, '{\n" + " \"_TYPE\" : \"\",\n" + " \"ITEMS\" : [ { } ]\n" + "}'::JSONB, CAST(? AS TIMESTAMP)) RETURNING \"EHR\".\"FOLDER\".\"ID\""))) {
if (((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("f4a2af65-fe89-45a4-9456-07c5e17b1634")) == 0) {
Result<Record1<UUID>> result2 = create.newResult(FOLDER.ID);
result2.add(create.newRecord(FOLDER.ID).values(UUID.fromString("f4a2af65-fe89-45a4-9456-07c5e17b1634")));
mock[0] = new MockResult(1, result2);
return mock;
}
}
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 if (sql2.toUpperCase().startsWith("INSERT INTO \"EHR\".\"FOLDER_HIERARCHY\" (\"PARENT_FOLDER\", \"CHILD_FOLDER\", \"IN_CONTRIBUTION\", \"SYS_TRANSACTION\") VALUES")) {
String uidParentFolder = ((UUID) ctx.bindings()[0]).toString();
String uidChildFolder = ((UUID) ctx.bindings()[1]).toString();
if ((uidParentFolder.equals("f0a2af65-fe89-45a4-9456-07c5e17b1634")) && (uidChildFolder.equals("f4a2af65-fe89-45a4-9456-07c5e17b1634"))) {
Result<Record2<UUID, UUID>> result2 = create.newResult(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER);
result2.add(create.newRecord(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER).values(UUID.fromString("f0a2af65-fe89-45a4-9456-07c5e17b1634"), UUID.fromString("f4a2af65-fe89-45a4-9456-07c5e17b1634")));
mock[0] = new MockResult(1, result2);
return mock;
} else if ((uidParentFolder.equals("f8a2af65-fe89-45a4-9456-07c5e17b1634")) && (uidChildFolder.equals("f0a2af65-fe89-45a4-9456-07c5e17b1634"))) {
Result<Record2<UUID, UUID>> result2 = create.newResult(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER);
result2.add(create.newRecord(FOLDER_HIERARCHY.PARENT_FOLDER, FOLDER_HIERARCHY.CHILD_FOLDER).values(UUID.fromString("f8a2af65-fe89-45a4-9456-07c5e17b1634"), UUID.fromString("f0a2af65-fe89-45a4-9456-07c5e17b1634")));
mock[0] = new MockResult(1, result2);
return mock;
}
} else if (sql2.toUpperCase().startsWith("UPDATE \"EHR\".\"CONTRIBUTION\" SET \"CONTRIBUTION_TYPE\"")) {
Field<Integer> c = DSL.count();
Result<Record1<Integer>> result2 = create.newResult(c);
result2.add(create.newRecord(c).values(1));
mock[0] = new MockResult(1, result2);
return mock;
} else if (sql2.toUpperCase().startsWith("UPDATE \"EHR\".\"CONTRIBUTION\" SET \"EHR_ID\" = ?, \"CONTRIBUTION_TYPE\" = ?::\"EHR\".\"CONTRIBUTION_DATA_TYPE\", \"STATE\" =")) {
Field<Integer> c = DSL.count();
Result<Record1<Integer>> result2 = create.newResult(c);
result2.add(create.newRecord(c).values(1));
mock[0] = new MockResult(1, result2);
return mock;
} else if (sql2.toUpperCase().startsWith("UPDATE \"EHR\".\"FOLDER\" SET \"ID\" = ?, \"IN_CONTRIBUTION\" = ?, \"NAME\" = ?, \"ARCHETYPE_NODE_ID\" = ?, \"ACTIVE\" = ?, \"DETAILS\" = ")) {
if ((((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb")) == 0) && (((UUID) ctx.bindings()[1]).compareTo(UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb")) == 0) && (((String) ctx.bindings()[2]).compareTo("modifiedName") == 0) && (((String) ctx.bindings()[3]).compareTo("modifiedArchetypeNodeId") == 0) && (((Boolean) ctx.bindings()[4]).compareTo(false) == 0)) {
mock[0] = new MockResult(1, create.newResult(FOLDER));
return mock;
} else if ((((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("99550555-ec91-4025-838d-09ddb4e999cb")) == 0) && (((UUID) ctx.bindings()[1]).compareTo(UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb")) == 0) && (((String) ctx.bindings()[2]).compareTo("new name of folder 2") == 0) && (((String) ctx.bindings()[3]).compareTo("folder_archetype.v1") == 0) && (((Boolean) ctx.bindings()[4]).compareTo(true) == 0)) {
mock[0] = new MockResult(1, create.newResult(FOLDER));
return mock;
} else if ((((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("33550555-ec91-4025-838d-09ddb4e999cb")) == 0) && (((UUID) ctx.bindings()[1]).compareTo(UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb")) == 0) && (((String) ctx.bindings()[2]).compareTo("folder_archetype_name_3") == 0) && (((String) ctx.bindings()[3]).compareTo("new archetype node id") == 0) && (((Boolean) ctx.bindings()[4]).compareTo(true) == 0)) {
mock[0] = new MockResult(1, create.newResult(FOLDER));
return mock;
} else if ((((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("8701233c-c8fd-47ba-91b5-ef9ff23c259b")) == 0) && (((UUID) ctx.bindings()[1]).compareTo(UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb")) == 0) && (((String) ctx.bindings()[2]).compareTo("folder_archetype_name_5") == 0) && (((String) ctx.bindings()[3]).compareTo("folder_archetype.v1") == 0) && (((Boolean) ctx.bindings()[4]).compareTo(false) == 0)) {
mock[0] = new MockResult(1, create.newResult(FOLDER));
return mock;
} else if ((((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("77750555-ec91-4025-838d-09ddb4e999cb")) == 0) && (((UUID) ctx.bindings()[1]).compareTo(UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb")) == 0) && (((String) ctx.bindings()[2]).compareTo("folder_archetype_name_4") == 0) && (((String) ctx.bindings()[3]).compareTo("folder_archetype.v1") == 0) && (((Boolean) ctx.bindings()[4]).compareTo(true) == 0)) {
mock[0] = new MockResult(1, create.newResult(FOLDER));
return mock;
} else if ((((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("00550555-ec91-4025-838d-09ddb4e999cb")) == 0) && (((UUID) ctx.bindings()[1]).compareTo(UUID.fromString("3e2fcd27-d846-4a0d-888a-47b2da9e5cbb")) == 0)) {
mock[0] = new MockResult(1, create.newResult(FOLDER));
return mock;
}
} else if (sql2.toUpperCase().startsWith("DELETE FROM \"EHR\".\"FOLDER\" WHERE (\"EHR\".\"FOLDER\".\"ID\" IN (?, ?, ?, ?) OR \"EHR\".\"FOLDER\".\"ID\" = ?)")) {
if (((UUID) ctx.bindings()[0]).compareTo(UUID.fromString("99550555-ec91-4025-838d-09ddb4e999cb")) == 0) {
mock[0] = new MockResult(5, create.newResult(FOLDER));
return mock;
}
} else if (sql2.toLowerCase().startsWith("insert into \"ehr\".\"audit_details\" (\"system_id\", \"committer\", \"time_committed\", \"time_committed_tzid\", \"change_type\") values")) {
if ((((UUID) ctx.bindings()[0]).compareTo(UUID.fromString(TEST_SYSTEM_ID)) == 0) && (((UUID) ctx.bindings()[1]).compareTo(UUID.fromString(TEST_PARTY_IDENTIFIED_ID)) == 0)) {
Result<Record1<UUID>> result2 = create.newResult(AUDIT_DETAILS.ID);
result2.add(create.newRecord(AUDIT_DETAILS.ID).values(UUID.fromString("3e2fcd27-d846-4a0d-888a-47b2da9e5cbb")));
mock[0] = new MockResult(1, result2);
return mock;
}
throw new SQLException("SQL statement not expected. Consider enhancing or revising the FolderMockDataProvider in order to ensure the controlled behaviour of your code: " + sql2);
}
return mock;
}
use of com.nedap.archie.rm.datastructures.ItemStructure in project ehrbase by ehrbase.
the class ContextAccess method mapRmEventContext.
/**
* @throws InternalServerException on failure of decoding DvText or DvDateTime
*/
@Override
public EventContext mapRmEventContext() {
// get the facility entry
PartyIdentifiedRecord partyIdentifiedRecord = getContext().fetchOne(PARTY_IDENTIFIED, PARTY_IDENTIFIED.ID.eq(eventContextRecord.getFacility()));
// facility identifiers
PartyIdentified healthCareFacility = null;
if (partyIdentifiedRecord != null) {
List<DvIdentifier> identifiers = new ArrayList<>();
getContext().fetch(IDENTIFIER, IDENTIFIER.PARTY.eq(partyIdentifiedRecord.getId())).forEach(record -> {
DvIdentifier dvIdentifier = new DvIdentifier();
dvIdentifier.setIssuer(record.getIssuer());
dvIdentifier.setAssigner(record.getAssigner());
dvIdentifier.setId(record.getIdValue());
dvIdentifier.setType(record.getTypeName());
identifiers.add(dvIdentifier);
});
// get PartyRef values from record
healthCareFacility = getPartyIdentifiedFromRecord(partyIdentifiedRecord, identifiers);
}
List<Participation> participationList = new ArrayList<>();
// get the participations
getContext().fetch(PARTICIPATION, PARTICIPATION.EVENT_CONTEXT.eq(eventContextRecord.getId())).forEach(record -> {
// retrieve performer
PartyProxy performer = new PersistedPartyProxy(this).retrieve(record.getPerformer());
DvInterval<DvDateTime> dvInterval = convertDvIntervalDvDateTimeFromRecord(record);
DvCodedText mode = convertModeFromRecord(record);
Participation participation = new Participation(performer, (DvText) new RecordedDvCodedText().fromDB(record, PARTICIPATION.FUNCTION), mode, dvInterval);
participationList.add(participation);
});
DvCodedText concept = (DvCodedText) new RecordedDvCodedText().fromDB(eventContextRecord, EVENT_CONTEXT.SETTING);
ItemStructure otherContext = null;
if (eventContextRecord.getOtherContext() != null) {
otherContext = new RawJson().unmarshal((eventContextRecord.getOtherContext().data()), ItemStructure.class);
}
return new EventContext(healthCareFacility, new RecordedDvDateTime().decodeDvDateTime(eventContextRecord.getStartTime(), eventContextRecord.getStartTimeTzid()), new RecordedDvDateTime().decodeDvDateTime(eventContextRecord.getEndTime(), eventContextRecord.getEndTimeTzid()), participationList.isEmpty() ? null : participationList, eventContextRecord.getLocation(), concept, otherContext);
}
use of com.nedap.archie.rm.datastructures.ItemStructure in project openEHR_SDK by ehrbase.
the class DBEncodeTest method decodeOtherDetailsFailing.
@Test
public void decodeOtherDetailsFailing() {
String dbEncoded = "{\n" + " \"/name\": {\n" + " \"value\": \"family group\"\n" + " },\n" + " \"/$CLASS$\": \"ItemTree\",\n" + " \"/archetype_node_id\": \"openEHR-EHR-ITEM_TREE.fake.v1\",\n" + " \"/items[openEHR-EHR-ITEM_TREE.fake.v1 and name/value='family group']\": {\n" + " \"/name\": [\n" + " {\n" + " \"value\": \"family group id\"\n" + " }\n" + " ],\n" + " \"/value\": {\n" + " \"id\": \"55175056\",\n" + " \"type\": \"FAMILY_GROUP_ID\",\n" + " \"issuer\": \"MoH\",\n" + " \"assigner\": \"MoH\"\n" + " },\n" + " \"/$PATH$\": \"/items[openEHR-EHR-ITEM_TREE.fake.v1 and name/value='family group']/items[at0001]\",\n" + " \"/$CLASS$\": \"DvIdentifier\"\n" + " }\n" + "}";
ItemStructure converted = new RawJson().unmarshal(dbEncoded, ItemStructure.class);
assertNotNull(converted);
}
Aggregations