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

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


    private void addMemberPropertyDefinitionsToDynamicPropertyMap(PropertyDefinitionMap propertyDefinitionMap,
        PropertyMap propertyMap) {
        for (String propertyName : propertyMap.getMap().keySet()) {
            PropertySimple memberPropertySimple = propertyMap.getSimple(propertyName);
            if (memberPropertySimple != null) {
                PropertyDefinitionSimple memberPropertyDefinitionSimple = new PropertyDefinitionSimple(propertyName,
                    null, false, PropertySimpleType.STRING);
                propertyDefinitionMap.put(memberPropertyDefinitionSimple);
            }
        }
    }
View Full Code Here


        return errorLabel;
    }

    private ListGridField createListGridField(PropertyDefinition summaryPropDef) {
        ListGridField field = new ListGridField(summaryPropDef.getName(), summaryPropDef.getDisplayName(), 90);
        PropertyDefinitionSimple defSimple = (PropertyDefinitionSimple) summaryPropDef;
        PropertySimpleType propSimpleType = defSimple.getType();
        switch (propSimpleType) {
        case BOOLEAN:
            field.setType(ListGridFieldType.BOOLEAN);
            break;
        case INTEGER:
View Full Code Here

                        HTMLFlow description = new HTMLFlow(propertyDefinitionList.getDescription());
                        vLayout.addMember(description);

                        final DynamicForm form = new DynamicForm();

                        PropertyDefinitionSimple memberPropertyDefinitionSimple = (PropertyDefinitionSimple) propertyDefinitionList
                            .getMemberDefinition();
                        final String propertyName = memberPropertyDefinitionSimple.getName();
                        final PropertySimple newMemberPropertySimple = new PropertySimple(propertyName, null);

                        FormItem simpleField = buildSimpleField(memberPropertyDefinitionSimple, newMemberPropertySimple);
                        simpleField.setTitle(memberPropertyDefinitionSimple.getDisplayName());
                        simpleField.setShowTitle(true);
                        simpleField.setAlign(Alignment.CENTER);
                        simpleField.setDisabled(false);
                        simpleField.setRequired(true);
                        simpleField.setEndRow(true);
View Full Code Here

    }

    private void mergePropertyMap(PropertyMap sourceMap, PropertyMap targetMap,
        List<PropertyDefinition> memberDefinitions) {
        for (PropertyDefinition subDef : memberDefinitions) {
            PropertyDefinitionSimple subDefSimple = (PropertyDefinitionSimple) subDef;
            PropertySimple propertySimple = ((PropertySimple) sourceMap.get(subDefSimple.getName()));
            String newValue = (propertySimple != null) ? propertySimple.getStringValue() : null;
            PropertySimple existingProp = targetMap.getSimple(subDefSimple.getName());
            if (null == existingProp) {
                if (null != newValue) {
                    existingProp = new PropertySimple(subDefSimple.getName(), newValue);
                    targetMap.put(existingProp);
                }
            } else {
                existingProp.setStringValue(newValue);
            }
View Full Code Here

            assert cpdl.size() == 3 : "Did not find 3 properties in <resource-configuration> in v1 but " + cpdl.size();
            for (PropertyDefinition pd : cpdl) {
                if (pd.getName().equals("jnpPort")) {
                    assert pd instanceof PropertyDefinitionSimple : "jnpPort is no simple-property in v1";
                    PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pd;

                    List<PropertyDefinitionEnumeration> pdel = pds.getEnumeratedValues();
                    assert pdel.size() == 3 : "jnpPort did not have 3 options in v1, but " + pdel.size();
                    int found = 0;
                    for (PropertyDefinitionEnumeration pde : pdel) {
                        if (containedIn(pde.getName(), new String[] { "option1", "option2", "option3" })) {
                            found++;
                        }
                    }

                    assert found == 3 : "Did not find the three expected options in v1";
                } else if (pd.getName().equals("secureJnpPort")) {
                    assert pd instanceof PropertyDefinitionSimple : "secureJnpPort is no simple-property in v1";
                    PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pd;
                    assert pds.getType() == PropertySimpleType.INTEGER : "Type of secureJnpPort is not integer in v1";
                    Set<Constraint> constraints = pds.getConstraints();
                    assert constraints.size() == 4 : "Did not find 4 constraints for secureJnpPort in v1, but "
                        + constraints.size();
                }
            }
            getTransactionManager().rollback();

            /*
             * Now check the changed plugin
             */
            registerPlugin("update5-v2_0.xml", "2");
            ResourceType platform2 = getResourceType("myPlatform5");
            getTransactionManager().begin();
            em = getEntityManager();
            platform2 = em.find(ResourceType.class, platform2.getId());

            Set<ResourceType> servers2 = platform2.getChildResourceTypes();
            assert servers2.size() == 1 : "Expected to find 1 server in v2, but got " + servers2.size();
            ResourceType server2 = servers2.iterator().next();
            ConfigurationDefinition def2 = server2.getResourceConfigurationDefinition();
            def2 = getEntityManager().find(ConfigurationDefinition.class, def2.getId());
            List<PropertyDefinition> cpdl2 = def2.getNonGroupedProperties();
            assert cpdl2.size() == 3 : "Did not find 3 properties in <resource-configuration> in v2 but "
                + cpdl2.size();
            int found = 0;
            for (PropertyDefinition pd : cpdl2) {
                if (containedIn(pd.getName(), new String[] { "jnpPort", "secureJnpPort", "memorySize" })) {
                    found++;
                }
            }

            assert found == 3 : "Did not find the 3 specific properties in v2";
            for (PropertyDefinition pd : cpdl2) {
                if (pd.getName().equals("jnpPort")) {
                    if (pd instanceof PropertyDefinitionSimple) {
                        PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pd;

                        List<PropertyDefinitionEnumeration> pdel = pds.getEnumeratedValues();

                        /*
                         * TODO there is a strange effect where pdel has also "null" elements in it, that were not
                         * present at the time the new enumeration has been computed in the ResourceMetadataManager.
                         * That is why I am here first removing the nulls and then do the assertion
                         */
                        for (int i = pdel.size() - 1; i >= 0; i--) {
                            if (pdel.get(i) == null) {
                                pdel.remove(i);
                            }
                        }

                        assert pdel.size() == 4 : "jnpPort did not have 4 options in v2, but " + pdel.size();
                        found = 0;
                        for (PropertyDefinitionEnumeration pde : pdel) {
                            if (containedIn(pde.getName(), new String[] { "option2", "option3", "newOption4",
                                "newOption5" })) {
                                found++;
                            }

                            if (pde.getName().equals("option3")) {
                                assert pde.getValue().equals("changed") : "Value for option 'option3' did not change in v2";
                            }
                        }

                        assert found == 4 : "Did not find the four expected options in v2 ";
                    }
                } else if (pd.getName().equals("secureJnpPort")) {
                    assert pd instanceof PropertyDefinitionSimple : "secureJnpPort is no simple-property in v2";
                    PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pd;
                    Set<Constraint> constraints = pds.getConstraints();
                    assert constraints.size() == 3 : "Did not find 3 constraints for secureJnpPort in v2, but "
                        + constraints.size();
                }
            }
            getTransactionManager().rollback();

            /*
             * And now back to the first version
             */

            registerPlugin("update5-v1_0.xml", "3");
            platform1 = getResourceType("myPlatform5");
            getTransactionManager().begin();
            em = getEntityManager();
            platform1 = em.find(ResourceType.class, platform1.getId());

            servers = platform1.getChildResourceTypes();
            assert servers.size() == 1 : "Expected to find 1 server in v1, but got " + servers.size();
            ResourceType server3 = servers.iterator().next();
            ConfigurationDefinition def3 = server3.getResourceConfigurationDefinition();
            List<PropertyDefinition> cpdl3 = def3.getNonGroupedProperties();

            assert cpdl3.size() == 3 : "Did not find 3 properties in <resource-configuration> in v3 again but "
                + cpdl3.size();
            for (PropertyDefinition pd : cpdl3) {
                if (pd.getName().equals("jnpPort")) {
                    if (pd instanceof PropertyDefinitionSimple) {
                        PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pd;

                        List<PropertyDefinitionEnumeration> pdel = pds.getEnumeratedValues();

                        /*
                         * TODO there is a strange effect where pdel has also "null" elements in it, that were not
                         * present at the time the new enumeration has been computed in the ResourceMetadataManager.
                         * That is why I am here first removing the nulls and then do the assertion
View Full Code Here

            ResourceType platform = getResourceType("constraintPlatform");
            getTransactionManager().begin();
            platform = em.find(ResourceType.class, platform.getId());

            ConfigurationDefinition config = platform.getResourceConfigurationDefinition();
            PropertyDefinitionSimple propDef = config.getPropertyDefinitionSimple("secureJnpPort");
            Set<Constraint> constraints = propDef.getConstraints();
            assert constraints.size() == 4 : "Expected to get 4 constraints, but got " + constraints.size();

            assert propDef.getDefaultValue().equals("1234");
            getTransactionManager().rollback();

        } finally {
            if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
                getTransactionManager().rollback();
View Full Code Here

            getTransactionManager().begin();
            platform = em.find(ResourceType.class, platform.getId());

            ConfigurationDefinition config = platform.getResourceConfigurationDefinition();
            Map<String, PropertyDefinition> propDefMap = config.getPropertyDefinitions();
            PropertyDefinitionSimple propDef = (PropertyDefinitionSimple) propDefMap.get("secureJnpPort");
            Set<Constraint> constraints = propDef.getConstraints();
            assert constraints.size() == 4 : "Expected to get 4 constraints, but got " + constraints.size();

            assert propDef.getDefaultValue().equals("1234");
            getTransactionManager().rollback();

        } finally {
            if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
                getTransactionManager().rollback();
View Full Code Here

            ResourceType platform = getResourceType("constraintPlatform");
            getTransactionManager().begin();
            platform = em.find(ResourceType.class, platform.getId());

            ConfigurationDefinition config = platform.getResourceConfigurationDefinition();
            PropertyDefinitionSimple propDef = config.getPropertyDefinitionSimple("secureJnpPort");
            Set<Constraint> constraints = propDef.getConstraints();
            assert constraints.size() == 2 : "Expected to get 2 constraints, but got " + constraints.size();
            for (Constraint co : constraints) {
                if (co instanceof IntegerRangeConstraint) {
                    IntegerRangeConstraint irc = (IntegerRangeConstraint) co;
                    assert irc.getMinimum() == 5; // TODO change when JBNADM-1597 is being worked on
View Full Code Here

                PropertyDefinition member = pdl.getMemberDefinition();

                if (pdl.getName().equals("myList1")) {
                    assert pdl.getDescription().equals("Just a simple list");
                    assert member instanceof PropertyDefinitionSimple : "Expected the member of myList1 to be a simple property in v1";
                    PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
                    assert pds.getName().equals("foo");
                } else if (pdl.getName().equals("myList2")) {
                    assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v1";
                } else if (pdl.getName().equals("myList3")) {
                    assert member instanceof PropertyDefinitionSimple : "Expected the member of myList3 to be a simple property in v1";
                    PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
                    assert pds.getName().equals("baz");
                } else if (pdl.getName().equals("rec1")) {
                    assert member instanceof PropertyDefinitionList : "Expected the member of rc1 to be a list property in v1";
                    PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;

                    // TODO check min/max for the lists on the way. Commented out. See JBNADM-1595
                    assert pdl2.getName().equals("rec2");

                    //                  assert pdl2.getMin()==2 : "Expected rec2:min to be 2, but it was " + pdl2.getMin();
                    //                  assert pdl2.getMax()==20;
                    pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
                    assert pdl2.getName().equals("rec3");

                    //                  assert pdl2.getMin()==3;
                    //                  assert pdl2.getMax()==30;
                    pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
                    assert pdl2.getName().equals("rec4");

                    //                  assert pdl2.getMin()==4;
                    //                  assert pdl2.getMax()==40;
                    assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
                    PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
                    assert pds.getName().equals("rec5");
                    assert pds.getDescription().equals("Deeply nested");
                    List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
                    assert options.size() == 4;
                    int found = 0;
                    String[] optionVals = new String[] { "a", "b", "c", "d" };
                    for (PropertyDefinitionEnumeration option : options) {
                        if (containedIn(option.getValue(), optionVals)) {
                            found++;
                        }
                    }

                    assert found == 4;
                    Set<Constraint> constraints = pds.getConstraints();
                    assert constraints.size() == 1;
                } else {
                    assert true == false : "Unknown list-definition in v1: " + pdl.getName();
                }
            }
            getTransactionManager().rollback();

            /*
             * Deploy v2 of the plugin
             */
            registerPlugin("propertyList-v2.xml");
            platform = getResourceType("myPlatform6");
            getTransactionManager().begin();
            em = getEntityManager();
            platform = em.find(ResourceType.class, platform.getId());

            cd = platform.getResourceConfigurationDefinition();
            propDefs = cd.getPropertyDefinitions();
            assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v2, but got " + propDefs.size();
            for (PropertyDefinition def : propDefs.values()) {
                assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
                    + " is no list-property in v2";
                PropertyDefinitionList pdl = (PropertyDefinitionList) def;
                PropertyDefinition member = pdl.getMemberDefinition();

                if (pdl.getName().equals("myList2")) {
                    assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v2";
                } else if (pdl.getName().equals("myList3")) {
                    assert member instanceof PropertyDefinitionList : "Expected the member of myList3 to be a list property in v2";
                    PropertyDefinitionList pds = (PropertyDefinitionList) member;
                    assert pds.getName().equals("baz");
                    assert pds.getDescription().equals("myList3:baz");
                    assert pds.getMemberDefinition() instanceof PropertyDefinitionSimple : "Expected the member of list3:baz to be a simple property in v2";
                } else if (pdl.getName().equals("myList4")) {
                    assert pdl.getDescription().equals("Just a simple list");
                    assert member instanceof PropertyDefinitionSimple : "Expected the member of myList4 to be a simple property in v2";
                    PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
                    assert pds.getName().equals("foo");
                } else if (pdl.getName().equals("rec1")) {
                    assert member instanceof PropertyDefinitionList : "Expected the member of rec1 to be a list property in v2";
                    PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
                    assert pdl2.getName().equals("rec2");

                    /*
                     * PropertyDefinitionList.getMin()/getMax() are commented out. See JBNADM1595
                     */

                    //                assert pdl2.getMin()==12 : "Expected rec2:min to be 12, but it was " + pdl2.getMin();
                    //                assert pdl2.getMax()==200;
                    pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
                    assert pdl2.getName().equals("rec3+");

                    //                assert pdl2.getMin()==13;
                    //                assert pdl2.getMax()==300;
                    pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
                    assert pdl2.getName().equals("rec4");

                    //                assert pdl2.getMin()==14;
                    //                assert pdl2.getMax()==400;
                    assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
                    PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
                    assert pds.getName().equals("rec5");
                    assert pds.getDescription().equals("Nested deeply");
                    List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
                    assert options.size() == 5;
                    int found = 0;
                    String[] optionVals = new String[] { "b", "c", "d", "x", "z" };
                    for (PropertyDefinitionEnumeration option : options) {
                        if (containedIn(option.getValue(), optionVals)) {
                            found++;
                        }
                    }

                    assert found == optionVals.length;
                    Set<Constraint> constraints = pds.getConstraints();
                    assert constraints.size() == 2;
                    for (Constraint constraint : constraints) {
                        if (constraint instanceof IntegerRangeConstraint) {
                            IntegerRangeConstraint irc = (IntegerRangeConstraint) constraint;
                            assert irc != null : "Integer-constraint was null, but should not be";
View Full Code Here

                        assert map != null : "Child map4:2 not found";
                        children = map.getMap();
                        map = (PropertyDefinitionMap) children.get("map4:2:3");
                        assert map != null : "Child map4:2:3 not found";
                        children = map.getMap();
                        PropertyDefinitionSimple simple = (PropertyDefinitionSimple) children.get("simple");
                        assert simple != null : "Child simple not found";
                    }

                    if (def.getName().equals("map5")) {
                        PropertyDefinitionMap map = (PropertyDefinitionMap) def;
                        Map<String, PropertyDefinition> children = map.getMap();
                        assert children.size() == 1 : "Map4 should have 1 child";
                        children = map.getMap();
                        PropertyDefinitionSimple simple = (PropertyDefinitionSimple) children.get("hugo");
                        assert simple.getDescription().equals("foo");
                    }
                }

                assert found == 5 : "Did not find the 5 desired maps in v1";

                getTransactionManager().rollback();
            }

            System.out.println("Done with v1");

            /*
             * Now deploy v2
             */
            { // extra block for variable scoping purposes
                registerPlugin("propertyMap-v2.xml");
                ResourceType platform = getResourceType("myPlatform7");
                getTransactionManager().begin();
                platform = em.find(ResourceType.class, platform.getId());

                ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
                Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
                assert propDefs.size() == 5 : "Expected to find 5 properties in v2, but got " + propDefs.size();

                int found = 0;
                for (PropertyDefinition def : propDefs.values()) {
                    if (containedIn(def.getName(), new String[] { "map1", "map2", "map3", "map4", "map5" })) {
                        found++;
                    }

                    if (def.getName().equals("map1")) {
                        assert def instanceof PropertyDefinitionSimple : "Map 1 should be a simple-property in v2";
                    } else {
                        assert def instanceof PropertyDefinitionMap : "Not all properties are maps in v2";
                    }

                    if (def.getName().equals("map3")) {
                        assert def.isRequired() == false : "Map 3 should not be false in v2";
                    }

                    if (def.getName().equals("map4")) {
                        PropertyDefinitionMap map = (PropertyDefinitionMap) def;
                        Map<String, PropertyDefinition> children = map.getMap();
                        assert children.size() == 1 : "Map4 should have 1 child, but has " + children.size();
                        children = map.getMap();
                        map = (PropertyDefinitionMap) children.get("map4:2+");
                        assert map != null : "Child map4:2 not found";
                        children = map.getMap();
                        assert children.size() == 1 : "Map4:2 should have 1 child, but has " + children.size();
                        map = (PropertyDefinitionMap) children.get("map4:2:3");
                        assert map != null : "Child map4:2:3 not found";
                        children = map.getMap();
                        assert children.size() == 2 : "Map4:2:3 should have 1 child, but has " + children.size();
                        PropertyDefinitionList list = (PropertyDefinitionList) children.get("list");
                        assert list != null : "Child list not found";
                        PropertyDefinitionSimple simple = (PropertyDefinitionSimple) children.get("simple2");
                        assert simple != null : "Child simple2 not found";
                    }

                    if (def.getName().equals("map5")) {
                        PropertyDefinitionMap map = (PropertyDefinitionMap) def;
                        Map<String, PropertyDefinition> children = map.getMap();
                        assert children.size() == 1 : "Map5 should have 1 child";
                        children = map.getMap();
                        PropertyDefinitionSimple simple = (PropertyDefinitionSimple) children.get("hugo");
                        assert simple.getDescription().equals("bar") : "Map5:hugo should have 'bar' in v2";
                    }
                }

                assert found == 5 : "Did not find the 5 desired properties in v2, instead found " + found;

View Full Code Here

TOP

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

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.