use of org.opennms.netmgt.dao.DatabasePopulator.DaoSupport in project opennms by OpenNMS.
the class FilterFavoriteServiceIT method setUp.
@Before
public void setUp() {
populator.addExtension(new DatabasePopulator.Extension<FilterFavoriteDao>() {
@Override
public DaoSupport<FilterFavoriteDao> getDaoSupport() {
return new DaoSupport<FilterFavoriteDao>(FilterFavoriteDao.class, service.getFilterFavoriteDao());
}
@Override
public void onPopulate(DatabasePopulator populator, FilterFavoriteDao dao) {
dao.save(createFavorite("mvr", "First Favorite 1", "filter=severity%3D6&filter=node%3D2", OnmsFilterFavorite.Page.EVENT));
dao.save(createFavorite("mvr", "First Favorite 2", "filter=severity%3D6&filter=node%3D2", OnmsFilterFavorite.Page.EVENT));
dao.save(createFavorite("mvr", "First Favorite 3", "filter=severity%3D6&filter=node%3D2", OnmsFilterFavorite.Page.EVENT));
dao.save(createFavorite("mvr", "First Favorite 1", "filter=severity%3D6&filter=node%3D2", OnmsFilterFavorite.Page.ALARM));
dao.save(createFavorite("mvr", "First Favorite 2", "filter=severity%3D6&filter=node%3D2", OnmsFilterFavorite.Page.ALARM));
dao.save(createFavorite("mvr", "First Favorite 3", "filter=severity%3D6&filter=node%3D2", OnmsFilterFavorite.Page.ALARM));
}
@Override
public void onShutdown(DatabasePopulator populator, FilterFavoriteDao dao) {
for (OnmsFilterFavorite eachFavorite : dao.findAll()) {
dao.delete(eachFavorite);
}
}
private OnmsFilterFavorite createFavorite(String user, String filterName, String filterCriteria, Page page) {
OnmsFilterFavorite favorite = new OnmsFilterFavorite();
favorite.setName(filterName);
favorite.setFilter(filterCriteria);
favorite.setPage(page);
favorite.setUsername(user);
return favorite;
}
});
populator.populateDatabase();
}
Aggregations