amalgame/commit

REVERT: oops, update process parameters is different from update node properties, and we need both. This is a manual revert of 6741270a2fd86ef9e0e117ed72868af94c048b43

authorJacco van Ossenbruggen
Sun Sep 7 11:11:13 2014 +0200
committerJacco van Ossenbruggen
Sun Sep 7 11:11:13 2014 +0200
commitc9571bd3f92f8cf4ffdd0d44a34ba3632b0e9915
tree5a6a28986711c445f7bb596bbd648f6b1432535c
parent77de416574cc78acb74015e2e01edeb8f08d1702
Diff style: patch stat
diff --git a/api/ag_process.pl b/api/ag_process.pl
index 89329c2..fd91bf8 100644
--- a/api/ag_process.pl
+++ b/api/ag_process.pl
@@ -54,7 +54,10 @@ http_add_process(Request) :-
 				   description('URI of an existing process or type of new process')]),
 			  strategy(Strategy,
 				    [uri,
-				     description('URI of the strategy graph to which the process is added')])
+				     description('URI of the strategy graph to which the process is added')]),
+			  update(Update,
+				 [boolean, default(false),
+				  descrption('When set to true process is updated with new parameters')])
 			],
 			[form_data(Params0)]),
 	sort(SecInputs0, SecInputs),
@@ -63,7 +66,15 @@ http_add_process(Request) :-
 	subtract(Params1, SecParams, Params),
 	fix_not_expanded_options(Params, ExpandedParams),
 	flush_refs_cache_if_needed(Process),
-	strategy_new_process(Strategy, Process, Source, Target, Input, SecInputs, ExpandedParams, Focus, URI),
+	(   Update == true
+	->  rdf_retractall(Process, amalgame:secondary_input, _, Strategy),
+	    flush_dependent_caches(Process, Strategy),
+	    strategy_update_process_parameters(Strategy, Process, SecInputs, ExpandedParams),
+	    Focus = Process, URI = Process
+	;   ((nonvar(Source), nonvar(Target)) ; nonvar(Input))
+	->  strategy_new_process(Strategy, Process, Source, Target, Input, SecInputs, ExpandedParams, Focus, URI)
+	;   true
+	),
 	% precompute results to speed things up
 	(   setting(amalgame:precompute, true)
 	->  precompute_process(Strategy, URI)
@@ -138,7 +149,6 @@ http_delete_node(Request) :-
 		       }).
 
 
-
 change_ns_if_needed(NS, URI, Strategy, NewStrategy) :-
 	rdf(Strategy, amalgame:publish_ns, OldNS, Strategy),
 	(   (OldNS == NS; NS == 'same')
diff --git a/lib/amalgame/ag_strategy.pl b/lib/amalgame/ag_strategy.pl
index f31b86b..68ba384 100644
--- a/lib/amalgame/ag_strategy.pl
+++ b/lib/amalgame/ag_strategy.pl
@@ -1,6 +1,7 @@
 :- module(ag_strategy,
 	  [ strategy_process_entity/3,
 	    strategy_new_process/9,
+	    strategy_update_process_parameters/4,
 	    strategy_update_node/3,
 	    strategy_delete_node/2,
 
@@ -21,6 +22,7 @@
 	strategy_process_entity(r,r,r),
 	strategy_delete_node(r,r),
 	strategy_update_node(r,+,r),
+	strategy_update_process_parameters(r,r,+,+),
 	assert_output(r,r,r,r,r,r),
 	new_output(r,r,r,r,r,r),
 	output_type(r,r),
@@ -47,6 +49,18 @@ strategy_new_process(Strategy, Type, Source, Target, Input, SecInputs, Params, F
 		assert_secondary_inputs(SecInputs, URI, Type, Strategy),
 		assert_output(URI, Type, Strategy, Input, SecInputs, Focus)
 	    )).
+%%	update_process(+Process, +Strategy, +SecInputs, +Params) is det.
+%
+%	Update the parameters of Process.
+strategy_update_process_parameters(Strategy, Process, SecInputs, Params) :-
+	uri_query_components(Search, Params),
+	rdf(Process, rdf:type, Type, Strategy),
+	assert_secondary_inputs(SecInputs, Process, Type, Strategy),
+	rdf_transaction((rdf_retractall(Process, amalgame:parameters, _),
+			 rdf_assert(Process, amalgame:parameters, literal(Search), Strategy)
+			)).
+
+
 %%	strategy_update_node(+Strategy, +Properties, +Node) is det.
 %
 %	Update Properties of Node in Strategy named graph.