Commit 7d057d72c2bd0c103582d4404623a74d6d8d0d06

Authored by Ali B
1 parent 26693b83

Working on routs, fixed so the API now follows the RESTful standard and working on patch requests

Showing 2 changed files with 245 additions and 184 deletions   Show diff stats
restApi/.idea/workspace.xml
... ... @@ -2,6 +2,7 @@
2 2 <project version="4">
3 3 <component name="ChangeListManager">
4 4 <list default="true" id="8a337026-05ab-47b0-872d-ab1e8037e9a0" name="Default" comment="">
  5 + <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
5 6 <change beforePath="$PROJECT_DIR$/api/routes/routes.js" afterPath="$PROJECT_DIR$/api/routes/routes.js" />
6 7 </list>
7 8 <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
... ... @@ -54,38 +55,8 @@
54 55 <file leaf-file-name="routes.js" pinned="false" current-in-tab="true">
55 56 <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
56 57 <provider selected="true" editor-type-id="text-editor">
57   - <state relative-caret-position="690">
58   - <caret line="46" column="4" lean-forward="false" selection-start-line="46" selection-start-column="4" selection-end-line="46" selection-end-column="4" />
59   - <folding />
60   - </state>
61   - </provider>
62   - </entry>
63   - </file>
64   - <file leaf-file-name="server.js" pinned="false" current-in-tab="false">
65   - <entry file="file://$PROJECT_DIR$/server.js">
66   - <provider selected="true" editor-type-id="text-editor">
67   - <state relative-caret-position="105">
68   - <caret line="7" column="0" lean-forward="false" selection-start-line="7" selection-start-column="0" selection-end-line="7" selection-end-column="0" />
69   - <folding />
70   - </state>
71   - </provider>
72   - </entry>
73   - </file>
74   - <file leaf-file-name="README.txt" pinned="false" current-in-tab="false">
75   - <entry file="file://$PROJECT_DIR$/README.txt">
76   - <provider selected="true" editor-type-id="text-editor">
77   - <state relative-caret-position="120">
78   - <caret line="8" column="58" lean-forward="false" selection-start-line="8" selection-start-column="58" selection-end-line="8" selection-end-column="58" />
79   - <folding />
80   - </state>
81   - </provider>
82   - </entry>
83   - </file>
84   - <file leaf-file-name="package-lock.json" pinned="false" current-in-tab="false">
85   - <entry file="file://$PROJECT_DIR$/package-lock.json">
86   - <provider selected="true" editor-type-id="text-editor">
87   - <state relative-caret-position="0">
88   - <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
  58 + <state relative-caret-position="595">
  59 + <caret line="94" column="56" lean-forward="true" selection-start-line="94" selection-start-column="56" selection-end-line="94" selection-end-column="56" />
89 60 <folding />
90 61 </state>
91 62 </provider>
... ... @@ -94,43 +65,13 @@
94 65 <file leaf-file-name="package.json" pinned="false" current-in-tab="false">
95 66 <entry file="file://$PROJECT_DIR$/package.json">
96 67 <provider selected="true" editor-type-id="text-editor">
97   - <state relative-caret-position="360">
  68 + <state relative-caret-position="408">
98 69 <caret line="24" column="0" lean-forward="false" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
99 70 <folding />
100 71 </state>
101 72 </provider>
102 73 </entry>
103 74 </file>
104   - <file leaf-file-name="incident.js" pinned="false" current-in-tab="false">
105   - <entry file="file://$PROJECT_DIR$/api/modules/incident.js">
106   - <provider selected="true" editor-type-id="text-editor">
107   - <state relative-caret-position="135">
108   - <caret line="9" column="1" lean-forward="false" selection-start-line="9" selection-start-column="1" selection-end-line="9" selection-end-column="1" />
109   - <folding />
110   - </state>
111   - </provider>
112   - </entry>
113   - </file>
114   - <file leaf-file-name="activity.js" pinned="false" current-in-tab="false">
115   - <entry file="file://$PROJECT_DIR$/api/modules/activity.js">
116   - <provider selected="true" editor-type-id="text-editor">
117   - <state relative-caret-position="105">
118   - <caret line="7" column="23" lean-forward="true" selection-start-line="7" selection-start-column="23" selection-end-line="7" selection-end-column="23" />
119   - <folding />
120   - </state>
121   - </provider>
122   - </entry>
123   - </file>
124   - <file leaf-file-name="evaluation.js" pinned="false" current-in-tab="false">
125   - <entry file="file://$PROJECT_DIR$/api/modules/evaluation.js">
126   - <provider selected="true" editor-type-id="text-editor">
127   - <state relative-caret-position="30">
128   - <caret line="2" column="9" lean-forward="false" selection-start-line="2" selection-start-column="9" selection-end-line="2" selection-end-column="19" />
129   - <folding />
130   - </state>
131   - </provider>
132   - </entry>
133   - </file>
134 75 </leaf>
135 76 </component>
136 77 <component name="FileTemplateManagerImpl">
... ... @@ -144,6 +85,7 @@
144 85 <findStrings>
145 86 <find>get</find>
146 87 <find>.get</find>
  88 + <find>patch</find>
