X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fmathql_interpreter%2Frelation.ml;h=044bb82d367bccec92f3756da9b38cd61f4c30d7;hb=d59d2f93956bcbe4dd7bb3407e3c53de8b66c003;hp=e5b700064bb297e6d35e533a3d4b73af334c7c31;hpb=d6dd3cb8ee6718a0992a87e15a4b98b438d0f30d;p=helm.git diff --git a/helm/ocaml/mathql_interpreter/relation.ml b/helm/ocaml/mathql_interpreter/relation.ml index e5b700064..044bb82d3 100644 --- a/helm/ocaml/mathql_interpreter/relation.ml +++ b/helm/ocaml/mathql_interpreter/relation.ml @@ -30,12 +30,11 @@ *) - - open Union;; open Dbconn;; open Utility;; +let quoted s = Str.global_substitute (Str.regexp "'") (function _ -> "\\'") s (* Cerca in una lista di assegnamenti (lista di coppie (path,path) dove path e' di tipo (string * string list) quello relativo alla proprietà p e ne @@ -54,7 +53,7 @@ let get_prop_id prop = ;; -let relation_ex inv rop path rset assl = +let relation_ex handle inv rop path rset assl = let relk = fst path in match relk with @@ -65,19 +64,19 @@ let relation_ex inv rop path rset assl = "refObj" | "backPointer" -> (* proprieta` refObj e backPointer *) - print_endline "IN BACKPOINTER"; +(* print_endline "IN BACKPOINTER"; *) let prop = get_prop_id relk in if assl = [] then (* se non ci sono assegnamenti *) - let c = pgc () in + let c = MQIConn.pgc handle in let rset_list = (* lista di singoletti:resource_set di un elemento *) (List.fold_left (fun acc (uri,l) -> - let tv = pgresult_to_string (c#exec ("select id from registry where uri='" ^ uri ^ "'")) in + let tv = pgresult_to_string (c#exec ("select id from registry where uri='" ^ quoted uri ^ "'")) in let qq = "select uri from t" ^ tv ^ " where prop_id='" ^ prop ^ "' order by uri asc" in - print_endline qq; +(* print_endline qq; *) let res = c#exec qq in let l = (pgresult_to_string_list res) in - List.iter print_endline l; +(* List.iter print_endline l; *) (List.map (function [uri] -> [(uri,[])] @@ -95,10 +94,10 @@ let relation_ex inv rop path rset assl = else (* con assegnamenti *) - let c = pgc () in + let c = MQIConn.pgc handle in let rset_list = (* lista di singoletti:resource_set di un elemento *) (List.fold_left (fun acc (uri,l) -> - let tv = pgresult_to_string (c#exec ("select id from registry where uri='" ^ uri ^ "'")) in + let tv = pgresult_to_string (c#exec ("select id from registry where uri='" ^ quoted uri ^ "'")) in let qq = "select uri, position, depth from t" ^ tv ^ " where prop_id='" ^ prop ^ "' order by uri asc" in print_endline qq; let res = c#exec qq in @@ -117,7 +116,7 @@ let relation_ex inv rop path rset assl = [uri;position;depth] -> [(uri,[[((pos, []),[position])]])] | _ -> assert false ) res#get_list) @ acc - else (* voglio solo depth *) + else (* voglio solo depth *) (List.map (function [uri;position;depth] -> [(uri,[[((dep, []),[depth])]])] @@ -138,7 +137,7 @@ let relation_ex inv rop path rset assl = | "refRel" -> (* proprietà refRel *) if assl = [] then [] (* se non ci sono assegnamenti *) -(* let c = pgc () in +(* let c = MQIConn.pgc handle in let rset_list = (* lista di singoletti:resource_set di un elemento *) (List.fold_left (fun acc (uri,l) -> let qq = "select uri from hrefRel order by uri asc" in @@ -161,7 +160,7 @@ let relation_ex inv rop path rset assl = else (* con assegnamenti *) if inv then (* INVERSA *) - let c = pgc () in + let c = MQIConn.pgc handle in let rset_list = (* lista di singoletti:resource_set di un elemento *) (List.fold_left (fun acc (uri,l) -> let qq = "select uri, position, depth from hrefRel order by uri asc" in @@ -198,7 +197,7 @@ let relation_ex inv rop path rset assl = in edup rset_list else (* DIRETTA, con risorsa nulla *) - let c = pgc () in + let c = MQIConn.pgc handle in let rset_list = (* lista di singoletti:resource_set di un elemento *) (List.fold_left (fun acc (uri,l) -> let qq = "select position, depth from hrefRel order by uri asc" in @@ -246,7 +245,7 @@ let relation_ex inv rop path rset assl = | "refSort" -> (* proprietà refSort *) if assl = [] then [] (* se non ci sono assegnamenti *) -(* let c = pgc () in +(* let c = MQIConn.pgc handle in let rset_list = (* lista di singoletti:resource_set di un elemento *) (List.fold_left (fun acc (uri,l) -> let qq = "select uri from hrefSort order by uri asc" in @@ -271,7 +270,7 @@ let relation_ex inv rop path rset assl = else (* con assegnamenti *) if inv then (*INVERSA ----> SISTEMARE: vedi refRel!!!!*) - let c = pgc () in + let c = MQIConn.pgc handle in let rset_list = (* lista di singoletti:resource_set di un elemento *) (List.fold_left (fun acc (uri,l) -> let qq = "select uri, position, depth, sort from hrefSort order by uri asc" in @@ -347,7 +346,7 @@ let relation_ex inv rop path rset assl = edup rset_list else (* DIRETTA con risorsa vuota ----> SISTEMARE: vedi refRel!!!!*) - let c = pgc () in + let c = MQIConn.pgc handle in let rset_list = (* lista di singoletti:resource_set di un elemento *) (List.fold_left (fun acc (uri,l) -> let qq = "select position, depth, sort from hrefSort order by uri asc" in @@ -498,7 +497,7 @@ let muse path assl r = (* prende un resource_set, una vvar (primo el. di assl) a cui associare la posizione, e la relazione (refObj o backPointer) e per ogni resource chiama la muse NOTA: "rop" per ora non viene usato perche' vale sempre "ExactOp" *) -let relation_galax_ex inv rop path rset assl = [] +let relation_galax_ex handle inv rop path rset assl = [] (*