Package org.apache.tuscany.spi.idl

Examples of org.apache.tuscany.spi.idl.ElementInfo


    public Java2SimpleTypeTransformer(SimpleTypeMapper mapper) {
        this.mapper = (mapper != null) ? mapper : new SimpleTypeMapperExtension();
    }

    public T transform(Object source, TransformationContext context) {
        ElementInfo element =
                (ElementInfo) context.getTargetDataType().getMetadata(ElementInfo.class.getName());
        TypeInfo simpleType = (TypeInfo) element.getType();
        String text = mapper.toXMLLiteral(simpleType, source, context);
        return createElement(element, text, context);
    }
View Full Code Here


            return unwrappedOutputType;
        }

        public WrapperInfo getWrapperInfo() throws InvalidServiceContractException {
            if (wrapperInfo == null) {
                ElementInfo in = getElementInfo(getInputWrapperElement());
                ElementInfo out = getElementInfo(getOutputWrapperElement());
                List<ElementInfo> inChildren = new ArrayList<ElementInfo>();
                for (XmlSchemaElement e : getInputChildElements()) {
                    inChildren.add(getElementInfo(e));
                }
                List<ElementInfo> outChildren = new ArrayList<ElementInfo>();
View Full Code Here

                    targetWrapperHandler.create(wrapper.getOutputWrapperElement(), context);
                if (response == null) {
                    return targetWrapper;
                }

                ElementInfo argElement = wrapper.getOutputChildElements().get(0);
                DataType<QName> argType = wrapper.getUnwrappedOutputType();
                Object child = response;
                child = mediator.mediate(response, sourceType.getLogical(), argType, context.getMetadata());
                targetWrapperHandler.setChild(targetWrapper, 0, argElement, child);
                return targetWrapper;
            } else if (sourceWrapped && (!targetWrapped)) {
                // Wrapped to Unwrapped
                Object sourceWrapper = response;
                List<ElementInfo> childElements = sourceOp.getWrapper().getOutputChildElements();
                ElementInfo childElement = childElements.get(0);

                targetWrapperHandler = getWapperHandler(targetType.getLogical().getDataBinding());
                if (targetWrapperHandler != null) {
                    ElementInfo wrapperElement = sourceOp.getWrapper().getInputWrapperElement();
                    // Object targetWrapper =
                    // targetWrapperHandler.create(wrapperElement, context);
                    DataType<QName> targetWrapperType =
                        new DataType<QName>(targetType.getLogical().getDataBinding(), Object.class,
                                            wrapperElement.getQName());
                    Object targetWrapper =
                        mediator.mediate(sourceWrapper, sourceType.getLogical(), targetWrapperType, context
                            .getMetadata());
                    return targetWrapperHandler.getChild(targetWrapper, 0, childElement);
                } else {
View Full Code Here

        }

        if ((!sourceWrapped) && targetWrapped) {
            // Unwrapped --> Wrapped
            WrapperInfo wrapper = targetOp.getWrapper();
            ElementInfo wrapperElement = wrapper.getInputWrapperElement();

            // If the source can be wrapped, wrapped it first
            if (sourceWrapperHandler != null) {
                Object sourceWrapper = sourceWrapperHandler.create(wrapperElement, context);
                for (int i = 0; i < source.length; i++) {
                    ElementInfo argElement = wrapper.getInputChildElements().get(i);
                    sourceWrapperHandler.setChild(sourceWrapper, i, argElement, source[0]);
                }
            }
            Object targetWrapper = targetWrapperHandler.create(wrapperElement, context);
            if (source == null) {
                return new Object[] {targetWrapper};
            }
            List<DataType<QName>> argTypes = wrapper.getUnwrappedInputType().getLogical();

            for (int i = 0; i < source.length; i++) {
                ElementInfo argElement = wrapper.getInputChildElements().get(i);
                DataType<QName> argType = argTypes.get(i);
                Object child = source[i];
                child =
                    mediator.mediate(source[i], sourceType.getLogical().get(i), argType, context
                        .getMetadata());
                targetWrapperHandler.setChild(targetWrapper, i, argElement, child);
            }
            return new Object[] {targetWrapper};
        } else if (sourceWrapped && (!targetWrapped)) {
            // Wrapped to Unwrapped
            Object sourceWrapper = source[0];
            List<ElementInfo> childElements = sourceOp.getWrapper().getInputChildElements();
            Object[] target = new Object[childElements.size()];

            targetWrapperHandler = getWapperHandler(targetType.getLogical().get(0).getDataBinding(), false);
            if (targetWrapperHandler != null) {
                ElementInfo wrapperElement = sourceOp.getWrapper().getInputWrapperElement();
                // Object targetWrapper =
                // targetWrapperHandler.create(wrapperElement, context);
                DataType<QName> targetWrapperType =
                    new DataType<QName>(targetType.getLogical().get(0).getDataBinding(), Object.class,
                                        wrapperElement.getQName());
                Object targetWrapper =
                    mediator.mediate(sourceWrapper,
                                     sourceType.getLogical().get(0),
                                     targetWrapperType,
                                     context.getMetadata());
                for (int i = 0; i < childElements.size(); i++) {
                    ElementInfo childElement = childElements.get(i);
                    target[i] = targetWrapperHandler.getChild(targetWrapper, i, childElement);
                }
            } else {
                for (int i = 0; i < childElements.size(); i++) {
                    ElementInfo childElement = childElements.get(i);
                    Object child = sourceWrapperHandler.getChild(sourceWrapper, i, childElement);
                    DataType<QName> childType =
                        sourceOp.getWrapper().getUnwrappedInputType().getLogical().get(i);
                    target[i] =
                        mediator.mediate(child, childType, targetType.getLogical().get(i), context
View Full Code Here

    }

    public Object transform(T source, TransformationContext context) {
        TypeInfo simpleType = (TypeInfo)context.getSourceDataType().getMetadata(TypeInfo.class.getName());
        if (simpleType == null) {
            ElementInfo element =
                (ElementInfo)context.getSourceDataType().getMetadata(ElementInfo.class.getName());
            simpleType = (TypeInfo)element.getType();
        }
        return mapper.toJavaObject(simpleType, getText(source), context);
    }
View Full Code Here

        public ObjectFactoryImpl(Property<P> property, PropertyValue<P> propertyValue) {
            this.property = property;
            this.propertyValue = propertyValue;
            sourceDataType = new DataType<QName>(DOMDataBinding.NAME, Node.class, this.property.getXmlType());
            TypeInfo typeInfo = new TypeInfo(property.getXmlType(), true, null);
            ElementInfo elementInfo = new ElementInfo(null, typeInfo);
            sourceDataType.setMetadata(ElementInfo.class.getName(), elementInfo);
            Class javaType = this.property.getJavaType();
            String dataBinding = (String)property.getExtensions().get(DataBinding.class.getName());
            if (dataBinding != null) {
                targetDataType = new DataType<Class>(dataBinding, javaType, javaType);
View Full Code Here

        DataType<List<DataType<QName>>> unwrappedInputType = op.getWrapper().getUnwrappedInputType();
        List<DataType<QName>> childTypes = unwrappedInputType.getLogical();
        Assert.assertEquals(1, childTypes.size());
        DataType<QName> childType = childTypes.get(0);
        Assert.assertEquals(new QName(null, "tickerSymbol"), childType.getLogical());
        ElementInfo element = (ElementInfo) childType.getMetadata(ElementInfo.class.getName());
        Assert.assertNotNull(element);
       
        childType = op.getWrapper().getUnwrappedOutputType();
        Assert.assertEquals(new QName(null, "price"), childType.getLogical());
        element = (ElementInfo) childType.getMetadata(ElementInfo.class.getName());
View Full Code Here

    private static ElementInfo getElementInfo(XmlSchemaElement element) {
        if (element == null) {
            return null;
        }
        return new ElementInfo(element.getQName(), getTypeInfo(element.getSchemaType()));
    }
View Full Code Here

                                                              null);
        op.setDataBinding(DOMDataBinding.NAME);

        inputType0.setMetadata(OPERATION_KEY, op);
        op.setWrapperStyle(true);
        ElementInfo inputElement =
            new ElementInfo(new QName(URI_ORDER_XSD, "checkOrderStatus"), new TypeInfo(null, false, null));
        wrapperType.setMetadata(ElementInfo.class.getName(), inputElement);

        ElementInfo customerId =
            new ElementInfo(new QName("", "customerId"), SimpleTypeMapperExtension.XSD_SIMPLE_TYPES
                .get("string"));
        ElementInfo order =
            new ElementInfo(new QName("", "order"), new TypeInfo(new QName(URI_ORDER_XSD), false, null));
        ElementInfo flag =
            new ElementInfo(new QName("", "flag"), SimpleTypeMapperExtension.XSD_SIMPLE_TYPES.get("int"));

        customerIdType.setMetadata(ElementInfo.class.getName(), customerId);
        orderType.setMetadata(ElementInfo.class.getName(), order);
        flagType.setMetadata(ElementInfo.class.getName(), flag);

        customerIdType.setMetadata(OPERATION_KEY, op);
        orderType.setMetadata(OPERATION_KEY, op);
        flagType.setMetadata(OPERATION_KEY, op);

        List<ElementInfo> inputElements = new ArrayList<ElementInfo>();
        inputElements.add(customerId);
        inputElements.add(order);
        inputElements.add(flag);

        ElementInfo statusElement =
            new ElementInfo(new QName("", "status"), SimpleTypeMapperExtension.XSD_SIMPLE_TYPES.get("string"));

        statusType.setMetadata(ElementInfo.class.getName(), statusElement);
        statusType.setMetadata(OPERATION_KEY, op);

        List<ElementInfo> outputElements = new ArrayList<ElementInfo>();
        outputElements.add(statusElement);

        ElementInfo outputElement =
            new ElementInfo(new QName(URI_ORDER_XSD, "checkOrderStatusResponse"), new TypeInfo(null, false,
                                                                                               null));

        responseType.setMetadata(ElementInfo.class.getName(), inputElement);
        responseType.setMetadata(OPERATION_KEY, op);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.spi.idl.ElementInfo

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.