fintp_routingengine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RoutingActions.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 ROUTINGACTIONS_H
22 #define ROUTINGACTIONS_H
23 
24 #include "StringUtil.h"
25 #include "XSLT/XSLTFilter.h"
26 
27 #include "RoutingEngineMain.h"
28 #include "RoutingExceptions.h"
29 #include "RoutingMessage.h"
30 #include "RoutingDbOp.h"
31 
32 #define ENRICHFIELDSCOUNT 10
33 
35 {
36 #if defined( TESTDLL_EXPORT ) || defined ( TESTDLL_IMPORT )
37  friend class RoutingActionsTest;
38 #endif
39 
40  friend class RoutingSchema;
41  friend class RoutingStructures;
42  friend class RoutingQueue;
43 
44  public :
45 
46  // datatype type
47  typedef enum
48  {
53 
60 
62 
66 
69 
70  AGGREGATE
71  } ROUTING_ACTION;
72 
73  // returns a friendly name of the action
74  static string ToString( RoutingAction::ROUTING_ACTION type );
75  static RoutingAction::ROUTING_ACTION Parse( const string& action );
76 
77  // .ctor
78  RoutingAction() : m_Action( NOACTION ), m_Param( "" )
79  {
80  }
81 
82  RoutingAction( const RoutingAction::ROUTING_ACTION action, const string& param ) :
83  m_Action( action ), m_Param( param )
84  {
85  }
86 
87  RoutingAction( const string& text );
88 
89  // perform the action
90  string Perform( RoutingMessage* message, const int userId, bool bulk = false ) const;
91 
92  string ToString() const;
93 
94  // accessors
95  RoutingAction::ROUTING_ACTION getRoutingAction() const { return m_Action; }
96  string getParam() const { return m_Param; }
97 
98  void setText( const string& text );
99  void setSessionCode( const string& sessionCode ) { m_SessionCode = sessionCode; }
100 
101  static void CreateXSLTFilter();
102 
103  private :
104 
106  string m_Param;
108 
109  static XSLTFilter* m_XSLTFilter;
110 
111  static RoutingExceptionMoveInvestig internalPerformMoveToInvestigation( RoutingMessage* message, const string& reason = "Invalid message sent to investigation queue", bool investigIn = false );
112  static RoutingExceptionMoveInvestig internalPerformMoveDuplicate( RoutingMessage* message, const string& reason = "Possible duplicate message sent to investigation queue" );
113  static void internalPerformMoveTo( RoutingMessage* message, const string& queue );
114  static void internalPerformTransformMessage( RoutingMessage* message, const string& xsltFilename, const string& sessionCode )
115  {
116  internalPerformTransformMessage( message, xsltFilename, sessionCode, NameValueCollection() );
117  }
118  static void internalPerformTransformMessage( RoutingMessage* message, const string& xsltFilename, const string& sessionCode, const NameValueCollection& addParams );
119  static void internalPerformAggregate( RoutingMessage* message, const bool dummy );
120  static void internalPerformReactivate( RoutingMessage* message, const string& tableName );
121  static void internalPerformReactivate( RoutingMessage* message, const string& tableName, const RoutingAggregationCode& reactAgregationCode );
122  static void internalPerformSendReply( RoutingMessage* message, const string& tableName, bool bulk = false );
123  static void internalPerformChangeHoldStatus( RoutingMessage* message, const bool value );
124  static void internalInsertBMInfo( RoutingMessage* message );
125  static void internalAggregateBMInfo( RoutingMessage* message );
126 
127  //static void internalPerformComplete( RoutingMessage* message, const string code );
128 
129  void internalPerformWaitOn( RoutingMessage* message ) const;
130 
131  void internalPerformAssemble( RoutingMessage* message ) const;
132  void internalPerformDisassemble( RoutingMessage* message ) const;
133  void internalPerformEnrichMessage( RoutingMessage* message ) const;
134 
135  //MoveTo from routing rules
136  void internalPerformMoveTo( RoutingMessage* message ) const
137  {
138  internalPerformMoveTo( message, m_Param );
139  }
140 
141  void internalPerformAggregate( RoutingMessage* message ) const
142  {
143  internalPerformAggregate( message, true );
144  }
145 
146  void internalPerformComplete( RoutingMessage* message ) const;
147  void internalPerformChangeHoldStatus( RoutingMessage* message ) const
148  {
149  internalPerformChangeHoldStatus( message, ( m_Param == "true" ) || ( m_Param == "1" ) );
150  }
151 
152  void internalPerformChangePriority( RoutingMessage* message ) const
153  {
154  message->setPriority( StringUtil::ParseULong( m_Param ) );
155  }
156 
157  void internalPerformChangeValueDate( RoutingMessage* message ) const;
158 
159  void internalPerformTransformMessage( RoutingMessage* message, bool bulk = false ) const;
160 
161  void internalPerformSendReply( RoutingMessage* message, bool bulk = false ) const
162  {
163  internalPerformSendReply( message, m_Param, bulk );
164  }
165 
166  void internalPerformHoldQueue( const RoutingMessage* message, bool holdStatus ) const
167  {
168  RoutingDbOp::ChangeQueueHoldStatus( message->getTableName(), holdStatus );
169  }
170 
171  void internalPerformReactivate( RoutingMessage* message ) const
172  {
173  message->setTableName( m_Param );
174  internalPerformReactivate( message, m_Param );
175  }
176 
177  void internalPerformUpdateLiquidities( const RoutingMessage* message ) const
178  {
180  }
181 
182  static RoutingExceptionMoveInvestig internalPerformeMoveToDuplicateReply( RoutingMessage* message, const string& reason = "A reply was received, but original message has already been replied." );
183 };
184 
186 {
187 
188  protected:
189  RoutingMessageEvaluator* m_MessageEvaluator;
191 
192  static const int m_EnrichFields[ ENRICHFIELDSCOUNT ];
193  static const string m_EnrichFieldsName[ ENRICHFIELDSCOUNT ];
194 
195  inline EnrichTemplate( const string& xsltFile, RoutingMessageEvaluator* evaluator ): m_XsltFileName( xsltFile ), m_MessageEvaluator( evaluator ) {};
196  virtual string getIdFilterValue() = 0;
197  virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* getEnrichData( const string& idValue ) = 0;
198 
199  public:
200 
201  static EnrichTemplate* GetEnricher( RoutingMessageEvaluator* evaluator, const string& param );
202  inline virtual ~EnrichTemplate(){};
210  void enrich( RoutingMessage* message );
211 
212 };
213 
215 {
216  private:
217 
218  string m_TableName;
219  string m_IdPath;
220 
221  public:
222 
223  inline EnrichFromList( const string& xsltFile, const string& table, const string& idPath, RoutingMessageEvaluator* evaluator ): EnrichTemplate( xsltFile, evaluator),
224  m_TableName( table ), m_IdPath( idPath + "/text()" ){};
225 
226  protected:
227  inline string getIdFilterValue(){ return m_MessageEvaluator->getCustomXPath( m_IdPath ); };
228  XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* getEnrichData( const string& idFilterValue );
229 
230 };
231 
233 {
234  public:
235 
236  inline EnrichFromBusiness( const string& xsltFile, RoutingMessageEvaluator* evaluator ): EnrichTemplate( xsltFile, evaluator ){};
237 
238  protected:
239 
240  inline string getIdFilterValue(){ return m_MessageEvaluator->getField( InternalXmlPayload::ORGTXID ); };
241  XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* getEnrichData( const string& idFilterValue );
242 
243 };
244 #endif // ROUTINGACTIONS_H