(* Copyright (C) 2000, HELM Team. * * This file is part of HELM, an Hypertextual, Electronic * Library of Mathematics, developed at the Computer Science * Department, University of Bologna, Italy. * * HELM is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * HELM is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HELM; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * For details, see the HELM World-Wide-Web page, * http://www.cs.unibo.it/helm/. *) (* * implementazione dei comandi USE/USED BY *) open Utility;; open Dbconn;; (* * implementazione dei comandi USE/USED BY * * parametri: * alist: string list list; lista su cui eseguire il comando USE/USED BY * asvar: string; nome della variabile del comando use * usek: string; nome della tabella in cui ricercare le occorrenze; * la distinzione fra l'esecuzione del comando USE e USED BY * sta nell'utilizzo della tabella 'backPointer' per USE * e 'refObj' per USED BY * * output: string list list; lista su cui e' stato eseguito il * comando USE/USED BY *) let get_prop_id prop = if prop="refObj" then "F" else if prop="backPointer" then "B" else assert false ;; let relation_ex rop path rset attl = let usek = get_prop_id (List.hd path) in let _ = print_string ("RELATION "^usek) and t = Sys.time () in let result = let c = pgc () in Sort.list (fun (uri1-> uri1 < uri2) (List.fold_left (fun parziale (uri,aset)-> print_string uri ; let tv = pgresult_to_string (c#exec ("select id from registry where uri='" ^ uri ^ "'")) in let qq = "select uri, context from t" ^ tv ^ " where prop_id='" ^ usek ^ "' order by uri asc" in let res = c#exec qq in (List.map (function [uri;context] -> {S.uri = uri ; S.attributes = [asvar, context] ; S.extra = ""} | _ -> assert false ) res#get_list ) @ parziale ) [] rset ) in print_string (" = " ^ string_of_int (List.length result) ^ ": ") ; print_endline (string_of_float (Sys.time () -. t) ^ "s") ; flush stdout ; result ;;