|
Re: ProvideAndRegisterDocumentSetType --> OMElement [message #46040 is a reply to message #45932] |
Tue, 19 August 2008 19:44 |
Matthew Davis Messages: 269 Registered: July 2009 |
Senior Member |
|
|
Hi Stefan,
Indeed this is --- kinda simple. So, one thing to start with is - when
sending the payload to the registry from a repository, you will need to
convert from the ProvideAndRegisterDocumentSetType back to an ebXML
SubmitObjectsRequestType. Once you're back into that type, then you can
submit to the repository.
The way we handle this in the XDS Source and XDS Consumer is
straightforward. In general, it requires three things:
1. Convert the ProvideAndRegisterDocumentSetType (XDS) object to
SubmitObjectsRequestType (ebXML) object
2. Convert the EMF-created SubmitObjectsRequestType object to a DOM object
3. Convert the DOM object to OM for use with Axis2.
Converting from ProvideAndRegisterDocumentSetType (XDS) object to
SubmitObjectsRequestType (ebXML) object
---
For XDS.a:
EbXML_2_1ProvideAndRegisterDocumentSetTransformer setTransformer = new
EbXML_2_1ProvideAndRegisterDocumentSetTransformer();
setTransformer.transform(prDocumentSetTypeObject);
SubmitObjectsRequestType submitObjectsRequest =
setTransformer.getSubmitReq()
For XDS.b:
EbXML_3_0ProvideAndRegisterDocumentSetTransformer setTransformer = new
EbXML_3_0ProvideAndRegisterDocumentSetTransformer();
setTransformer.transform(prDocumentSetTypeObject);
SubmitObjectsRequestType submitObjectsRequest =
setTransformer.getSubmitReq()
Converting from EMF to DOM
---
This conversion requires the creation of an empty DOM Document and then
using the EMF XMLResource's "save" method to save EMF to DOM. Code
snippet looks something like this:
// Create DOM Document Instance
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
org.w3c.dom.Document domDocument = builder.newDocument();
// Convert / "save" EMF to DOM
RegistryPackage packageInstance = RegistryPackage.eINSTANCE;
DocumentRoot root = RegistryFactory.eINSTANCE.createDocumentRoot();
root.setSubmitObjectsRequest(submitObjectsRequest);
XMLResource resource = (XMLResource)(new
RegistryResourceFactoryImpl()).createResource(URI.createURI( RegistryPackage.eNS_URI));
resource.getContents().add(root);
resource.save(domDocument, new HashMap(), new DefaultDOMHandlerImpl());
resource.unload();
Element domElement = domDocument.getDocumentElement();
Converting from DOM to OM
---
Apache Axis provides a utility to convert from DOM to OM (and back).
Use this:
OMElement omElement = org.apache.axis2.util.XMLUtils.toOM(domElement);
The P&R element should now be "sendable" over the wire.
I put this together pretty fast, so I'm sure I missed something, but
might give it a try!
-Matt
Stefan S. wrote:
> Hi Everybody!
>
> I have a very basic question - at least I hope it is basic ;) - that is
> bothering me for days now!
>
> I have metadata - received by an ITI-15 request - in form of an
> ProvideAndRegisterDocumentSetType. Now I am changing and adding some
> specific attributes. As an example - just for testing - I am trying to
> add a XDSDocumentEntry.size to every DocumentEntryType with a simple
> loop like:
>
> for (DocumentEntryType documentEntry :
> (EList<DocumentEntryType>)xdsMetadata.getDocumentEntry()) {
> documentEntry.setSize("123456");
> }
>
> Now my problem is, that I want to send this "modified" metadata to an
> IHE Registry using ITI-14.
> Therefore I have to convert this metadata
> -ProvideAndRegisterDocumentSetType - to an OMElement.
>
> But I am really stuck on how to solve this problem.
> I hope someone can help me!
>
> Thanks in Advance for both your time and your knowledge!
>
> Greetings
> Stefan
>
|
|
|
|
|
Re: ProvideAndRegisterDocumentSetType --> OMElement [message #46342 is a reply to message #46131] |
Thu, 21 August 2008 01:24 |
Matthew Davis Messages: 269 Registered: July 2009 |
Senior Member |
|
|
Ah - good catch! I shouldn't have been as ambiguous with those Java
package names. Thanks for the clarification!
-Matt
Stefan S. wrote:
> Hi Matt!
>
> After examining your code fragment in detail I stumbled across the
> following "problem" and would like to present my solution, just in case
> someone experiences the same problem.
>
> The presented example contains the following:
>
> // Convert / "save" EMF to DOM
> RegistryPackage packageInstance = RegistryPackage.eINSTANCE;
> DocumentRoot root = RegistryFactory.eINSTANCE.createDocumentRoot();
> root.setSubmitObjectsRequest(submitObjectsRequest);
>
> The "problem" is, that the class/interface DocumentRoot -
> org.eclipse.ohf.ihe.common.ebxml._3._0.rs.DocumentRoot - as returned by
> RegistryFactory.eINSTANCE.createDocumentRoot() does not contain a method
> "setSubmitObjectsRequest".
>
> My "solution" - or approach - is to use the method
> "setRegisterRequest()", as shown in the lines below:
>
> org.eclipse.ohf.ihe.common.ebxml._3._0.rs.DocumentRoot root =
> RegistryFactory.eINSTANCE.createDocumentRoot();
> root.setRegistryRequest(submitObjectsRequest);
>
> It seems to work, so I think the "problem" is saved. Thanks again for
> your help!
>
> Greetings
> Stefan
>
|
|
|
Re: ProvideAndRegisterDocumentSetType --> OMElement [message #586885 is a reply to message #45932] |
Tue, 19 August 2008 19:44 |
Matthew Davis Messages: 269 Registered: July 2009 |
Senior Member |
|
|
Hi Stefan,
Indeed this is --- kinda simple. So, one thing to start with is - when
sending the payload to the registry from a repository, you will need to
convert from the ProvideAndRegisterDocumentSetType back to an ebXML
SubmitObjectsRequestType. Once you're back into that type, then you can
submit to the repository.
The way we handle this in the XDS Source and XDS Consumer is
straightforward. In general, it requires three things:
1. Convert the ProvideAndRegisterDocumentSetType (XDS) object to
SubmitObjectsRequestType (ebXML) object
2. Convert the EMF-created SubmitObjectsRequestType object to a DOM object
3. Convert the DOM object to OM for use with Axis2.
Converting from ProvideAndRegisterDocumentSetType (XDS) object to
SubmitObjectsRequestType (ebXML) object
---
For XDS.a:
EbXML_2_1ProvideAndRegisterDocumentSetTransformer setTransformer = new
EbXML_2_1ProvideAndRegisterDocumentSetTransformer();
setTransformer.transform(prDocumentSetTypeObject);
SubmitObjectsRequestType submitObjectsRequest =
setTransformer.getSubmitReq()
For XDS.b:
EbXML_3_0ProvideAndRegisterDocumentSetTransformer setTransformer = new
EbXML_3_0ProvideAndRegisterDocumentSetTransformer();
setTransformer.transform(prDocumentSetTypeObject);
SubmitObjectsRequestType submitObjectsRequest =
setTransformer.getSubmitReq()
Converting from EMF to DOM
---
This conversion requires the creation of an empty DOM Document and then
using the EMF XMLResource's "save" method to save EMF to DOM. Code
snippet looks something like this:
// Create DOM Document Instance
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
org.w3c.dom.Document domDocument = builder.newDocument();
// Convert / "save" EMF to DOM
RegistryPackage packageInstance = RegistryPackage.eINSTANCE;
DocumentRoot root = RegistryFactory.eINSTANCE.createDocumentRoot();
root.setSubmitObjectsRequest(submitObjectsRequest);
XMLResource resource = (XMLResource)(new
RegistryResourceFactoryImpl()).createResource(URI.createURI( RegistryPackage.eNS_URI));
resource.getContents().add(root);
resource.save(domDocument, new HashMap(), new DefaultDOMHandlerImpl());
resource.unload();
Element domElement = domDocument.getDocumentElement();
Converting from DOM to OM
---
Apache Axis provides a utility to convert from DOM to OM (and back).
Use this:
OMElement omElement = org.apache.axis2.util.XMLUtils.toOM(domElement);
The P&R element should now be "sendable" over the wire.
I put this together pretty fast, so I'm sure I missed something, but
might give it a try!
-Matt
Stefan S. wrote:
> Hi Everybody!
>
> I have a very basic question - at least I hope it is basic ;) - that is
> bothering me for days now!
>
> I have metadata - received by an ITI-15 request - in form of an
> ProvideAndRegisterDocumentSetType. Now I am changing and adding some
> specific attributes. As an example - just for testing - I am trying to
> add a XDSDocumentEntry.size to every DocumentEntryType with a simple
> loop like:
>
> for (DocumentEntryType documentEntry :
> (EList<DocumentEntryType>)xdsMetadata.getDocumentEntry()) {
> documentEntry.setSize("123456");
> }
>
> Now my problem is, that I want to send this "modified" metadata to an
> IHE Registry using ITI-14.
> Therefore I have to convert this metadata
> -ProvideAndRegisterDocumentSetType - to an OMElement.
>
> But I am really stuck on how to solve this problem.
> I hope someone can help me!
>
> Thanks in Advance for both your time and your knowledge!
>
> Greetings
> Stefan
>
|
|
|
|
|
Re: ProvideAndRegisterDocumentSetType --> OMElement [message #587006 is a reply to message #46131] |
Thu, 21 August 2008 01:24 |
Matthew Davis Messages: 269 Registered: July 2009 |
Senior Member |
|
|
Ah - good catch! I shouldn't have been as ambiguous with those Java
package names. Thanks for the clarification!
-Matt
Stefan S. wrote:
> Hi Matt!
>
> After examining your code fragment in detail I stumbled across the
> following "problem" and would like to present my solution, just in case
> someone experiences the same problem.
>
> The presented example contains the following:
>
> // Convert / "save" EMF to DOM
> RegistryPackage packageInstance = RegistryPackage.eINSTANCE;
> DocumentRoot root = RegistryFactory.eINSTANCE.createDocumentRoot();
> root.setSubmitObjectsRequest(submitObjectsRequest);
>
> The "problem" is, that the class/interface DocumentRoot -
> org.eclipse.ohf.ihe.common.ebxml._3._0.rs.DocumentRoot - as returned by
> RegistryFactory.eINSTANCE.createDocumentRoot() does not contain a method
> "setSubmitObjectsRequest".
>
> My "solution" - or approach - is to use the method
> "setRegisterRequest()", as shown in the lines below:
>
> org.eclipse.ohf.ihe.common.ebxml._3._0.rs.DocumentRoot root =
> RegistryFactory.eINSTANCE.createDocumentRoot();
> root.setRegistryRequest(submitObjectsRequest);
>
> It seems to work, so I think the "problem" is saved. Thanks again for
> your help!
>
> Greetings
> Stefan
>
|
|
|
Powered by
FUDForum. Page generated in 0.03678 seconds