147 89 </findStrings>
148 90 </component>
149 91 <component name="Git.Settings">
... ... @@ -193,6 +135,9 @@
193 135 <path value="$PROJECT_DIR$/package.json" />
194 136 </packageJsonPaths>
195 137 </component>
  138 + <component name="PhpServers">
  139 + <servers />
  140 + </component>
196 141 <component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
197 142 <component name="ProjectFrameBounds" fullScreen="true">
198 143 <option name="x" value="1440" />
... ... @@ -217,35 +162,35 @@
217 162 </navigator>
218 163 <panes>
219 164 <pane id="Scratches" />
  165 + <pane id="Scope" />
220 166 <pane id="ProjectPane">
221 167 <subPane>
222 168 <expand>
223 169 <path>
224 170 <item name="restApi" type="b2602c69:ProjectViewProjectNode" />
225   - <item name="restApi" type="462c0819:PsiDirectoryNode" />
  171 + <item name="restApi" type="2a2b976b:PhpTreeStructureProvider$1" />
226 172 </path>
227 173 <path>
228 174 <item name="restApi" type="b2602c69:ProjectViewProjectNode" />
229   - <item name="restApi" type="462c0819:PsiDirectoryNode" />
230   - <item name="api" type="462c0819:PsiDirectoryNode" />
  175 + <item name="restApi" type="2a2b976b:PhpTreeStructureProvider$1" />
  176 + <item name="api" type="2a2b976b:PhpTreeStructureProvider$1" />
231 177 </path>
232 178 <path>
233 179 <item name="restApi" type="b2602c69:ProjectViewProjectNode" />
234   - <item name="restApi" type="462c0819:PsiDirectoryNode" />
235   - <item name="api" type="462c0819:PsiDirectoryNode" />
236   - <item name="modules" type="462c0819:PsiDirectoryNode" />
  180 + <item name="restApi" type="2a2b976b:PhpTreeStructureProvider$1" />
  181 + <item name="api" type="2a2b976b:PhpTreeStructureProvider$1" />
  182 + <item name="modules" type="2a2b976b:PhpTreeStructureProvider$1" />
237 183 </path>
238 184 <path>
239 185 <item name="restApi" type="b2602c69:ProjectViewProjectNode" />
240   - <item name="restApi" type="462c0819:PsiDirectoryNode" />
241   - <item name="api" type="462c0819:PsiDirectoryNode" />
242   - <item name="routes" type="462c0819:PsiDirectoryNode" />
  186 + <item name="restApi" type="2a2b976b:PhpTreeStructureProvider$1" />
  187 + <item name="api" type="2a2b976b:PhpTreeStructureProvider$1" />
  188 + <item name="routes" type="2a2b976b:PhpTreeStructureProvider$1" />
243 189 </path>
244 190 </expand>
245 191 <select />
246 192 </subPane>
247 193 </pane>
248   - <pane id="Scope" />
249 194 </panes>
250 195 </component>
251 196 <component name="PropertiesComponent">
... ... @@ -295,30 +240,32 @@
295 240 <servers />
296 241 </component>
297 242 <component name="TimeTrackingManager">
298   - <option name="totallyTimeSpent" value="32345000" />
  243 + <option name="totallyTimeSpent" value="37232000" />
299 244 </component>
300 245 <component name="ToolWindowManager">
301   - <frame x="1440" y="-180" width="1920" height="1080" extended-state="0" />
  246 + <frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
302 247 <editor active="true" />
303 248 <layout>
304   - <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.18746708" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
  249 + <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.20309168" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
305 250 <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
306   - <window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
307   - <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
308   - <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.329602" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
309   - <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
  251 + <window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
  252 + <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="true" content_ui="tabs" />
  253 + <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
  254 + <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
