use of org.ehrbase.dao.access.interfaces.I_ConceptAccess.ContributionChangeType in project ehrbase by ehrbase.
the class FolderAccess method update.
/**
* {@inheritDoc}
*/
@Override
public boolean update(final LocalDateTime transactionTime, UUID contribution) {
/*create new contribution*/
UUID oldContribution = this.folderRecord.getInContribution();
UUID newContribution;
// Custom contribution is provided, so use given one
this.getFolderRecord().setInContribution(contribution);
newContribution = folderRecord.getInContribution();
var newContributionAccess = I_ContributionAccess.retrieveInstance(this.getDataAccess(), newContribution);
UUID systemId = newContributionAccess.getAuditsSystemId();
UUID committerId = newContributionAccess.getAuditsCommitter();
String description = newContributionAccess.getAuditsDescription();
ContributionChangeType changeType = newContributionAccess.getAuditsChangeType();
return this.internalUpdate(Timestamp.valueOf(transactionTime), true, null, oldContribution, newContribution, systemId, committerId, description, changeType);
}
use of org.ehrbase.dao.access.interfaces.I_ConceptAccess.ContributionChangeType in project ehrbase by ehrbase.
the class FolderAccess method internalUpdate.
private Boolean internalUpdate(final Timestamp transactionTime, boolean rootFolder, UUID parentFolder, UUID oldContribution, UUID newContribution, UUID systemId, UUID committerId, String description, ContributionChangeType contributionChangeType) {
boolean result;
// Set new Contribution for MODIFY
this.setInContribution(newContribution);
// create new folder audit with given values
auditDetailsAccess = new AuditDetailsAccess(this);
auditDetailsAccess.setSystemId(systemId);
auditDetailsAccess.setCommitter(committerId);
auditDetailsAccess.setDescription(description);
auditDetailsAccess.setChangeType(I_ConceptAccess.fetchContributionChangeType(this, contributionChangeType));
UUID auditId = this.auditDetailsAccess.commit();
if (rootFolder) {
// if it is the root folder preserve the original id, otherwise let the DB provide a new one for the overridden subfolders.
folderRecord.setInContribution(newContribution);
folderRecord.setSysTransaction(transactionTime);
getContext().attach(folderRecord);
result = folderRecord.update() > 0;
} else {
// Copy into new instance and attach to DB context.
var updatedFolderRecord = new FolderRecord();
updatedFolderRecord.setInContribution(newContribution);
updatedFolderRecord.setName(this.getFolderName());
updatedFolderRecord.setArchetypeNodeId(this.getFolderArchetypeNodeId());
updatedFolderRecord.setActive(this.isFolderActive());
updatedFolderRecord.setDetails(this.getFolderDetails());
updatedFolderRecord.setSysTransaction(transactionTime);
updatedFolderRecord.setSysPeriod(this.getFolderSysPeriod());
updatedFolderRecord.setHasAudit(auditId);
// attach to context DB
getContext().attach(updatedFolderRecord);
// Save new Folder entry to the database
result = updatedFolderRecord.insert() > 0;
// Finally overwrite original FolderRecord on this FolderAccess instance to have the
// new data available at service layer. Thus we do not need to re-fetch the updated folder
// tree from DB
this.folderRecord = updatedFolderRecord;
// Create FolderHierarchy entries this sub folder instance
var updatedFhR = new FolderHierarchyRecord();
updatedFhR.setParentFolder(parentFolder);
updatedFhR.setChildFolder(updatedFolderRecord.getId());
updatedFhR.setInContribution(newContribution);
updatedFhR.setSysTransaction(transactionTime);
updatedFhR.setSysPeriod(folderRecord.getSysPeriod());
getContext().attach(updatedFhR);
updatedFhR.store();
}
// Get new folder id for folder items and hierarchy
UUID updatedFolderId = this.folderRecord.getId();
// Update items -> Save new list of all items in this folder
this.saveFolderItems(updatedFolderId, oldContribution, newContribution, transactionTime, getContext());
boolean anySubfolderModified = // Map of sub folders with UUID
this.getSubfoldersList().values().stream().map(subfolder -> (// Update each entry and return if there has been at least one entry updated
((FolderAccess) subfolder).internalUpdate(transactionTime, false, updatedFolderId, oldContribution, newContribution, systemId, committerId, description, contributionChangeType))).reduce((b1, b2) -> b1 || b2).orElse(false);
return result || anySubfolderModified;
}
use of org.ehrbase.dao.access.interfaces.I_ConceptAccess.ContributionChangeType in project ehrbase by ehrbase.
the class ContributionAccess method update.
@Override
public Boolean update(Timestamp transactionTime, UUID committerId, UUID systemId, String contributionType, String contributionState, String contributionChangeType, String description) {
// set contribution attributes
ContributionDataType type = null;
ContributionDef.ContributionState state = null;
I_ConceptAccess.ContributionChangeType changeType = null;
if (contributionType == null)
type = ContributionDataType.valueOf(contributionType);
if (contributionState != null)
state = ContributionDef.ContributionState.valueOf(contributionState);
if (contributionChangeType != null)
changeType = I_ConceptAccess.ContributionChangeType.valueOf(contributionChangeType);
// audit handling will be executed centralized in the following called method
return update(transactionTime, committerId, systemId, type, state, changeType, description);
}
Aggregations