Package org.rhq.core.domain.configuration

Examples of org.rhq.core.domain.configuration.Property


        assertEquals(def.getPropertyDefinitions().size(), 1, "Unexpected number of defined properties");
        assertEquals(conf.getProperties().size(), 1, "Unexpected number of properties");

        PropertyDefinition propDef = def.get("list");
        Property prop = conf.get("list");

        assertNotNull(propDef, "Could not find the expected property definition");
        assertNotNull(prop, "Could not find the expected property");

        assertEquals(propDef.getClass(), PropertyDefinitionList.class, "Unexpected type of the property definition");
        assertEquals(prop.getClass(), PropertyList.class, "Unexpecetd type of the property");

        PropertyDefinitionList listDef = (PropertyDefinitionList) propDef;
        PropertyList listProp = (PropertyList) prop;

        PropertyDefinition memberDef = listDef.getMemberDefinition();
        assertEquals(memberDef.getClass(), PropertyDefinitionSimple.class, "Unexpected type of the list member property definition");

        PropertyDefinitionSimple memberSimpleDef = (PropertyDefinitionSimple) memberDef;
        assertEquals(memberSimpleDef.getName(), "member");
        assertEquals(memberSimpleDef.getType(), PropertySimpleType.INTEGER);

        assertEquals(listProp.getList().size(), 3, "Unexpected number of list members");

        for(int i = 0; i < 3; ++i) {
            Property memberProp = listProp.getList().get(i);
            assertEquals(memberProp.getClass(), PropertySimple.class, "Unexpected type of the property in the list on index " + i);
            assertEquals(memberProp.getName(), "member");
            assertEquals(((PropertySimple)memberProp).getIntegerValue(), Integer.valueOf(i + 1));
        }
    }
View Full Code Here


        assertEquals(def.getPropertyDefinitions().size(), 1, "Unexpected number of defined properties");
        assertEquals(conf.getProperties().size(), 1, "Unexpected number of properties");

        PropertyDefinition propDef = def.get("map");
        Property prop = conf.get("map");

        assertNotNull(propDef, "Could not find the expected property definition");
        assertNotNull(prop, "Could not find the expected property");

        assertEquals(propDef.getClass(), PropertyDefinitionMap.class, "Unexpected type of the property definition");
        assertEquals(prop.getClass(), PropertyMap.class, "Unexpecetd type of the property");

        PropertyDefinitionMap mapDef = (PropertyDefinitionMap) propDef;
        PropertyMap mapProp = (PropertyMap) prop;

        assertEquals(mapDef.getMap().size(), 2, "Unexpected number of map member definitions");
        assertEquals(mapProp.getMap().size(), 2, "Unexpected number of map members");

        PropertyDefinition m1Def = mapDef.get("m1");
        PropertyDefinition m2Def = mapDef.get("m2");
        Property m1Prop = mapProp.get("m1");
        Property m2Prop = mapProp.get("m2");

        assertEquals(m1Def.getClass(), PropertyDefinitionSimple.class);
        assertEquals(m2Def.getClass(), PropertyDefinitionSimple.class);
        assertEquals(m1Prop.getClass(), PropertySimple.class);
        assertEquals(m2Prop.getClass(), PropertySimple.class);

        PropertyDefinitionSimple m1SimpleDef = (PropertyDefinitionSimple) m1Def;
        PropertyDefinitionSimple m2SimpleDef = (PropertyDefinitionSimple) m2Def;
        PropertySimple m1SimpleProp = (PropertySimple) m1Prop;
        PropertySimple m2SimpleProp = (PropertySimple) m2Prop;
