amalgame/commit
REFACTORING: private fix_not_expanded_options/2 -> public expand_options/2
author | Jacco van Ossenbruggen |
---|---|
Tue Mar 3 15:13:50 2015 +0100 | |
committer | Jacco van Ossenbruggen |
Tue Mar 3 15:14:54 2015 +0100 | |
commit | 67023a1e7ff495c22cee907baba140c2fa5f2ff4 |
tree | b763382147ea90b382fe065164aa087dea561bdc |
parent | 9d19d8ea187a175a1a02b6c3276a77a876f90c25 |
Diff style: patch stat
diff --git a/api/ag_process.pl b/api/ag_process.pl index fd91bf8..38f8515 100644 --- a/api/ag_process.pl +++ b/api/ag_process.pl @@ -17,6 +17,7 @@ :- use_module(library(amalgame/ag_provenance)). :- use_module(library(amalgame/ag_strategy)). :- use_module(library(amalgame/json_util)). +:- use_module(library(amalgame/amalgame_modules)). :- setting(amalgame:precompute, boolean, true, @@ -64,7 +65,7 @@ http_add_process(Request) :- subtract(Params0, [input=_,source=_,target=_,process=_,strategy=_,update=_,graphic=_], Params1), findall(secondary_input=S,member(secondary_input=S, Params1), SecParams), subtract(Params1, SecParams, Params), - fix_not_expanded_options(Params, ExpandedParams), + expand_options(Params, ExpandedParams), flush_refs_cache_if_needed(Process), ( Update == true -> rdf_retractall(Process, amalgame:secondary_input, _, Strategy), @@ -204,17 +205,6 @@ fix_o_ns(rdf(S,P,O), Old, New) :- atom_concat(New,Local,NewO), rdf_update(S,P,O, object(NewO)). -fix_not_expanded_options([''],[]). -fix_not_expanded_options([],[]). -fix_not_expanded_options([Key=Value|Tail], [Key=FixedValue|Results]):- - ( \+ sub_atom(Value,0,_,_,'http:'), - atomic_list_concat([NS,L], :, Value), - rdf_global_id(NS:L,FixedValue) - -> true - ; FixedValue = Value - ), - fix_not_expanded_options(Tail, Results). - flush_refs_cache_if_needed(Process) :- ( rdfs_individual_of(Process, amalgame:'SelectPreLoaded') -> flush_refs_cache(Process) diff --git a/lib/amalgame/amalgame_modules.pl b/lib/amalgame/amalgame_modules.pl index f99a7aa..89743b9 100644 --- a/lib/amalgame/amalgame_modules.pl +++ b/lib/amalgame/amalgame_modules.pl @@ -4,7 +4,8 @@ amalgame_modules_of_type/2, % +Class, -Modules amalgame_module_parameters/2, % +Module, -Parameters amalgame_module_property/2, % +URI, ?Term, - process_options/3 + process_options/3, + expand_options/2 ]). :- use_module(library(semweb/rdf_db)). @@ -113,21 +114,24 @@ process_options(Process, Module, Options) :- !, module_options(Module, Options, Parameters), parse_url_search(ParamString, Search0), - fix_not_expanded_options(Search0, Search), + expand_options(Search0, Search), Request = [search(Search)] , http_parameters(Request, Parameters). process_options(_, _, []). -fix_not_expanded_options([''],[]). -fix_not_expanded_options([],[]). -fix_not_expanded_options([Key=Value|Tail], [Key=FixedValue|Results]):- - ( \+ sub_atom(Value,0,_,_,'http:'), - atomic_list_concat([NS,L], :, Value), - rdf_global_id(NS:L,FixedValue) - -> true - ; FixedValue = Value - ), - fix_not_expanded_options(Tail, Results). +%% expand_options(Pairs, ExpandedPairs) is det. +% +% Expand values using rdf_global_id if not already expanded. + +expand_options([''],[]). +expand_options([],[]). +expand_options([Key=Value|Tail], [Key=FixedValue|Results]):- + atomic_list_concat([NS,L], :, Value), + catch(rdf_global_id(NS:L,FixedValue),_,fail), + expand_options(Tail, Results). +expand_options([Key=Value|Tail], [Key=Value|Results]) :- + expand_options(Tail, Results). + %% module_options(+Module, -Options, -Parameters) %