+let relation_ex inv rop path rset assl =
+ let relk = fst path in
+ match relk with
+
+ (* Nota: mancano le inverse di refObj e backPointer!!!! *)
+
+(* Notabis: ora per refObj si restituiscono tutti gli uri della tabella, nella diretta c'e` l'uri vuota *)
+(* Notater: quando non richiedo tutte le proprieta` della tabella quelle che non voglio mi vengono restituite lo stesso ma con nome vuoto *)
+
+ "refObj"
+ | "backPointer" -> (* proprieta` refObj e 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 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 qq = "select uri from t" ^ tv ^ " where prop_id='" ^ prop ^ "' order by uri asc" in
+ print_endline qq;
+ let res = c#exec qq in
+
+ let l = (pgresult_to_string_list res) in
+ List.iter print_endline l;
+ (List.map
+ (function
+ [uri] -> [(uri,[])]
+ | _ -> assert false )
+ res#get_list) @ acc
+ )
+ [] rset
+ )
+ in
+ let rec edup = function
+ [] -> []
+ | rs1::tl -> union_ex rs1 (edup tl)
+ in
+ edup rset_list
+
+
+ else (* con assegnamenti *)
+ let c = pgc () 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 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
+ let pos = search "position" assl in
+ let dep = search "depth" assl in
+ if ((pos != "") && (dep != "")) then (*caso in cui voglio sia position che depth*)
+ (List.map
+ (function
+ [uri;position;depth] -> [(uri,[[((pos, []),[position]);((dep, []),[depth])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+ else
+ if (dep = "") then (* voglio solo position *)
+ (List.map
+ (function
+ [uri;position;depth] -> [(uri,[[((pos, []),[position])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+ else (* voglio solo depth *)
+ (List.map
+ (function
+ [uri;position;depth] -> [(uri,[[((dep, []),[depth])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ )
+ [] rset
+ )
+ in
+ let rec edup = function
+ [] -> []
+ | rs1::tl -> union_ex rs1 (edup tl)
+ in
+ edup rset_list
+
+(* Fine proprieta` refObj e backPointer *)
+
+ | "refRel" -> (* proprietà refRel *)
+ if assl = [] then [] (* se non ci sono assegnamenti *)
+(* let c = pgc () 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
+ let res = c#exec qq in
+ (List.map
+ (function
+ [uri] -> [(uri,[])]
+ | _ -> assert false )
+ res#get_list) @ acc
+ )
+ [] rset
+ )
+ in
+ let rec edup = function
+ [] -> []
+ | rs1::tl -> union_ex rs1 (edup tl)
+ in
+ edup rset_list
+*)
+
+ else (* con assegnamenti *)
+ if inv then (* INVERSA *)
+ let c = pgc () 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
+ let res = c#exec qq in
+ let pos = search "position" assl in
+ let dep = search "depth" assl in
+ if ((pos != "") && (dep != "")) then (*caso in cui voglio sia position che depth*)
+ (List.map
+ (function
+ [uri;position;depth] -> [(uri,[[((pos, []),[position]);((dep, []),[depth])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+ else
+ if (dep = "") then (* voglio solo position *)
+ (List.map
+ (function
+ [uri;position;depth] -> [(uri,[[((pos, []),[position])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+ else (* voglio solo depth *)
+ (List.map
+ (function
+ [uri;position;depth] -> [(uri,[[((dep, []),[depth])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ )
+ [] rset
+ )
+ in
+ let rec edup = function
+ [] -> []
+ | rs1::tl -> union_ex rs1 (edup tl)
+ in
+ edup rset_list
+ else (* DIRETTA, con risorsa nulla *)
+ let c = pgc () 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
+ let res = c#exec qq in
+ let pos = search "position" assl in
+ let dep = search "depth" assl in
+ if ((pos != "") && (dep != "")) then (*caso in cui voglio sia position che depth*)
+ (List.map
+ (function
+ [position;depth] -> [("",[[((pos, []),[position]);((dep, []),[depth])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+ else
+ if (dep = "") then (* voglio solo position *)
+ (List.map
+ (function
+ [position;depth] -> [("",[[((pos, []),[position])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+ else (* voglio solo depth *)
+ (List.map
+ (function
+ [position;depth] -> [("",[[((dep, []),[depth])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ )
+ [] rset
+ )
+ in
+ let rec edup = function
+ [] -> []
+ | rs1::tl -> union_ex rs1 (edup tl)
+ in
+ edup rset_list
+
+
+
+
+
+(* Fine proprieta` refRel *)
+
+
+
+
+ | "refSort" -> (* proprietà refSort *)
+ if assl = [] then [] (* se non ci sono assegnamenti *)
+(* let c = pgc () 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
+ let res = c#exec qq in
+ (List.map
+ (function
+ [uri] -> [(uri,[])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ )
+ [] rset
+ )
+ in
+ let rec edup = function
+ [] -> []
+ | rs1::tl -> union_ex rs1 (edup tl)
+ in
+ edup rset_list
+*)
+
+
+ else (* con assegnamenti *)
+ if inv then (*INVERSA ----> SISTEMARE: vedi refRel!!!!*)
+ let c = pgc () 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
+ let res = c#exec qq in
+ let pos = search "position" assl in
+ let dep = search "depth" assl in
+ let sor = search "sort" assl in
+ if ((pos != "") && (dep != "") && (sor != "")) then (*caso in cui
+ voglio position, depth e sort*)
+ (List.map
+ (function
+ [uri;position;depth;sort] -> [(uri,[[((pos, []),[position]);((dep, []),[depth]);((sor, []),[sort])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+ else
+ if ((dep = "") && (sor = "")) then (* voglio solo position *)
+ (List.map
+ (function
+ [uri;position;depth;sort] -> [(uri,[[((pos, []),[position])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ else
+ if ((pos = "") && (sor = "")) then (* voglio solo depth *)
+ (List.map
+ (function
+ [uri;position;depth;sort] -> [(uri,[[((dep, []),[depth])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ else
+ if ((pos = "") && (dep = "")) then (* voglio solo sort *)
+ (List.map
+ (function
+ [uri;position;depth;sort] -> [(uri,[[((sor, []),[sort])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ else
+ if ((pos = "") && (dep != "") && (sor != "")) then (*voglio depth e sort*)
+ (List.map
+ (function
+ [uri;position;depth;sort] -> [(uri,[[((dep, []),[depth]);((sor, []),[sort])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ else
+ if((pos != "") && (dep = "") && (sor != "")) then (*voglio
+ position e sort*)
+ (List.map
+ (function
+ [uri;position;depth;sort] -> [(uri,[[((pos, []),[position]);((sor, []),[sort])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ else
+ (* if ((pos != "") && (dep != "") && (sor = "")) then*) (*voglio
+ position e depth*)
+ (List.map
+ (function
+ [uri;position;depth;sort] -> [(uri,[[((pos, []),[position]);((dep, []),[depth])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ )
+ [] rset
+ )
+ in
+ let rec edup = function
+ [] -> []
+ | rs1::tl -> union_ex rs1 (edup tl)
+ in
+ edup rset_list
+
+ else (* DIRETTA con risorsa vuota ----> SISTEMARE: vedi refRel!!!!*)
+ let c = pgc () 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
+ let res = c#exec qq in
+ let pos = search "position" assl in
+ let dep = search "depth" assl in
+ let sor = search "sort" assl in
+ if ((pos != "") && (dep != "") && (sor != "")) then (*caso in cui
+ voglio position, depth e sort*)
+ (List.map
+ (function
+ [position;depth;sort] -> [("",[[((pos, []),[position]);((dep, []),[depth]);((sor, []),[sort])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+ else
+ if ((dep = "") && (sor = "")) then (* voglio solo position *)
+ (List.map
+ (function
+ [position;depth;sort] -> [("",[[((pos, []),[position])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ else
+ if ((pos = "") && (sor = "")) then (* voglio solo depth *)
+ (List.map
+ (function
+ [position;depth;sort] -> [("",[[((dep, []),[depth])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ else
+ if ((pos = "") && (dep = "")) then (* voglio solo sort *)
+ (List.map
+ (function
+ [position;depth;sort] -> [("",[[((sor, []),[sort])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ else
+ if ((pos = "") && (dep != "") && (sor != "")) then (*voglio depth e sort*)
+ (List.map
+ (function
+ [position;depth;sort] -> [("",[[((dep, []),[depth]);((sor, []),[sort])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ else
+ if((pos != "") && (dep = "") && (sor != "")) then (*voglio
+ position e sort*)
+ (List.map
+ (function
+ [position;depth;sort] -> [("",[[((pos, []),[position]);((sor, []),[sort])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ else
+ (* if ((pos != "") && (dep != "") && (sor = "")) then*) (*voglio
+ position e depth*)
+ (List.map
+ (function
+ [position;depth;sort] -> [("",[[((pos, []),[position]);((dep, []),[depth])]])]
+ | _ -> assert false )
+ res#get_list) @ acc
+
+ )
+ [] rset
+ )
+ in
+ let rec edup = function
+ [] -> []
+ | rs1::tl -> union_ex rs1 (edup tl)
+ in
+ edup rset_list
+
+
+
+(* Fine proprieta` refSort *)
+
+
+
+ | _ -> []
+