org.xwiki.observation.ObservationManager.notify()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(95)

本文整理了Java中org.xwiki.observation.ObservationManager.notify()方法的一些代码示例,展示了ObservationManager.notify()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObservationManager.notify()方法的具体详情如下:
包路径:org.xwiki.observation.ObservationManager
类名称:ObservationManager
方法名:notify

ObservationManager.notify介绍

[英]Convenience front-end where the additional data parameter is null.
[中]方便的前端,附加数据参数为null

代码示例

代码示例来源:origin: org.xwiki.commons/xwiki-commons-component-default

/**
 * Send the event.
 *
 * @param event the event to send
 * @param descriptor the event related component descriptor.
 * @param componentManager the event related component manager instance.
 */
private void sendEvent(Event event, ComponentDescriptor<?> descriptor, ComponentManager componentManager)
{
  if (this.observationManager != null) {
    this.observationManager.notify(event, componentManager, descriptor);
  }
}

代码示例来源:origin: org.phenotips/patient-access-rules-api

public void fireRightsUpdateEvent(String patientId)
  {
    this.observationManager.notify(new PatientRightsUpdatedEvent(patientId), null);
  }
}

代码示例来源:origin: phenotips/phenotips

@Override
  public void fireRightsUpdateEvent(@Nonnull final String entityId)
  {
    this.observationManager.notify(new EntityRightsUpdatedEvent(entityId), null);
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-wiki-default

@Override
public void delete(String wikiId) throws WikiManagerException
{
  // Delete the wiki
  wikiDeleter.delete(wikiId);
  // Send an event
  observationManager.notify(new WikiDeletedEvent(wikiId), wikiId);
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-wiki-default

@Override
public WikiDescriptor copy(String fromWikiId, String newWikiId, String newWikiAlias, boolean copyHistory,
    boolean copyRecycleBin, boolean failOnExist) throws WikiManagerException
{
  WikiDescriptor newWiki = create(newWikiId, newWikiAlias, failOnExist);
  wikiCopier.copyDocuments(fromWikiId, newWikiId, copyHistory);
  if (copyRecycleBin) {
    wikiCopier.copyDeletedDocuments(fromWikiId, newWikiId);
  }
  observationManager.notify(new WikiCopiedEvent(fromWikiId, newWikiId), fromWikiId, xcontextProvider.get());
  return newWiki;
}

代码示例来源:origin: org.phenotips/patient-data-default-impl

@Override
  public void onEvent(Event event, Object source, Object data)
  {
    XWikiDocument doc = (XWikiDocument) source;

    BaseObject patientRecordObj = doc.getXObject(Patient.CLASS_REFERENCE);
    if (patientRecordObj == null || "PatientTemplate".equals(doc.getDocumentReference().getName())) {
      return;
    }
    Patient patient = this.repo.load(doc);
    User user = this.userManager.getCurrentUser();
    this.observationManager.notify(new PatientCreatedEvent(patient, user), source);
    this.observationManager.notify(new PatientChangedEvent(patient, user), source);
  }
}

代码示例来源:origin: phenotips/phenotips

@Override
  public void onEvent(Event event, Object source, Object data)
  {
    XWikiDocument doc = (XWikiDocument) source;

    BaseObject patientRecordObj = doc.getXObject(Patient.CLASS_REFERENCE);
    if (patientRecordObj == null || "PatientTemplate".equals(doc.getDocumentReference().getName())) {
      return;
    }
    Patient patient = this.repo.load(doc);
    User user = this.userManager.getCurrentUser();
    this.observationManager.notify(new PatientCreatedEvent(patient, user), source);
    this.observationManager.notify(new PatientChangedEvent(patient, user), source);
  }
}

代码示例来源:origin: jvelo/mayocat-shop

public void addEntityToList(EntityList list, UUID entity) throws EntityDoesNotExistException
{
  EntityList originalList;
  originalList = getStoredEntityList(list);
  if (originalList == null) {
    this.dao.commit();
    throw new EntityDoesNotExistException();
  }
  getObservationManager().notify(new EntityUpdatingEvent(), originalList);
  this.dao.addEntityToList(list.getId(), entity);
  getObservationManager().notify(new EntityUpdatedEvent(), originalList);
}

代码示例来源:origin: jvelo/mayocat-shop

public void removeEntityFromList(EntityList list, UUID entity) throws EntityDoesNotExistException
{
  EntityList originalList;
  originalList = getStoredEntityList(list);
  if (originalList == null) {
    this.dao.commit();
    throw new EntityDoesNotExistException();
  }
  getObservationManager().notify(new EntityUpdatingEvent(), originalList);
  this.dao.removeEntityFromList(list.getId(), entity);
  getObservationManager().notify(new EntityUpdatedEvent(), originalList);
}

代码示例来源:origin: org.phenotips/patient-data-default-impl

@Override
  public void onEvent(Event event, Object source, Object data)
  {
    XWikiDocument doc = (XWikiDocument) source;

    BaseObject patientRecordObj = doc.getXObject(Patient.CLASS_REFERENCE);
    if (patientRecordObj == null || "PatientTemplate".equals(doc.getDocumentReference().getName())) {
      return;
    }
    Patient patient = this.repo.load(doc);
    User user = this.userManager.getCurrentUser();
    this.observationManager.notify(new PatientChangedEvent(patient, user), source);
    // FIXME Send a diff as the notification data
  }
}

代码示例来源:origin: phenotips/phenotips

@Override
  public void onEvent(Event event, Object source, Object data)
  {
    XWikiDocument doc = (XWikiDocument) source;

    BaseObject patientRecordObj = doc.getXObject(Patient.CLASS_REFERENCE);
    if (patientRecordObj == null || "PatientTemplate".equals(doc.getDocumentReference().getName())) {
      return;
    }
    Patient patient = this.repo.load(doc);
    User user = this.userManager.getCurrentUser();
    this.observationManager.notify(new PatientChangedEvent(patient, user), source);
    // FIXME Send a diff as the notification data
  }
}

