fintp_base
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BatchXMLfileStorage.h
Go to the documentation of this file.
1 /*
2 * FinTP - Financial Transactions Processing Application
3 * Copyright (C) 2013 Business Information Systems (Allevo) S.R.L.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>
17 * or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania,
18 * phone +40212554577, office@allevo.ro <mailto:office@allevo.ro>, www.allevo.ro.
19 */
20 
21 #ifndef BATCHXMLFILESTORAGE_H
22 #define BATCHXMLFILESTORAGE_H
23 
24 #include "../BatchStorageBase.h"
25 #include "XmlUtil.h"
26 #include "../../XSLT/XSLTFilter.h"
27 
28 
29 namespace FinTP
30 {
32  {
33  public:
34 
37 
38  //at first enqueue create DOMDocument from the item
39  // ex. ACH XML - first element will be <CoreBulk...> <GrpHdr> ...</GrpHdr> <CdTrf> ... first message ... </CdtTf> </Core Bulk...>
40  //next enqueues will add the children as items
41  void enqueue( BatchResolution& resolution );
42 
43  BatchItem dequeue();
44 
45  // open/close storage
46 
47  // if openmode = inputMode => TODO: decompose the DOM from the BatchXML
48  // if openmode = outputMode => TODO: build the DOM for the BatchXML
49  void open( const string& storageId, ios_base::openmode openMode );
50 
51  //free the storage: delete the whole document
52  void close( const string& storageId );
53 
54  void commit() {}
55  void rollback() {}
56 
57  //nothing special TO DO
58  long size() const { return 0; }
59 
60  //nothing special TO DO
61  void setBufferSize( const unsigned long buffersize ){}
62 
63  //serialize XMLBatch document ( for test purpose )
64  string getSerializedXml() const;
65 
66  void setSerializedXml( const string& document );
67  void setSerializedXml( const unsigned char * document, const unsigned long size );
68 
69  // for dequeue
70  // Xslt will be applied on m_CrtStorage , parameter passed will be item position
71  // will return the m_CrtStorage item with position specified
72 
73  // using Xslt will offer the possibility to do a specialized selection
74  // for example => return item in position specified
75  // => header + item in posistion specified
76  string getXslt() const { return m_XsltFileName; }
77  void setXslt( const string& xsltFile ) { m_XsltFileName = xsltFile; }
78 
79  // for enqueue
80  // XPath will be applied on m_CrtStorage and will return the parent node
81  // for subsequent batch items
82  string getXPath() const { return m_XPath; }
83  void setXPath( const string& xpath ) { m_XPath = xpath; }
84 
85  long getCrtSequence(){ return m_CrtSequence; }
86 
87  void setXPathCallback( string ( *xPathCallback )( const string& itemNamespace ) )
88  {
89  m_XPathCallback = xPathCallback;
90  }
91 
92  string getInternalBatchID() const { return m_BatchId; }
93 
94  private :
95 
96  //m_CrtStorage is the DOM under construction
97  //the XML batch file under construction or under parsed
98  XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* m_CrtStorage;
99  XALAN_CPP_NAMESPACE_QUALIFIER XercesDOMWrapperParsedSource* m_CrtStorageWrapper;
100 
101  XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* m_CrtStorageRoot, *m_CrtInsertNode;
102  string m_BatchId;
104 
105  // current sequence in the current Storage
107 
110  string m_XPath;
111 
112  string ( *m_XPathCallback )( const string& itemNamespace );
113  map< string, vector< string > > m_XPathTokens;
114  vector< string > getXPath( const string& itemNamespace );
115  };
116 }
117 
118 #endif // BATCHXMLFILESTORAGE_H