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

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


        return expression.toString();
    }

    private static Collection<PropertyDefinition> getPropertyDefinitions(
        ConfigurationDefinition configurationDefinition, String listName) {
        PropertyDefinitionMap mapDefinition = (PropertyDefinitionMap) configurationDefinition
            .getPropertyDefinitionList(listName).getMemberDefinition();
        return mapDefinition.getMap().values();
    }
View Full Code Here


                    rowCount++;
                }
            } else {
                // If the map contains no member definitions, it means the map permits arbitrary simple properties as
                // members. We refer to such a map as an "open map."
                PropertyDefinitionMap propertyDefinitionMap = this.config.getConfigurationDefinition()
                    .getPropertyDefinitionMap(((PropertyMap) this.propertyMap).getName());
                FacesComponentUtility.addVerbatimText(rootPanel, "\n\n<table class='"
                    + OPENMAP_PROPERTIES_TABLE_STYLE_CLASS + "'>");
                addOpenMapMemberPropertiesTableHeaders(rootPanel, propertyDefinitionMap);
                for (Property property : this.propertyMap.getMap().values()) {
View Full Code Here

    }

    private void addListMemberMapProperties(UIComponent parent, PropertyList listProperty,
        PropertyDefinitionMap listMemberPropertyDefinition, String rowStyleClass) {
        addDebug(parent, true, ".addListMemberMapProperties()");
        PropertyDefinitionMap listMemberMapPropertyDefinition = listMemberPropertyDefinition;
        validateMapDefinition(listMemberMapPropertyDefinition);

        FacesComponentUtility.addVerbatimText(parent, "\n\n<tr class='" + rowStyleClass + "'>\n");
        FacesComponentUtility.addVerbatimText(parent, "<td colspan='4' class='"
            + LIST_PROPERTY_CHILDREN_CELL_STYLE_CLASS + "'>");

        Collection<PropertyDefinition> mapSummaryPropertyDefinitions = listMemberMapPropertyDefinition
            .getSummaryPropertyDefinitions();

        // Start the "List of maps" table
        FacesComponentUtility.addVerbatimText(parent, "\n<!-- start list of maps -->\n");
        FacesComponentUtility.addVerbatimText(parent, "<table class='" + PROPERTY_MAP_SUMMARY_TABLE_STYLE_CLASS
            + "'>\n");
        FacesComponentUtility.addVerbatimText(parent, "<tbody>\n");

        // Add the row for the headers
        FacesComponentUtility.addVerbatimText(parent, "<tr>\n");

        // Add column header cells...
        for (PropertyDefinition summaryPropertyDefinition : listMemberMapPropertyDefinition
            .getSummaryPropertyDefinitions()) {
            // We can safely cast here, because we already validated the map member definitions.
            PropertyDefinitionSimple mapMemberSimplePropertyDefinition = (PropertyDefinitionSimple) listMemberMapPropertyDefinition
                .get(summaryPropertyDefinition.getName());
            FacesComponentUtility.addVerbatimText(parent, "<th class='"
                + PROPERTY_MAP_SUMMARY_DATA_HEADER_CELL_STYLE_CLASS + "'>");
            FacesComponentUtility.addOutputText(parent, this.config,
                mapMemberSimplePropertyDefinition.getDisplayName(), PROPERTY_MAP_SUMMARY_HEADER_TEXT_STYLE_CLASS);
            FacesComponentUtility.addVerbatimText(parent, "</th>\n");
        }

        // add the "Actions" header
        FacesComponentUtility.addVerbatimText(parent, "<th class='" + PROPERTY_MAP_SUMMARY_DATA_HEADER_CELL_STYLE_CLASS
            + "'>");
        FacesComponentUtility.addOutputText(parent, this.config, "Actions",
            PROPERTY_MAP_SUMMARY_HEADER_TEXT_STYLE_CLASS);
        FacesComponentUtility.addVerbatimText(parent, "</th>\n");
        FacesComponentUtility.addVerbatimText(parent, "</tr>\n");

        // Add body cells...
        // NOTE: We only display the View button if the config component is read-only. If the list is read-only, members
        //       cannot be added or deleted, but existing members can still be edited.
        String viewEditButtonLabel = (this.config.isReadOnly()) ? VIEW_MAP_BUTTON_LABEL : EDIT_MAP_BUTTON_LABEL;
        String viewEditButtonTitle = (this.config.isReadOnly()) ? VIEW_MAP_BUTTON_TITLE : EDIT_MAP_BUTTON_TITLE;
        for (int index = 0; index < listProperty.getList().size(); index++) {
            addListMemberMapProperty(parent, listProperty, listMemberMapPropertyDefinition, viewEditButtonLabel,
                viewEditButtonTitle, index);
        }
        //HtmlPanelGrid buttonsPanelGrid = FacesComponentUtility.addPanelGrid(parent, this.configurationUIBean, 1, BUTTONS_TABLE_STYLE_CLASS);

        if (!isReadOnly(listMemberMapPropertyDefinition.getParentPropertyListDefinition())) {
            FacesComponentUtility.addVerbatimText(parent, "<tr>\n");
            FacesComponentUtility.addVerbatimText(parent, "<td colspan='" + (mapSummaryPropertyDefinitions.size() + 1)
                + "' class='" + PROPERTY_MAP_SUMMARY_BUTTON_FOOTER_STYLE_CLASS + "'>");

            // add-new button
View Full Code Here

            PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
            PropertyDefinition listMemberPropertyDefinition = propertyDefinitionList.getMemberDefinition();
            PropertyList targetPropertyList = new PropertyList(propertyDefinition.getName());
            targetParentPropertyMap.put(targetPropertyList);
            if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
                PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
                // TODO: How do we group together Lists of Maps? Not trivial...
            }
        }
    }
