use of com.nedap.archie.rm.directory.Folder in project ehrbase by ehrbase.
the class FolderServiceImpTest method serializesFolderToXML.
@Test
@Ignore
public void serializesFolderToXML() throws IOException {
String value = IOUtils.toString(FolderTestDataCanonicalJson.SIMPLE_EMPTY_FOLDER.getStream(), UTF_8);
Folder folder = cut.unmarshal(value, Folder.class);
StructuredString result = folderService.serialize(folder, StructuredStringFormat.XML);
StructuredString result2 = folderService.serialize(folder, StructuredStringFormat.XML);
assertThat(result).isNotNull();
assertThat(result.getFormat()).isEqualTo(StructuredStringFormat.XML);
assertThat(result.getValue()).isEqualToIgnoringWhitespace("<folder xsi:type=\"FOLDER\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><name><value>Simple empty folder</value></name></folder>");
}
use of com.nedap.archie.rm.directory.Folder in project ehrbase by ehrbase.
the class FolderAccess method buildFolderAccessTreeRecursively.
/**
* Recursive method for populating the hierarchy of {@link I_FolderAccess} for a given {@link
* com.nedap.archie.rm.directory.Folder}.
*
* @param domainAccess providing the information about the DB connection.
* @param current {@link com.nedap.archie.rm.directory.Folder} explored in the current
* iteration.
* @param parent folder of the {@link com.nedap.archie.rm.directory.Folder} procided
* as the current parameter.
* @param dateTime of the transaction that will be stored inthe DB.
* @param ehrId of the {@link com.nedap.archie.rm.ehr.Ehr} referencing the current
* {@link com.nedap.archie.rm.directory.Folder}.
* @param contributionAccess that corresponds to the contribution that the {@link
* com.nedap.archie.rm.directory.Folder} refers to.
* @return {@link I_FolderAccess} with the complete hierarchy of sub-folders represented as {@link
* I_FolderAccess}.
* @throws Exception
*/
private static I_FolderAccess buildFolderAccessTreeRecursively(final I_DomainAccess domainAccess, final Folder current, final FolderAccess parent, final DateTime dateTime, final UUID ehrId, final I_ContributionAccess contributionAccess) {
I_FolderAccess folderAccess = null;
// if the parent already contains the FolderAccess for the specified folder return the corresponding FolderAccess
if ((parent != null) && (parent.getSubfoldersList().containsKey(UUID.fromString(current.getUid().getValue())))) {
return parent.getSubfoldersList().get(current.getUid());
}
// create the corresponding FolderAccess for the current folder
folderAccess = FolderAccess.buildPlainFolderAccess(domainAccess, current, Timestamp.from(Instant.now()), ehrId, contributionAccess);
// add to parent subfolder list
if (parent != null) {
parent.getSubfoldersList().put(((FolderAccess) folderAccess).getFolderRecord().getId(), folderAccess);
}
for (Folder child : current.getFolders()) {
buildFolderAccessTreeRecursively(domainAccess, child, (FolderAccess) folderAccess, dateTime, ehrId, ((FolderAccess) folderAccess).getContributionAccess());
}
return folderAccess;
}
use of com.nedap.archie.rm.directory.Folder in project openEHR_SDK by ehrbase.
the class DefaultRestDirectoryEndpoint method find.
synchronized Folder find(String path) {
if (StringUtils.isBlank(path)) {
return root;
}
String[] split = path.split(FOLDER_DIVIDER);
Folder current = root;
for (String folderName : split) {
Folder newFolder = Optional.ofNullable(current).map(Folder::getFolders).flatMap(l -> l.stream().filter(f -> folderName.equals(f.getName().getValue())).findAny()).orElse(null);
if (newFolder == null) {
newFolder = new Folder();
newFolder.setArchetypeNodeId("openEHR-EHR-FOLDER.generic.v1");
newFolder.setName(new DvText(folderName));
if (current.getFolders() == null) {
current.setFolders(new ArrayList<>());
}
current.addFolder(newFolder);
}
current = newFolder;
}
return current;
}
use of com.nedap.archie.rm.directory.Folder in project openEHR_SDK by ehrbase.
the class DefaultRestDirectoryEndpoint method createRoot.
private void createRoot() {
root = new Folder();
root.setName(new DvText("root"));
root.setArchetypeNodeId("openEHR-EHR-FOLDER.generic.v1");
VersionUid versionUid = defaultRestClient.httpPost(resolve(""), root);
rootVersion = versionUid;
}
use of com.nedap.archie.rm.directory.Folder in project openEHR_SDK by ehrbase.
the class DefaultRestFolderDAO method addCompositionEntity.
@Override
public <T> T addCompositionEntity(T entity) {
T updatedEntity = directoryEndpoint.getCompositionEndpoint().mergeCompositionEntity(entity);
UUID uuid = DefaultRestCompositionEndpoint.extractVersionUid(updatedEntity).orElseThrow(() -> new ClientException(String.format("No Id Element for %s", entity.getClass()))).getUuid();
Folder folder = getFolder();
if (folder.getItems() == null) {
folder.setItems(new ArrayList<>());
}
folder.getItems().add(new ObjectRef(new ObjectVersionId(uuid.toString()), "dffddfd", "VERSIONED_COMPOSITION"));
directoryEndpoint.saveToDb();
return updatedEntity;
}
Aggregations