Search in sources :

Example 6 with HelperContext

use of commonj.sdo.helper.HelperContext in project metro-jax-ws by eclipse-ee4j.

the class SDOBond method deserialize.

private T deserialize(Source src, jakarta.xml.bind.attachment.AttachmentUnmarshaller au) {
    try {
        if (!commonj.sdo.DataObject.class.isAssignableFrom(javaType) && !javaType.isInterface()) {
            return (T) deserializePrimitives(src);
        }
        HelperContext context = parent.getHelperContext();
        SDOAttachmentUnmarshaller unmarshaller = null;
        if (au != null) {
            unmarshaller = new SDOAttachmentUnmarshaller(au);
        }
        DataFactory dataFactory = context.getDataFactory();
        DataObject loadOptions = dataFactory.create(SDOConstants.ORACLE_SDO_URL, SDOConstants.XMLHELPER_LOAD_OPTIONS);
        // bug 8680450
        loadOptions.set(SDOConstants.TYPE_LOAD_OPTION, theType);
        if (unmarshaller != null) {
            loadOptions.set(SDOConstants.ATTACHMENT_UNMARSHALLER_OPTION, unmarshaller);
        }
        XMLDocument xdoc = context.getXMLHelper().load(src, null, loadOptions);
        DataObject obj = xdoc.getRootObject();
        Object o = SDOUtils.unwrapPrimitives(obj);
        // ClassCast possible without check
        return (T) o;
    } catch (Exception e) {
        throw new SDODatabindingException(e);
    }
}
Also used : HelperContext(commonj.sdo.helper.HelperContext) DataObject(commonj.sdo.DataObject) DataObject(commonj.sdo.DataObject) DataFactory(commonj.sdo.helper.DataFactory) XMLDocument(commonj.sdo.helper.XMLDocument) XMLStreamException(javax.xml.stream.XMLStreamException) JAXBException(jakarta.xml.bind.JAXBException)

Example 7 with HelperContext

use of commonj.sdo.helper.HelperContext in project metro-jax-ws by eclipse-ee4j.

the class SDOHRAppServiceTest method doTest.

public void doTest(HRAppService proxy, HelperContext chc) throws Exception {
    java.math.BigDecimal totalComp = proxy.getTotalComp(new BigInteger("222"));
    assertEquals("222", totalComp.toString());
    totalComp = proxy.getTotalComp(new BigInteger("333"));
    assertEquals("333", totalComp.toString());
    doTestGetDeptno("1", proxy);
    doTestGetDeptno("2", proxy);
    doTestGetDeptno("2000", proxy);
    List<Emp> emps = proxy.getManagerAndPeers(new BigInteger("100"));
    assertEquals(3, emps.size());
    for (int i = 0; i < emps.size(); i++) {
        assertEquals("name" + i, emps.get(i).getEname());
        assertEquals("job" + i, emps.get(i).getJob());
    }
    HelperContext context = chc;
    {
        Emp emp = (Emp) context.getDataFactory().create(Emp.class);
        ProcessControl processControl = (ProcessControl) context.getDataFactory().create(ProcessControl.class);
        processControl.setReturnMode("Full");
        emp.setEname("name0");
        List<Emp> empIn = new Vector<Emp>();
        empIn.add(emp);
        emp = (Emp) context.getDataFactory().create(Emp.class);
        emp.setEname("name1");
        empIn.add(emp);
        List<Emp> ret = proxy.processEmps("myoperation", empIn, processControl);
        for (int i = 0; i < ret.size(); i++) {
            assertEquals(ret.get(i).getEname(), empIn.get(i).getEname());
            assertEquals("myoperation", ret.get(i).getJob());
        }
    }
    {
        Emp emp = createEmployee(200, "1", "name", "1000", "fry cook", context);
        Emp ret = proxy.createEmp(emp);
        assertEquals(ret.getEname(), emp.getEname());
        assertEquals(ret.getEmpno(), emp.getEmpno());
        assertEquals(ret.getDeptno(), emp.getDeptno());
        assertEquals(ret.getJob(), emp.getJob());
        doTestGetDeptno("1", proxy);
        doTestGetDeptno("2", proxy);
        doTestGetDeptno("2000", proxy);
    }
}
Also used : ProcessControl(com.sun.xml.ws.sdo.sample.service.types.ProcessControl) BigDecimal(java.math.BigDecimal) HelperContext(commonj.sdo.helper.HelperContext) SDOHelperContext(org.eclipse.persistence.sdo.helper.SDOHelperContext) BigInteger(java.math.BigInteger) Emp(com.sun.xml.ws.sdo.sample.service.types.Emp) List(java.util.List) WSEndpoint(com.sun.xml.ws.api.server.WSEndpoint)

Example 8 with HelperContext

use of commonj.sdo.helper.HelperContext in project metro-jax-ws by eclipse-ee4j.

the class SDOBond method serializePrimitive.

