String newsName = INews.class.getName();
/* 1) State IS new */
{
ISearchField field = fFactory.createSearchField(INews.STATE, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, EnumSet.of(State.NEW));
fSearchmark = fFactory.createSearchMark(null, parent, "Search");
fSearchmark.addSearchCondition(condition);
addProperties(Owl.getPreferenceService().getEntityScope(fSearchmark));
}
/* 2) State IS new, unread, updated */
{
ISearchField field = fFactory.createSearchField(INews.STATE, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, EnumSet.of(State.NEW, State.UNREAD, State.UPDATED));
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
searchmark.addSearchCondition(condition);
}
/* 3) Entire News CONTAINS foo?bar */
{
ISearchField field = fFactory.createSearchField(IEntity.ALL_FIELDS, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS, "foo?bar");
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
searchmark.addSearchCondition(condition);
}
/* 4) Age in Days is > 5 */
{
ISearchField field = fFactory.createSearchField(INews.AGE_IN_DAYS, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS_GREATER_THAN, 5);
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
searchmark.addSearchCondition(condition);
}
/* 5) Publish Date is 26.12.1981 */
{
Calendar cal = DateUtils.getToday();
cal.set(Calendar.YEAR, 1981);
cal.set(Calendar.MONTH, Calendar.DECEMBER);
cal.set(Calendar.DATE, 26);
ISearchField field = fFactory.createSearchField(INews.PUBLISH_DATE, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, cal.getTime());
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
searchmark.addSearchCondition(condition);
}
/* 6) Feed Links is not http://www.rssowl.org/node/feed */
{
ISearchField field = fFactory.createSearchField(INews.FEED, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS_NOT, "http://www.rssowl.org/node/feed");
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
searchmark.addSearchCondition(condition);
}
/* 7) Has Attachments is TRUE */
{
ISearchField field = fFactory.createSearchField(INews.HAS_ATTACHMENTS, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, true);
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
searchmark.addSearchCondition(condition);
}
/*
* 8) Entire News CONTAINS foo?bar AND State ISnew AND Has Attachments is
* TRUE
*/
{
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
ISearchField field = fFactory.createSearchField(IEntity.ALL_FIELDS, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS, "foo?bar");
searchmark.addSearchCondition(condition);
field = fFactory.createSearchField(INews.HAS_ATTACHMENTS, newsName);
condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, true);
searchmark.addSearchCondition(condition);
field = fFactory.createSearchField(INews.STATE, newsName);
condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, EnumSet.of(State.NEW));
searchmark.addSearchCondition(condition);
searchmark.setMatchAllConditions(true);
}
/* 9) Location is Default Set */
{
ISearchField field = fFactory.createSearchField(INews.LOCATION, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { fDefaultSet })));
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
searchmark.addSearchCondition(condition);
}
/* 10) Location is Default Set OR Location is Custom Set */
{
ISearchField field = fFactory.createSearchField(INews.LOCATION, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { fDefaultSet, fCustomSet })));
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
searchmark.addSearchCondition(condition);
}
/* 11) Location is Folder 1 */
{
ISearchField field = fFactory.createSearchField(INews.LOCATION, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { fDefaultFolder1 })));
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
searchmark.addSearchCondition(condition);
}
/* 12) Location is BookMark 1 */
{
ISearchField field = fFactory.createSearchField(INews.LOCATION, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { fBookMark1 })));
fSearchmarkWithLocation = fFactory.createSearchMark(null, parent, "Search");
fSearchmarkWithLocation.addSearchCondition(condition);
}
/*
* 13) Location is Default Set OR Location is Custom Set OR Location is
* BookMark1
*/
{
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
ISearchField field = fFactory.createSearchField(INews.LOCATION, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { fDefaultSet })));
searchmark.addSearchCondition(condition);
condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { fCustomSet })));
searchmark.addSearchCondition(condition);
condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { fBookMark1 })));
searchmark.addSearchCondition(condition);
}
/* 14) Location is Bin 1 */
{
ISearchField field = fFactory.createSearchField(INews.LOCATION, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { fNewsBin })));
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
searchmark.addSearchCondition(condition);
}
/* 15) Entire News CONTAINS_ALL foo?bar */
{
ISearchField field = fFactory.createSearchField(IEntity.ALL_FIELDS, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, "foo?bar");
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
searchmark.addSearchCondition(condition);
}
/* 16) Entire News CONTAINS_NOT foo?bar */
{
ISearchField field = fFactory.createSearchField(IEntity.ALL_FIELDS, newsName);
ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS_NOT, "foo?bar");
ISearchMark searchmark = fFactory.createSearchMark(null, parent, "Search");
searchmark.addSearchCondition(condition);
}
}