private void setFamilyExternalId(String externalId, Family family, XWikiContext context) { BaseObject familyObject = family.getDocument().getXObject(Family.CLASS_REFERENCE); familyObject.set("external_id", externalId, context); }
private synchronized boolean saveFamilyDocument(Family family, String documentHistoryComment, XWikiContext context) { try { family.getDocument().setAuthorReference(context.getUserReference()); context.getWiki().saveDocument(family.getDocument(), documentHistoryComment, context); } catch (XWikiException e) { this.logger.error("Error saving family [{}] document for commit {}: [{}]", family.getId(), documentHistoryComment, e.getMessage()); return false; } return true; }
/** * For every family member, read users and groups that have either view or edit edit access on the patient, then * gives the sam elevel of access on the family for those users and groups. After performing this method, if p is a * member of the family, and x has level y access on p, x has level y access on the family. The user who is the * owner of the family always has full access to the family. Note that the document is not saved to disk, changes * are only made for the provided Family object and its in-memory copy of the corresponding XWiki document. * * @param family to update permissions * @param context XWiki context to be used. The documnt will not be saved to disk, only changes in memory for the * family document given will be made */ public void updatePermissions(Family family, XWikiContext context) { XWiki wiki = context.getWiki(); List<Patient> members = family.getMembers(); this.updatePermissionsForOneRightLevel(VIEW_RIGHTS, members, family.getDocument(), wiki, context); // setting view-edit rights after view rights makes sure if a user has edit rights on one patient // and view rights on another the user still gets edit permissions for the family this.updatePermissionsForOneRightLevel(VIEWEDIT_RIGHTS, members, family.getDocument(), wiki, context); DocumentReference creatorReference = family.getDocument().getCreatorReference(); this.setOwnerPermissionsForUser(creatorReference == null ? "" : creatorReference.toString(), family.getDocument(), context); }
private boolean setPedigreeObject(Family family, Pedigree pedigree, XWikiContext context) { if (pedigree == null) { this.logger.error("Can not set NULL pedigree for family [{}]", family.getId()); return false; } BaseObject pedigreeObject = family.getDocument().getXObject(Pedigree.CLASS_REFERENCE); pedigreeObject.set(Pedigree.IMAGE, ((pedigree == null) ? "" : pedigree.getImage(null)), context); pedigreeObject.set(Pedigree.DATA, ((pedigree == null) ? "" : pedigree.getData().toString()), context); // update proband ID every time pedigree is changed BaseObject familyClassObject = family.getDocument().getXObject(Family.CLASS_REFERENCE); if (familyClassObject != null) { String probandId = pedigree.getProbandId(); if (!StringUtils.isEmpty(probandId)) { Patient patient = this.patientRepository.get(probandId); familyClassObject.setStringValue("proband_id", (patient == null) ? "" : patient.getDocument() .toString()); } else { familyClassObject.setStringValue("proband_id", ""); } } return true; }
@Override public synchronized boolean deleteFamily(Family family, User updatingUser, boolean deleteAllMembers) { if (!canDeleteFamily(family, updatingUser, deleteAllMembers, false)) { return false; } if (deleteAllMembers) { for (Patient patient : family.getMembers()) { if (!this.patientRepository.delete(patient)) { this.logger.error("Failed to delete patient [{}] - deletion of family [{}] aborted", patient.getId(), family.getId()); return false; } } } else if (!this.forceRemoveAllMembers(family, updatingUser)) { return false; } try { XWikiContext context = this.provider.get(); XWiki xwiki = context.getWiki(); xwiki.deleteDocument(xwiki.getDocument(family.getDocument(), context), context); } catch (XWikiException ex) { this.logger.error("Failed to delete family document [{}]: {}", family.getId(), ex.getMessage()); return false; } return true; }
if (!this.setFamilyReference(patientDocument, family.getDocument(), context)) { throw new PTInternalErrorException(); BaseObject familyObject = family.getDocument().getXObject(Family.CLASS_REFERENCE); familyObject.set(PhenotipsFamily.FAMILY_MEMBERS_FIELD, members, context);
BaseObject familyObject = family.getDocument().getXObject(Family.CLASS_REFERENCE); familyObject.set(PhenotipsFamily.FAMILY_MEMBERS_FIELD, members, context);