private String serializePrimitive(Object obj, Class<?> contentClass) {
    if (logger.isLoggable(Level.FINEST)) {
        logger.log(Level.FINEST, "Primitive class to be serialized ==> {0}", contentClass);
    }
    HelperContext context = parent.getHelperContext();
    Type type = context.getTypeHelper().getType(contentClass);
    if (type != null) {
        return ((SDODataHelper) context.getDataHelper()).convertToStringValue(obj, type);
    }
    if (logger.isLoggable(Level.FINE)) {
        logger.log(Level.FINE, "Invalid SDO primitive type: {0}", contentClass.getClass().getName());
    }
    throw new SDODatabindingException("Invalid SDO primitive type: " + contentClass.getClass().getName());
}
Also used : Type(commonj.sdo.Type) HelperContext(commonj.sdo.helper.HelperContext) SDODataHelper(org.eclipse.persistence.sdo.helper.SDODataHelper)

Example 9 with HelperContext

use of commonj.sdo.helper.HelperContext in project metro-jax-ws by eclipse-ee4j.

the class SDOBond method serializeDataObject.

private void serializeDataObject(DataObject java, Result result, jakarta.xml.bind.attachment.AttachmentMarshaller am) {
    logger.entering(CLASSNAME, "serializeDataObject");
    try {
        HelperContext context = parent.getHelperContext();
        SDOAttachmentMarshaller marshaller = null;
        if (am != null) {
            marshaller = new SDOAttachmentMarshaller(am);
        }
        // check Primitives for T
        SDOXMLHelper sdoXMLHelper = (SDOXMLHelper) context.getXMLHelper();
        // Bug 8909750 - Toplink already sets this to "GMT".  ADF
        // resets it before we get here, so don't change it again.
        // sdoXMLHelper.setTimeZone(TimeZone.getTimeZone("GMT"));
        sdoXMLHelper.setTimeZoneQualified(true);
        XMLDocument xmlDoc = sdoXMLHelper.createDocument(java, xmlTag.getNamespaceURI(), xmlTag.getLocalPart());
        if (xmlDoc == null) {
            return;
        }
        xmlDoc.setXMLDeclaration(false);
        DataObject saveOptions = null;
        if (marshaller != null) {
            DataFactory dataFactory = parent.getHelperContext().getDataFactory();
            saveOptions = dataFactory.create(SDOConstants.ORACLE_SDO_URL, SDOConstants.XMLHELPER_LOAD_OPTIONS);
            saveOptions.set(SDOConstants.ATTACHMENT_MARSHALLER_OPTION, marshaller);
        }
        sdoXMLHelper.save(xmlDoc, result, saveOptions);
    } catch (Exception e) {
        throw new SDODatabindingException(e);
    }
}
Also used : HelperContext(commonj.sdo.helper.HelperContext) DataObject(commonj.sdo.DataObject) DataFactory(commonj.sdo.helper.DataFactory) SDOXMLHelper(org.eclipse.persistence.sdo.helper.SDOXMLHelper) XMLDocument(commonj.sdo.helper.XMLDocument) XMLStreamException(javax.xml.stream.XMLStreamException) JAXBException(jakarta.xml.bind.JAXBException)

Example 10 with HelperContext

use of commonj.sdo.helper.HelperContext in project metro-jax-ws by eclipse-ee4j.

the class SDOContextWrapper method getTypeName.

@Override
public QName getTypeName(TypeInfo tr) {
    QName res = model.getXsdTypeName(((Class<?>) tr.type).getName());
    if (res != null) {
        return res;
    }
    HelperContext hc = contextResolver.getHelperContext(isClient, serviceName, properties);
    TypeHelper th = hc.getTypeHelper();
    Type t = th.getType((Class<?>) tr.type);
    XSDHelper helper = hc.getXSDHelper();
    String localName = helper.getLocalName(t);
    String namespaceURI = helper.getNamespaceURI(t);
    if (namespaceURI == null) {
        namespaceURI = t.getURI();
    }
    if (localName == null) {
        localName = t.getName();
    }
    return new QName(namespaceURI == null ? "" : namespaceURI, localName);
}
Also used : TypeHelper(commonj.sdo.helper.TypeHelper) Type(commonj.sdo.Type) HelperContext(commonj.sdo.helper.HelperContext) SDOHelperContext(org.eclipse.persistence.sdo.helper.SDOHelperContext) QName(javax.xml.namespace.QName) XSDHelper(commonj.sdo.helper.XSDHelper)

Aggregations

HelperContext (commonj.sdo.helper.HelperContext)10 SDOHelperContext (org.eclipse.persistence.sdo.helper.SDOHelperContext)7 SchemaInfo (com.sun.xml.ws.db.sdo.SchemaInfo)5 QName (javax.xml.namespace.QName)5 DatabindingModeFeature (com.oracle.webservices.api.databinding.DatabindingModeFeature)4 DatabindingConfig (com.sun.xml.ws.api.databinding.DatabindingConfig)4 HelperContextResolver (com.sun.xml.ws.db.sdo.HelperContextResolver)4 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)4 File (java.io.File)3 List (java.util.List)3 Map (java.util.Map)3 WSEndpoint (com.sun.xml.ws.api.server.WSEndpoint)2 Emp (com.sun.xml.ws.sdo.sample.service.types.Emp)2 ProcessControl (com.sun.xml.ws.sdo.sample.service.types.ProcessControl)2 MySDO (com.sun.xml.ws.sdo.test.helloSDO.MySDO)2 BindingContext (com.sun.xml.ws.spi.db.BindingContext)2 DataObject (commonj.sdo.DataObject)2 Type (commonj.sdo.Type)2 DataFactory (commonj.sdo.helper.DataFactory)2 XMLDocument (commonj.sdo.helper.XMLDocument)2