use of com.xpn.xwiki.objects.BaseObjectReference in project xwiki-platform by xwiki.
the class NotificationEmailJob method getSchedulerJobDocument.
private DocumentReference getSchedulerJobDocument(JobExecutionContext jobContext) {
JobDataMap data = jobContext.getJobDetail().getJobDataMap();
BaseObject schedulerJobObject = (BaseObject) data.get("xjob");
BaseObjectReference schedulerJobObjectReference = schedulerJobObject.getReference();
return (DocumentReference) schedulerJobObjectReference.getParent();
}
use of com.xpn.xwiki.objects.BaseObjectReference in project xwiki-platform by xwiki.
the class BaseObjectOutputFilterStream method beginWikiObject.
@Override
public void beginWikiObject(String name, FilterEventParameters parameters) throws FilterException {
super.beginWikiObject(name, parameters);
if (this.enabled) {
if (this.entity == null) {
this.entity = new BaseObject();
}
if (parameters.containsKey(WikiObjectFilter.PARAMETER_NAME)) {
this.entity.setDocumentReference(getDocumentReference(WikiObjectFilter.PARAMETER_NAME, parameters, null));
}
int number = getInt(WikiObjectFilter.PARAMETER_NUMBER, parameters, -1);
EntityReference classReference = getEntityReference(WikiObjectFilter.PARAMETER_CLASS_REFERENCE, parameters, null);
if (classReference == null) {
BaseObjectReference reference = new BaseObjectReference(this.currentEntityReference);
classReference = reference.getXClassReference();
if (number < 0 && reference.getObjectNumber() != null) {
number = reference.getObjectNumber();
}
}
this.entity.setXClassReference(classReference);
// Get the class in the current instance
XWikiContext xcontext = this.xcontextProvider.get();
if (xcontext != null && xcontext.getWiki() != null) {
try {
setCurrentXClass(xcontext.getWiki().getXClass(this.entity.getXClassReference(), xcontext));
} catch (XWikiException e) {
// TODO: log something ?
}
}
this.entity.setNumber(number);
this.entity.setGuid(getString(WikiObjectFilter.PARAMETER_GUID, parameters, null));
getBaseClassOutputFilterStream().enable();
getBasePropertyOutputFilterStream().enable();
}
}
use of com.xpn.xwiki.objects.BaseObjectReference in project xwiki-platform by xwiki.
the class ObjectSolrMetadataExtractor method setFieldsInternal.
@Override
public boolean setFieldsInternal(LengthSolrInputDocument solrDocument, EntityReference entityReference) throws Exception {
BaseObjectReference objectReference = new BaseObjectReference(entityReference);
DocumentReference classReference = objectReference.getXClassReference();
DocumentReference documentReference = new DocumentReference(objectReference.getParent());
XWikiDocument originalDocument = getDocument(documentReference);
BaseObject object = originalDocument.getXObject(objectReference);
if (object == null) {
return false;
}
solrDocument.setField(FieldUtils.ID, resolver.getId(object.getReference()));
setDocumentFields(documentReference, solrDocument);
solrDocument.setField(FieldUtils.TYPE, objectReference.getType().name());
solrDocument.setField(FieldUtils.CLASS, localSerializer.serialize(classReference));
solrDocument.setField(FieldUtils.NUMBER, objectReference.getObjectNumber());
setLocaleAndContentFields(documentReference, solrDocument, object);
return true;
}
use of com.xpn.xwiki.objects.BaseObjectReference in project xwiki-platform by xwiki.
the class ObjectSolrReferenceResolver method getQuery.
@Override
public String getQuery(EntityReference reference) throws SolrIndexerException {
BaseObjectReference objectReference = new BaseObjectReference(reference);
StringBuilder builder = new StringBuilder();
EntityReference documentReference = reference.extractReference(EntityType.DOCUMENT);
builder.append(this.documentResolverProvider.get().getQuery(documentReference));
builder.append(QUERY_AND);
builder.append(FieldUtils.CLASS);
builder.append(':');
builder.append(ClientUtils.escapeQueryChars(this.localSerializer.serialize(objectReference.getXClassReference())));
builder.append(QUERY_AND);
builder.append(FieldUtils.NUMBER);
builder.append(':');
builder.append(ClientUtils.escapeQueryChars(String.valueOf(objectReference.getObjectNumber())));
return builder.toString();
}
use of com.xpn.xwiki.objects.BaseObjectReference in project xwiki-platform by xwiki.
the class NotificationEmailJob method executeJob.
@Override
protected void executeJob(JobExecutionContext jobContext) throws JobExecutionException {
NotificationConfiguration configuration = Utils.getComponent(NotificationConfiguration.class);
if (!configuration.isEnabled() || !configuration.areEmailsEnabled()) {
// do nothing
return;
}
DocumentReference schedulerJobDocument = getSchedulerJobDocument(jobContext);
BaseObjectReference emailJobObjectReference = getNotificationEmailJobObjectReference(schedulerJobDocument);
NotificationUserIterator userIterator = Utils.getComponent(NotificationUserIterator.class);
userIterator.initialize(getJobInterval(schedulerJobDocument));
NotificationEmailSender mailSender = Utils.getComponent(NotificationEmailSender.class);
mailSender.sendEmails(getPreviousFireTime(emailJobObjectReference), userIterator);
setPreviousFireTime(emailJobObjectReference);
}
Aggregations