Package org.rhq.modules.plugins.jbossas7.json

Examples of org.rhq.modules.plugins.jbossas7.json.Operation


        if (prop.get(namePropLocator) == null) {
            throw new IllegalArgumentException("There is no element in the map with the name " + namePropLocator);
        }
        String key = ((PropertySimple) prop.get(namePropLocator)).getStringValue();

        Operation operation;
        Address addr = new Address(address);
        addr.add(type, key);

        if (!addNewChildren || existingPropNames.contains(key)) {
            // update existing entry
            if (addDeleteModifiedChildren) {

                operation = new Remove(addr);
                cop.addStep(operation);

                operation = new Operation("add", addr);
                for (Map.Entry<String, Object> entry : results.entrySet()) {
                    String key1 = entry.getKey();
                    Object value = getValueWithType(entry, propDef);
                    if (key1.endsWith(":expr")) {
                        key1 = key1.substring(0, key1.indexOf(':'));
                        Map<String, Object> tmp = new HashMap<String, Object>();
                        tmp.put("EXPRESSION_VALUE", value);

                        operation.addAdditionalProperty(key1, tmp);
                    } else {
                        operation.addAdditionalProperty(key1, value);
                    }
                }
                cop.addStep(operation);
            } else {
                for (Map.Entry<String, Object> entry : results.entrySet()) {
                    String key1 = entry.getKey();
                    Object value = getValueWithType(entry, propDef);
                    if (key1.endsWith(":expr")) {
                        key1 = key1.substring(0, key1.indexOf(':'));
                        Map<String, Object> tmp = new HashMap<String, Object>();
                        tmp.put("EXPRESSION_VALUE", value);
                        operation = new WriteAttribute(addr, key1, tmp);
                    } else {
                        operation = new WriteAttribute(addr, key1, value);
                    }
                    cop.addStep(operation);
                }
            }

        } else {
            // write new child ( :name+ case )
            operation = new Operation("add", addr);
            for (Map.Entry<String, Object> entry : results.entrySet()) {
                String key1 = entry.getKey();
                Object value = getValueWithType(entry, propDef);
                if (key1.endsWith(":expr")) {
                    key1 = key1.substring(0, key1.indexOf(':'));
                    Map<String, Object> tmp = new HashMap<String, Object>();
                    tmp.put("EXPRESSION_VALUE", value);
                    operation.addAdditionalProperty(key1, tmp);
                } else {
                    operation.addAdditionalProperty(key1, value);
                }
            }

            cop.addStep(operation);
        }
View Full Code Here


            String name = property.getName();
            if (name.indexOf(':') != -1) {
                name = name.substring(0, name.indexOf(":"));
            }

            Operation writeAttribute = new WriteAttribute(address, name, null);
            cop.addStep(writeAttribute);
            return;
        }

        SimpleEntry<String, Object> entry = this.preparePropertySimple(property, propertyDefinition);
        Operation writeAttribute = new WriteAttribute(address, entry.getKey(), entry.getValue());
        cop.addStep(writeAttribute);
    }
View Full Code Here

    private void createWriteAttributePropertyList(CompositeOperation cop, PropertyList property,
        PropertyDefinitionList propertyDefinition, Address address) {

        SimpleEntry<String, List<Object>> entry = preparePropertyList(property, propertyDefinition);
        Operation writeAttribute = new WriteAttribute(address, entry.getKey(), entry.getValue());
        cop.addStep(writeAttribute);
    }
View Full Code Here

    private void createWriteAttributePropertyMap(CompositeOperation cop, PropertyMap property,
        PropertyDefinitionMap propertyDefinition, Address address) {

        // A map of simples can be me an empty map if all of the simples are optional and unset
        SimpleEntry<String, Map<String, Object>> entry = this.preparePropertyMap(property, propertyDefinition);
        Operation writeAttribute = new WriteAttribute(address, entry.getKey(), entry.getValue());
        cop.addStep(writeAttribute);
    }
View Full Code Here

        CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());

        Assert.assertEquals(cop.numberOfSteps(), 2);

        for (int i = 0; i < cop.numberOfSteps(); i++) {
            Operation step = cop.step(0);
            Assert.assertEquals(step.getOperation(), "write-attribute");
            Map<String, Object> stepProps = step.getAdditionalProperties();
            Assert.assertEquals(stepProps.size(), 2);

            if (stepProps.get("name").equals("needed")) {
                Assert.assertEquals(stepProps.get("value"), "test");
            } else if (stepProps.get("name").equals("optional")) {
View Full Code Here

        conf.put(propertyList);

        CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());

        assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps();
        Operation step1 = cop.step(0);
        assert step1.getOperation().equals("write-attribute");
        Map<String, Object> props = step1.getAdditionalProperties();
        assert props.size() == 2;
        List<String> values = (List<String>) props.get("value");
        assert values.size() == 2 : "Values had " + values.size() + " entries"; // The optional null must not be present

        String result = mapper.writeValueAsString(cop);
View Full Code Here

        conf.put(propertyMap);

        CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());

        assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps();
        Operation step1 = cop.step(0);
        assert step1.getOperation().equals("write-attribute");
        Map<String, Object> props = step1.getAdditionalProperties();
        assert props.size() == 2;
        Map<String, Object> values = (Map<String, Object>) props.get("value");
        assert values.size() == 2 : "Values had " + values.size() + " entries instead of 2"; // The optional null must not be present

        String result = mapper.writeValueAsString(cop);
View Full Code Here

        conf.put(propertyMap);

        CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());

        assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps();
        Operation step1 = cop.step(0);
        assert step1.getOperation().equals("write-attribute");
        Map<String, Object> props = step1.getAdditionalProperties();
        assert props.size() == 2;
        Map<String, Object> values = (Map<String, Object>) props.get("value");
        assert values.size() == 1 : "Values had " + values.size() + " entries instead of 1"; // The optional null must not be present

        String result = mapper.writeValueAsString(cop);
View Full Code Here

        conf.put(propertyMap);

        CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());

        assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps();
        Operation step1 = cop.step(0);
        assert step1.getOperation().equals("write-attribute");
        Map<String, Object> props = step1.getAdditionalProperties();
        assert props.size() == 2;
        Map<String, Object> values = (Map<String, Object>) props.get("value");
        assert values.size() == 1 : "Values had " + values.size() + " entries instead of 1"; // The optional null must not be present

        String result = mapper.writeValueAsString(cop);
View Full Code Here

        conf.put(propertyList);

        CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());

        assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps();
        Operation step1 = cop.step(0);
        assert step1.getOperation().equals("write-attribute");
        Map<String, Object> props = step1.getAdditionalProperties();
        assert props.size() == 2;
        List<Map<String, Object>> values = (List<Map<String, Object>>) props.get("value");
        assert values.size() == 1 : "Values had " + values.size() + " entries instead of 1"; // The optional null must not be present
        Map<String, Object> map = values.get(0);
        assert map.size() == 2 : "Map had " + map.size() + " entries instead of two";
View Full Code Here

TOP

Related Classes of org.rhq.modules.plugins.jbossas7.json.Operation

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.