Package commonj.sdo.helper

Examples of commonj.sdo.helper.HelperContext


    }

    @Override
    public boolean introspect(DataType dataType, Annotation[] annotations) {
        Class javaType = dataType.getPhysical();
        HelperContext context = HelperProvider.getDefaultContext();
        // FIXME: Need a better to test dynamic SDO
        if (DataObject.class.isAssignableFrom(javaType)) {
            // Dynamic SDO
            dataType.setDataBinding(getName());
            if (dataType.getLogical() == null) {
                dataType.setLogical(XMLType.UNKNOWN);
            }
            return true;
        }
        // FIXME: We need to access HelperContext
        Type type = context.getTypeHelper().getType(javaType);
        if (type == null) {
            return false;
        }
        if (type.isDataType()) {
            // FIXME: Ignore simple types?
            return false;
        }
        String namespace = type.getURI();
        String name = context.getXSDHelper().getLocalName(type);
        QName xmlType = new QName(namespace, name);
        dataType.setDataBinding(getName());
        QName elementName = null;
        Object logical = dataType.getLogical();
        if (logical instanceof XMLType) {
View Full Code Here


        return new SDOSimpleTypeMapper();
    }

    @Override
    public Object copy(Object arg) {
        HelperContext context = HelperProvider.getDefaultContext();
        CopyHelper copyHelper = context.getCopyHelper();
        if (arg instanceof XMLDocument) {
            XMLDocument document = (XMLDocument)arg;
            DataObject dataObject = copyHelper.copy(document.getRootObject());
            return context.getXMLHelper().createDocument(dataObject,
                                                         document.getRootElementURI(),
                                                         document.getRootElementName());
        } else if (arg instanceof DataObject) {
            return context.getCopyHelper().copy((DataObject)arg);
        } else {
            return super.copy(arg);
        }
    }
View Full Code Here

        List children = handler.getChildren(document, null, null);
        assertEquals(5, children.size());
    }
   
    public void testCreate() {
        HelperContext context = HelperProvider.getDefaultContext();
        XSDHelper xsdHelper = context.getXSDHelper();
        xsdHelper.define(getClass().getResourceAsStream("/wrapper.xsd"), null);
        ElementInfo element = new ElementInfo(new QName("http://www.example.com/wrapper", "op"), null);
        DataObject wrapper = (DataObject) handler.create(element, null);
        assertNotNull(wrapper);
    }