310 255 <window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
  256 + <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32934782" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
311 257 <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
312   - <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
313   - <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
  258 + <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
  259 + <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="true" content_ui="tabs" />
314 260 <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
315 261 <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
  262 + <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
316 263 <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
317 264 <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
318 265 <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
319 266 <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
  267 + <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.18746708" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
320 268 <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
321   - <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
322 269 <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
323 270 </layout>
324 271 </component>
... ... @@ -335,6 +282,137 @@
335 282 <component name="editorHistoryManager">
336 283 <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
337 284 <provider selected="true" editor-type-id="text-editor">
  285 + <state relative-caret-position="119">
  286 + <caret line="7" column="14" lean-forward="false" selection-start-line="7" selection-start-column="14" selection-end-line="7" selection-end-column="14" />
  287 + <folding />
  288 + </state>
  289 + </provider>
  290 + </entry>
  291 + <entry file="file://$PROJECT_DIR$/server.js">
  292 + <provider selected="true" editor-type-id="text-editor">
  293 + <state relative-caret-position="170">
  294 + <caret line="10" column="18" lean-forward="false" selection-start-line="10" selection-start-column="18" selection-end-line="10" selection-end-column="18" />
  295 + <folding />
  296 + </state>
  297 + </provider>
  298 + </entry>
  299 + <entry file="file://$PROJECT_DIR$/api/modules/incident.js">
  300 + <provider selected="true" editor-type-id="text-editor">
  301 + <state relative-caret-position="170">
  302 + <caret line="10" column="9" lean-forward="false" selection-start-line="10" selection-start-column="9" selection-end-line="10" selection-end-column="9" />
  303 + <folding />
  304 + </state>
  305 + </provider>
  306 + </entry>
  307 + <entry file="file://$PROJECT_DIR$/api/modules/activity.js">
  308 + <provider selected="true" editor-type-id="text-editor">
  309 + <state relative-caret-position="0">
  310 + <caret line="0" column="19" lean-forward="false" selection-start-line="0" selection-start-column="19" selection-end-line="0" selection-end-column="19" />
  311 + <folding />
  312 + </state>
  313 + </provider>
  314 + </entry>
  315 + <entry file="file://$PROJECT_DIR$/api/modules/evaluation.js">
  316 + <provider selected="true" editor-type-id="text-editor">
  317 + <state relative-caret-position="153">
  318 + <caret line="9" column="49" lean-forward="false" selection-start-line="9" selection-start-column="49" selection-end-line="9" selection-end-column="49" />
  319 + <folding />
  320 + </state>
  321 + </provider>
  322 + </entry>
  323 + <entry file="file://$PROJECT_DIR$/package.json">
  324 + <provider selected="true" editor-type-id="text-editor">
  325 + <state relative-caret-position="357">
  326 + <caret line="21" column="19" lean-forward="false" selection-start-line="21" selection-start-column="19" selection-end-line="21" selection-end-column="19" />
  327 + <folding />
  328 + </state>
  329 + </provider>
  330 + </entry>
  331 + <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
  332 + <provider selected="true" editor-type-id="text-editor">
  333 + <state relative-caret-position="0">
  334 + <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
  335 + <folding />
  336 + </state>
  337 + </provider>
  338 + </entry>
  339 + <entry file="file://$PROJECT_DIR$/api/modules/incident.js">
  340 + <provider selected="true" editor-type-id="text-editor">
  341 + <state relative-caret-position="153">
  342 + <caret line="9" column="1" lean-forward="false" selection-start-line="9" selection-start-column="1" selection-end-line="9" selection-end-column="1" />
  343 + <folding />
  344 + </state>
  345 + </provider>
  346 + </entry>
  347 + <entry file="file://$PROJECT_DIR$/api/modules/activity.js">
  348 + <provider selected="true" editor-type-id="text-editor">
  349 + <state relative-caret-position="0">
  350 + <caret line="0" column="19" lean-forward="false" selection-start-line="0" selection-start-column="19" selection-end-line="0" selection-end-column="19" />
  351 + <folding />
  352 + </state>
  353 + </provider>
  354 + </entry>
  355 + <entry file="file://$PROJECT_DIR$/api/modules/evaluation.js">
  356 + <provider selected="true" editor-type-id="text-editor">
  357 + <state relative-caret-position="170">
  358 + <caret line="10" column="1" lean-forward="false" selection-start-line="10" selection-start-column="1" selection-end-line="10" selection-end-column="1" />
  359 + <folding />
  360 + </state>
  361 + </provider>
  362 + </entry>
  363 + <entry file="file://$PROJECT_DIR$/api/models/evaluationModel.js" />
  364 + <entry file="file://$PROJECT_DIR$/api/models/models.js" />
  365 + <entry file="file://$PROJECT_DIR$/api/controllers/evaluationController.js" />
  366 + <entry file="file://$PROJECT_DIR$/api/modules/evaluation.js">
  367 + <provider selected="true" editor-type-id="text-editor">
  368 + <state relative-caret-position="153">
  369 + <caret line="9" column="49" lean-forward="false" selection-start-line="9" selection-start-column="49" selection-end-line="9" selection-end-column="49" />
  370 + <folding />
  371 + </state>
  372 + </provider>
  373 + </entry>
  374 + <entry file="file://$PROJECT_DIR$/api/modules/activity.js">
  375 + <provider selected="true" editor-type-id="text-editor">
  376 + <state relative-caret-position="0">
  377 + <caret line="0" column="19" lean-forward="false" selection-start-line="0" selection-start-column="19" selection-end-line="0" selection-end-column="19" />
  378 + <folding />
  379 + </state>
  380 + </provider>
  381 + </entry>
  382 + <entry file="file://$PROJECT_DIR$/server.js">
  383 + <provider selected="true" editor-type-id="text-editor">
  384 + <state relative-caret-position="170">
  385 + <caret line="10" column="18" lean-forward="false" selection-start-line="10" selection-start-column="18" selection-end-line="10" selection-end-column="18" />
  386 + <folding />
  387 + </state>
  388 + </provider>
  389 + </entry>
  390 + <entry file="file://$PROJECT_DIR$/api/modules/incident.js">
  391 + <provider selected="true" editor-type-id="text-editor">
  392 + <state relative-caret-position="170">
  393 + <caret line="10" column="9" lean-forward="false" selection-start-line="10" selection-start-column="9" selection-end-line="10" selection-end-column="9" />
  394 + <folding />
  395 + </state>
  396 + </provider>
  397 + </entry>
  398 + <entry file="file://$PROJECT_DIR$/package.json">
  399 + <provider selected="true" editor-type-id="text-editor">
  400 + <state relative-caret-position="170">
  401 + <caret line="10" column="13" lean-forward="false" selection-start-line="10" selection-start-column="13" selection-end-line="10" selection-end-column="13" />
  402 + <folding />
  403 + </state>
  404 + </provider>
  405 + </entry>
  406 + <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
  407 + <provider selected="true" editor-type-id="text-editor">
  408 + <state relative-caret-position="-136">
  409 + <caret line="7" column="14" lean-forward="false" selection-start-line="7" selection-start-column="14" selection-end-line="7" selection-end-column="14" />
  410 + <folding />
  411 + </state>
  412 + </provider>
  413 + </entry>
  414 + <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
  415 + <provider selected="true" editor-type-id="text-editor">
