try {
/* Add */
FolderReference folderRef = new FolderReference(fDao.saveFolder(fFactory.createFolder(null, null, "Folder")).getId());
SearchMarkReference searchMarkRef = new SearchMarkReference(fDao.saveSearchMark(fFactory.createSearchMark(null, folderRef.resolve(), "SearchMark")).getId());
ISearchField field = fFactory.createSearchField(IExtendableType.ALL_FIELDS, INews.class);
ISearchCondition searchCondition = fFactory.createSearchCondition(null, searchMarkRef.resolve(), field, SearchSpecifier.CONTAINS, "Foo", true);
final boolean searchConditionEvents[] = new boolean[3];
final SearchConditionReference searchConditionReference[] = new SearchConditionReference[1];
searchConditionListener = new SearchConditionListener() {
public void searchConditionAdded(Set<SearchConditionEvent> events) {
for (SearchConditionEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
searchConditionEvents[0] = true;
}
}
public void searchConditionDeleted(Set<SearchConditionEvent> events) {
for (SearchConditionEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
if (searchConditionReference[0].references(event.getEntity()))
searchConditionEvents[1] = true;
}
}
public void searchConditionUpdated(Set<SearchConditionEvent> events) {
for (SearchConditionEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
if (searchConditionReference[0].references(event.getEntity()))
searchConditionEvents[2] = true;
}
}
};
fModel.addSearchConditionListener(searchConditionListener);
searchConditionReference[0] = new SearchConditionReference(fDao.saveSearchCondition(searchCondition).getId());
/* Update */
searchCondition = searchConditionReference[0].resolve();
searchCondition.setValue("Bar");
searchCondition.setSpecifier(SearchSpecifier.CONTAINS_NOT);
fDao.saveSearchCondition(searchCondition);
/* Delete */
fDao.deleteSearchCondition(searchConditionReference[0]);