代码示例来源:origin: org.xwiki.commons/xwiki-commons-filter-api

@Override
  protected void jobFinished(Throwable error)
  {
    try {
      super.jobFinished(error);
    } finally {
      this.observationManager.notify(new FilterConversionFinished(getRequest().getId(), getType(), this.request),
        this);
    }
  }
}

代码示例来源:origin: org.xwiki.commons/xwiki-commons-filter-api

@Override
protected void jobStarting()
{
  this.observationManager.notify(new FilterConversionStarted(getRequest().getId(), getType(), this.request),
    this);
  super.jobStarting();
}

代码示例来源:origin: jvelo/mayocat-shop

public void update(@Valid HomePage entity) throws EntityDoesNotExistException, InvalidEntityException
{
  this.dao.begin();
  HomePage homePage = find();
  if (homePage == null) {
    this.dao.commit();
    throw new EntityDoesNotExistException();
  }
  getObservationManager().notify(new EntityUpdatingEvent(), entity);
  entity.setId(homePage.getId());
  this.dao.createOrUpdateAddons(entity);
  this.dao.commit();
  getObservationManager().notify(new EntityUpdatedEvent(), entity);
}

代码示例来源:origin: jvelo/mayocat-shop

public HomePage getOrCreate(HomePage homePage) throws InvalidEntityException
{
  HomePage original;
  this.dao.begin();
  original = this.find();
  if (original != null) {
    this.dao.commit();
    return original;
  }
  getObservationManager().notify(new EntityCreatingEvent(), homePage);
  UUID entityId = UUID.randomUUID();
  homePage.setId(entityId);
  this.dao.createEntityIfItDoesNotExist(homePage, HOME_PAGE_TYPE, getTenant());
  this.dao.commit();
  getObservationManager().notify(new EntityCreatedEvent(), homePage);
  return this.find();
}

代码示例来源:origin: org.phenotips/patient-data-default-impl

@Override
  public void onEvent(Event event, Object source, Object data)
  {
    XWikiDocument doc = (XWikiDocument) source;

    BaseObject patientRecordObj = doc.getXObject(Patient.CLASS_REFERENCE);
    if (patientRecordObj == null || "PatientTemplate".equals(doc.getDocumentReference().getName())) {
      return;
    }
    Patient patient = this.repo.load(doc);
    User user = this.userManager.getCurrentUser();
    CancelableEvent patientEvent = new PatientChangingEvent(patient, user);
    this.observationManager.notify(patientEvent, doc);
    if (patientEvent.isCanceled()) {
      // FIXME DocumentUpdatingEvent is not cancelable yet!
      // ((CancelableEvent) event).cancel();
    }
  }
}

代码示例来源:origin: jvelo/mayocat-shop

public void update(@Valid EntityList list) throws EntityDoesNotExistException, InvalidEntityException
{
  EntityList originalList;
  this.dao.begin();
  originalList = getStoredEntityList(list);
  if (originalList == null) {
    this.dao.commit();
    throw new EntityDoesNotExistException();
  }
  getObservationManager().notify(new EntityUpdatingEvent(), list);
  list.setId(originalList.getId());
  Integer updatedRows = this.dao.updateEntityList(list);
  this.dao.commit();
  if (updatedRows <= 0) {
    throw new StoreException("No rows was updated when updating list");
  }
  getObservationManager().notify(new EntityUpdatedEvent(), list);
}

代码示例来源:origin: phenotips/phenotips

@Override
  public void onEvent(Event event, Object source, Object data)
  {
    XWikiDocument doc = (XWikiDocument) source;
    if (doc == null || doc.getOriginalDocument() == null) {
      return;
    }
    XWikiDocument odoc = doc.getOriginalDocument();

    BaseObject patientRecordObj = odoc.getXObject(Patient.CLASS_REFERENCE);
    if (patientRecordObj == null || "PatientTemplate".equals(doc.getDocumentReference().getName())) {
      return;
    }
    Patient patient = this.repo.load(odoc);
    User user = this.userManager.getCurrentUser();
    this.observationManager.notify(new PatientDeletedEvent(patient, user), odoc);
  }
}

代码示例来源:origin: org.phenotips/patient-data-default-impl

@Override
  public void onEvent(Event event, Object source, Object data)
  {
    XWikiDocument doc = (XWikiDocument) source;
    if (doc == null || doc.getOriginalDocument() == null) {
      return;
    }
    XWikiDocument odoc = doc.getOriginalDocument();

    BaseObject patientRecordObj = odoc.getXObject(Patient.CLASS_REFERENCE);
    if (patientRecordObj == null || "PatientTemplate".equals(doc.getDocumentReference().getName())) {
      return;
    }
    Patient patient = this.repo.load(odoc);
    User user = this.userManager.getCurrentUser();
    this.observationManager.notify(new PatientDeletedEvent(patient, user), odoc);
  }
}

代码示例来源:origin: jvelo/mayocat-shop

public void updateStock(UUID productId, Integer stockOffset) throws EntityDoesNotExistException
{
  this.dao.begin();
  Product product = this.findById(productId);
  if (product == null) {
    this.dao.commit();
    throw new EntityDoesNotExistException();
  }
  product.setStock((product.getStock() == null ? 0 : product.getStock()) + stockOffset);
  Integer updatedRows = this.dao.updateProduct(product);
  this.dao.commit();
  if (updatedRows <= 0) {
    throw new StoreException("No rows was updated when updating product");
  }
  getObservationManager().notify(new EntityUpdatedEvent(), product);
}

相关文章