/* Create Default SearchMarks */
String newsEntityName = INews.class.getName();
/* SearchCondition: New and Updated News */
{
ISearchMark mark = factory.createSearchMark(null, folder, "New and Updated News");
ISearchField field1 = factory.createSearchField(INews.STATE, newsEntityName);
factory.createSearchCondition(null, mark, field1, SearchSpecifier.IS, EnumSet.of(State.NEW));
}
/* SearchCondition: Recent News */
{
ISearchMark mark = factory.createSearchMark(null, folder, "Recent News");
ISearchField field1 = factory.createSearchField(INews.AGE_IN_DAYS, newsEntityName);
factory.createSearchCondition(null, mark, field1, SearchSpecifier.IS_LESS_THAN, 2);
}
/* SearchCondition: News with Attachments */
{
ISearchMark mark = factory.createSearchMark(null, folder, "News with Attachments");
ISearchField field = factory.createSearchField(INews.HAS_ATTACHMENTS, newsEntityName);
factory.createSearchCondition(null, mark, field, SearchSpecifier.IS, true);
}
/* SearchCondition: Sticky News */
{
ISearchMark mark = factory.createSearchMark(null, folder, "Sticky News");
ISearchField field = factory.createSearchField(INews.IS_FLAGGED, newsEntityName);
factory.createSearchCondition(null, mark, field, SearchSpecifier.IS, true);
}
/*
* Condition : +(State IS *new* OR State is *unread* OR State IS *updated*)
* AND +((Entire News contains "Foo") OR Author is "Benjamin Pasero")
*/
{
ISearchMark mark = factory.createSearchMark(null, folder, "Complex Search");
ISearchField field1 = factory.createSearchField(INews.STATE, newsEntityName);
ISearchCondition cond1 = factory.createSearchCondition(null, mark, field1, SearchSpecifier.IS, EnumSet.of(INews.State.NEW, State.UNREAD, State.UPDATED));
ISearchField field4 = factory.createSearchField(IEntity.ALL_FIELDS, newsEntityName);
ISearchCondition cond4 = factory.createSearchCondition(null, mark, field4, SearchSpecifier.CONTAINS, "Foo");
ISearchField field5 = factory.createSearchField(INews.AUTHOR, newsEntityName);
ISearchCondition cond5 = factory.createSearchCondition(null, mark, field5, SearchSpecifier.IS, "Benjamin Pasero");
}
/*
* Condition : +(State IS *new* OR State is *unread* OR State IS *updated*)
* AND (Entire News contains "Foo") AND (Author is "Benjamin Pasero")
*/
{
ISearchMark mark = factory.createSearchMark(null, folder, "Complex Search");
ISearchField field1 = factory.createSearchField(INews.STATE, newsEntityName);
ISearchCondition cond1 = factory.createSearchCondition(null, mark, field1, SearchSpecifier.IS, EnumSet.of(INews.State.NEW, State.UNREAD, State.UPDATED));
ISearchField field4 = factory.createSearchField(IEntity.ALL_FIELDS, newsEntityName);
ISearchCondition cond4 = factory.createSearchCondition(null, mark, field4, SearchSpecifier.CONTAINS, "Foo");
ISearchField field5 = factory.createSearchField(INews.AUTHOR, newsEntityName);
ISearchCondition cond5 = factory.createSearchCondition(null, mark, field5, SearchSpecifier.CONTAINS, "Benjamin Pasero");
}
/*
* Condition : (Entire News contains "Foo") AND (Title contains "Bar") AND
* (Author is not "Benjamin Pasero")
*/
{
ISearchMark mark = factory.createSearchMark(null, folder, "Complex Search");
ISearchField field1 = factory.createSearchField(IEntity.ALL_FIELDS, newsEntityName);
ISearchCondition cond1 = factory.createSearchCondition(null, mark, field1, SearchSpecifier.CONTAINS, "fafa");
ISearchField field2 = factory.createSearchField(INews.TITLE, newsEntityName);
ISearchCondition cond2 = factory.createSearchCondition(null, mark, field2, SearchSpecifier.CONTAINS, "Bar");
ISearchField field3 = factory.createSearchField(INews.AUTHOR, newsEntityName);
ISearchCondition cond3 = factory.createSearchCondition(null, mark, field3, SearchSpecifier.IS_NOT, "Benjamin Pasero");
}
/*
* Condition : +(State IS *new* OR State is *unread* OR State IS *updated*)
* AND (Category IS Windows) AND (Category IS Apple)
*/
{
ISearchMark mark = factory.createSearchMark(null, folder, "Complex Search");
ISearchField field1 = factory.createSearchField(INews.STATE, newsEntityName);
ISearchCondition cond1 = factory.createSearchCondition(null, mark, field1, SearchSpecifier.IS, EnumSet.of(INews.State.NEW, State.UNREAD, State.UPDATED));
ISearchField field4 = factory.createSearchField(INews.CATEGORIES, newsEntityName);
ISearchCondition cond4 = factory.createSearchCondition(null, mark, field4, SearchSpecifier.IS, "windows");
ISearchField field5 = factory.createSearchField(INews.CATEGORIES, newsEntityName);
ISearchCondition cond5 = factory.createSearchCondition(null, mark, field5, SearchSpecifier.IS, "apple");
}
/*
* Condition : +(State IS *new* OR State is *unread* OR State IS *updated*)
* AND (Category IS Windows) AND (Category IS Apple) AND (Category IS NOT
* Slashdot)
*/
{
ISearchMark mark = factory.createSearchMark(null, folder, "Complex Search");
ISearchField field1 = factory.createSearchField(INews.STATE, newsEntityName);
ISearchCondition cond1 = factory.createSearchCondition(null, mark, field1, SearchSpecifier.IS, EnumSet.of(INews.State.NEW, State.UNREAD, State.UPDATED));
ISearchField field4 = factory.createSearchField(INews.CATEGORIES, newsEntityName);
ISearchCondition cond4 = factory.createSearchCondition(null, mark, field4, SearchSpecifier.IS, "windows");
ISearchField field5 = factory.createSearchField(INews.CATEGORIES, newsEntityName);
ISearchCondition cond5 = factory.createSearchCondition(null, mark, field5, SearchSpecifier.IS, "apple");
ISearchField field6 = factory.createSearchField(INews.CATEGORIES, newsEntityName);
factory.createSearchCondition(null, mark, field6, SearchSpecifier.IS_NOT, "slashdot");
}
/*
* Condition : +(State IS *new* OR State is *unread* OR State IS *updated*)
* AND (Category IS NOT Windows)
*/
{
ISearchMark mark = factory.createSearchMark(null, folder, "Complex Search");
ISearchField field1 = factory.createSearchField(INews.STATE, newsEntityName);
ISearchCondition cond1 = factory.createSearchCondition(null, mark, field1, SearchSpecifier.IS, EnumSet.of(INews.State.NEW, State.UNREAD, State.UPDATED));
ISearchField field4 = factory.createSearchField(INews.CATEGORIES, newsEntityName);
ISearchCondition cond4 = factory.createSearchCondition(null, mark, field4, SearchSpecifier.IS_NOT, "windows");
}
/*
* Condition : +(State IS *new* OR State is *unread* OR State IS *updated*)
* AND (Age is Less than 5 Days)
*/
{
ISearchMark mark = factory.createSearchMark(null, folder, "Complex Search");
ISearchField field1 = factory.createSearchField(INews.STATE, newsEntityName);
ISearchCondition cond1 = factory.createSearchCondition(null, mark, field1, SearchSpecifier.IS, EnumSet.of(INews.State.NEW, State.UNREAD, State.UPDATED));
ISearchField field4 = factory.createSearchField(INews.AGE_IN_DAYS, newsEntityName);
ISearchCondition cond4 = factory.createSearchCondition(null, mark, field4, SearchSpecifier.IS_LESS_THAN, 5);
}
/*
* Condition 5: (State IS *new* OR State is *unread* OR State IS *updated*)
* AND All_Fields CONTAINS foo
*/
{
ISearchMark mark = factory.createSearchMark(null, folder, "Complex Search");
ISearchField field1 = factory.createSearchField(INews.STATE, newsEntityName);
ISearchCondition cond1 = factory.createSearchCondition(null, mark, field1, SearchSpecifier.IS, EnumSet.of(INews.State.NEW, State.UNREAD, State.UPDATED));
ISearchField field4 = factory.createSearchField(IEntity.ALL_FIELDS, newsEntityName);