rxcms-dbms_plugin 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,49 @@
1
+ module DbmsEngineHelper
2
+
3
+ def persist_connection
4
+ SymmetricEncryption.load!
5
+
6
+ if (ActiveRecord::Base.connection == Database.connection)
7
+ adapter = !Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_ADAPTER], session[:accessible_appid]] }).nil? ? Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_ADAPTER], session[:accessible_appid]] }).value : nil
8
+
9
+ if (!adapter.nil?)
10
+ if (adapter == 'sqlite')
11
+ if (Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_DATABASE], session[:accessible_appid]] }).nil?)
12
+ raise "database malformed"
13
+ end
14
+
15
+ connectionResult = Database.connect_sqlite(Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_DATABASE], session[:accessible_appid]] }).value)
16
+
17
+ if (!connectionResult)
18
+ raise "connection malformed or altered"
19
+ end
20
+ else
21
+ if (Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_HOST], session[:accessible_appid]] }).nil? ||
22
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_PORT], session[:accessible_appid]] }).nil? ||
23
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_DATABASE], session[:accessible_appid]] }).nil? ||
24
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_USER], session[:accessible_appid]] }).nil? ||
25
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_PASSWORD], session[:accessible_appid]] }).nil?)
26
+ raise "host, database, user or password malformed"
27
+ end
28
+
29
+ connectionResult = Database.connect_sql(Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_ADAPTER], session[:accessible_appid]] }).value,
30
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_HOST], session[:accessible_appid]] }).value,
31
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_PORT], session[:accessible_appid]] }).value,
32
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_USER], session[:accessible_appid]] }).value,
33
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_PASSWORD], session[:accessible_appid]] }).value,
34
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_DATABASE], session[:accessible_appid]] }).value)
35
+
36
+ if (!connectionResult)
37
+ raise "connection malformed or altered"
38
+ end
39
+ end
40
+ else
41
+ raise "adapter malformed"
42
+ end
43
+ else
44
+ logger.debug("[dbms-plugin] Not persisting connection")
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,2 @@
1
+ module DbmsInstallerHelper
2
+ end
@@ -0,0 +1,30 @@
1
+ module DbmsPluginHelper
2
+
3
+ def current_user
4
+ if UserSession.find.nil?
5
+ @current_user ||= nil
6
+ else
7
+ @current_user ||= User.find(UserSession.find.record.id)
8
+ end
9
+ end
10
+
11
+ # Get current user's role
12
+ def get_current_user_role
13
+ @current_user = current_user
14
+ if (!@current_user.nil?)
15
+ siteId = session[:accessible_appid]
16
+ roleId = session[:accessible_roleid]
17
+
18
+ if (!siteId.nil? && !roleId.nil?)
19
+ userRole = Role.find(roleId)
20
+ @curUserRole = userRole.name
21
+ else
22
+ @curUserRole = 'loggedin'
23
+ end
24
+
25
+ else
26
+ @curUserRole = 'anonymous'
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,47 @@
1
+ class Database < ActiveRecord::Base
2
+ @@conn = nil
3
+
4
+ def self.connect_sql(adapter, host, port, username, password, database)
5
+ SymmetricEncryption.load!
6
+ # Load configuration items (MANDATORY, must be included)
7
+ app_config = HashWithIndifferentAccess.new(YAML.load(File.read(File.expand_path('../../../config/dbms/dbms_config.yml', __FILE__))))
8
+
9
+ begin
10
+ decryptedPassword = SymmetricEncryption.decrypt(password)
11
+
12
+ establish_connection(
13
+ :adapter => adapter,
14
+ :host => host,
15
+ :port => port.to_i,
16
+ :username => username,
17
+ :password => decryptedPassword,
18
+ :database => database
19
+ )
20
+
21
+ if (self.connection.nil?)
22
+ return false
23
+ else
24
+ return true
25
+ end
26
+ rescue
27
+ return false
28
+ end
29
+ end
30
+
31
+ def self.connect_sqlite(path)
32
+ begin
33
+ establish_connection(
34
+ :adapter => "sqlite3",
35
+ :database => path
36
+ )
37
+
38
+ if (self.connection.nil?)
39
+ return false
40
+ else
41
+ return true
42
+ end
43
+ rescue
44
+ return false
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,165 @@
1
+ <!-- Store Query Modal -->
2
+ <div id="storeQueryModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
3
+ <div class="modal-header">
4
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
5
+ <h3 id="myModalLabel">Save Query</h3>
6
+ </div>
7
+ <div class="modal-body">
8
+ <div class="row-fluid">
9
+ <div class="span3">
10
+ <div style="padding:2px 0 2px 0;">Stored Query Key</div>
11
+ </div>
12
+ <div class="span8">
13
+ <input type="text" id="storedQueryKey" />
14
+ </div>
15
+ </div>
16
+ </div>
17
+ <div class="modal-footer">
18
+ <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
19
+ <button class="btn btn-primary" id="processStoreQueryModalBtn">process...</button>
20
+ </div>
21
+ </div>
22
+
23
+ <!-- Language Modal -->
24
+ <div id="storeQueryLanguageModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
25
+ <div class="modal-header">
26
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
27
+ <h3 id="myModalLabel">Change locale for query</h3>
28
+ </div>
29
+ <div class="modal-body">
30
+ <p><select id="storeQueryLanguageSelect">
31
+
32
+ </select></p>
33
+ </div>
34
+ <div class="modal-footer">
35
+ <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
36
+ </div>
37
+ </div>
38
+
39
+ <div class="container">
40
+ <ul id="dbmsConfigureTabs" class="nav nav-tabs">
41
+ <li class="active"><a href="#home" data-toggle="tab">Configuration</a></li>
42
+ <li id="dataManagementConsole" class="dropdown">
43
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">Operations <b class="caret"></b></a>
44
+ <ul class="dropdown-menu">
45
+ <li><a href="#dataMapping" data-toggle="tab">Data Mapping</a></li>
46
+ </ul>
47
+ </li>
48
+ <li><a href="#uninstall" data-toggle="tab">Uninstall</a></li>
49
+ </ul>
50
+
51
+ <div id="myTabContent" class="tab-content">
52
+ <div class="tab-pane fade in active" id="home">
53
+
54
+ <h4>Please provide your database connection and credentials</h4>
55
+
56
+ <div class="input-prepend">
57
+ <span class="add-on">DBMS Type</span>
58
+ <select id="dbmsTypeSelect" style="margin-left:5px;">
59
+ <option value=""></option>
60
+ <option value="mysql2">MySQL</option>
61
+ <!--<option value="sqlite">SQLite</option>-->
62
+ <option value="postgresql">PostgreSQL</option>
63
+ </select>
64
+ </div>
65
+ <br />
66
+ <div class="connectorContainer" id="sql" style="display:none;">
67
+ <div class="input-prepend">
68
+ <span class="add-on">Connection URL</span>
69
+ <input class="span2" id="hostTxt" type="text" placeholder="host...">
70
+ </div>
71
+ <br />
72
+ <div class="input-prepend">
73
+ <span class="add-on">Connection Host</span>
74
+ <input class="span2" id="portTxt" type="text" placeholder="port...">
75
+ </div>
76
+ <br />
77
+ <div class="input-prepend">
78
+ <span class="add-on">Database Name</span>
79
+ <input class="span2" id="dbTxt" type="text" placeholder="database name...">
80
+ </div>
81
+ <br />
82
+ <div class="input-prepend">
83
+ <span class="add-on">Login</span>
84
+ <input class="span2" id="userTxt" type="text" placeholder="username">
85
+ </div>
86
+ <br />
87
+ <div class="input-prepend">
88
+ <span class="add-on">Password</span>
89
+ <input class="span2" id="passwordTxt" type="password" placeholder="password">
90
+ </div>
91
+ <br />
92
+ <button type="button" id="sqlProceedBtn" class="btn btn-danger sqlProceedBtn">proceed</button>
93
+ </div>
94
+
95
+ <!--<div class="connectorContainer" id="sqlite" style="display:none;">
96
+ <div class="input-prepend">
97
+ <span class="add-on">Database</span>
98
+ <input class="span2" id="prependedInput" type="text" placeholder="url to your sqlite db">
99
+ </div>
100
+ <br />
101
+ <button type="button" id="sqliteProceedBtn" class="btn btn-danger sqlProceedBtn">proceed</button>
102
+ </div>-->
103
+
104
+ </div>
105
+
106
+ <div class="tab-pane fade" id="dataMapping">
107
+
108
+ <div class="row-fluid">
109
+ <div class="span3">
110
+
111
+ <label class="control-label">Stored Queries</label>
112
+ <ul class="nav nav-tabs nav-stacked" id="storeQueryList">
113
+ <li id="storeQueryDummy" style="display:none;"><a href="#"><input type="checkbox" style="margin:-2px 5px 0 0;" /><span></span>&nbsp;<span>(x)</span></a></li>
114
+ </ul>
115
+
116
+ </div>
117
+ <div class="span9">
118
+ <div>
119
+ <!-- Textarea -->
120
+ <div class="control-group">
121
+ <label class="control-label">SQL Command</label>
122
+ <div class="controls">
123
+ <textarea id="sqlQueryTxt" name="textarea" style="width:97%;height:96px;font-family:'Courier New', sans-serif;" placeholder="SQL Query here"></textarea>
124
+ </div>
125
+ </div>
126
+
127
+ <!-- Button -->
128
+ <div class="control-group">
129
+ <div class="controls">
130
+ <button id="executeSqlBtn" name="singlebutton" class="btn btn-primary">test</button>
131
+ <button id="saveSqlBtn" name="singlebutton" class="btn btn-primary" disabled="disabled">save query</button>
132
+ <button id="updateSqlBtn" name="singlebutton" class="btn btn-primary" disabled="disabled" style="display:none;">update query</button>
133
+ <button id="localeSqlBtn" name="singlebutton" class="btn btn-primary" style="display:none;">language</button>
134
+ </div>
135
+ </div>
136
+ </div>
137
+
138
+ <div>
139
+ <table class="table table-striped" id="resultTable">
140
+ <thead>
141
+ <tr>
142
+ <!-- HEADER GOES HERE -->
143
+ </tr>
144
+ </thead>
145
+ <tbody>
146
+ <!-- BODY GOES HERE -->
147
+ </tbody>
148
+ </table>
149
+ </div>
150
+ </div>
151
+ </div>
152
+
153
+ </div>
154
+
155
+ <div class="tab-pane fade" id="uninstall" >
156
+ <div>
157
+ <button id="uninstallBtn" type="button" class="btn btn-danger">Uninstall</button>
158
+ </div>
159
+ </div>
160
+
161
+ </div>
162
+
163
+ </div>
164
+
165
+ <%= javascript_include_tag "alliance_dbms_plugin/configure" %>
@@ -0,0 +1 @@
1
+ <h1>This is the readme page of Alliance CMS DBMS Plugin</h1>
@@ -0,0 +1,55 @@
1
+ <div class="container">
2
+ <div>
3
+ <h4>Please provide your database connection and credentials</h4>
4
+
5
+ <div class="input-prepend">
6
+ <span class="add-on">DBMS Type</span>
7
+ <select id="dbmsTypeSelect" style="margin-left:5px;">
8
+ <option value=""></option>
9
+ <option value="mysql2">MySQL</option>
10
+ <!--<option value="sqlite">SQLite</option>-->
11
+ <option value="postgresql">PostgreSQL</option>
12
+ </select>
13
+ </div>
14
+ <br />
15
+ <div class="connectorContainer" id="sql" style="display:none;">
16
+ <div class="input-prepend">
17
+ <span class="add-on">Connection URL</span>
18
+ <input class="span2" id="hostTxt" type="text" placeholder="host...">
19
+ </div>
20
+ <br />
21
+ <div class="input-prepend">
22
+ <span class="add-on">Connection Port</span>
23
+ <input class="span2" id="portTxt" type="text" placeholder="port...">
24
+ </div>
25
+ <br />
26
+ <div class="input-prepend">
27
+ <span class="add-on">Database Name</span>
28
+ <input class="span2" id="dbTxt" type="text" placeholder="database name...">
29
+ </div>
30
+ <br />
31
+ <div class="input-prepend">
32
+ <span class="add-on">Login</span>
33
+ <input class="span2" id="userTxt" type="text" placeholder="username">
34
+ </div>
35
+ <br />
36
+ <div class="input-prepend">
37
+ <span class="add-on">Password</span>
38
+ <input class="span2" id="passwordTxt" type="password" placeholder="password">
39
+ </div>
40
+ <br />
41
+ <button type="button" id="sqlProceedBtn" class="btn btn-danger sqlProceedBtn">proceed</button>
42
+ </div>
43
+
44
+ <!--<div class="connectorContainer" id="sqlite" style="display:none;">
45
+ <div class="input-prepend">
46
+ <span class="add-on">Database</span>
47
+ <input class="span2" id="dbTxtSqlite" type="text" placeholder="url to your sqlite db">
48
+ </div>
49
+ <br />
50
+ <button type="button" id="sqliteProceedBtn" class="btn btn-danger sqlProceedBtn">proceed</button>
51
+ </div>-->
52
+ </div>
53
+ </div>
54
+
55
+ <%= javascript_include_tag "alliance_dbms_plugin/installer" %>
@@ -0,0 +1,8 @@
1
+ DBMS_CURRENT_ADAPTER : dbmsCurrentAdapter
2
+ DBMS_CURRENT_HOST : dbmsCurrentHost
3
+ DBMS_CURRENT_PORT : dbmsCurrentPort
4
+ DBMS_CURRENT_DATABASE : dbmsCurrentDatabase
5
+ DBMS_CURRENT_USER : dbmsCurrentUser
6
+ DBMS_CURRENT_PASSWORD : dbmsCurrentPassword
7
+ DBMS_CAT_CONFIG : dbms_config
8
+ DBMS_CAT_STORED_QUERY : dbms_stored_query
data/config/routes.rb ADDED
@@ -0,0 +1,25 @@
1
+ Rails.application.routes.draw do
2
+
3
+ get "/dbms/engine/readme" => "dbms_engine#index"
4
+ get "/dbms/engine/configure" => "dbms_engine#configure"
5
+ get "/dbms/engine/installer" => "dbms_engine#installer"
6
+
7
+ post "/dbms/installer/before_process" => "dbms_installer#before_process"
8
+ post "/dbms/installer/core_process" => "dbms_installer#core_process"
9
+ post "/dbms/installer/post_process" => "dbms_installer#post_process"
10
+ post "/dbms/installer/uninstall" => "dbms_installer#uninstall"
11
+
12
+ get "/dbms/connection/status" => "dbms_connection#getConnectionStatus"
13
+ post "/dbms/connection/make" => "dbms_connection#makeNewConnection"
14
+ get "/dbms/connection/tables" => "dbms_connection#getListOfTables"
15
+ post "/dbms/connection/sql" => "dbms_connection#executeSQL"
16
+ post "/dbms/connection/query/store" => "dbms_connection#addStoredQuery"
17
+ get "/dbms/connection/query/all" => "dbms_connection#getListOfStoredQueries"
18
+ get "/dbms/connection/query/one/:id/:cat" => "dbms_connection#getOneStoredQueryInfos"
19
+ put "/dbms/connection/query/update/:id" => "dbms_connection#updateStoredQuery"
20
+ delete "/dbms/connection/query/delete/:id" => "dbms_connection#deleteStoredQuery"
21
+
22
+ # Service Route
23
+ get "/ext/dbms/:key" => "dbms_services#execute"
24
+
25
+ end
@@ -0,0 +1,8 @@
1
+ class CreateDatabases < ActiveRecord::Migration
2
+ def change
3
+ #create_table :databases do |t|
4
+
5
+ # t.timestamps
6
+ #end
7
+ end
8
+ end
@@ -0,0 +1,153 @@
1
+ module RxcmsDbmsPlugin
2
+
3
+ class Executor
4
+
5
+ # Tag syntax [[<<placeholder>>? &type="stored-query" &data="<<data-source>>" &attrs="<<attr-data>>"...]]
6
+ def self.execute(placeholder, attrs, exts)
7
+ begin
8
+
9
+ dbms_config = HashWithIndifferentAccess.new(YAML.load(File.read(File.expand_path("../../../../config/dbms/dbms_config.yml", __FILE__))))
10
+
11
+ if attrs.has_key?('configs')
12
+ if attrs['configs'].has_key?('type')
13
+ if attrs['configs']['type'] == 'stored-query'
14
+
15
+ if (ActiveRecord::Base.connection == Database.connection)
16
+ if (!Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_HOST], ext[:appid]] }).nil? &&
17
+ !Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_PORT], ext[:appid]] }).nil? &&
18
+ !Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_DATABASE], ext[:appid]] }).nil? &&
19
+ !Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_USER], ext[:appid]] }).nil? &&
20
+ !Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_PASSWORD], ext[:appid]] }).nil?)
21
+
22
+ connectionResult = Database.connect_sql(Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_ADAPTER], ext[:appid]] }).value,
23
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_HOST], ext[:appid]] }).value,
24
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_PORT], ext[:appid]] }).value,
25
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_USER], ext[:appid]] }).value,
26
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_PASSWORD], ext[:appid]] }).value,
27
+ Metadata.first({ :conditions => ['key = ? and sites_id = ?', dbms_config[:DBMS_CURRENT_DATABASE], ext[:appid]] }).value)
28
+ if (!connectionResult)
29
+ return "{{[alliance_dbms - #{placeholder.key}] Unable to establish connection to database}}"
30
+ end
31
+ else
32
+ return "{{[alliance_dbms - #{placeholder.key}] Missing important keys to establish connection}}"
33
+ end
34
+ end
35
+
36
+ if attrs['configs'].has_key?('data')
37
+ tQueryItem = Metadata.all({ :conditions => ['key = ? and sites_id = ?', attrs['configs']['data'], ext[:appid]] })
38
+ languageSwitchable = Metadata.first({ :conditions => ['key = ? and sites_id = ?', 'autoLanguageSwitch'. ext[:appid]] })
39
+ queryItem = nil
40
+
41
+ tQueryItem.each do |query|
42
+ tQueryItemJsonObject = ActiveSupport::JSON.decode(SymmetricEncryption.decrypt(query.value))
43
+ tQueryItemJsonObjectLanguage = tQueryItemJsonObject['language'].scan(/^[a-z]{2}/).first
44
+
45
+ if (!languageSwitchable.nil?)
46
+ if (languageSwitchable.value == 'yes')
47
+ if (exts[:language] == tQueryItemJsonObjectLanguage)
48
+ queryItem = query
49
+ break
50
+ end
51
+ elsif (languageSwitchable.value == 'no')
52
+ if ('no' == tQueryItemJsonObjectLanguage)
53
+ queryItem = query
54
+ break
55
+ end
56
+ else
57
+ return "{{alliance-dbms - #{placeholder.key} the \"value\" for language switchability is invalid}}"
58
+ end
59
+ else
60
+ return "{{alliance-dbms - #{placeholder.key} Language switchability is not available}}"
61
+ end
62
+ end
63
+
64
+ if (!queryItem.nil?)
65
+
66
+ queryItemJsonObject = ActiveSupport::JSON.decode(SymmetricEncryption.decrypt(queryItem.value))
67
+ queryItemJsonData = Database.connection.select_all(queryItemJsonObject['sql'])
68
+
69
+ if (attrs['configs'].has_key?('tple') && attrs['configs'].has_key?('tplo'))
70
+ # if it is alternate template
71
+ contentResult = ''
72
+
73
+ queryItemEvenTemplate = Metadata.find_by_key(attrs['configs']['tple'])
74
+ queryItemOddTemplate = Metadata.find_by_key(attrs['configs']['tplo'])
75
+
76
+ if (!queryItemEvenTemplate.nil? && !queryItemOddTemplate.nil?)
77
+ tplCount = 0
78
+ queryItemJsonData.each do |q|
79
+ itemTemplate = ''
80
+
81
+ if (tplCount % 2 == 0)
82
+ itemTemplate = queryItemEvenTemplate.value.strip
83
+ else
84
+ itemTemplate = queryItemOddTemplate.value.strip
85
+ end
86
+ parsedObjs = itemTemplate.scan(/\[\[\$[a-zA-Z\-_]+\]\]/)
87
+
88
+ parsedObjs.each do |p|
89
+ tpObj = p.gsub(/[^a-zA-Z\-_]/, '')
90
+
91
+ if (!q[tpObj].nil?)
92
+ itemTemplate = itemTemplate.gsub(p, q[tpObj].to_s.strip)
93
+ else
94
+ itemTemplate = itemTemplate.gsub(p, '')
95
+ end
96
+ end
97
+
98
+ contentResult << itemTemplate
99
+ tplCount = tplCount + 1
100
+ end
101
+ end
102
+
103
+ # Content should be empty if even and odd template don't exist
104
+ contentResult
105
+ elsif (attrs['configs'].keys.grep(/^tpl[0-9]+$/).size > 0)
106
+ # if it is multiple template
107
+ "{{[alliance-dbms - #{placeholder.key}] multiple template is not supported}}"
108
+ else
109
+ # if it is single template
110
+ contentResult = ''
111
+
112
+ queryItemJsonData.each do |q|
113
+ queryItemTemplate = placeholder.value.strip
114
+ parsedObjs = queryItemTemplate.scan(/\[\[\$[a-zA-Z\-_]+\]\]/)
115
+
116
+ parsedObjs.each do |p|
117
+ tpObj = p.gsub(/[^a-zA-Z\-_]/, '')
118
+
119
+ if (!q[tpObj].nil?)
120
+ queryItemTemplate = queryItemTemplate.gsub(p, q[tpObj].to_s.strip)
121
+ else
122
+ queryItemTemplate = queryItemTemplate.gsub(p, '')
123
+ end
124
+ end
125
+
126
+ contentResult << queryItemTemplate
127
+ end
128
+
129
+ # Content should be empty if db returns no data
130
+ contentResult
131
+ end
132
+ else
133
+ placeholder.value.strip.html_safe
134
+ end
135
+ else
136
+ placeholder.value.strip.html_safe
137
+ end
138
+ else
139
+ placeholder.value.strip.html_safe
140
+ end
141
+ else
142
+ placeholder.value.strip.html_safe
143
+ end
144
+ else
145
+ placeholder.value.strip.html_safe
146
+ end
147
+ rescue Exception => ex
148
+ "{{[alliance-dbms - #{placeholder.key}] #{ex.message}}}"
149
+ end
150
+ end
151
+
152
+ end
153
+ end
@@ -0,0 +1,14 @@
1
+ require "rubygems"
2
+ require "mysql2"
3
+ require "pg"
4
+
5
+ module RxcmsDbmsPlugin
6
+ extend ::ActiveSupport::Autoload
7
+
8
+ autoload :Mysql2
9
+ autoload :PG
10
+
11
+ class Engine < ::Rails::Engine
12
+ config.autoload_paths += Dir["#{config.root}/lib/rxcms-dbms_plugin/classes/**/"]
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module RxcmsDbmsPlugin
2
+ VERSION = "0.3.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "rxcms-dbms_plugin/engine"
2
+
3
+ module RxcmsDbmsPlugin
4
+ require 'rxcms-dbms_plugin/classes/executor'
5
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :rxcms-dbms_plugin do
3
+ # # Task goes here
4
+ # end