use of org.ehrbase.jooq.binding.SysPeriodBinder in project ehrbase by ehrbase.
the class FolderAccess method buildFolderAccessFromGenericRecord.
/**
* Create a new {@link FolderAccess} from a {@link org.jooq.Record} DB record
*
* @param record_ record containing all the information to build one folder-subfolder
* relationship.
* @param domainAccess containing the DB connection information.
* @return FolderAccess instance
*/
private static FolderAccess buildFolderAccessFromGenericRecord(final Record record_, final I_DomainAccess domainAccess) {
Record13<UUID, UUID, UUID, Timestamp, Object, UUID, UUID, String, String, Boolean, JSONB, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>> record = (Record13<UUID, UUID, UUID, Timestamp, Object, UUID, UUID, String, String, Boolean, JSONB, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>>) record_;
FolderAccess folderAccess = new FolderAccess(domainAccess);
folderAccess.folderRecord = new FolderRecord();
folderAccess.setFolderId(record.value1());
folderAccess.setInContribution(record.value7());
folderAccess.setFolderName(record.value8());
folderAccess.setFolderNArchetypeNodeId(record.value9());
folderAccess.setIsFolderActive(record.value10());
// Due to generic type from JOIN The ItemStructure binding does not cover the details
// and we have to parse it manually
folderAccess.setFolderDetails(new OtherDetailsJsonbBinder().converter().from(record.value11()));
folderAccess.setFolderSysTransaction(record.value12());
folderAccess.setFolderSysPeriod(new SysPeriodBinder().converter().from(record.value13()));
folderAccess.getItems().addAll(FolderAccess.retrieveItemsByFolderAndContributionId(record.value1(), record.value7(), domainAccess));
return folderAccess;
}
use of org.ehrbase.jooq.binding.SysPeriodBinder in project ehrbase by ehrbase.
the class FolderAccess method retrieveItemsByFolderAndContributionId.
/**
* Retrieves a list containing the items as ObjectRefs of the folder corresponding to the id
* provided.
*
* @param folderId of the FOLDER that the items correspond to.
* @param in_contribution contribution that establishes the reference between a FOLDER and its
* item.
* @param domainAccess connection DB data.
* @return
*/
private static List<ObjectRef<?>> retrieveItemsByFolderAndContributionId(UUID folderId, UUID in_contribution, I_DomainAccess domainAccess) {
Result<Record> retrievedRecords = domainAccess.getContext().with("folderItemsSelect").as(select(FOLDER_ITEMS.OBJECT_REF_ID.as("object_ref_id"), FOLDER_ITEMS.IN_CONTRIBUTION.as("item_in_contribution")).from(FOLDER_ITEMS).where(FOLDER_ITEMS.FOLDER_ID.eq(folderId))).select().from(OBJECT_REF, table(name("folderItemsSelect"))).where(field(name("object_ref_id"), FOLDER_ITEMS.OBJECT_REF_ID.getType()).eq(OBJECT_REF.ID).and(field(name("item_in_contribution"), FOLDER_ITEMS.IN_CONTRIBUTION.getType()).eq(OBJECT_REF.IN_CONTRIBUTION))).fetch();
List<ObjectRef<?>> result = new ArrayList<>();
for (Record recordRecord : retrievedRecords) {
Record8<String, String, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>, UUID, UUID> recordParam = (Record8<String, String, UUID, UUID, Timestamp, AbstractMap.SimpleEntry<OffsetDateTime, OffsetDateTime>, UUID, UUID>) recordRecord;
ObjectRefRecord objectRef = new ObjectRefRecord();
objectRef.setIdNamespace(recordParam.value1());
objectRef.setType(recordParam.value2());
objectRef.setId(recordParam.value3());
objectRef.setInContribution(recordParam.value4());
objectRef.setSysTransaction(recordParam.value5());
objectRef.setSysPeriod(new SysPeriodBinder().converter().from(recordParam.value6()));
objectRef.setId(recordParam.value7());
result.add(parseObjectRefRecordIntoObjectRef(objectRef, domainAccess));
}
return result;
}
use of org.ehrbase.jooq.binding.SysPeriodBinder in project ehrbase by ehrbase.
the class FolderHistoryAccess method buildFolderAccessFromGenericRecord.
private static FolderHistoryAccess buildFolderAccessFromGenericRecord(final Record record_, final I_DomainAccess domainAccess) {
Record15<UUID, UUID, UUID, Timestamp, Object, UUID, Timestamp, UUID, UUID, String, String, Boolean, JSONB, Timestamp, Object> record = (Record15<UUID, UUID, UUID, Timestamp, Object, UUID, Timestamp, UUID, UUID, String, String, Boolean, JSONB, Timestamp, Object>) record_;
FolderHistoryAccess folderAccess = new FolderHistoryAccess(domainAccess);
folderAccess.folderRecord = new FolderRecord();
folderAccess.setFolderId(record.value1());
folderAccess.setInContribution(record.value3());
folderAccess.setFolderName(record.value10());
folderAccess.setFolderNArchetypeNodeId(record.value11());
folderAccess.setIsFolderActive(record.value12());
// Due to generic type from JOIN The ItemStructure binding does not cover the details
// and we have to parse it manually
folderAccess.setFolderDetails(new OtherDetailsJsonbBinder().converter().from(record.value13()));
folderAccess.setFolderSysTransaction(record.value14());
folderAccess.setFolderSysPeriod(new SysPeriodBinder().converter().from(record.value15()));
folderAccess.getItems().addAll(FolderHistoryAccess.retrieveItemsByFolderAndContributionId(record.value1(), record.value3(), domainAccess));
return folderAccess;
}
Aggregations