/** * return the ID of the document. this ID is unique across the wiki. * * @return the id of the document. */ public long getId() { return this.doc.getId(); }
public long getDocId() { return this.doc.getId(); }
/** * {@inheritDoc} * * @see com.xpn.xwiki.doc.XWikiDocument#getId() */ @Override public long getId() { return getDocument().getId(); }
@SuppressWarnings(ANOTATE_UNCHECKED) public List<DeletedAttachment> doInHibernate(Session session) throws HibernateException, XWikiException { assert doc != null; return session.createCriteria(DeletedAttachment.class).add(Restrictions.eq(DOC_ID, doc.getId())) .addOrder(Order.desc(DATE)).list(); } });
public Object doInHibernate(Session session) throws HibernateException, XWikiException { session.createQuery("delete from " + XWikiRCSNodeInfo.class.getName() + " where id.docId=?").setLong(0, doc.getId()).executeUpdate(); return null; } });
/** * Removes a family reference from a patient. * * @param patientDoc to set the family reference * @return true if successful */ private boolean removeFamilyReference(XWikiDocument patientDoc) { try { BaseObject pointer = patientDoc.getXObject(Family.REFERENCE_CLASS_REFERENCE); if (pointer != null) { return patientDoc.removeXObject(pointer); } return true; } catch (Exception ex) { this.logger.error("Could not remove patient [{}] from family. Error removing family reference: []", patientDoc.getId(), ex); return false; } }
/** * Removes a family reference from a patient. * * @param patientDoc to set the family reference * @return true if successful */ private boolean removeFamilyReference(XWikiDocument patientDoc) { try { BaseObject pointer = patientDoc.getXObject(Family.REFERENCE_CLASS_REFERENCE); if (pointer != null) { return patientDoc.removeXObject(pointer); } return true; } catch (Exception ex) { this.logger.error("Could not remove patient [{}] from family. Error removing family reference: []", patientDoc.getId(), ex); return false; } }
/** * get the rights object for a family A document can have several rights objects. * * @return XWiki {@link BaseObject} that corresponds to the default rights */ private BaseObject getOrCreateRightsObject(XWikiDocument familyDoc, String rightsLevel, XWikiContext context) { List<BaseObject> rights = familyDoc.getXObjects(RIGHTS_CLASS); for (BaseObject right : rights) { String level = right.getStringValue(RIGHTS_LEVELS_FIELD); if (StringUtils.equalsIgnoreCase(level, rightsLevel)) { return right; } } // rights object not found - create one try { BaseObject newRightObject = familyDoc.newXObject(RIGHTS_CLASS, context); return newRightObject; } catch (Exception ex) { this.logger.error("Can not create rights object for family {}", familyDoc.getId()); } return null; } }
public void setDocumentArchive(String sarch) throws XWikiException { XWikiDocumentArchive xda = new XWikiDocumentArchive(getId()); xda.setArchive(sarch); setDocumentArchive(xda); }
public void setLock(String userName, XWikiContext context) throws XWikiException { XWikiLock lock = new XWikiLock(getId(), userName); getStore(context).saveLock(lock, context, true); }
public XWikiLock getLock(XWikiContext context) throws XWikiException { XWikiLock theLock = getStore(context).loadLock(getId(), context, true); if (theLock != null) { int timeout = context.getWiki().getXWikiPreferenceAsInt("lock_Timeout", 30 * 60, context); if (theLock.getDate().getTime() + timeout * 1000 < new Date().getTime()) { getStore(context).deleteLock(theLock, context, true); theLock = null; } } return theLock; }
if (pedigreeXObject == null || pedigreeXObject.get("data") == null) { this.migrator.logger.debug("Patient does not have pedigree. Patient Id: {}.", patientXDocument.getId()); return null; this.migrator.logger.debug( "Patient does not have pedigree data or pedigree image properties. Patient Id: {}.", patientXDocument.getId()); return null; this.migrator.familyMigrations.processPedigree(new JSONObject(dataText), patientId); this.migrator.logger.debug("Creating new family for patient {}.", patientXDocument.getId()); return this.migrator.familyMigrations.createFamilyDocument(patientXDocument, procesedData, imageText, this.context, this.session);
private boolean savePatientDocument(XWikiDocument patientDocument, String documentHistoryComment, XWikiContext context) { try { patientDocument.setAuthorReference(context.getUserReference()); context.getWiki().saveDocument(patientDocument, documentHistoryComment, context); } catch (XWikiException e) { this.logger.error("Error saving patient [{}] document for commit {}: [{}]", patientDocument.getId(), documentHistoryComment, e.getMessage()); return false; } return true; }
/** * Sets the reference to the family document in the patient document. * * @param patientDoc to set the family reference * @param familyDoc family of the patient * @param context context * @return true if no problems, false in case of any error/sexception */ private boolean setFamilyReference(XWikiDocument patientDoc, XWikiDocument familyDoc, XWikiContext context) { try { BaseObject pointer = patientDoc.getXObject(Family.REFERENCE_CLASS_REFERENCE, true, context); pointer.set(FAMILY_REFERENCE_FIELD, familyDoc.getDocumentReference().toString(), context); return true; } catch (Exception ex) { this.logger.error("Could not add patient [{}] to family. Error setting family reference: []", patientDoc.getId(), ex); return false; } }
/** * Sets the reference to the family document in the patient document. * * @param patientDoc to set the family reference * @param familyDoc family of the patient * @param context context * @return true if no problems, false in case of any error/sexception */ private boolean setFamilyReference(XWikiDocument patientDoc, XWikiDocument familyDoc, XWikiContext context) { try { BaseObject pointer = patientDoc.getXObject(Family.REFERENCE_CLASS_REFERENCE, true, context); pointer.set(FAMILY_REFERENCE_FIELD, familyDoc.getDocumentReference().toString(), context); return true; } catch (Exception ex) { this.logger.error("Could not add patient [{}] to family. Error setting family reference: []", patientDoc.getId(), ex); return false; } }
private boolean savePatientDocument(XWikiDocument patientDocument, String documentHistoryComment, XWikiContext context) { try { patientDocument.setAuthorReference(context.getUserReference()); context.getWiki().saveDocument(patientDocument, documentHistoryComment, context); } catch (XWikiException e) { this.logger.error("Error saving patient [{}] document for commit {}: [{}]", patientDocument.getId(), documentHistoryComment, e.getMessage()); return false; } return true; }
public void removeLock(XWikiContext context) throws XWikiException { XWikiLock lock = getStore(context).loadLock(getId(), context, true); if (lock != null) { getStore(context).deleteLock(lock, context, true); } }
links = new LinkedHashSet<XWikiLink>(getStore(context).loadLinks(getId(), context, true)); } else { Set<String> linkedPages = getUniqueLinkedPages(context); XWikiLink wikiLink = new XWikiLink(); wikiLink.setDocId(getId()); wikiLink.setFullName(this.localEntityReferenceSerializer.serialize(getDocumentReference())); wikiLink.setLink(linkedPage);
/** * @since 2.2M1 */ public XWikiDocument copyDocument(DocumentReference newDocumentReference, XWikiContext context) throws XWikiException { loadAttachments(context); loadArchive(context); XWikiDocument newdoc = duplicate(newDocumentReference); newdoc.setOriginalDocument(null); newdoc.setContentDirty(true); newdoc.getXClass().setDocumentReference(newDocumentReference); XWikiDocumentArchive archive = newdoc.getDocumentArchive(); if (archive != null) { newdoc.setDocumentArchive(archive.clone(newdoc.getId(), context)); } return newdoc; }
link.setDocId(doc.getId()); link.setFullName(doc.getFullName()); link.setLink(reference);