View Full Code Here

                            transferred.put(simple);
                            break;
                        case FULL:
                            for (Property p : pluginConfiguration.getProperties()) {
                                Property copy = p.deepCopy(false);
                                if (refProp.getTargetName() != null) {
                                    copy.setName(refProp.getTargetName() + copy.getName());
                                }
                                transferred.put(copy);
                            }
                            break;
                        }
                        break;
                    case RESOURCE_CONFIGURATION:
                        switch (refProp.getType()) {
                        case LIST:
                            PropertyList list = resourceConfiguration.getList(refProp.getName()).deepCopy(false);
                            list.setName(refProp.getTargetName());

                            transferred.put(list);
                            break;
                        case MAP:
                            PropertyMap map = resourceConfiguration.getMap(refProp.getName()).deepCopy(false);
                            map.setName(refProp.getTargetName());

                            transferred.put(map);
                            break;
                        case SIMPLE:
                            PropertySimple simple = resourceConfiguration.getSimple(refProp.getName()).deepCopy(false);
                            simple.setName(refProp.getTargetName());

                            transferred.put(simple);
                            break;
                        case FULL:
                            for (Property p : resourceConfiguration.getProperties()) {
                                Property copy = p.deepCopy(false);
                                if (refProp.getTargetName() != null) {
                                    copy.setName(refProp.getTargetName() + copy.getName());
                                }
                                transferred.put(copy);
                            }
                            break;
                        }
View Full Code Here

        assert config!=null;
        Collection<Property> properties = config.getProperties();
        assert properties.size()==3 : "Expected 3 props, got " + properties.size();

        Property prop = config.get("Inner");
        assert prop!=null;
        assert prop instanceof PropertyMap : "Inner is no map";

        PropertyMap pm = (PropertyMap) prop;
        Map<String, Property> innerMap = pm.getMap();
View Full Code Here

        assert config!=null;
        Collection<Property> properties = config.getProperties();
        assert properties.size()==2 : "Expected 2 props, got " + properties.size();

        Property prop = config.get("Inner");
        assert prop==null;

        prop = config.get("list");
        assert prop instanceof PropertyList : "list is no list";

        PropertyList pl = (PropertyList) prop;
        List<Property> propertyList = pl.getList();
        assert propertyList.size()==1;
        PropertyMap innerMapProperty = (PropertyMap) propertyList.get(0);

        Map<String, Property> propertyMap = innerMapProperty.getMap();
        assert propertyMap.size()==1;
        Map<String,Property> innerMap = propertyMap;

        assert innerMap.containsKey("Foo");
        Property property = innerMapProperty.get("Foo");
        assert property != null;
        assert property instanceof PropertySimple;
        PropertySimple ps = (PropertySimple) property;
        assert ps.getStringValue().equals("Bar");
View Full Code Here

        assert config!=null;
        Collection<Property> properties = config.getProperties();
        assert properties.size()==3 : "Expected 3 props, got " + properties.size();

        Property prop = config.get("Inner");
        assert prop!=null;
        assert prop instanceof PropertyList : "Inner is no list";

        PropertyList plist = (PropertyList) prop;
        List<Property> propertyList = plist.getList();
View Full Code Here

        private static void addAll(List<JAXBElement<?>> descriptors, Map<String, PropertyDefinition> defs,
            Map<String, Property> props) {
            for (Map.Entry<String, PropertyDefinition> e : defs.entrySet()) {
                String propName = e.getKey();
                PropertyDefinition def = e.getValue();
                Property prop = props.get(propName);

                addSingle(descriptors, def, prop);
            }
        }
