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

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


        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


        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 listMember = new PropertyDefinitionSimple("list-member", null, true,
            PropertySimpleType.STRING);
        listMember.setDefaultValue("list-member-definition");
        listMember.setReadOnly(true);

        PropertyDefinitionList list = new PropertyDefinitionList("list-optional", null, false,
            listMember);

        PropertyDefinitionSimple mapMember1 = new PropertyDefinitionSimple("mm1", null, true,
            PropertySimpleType.BOOLEAN);
        PropertyDefinitionSimple mapMember2 = new PropertyDefinitionSimple("mm2", null, false,
View Full Code Here

        assert noMaxRangeFound : "serverProperty32 loaded without no maximum range constraint";
        assert noMinRangeFound : "serverProperty32 loaded without no minimum range constraint";
        assert bothRangeFound : "serverProperty32 loaded without both ranges constraint";

        PropertyDefinitionList list;

        list = definition.getPropertyDefinitionList("serverProperty40");
        assert list != null : "serverProperty40 was not loaded";
        assert "serverProperty40".equals(list.getName());
        assert list.getMemberDefinition() == null : "serverProperty40 incorrectly loaded with member definition";

        list = definition.getPropertyDefinitionList("serverProperty41");
        assert list != null : "serverProperty41 was not loaded";
        assert list.getMemberDefinition() != null : "serverProperty41 member definition was not loaded";
        simple = (PropertyDefinitionSimple) list.getMemberDefinition();
        assert simple.getType() == PropertySimpleType.INTEGER : "serverProperty41 members type is incorrect";

        list = definition.getPropertyDefinitionList("serverProperty42");
        assert list != null : "serverProperty42 was not loaded";
        assert "List Description".equals(list.getDescription()) : "serverProperty42 description is incorrect";
        assert "List Property".equals(list.getDisplayName()) : "serverProperty42 display name is incorrect";

        list = definition.getPropertyDefinitionList("serverProperty43");
        assert list != null : "serverProperty43 was not loaded";
        assert "External Description".equals(list.getDescription()) : "serverProperty43 description is incorrect";
        assert "Server Property 43".equals(list.getDisplayName()) : "serverProperty43 display name is incorrect";

        list = definition.getPropertyDefinitionList("serverProperty44");
        assert list != null : "serverProperty44 was not loaded";
        assert "Internal Description".equals(list.getDescription()) : "serverProperty44 description loaded from external instead of internal";

        PropertyDefinitionMap map;
        Map<String, PropertyDefinition> nestedProperties;

        map = definition.getPropertyDefinitionMap("serverProperty50");
View Full Code Here

                if (!mapNode.getAttributeAsBoolean(ATTRIB_ALL_SAME)) {
                    parent.setAttribute(ATTRIB_ALL_SAME, false);
                }
                children.add(mapNode);
            } else if (definition instanceof PropertyDefinitionList) {
                PropertyDefinitionList defList = (PropertyDefinitionList) definition;
                TreeNode listNode = new TreeNode(defList.getDisplayName());
                listNode.setAttribute(ATTRIB_ALL_SAME, true);
                if (defList.getMemberDefinition() instanceof PropertyDefinitionMap) { // support list-o-maps only
                    PropertyDefinition memberDef = defList.getMemberDefinition();
                    Collection<PropertyDefinition> memberDefColl = new ArrayList<PropertyDefinition>(1);
                    memberDefColl.add(memberDef);

                    int max = 0; // will be the largest size of any of our lists that are being compared
                    for (AbstractPropertyMap map : maps) {
                        try {
                            int size = map.getList(defList.getName()).getList().size();
                            if (size > max) {
                                max = size;
                            }
                        } catch (Throwable t) {
                            // paranoia - just skip so we don't kill entire compare window if our config doesn't have proper list-o-map
                        }
                    }
                    ArrayList<TreeNode> innerChildren = new ArrayList<TreeNode>();
                    for (int i = 0; i < max; i++) {
                        TreeNode listItemNode = new TreeNode(String.valueOf(i));
                        ArrayList<PropertyMap> properties = new ArrayList<PropertyMap>();
                        for (AbstractPropertyMap map : maps) {
                            try {
                                List<Property> list = map.getList(defList.getName()).getList();
                                if (list.size() < (i + 1)) {
                                    properties.add(new PropertyMap()); // this list didn't have an i-th item, just use an empty map
                                } else {
                                    properties.add((PropertyMap) list.get(i));
                                }
View Full Code Here

        assert def.getPropertyDefinitionSimple("foxtrotdouble").getType() == PropertySimpleType.DOUBLE;
        assert def.getPropertyDefinitionSimple("golf").getType() == PropertySimpleType.DIRECTORY;
        assert def.getPropertyDefinitionSimple("hotel").getType() == PropertySimpleType.FILE;
        assert def.getPropertyDefinitionSimple("india").getType() == PropertySimpleType.LONG_STRING;

        PropertyDefinitionList juliet = def.getPropertyDefinitionList("juliet");
        assert juliet.getMin() == 3;
        assert juliet.getMax() == 4;
        PropertyDefinitionSimple foo = (PropertyDefinitionSimple) juliet.getMemberDefinition();
        assert foo != null;
        assert foo.getName().equals("foo");
        assert foo.getType() == PropertySimpleType.STRING;

        // This is an arbitrary entry map
View Full Code Here

                } else {
                    config.put(new PropertySimple(property.getName(), value));
                }
            } else if (p instanceof PropertyDefinitionList) {
                // This very hackish bit of code is to suport the list-of-maps standard with a single simple definition in the map
                PropertyDefinitionList listDef = ((PropertyDefinitionList) p);
                PropertyDefinitionMap mapDef = ((PropertyDefinitionMap) listDef.getMemberDefinition());
                PropertyDefinitionSimple simpleDef = (PropertyDefinitionSimple) mapDef.getPropertyDefinitions().get(0);
                String name = simpleDef.getName();

                List<String> allValues = new ArrayList<String>();

                List<String> tests = augeas.match(sshdPath + "*");
                for (String test : tests) {
                    if (test.matches(sshdPath + name + ".*")) {
                        String data = augeas.get(test);
                        allValues.addAll(Arrays.asList(data.split(" ")));
                    }
                }
                PropertyList list = new PropertyList(listDef.getName());
                for (String value : allValues) {
                    PropertyMap map = new PropertyMap(mapDef.getName(), new PropertySimple(simpleDef.getName(), value));
                    list.add(map);
                }
            }
View Full Code Here

            } else if (propDef instanceof PropertyDefinitionMap) {
                PropertyDefinitionMap propDefMap = (PropertyDefinitionMap) propDef;
                PropertyMap propMap = parentPropMap.getMap(propDefMap.getName());
                setNodeFromPropertyMap(propDefMap, propMap, augeas, node);
            } else if (propDef instanceof PropertyDefinitionList) {
                PropertyDefinitionList propDefList = (PropertyDefinitionList) propDef;
                PropertyList propList = parentPropMap.getList(propDefList.getName());
                setNodeFromPropertyList(propDefList, propList, augeas, node);
            } else {
                throw new IllegalStateException("Unsupported PropertyDefinition subclass: "
                    + propDef.getClass().getName());
            }
View Full Code Here

        //Add a few properties that we will be testing/exercising
        definition.put(new PropertyDefinitionSimple("access-log", "Access-Log", false, PropertySimpleType.STRING));
        definition.put(new PropertyDefinitionSimple("rewrite", "Rewrite", false, PropertySimpleType.BOOLEAN));
        definition.put(new PropertyDefinitionSimple("notThere", "NotThere", false, PropertySimpleType.STRING));

        definition.put(new PropertyDefinitionList("alias", "Alias", true, new PropertyDefinitionSimple("alias",
            "alias", true, PropertySimpleType.STRING)));

        //Construct the result string that we would expect back.
        String resultString = " {\"outcome\" : \"success\", \"result\" : {\"alias\" : [\"example.com\",\"example2.com\"],"
            + " \"access-log\" : \"my.log\", \"rewrite\" : true}}";
View Full Code Here

            File crontabFile = new File(crontabPath);
            String basePath = AUGEAS_FILES_PREFIX + crontabFile.getAbsolutePath();
            AugeasNode baseNode = new AugeasNode(basePath);

            PropertyList entries = crontabConfiguration.getList(CronTabComponent.ENTRIES_PROP);
            PropertyDefinitionList entriesDef = crontabConfigurationDefinition
                .getPropertyDefinitionList(CronTabComponent.ENTRIES_PROP);
            setNodeFromPropertyList(entriesDef, entries, augeas, baseNode);

            PropertyList settings = crontabConfiguration.getList(CronTabComponent.ENVIRONMENT_SETTINGS_PROP);
            if (settings != null) {
View Full Code Here

TOP

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

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.