[ckan-discuss] Datacatalog

Luca Racchetti l.racchetti at campus.unimib.it
Mon Jul 8 16:51:59 BST 2013


Good morning,
I would like to make a catalog of my CKAN dataset.
To do this I started with export the database into CSV, and then I have 
created a function and a trigger on the Postgresql DB:

     CREATE FUNCTION create_datacatalog ()
     RETURNS trigger
     AS $create_datacatalog$
     BEGIN EXECUTE '
     Copy (SELECT "name" AS "nome", "description" AS "descrizione", 
"url" AS "url", "format" AS "formato", "last_modified" AS "ultima 
modifica", "author" AS "autore", "author_email" AS "email autore", 
"maintainer" AS "manutentore", "maintainer_email" AS "email manutentore" 
FROM (SELECT "name", "description", "url", "format", "last_modified", 
"resource_group_id", "package_id", resource.id AS "url_id" FROM 
"resource_group" JOIN "resource" ON 
resource_group.id=resource.resource_group_id) AS "resource" JOIN (SELECT 
"id", "author", "author_email", "maintainer", "maintainer_email", "name" 
AS "url_name" FROM "package") AS "package" ON 
resource.package_id=package.id ORDER BY "last_modified" DESC) To 
''/usr/lib/ckan/default/src/ckan/ckan/public/datacatalog.csv'' With CSV 
HEADER;
     ';
     RETURN NEW;
     END;
     $create_datacatalog$
     LANGUAGE plpgsql;

     CREATE TRIGGER datacatalog_update
     AFTER insert OR update
     ON resource
     FOR EACH ROW
     EXECUTE PROCEDURE create_datacatalog();


Then I assigned permissions in writing to the output file.


Now if I create a new dataset and I do point to the url <server> / 
datacatalog.csv is taken the url of datacatalog.
But if I update one of the other dataset that file is modified and 
updated. When I download the datacatalog returns the new file, but the 
preview and the general datastore still contain the old file.

How to upgrade and automate it?

Thanks,
Luca Racchetti
Matricola: 703311
Informatica, Università degli Studi di Milano-Bicocca

Senatore Accademico
Rappresentante studenti CCD Scienze e Tecnologie Informatiche

--------------------------------------------------------------------------------
-Internet Email Confidentiality Footer-
La presente comunicazione, con le informazioni in essa contenute e ogni 
documento o file allegato, e' rivolta unicamente alla/e persona/e cui e' 
indirizzata ed alle altre da questa autorizzata/e a riceverla. Se non 
siete i destinatari/autorizzati siete avvisati che qualsiasi azione, 
copia, comunicazione, divulgazione o simili basate sul contenuto di tali 
informazioni e' vietata e potrebbe essere contro la legge (art. 616 
C.P., D.Lgs n. 196/2003 Codice in materia di protezione dei dati 
personali). Se avete ricevuto questa comunicazione per errore, vi 
preghiamo di darne immediata notizia al mittente e di distruggere il 
messaggio originale e ogni file allegato senza farne copia alcuna o 
riprodurne in alcun modo il contenuto.
This e-mail and its attachments are intended for the addressee(s) only 
and are confidential and/or may contain legally privileged information. 
If you have received this message by mistake or are not one of the 
addressees above, you may take no action based on it, and you may not 
copy or show it to anyone; please reply to this e-mail and point out the 
error which has occurred.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-discuss/attachments/20130708/62783032/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3207 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.okfn.org/pipermail/ckan-discuss/attachments/20130708/62783032/attachment.bin>


More information about the ckan-discuss mailing list