338 416 <state relative-caret-position="0">
339 417 <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
340 418 <folding />
... ... @@ -345,7 +423,6 @@
345 423 <provider selected="true" editor-type-id="text-editor">
346 424 <state relative-caret-position="105">
347 425 <caret line="7" column="0" lean-forward="false" selection-start-line="7" selection-start-column="0" selection-end-line="7" selection-end-column="0" />
348   - <folding />
349 426 </state>
350 427 </provider>
351 428 </entry>
... ... @@ -353,7 +430,6 @@
353 430 <provider selected="true" editor-type-id="text-editor">
354 431 <state relative-caret-position="120">
355 432 <caret line="8" column="58" lean-forward="false" selection-start-line="8" selection-start-column="58" selection-end-line="8" selection-end-column="58" />
356   - <folding />
357 433 </state>
358 434 </provider>
359 435 </entry>
... ... @@ -361,7 +437,6 @@
361 437 <provider selected="true" editor-type-id="text-editor">
362 438 <state relative-caret-position="0">
363 439 <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
364   - <folding />
365 440 </state>
366 441 </provider>
367 442 </entry>
... ... @@ -369,7 +444,6 @@
369 444 <provider selected="true" editor-type-id="text-editor">
370 445 <state relative-caret-position="135">
371 446 <caret line="9" column="1" lean-forward="false" selection-start-line="9" selection-start-column="1" selection-end-line="9" selection-end-column="1" />
372   - <folding />
373 447 </state>
374 448 </provider>
375 449 </entry>
... ... @@ -385,7 +459,6 @@
385 459 <provider selected="true" editor-type-id="text-editor">
386 460 <state relative-caret-position="0">
387 461 <caret line="0" column="19" lean-forward="false" selection-start-line="0" selection-start-column="19" selection-end-line="0" selection-end-column="19" />
388   - <folding />
389 462 </state>
390 463 </provider>
391 464 </entry>
... ... @@ -393,7 +466,6 @@
393 466 <provider selected="true" editor-type-id="text-editor">
394 467 <state relative-caret-position="30">
395 468 <caret line="2" column="9" lean-forward="false" selection-start-line="2" selection-start-column="9" selection-end-line="2" selection-end-column="19" />
396   - <folding />
397 469 </state>
398 470 </provider>
399 471 </entry>
... ... @@ -409,7 +481,6 @@
409 481 <provider selected="true" editor-type-id="text-editor">
410 482 <state relative-caret-position="135">
411 483 <caret line="9" column="1" lean-forward="false" selection-start-line="9" selection-start-column="1" selection-end-line="9" selection-end-column="1" />
412   - <folding />
413 484 </state>
414 485 </provider>
415 486 </entry>
... ... @@ -417,7 +488,6 @@
417 488 <provider selected="true" editor-type-id="text-editor">
418 489 <state relative-caret-position="0">
419 490 <caret line="0" column="19" lean-forward="false" selection-start-line="0" selection-start-column="19" selection-end-line="0" selection-end-column="19" />
420   - <folding />
421 491 </state>
422 492 </provider>
423 493 </entry>
... ... @@ -425,7 +495,6 @@
425 495 <provider selected="true" editor-type-id="text-editor">
426 496 <state relative-caret-position="150">
427 497 <caret line="10" column="1" lean-forward="false" selection-start-line="10" selection-start-column="1" selection-end-line="10" selection-end-column="1" />
428   - <folding />
429 498 </state>
430 499 </provider>
431 500 </entry>
... ... @@ -436,7 +505,6 @@
436 505 <provider selected="true" editor-type-id="text-editor">
437 506 <state relative-caret-position="105">
438 507 <caret line="7" column="0" lean-forward="false" selection-start-line="7" selection-start-column="0" selection-end-line="7" selection-end-column="0" />
439   - <folding />
440 508 </state>
441 509 </provider>
442 510 </entry>
... ... @@ -444,7 +512,6 @@
444 512 <provider selected="true" editor-type-id="text-editor">
445 513 <state relative-caret-position="120">
446 514 <caret line="8" column="58" lean-forward="false" selection-start-line="8" selection-start-column="58" selection-end-line="8" selection-end-column="58" />
447   - <folding />
448 515 </state>
449 516 </provider>
450 517 </entry>
... ... @@ -452,15 +519,6 @@
452 519 <provider selected="true" editor-type-id="text-editor">
453 520 <state relative-caret-position="0">
454 521 <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
455   - <folding />
456   - </state>
457   - </provider>
458   - </entry>
459   - <entry file="file://$PROJECT_DIR$/package.json">
460   - <provider selected="true" editor-type-id="text-editor">
461   - <state relative-caret-position="360">
462   - <caret line="24" column="0" lean-forward="false" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
463   - <folding />
464 522 </state>
465 523 </provider>
466 524 </entry>
... ... @@ -468,7 +526,6 @@
468 526 <provider selected="true" editor-type-id="text-editor">
469 527 <state relative-caret-position="135">
470 528 <caret line="9" column="1" lean-forward="false" selection-start-line="9" selection-start-column="1" selection-end-line="9" selection-end-column="1" />
471   - <folding />
472 529 </state>
473 530 </provider>
474 531 </entry>
... ... @@ -476,7 +533,6 @@
476 533 <provider selected="true" editor-type-id="text-editor">
477 534 <state relative-caret-position="30">
478 535 <caret line="2" column="9" lean-forward="false" selection-start-line="2" selection-start-column="9" selection-end-line="2" selection-end-column="19" />
479   - <folding />
480 536 </state>
481 537 </provider>
482 538 </entry>
... ... @@ -484,14 +540,21 @@
484 540 <provider selected="true" editor-type-id="text-editor">
485 541 <state relative-caret-position="105">
486 542 <caret line="7" column="23" lean-forward="true" selection-start-line="7" selection-start-column="23" selection-end-line="7" selection-end-column="23" />
  543 + </state>
  544 + </provider>
  545 + </entry>
  546 + <entry file="file://$PROJECT_DIR$/package.json">
  547 + <provider selected="true" editor-type-id="text-editor">
  548 + <state relative-caret-position="408">
  549 + <caret line="24" column="0" lean-forward="false" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
