Package org.rhq.core.domain.configuration.definition

Examples of org.rhq.core.domain.configuration.definition.PropertyDefinitionMap


            property = new PropertyList(propertyDefinition.getName());
            PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
            PropertyDefinition listMemberPropertyDefinition = propertyDefinitionList.getMemberDefinition();
            // If the property is a List of Maps, add 10 members to it, then recursively populate them.
            if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
                PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
                PropertyList propertyList = (PropertyList) property;
                for (int i = 0; i < 10; i++) {
                    PropertyMap memberProperty = generatePropertyMap(propertyDefinitionMap);
                    propertyList.add(memberProperty);
                }
View Full Code Here


                    Object result = attribute.refresh();

                    PropertyList propertyList = new PropertyList(propertyDefinition.getName());

                    if (result instanceof Map) {
                        PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) ((PropertyDefinitionList) propertyDefinition)
                            .getMemberDefinition();

                        String mapName = propertyDefinitionMap.getName();

                        Collection<PropertyDefinition> subPropertyDefinitions = propertyDefinitionMap
                            .getOrderedPropertyDefinitions();
                        Iterator<PropertyDefinition> iterator = subPropertyDefinitions.iterator();
                        String keyName = ((PropertyDefinitionSimple) iterator.next()).getName();
                        String valueName = ((PropertyDefinitionSimple) iterator.next()).getName();
View Full Code Here

                } else {
                    entry = preparePropertyList(propertyList, propertyDefinition);
                }
            } else if (prop instanceof PropertyMap) {
                PropertyMap propertyMap = (PropertyMap) prop;
                PropertyDefinitionMap propertyDefinition = this.configurationDefinition
                    .getPropertyDefinitionMap(propertyMap.getName());

                if (!propertyDefinition.isRequired() && propertyMap.getMap().size() == 0) {
                    isEntryEligible = false;
                } else {
                    entry = preparePropertyMap(propertyMap, propertyDefinition);
                    isEntryEligible = !((Map<String, Object>) entry.getValue()).isEmpty();
                }
View Full Code Here

        if (propDef instanceof PropertyDefinitionSimple) {
            PropertyDefinitionSimple propDefSimple = (PropertyDefinitionSimple) propDef;
            updateSimple(parentNode, propDefSimple, parentProp, seq);
        } else if (propDef instanceof PropertyDefinitionMap) {
            PropertyDefinitionMap propDefMap = (PropertyDefinitionMap) propDef;
            updateMap(propDefMap, parentProp, parentNode, seq);
        } else if (propDef instanceof PropertyDefinitionList) {
            PropertyDefinitionList propDefList = (PropertyDefinitionList) propDef;
            updateList(propDefList, parentProp, parentNode, seq);
        } else {
View Full Code Here

                "Config definition for the thing");
            definition.setConfigurationFormat(ConfigurationFormat.STRUCTURED);
            definition.put(new PropertyDefinitionSimple("SimpleProp", "My Simple Property", true,
                PropertySimpleType.STRING));

            definition.put(new PropertyDefinitionMap("MapProp", "Map Properties", true, new PropertyDefinitionSimple(
                "IntInMap", "Integer In Map", true, PropertySimpleType.INTEGER)));

            PropertyDefinitionSimple enumeratedString = new PropertyDefinitionSimple("ConnectionType", "My conn type",
                true, PropertySimpleType.STRING);
            enumeratedString.addEnumeratedValues(new PropertyDefinitionEnumeration("Local", "local"),
View Full Code Here

    public void testCreateDefaultNone() {
        // no defaults, no required props - returned config should be empty
        ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);

        PropertyDefinitionSimple simple = new PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
        PropertyDefinitionMap map = new PropertyDefinitionMap("map", null, false, simple);
        PropertyDefinitionList list = new PropertyDefinitionList("list", null, false, simple);

        configDef.put(simple);
        configDef.put(map);
        configDef.put(list);
View Full Code Here

        PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null, false, PropertySimpleType.STRING);
        PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
        b.setDefaultValue("!!bDefaultValue!!");
        c.setDefaultValue("!!cDefaultValue!!");

        PropertyDefinitionMap map1 = new PropertyDefinitionMap("map1", null, false, a, b, c);
        PropertyDefinitionMap mapRequired1 = new PropertyDefinitionMap("mapRequired1", null, true, a, b, c);
        PropertyDefinitionMap mapRequiredDefault1 = new PropertyDefinitionMap("mapRequiredDefault1", null, true, a, b,
            c);

        configDef.put(map1);
        configDef.put(mapRequired1);
        configDef.put(mapRequiredDefault1);

        Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
        assert config != null;
        assert config.getProperties().size() == 2; // map is not required with no default - its not in the config
        assert config.getMap(map1.getName()) == null;

        // the two required maps have the same definitions - a,b,c as above. since a isn't required with no default, its not there
        PropertyMap mapProp1 = config.getMap(mapRequired1.getName());
        assert mapProp1 != null;
        assert mapProp1.getSimple(a.getName()) == null;
        assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
        assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");

        mapProp1 = config.getMap(mapRequiredDefault1.getName());
        assert mapProp1 != null;
        assert mapProp1.getSimple(a.getName()) == null;
        assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
        assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");
    }
