Package org.adfemg.datacontrol.xml.data

Examples of org.adfemg.datacontrol.xml.data.XMLDCElement$Accessor


        InsteadPutHandler putHandler = new InsteadPutHandler() {
            @Override
            public Object doInsteadPut(AttrChangeEvent attrChangeEvent) {
                TransientAttrAdopter.ValueHolder holder =
                    new TransientAttrAdopter.ValueHolder(attrChangeEvent.getNewValue());
                XMLDCElement element = attrChangeEvent.getElement();
                Map<String, Object> props = element.getProperties();
                props.put(propKey, holder);
                return attrChangeEvent.getOldValue();
            }

            @Override
            public boolean handlesAttribute(String input) {
                return attrName.equals(input);
            }
        };
        InsteadGetHandler getHandler = new InsteadGetHandler() {
            @Override
            public Object doInsteadGet(XMLDCElement element) {
                Map<String, Object> props = element.getProperties();
                if (!props.containsKey(propKey)) {
                    // no transient value known yet, invoke annotated method
                    Object value = AdopterUtil.invokeMethod(customizer, method, element);
                    TransientAttrAdopter.ValueHolder holder = new TransientAttrAdopter.ValueHolder(value);
                    props.put(propKey, holder);
View Full Code Here


        // check for situation where the operation comes from a customization-class
        // annotation
        final Object instance = resolveAsExpression(bindingContext, bindings, operationInfo.getInstanceName());
        if (instance instanceof XMLDCElement) {
            XMLDCElement xmldce = (XMLDCElement) instance;
            if (xmldce.hasMethod(methodName, action.getParamsMap())) {
                // TODO: logging
                logger.fine("invoking @Operation method {0} on {1}, new Object[]{methodName, instance}");
                Object result = xmldce.invokeMethod(methodName, action.getParamsMap());
                logger.fine("returning {0}", result);
                processResult(result, bindingContext, action);
                return true; // true to indicate we handled the operation
            }
        }

        // see if invoked method is any one of ours
        DataControlDefinitionNode invokedDef = null;
        for (DataControlDefinitionNode defNode : getDCDefinition().getDefinitionNodes()) {
            if (defNode.getDatacontrolOperation().equals(methodName)) {
                logger.fine("dataControl {0} is handling the {0} datacontrol operation", new Object[] {
                            mName, methodName });
                invokedDef = defNode;
                break;
            }
        }
        if (invokedDef == null) {
            return false; // false means we did not handle this call
        }

        // determine StructureDefinition we should return
        final String beanClassName =
            getDCDefinition().getReturnStructName(getDCDefinition().getStructure(), invokedDef);
        final StructureDefinition structDef = getDCDefinition().findStructure(beanClassName);
        if (structDef == null) {
            throw new IllegalStateException("StructureDefinition " + beanClassName +
                                            " not found in the DataControl Definition: " + getDCDefinition().getName());
        }

        // build DataRequest (clone dynamicParams so we don't alter the ones from binding layer)
        Map<String, Object> mutableParamValues =
            new LinkedHashMap<String, Object>((Map<String, Object>) action.getParamsMap());
        DataRequest dataRequest = new DataRequestImpl(structDef, mutableParamValues, invokedDef);

        // get root XML element from dataProvider
        final DataProvider dataProvider = invokedDef.getProviderInstance(DataProvider.class);
        Element element = dataProvider.getRootElement(dataRequest);
        if (logger.isFine() && !(dataProvider instanceof WSDataProvider)) {
            // TODO: look at root data-provider not most outer provider(filter)
            // TODO: shouldn't each filter log the element at finest so we can see work of each filter
            // WSDataProvider takes care of its own logging
            logger.fine("data-provider {0} returned XML:\n{1}", new Object[] {
                        dataProvider.getClass().getName(), Utils.xmlNodeToString(Utils.toXMLNode(element)) });
        }

        // create XMLDCElement from XML element
        if (element == null) {
            // returning null would cause refresh issues once parameters change and the DC no
            // longer returns null
            element = new EmptyElementProvider().getRootElement(dataRequest);
        }
        final XMLDCElement xmldce = new XMLDCElement(this, structDef, element);

        // write XMLDCElement result to the binding layer
        processResult(xmldce, map, action);

        return true; // true means we handled this call
View Full Code Here

    @Override
    public XMLDCAccessorTarget invokeAccessor(final RowContext rowCtx, final String name, final DataFilter filter) {
        final Object rowDataProvider = rowCtx.getRowDataProvider();
        if (rowDataProvider instanceof XMLDCElement) {
            XMLDCElement elem = (XMLDCElement) rowDataProvider;
            if (!elem.containsAccessor(name)) {
                throw new IllegalArgumentException("XMLDCElement does not have an accessor named : " + name);
            }
            XMLDCAccessorTarget target = (XMLDCAccessorTarget) elem.get(name);
            return target;
        } else {
            throw new IllegalStateException("Unsupported rowDataProvider: " + rowDataProvider);
        }
    }
View Full Code Here

                        ctx.getMasterRowDataProvider(), ctx.getMasterAccessorName(), ctx.getCurrentRowIndex(),
                        ctx.isNullContainer(), ctx.getRowDataContainer(), ctx.getRowDataProvider(),
                        ctx.getRowDataProviderType()
            });
        }
        XMLDCElement master = (XMLDCElement) ctx.getMasterRowDataProvider();
        String accessorName = ctx.getMasterAccessorName();
        XMLDCAccessorTarget newChild;
        if (master.isCollection(accessorName)) {
            if (ctx.isNullContainer()) {
                throw new UnsupportedOperationException("DataControl.createRowData for collection with NullContainer not (yet) supported.");
            }
            XMLDCCollection coll = (XMLDCCollection) ctx.getRowDataContainer();
            newChild = coll.createElement(ctx.getCurrentRowIndex(), master);
        } else {
            Object existingChild = master.get(accessorName);
            if (existingChild instanceof XMLDCAccessorTarget) {
                logger.warning("Ignore the create for {0}.{1} because it already exists.", new Object[] {
                               master, accessorName });
                newChild = (XMLDCAccessorTarget) existingChild;
            } else {
                newChild = master.createChild(accessorName);
            }
        }
        return newChild;
    }