487 550 <folding />
488 551 </state>
489 552 </provider>
490 553 </entry>
491 554 <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
492 555 <provider selected="true" editor-type-id="text-editor">
493   - <state relative-caret-position="690">
494   - <caret line="46" column="4" lean-forward="false" selection-start-line="46" selection-start-column="4" selection-end-line="46" selection-end-column="4" />
  556 + <state relative-caret-position="595">
  557 + <caret line="94" column="56" lean-forward="true" selection-start-line="94" selection-start-column="56" selection-end-line="94" selection-end-column="56" />
495 558 <folding />
496 559 </state>
497 560 </provider>
... ...
restApi/api/routes/routes.js
... ... @@ -3,40 +3,10 @@ const Incident = require(&quot;../modules/incident.js&quot;);
3 3 const Evaluation = require("../modules/evaluation.js");
4 4 const Activity = require("../modules/activity.js");
5 5  
6   -
7 6 const uuid = require('uuid');
8 7 var cassandra = require("cassandra-driver");
9 8  
10   -var client = new cassandra.Client({contactPoints: ['127.0.0.1']});
11   -client.connect(function (err, result) {
12   - if(err) console.log("Could not connect to Cassandra");
13   - console.log('Successfully connected to Cassandra');
14   -});
15   -
16   -
17   -client.execute("CREATE KEYSPACE IF NOT EXISTS risk WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1};", function (err) {
18   - if (err) console.log("Failed to create keyspace. Error: " + err);
19   -
20   - client.execute("CREATE TABLE risk.incident(uuid uuid, id int, date date, location text, title text, description text, associatedEval int, PRIMARY KEY(id));", function (err) {
21   - if (err) console.log("Failed to create table incident. Error: " + err)
22   - });
23   -
24   - client.execute("CREATE TABLE risk.evaluation(id int, uuid uuid, title text, outcome text, measures text, consequence int, probability int, associatedActivity int, PRIMARY KEY(id));", function (err) {
25   - if (err) console.log("Failed to create table evaluation. Error: " + err)
26   - });
27   -
28   - client.execute("CREATE TABLE risk.activity(id int, uuid uuid, title text, PRIMARY KEY(id));", function (err) {
29   - if (err) console.log("Failed to create table activity. Error: " + err)
30   - });
31   -});
32   -
33   -
34   -
35   -var mockIncidents = [
36   - new Incident("1", "03.03.2018", "Bodø", "Datt på isen", "Datt på isen når jeg skuplle gå til bilen", "4"),
37   - new Incident("2", "11.11.2012", "Oslo", "Bilkræsj", "Kræsjet med en annen bil", "2"),
38   - new Incident("3", "26.04.2018", "Bodø", "Tråkket over", "Tråkket over og vrikket foten", "5")
39   -];
  9 +setupDatabase('127.0.0.1');