View Full Code Here

        List children = handler.getChildren(document, op, true);
        assertEquals(5, children.size());
    }
   
    public void testCreate() {
        HelperContext context = HelperProvider.getDefaultContext();
        XSDHelper xsdHelper = context.getXSDHelper();
        xsdHelper.define(getClass().getResourceAsStream("/wrapper.xsd"), null);
        ElementInfo element = new ElementInfo(new QName("http://www.example.com/wrapper", "op"), null);
        Operation op = new OperationImpl();
        WrapperInfo wrapperInfo = new WrapperInfo(SDODataBinding.NAME, element, null);
        op.setInputWrapper(wrapperInfo);
View Full Code Here

    public Object toJavaObject(QName typeName, String value, TransformationContext context) {
        Type type = null;
        if (URI_2001_SCHEMA_XSD.equals(typeName.getNamespaceURI())) {
            type = SDOUtil.getXSDSDOType(typeName.getLocalPart());
        } else {
            HelperContext helperContext = SDOContextHelper.getHelperContext(context, false);
            TypeHelper typeHelper = helperContext.getTypeHelper();
            type = typeHelper.getType(typeName.getNamespaceURI(), typeName.getLocalPart());
        }
        return SDOUtil.createFromString(type, value);
    }
View Full Code Here

    public String toXMLLiteral(QName typeName, Object obj, TransformationContext context) {
        Type type = null;
        if (URI_2001_SCHEMA_XSD.equals(typeName.getNamespaceURI())) {
            type = SDOUtil.getXSDSDOType(typeName.getLocalPart());
        } else {
            HelperContext helperContext = SDOContextHelper.getHelperContext(context, true);
            TypeHelper typeHelper = helperContext.getTypeHelper();
            type = typeHelper.getType(typeName.getNamespaceURI(), typeName.getLocalPart());
        }
        return SDOUtil.convertToString(type, obj);
    }
View Full Code Here

            // Load the config file into a stream
            fis = new FileInputStream(projectBuildDir + "/classes/generate/generate.xml");

            // Load the stream into SDO
            // We are just using SDO as a convenient way to parse the XML config file
            HelperContext scope       = SDOUtil.createHelperContext();
            GenerateFactory.INSTANCE.register(scope);
            XMLDocument xmlDoc        = scope.getXMLHelper().load(fis);
            GenerateType generateType = (GenerateType)xmlDoc.getRootObject();

            // Get the file list. This is the list of XSD that is passed into the
            // the velocity templates. Each configured file holds a list of types
            // that the velocity templates expand into appropriate methods and method calls          
View Full Code Here

            // Load the config file into a stream
            fis = new FileInputStream(projectBuildDir + "/classes/generate/generate.xml");

            // Load the stream into SDO
            // We are just using SDO as a convenient way to parse the XML config file
            HelperContext scope       = SDOUtil.createHelperContext();
            GenerateFactory.INSTANCE.register(scope);
            XMLDocument xmlDoc        = scope.getXMLHelper().load(fis);
            GenerateType generateType = (GenerateType)xmlDoc.getRootObject();

            // Get the file list. This is the list of XSD that is passed into the
            // the velocity templates. Each configured file holds a list of types
            // that the velocity templates expand into appropriate methods and method calls          
View Full Code Here

*/
public class DataObject2OMElement extends BaseTransformer<DataObject, OMElement> implements
    PullTransformer<DataObject, OMElement> {

    public OMElement transform(DataObject source, TransformationContext context) {
        HelperContext helperContext = SDOContextHelper.getHelperContext(context, true);
        OMFactory factory = OMAbstractFactory.getOMFactory();

        QName name  = ROOT_ELEMENT;
        if (context != null) {
            DataType dataType = context.getTargetDataType();
            Object logical = dataType == null ? null : dataType.getLogical();
            if (logical instanceof XMLType) {
                XMLType xmlType = (XMLType)logical;
                if (xmlType.isElement()) {
                    name = xmlType.getElementName();
                }
            }
        }

        XMLDocument document = helperContext.getXMLHelper().createDocument(source,
                                                                           name.getNamespaceURI(),
                                                                           name.getLocalPart());
        SDODataSource dataSource = new SDODataSource(document, helperContext);
        OMElement element = AxiomHelper.createOMElement(factory, name, dataSource);
        return element;
View Full Code Here

    @Override
    public boolean introspect(DataType dataType, final Operation operation) {
        final Class javaType = dataType.getPhysical();
        // Allow privileged access to read system properties. Requires PropertyPermission
        // java.specification.version read in security policy.
        final HelperContext context = AccessController.doPrivileged(new PrivilegedAction<HelperContext>() {
            public HelperContext run() {
                return SDOContextHelper.getHelperContext(operation);
            }
        });

        final Type type = context.getTypeHelper().getType(javaType);
        if (type == null) {
            // FIXME: Need a better to test dynamic SDO
            if (DataObject.class.isAssignableFrom(javaType)) {
                // Dynamic SDO
                dataType.setDataBinding(getName());
                if (dataType.getLogical() == null) {
                    dataType.setLogical(XMLType.UNKNOWN);
                }
                return true;
            }
            return false;
        }
        if (type.isDataType()) {
            // FIXME: Ignore simple types?
            return false;
        }

        // Found a SDO type, replace the default context with a private one
        AccessController.doPrivileged(new PrivilegedAction<Object>() {
            public Object run() {
                if (context == SDOContextHelper.getDefaultHelperContext()) {
                    HelperContext newContext = SDOUtil.createHelperContext();
                    SDOContextHelper.register(newContext, type);
                    if (operation != null) {
                        operation.getInputType().setMetaData(HelperContext.class, newContext);
                    }
                } else {
View Full Code Here

TOP

Related Classes of commonj.sdo.helper.HelperContext

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.