View Full Code Here

        PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null, false, PropertySimpleType.STRING);
        PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
        b.setDefaultValue("!!bDefaultValue!!");
        c.setDefaultValue("!!cDefaultValue!!");

        PropertyDefinitionMap map2 = new PropertyDefinitionMap("map2", null, false, a, b, c);
        PropertyDefinitionMap mapRequired2 = new PropertyDefinitionMap("mapRequired2", null, true, a, b, c);
        PropertyDefinitionMap mapRequiredDefault2 = new PropertyDefinitionMap("mapRequiredDefault2", null, true, a, b,
            c);

        PropertyDefinitionList listX = new PropertyDefinitionList("listX", null, true, map2);
        PropertyDefinitionList listY = new PropertyDefinitionList("listY", null, true, mapRequired2);
        PropertyDefinitionList listZ = new PropertyDefinitionList("listZ", null, true, mapRequiredDefault2);

        configDef.put(listX);
        configDef.put(listY);
        configDef.put(listZ);

        Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);

        assert config != null;
        assert config.getProperties().size() == 3;

        PropertyList listPropTest = config.getList(listX.getName());
        assert listPropTest != null;
        assert listPropTest.getList().isEmpty();

        listPropTest = config.getList(listY.getName());
        assert listPropTest != null;
        PropertyMap childMap2 = (PropertyMap) listPropTest.getList().get(0);

        listPropTest = config.getList(listZ.getName());
        assert listPropTest != null;
        PropertyMap childMap3 = (PropertyMap) listPropTest.getList().get(0);

        assert childMap2.getName().equals(mapRequired2.getName());
        assert childMap3.getName().equals(mapRequiredDefault2.getName());
    }
