use of org.apache.openejb.jee.ResultTypeMapping in project tomee by apache.
the class Query$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final Query query, RuntimeContext context) throws Exception {
if (query == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (Query.class != query.getClass()) {
context.unexpectedSubclass(writer, query, Query.class);
return;
}
context.beforeMarshal(query, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = query.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(query, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: description
final Text description = query.description;
if (description != null) {
writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
writeText(writer, description, context);
writer.writeEndElement();
}
// ELEMENT: queryMethod
final QueryMethod queryMethod = query.queryMethod;
if (queryMethod != null) {
writer.writeStartElement(prefix, "query-method", "http://java.sun.com/xml/ns/javaee");
writeQueryMethod(writer, queryMethod, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(query, "queryMethod");
}
// ELEMENT: resultTypeMapping
final ResultTypeMapping resultTypeMapping = query.resultTypeMapping;
if (resultTypeMapping != null) {
writer.writeStartElement(prefix, "result-type-mapping", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(toStringResultTypeMapping(query, null, context, resultTypeMapping));
writer.writeEndElement();
}
// ELEMENT: ejbQl
final String ejbQlRaw = query.ejbQl;
String ejbQl = null;
try {
ejbQl = Adapters.collapsedStringAdapterAdapter.marshal(ejbQlRaw);
} catch (final Exception e) {
context.xmlAdapterError(query, "ejbQl", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (ejbQl != null) {
writer.writeStartElement(prefix, "ejb-ql", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(ejbQl);
writer.writeEndElement();
} else {
context.unexpectedNullValue(query, "ejbQl");
}
context.afterMarshal(query, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.ResultTypeMapping in project tomee by apache.
the class Query$JAXB method _read.
public static final Query _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final Query query = new Query();
context.beforeUnmarshal(query, LifecycleCallback.NONE);
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("queryType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, Query.class);
}
}
// Read attributes
for (final Attribute attribute : reader.getAttributes()) {
if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
// ATTRIBUTE: id
final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
context.addXmlId(reader, id, query);
query.id = id;
} else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
context.unexpectedAttribute(attribute, new QName("", "id"));
}
}
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("description" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: description
final Text description = readText(elementReader, context);
query.description = description;
} else if (("query-method" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: queryMethod
final QueryMethod queryMethod = readQueryMethod(elementReader, context);
query.queryMethod = queryMethod;
} else if (("result-type-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: resultTypeMapping
final ResultTypeMapping resultTypeMapping = parseResultTypeMapping(elementReader, context, elementReader.getElementAsString());
if (resultTypeMapping != null) {
query.resultTypeMapping = resultTypeMapping;
}
} else if (("ejb-ql" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbQl
final String ejbQlRaw = elementReader.getElementAsString();
final String ejbQl;
try {
ejbQl = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbQlRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
query.ejbQl = ejbQl;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "query-method"), new QName("http://java.sun.com/xml/ns/javaee", "result-type-mapping"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-ql"));
}
}
context.afterUnmarshal(query, LifecycleCallback.NONE);
return query;
}
use of org.apache.openejb.jee.ResultTypeMapping in project tomee by apache.
the class EjbJarInfoBuilder method initEntityBean.
private EnterpriseBeanInfo initEntityBean(final EntityBean e, final Map m) throws OpenEJBException {
final EntityBeanInfo bean = new EntityBeanInfo();
final EjbDeployment d = (EjbDeployment) m.get(e.getEjbName());
if (d == null) {
throw new OpenEJBException("No deployment information in openejb-jar.xml for bean " + e.getEjbName() + ". Please redeploy the jar");
}
bean.ejbDeploymentId = d.getDeploymentId();
bean.containerId = d.getContainerId();
final Icon icon = e.getIcon();
bean.largeIcon = icon == null ? null : icon.getLargeIcon();
bean.smallIcon = icon == null ? null : icon.getSmallIcon();
bean.description = e.getDescription();
bean.displayName = e.getDisplayName();
bean.ejbClass = e.getEjbClass();
bean.abstractSchemaName = e.getAbstractSchemaName();
bean.ejbName = e.getEjbName();
bean.home = e.getHome();
bean.remote = e.getRemote();
bean.localHome = e.getLocalHome();
bean.local = e.getLocal();
bean.transactionType = "Container";
bean.primKeyClass = e.getPrimKeyClass();
bean.primKeyField = e.getPrimkeyField();
bean.persistenceType = e.getPersistenceType().toString();
bean.reentrant = String.valueOf(e.getReentrant());
bean.properties.putAll(d.getProperties());
final CmpVersion cmpVersion = e.getCmpVersion();
if (e.getPersistenceType() == PersistenceType.CONTAINER) {
if (cmpVersion != null && cmpVersion == CmpVersion.CMP1) {
bean.cmpVersion = 1;
} else {
bean.cmpVersion = 2;
}
}
final List<CmpField> cmpFields = e.getCmpField();
for (final CmpField cmpField : cmpFields) {
bean.cmpFieldNames.add(cmpField.getFieldName());
}
if (bean.persistenceType.equalsIgnoreCase("Container")) {
for (final Query q : e.getQuery()) {
final QueryInfo query = new QueryInfo();
query.queryStatement = q.getEjbQl().trim();
final MethodInfo method = new MethodInfo();
method.ejbName = bean.ejbName;
method.className = "*";
final QueryMethod qm = q.getQueryMethod();
method.methodName = qm.getMethodName();
if (qm.getMethodParams() != null) {
method.methodParams = qm.getMethodParams().getMethodParam();
}
query.method = method;
final ResultTypeMapping resultType = q.getResultTypeMapping();
if (ResultTypeMapping.REMOTE.equals(resultType)) {
query.remoteResultType = true;
}
bean.queries.add(query);
}
for (final org.apache.openejb.jee.oejb3.Query q : d.getQuery()) {
final QueryInfo query = new QueryInfo();
query.description = q.getDescription();
query.queryStatement = q.getObjectQl().trim();
final MethodInfo method = new MethodInfo();
method.ejbName = bean.ejbName;
method.className = "*";
final org.apache.openejb.jee.oejb3.QueryMethod qm = q.getQueryMethod();
method.methodName = qm.getMethodName();
if (qm.getMethodParams() != null) {
method.methodParams = qm.getMethodParams().getMethodParam();
}
query.method = method;
bean.queries.add(query);
}
}
return bean;
}
Aggregations