fintp_base
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BatchItem.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 BATCHITEM_H
22 #define BATCHITEM_H
23 
24 #include <xercesc/dom/DOMDocument.hpp>
25 #include "Collaboration.h"
26 #include "WorkItemPool.h"
27 #include "DllMain.h"
28 
29 XERCES_CPP_NAMESPACE_USE
30 
31 namespace FinTP
32 {
34  {
35  public:
36  typedef enum
37  {
38  BATCHITEM_TXT = 1,
39  BATCHITEM_XML = 2,
40  BATCHITEM_BIN = 3
41  } BATCHITEM_TYPE;
42 
43  explicit BatchItem( const int sequence = BatchItem::FIRST_IN_SEQUENCE,
44  const string& batchId = Collaboration::EmptyGuid(),
45  const string& messageId = Collaboration::EmptyGuid(),
46  const bool isLast = false, const string& eyecatcher = "" );
47  BatchItem( const BatchItem& source );
48  ~BatchItem();
49 
50  BatchItem& operator=( const BatchItem& source );
51 
52  void setPayload( const string& payload );
53  void setPayload( const char* payload );
54  void setPayload( const ManagedBuffer *payload );
55  void setBinPayload( const ManagedBuffer *payload );
56  void setXmlPayload( XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* payload );
57 
58  string getPayload() const;
59  XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* getXmlPayload();
60  const XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* getXmlPayload() const;
61  ManagedBuffer* getBinPayload() const;
62 
63  BatchItem::BATCHITEM_TYPE getPayloadType() const { return m_PayloadType; }
64 
65  int getSequence() const { return m_Sequence; }
66  void setSequence( const int sequence ) { m_Sequence = sequence; }
67 
68  string getBatchId() const { return m_BatchId; }
69  void setBatchId( const string& batchId ) { m_BatchId = batchId; }
70 
71  string getMessageId() const { return m_MessageId; }
72  void setMessageId( const string& messageId ) { m_MessageId = messageId; }
73 
74  string getEyecatcher() const { return m_Eyecatcher; }
75  void setEyecatcher( const string& eyecatcher ) { m_Eyecatcher = eyecatcher; }
76 
77  void setLast( const bool flag = true ) { m_IsLast = flag; }
78  bool isLast() const { return m_IsLast; }
79 
80  time_t getCreateDate() const { return m_CreateDate; }
81  void setCreateDate( const time_t createDate ) { m_CreateDate = createDate; }
82 
83  friend bool operator !=( const BatchItem& lparamBI, const BatchItem& rparamBI );
84 
85  static const int FIRST_IN_SEQUENCE;
86  static const int LAST_IN_SEQUENCE;
87  static const int INVALID_SEQUENCE;
88 
89  static BatchItem first() { return BatchItem( BatchItem::FIRST_IN_SEQUENCE, Collaboration::EmptyGuid(), Collaboration::EmptyGuid() ); }
90  static BatchItem last() { return BatchItem( BatchItem::FIRST_IN_SEQUENCE, Collaboration::EmptyGuid(), Collaboration::EmptyGuid() ); }
91 
92  private :
93 
94  string m_Eyecatcher;
95  string m_Payload;
96  ManagedBuffer* m_BinPayload;
97 
98  XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* m_XmlPayload;
99  // m_PayloadTupe = false - string, true - XML
101 
102  time_t m_CreateDate;
104  string m_BatchId;
105  string m_MessageId;
106  bool m_IsLast;
108  };
109 }
110 
111 #endif // BATCHITEM_H