View Full Code Here

        PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null, false, PropertySimpleType.STRING);
        PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
        b.setDefaultValue("!!bDefaultValue!!");
        c.setDefaultValue("!!cDefaultValue!!");

        PropertyDefinitionMap map1 = new PropertyDefinitionMap("map1", null, false, a, b, c);
        PropertyDefinitionMap mapRequired1 = new PropertyDefinitionMap("mapRequired1", null, true, a, b, c);
        PropertyDefinitionMap mapRequiredDefault1 = new PropertyDefinitionMap("mapRequiredDefault1", null, true, a, b,
            c);

        configDef.put(map1);
        configDef.put(mapRequired1);
        configDef.put(mapRequiredDefault1);

        // SETUP LIST

        PropertyDefinitionList list1 = new PropertyDefinitionList("list1", null, false, a);
        PropertyDefinitionList listRequired1 = new PropertyDefinitionList("listRequired1", null, true, a);
        PropertyDefinitionList listRequiredDefault1 = new PropertyDefinitionList("listRequiredDefault1", null, true, c);

        configDef.put(list1);
        configDef.put(listRequired1);
        configDef.put(listRequiredDefault1);

        // SETUP LIST-O-MAPS

        PropertyDefinitionMap map2 = new PropertyDefinitionMap("map2", null, false, a, b, c);
        PropertyDefinitionMap mapRequired2 = new PropertyDefinitionMap("mapRequired2", null, true, a, b, c);
        PropertyDefinitionMap mapRequiredDefault2 = new PropertyDefinitionMap("mapRequiredDefault2", null, true, a, b,
            c);

        PropertyDefinitionList listX = new PropertyDefinitionList("listX", null, true, map2);
        PropertyDefinitionList listY = new PropertyDefinitionList("listY", null, true, mapRequired2);
        PropertyDefinitionList listZ = new PropertyDefinitionList("listZ", null, true, mapRequiredDefault2);

        configDef.put(listX);
        configDef.put(listY);
        configDef.put(listZ);

        // get the default config
        Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
        assert config != null;
        assert config.getProperties().size() == 10;

        // ASSERT SIMPLE

        assert config.getSimple(simple.getName()) == null;
        assert config.getSimpleValue(simpleRequired.getName(), null) == null;
        assert config.getSimpleValue(simpleDefault.getName(), null).equals("!!simpleDefaultValue!!");
        assert config.getSimpleValue(simpleRequiredDefault.getName(), null).equals("!!simpleRequiredDefaultValue!!");

        // ASSERT MAP

        assert config.getMap(map1.getName()) == null;

        // the two required maps have the same definitions - a,b,c as above. since a isn't required with no default, its not there
        PropertyMap mapProp1 = config.getMap(mapRequired1.getName());
        assert mapProp1 != null;
        assert mapProp1.getSimple(a.getName()) == null;
        assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
        assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");

        mapProp1 = config.getMap(mapRequiredDefault1.getName());
        assert mapProp1 != null;
        assert mapProp1.getSimple(a.getName()) == null;
        assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
        assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");

        // ASSERT LIST

        assert config.getList(list1.getName()) == null;

        PropertyList listProp1 = config.getList(listRequired1.getName());
        assert listProp1 != null;
        assert listProp1.getList().isEmpty(); // has "a" definition, which is not required and has no default

        listProp1 = config.getList(listRequiredDefault1.getName());
        assert listProp1 != null;
        assert listProp1.getList().get(0).getName().equals(c.getName());
        assert ((PropertySimple) listProp1.getList().get(0)).getStringValue().equals("!!cDefaultValue!!");

        // ASSERT LIST-O-MAPS

        PropertyList listPropTest = config.getList(listX.getName());
        assert listPropTest != null;
        assert listPropTest.getList().isEmpty();

        listPropTest = config.getList(listY.getName());
        assert listPropTest != null;
        PropertyMap childMap2 = (PropertyMap) listPropTest.getList().get(0);

        listPropTest = config.getList(listZ.getName());
        assert listPropTest != null;
        PropertyMap childMap3 = (PropertyMap) listPropTest.getList().get(0);

        assert childMap2.getName().equals(mapRequired2.getName());
        assert childMap3.getName().equals(mapRequiredDefault2.getName());
    }
View Full Code Here

        PropertyDefinitionSimple mapMember1 = new PropertyDefinitionSimple("mm1", null, true,
            PropertySimpleType.BOOLEAN);
        PropertyDefinitionSimple mapMember2 = new PropertyDefinitionSimple("mm2", null, false,
            PropertySimpleType.STRING);

        PropertyDefinitionMap map = new PropertyDefinitionMap("map-required", null, true, mapMember1, mapMember2);

        def.put(writableOptional);
        def.put(writableRequired);
        def.put(readonlyRequiredWithDefault);
        def.put(list);
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.configuration.definition.PropertyDefinitionMap

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.