View Full Code Here

                        ctx.getMasterRowDataProvider(), ctx.getMasterAccessorName(), ctx.getCurrentRowIndex(),
                        ctx.isNullContainer(), ctx.getRowDataContainer(), ctx.getRowDataProvider(),
                        ctx.getRowDataProviderType()
            });
        }
        XMLDCElement master = (XMLDCElement) ctx.getMasterRowDataProvider();
        String accessorName = ctx.getMasterAccessorName();
        if (master.isCollection(accessorName)) {
            XMLDCCollection collection = (XMLDCCollection) master.get(accessorName);
            collection.remove(ctx.getCurrentRowIndex());
        } else {
            master.put(accessorName, null);
        }
        return true;
    }
View Full Code Here

                DynamicParameter dynamicParam = findDynamicParameter(paramName, request.getDynamicParams());
                if (dynamicParam.isXml()) {
                    Object dynParVal = request.getDynamicParamValues().get(paramName);
                    if (dynParVal instanceof XMLDCElement) {
                        // dynamic parameter is XMLDCElement, replace #{param.xxx} with org.w3c.dom.Element from XMLDCElement
                        XMLDCElement dcElem = (XMLDCElement) dynParVal;
                        Element elem = dcElem.getElement();
                        Node importedNode = document.importNode(elem, true); // import clones the source node
                        parent.insertBefore(importedNode, node);
                    } else if (dynParVal instanceof Node) {
                        // dynamic parameter is org.w3c.dom.Node (likely Element), replace #{param.xxx} with this Node
                        Node importedNode = document.importNode((Node) dynParVal, true); // import clones the source node
View Full Code Here

TOP

Related Classes of org.adfemg.datacontrol.xml.data.XMLDCElement$Accessor

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.