Hi,
Just a simple post concerning a useful functionality provided by Documentum in com.documentum.xml.xdql DFC package.
As you would see in my previous post http://www.javablog.fr/xstream-presentation-serialization-deserialization-xml.html, there is another solutions/frameworks like Xstream for the serialization and deserialization of XML in Java applications.
SOLUTION 1
This package com.documentum.xml.xdql contains only the Interface IDfXmlQuery. This interface provides functionality for running queries against a repository, returning the results as XML.
The structure of the XML output is a root element, specified by setRootTag, followed by each query result row. The following is an example of the XML output:
03 | < object ID = "09017e1080001932" > |
04 | < r_object_id >09017e1080001932</ r_object_id > |
05 | < object_name >catalog A</ object_name > |
07 | < object ID = "09017e10800019aa" > |
08 | < r_object_id >09017e10800019aa</ r_object_id > |
09 | < object_name >catalog B</ object_name > |
There are many options available for customizing the XML output, such as specifying the whether object content should be included in the output. Each option has a default value, so you only need to set the options that you want to override.
Sample DFC code to get document as XML
001 | package com.huo.test.ecm.test2; |
003 | import java.io.FileOutputStream; |
004 | import java.io.IOException; |
006 | import com.documentum.fc.client.DfClient; |
007 | import com.documentum.fc.client.IDfClient; |
008 | import com.documentum.fc.client.IDfQuery; |
009 | import com.documentum.fc.client.IDfSession; |
010 | import com.documentum.fc.client.IDfSessionManager; |
011 | import com.documentum.fc.client.IDfSysObject; |
012 | import com.documentum.fc.common.DfException; |
013 | import com.documentum.fc.common.DfLoginInfo; |
014 | import com.documentum.fc.common.IDfLoginInfo; |
015 | import com.documentum.xml.xdql.DfXmlQuery; |
016 | import com.documentum.xml.xdql.IDfXmlQuery; |
023 | public class DocumentRecordsAsXMLTest { |
025 | IDfSysObject sysObject = null ; |
026 | IDfSession idfSession = null ; |
027 | IDfSessionManager sessMgr = null ; |
029 | public DocumentRecordsAsXMLTest(String user, String passwd, String docbase) throws Exception { |
030 | getDfSession(user, passwd, docbase); |
033 | public IDfSession getDfSession(String args1, String args2, String args3) throws Exception { |
034 | IDfLoginInfo login = new DfLoginInfo(); |
035 | login.setUser(args1); |
036 | login.setPassword(args2); |
037 | IDfClient client = DfClient.getLocalClient(); |
038 | sessMgr = client.newSessionManager(); |
039 | sessMgr.setIdentity(args3, login); |
040 | idfSession = sessMgr.getSession(args3); |
042 | if (idfSession != null ) |
043 | System.out.println( "Session created successfully" ); |
049 | public void releaseSession() throws Exception { |
050 | sessMgr.release(idfSession); |
053 | public String getdm_documentRecordsAsXML(String dql, String fileStoring) throws DfException { |
054 | System.out.println( "#################################################" ); |
056 | IDfXmlQuery objDfXmlQuery = new DfXmlQuery(); |
057 | objDfXmlQuery.init(); |
058 | objDfXmlQuery.setDql(dql); |
059 | objDfXmlQuery.setContentAsLink( true ); |
060 | objDfXmlQuery.setMetaDataAsAttributes( false ); |
062 | objDfXmlQuery.setRepeatingAsNested( true ); |
063 | objDfXmlQuery.setRepeatingIncludeIndex( true ); |
064 | objDfXmlQuery.includeMetaData( true ); |
065 | objDfXmlQuery.useNullAttributeIndicator( true ); |
066 | objDfXmlQuery.includeDCTMChunkInfo( true ); |
067 | objDfXmlQuery.includeContent( true ); |
068 | objDfXmlQuery.execute(IDfQuery.DF_READ_QUERY, idfSession); |
069 | String xml = objDfXmlQuery.getXMLString(); |
070 | System.out.println( "XML is : " + xml); |
072 | FileOutputStream fos = null ; |
074 | fos = new FileOutputStream(fileStoring); |
075 | objDfXmlQuery.getXMLString(fos); |
076 | } catch (Exception e) { |
080 | try { fos.flush(); } catch (IOException e) { e.printStackTrace(); } |
081 | try { fos.close(); } catch (IOException e) { e.printStackTrace(); } |
090 | public static void main(String[] args) throws Exception { |
092 | String user = "myuser" ; |
093 | String passwd = "passeord4myus" ; |
094 | String docbase = "MY_DOC_BASE" ; |
095 | DocumentRecordsAsXMLTest object = new DocumentRecordsAsXMLTest(user, passwd, docbase); |
099 | object.getdm_documentRecordsAsXML( "select * from dm_document where r_object_id='090xxxxxxxxxxxxf1d'" , "C:\\Workspaces\\TestDCTMHUO\\src\\com\\huo\\test\\ecm\\test2\\documentXML.xml" ); |
102 | object.releaseSession(); |
….outputs:
01 | Session created successfully |
02 | ################################################# |
03 | XML is : <?xml version= "1.0" ?> |
05 | <object ID= "090xxxxxxxxxxxxf1d" > |
06 | <r_object_id>090xxxxxxxxxxxxf1d</r_object_id> |
07 | <object_name>Test 12</object_name> |
09 | <subject> null </subject> |
10 | <resolution_label> null </resolution_label> |
11 | <owner_name>gedadm</owner_name> |
12 | <owner_permit>6</owner_permit> |
13 | <group_name> null </group_name> |
14 | <group_permit>1</group_permit> |
15 | <world_permit>1</world_permit> |
16 | <log_entry> null </log_entry> |
17 | <acl_domain>MYDOCBASEDEV</acl_domain> |
18 | <acl_name>dm_450220c580068103_8005a971</acl_name> |
19 | <language_code> null </language_code> |
20 | <r_object_type>huo_client_document</r_object_type> |
21 | <r_creation_date>12/02/2014 15:20:56</r_creation_date> |
22 | <r_modify_date>18/11/2016 15:18:21</r_modify_date> |
23 | <a_content_type>dxl</a_content_type> |
Document with aspect attached
2 | object.getdm_documentRecordsAsXML( "select r_object_id, r_modifier, r_modify_date, r_aspect_name, object_name, aspect_huo.huo_request_num from dm_document where r_object_id='090xxxxxxxxxxxx36'" , "C:\\Workspaces\\TestDCTMHUO\\src\\com\\huo\\test\\ecm\\test2\\documentXML.xml" ); |
….outputs:
01 | Session created successfully |
02 | ################################################# |
03 | XML is : <?xml version= "1.0" ?> |
05 | <object ID= "090xxxxxxxxxxxx36" > |
06 | <r_object_id>090xxxxxxxxxxxx36</r_object_id> |
07 | <r_modifier>gedadm</r_modifier> |
08 | <r_modify_date>19/10/2016 14:38:41</r_modify_date> |
10 | <r_aspect_name-value index = "0" >aspect_huo</r_aspect_name-value> |
11 | <r_aspect_name-value index = "1" >aspect_copy</r_aspect_name-value> |
12 | <r_aspect_name-value index = "2" >aspect_email</r_aspect_name-value> |
14 | <object_name>HUO value object name . |
15 | Residential II S.A.</object_name> |
16 | <aspect_huo.huo_request_num>900971</aspect_huo.huo_request_num> |
SOLUTION 2
Documentum proposes methods accessible via API and DFC:
01 | System.out.println(dfDocument.getString( "_xml_string" )); |
04 | API> get,c,090XXXXXXXXXXXXXXX03,_xml_string |
07 | <dctm-attr name= "r_object_id" type= "ID" repeating= "true" index= "0" ><![CDATA[090XXXXXXXXXXXXXXX03]]></dctm-attr> |
08 | <dctm-attr name= "object_name" type= "STRING" ><![CDATA[My doc name]]></dctm-attr> |
09 | <dctm-attr name= "r_object_type" type= "STRING" ><![CDATA[my_document]]></dctm-attr> |
10 | <dctm-attr name= "title" type= "STRING" ><![CDATA[]]></dctm-attr> |
11 | <dctm-attr name= "subject" type= "STRING" ><![CDATA[]]></dctm-attr> |
12 | <dctm-attr name= "authors" type= "STRING" repeating= "true" index= "0" ><![CDATA[]]></dctm-attr> |
13 | <dctm-attr name= "keywords" type= "STRING" repeating= "true" index= "0" ><![CDATA[]]></dctm-attr> |
14 | <dctm-attr name= "a_application_type" type= "STRING" ><![CDATA[]]></dctm-attr> |
15 | <dctm-attr name= "a_status" type= "STRING" ><![CDATA[]]></dctm-attr> |
16 | <dctm-attr name= "r_creation_date" type= "TIME" ><![CDATA[ 2015 - 09 - 22 11 : 38 : 22 ]]></dctm-attr> |
17 | <dctm-attr name= "r_modify_date" type= "TIME" ><![CDATA[ 2015 - 09 - 22 11 : 38 : 22 ]]></dctm-attr> |
18 | <dctm-attr name= "r_modifier" type= "STRING" ><![CDATA[useradm]]></dctm-attr> |
19 | <dctm-attr name= "r_access_date" type= "TIME" ><![CDATA[ 2018 - 12 - 18 13 : 49 : 03 ]]></dctm-attr> |
20 | <dctm-attr name= "a_is_hidden" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
21 | <dctm-attr name= "i_is_deleted" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
22 | <dctm-attr name= "a_retention_date" type= "TIME" ><![CDATA[]]></dctm-attr> |
23 | <dctm-attr name= "a_archive" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
24 | <dctm-attr name= "a_compound_architecture" type= "STRING" ><![CDATA[]]></dctm-attr> |
25 | <dctm-attr name= "a_link_resolved" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
26 | <dctm-attr name= "i_reference_cnt" type= "INT" ><![CDATA[ 1 ]]></dctm-attr> |
27 | <dctm-attr name= "i_has_folder" type= "BOOL" ><![CDATA[T]]></dctm-attr> |
28 | <dctm-attr name= "i_folder_id" type= "ID" repeating= "true" index= "0" ><![CDATA[0bXXXXXXXXXXXXXXXXXf9]]></dctm-attr> |
29 | <dctm-attr name= "r_composite_id" type= "ID" repeating= "true" index= "0" ><![CDATA[]]></dctm-attr> |
30 | <dctm-attr name= "r_composite_label" type= "STRING" repeating= "true" index= "0" ><![CDATA[]]></dctm-attr> |
31 | <dctm-attr name= "r_component_label" type= "STRING" repeating= "true" index= "0" ><![CDATA[]]></dctm-attr> |
32 | <dctm-attr name= "r_order_no" type= "INT" repeating= "true" index= "0" ><![CDATA[]]></dctm-attr> |
33 | <dctm-attr name= "r_link_cnt" type= "INT" ><![CDATA[ 0 ]]></dctm-attr> |
34 | <dctm-attr name= "r_link_high_cnt" type= "INT" ><![CDATA[ 0 ]]></dctm-attr> |
35 | <dctm-attr name= "r_assembled_from_id" type= "ID" ><![CDATA[ 0000000000000000 ]]></dctm-attr> |
36 | <dctm-attr name= "r_frzn_assembly_cnt" type= "INT" ><![CDATA[ 0 ]]></dctm-attr> |
37 | <dctm-attr name= "r_has_frzn_assembly" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
38 | <dctm-attr name= "resolution_label" type= "STRING" ><![CDATA[]]></dctm-attr> |
39 | <dctm-attr name= "r_is_virtual_doc" type= "INT" ><![CDATA[ 0 ]]></dctm-attr> |
40 | <dctm-attr name= "i_contents_id" type= "ID" ><![CDATA[060XXXXXXXXXXXXXXXXX7]]></dctm-attr> |
41 | <dctm-attr name= "a_content_type" type= "STRING" ><![CDATA[pdf]]></dctm-attr> |
42 | <dctm-attr name= "r_page_cnt" type= "INT" ><![CDATA[ 1 ]]></dctm-attr> |
43 | <dctm-attr name= "r_content_size" type= "INT" ><![CDATA[ 183446 ]]></dctm-attr> |
44 | <dctm-attr name= "a_full_text" type= "BOOL" ><![CDATA[T]]></dctm-attr> |
45 | <dctm-attr name= "a_storage_type" type= "STRING" ><![CDATA[filestore_01]]></dctm-attr> |
46 | <dctm-attr name= "i_cabinet_id" type= "ID" ><![CDATA[0cXXXXXXXXXXXXXXXX02]]></dctm-attr> |
47 | <dctm-attr name= "owner_name" type= "STRING" ><![CDATA[useradm]]></dctm-attr> |
48 | <dctm-attr name= "owner_permit" type= "INT" ><![CDATA[ 1 ]]></dctm-attr> |
49 | <dctm-attr name= "group_name" type= "STRING" ><![CDATA[docu]]></dctm-attr> |
50 | <dctm-attr name= "group_permit" type= "INT" ><![CDATA[ 1 ]]></dctm-attr> |
51 | <dctm-attr name= "world_permit" type= "INT" ><![CDATA[ 1 ]]></dctm-attr> |
52 | <dctm-attr name= "i_antecedent_id" type= "ID" ><![CDATA[ 0000000000000000 ]]></dctm-attr> |
53 | <dctm-attr name= "i_chronicle_id" type= "ID" ><![CDATA[09XXXXXXXXXXXXXX03]]></dctm-attr> |
54 | <dctm-attr name= "i_latest_flag" type= "BOOL" ><![CDATA[T]]></dctm-attr> |
55 | <dctm-attr name= "r_lock_owner" type= "STRING" ><![CDATA[]]></dctm-attr> |
56 | <dctm-attr name= "r_lock_date" type= "TIME" ><![CDATA[]]></dctm-attr> |
57 | <dctm-attr name= "r_lock_machine" type= "STRING" ><![CDATA[]]></dctm-attr> |
58 | <dctm-attr name= "log_entry" type= "STRING" ><![CDATA[]]></dctm-attr> |
59 | <dctm-attr name= "r_version_label" type= "STRING" repeating= "true" index= "0" ><![CDATA[ 1.0 ]]></dctm-attr> |
60 | <dctm-attr name= "r_version_label" type= "STRING" repeating= "true" index= "1" ><![CDATA[CURRENT]]></dctm-attr> |
61 | <dctm-attr name= "i_branch_cnt" type= "INT" ><![CDATA[ 0 ]]></dctm-attr> |
62 | <dctm-attr name= "i_direct_dsc" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
63 | <dctm-attr name= "r_immutable_flag" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
64 | <dctm-attr name= "r_frozen_flag" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
65 | <dctm-attr name= "r_has_events" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
66 | <dctm-attr name= "acl_domain" type= "STRING" ><![CDATA[MYDOCBASEDEV]]></dctm-attr> |
67 | <dctm-attr name= "acl_name" type= "STRING" ><![CDATA[dm_450XXXXXXXXXXXXXXXea_8YYY5]]></dctm-attr> |
68 | <dctm-attr name= "a_special_app" type= "STRING" ><![CDATA[]]></dctm-attr> |
69 | <dctm-attr name= "i_is_reference" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
70 | <dctm-attr name= "r_creator_name" type= "STRING" ><![CDATA[useradm]]></dctm-attr> |
71 | <dctm-attr name= "r_is_public" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
72 | <dctm-attr name= "r_policy_id" type= "ID" ><![CDATA[ 0000000000000000 ]]></dctm-attr> |
73 | <dctm-attr name= "r_resume_state" type= "INT" ><![CDATA[ 0 ]]></dctm-attr> |
74 | <dctm-attr name= "r_current_state" type= "INT" ><![CDATA[ 0 ]]></dctm-attr> |
75 | <dctm-attr name= "r_alias_set_id" type= "ID" ><![CDATA[ 0000000000000000 ]]></dctm-attr> |
76 | <dctm-attr name= "a_effective_date" type= "TIME" repeating= "true" index= "0" ><![CDATA[]]></dctm-attr> |
77 | <dctm-attr name= "a_expiration_date" type= "TIME" repeating= "true" index= "0" ><![CDATA[]]></dctm-attr> |
78 | <dctm-attr name= "a_publish_formats" type= "STRING" repeating= "true" index= "0" ><![CDATA[]]></dctm-attr> |
79 | <dctm-attr name= "a_effective_label" type= "STRING" repeating= "true" index= "0" ><![CDATA[]]></dctm-attr> |
80 | <dctm-attr name= "a_effective_flag" type= "STRING" repeating= "true" index= "0" ><![CDATA[]]></dctm-attr> |
81 | <dctm-attr name= "a_category" type= "STRING" ><![CDATA[]]></dctm-attr> |
82 | <dctm-attr name= "language_code" type= "STRING" ><![CDATA[]]></dctm-attr> |
83 | <dctm-attr name= "a_is_template" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
84 | <dctm-attr name= "a_controlling_app" type= "STRING" ><![CDATA[]]></dctm-attr> |
85 | <dctm-attr name= "r_full_content_size" type= "DOUBLE" ><![CDATA[ 183446 ]]></dctm-attr> |
86 | <dctm-attr name= "a_extended_properties" type= "STRING" repeating= "true" index= "0" ><![CDATA[]]></dctm-attr> |
87 | <dctm-attr name= "a_is_signed" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
88 | <dctm-attr name= "a_last_review_date" type= "TIME" ><![CDATA[]]></dctm-attr> |
89 | <dctm-attr name= "i_retain_until" type= "TIME" ><![CDATA[]]></dctm-attr> |
90 | <dctm-attr name= "r_aspect_name" type= "STRING" repeating= "true" index= "0" ><![CDATA[my_aspect]]></dctm-attr> |
91 | <dctm-attr name= "i_retainer_id" type= "ID" repeating= "true" index= "0" ><![CDATA[]]></dctm-attr> |
92 | <dctm-attr name= "i_partition" type= "INT" ><![CDATA[ 0 ]]></dctm-attr> |
93 | <dctm-attr name= "i_is_replica" type= "BOOL" ><![CDATA[F]]></dctm-attr> |
94 | <dctm-attr name= "i_vstamp" type= "INT" ><![CDATA[ 1 ]]></dctm-attr> |
96 | <dctm-attr name= "metdata_id" type= "INT" ><![CDATA[ 121231 ]]></dctm-attr> |
97 | <dctm-attr name= "metdata_name" type= "STRING" ><![CDATA[MY DOC user Name]]></dctm-attr> |
98 | <dctm-attr name= "business_year" type= "STRING" ><![CDATA[ 2014 ]]></dctm-attr> |
That’s all!!!
Huseyin OZVEREN
Related