40 10  
41 11 var appRouter = function(app) {
42 12  
... ... @@ -49,16 +19,15 @@ var appRouter = function(app) {
49 19 /**
50 20 * Get incident by id endpoint (http://localhost:3000/getIncident?id=1 will return incident with id 1)
51 21 */
  22 + app.get("/incident/:id", function (req, res) {
52 23  
53   - app.get("/getIncident", function (req, res) {
54   -
55   - client.execute('SELECT * FROM risk.incident WHERE id=' + req.query.id, [], function(err, result) {
  24 + client.execute('SELECT * FROM risk.incident WHERE id=' + req.params.id, [], function(err, result) {
56 25 if(err) {
57 26 console.log(err);
58   - return res.send({"status": "error", "message": "Missing id, please use /getIncident?id=[id]"})
  27 + return res.send({"status": "error", "message": "Missing id, please use /getIncident/{id}"})
59 28 } else {
60 29 if (result.rows.length != 0)
61   - return res.send(result.rows[0])
  30 + return res.send(result.rows[0]);
62 31 else
63 32 return res.send({"status": "error", "message": "Id not found"})
64 33  
... ... @@ -70,8 +39,7 @@ var appRouter = function(app) {
70 39 /**
71 40 * See all incidents
72 41 */
73   -
74   - app.get("/getAllIncidents", function (req, res) {
  42 + app.get("/incident", function (req, res) {
75 43  
76 44 client.execute('SELECT * FROM risk.incident', [], function (err, result) {
77 45 if(err) {
... ... @@ -90,10 +58,9 @@ var appRouter = function(app) {
90 58 });
91 59  
92 60 /**
93   - * Add a new incident (http://localhost:3000/addIncident - with an "x-www-form-urlencoded" body of params)
  61 + * Add a new incident (a post request at http://localhost:3000/incident - with an "x-www-form-urlencoded" body of params)
94 62 */
95   -
96   - app.post("/addIncident", function(req, res) {
  63 + app.post("/incident", function(req, res) {
97 64  
98 65 // All these parameters must exist in the body with the exact name for this method to work
99 66 if(!req.body.id || !req.body.date || !req.body.location || !req.body.title || !req.body.description || !req.body.associatedEval) {
... ... @@ -114,42 +81,43 @@ var appRouter = function(app) {
114 81 });
115 82  
116 83 /**
117   - * Update an incident (http://localhost:3000/updateIncident?id=1 will update the incident with id=1 with the params passed in the request body)
  84 + * Update an incident (a patch request at http://localhost:3000/incident/{id} will update the incident with id=1 with the params passed in the request body)
118 85 */
  86 + app.patch("/incident/:id", function (req, res) {
  87 + var foundIncident = null;
119 88  
  89 + //Only mock so nothing is really happening here, here the database should be updated
  90 + if (req.params.id) {
120 91  
121   - app.patch("/updateIncident", function (req, res) {
122   - var foundIncident = null;
  92 + client.execute("UPDATE risk.incident SET " +
  93 + (req.body.date !== null ? "date = ?" : "") +
  94 + (req.body.location !== null ? "location = ?" : "") +
  95 + (req.body.title !== null ? "title = ?");
123 96  
124   - //Search the array with mockIncidents and if id is found stop the loop and set foundIncident variable
125   - mockIncidents.forEach(function (value) {
126   - if (value.id === req.query.id) {
127   - foundIncident = value;
128   - return true;
129   - }
  97 + if (req.body.date !== null)
130 98  
131   - //Only mock so nothing is really happening here, here the database should be updated
132   - if (foundIncident != null) {
133   - if (req.body.date !== null) foundIncident.date = req.body.date;
134   - if (req.body.location !== null) foundIncident.location = req.body.location;
135   - if (req.body.title !== null) foundIncident.title = req.body.title;
136   - if (req.body.description !== null) foundIncident.description = req.body.description;
137   - if (req.body.associatedEval !== null) foundIncident.associatedEval = req.body.associatedEval;
138   - return res.send({"status": "success", "message": "Incident updated"});
139   - }
  99 + if (req.body.location !== null) foundIncident.location = req.body.location;
  100 + if (req.body.title !== null) foundIncident.title = req.body.title;
  101 + if (req.body.description !== null) foundIncident.description = req.body.description;
  102 + if (req.body.associatedEval !== null) foundIncident.associatedEval = req.body.associatedEval;
140 103  
  104 + return res.send({"status": "success", "message": "Incident updated"});
  105 + }
141 106 return res.send({"status": "error", "message": "Id missing"});
142 107  
143   - });
  108 +
144 109 });
145 110  
  111 + function updateTable(tableName, co) {
  112 +
  113 + }
  114 +
146 115  
147 116 /**
148   - * Delete an incident (http://localhost:3000/deleteIncident?id=1 should delete incident with id=1)
  117 + * Delete an incident (a delete request at http://localhost:3000/incident/{id} should delete incident with id=1)
149 118 */
150   -
151   - app.delete("/deleteIncident", function (req, res) {
152   - if (!req.query.id) return res.send({"status": "failed", "message": "Id missing"});
  119 + app.delete("/incident/:id", function (req, res) {
  120 + if (!req.params.id) return res.send({"status": "failed", "message": "Id missing"});
153 121  
154 122 return res.send({"status": "success", "message": "Nothing really deleted because this is a mock server but this should delete incident with id: " + req.query.id});
155 123 });
... ... @@ -159,9 +127,8 @@ var appRouter = function(app) {
159 127 /**
160 128 * See an evaluation with id x
161 129 */
162   -
163   - app.get("/getEvaluation", function (req, res) {
164   - client.execute('SELECT * FROM risk.evaluation WHERE id=' + req.query.id, [], function(err, result) {
  130 + app.get("/evaluation/:id", function (req, res) {
  131 + client.execute('SELECT * FROM risk.evaluation WHERE id=' + req.params.id, [], function(err, result) {
165 132 if(err) {
166 133 console.log(err);
167 134 return res.send({"status": "error", "message": "Missing id, please use /getEvaluation?id=[id]"})
... ... @@ -173,14 +140,13 @@ var appRouter = function(app) {
173 140 }
174 141 });
175 142  
176   - })
  143 + });
177 144  
178 145  
179 146 /**
180 147 * See all evaluations
181 148 */
182   -
183   - app.get("/getAllEvaluations", function (req, res) {
  149 + app.get("/evaluation", function (req, res) {
184 150  
185 151 client.execute('SELECT * FROM risk.evaluation', [], function (err, result) {
186 152 if(err) {
... ... @@ -202,8 +168,7 @@ var appRouter = function(app) {
202 168 /**
203 169 * Add a new evaluation
204 170 */
205   -
206   - app.post("/addEvaluation", function(req, res) {
  171 + app.post("/evaluation", function(req, res) {
207 172 if(!req.body.id || !req.body.title || !req.body.outcome || !req.body.measures || !req.body.consequence || !req.body.probability || !req.body.associatedActivity) {
208 173 return res.send({"status": "error", "message": "missing a parameter"});
209 174 } else {
... ... @@ -225,9 +190,8 @@ var appRouter = function(app) {
225 190 /**
226 191 * See an activity with id x
227 192 */
228   -
229   - app.get("/getActivity", function (req, res) {
230   - client.execute('SELECT * FROM risk.activity WHERE id=' + req.query.id, [], function(err, result) {
  193 + app.get("/activity/:id", function (req, res) {
  194 + client.execute('SELECT * FROM risk.activity WHERE id=' + req.params.id, [], function(err, result) {
231 195 if(err) {
232 196 console.log(err);
233 197 return res.send({"status": "error", "message": "Missing id, please use /getActivity?id=[id]"})
... ... @@ -246,8 +210,7 @@ var appRouter = function(app) {
246 210 /**
247 211 * See all activities
248 212 */
249   -
250   - app.get("/getAllActivities", function (req, res) {
  213 + app.get("/activity", function (req, res) {
251 214  
252 215 client.execute('SELECT * FROM risk.activity', [], function (err, result) {
253 216 if(err) {
... ... @@ -268,5 +231,40 @@ var appRouter = function(app) {
268 231  
269 232 };
270 233  
  234 +/**
  235 + * Sets up connection to the database at a given contact point
  236 + * @param contactPoint: cassandra contact point to connect to
  237 + */
  238 +function setupDatabase(contactPoint) {
  239 + var client = new cassandra.Client({contactPoints: [contactPoint]});
  240 + client.connect(function (err, result) {
  241 + if(err) console.log("Could not connect to Cassandra at " + contactPoint);
  242 + console.log('Successfully connected to Cassandra at ' + contactPoint);
  243 + });
  244 +
  245 + setupTables();
  246 +}
  247 +
  248 +/**
  249 +Creates keyspace and all tables needed if they don't exist
  250 + */
  251 +function setupTables() {
  252 + client.execute("CREATE KEYSPACE IF NOT EXISTS risk WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1};", function (err) {
  253 + if (err) console.log("Failed to create keyspace. Error: " + err);
  254 +
  255 + client.execute("CREATE TABLE risk.incident(uuid uuid, id int, date date, location text, title text, description text, associatedEval int, PRIMARY KEY(id));", function (err) {
  256 + if (err) console.log("Failed to create table incident.\n" + err)
  257 + });
  258 +
  259 + client.execute("CREATE TABLE risk.evaluation(id int, uuid uuid, title text, outcome text, measures text, consequence int, probability int, associatedActivity int, PRIMARY KEY(id));", function (err) {
  260 + if (err) console.log("Failed to create table evaluation.\n" + err)
  261 + });
  262 +
  263 + client.execute("CREATE TABLE risk.activity(id int, uuid uuid, title text, PRIMARY KEY(id));", function (err) {
  264 + if (err) console.log("Failed to create table activity.\n" + err)
  265 + });
  266 + });
  267 +}
  268 +
271 269  
272 270 module.exports = appRouter;
273 271 \ No newline at end of file
... ...