Package org.rhq.core.domain.configuration

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


        this.propertyValue = propertyValue;
    }

    public String addProperty() {
        String mapName = FacesContextUtility.getRequiredRequestParameter(RequestParameterNameConstants.MAP_NAME_PARAM);
        PropertyMap propertyMap = getConfiguration().getMap(mapName);
        if (propertyMap == null) {
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Configuration does not contain a map named '"
                + mapName + "'.");
            return FAILURE_OUTCOME;
        }

        // Assume any leading or trailing whitespace in the property name was not intended by the user.
        String propertyName = this.propertyName.trim();
        if (propertyMap.getMap().containsKey(propertyName)) {
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Map '" + mapName
                + "' already contains a property named '" + propertyName + "'.");
            return FAILURE_OUTCOME;
        }

        PropertySimple propertySimple = new PropertySimple(propertyName, this.propertyValue);
        // It is essential to set override to true in case this is an group config.
        propertySimple.setOverride(true);
        propertyMap.put(propertySimple);
        FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Property '" + propertySimple.getName()
            + "' added to map '" + mapName + "'.");
        return SUCCESS_OUTCOME;
    }
View Full Code Here


    @Test
    public void testConfigToMapComplexMap() throws Exception {

        Configuration config = new Configuration();
        PropertyMap propertyMap = new PropertyMap("aMap");
        config.put(propertyMap);
        PropertyList propertyList = new PropertyList("aList");
        propertyList.add(new PropertySimple("string", "Hello"));
        propertyList.add(new PropertySimple("string", "World"));
        propertyMap.put(propertyList);

        propertyMap.put(new PropertySimple("aString","Frobnitz"));


        ConfigurationDefinition definition = new ConfigurationDefinition("bla",null);
        definition.put(new PropertyDefinitionMap("aMap",null,false,
            new PropertyDefinitionList("aList",null,false,
View Full Code Here

    @Test
    public void testConfigToMapComplexMapWithBadSetupStrict() throws Exception {

        Configuration config = new Configuration();
        PropertyMap propertyMap = new PropertyMap("aMap");
        config.put(propertyMap);
        PropertyList propertyList = new PropertyList("aList");
        propertyList.add(new PropertySimple("string", "Hello"));
        propertyList.add(new PropertySimple("string", "World"));
        propertyMap.put(propertyList);

        propertyMap.put(new PropertySimple("aString","Frobnitz"));


        ConfigurationDefinition definition = new ConfigurationDefinition("bla",null);
        definition.put(new PropertyDefinitionMap("aMap",null,false,
            new PropertyDefinitionList("aBla",null,false,
View Full Code Here

    @Test(enabled = false)
    public void testConfigToMapComplexMapWithBadSetupLenient() throws Exception {

        Configuration config = new Configuration();
        PropertyMap propertyMap = new PropertyMap("aMap");
        config.put(propertyMap);
        PropertyList propertyList = new PropertyList("aList");
        propertyList.add(new PropertySimple("string", "Hello"));
        propertyList.add(new PropertySimple("string", "World"));
        propertyMap.put(propertyList);

        propertyMap.put(new PropertySimple("aString","Frobnitz"));


        ConfigurationDefinition definition = new ConfigurationDefinition("bla",null);
        definition.put(new PropertyDefinitionMap("aMap",null,false,
            new PropertyDefinitionList("aBla",null,false,
View Full Code Here

            List<DisambiguationReport<Property>> disambiguated = resourceManager.disambiguate(allMissing,
                new IntExtractor<Property>() {
                    @Override
                    public int extract(Property object) {
                        PropertyMap map = (PropertyMap) object;
                        return map.getSimple(PROP_RESOURCE_ID).getIntegerValue();
                    }
                }, DefaultDisambiguationUpdateStrategies.KEEP_ALL_PARENTS);

            DisambiguationReportRenderer renderer = new DisambiguationReportRenderer();

            for (DisambiguationReport<Property> r : disambiguated) {
                PropertyMap map = (PropertyMap) r.getOriginal();

                String resourcePath = renderer.render(r);

                map.put(new PropertySimple(PROP_RESOURCE_PATH, resourcePath));
            }
        }

    }
View Full Code Here

                //skip this definition - it has more than one incorrect notifs and we already
                //included it in the output.
                continue;
            }

            PropertyMap alertDefinitionMap = new PropertyMap(PROP_ALERT_DEFINITION);

            alertDefinitionMap.put(new PropertySimple(PROP_ALERT_DEFINITION_ID, def.getId()));
            alertDefinitionMap.put(new PropertySimple(PROP_ALERT_DEFINITION_NAME, def.getName()));
            alertDefinitionMap.put(new PropertySimple(PROP_RESOURCE_ID, def.getResource().getId()));

            results.add(alertDefinitionMap);
        }
    }
View Full Code Here

            } 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;
            } else {
View Full Code Here

                }
                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

        // if the definition is not a map, it can't be a schedule
        if (mapDef instanceof PropertyDefinitionMap) {
            PropertyDefinitionMap jobMapDef = (PropertyDefinitionMap) mapDef;
            ConfigurationTemplate defaultTemplate = jobMapDef.getConfigurationDefinition().getDefaultTemplate();
            PropertyMap defaults = defaultTemplate.getConfiguration().getMap(mapDef.getName());
            // prepare some defaults if the schedule didn't define some of these
            // we assume:
            //    the map name is the methodName that will be invoked
            //    the class name is null, which means its the stateful plugin component to be invoked
            //    the schedule is always enabled
            //    the schedule is never concurrent
            //    the schedule is a periodic schedule that triggers every 10 minutes
            //    the schedule has no callback data
            String methodName = defaults.getSimpleValue(SCHEDULED_JOB_PROP_NAME_METHOD_NAME, mapDef.getName());
            String className = defaults.getSimpleValue(SCHEDULED_JOB_PROP_NAME_CLASS, null);
            String enabledStr = defaults.getSimpleValue(SCHEDULED_JOB_PROP_NAME_ENABLED, "true");
            String concurrentStr = defaults.getSimpleValue(SCHEDULED_JOB_PROP_NAME_CONCURRENT, "false");
            String clusteredStr = defaults.getSimpleValue(SCHEDULED_JOB_PROP_NAME_CLUSTERED, "true");
            String scheduleTypeStr = defaults.getSimpleValue(SCHEDULED_JOB_PROP_NAME_SCHEDULE_TYPE,
                PeriodicScheduleType.TYPE_NAME);
            String scheduleTriggerStr = defaults.getSimpleValue(SCHEDULED_JOB_PROP_NAME_SCHEDULE_TRIGGER, "600000");

            String jobId = jobMapDef.getName();
            boolean enabled = Boolean.parseBoolean(enabledStr);
            boolean concurrent = Boolean.parseBoolean(concurrentStr);
            boolean clustered = Boolean.parseBoolean(clusteredStr);

            AbstractScheduleType scheduleType;
            scheduleType = AbstractScheduleType.create(concurrent, clustered, scheduleTypeStr, scheduleTriggerStr);
            if (scheduleType == null) {
                throw new InvalidPluginDescriptorException("Invalid schedule type: " + scheduleTypeStr);
            }

            // the callback data will contain all simple properties in the schedule job map
            Properties callbackData = new Properties();
            Map<String, PropertyDefinition> allPropDefs = jobMapDef.getMap();
            for (PropertyDefinition currentPropDef : allPropDefs.values()) {
                if (currentPropDef instanceof PropertyDefinitionSimple) {
                    String currentPropDefName = currentPropDef.getName();
                    String currentPropDefValue = defaults.getSimpleValue(currentPropDefName, null);
                    if (currentPropDefValue != null) {
                        callbackData.setProperty(currentPropDefName, currentPropDefValue);
                    }
                }
            }
View Full Code Here

    private static ScheduledJobDefinition getScheduledJob(Property map) throws Exception {
        ScheduledJobDefinition job = null;

        // if the definition is not a map, it can't be a schedule
        if (map instanceof PropertyMap) {
            PropertyMap jobMap = (PropertyMap) map;
            // prepare some defaults if the schedule didn't define some of these
            // we assume:
            //    the map name is the methodName that will be invoked
            //    the class name is null, which means its the stateful plugin component to be invoked
            //    the schedule is always enabled
            //    the schedule is never concurrent
            //    the schedule is a periodic schedule that triggers every 10 minutes
            //    the schedule has no callback data
            String methodName = jobMap.getSimpleValue(SCHEDULED_JOB_PROP_NAME_METHOD_NAME, jobMap.getName());
            String className = jobMap.getSimpleValue(SCHEDULED_JOB_PROP_NAME_CLASS, null);
            String enabledStr = jobMap.getSimpleValue(SCHEDULED_JOB_PROP_NAME_ENABLED, "true");
            String concurrentStr = jobMap.getSimpleValue(SCHEDULED_JOB_PROP_NAME_CONCURRENT, "false");
            String clusteredStr = jobMap.getSimpleValue(SCHEDULED_JOB_PROP_NAME_CLUSTERED, "true");
            String scheduleTypeStr = jobMap.getSimpleValue(SCHEDULED_JOB_PROP_NAME_SCHEDULE_TYPE,
                PeriodicScheduleType.TYPE_NAME);
            String scheduleTriggerStr = jobMap.getSimpleValue(SCHEDULED_JOB_PROP_NAME_SCHEDULE_TRIGGER, "600000");

            String jobId = jobMap.getName();
            boolean enabled = Boolean.parseBoolean(enabledStr);
            boolean concurrent = Boolean.parseBoolean(concurrentStr);
            boolean clustered = Boolean.parseBoolean(clusteredStr);

            AbstractScheduleType scheduleType;
            scheduleType = AbstractScheduleType.create(concurrent, clustered, scheduleTypeStr, scheduleTriggerStr);
            if (scheduleType == null) {
                throw new InvalidPluginDescriptorException("Invalid schedule type: " + scheduleTypeStr);
            }

            // the callback data will contain all simple properties in the schedule job map
            Properties callbackData = new Properties();
            Map<String, Property> allProps = jobMap.getMap();
            for (Property currentProp : allProps.values()) {
                if (currentProp instanceof PropertySimple) {
                    String currentPropName = currentProp.getName();
                    String currentPropValue = jobMap.getSimpleValue(currentPropName, null);
                    if (currentPropValue != null) {
                        callbackData.setProperty(currentPropName, currentPropValue);
                    }
                }
            }
View Full Code Here

TOP

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

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.