2 #ifndef FUNCTIONS_ACTION
3 #define FUNCTIONS_ACTION
15 #include "Poco/JSON/Object.h"
16 #include <Poco/Net/HTTPServerRequest.h>
17 #include "Poco/Data/Session.h"
18 #include "Poco/Data/MySQL/Connector.h"
19 #include <Poco/Data/MySQL/MySQLException.h>
20 #include <Poco/Data/Statement.h>
22 #include <Poco/StreamCopier.h>
23 #include <Poco/JSON/JSON.h>
24 #include <Poco/JSON/JSONException.h>
25 #include <Poco/JSON/Array.h>
26 #include <Poco/JSON/Object.h>
27 #include <Poco/JSON/Parser.h>
28 #include <Poco/Dynamic/Var.h>
29 #include <Poco/Dynamic/Struct.h>
30 #include <Poco/Data/RecordSet.h>
31 #include <Poco/Net/HTMLForm.h>
33 #include "query/database_manager.h"
34 #include "tools/settings_manager.h"
35 #include "query/results.h"
36 #include "query/parameter.h"
37 #include "query/condition.h"
38 #include "tools/manage_json.h"
39 #include "tools/output_logger.h"
40 #include "tools/dvalue.h"
41 #include "files/file_manager.h"
53 using namespace Poco::Net;
54 using namespace Poco::Data;
55 using namespace Poco::Data::Keywords;
61 using Ptr = std::shared_ptr<Action>;
63 Action(std::string identifier);
66 std::string get_identifier()
const {
return identifier_; };
67 std::string get_status()
const {
return status_; };
68 std::string get_message()
const {
return message_; };
69 std::string get_custom_error()
const {
return custom_error_; };
70 bool get_final()
const {
return final_; };
71 bool get_error()
const {
return error_; };
72 std::vector<Query::Parameter::Ptr>& get_parameters()
74 auto& var = parameters_;
77 Query::Condition<Action&>::Ptr get_condition()
79 auto& var = condition_;
82 Query::Results::Ptr get_results()
87 JSON::Object::Ptr get_json_result()
89 auto& var = json_result_;
92 std::vector<Ptr>& get_actions_container()
94 auto& var = actions_container_;
97 std::string get_sql_code()
const {
return sql_code_; };
98 std::string get_final_query()
const {
return final_query_;}
99 int get_affected_rows_()
const {
return affected_rows_;}
100 std::shared_ptr<Data::Session>& get_session()
102 auto& var = session_;
105 std::shared_ptr<Data::Statement>& get_query()
112 auto& var = credentials_;
116 void set_identifier(std::string identifier) { identifier_ = identifier; };
117 void set_status(std::string status) { status_ = status; };
118 void set_message(std::string message) { message_ = message; };
119 void set_custom_error(std::string custom_error) { custom_error_ = custom_error; };
120 void set_final(
bool final) { final_ =
final; };
121 void set_error(
bool error) { error_ = error; };
122 void set_sql_code(std::string sql_code) { sql_code_ = sql_code; };
123 void set_final_query(std::string final_query) {final_query_ = final_query;}
125 JSON::Array::Ptr GetParametersArray_(JSON::Array::Ptr json_array,
int counter);
126 Query::Parameter::Ptr GetParameterObject_(JSON::Array::Ptr parameters_array,
int counter);
127 void ReplaceParamater_(Query::Parameter::Ptr parameter);
128 Query::Parameter::Ptr AddParameter_(std::string name,
Tools::DValue value,
bool editable);
129 Query::Parameter::Ptr AddParameter_(std::string name,
Query::Field::Position field_position, std::string related_action,
bool editable);
130 void IdentifyParameters_(std::shared_ptr<Net::HTMLForm> form);
132 void IdentifyParameters_(JSON::Array::Ptr json_array);
133 void IdentifyParameters_(URI::QueryParameters& query_parameters);
134 void SetupCondition_(std::string identifier, Query::ConditionType type, Query::Condition<Action&>::Functor functor);
135 bool ComposeQuery_();
136 void ExecuteQuery_();
137 void ExecuteAsyncQuery_();
139 JSON::Object::Ptr CreateJSONResult_();
140 virtual bool Work_();
143 void NotifyError_(std::string message);
144 void SetupPositionParameter_(Query::Parameter::Ptr parameter);
145 bool VerifyParameterCondition_(Query::Parameter::Ptr parameter);
146 bool VerifyCondition_();
149 bool InitializeQuery_();
152 bool async_finished_;
153 std::string identifier_;
155 std::string message_;
156 std::string custom_error_;
159 std::vector<Query::Parameter::Ptr> parameters_;
160 Query::Condition<Action&>::Ptr condition_;
161 std::shared_ptr<Query::Results> results_;
162 JSON::Object::Ptr json_result_;
163 std::vector<Ptr> actions_container_;
164 std::string sql_code_;
165 std::string final_query_;
167 std::shared_ptr<Data::Session> session_;
168 std::shared_ptr<Data::Statement> query_;
Definition: file_manager.h:76
Definition: database_manager.h:51