View Full Code Here

    @Test(enabled = ENABLED)
    public void mapPropertyOrderTest() {
        initConfigDefs("servers[name='UnchangedMap']", "UnchangedMap");

        String propertyName = "myMap";
        PropertyDefinitionMap map = originalConfigDef.getPropertyDefinitionMap(propertyName);
        Map<String, PropertyDefinition> propDefs = map.getMap();
        assertEquals("Expected three properties in unchanged map", 2, propDefs.size());
        assertEquals("Expected property to be kept", "property1ToKeep", propDefs.get("property1ToKeep").getName());
        assertEquals("Expected property to be kept", "property2ToKeep", propDefs.get("property2ToKeep").getName());
        assertEquals("Expected order_index to be 0", 0, propDefs.get("property1ToKeep").getOrder());
        assertEquals("Expected order_index to be 1", 1, propDefs.get("property2ToKeep").getOrder());
View Full Code Here

    @Test(enabled = ENABLED)
    public void updateMapWithAddRemoveProperty() {
        initConfigDefs("servers[name='UpdatedMapWithAddRemoveProperty']", "UpdateMapWithAddRemoveProperty");

        String propertyName = "myMap";
        PropertyDefinitionMap map = originalConfigDef.getPropertyDefinitionMap(propertyName);
        Map<String, PropertyDefinition> propDefs = map.getMap();
        assertEquals("Expected three properties in updated map", 3, propDefs.size());
        assertEquals("Expected property to be kept", "property1ToKeep", propDefs.get("property1ToKeep").getName());
        assertEquals("Expected property to be added", "propertyToAdd", propDefs.get("propertyToAdd").getName());
        assertEquals("Expected property to be kept", "property2ToKeep", propDefs.get("property2ToKeep").getName());
        assertEquals("Expected order_index to be 0", 0, propDefs.get("property1ToKeep").getOrder());
View Full Code Here

        initConfigDefs("servers[name='UpdatedMapWithUpdatedProperty']", "UpdateMapWithUpdatedProperty");

        String propertyName = "propertyToUpdate";
        String mapPropertyName = "myMap";

        PropertyDefinitionMap expectedMap = updatedConfigDef.getPropertyDefinitionMap(mapPropertyName);
        PropertyDefinitionSimple expected = expectedMap.getPropertyDefinitionSimple(propertyName);

        PropertyDefinitionMap actualMap = originalConfigDef.getPropertyDefinitionMap(mapPropertyName);
        PropertyDefinitionSimple actual = actualMap.getPropertyDefinitionSimple(propertyName);

        List<String> ignoredProperties = asList("id", "parentPropertyMapDefinition");

        assertPropertyDefinitionMatches("Expected property who is a child of map to get updated and remain in the map",
            expected, actual, ignoredProperties);

        assertEquals("Expected order_index to be 0", 0, actualMap.getMap().get("propertyToUpdate")
            .getOrder());
    }
View Full Code Here

        propDefEnums.add(new PropertyDefinitionEnumeration("blue", "blue"));
        propDefEnums.add(new PropertyDefinitionEnumeration("purple", "purple"));
        simplePropDef.setEnumeratedValues(propDefEnums, false);
        addPropertyDefinition(configDef, simplePropDef, orderIndex++);

        PropertyDefinitionMap mapPropDef = new PropertyDefinitionMap("MapOfSimples", "a map of simples", false);
        mapPropDef.put(createStringPropDef1());
        mapPropDef.put(createStringPropDef2());
        mapPropDef.put(createBooleanPropDef());
        mapPropDef.put(createIntegerPropDef());
        mapPropDef.setDisplayName(mapPropDef.getName());
        addPropertyDefinition(configDef, mapPropDef, orderIndex++);

        PropertyDefinitionMap openMapPropDef = new PropertyDefinitionMap("OpenMapOfSimples", "an open map of simples",
            false);
        openMapPropDef.setDisplayName(openMapPropDef.getName());
        addPropertyDefinition(configDef, openMapPropDef, orderIndex++);

        PropertyDefinitionMap readOnlyOpenMapPropDef = new PropertyDefinitionMap("ReadOnlyOpenMapOfSimples",
            "a read-only open map of simples", false);
        readOnlyOpenMapPropDef.setDisplayName(readOnlyOpenMapPropDef.getName());
        readOnlyOpenMapPropDef.setReadOnly(true);
        addPropertyDefinition(configDef, readOnlyOpenMapPropDef, orderIndex++);

        PropertyDefinitionList listOfSimplesPropDef = new PropertyDefinitionList("ListOfSimples",
            "a list of Integer simples", true, new PropertyDefinitionSimple("integer", "an integer", false,
                PropertySimpleType.INTEGER));
        listOfSimplesPropDef.setDisplayName(listOfSimplesPropDef.getName());
        listOfSimplesPropDef.setMax(listOfSimplesPropDef.getMax());
        listOfSimplesPropDef.setMin(listOfSimplesPropDef.getMin());
        addPropertyDefinition(configDef, listOfSimplesPropDef, orderIndex++);

        PropertyDefinitionMap mapInListPropDef =
            new PropertyDefinitionMap("MapOfSimplesInList", "a map of simples in a list", false);
        mapInListPropDef.put(createStringPropDef1());
        mapInListPropDef.put(createStringPropDef2());
        mapInListPropDef.put(createBooleanPropDef());
        mapInListPropDef.put(createIntegerPropDef());
        mapInListPropDef.setDisplayName(mapInListPropDef.getName());

        PropertyDefinitionList listPropDef = new PropertyDefinitionList("ListOfMaps", "a list of maps", true,
            mapInListPropDef);
        listPropDef.setDisplayName(listPropDef.getName());
        addPropertyDefinition(configDef, listPropDef, orderIndex++);

        PropertyDefinitionMap mapInReadOnlyListPropDef =
            new PropertyDefinitionMap("MapOfSimplesInReadOnlyList", "a map of simples in a list", false);
        PropertyDefinitionSimple propDef = createStringPropDef1();
        propDef.setReadOnly(true);
        mapInReadOnlyListPropDef.put(propDef);
        propDef = createStringPropDef2();
        propDef.setReadOnly(true);
        mapInReadOnlyListPropDef.put(propDef);
        propDef = createBooleanPropDef();
        propDef.setReadOnly(true);
        mapInReadOnlyListPropDef.put(propDef);
        propDef = createIntegerPropDef();
        propDef.setReadOnly(true);
        mapInReadOnlyListPropDef.put(propDef);
        mapInReadOnlyListPropDef.setDisplayName(mapInReadOnlyListPropDef.getName());

        PropertyDefinitionList readOnlyListPropDef = new PropertyDefinitionList("ReadOnlyListOfMaps",
            "a read-only list of maps", true, mapInReadOnlyListPropDef);
        readOnlyListPropDef.setDisplayName(readOnlyListPropDef.getName());
        readOnlyListPropDef.setReadOnly(true);
View Full Code Here

                PropertyDefinition memberDef = pdl.getMemberDefinition();
                if (memberDef instanceof PropertyDefinitionSimple) {
                    PropertyDefinitionSimple pds = (PropertyDefinitionSimple) memberDef;
                    handlePDS(subject, resource, baseResource, pds);
                } else if (memberDef instanceof PropertyDefinitionMap) {
                    PropertyDefinitionMap pdm = (PropertyDefinitionMap) memberDef;
                    for (PropertyDefinition inner : pdm.getOrderedPropertyDefinitions()) {
                        if (inner instanceof PropertyDefinitionSimple) {
                            handlePDS(subject, resource, baseResource, (PropertyDefinitionSimple) inner);
                        }
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("3 ____[ " + inner.toString() + " in " + pdl.toString()
                                + " ]____ not yet supported");
                        }
                    }
                } else {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("2 ____[ " + memberDef.toString() + " in " + pdl.toString()
                            + " ]____ not yet supported");
                    }
                }

            } else if (pd instanceof PropertyDefinitionMap) {
                PropertyDefinitionMap pdm = (PropertyDefinitionMap) pd;
                for (PropertyDefinition inner : pdm.getOrderedPropertyDefinitions()) {
                    if (inner instanceof PropertyDefinitionSimple) {
                        handlePDS(subject, resource, baseResource, (PropertyDefinitionSimple) inner);
                    } else {
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("4 ____[ " + inner.toString() + " in " + pdm.toString()
                                + " ]____ not yet supported");
                        }
                    }
                }
            } else {
View Full Code Here

            }
        }
        // If the property is a Map, recurse into it and mask its child properties.
        else if (propertyDefinition instanceof PropertyDefinitionMap) {
            PropertyMap propertyMap = parentPropertyMap.getMap(propertyDefinition.getName());
            PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) propertyDefinition;
            maskPropertyMap(propertyMap, propertyDefinitionMap);
        } else if (propertyDefinition instanceof PropertyDefinitionList) {
            PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
            PropertyDefinition listMemberPropertyDefinition = propertyDefinitionList.getMemberDefinition();
            // If the property is a List of Maps, iterate the list, and recurse into each Map and mask its child
            // properties.
            if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
                PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
                PropertyList propertyList = parentPropertyMap.getList(propertyDefinition.getName());
                for (Property property : propertyList.getList()) {
                    PropertyMap propertyMap = (PropertyMap) property;
                    maskPropertyMap(propertyMap, propertyDefinitionMap);
                }
View Full Code Here

TOP

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

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.