private void setFamilyExternalId(String externalId, Family family, XWikiContext context) { BaseObject familyObject = family.getXDocument().getXObject(Family.CLASS_REFERENCE); familyObject.set("external_id", externalId, context); }
private synchronized boolean saveFamilyDocument(Family family, String documentHistoryComment, XWikiContext context) { try { family.getXDocument().setAuthorReference(context.getUserReference()); context.getWiki().saveDocument(family.getXDocument(), documentHistoryComment, context); } catch (XWikiException e) { this.logger.error("Error saving family [{}] document for commit {}: [{}]", family.getId(), documentHistoryComment, e.getMessage()); return false; } return true; }
@Override public synchronized Family create(final DocumentReference creator) { try { final XWikiContext context = this.xcontextProvider.get(); final Family family = super.create(creator); final XWikiDocument doc = family.getXDocument(); if (doc.getXObject(Owner.CLASS_REFERENCE) == null) { // add owner reference to family - only if no owner already exist, e.g. from FamilyTemplate doc.newXObject(Owner.CLASS_REFERENCE, context).set(OWNER, creator == null ? StringUtils.EMPTY : this.entitySerializer.serialize(creator), context); } // Adding identifier to family doc.getXObject(Family.CLASS_REFERENCE).setLongValue(IDENTIFIER, Integer.parseInt(family.getId().replaceAll("\\D++", StringUtils.EMPTY))); context.getWiki().saveDocument(doc, context); return family; } catch (Exception ex) { this.logger.warn("Failed to create family: {}", ex.getMessage(), ex); return null; } }
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.getXDocument().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.getXDocument().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.getDocumentReference().toString()); } else { familyClassObject.setStringValue("proband_id", ""); } } return true; }
if (!this.setFamilyReference(patientDocument, family.getXDocument(), context)) { throw new PTInternalErrorException(); BaseObject familyObject = family.getXDocument().getXObject(Family.CLASS_REFERENCE); familyObject.set(PhenotipsFamily.FAMILY_MEMBERS_FIELD, members, context);
XWikiDocument familyDocument = family.getXDocument(); BaseObject familyClassObject = familyDocument.getXObject(Family.CLASS_REFERENCE); if (familyClassObject.getStringValue("proband_id").equals(patient.getDocumentReference().toString())) {
BaseObject familyObject = family.getXDocument().getXObject(Family.CLASS_REFERENCE); familyObject.set(PhenotipsFamily.FAMILY_MEMBERS_FIELD, members, context);