Package org.rhq.core.domain.criteria

Examples of org.rhq.core.domain.criteria.MeasurementDataTraitCriteria


        processResponse(request.getRequestId(), response);
    }

    @Override
    protected MeasurementDataTraitCriteria getFetchCriteria(DSRequest request) {
        MeasurementDataTraitCriteria criteria = new MeasurementDataTraitCriteria();

        Criteria requestCriteria = request.getCriteria();
        if (requestCriteria != null) {
            Map values = requestCriteria.getValues();
            for (Object key : values.keySet()) {
                String fieldName = (String) key;
                if (fieldName.equals(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID)) {
                    Integer resourceId = (Integer) values.get(fieldName);
                    criteria.addFilterResourceId(resourceId);
                } else if (fieldName.equals(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID)) {
                    Integer groupId = (Integer) values.get(fieldName);
                    criteria.addFilterGroupId(groupId);
                } else if (fieldName.equals(MeasurementDataTraitCriteria.FILTER_FIELD_DEFINITION_ID)) {
                    Integer definitionId = (Integer) values.get(fieldName);
                    criteria.addFilterDefinitionId(definitionId);
                } else if (fieldName.equals(MeasurementDataTraitCriteria.FILTER_FIELD_MAX_TIMESTAMP)) {
                    criteria.addFilterMaxTimestamp();
                } else if (fieldName.equals(MeasurementDataTraitCriteria.FILTER_FIELD_ENABLED)) {
                    criteria.addFilterEnabled(true);
                }
            }
        }

        return criteria;
View Full Code Here


            }
            // add the trait data (it stores it in db (without name field))
            measurementDataManager.addTraitData(expectedResult);
           
            // get back the trait data by schedule id
            MeasurementDataTraitCriteria criteria = new MeasurementDataTraitCriteria();
            criteria.addFilterScheduleId(schedule1.getId());
            List<MeasurementDataTrait> actualResult = measurementDataManager.findTraitsByCriteria(overlord, criteria);
            Set<MeasurementData> actualResultSet = new HashSet<MeasurementData>(actualResult);
            assertEquals(expectedResult, actualResultSet);
           
            // get back the trait data by resource id
            criteria = new MeasurementDataTraitCriteria();
            criteria.addFilterResourceId(resource1.getId());
            actualResult = measurementDataManager.findTraitsByCriteria(overlord, criteria);
            actualResultSet = new HashSet<MeasurementData>(actualResult);
            assertEquals(expectedResult, actualResultSet);
           
            // get back the trait data by schedule id and resource id
            criteria = new MeasurementDataTraitCriteria();
            criteria.addFilterScheduleId(schedule1.getId());
            criteria.addFilterResourceId(resource1.getId());
            actualResult = measurementDataManager.findTraitsByCriteria(overlord, criteria);
            actualResultSet = new HashSet<MeasurementData>(actualResult);
            assertEquals(expectedResult, actualResultSet);
           
            // get back the trait data by wrong schedule id
            criteria = new MeasurementDataTraitCriteria();
            criteria.addFilterScheduleId(Integer.MIN_VALUE);
            actualResult = measurementDataManager.findTraitsByCriteria(overlord, criteria);
            assertTrue(actualResult.isEmpty());
        } catch (Exception e) {
            e.printStackTrace();
            fail();
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.criteria.MeasurementDataTraitCriteria

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.