Search in sources :

Example 1 with PrimitiveSearchCondition

use of org.apache.cxf.jaxrs.ext.search.PrimitiveSearchCondition in project opennms by OpenNMS.

the class CriteriaBuilderSearchVisitorIT method testScanReportAndCondition.

@Test
public void testScanReportAndCondition() {
    CriteriaBuilder builder = new ScanReportRestService().getCriteriaBuilder();
    CriteriaBuilderSearchVisitor<ScanReport> visitor = new CriteriaBuilderSearchVisitor<ScanReport>(builder, ScanReport.class);
    // Simulates /opennms/api/v2/scanreports?_s=applications%3D%3DLocal+Access;timestamp%3Dle%3D2016-02-01T15:07:14.340-0500&limit=20&offset=0&order=desc&orderBy=timestamp
    List<SearchCondition<ScanReport>> conditions = new ArrayList<SearchCondition<ScanReport>>();
    conditions.add(new PrimitiveSearchCondition<ScanReport>("applications", "blah", String.class, ConditionType.EQUALS, new ScanReport()));
    conditions.add(new PrimitiveSearchCondition<ScanReport>("timestamp", new Date(), Date.class, ConditionType.LESS_OR_EQUALS, new ScanReport()));
    SearchCondition<ScanReport> andCondition = new AndSearchCondition<ScanReport>(conditions);
    visitor.visit(andCondition);
    Criteria criteria = visitor.getQuery().toCriteria();
    System.out.println(criteria.toString());
    m_dao.countMatching(criteria);
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) ScanReport(org.opennms.netmgt.model.ScanReport) ArrayList(java.util.ArrayList) Criteria(org.opennms.core.criteria.Criteria) Date(java.util.Date) ScanReportRestService(org.opennms.web.rest.v2.ScanReportRestService) AndSearchCondition(org.apache.cxf.jaxrs.ext.search.AndSearchCondition) PrimitiveSearchCondition(org.apache.cxf.jaxrs.ext.search.PrimitiveSearchCondition) SearchCondition(org.apache.cxf.jaxrs.ext.search.SearchCondition) AndSearchCondition(org.apache.cxf.jaxrs.ext.search.AndSearchCondition) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 AndSearchCondition (org.apache.cxf.jaxrs.ext.search.AndSearchCondition)1 PrimitiveSearchCondition (org.apache.cxf.jaxrs.ext.search.PrimitiveSearchCondition)1 SearchCondition (org.apache.cxf.jaxrs.ext.search.SearchCondition)1 Test (org.junit.Test)1 Criteria (org.opennms.core.criteria.Criteria)1 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)1 ScanReport (org.opennms.netmgt.model.ScanReport)1 ScanReportRestService (org.opennms.web.rest.v2.ScanReportRestService)1