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

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


            fieldsForThisProperty = buildFieldsForPropertySimple(propertyDefinition, propertyDefinitionSimple,
                propertySimple);
        } else if (propertyDefinition instanceof PropertyDefinitionList) {
            ///@TODO
            PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
            PropertyDefinition memberDefinition = propertyDefinitionList.getMemberDefinition();
            PropertyList propertyList = (PropertyList) property;
            if (propertyList == null) {
                propertyList = new PropertyList(propertyDefinitionList.getName());
                configuration.put(propertyList);
            }
View Full Code Here


        descriptionItem.setEndRow(true);
        return descriptionItem;
    }

    protected void firePropertyChangedEvent(Property property, PropertyDefinition propertyDefinition, boolean isValid) {
        PropertyDefinition topLevelPropertyDefinition = getTopLevelPropertyDefinition(propertyDefinition);
        boolean invalidPropertySetChanged;
        if (isValid) {
            invalidPropertySetChanged = (this.invalidPropertyNameToDisplayNameMap.remove(topLevelPropertyDefinition
                .getName()) != null);
        } else {
            invalidPropertySetChanged = (this.invalidPropertyNameToDisplayNameMap.put(
                topLevelPropertyDefinition.getName(), topLevelPropertyDefinition.getDisplayName()) == null);
        }

        PropertyValueChangeEvent event = new PropertyValueChangeEvent(property, propertyDefinition,
            invalidPropertySetChanged, this.invalidPropertyNameToDisplayNameMap);
        firePropertyChangedEvent(event);
View Full Code Here

        String stringValue = (value != null) ? value.toString() : null;
        setValueAsTooltipIfAppropriate(formItem, stringValue);
    }

    protected static PropertyDefinition getTopLevelPropertyDefinition(PropertyDefinition propertyDefinition) {
        PropertyDefinition currentPropertyDefinition = propertyDefinition;
        while (currentPropertyDefinition.getConfigurationDefinition() == null) {
            if (currentPropertyDefinition.getParentPropertyListDefinition() != null) {
                currentPropertyDefinition = currentPropertyDefinition.getParentPropertyListDefinition();
            } else if (currentPropertyDefinition.getParentPropertyMapDefinition() != null) {
                currentPropertyDefinition = currentPropertyDefinition.getParentPropertyMapDefinition();
            } else {
                Log.error("Property definition " + currentPropertyDefinition + " has no parent.");
                break;
            }
        }
View Full Code Here

            for (PropertyGroupDefinition pgd : groups2) {
                if (pgd.getName().equals("fun")) {
                    found++;
                    List<PropertyDefinition> pdl = cDef2.getPropertiesInGroup("fun");
                    assert pdl.size() == 1 : "Expected to find 1 property for group 'fun' in v2, but got " + pdl.size();
                    PropertyDefinition pd = pdl.get(0);
                    assert pd.getName().equals("funRampUpTime") : "Expected to find the property 'rampUpTime', but got "
                        + pd.getName();
                } else if (pgd.getName().equals("tuning")) {
                    found++;
                    List<PropertyDefinition> pdl = cDef2.getPropertiesInGroup("tuning");
                    assert pdl.size() == 3 : "Expected 3 properties in group 'tuning' in v2, but got " + pdl.size();
                    for (PropertyDefinition pd : pdl) {
                        if (pd.getName().equals("rampDownTime")) {
                            assert pd.isRequired() == true : "rampDownTime is now required in 'tuning' in v2";
                            assert pd.isReadOnly() == false : "rampDownTime should be r/w in v2";
                            assert pd.isSummary() == true : "rampDownTime should  be summary in v2";
                        }
                    }
                } else if (pgd.getName().equals("control")) {
                    found++;
                } else {
View Full Code Here

            // create resource with plugin configuration
            ResourceType testServerResourceType = getResourceType("TestServer");
            getTransactionManager().begin();
            testServerResourceType = em.find(ResourceType.class, testServerResourceType.getId());
            ConfigurationDefinition pluginConfigurationDef = testServerResourceType.getPluginConfigurationDefinition();
            PropertyDefinition testPropertyDef = pluginConfigurationDef.getPropertyDefinitionSimple("testProperty");
            Configuration pluginConfiguration = null;
            int pluginConfigurationId = 0;
            try {
                assertNotNull(
                    "Expected plugin configuration definition to have a property definition for 'testProperty'",
                    testPropertyDef);

                String resourceKey = testServerResourceType.getName() + System.currentTimeMillis();
                Resource testResource = new Resource(resourceKey, resourceKey, testServerResourceType);
                testResource.setUuid("" + new Random().nextInt());
                em.persist(testResource);
                em.flush();

                setUpAgent(testResource);

                testResource = em.find(Resource.class, testResource.getId());
                pluginConfigurationId = testResource.getPluginConfiguration().getId();

                pluginConfiguration = em.find(Configuration.class, pluginConfigurationId);
                PropertySimple testProperty = pluginConfiguration.getSimple("testProperty");

                assertNull(
                    "Did not expect to find a value for 'testProperty' since a value has not been supplied for it yet",
                    testProperty);

                getTransactionManager().commit();
            } catch (Exception e) {
                getTransactionManager().rollback();
                fail("testBZ_573034:" + e);
            }

            // register new version of plugin that specifies new plugin configuration property having a default value
            registerPlugin("BZ_573034_v2.xml", version2);

            // verify existing resource has its plugin configuration updated with new property having default value
            testServerResourceType = getResourceType("TestServer");
            getTransactionManager().begin();
            em = getEntityManager();
            testServerResourceType = em.find(ResourceType.class, testServerResourceType.getId());

            pluginConfigurationDef = testServerResourceType.getPluginConfigurationDefinition();
            PropertyDefinition testPropertyWithDefaultDef = pluginConfigurationDef
                .getPropertyDefinitionSimple("testPropertyWithDefault");

            assertNotNull(
                "Expected updated plugin configuration definition to define the property 'testPropertyWithDefault'",
                testPropertyWithDefaultDef);
View Full Code Here

            assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v1, but got " + propDefs.size();
            for (PropertyDefinition def : propDefs.values()) {
                assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
                    + " is no list-property in v1";
                PropertyDefinitionList pdl = (PropertyDefinitionList) def;
                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";
View Full Code Here

        }

        for (Property property : configuration.getProperties()) {

            String propertyName = property.getName();
            PropertyDefinition propertyDefinition = null;
            if (definition != null) {
                propertyDefinition = definition.get(propertyName);
            }
            if (propertyDefinition==null) {
                if (strict) {
View Full Code Here

        Map<String,Object> result = new HashMap<String, Object>(map.size());

        Set<String> names = map.keySet();
        for (String name : names ) {
            Property property = map.get(name);
            PropertyDefinition definition = null;
            if (propertyDefinition != null) {
                definition = propertyDefinition.get(name);
            }

            Object target = convertProperty(property,definition, strict);
View Full Code Here

            if (strict) {
                throw new IllegalArgumentException("No Definition exists for " + propertyList.getName());
            }
        }

        PropertyDefinition memberDefinition = null;
        if (definition != null) {
            memberDefinition = definition.getMemberDefinition();
        }
        for (Property property : propertyList.getList()) {
            Object target = convertProperty(property,memberDefinition, strict);
View Full Code Here

            } else if (property instanceof PropertyMap) {
                PropertyMap propertyMap = (PropertyMap) property;
                PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) propertyDefinition;
                for (Map.Entry<String,Property> entry : propertyMap.getMap().entrySet()) {
                    Property prop = entry.getValue();
                    PropertyDefinition definition = propertyDefinitionMap.get(name);
                    checkProperty(messages,definition,prop);
                }
            }
        }
    }
View Full Code Here

TOP

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

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.