/** * Sets the {@code value} for a {@code property} field in {@code xwikiDataObject}. * * @param xwikiDataObject the {@link BaseObject} where data will be saved * @param property the property of interest * @param value the value for the {@code property} of interest */ void saveFieldValue( @Nonnull final BaseObject xwikiDataObject, @Nonnull final String property, @Nullable final String value) { xwikiDataObject.setStringValue(property, value); }
/** * @since 2.2.3 */ public void setStringValue(EntityReference classReference, String fieldName, String value) { BaseObject bobject = prepareXObject(classReference); bobject.setStringValue(fieldName, value); }
/** * Helper method - set permissions object properties for one access level. */ private void setRights(XWikiDocument familyXDocument, XWikiDocument patientXDoc, String rightLevel) throws XWikiException { BaseObject permissionsObject = familyXDocument.newXObject(this.rightsClassReference, this.context); String[] rightHolders = this.familyPermissions.getEntitiesWithAccessAsString(patientXDoc, VIEW_RIGHT); permissionsObject.setStringValue("users", rightHolders[0]); permissionsObject.setStringValue("groups", rightHolders[1]); permissionsObject.setStringValue("levels", rightLevel); permissionsObject.setIntValue("allow", 1); }
/** * Set visibility object. */ private void setVisibilityObject(XWikiDocument familyXDocument, XWikiDocument patientXDoc) throws XWikiException { BaseObject visibilityObject = familyXDocument.newXObject(Visibility.CLASS_REFERENCE, this.context); visibilityObject.setStringValue(VISIBILITY_PROPERTY_NAME, this.getPropertyValue(patientXDoc, Visibility.CLASS_REFERENCE, VISIBILITY_PROPERTY_NAME, "")); }
private void setMembers(DocumentReference member, XWikiDocument doc, XWikiContext context) throws XWikiException { BaseObject memberObject = doc.newXObject(GROUP_CLASS_REFERENCE, context); memberObject.setStringValue("member", member.toString()); }
/** * Set owner object property. */ private void setOwner(XWikiDocument familyXDocument, XWikiDocument patientXDoc) throws XWikiException { BaseObject owner = familyXDocument.newXObject(Owner.CLASS_REFERENCE, this.context); owner.setStringValue(Owner.PROPERTY_NAME, this.getOwner(patientXDoc)); }
/** * Set visibility object. */ private void setVisibilityObject(XWikiDocument familyXDocument, XWikiDocument patientXDoc) throws XWikiException { BaseObject visibilityObject = familyXDocument.newXObject(Visibility.CLASS_REFERENCE, this.context); visibilityObject.setStringValue(VISIBILITY_PROPERTY_NAME, this.getPropertyValue(patientXDoc, Visibility.CLASS_REFERENCE, VISIBILITY_PROPERTY_NAME, "")); }
private void setMembers(DocumentReference member, XWikiDocument doc, XWikiContext context) throws XWikiException { BaseObject memberObject = doc.newXObject(GROUP_CLASS_REFERENCE, context); memberObject.setStringValue("member", member.toString()); }
/** * Set owner object property. */ private void setOwner(XWikiDocument familyXDocument, XWikiDocument patientXDoc) throws XWikiException { BaseObject owner = familyXDocument.newXObject(Owner.CLASS_REFERENCE, this.context); owner.setStringValue(Owner.PROPERTY_NAME, this.getOwner(patientXDoc)); }
@Override public void save(Patient patient, DocumentModelBridge doc) { BaseObject data = ((XWikiDocument) doc).getXObject(Patient.CLASS_REFERENCE); if (data == null) { throw new NullPointerException(ERROR_MESSAGE_NO_PATIENT_CLASS); } String gender = patient.<String>getData(DATA_NAME).getValue(); data.setStringValue(INTERNAL_PROPERTY_NAME, gender); }
@Override public void save(Patient patient, DocumentModelBridge doc) { BaseObject data = ((XWikiDocument) doc).getXObject(Patient.CLASS_REFERENCE); if (data == null) { throw new NullPointerException(ERROR_MESSAGE_NO_PATIENT_CLASS); } PatientData<String> lifeStatus = patient.getData(DATA_NAME); data.setStringValue(DATA_NAME, lifeStatus.getValue()); }
private void addMember(String member, XWikiDocument groupDocument, BaseClass groupClass, XWikiContext xcontext) throws WikiStreamException { BaseObject memberObject; try { memberObject = groupDocument.newXObject(groupClass.getReference(), xcontext); } catch (XWikiException e) { throw new WikiStreamException("Failed to add a group member object", e); } memberObject.setStringValue("member", member); }
/** * Set family object properties. */ private void setFamilyObject(XWikiDocument familyXDocument, XWikiDocument patientXDoc, long id) throws XWikiException { BaseObject familyObject = familyXDocument.newXObject(Family.CLASS_REFERENCE, this.context); familyObject.setLongValue("identifier", id); familyObject.setStringListValue("members", Arrays.asList(patientXDoc.getDocumentReference().getName())); familyObject.setStringValue("external_id", this.getPropertyValue(patientXDoc, Patient.CLASS_REFERENCE, "last_name", "")); familyObject.setIntValue("warning", 0); familyObject.setStringValue("warning_message", ""); }
/** * Set family object properties. */ private void setFamilyObject(XWikiDocument familyXDocument, XWikiDocument patientXDoc, long id) throws XWikiException { BaseObject familyObject = familyXDocument.newXObject(Family.CLASS_REFERENCE, this.context); familyObject.setLongValue("identifier", id); familyObject.setStringListValue("members", Arrays.asList(patientXDoc.getDocumentReference().getName())); familyObject.setStringValue("external_id", this.getPropertyValue(patientXDoc, Patient.CLASS_REFERENCE, "last_name", "")); familyObject.setIntValue("warning", 0); familyObject.setStringValue("warning_message", ""); }
@Override public void save(Patient patient, DocumentModelBridge doc) { BaseObject data = ((XWikiDocument) doc).getXObject(Patient.CLASS_REFERENCE); if (data == null) { throw new NullPointerException(ERROR_MESSAGE_NO_PATIENT_CLASS); } PatientData<String> identifiers = patient.<String>getData(DATA_NAME); if (!identifiers.isNamed()) { return; } String externalId = identifiers.get(EXTERNAL_IDENTIFIER_PROPERTY_NAME); data.setStringValue(EXTERNAL_IDENTIFIER_PROPERTY_NAME, externalId); }
private void setRights(DocumentReference editor, XWikiDocument doc, XWikiContext context) throws XWikiException { BaseObject rights = doc.newXObject(RIGHTS_CLASS_REFERENCE, context); rights.setIntValue("allow", 1); rights.setStringValue("levels", "edit"); rights.setLargeStringValue("groups", editor.toString()); } }
private void setRights(DocumentReference editor, XWikiDocument doc, XWikiContext context) throws XWikiException { BaseObject rights = doc.newXObject(RIGHTS_CLASS_REFERENCE, context); rights.setIntValue("allow", 1); rights.setStringValue("levels", "edit"); rights.setLargeStringValue("groups", editor.toString()); } }
@Override public void save(Patient patient, DocumentModelBridge doc) { BaseObject xwikiDataObject = ((XWikiDocument) doc).getXObject(Patient.CLASS_REFERENCE); if (xwikiDataObject == null) { throw new IllegalArgumentException(ERROR_MESSAGE_NO_PATIENT_CLASS); } PatientData<String> data = patient.<String>getData(this.getName()); if (!data.isNamed()) { return; } for (String property : this.getProperties()) { xwikiDataObject.setStringValue(property, data.get(property)); } }
private void saveStatus(String status, BaseObject object, XWikiContext context) throws XWikiException { XWikiDocument jobHolder = context.getWiki().getDocument(object.getName(), context); // We need to retrieve the object BaseObject the document again. Otherwise, modifications made to the // BaseObject passed as argument will not be saved (XWikiDocument#getObject clones the document // and returns the BaseObject from the clone) // TODO refactor the plugin in order to stop passing BaseObject around, passing document references instead. BaseObject job = jobHolder.getObject(XWIKI_JOB_CLASS); job.setStringValue("status", status); jobHolder.setMinorEdit(true); context.getWiki().saveDocument(jobHolder, context); }
private void saveStatus(String status, BaseObject object, XWikiContext context) throws XWikiException { XWikiDocument jobHolder = context.getWiki().getDocument(object.getDocumentReference(), context); // We need to retrieve the object BaseObject the document again. Otherwise, modifications made to the // BaseObject passed as argument will not be saved (XWikiDocument#getObject clones the document // and returns the BaseObject from the clone) // TODO refactor the plugin in order to stop passing BaseObject around, passing document references instead. BaseObject job = jobHolder.getXObject(XWIKI_JOB_CLASSREFERENCE); job.setStringValue("status", status); jobHolder.setMinorEdit(true); context.getWiki().saveDocument(jobHolder, context); }