View Full Code Here

            return ret;
        }

        private static void add(ConfigurationDefinition configurationDefinition, Configuration configuration,
            PropertyDefinition parentDef, Property parentProp, Object propertyInstance) {
            Property prop = null;
            PropertyDefinition def = null;

            if (propertyInstance instanceof SimplePropertyInstanceDescriptor) {
                def = convert((ConfigurationProperty) propertyInstance);
                def.setConfigurationDefinition(configurationDefinition);

                SimplePropertyInstanceDescriptor simpleInstance = (SimplePropertyInstanceDescriptor) propertyInstance;

                PropertySimple simpleProp = new PropertySimple(simpleInstance.getName(), simpleInstance.getValue());
                prop = simpleProp;
            } else if (propertyInstance instanceof ListPropertyInstanceDescriptor) {
                def = convert((ConfigurationProperty) propertyInstance);
                def.setConfigurationDefinition(configurationDefinition);

                ListPropertyInstanceDescriptor listInstance = (ListPropertyInstanceDescriptor) propertyInstance;
                PropertyList listProp = new PropertyList(listInstance.getName());

                PropertyDefinition memberDefinition = ((PropertyDefinitionList) def).getMemberDefinition();

                if (listInstance.getValues() != null) {
                    for (JAXBElement<?> val : listInstance.getValues().getComplexValue()) {
                        ComplexValueDescriptor valDesc = (ComplexValueDescriptor) val.getValue();
                        Property child = convert(memberDefinition, valDesc);
                        listProp.add(child);
                    }
                }

                prop = listProp;
            } else if (propertyInstance instanceof MapPropertyInstanceDescriptor) {
                def = convert((ConfigurationProperty) propertyInstance);
                def.setConfigurationDefinition(configurationDefinition);

                MapPropertyInstanceDescriptor mapInstance = (MapPropertyInstanceDescriptor) propertyInstance;
                PropertyMap mapProp = new PropertyMap(mapInstance.getName());

                if (mapInstance.getValues() != null) {
                    for (JAXBElement<?> val : mapInstance.getValues().getComplexValue()) {
                        ComplexValueDescriptor valueDesc = (ComplexValueDescriptor) val.getValue();
                        PropertyDefinition valueDefinition = ((PropertyDefinitionMap) def).get(valueDesc
                            .getPropertyName());

                        Property child = convert(valueDefinition, valueDesc);
                        mapProp.put(child);
                    }
                }

                prop = mapProp;
View Full Code Here

                throw new IllegalArgumentException(e);
            }
        }

        private static Property convert(PropertyDefinition definition, ComplexValueDescriptor value) {
            Property ret = null;

            if (value instanceof ComplexValueSimpleDescriptor) {
                ret = new PropertySimple(value.getPropertyName(), ((ComplexValueSimpleDescriptor) value).getValue());
            } else if (value instanceof ComplexValueListDescriptor) {
                ComplexValueListDescriptor listValue = (ComplexValueListDescriptor) value;

                PropertyDefinitionList listDefinition = (PropertyDefinitionList) definition;

                PropertyList list = new PropertyList(value.getPropertyName());

                for (JAXBElement<?> val : listValue.getComplexValue()) {
                    Property child = convert(listDefinition.getMemberDefinition(),
                        (ComplexValueDescriptor) val.getValue());

                    list.add(child);
                }
                ret = list;
            } else if (value instanceof ComplexValueMapDescriptor) {
                ComplexValueMapDescriptor mapValue = (ComplexValueMapDescriptor) value;

                PropertyMap map = new PropertyMap(value.getPropertyName());
                PropertyDefinitionMap mapDefinition = (PropertyDefinitionMap) definition;

                for (JAXBElement<?> val : mapValue.getComplexValue()) {
                    ComplexValueDescriptor childDesc = (ComplexValueDescriptor) val.getValue();

                    PropertyDefinition childDefinition = mapDefinition.get(childDesc.getPropertyName());

                    Property child = convert(childDefinition, childDesc);
                    map.put(child);
                }

                ret = map;
            }
View Full Code Here

        PropertySimple propertySimple, Integer listIndex) {
        StringBuilder stringBuilder = new StringBuilder("#{");
        stringBuilder.append(FacesExpressionUtility.unwrapExpressionString(configurationExpressionString));
        LinkedList<Property> propertyHierarchy = ConfigurationUtility.getPropertyHierarchy(propertySimple);
        for (Property property : propertyHierarchy) {
            Property parentProperty = ConfigurationUtility.getParentProperty(property);
            stringBuilder.append(".");
            if (parentProperty == null || parentProperty instanceof PropertyMap) {
                // top-level or map member property
                stringBuilder.append("map['").append(property.getName()).append("']");
            } else {
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.configuration.Property

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.