source: branches/new-datamodel/src/xml/xtm/setup.lisp

Last change on this file was 322, checked in by lgiessmann, 14 years ago

new-datamodel: fixed ticket #72 -> http://trac.common-lisp.net/isidorus/ticket/72

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1;;+-----------------------------------------------------------------------------
2;;+  Isidorus
3;;+  (c) 2008-2009 Marc Kuester, Christoph Ludwig, Lukas Giessmann
4;;+
5;;+  Isidorus is freely distributable under the LGPL license.
6;;+  You can find a detailed description in trunk/docs/LGPL-LICENSE.txt.
7;;+-----------------------------------------------------------------------------
8
9
10(in-package :xml-importer)
11
12(defun get-uuid ()
13  "Little helper funtion that gets a UUID as a string"
14  (format nil "~a" (uuid:make-v4-uuid)))
15
16(defun import-xtm (xtm-path repository-path 
17                   &key 
18                   (tm-id (error "you must provide a stable identifier (PSI-style) for this TM"))
19                   (xtm-format '2.0)
20                   (xtm-id (get-uuid)))
21  "Imports an XTM file into an existing repository using the correct
22   importer for the XTM version. Does *not* close the store afterwards"
23  (declare ((or pathname string) xtm-path))
24  (declare ((or pathname string) repository-path))
25  (let ((xtm-dom (dom:document-element
26                  (cxml:parse-file
27                   (truename xtm-path) (cxml-dom:make-dom-builder)))))
28    (unless elephant:*store-controller*
29      (elephant:open-store 
30       (get-store-spec repository-path)))
31         ;create the topic stubs so that we can refer to them later on
32    (setf d:*current-xtm* xtm-id)
33    (if (eq xtm-format '2.0)
34        (importer xtm-dom :tm-id tm-id :xtm-id xtm-id)
35        (importer-xtm1.0 xtm-dom :tm-id tm-id :xtm-id xtm-id))
36    (with-reader-lock
37      (format t "#Objects in the store: Topics: ~a, Associations: ~a~%"
38              (length (elephant:get-instances-by-class 'TopicC))
39              (length (elephant:get-instances-by-class 'AssociationC))))))
40
41(defun setup-repository (xtm-path repository-path 
42                         &key
43                         (tm-id (error "you must provide a stable identifier (PSI-style) for this TM"))
44                         (xtm-id (get-uuid))
45                         (xtm-format '2.0))
46  "Initializes a repository and imports a XTM file into it"
47  (declare ((or pathname string) xtm-path))
48  (declare ((or pathname string) repository-path))
49  (unless elephant:*store-controller*
50    (elephant:open-store 
51     (get-store-spec repository-path)))
52  (init-isidorus)
53  (import-xtm xtm-path repository-path :tm-id tm-id :xtm-id xtm-id :xtm-format xtm-format)
54  (when elephant:*store-controller*
55    (elephant:close-store)))
Note: See TracBrowser for help on using the repository browser.