@@ -271,6 +271,17 @@ def delete
271271 client . delete ( uri )
272272 end
273273
274+ # Helper for getting rid of all data in the project
275+ #
276+ # @option options [Boolean] :force has to be added otherwise the operation is not performed
277+ # @return [Array] Result of executing MAQLs
278+ def delete_all_data ( options = { } )
279+ return false unless options [ :force ]
280+ datasets . pmap do |dataset |
281+ execute_maql ( "SYNCHRONIZE {#{ dataset . identifier } }" )
282+ end
283+ end
284+
274285 # Deletes dashboards for project
275286 def delete_dashboards
276287 Dashboard . all . map { |data | Dashboard [ data [ 'link' ] ] } . each { |d | d . delete }
@@ -284,17 +295,29 @@ def deploy_process(path, options = {})
284295 # for some examples and explanations
285296 #
286297 # @param dml [String] DML expression
298+ # @return [Hash] Result of executing DML
287299 def execute_dml ( dml )
288300 uri = "/gdc/md/#{ pid } /dml/manage"
289- result = GoodData . post ( uri ,
290- manage : {
291- maql : dml
292- } )
301+ result = client . post ( uri , manage : { maql : dml } )
293302 polling_uri = result [ 'uri' ]
294- result = client . get ( polling_uri )
295- while result [ 'taskState' ] && result [ 'taskState' ] [ 'status' ] == 'WAIT'
296- sleep 10
297- result = client . get polling_uri
303+
304+ client . poll_on_response ( polling_uri ) do |body |
305+ body && body [ 'taskState' ] && body [ 'taskState' ] [ 'status' ] == 'WAIT'
306+ end
307+ end
308+
309+ # Executes MAQL expression and waits for it to be finished.
310+ #
311+ # @param maql [String] MAQL expression
312+ # @return [Hash] Result of executing MAQL
313+ def execute_maql ( maql )
314+ ldm_links = client . get ( md [ GoodData ::Model ::LDM_CTG ] )
315+ ldm_uri = Links . new ( ldm_links ) [ GoodData ::Model ::LDM_MANAGE_CTG ]
316+ response = client . post ( ldm_uri , manage : { maql : maql } )
317+ polling_uri = response [ 'entries' ] . first [ 'link' ]
318+
319+ client . poll_on_response ( polling_uri ) do |body |
320+ body && body [ 'wTaskStatus' ] && body [ 'wTaskStatus' ] [ 'status' ] == 'RUNNING'
298321 end
299322 end
300323
@@ -674,7 +697,7 @@ def partial_md_export(objects, options = {})
674697
675698 alias_method :transfer_objects , :partial_md_export
676699
677- # Helper for getting reports of a project
700+ # Helper for getting processes of a project
678701 #
679702 # @param [String | Number | Object] Anything that you can pass to GoodData::Report[id]
680703 # @return [GoodData::Report | Array<GoodData::Report>] report instance or list
@@ -725,7 +748,7 @@ def reload!
725748 # @param [String | Number | Object] Anything that you can pass to GoodData::Report[id]
726749 # @return [GoodData::Report | Array<GoodData::Report>] report instance or list
727750 def reports ( id = :all )
728- GoodData ::Report [ id , project : self ]
751+ GoodData ::Report [ id , project : self , client : client ]
729752 end
730753
731754 # Helper for getting report definitions of a project
0 commit comments