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);
}
}
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);
}
}
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());
}
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);
}
}
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);
}
Aggregations