Author: lgiessmann Date: Sat Oct 16 12:15:50 2010 New Revision: 330
Log: fixed ticket #64 --> reifier of the TopicMap-element for xtm 1.0; added a corresponding unit-test; this problem was solved for the xtm 2.0 importer in revision 329
Added: trunk/src/unit_tests/poems_light_tm_reification_xtm1.0.xtm Modified: trunk/src/isidorus.asd trunk/src/unit_tests/importer_test.lisp trunk/src/unit_tests/poems_light_tm_ii.xtm trunk/src/unit_tests/poems_light_tm_ii_merge.xtm trunk/src/unit_tests/unittests-constants.lisp trunk/src/xml/xtm/exporter.lisp trunk/src/xml/xtm/importer_xtm1.0.lisp
Modified: trunk/src/isidorus.asd ============================================================================== --- trunk/src/isidorus.asd (original) +++ trunk/src/isidorus.asd Sat Oct 16 12:15:50 2010 @@ -115,6 +115,7 @@ (:static-file "poems_light.xtm") (:static-file "poems_light_tm_ii.xtm") (:static-file "poems_light_tm_ii_merge.xtm") + (:static-file "poems_light_tm_reification_xtm1.0.xtm") (:static-file "full_mapping.rdf") (:static-file "reification_xtm1.0.xtm") (:static-file "reification_xtm2.0.xtm")
Modified: trunk/src/unit_tests/importer_test.lisp ============================================================================== --- trunk/src/unit_tests/importer_test.lisp (original) +++ trunk/src/unit_tests/importer_test.lisp Sat Oct 16 12:15:50 2010 @@ -40,7 +40,8 @@ :test-topicmaps :test-variants :test-variants-xtm1.0 - :test-merge-topicmaps)) + :test-merge-topicmaps + :test-merge-topicmaps-xtm1.0)) (declaim (optimize (debug 3) (speed 0) (safety 3) (space 0) (compilation-speed 0)))
(in-package :importer-test) @@ -710,6 +711,9 @@ "http://some.where/poems_light_tm_ii_1" "http://some.where/poems_light_tm_ii_2") :test #'string=)) + (is (eql (reifier tm-1) + (d:get-item-by-item-identifier + "http://some.where/poems/topicMap-reifier"))) (is (= (length (d:topics tm-1)) 9)) (is (= (length (d:associations tm-1)) (+ 1 3))) (is (= (length (d:in-topicmaps (d:get-item-by-id "schiller"))) 1)) @@ -727,6 +731,25 @@ (is-false schiller-2)))))))
+(test test-merge-topicmaps-xtm1.0 + (let ((dir "data_base") + (tm-id-1 "tm-id-1")) + (with-fixture with-empty-db (dir) + (xml-importer:setup-repository *poems_light_tm_reification_xtm1.0.xtm* + dir :tm-id tm-id-1 :xtm-format '1.0) + (elephant:open-store (xml-importer:get-store-spec dir)) + (with-revision 0 + (let ((tm-1 + (d:identified-construct + (first (elephant:get-instances-by-value + 'd:ItemIdentifierC 'd:uri tm-id-1))))) + (is-true tm-1) + (is (= (length (topics tm-1)) 8)) + (is (= (length (associations tm-1)) (+ 1 2))) + (is (eql (reifier tm-1) + (get-item-by-psi "#tm-reifier")))))))) + + (defun run-importer-tests () (run! 'importer-test))
Modified: trunk/src/unit_tests/poems_light_tm_ii.xtm ============================================================================== --- trunk/src/unit_tests/poems_light_tm_ii.xtm (original) +++ trunk/src/unit_tests/poems_light_tm_ii.xtm Sat Oct 16 12:15:50 2010 @@ -13,9 +13,6 @@
<tm:topicMap version="2.0" xmlns:tm="http://www.topicmaps.org/xtm/" reifier="http://some.where/poems/topicMap-reifier%22%3E - <!-- this file contains constructs that are originally defined as TM and - RDF. So certain constructs are not consistent because of test cases, - but all are valid! --> <tm:itemIdentity href="http://some.where/poems_light_tm_ii_1%22/%3E
<tm:itemIdentity href="http://some.where/poems_light_tm_ii_2%22/%3E
Modified: trunk/src/unit_tests/poems_light_tm_ii_merge.xtm ============================================================================== --- trunk/src/unit_tests/poems_light_tm_ii_merge.xtm (original) +++ trunk/src/unit_tests/poems_light_tm_ii_merge.xtm Sat Oct 16 12:15:50 2010 @@ -12,9 +12,6 @@ <!-- ======================================================================= -->
<tm:topicMap version="2.0" xmlns:tm="http://www.topicmaps.org/xtm/%22%3E - <!-- this file contains constructs that are originally defined as TM and - RDF. So certain constructs are not consistent because of test cases, - but all are valid! --> <tm:itemIdentity href="http://some.where/poems_light_tm_ii_1%22/%3E
<tm:topic id="author">
Added: trunk/src/unit_tests/poems_light_tm_reification_xtm1.0.xtm ============================================================================== --- (empty file) +++ trunk/src/unit_tests/poems_light_tm_reification_xtm1.0.xtm Sat Oct 16 12:15:50 2010 @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- ======================================================================= --> +<!-- Isidorus --> +<!-- (c) 2008-2010 Marc Kuester, Christoph Ludwig, Lukas Georgieff --> +<!-- --> +<!-- Isidorus is freely distributable under the LLGPL license. --> +<!-- This ajax module uses the frameworks PrototypeJs and Scriptaculous, --> +<!-- both are distributed under the MIT license. --> +<!-- You can find a detailed description in trunk/docs/LLGPL-LICENSE.txt, --> +<!-- trunk/docs/LGPL-LICENSE.txt and in --> +<!-- trunk/src/ajax/javascripts/external/MIT-LICENSE.txt. --> +<!-- ======================================================================= --> + +<tm:topicMap xmlns:tm="http://www.topicmaps.org/xtm/1.0/" + xmlns:xlink="http://www.w3.org/1999/xlink" + id="tm-reifier"> + + <tm:topic id="tm-reifier-topic"> + tm:subjectIdentity + <tm:subjectIndicatorRef xlink:href="#tm-reifier"/> + </tm:subjectIdentity> + </tm:topic> + + <tm:topic id="author"> + tm:subjectIdentity + <tm:subjectIndicatorRef xlink:href="http://some.where/types/Author%22/%3E + </tm:subjectIdentity> + </tm:topic> + + <tm:topic id="poem"> + tm:subjectIdentity + <tm:subjectIndicatorRef xlink:href="http://some.where/types/Poem%22/%3E + </tm:subjectIdentity> + </tm:topic> + + <tm:topic id="writer"> + tm:subjectIdentity + <tm:subjectIndicatorRef xlink:href="http://some.where/roletype/writer%22/%3E + </tm:subjectIdentity> + </tm:topic> + + <tm:topic id="written"> + tm:subjectIdentity + <tm:subjectIndicatorRef xlink:href="http://some.where/roletype/written%22/%3E + </tm:subjectIdentity> + </tm:topic> + + <tm:topic id="wrote"> + tm:subjectIdentity + <tm:subjectIndicatorRef xlink:href="http://some.where/relationship/wrote%22/%3E + </tm:subjectIdentity> + </tm:topic> + + <tm:topic id="goethe"> + tm:subjectIdentity + <tm:subjectIndicatorRef xlink:href="http://some.where/author/Goethe%22/%3E + </tm:subjectIdentity> + tm:instanceOf + <tm:topicRef xlink:href="#author"/> + </tm:instanceOf> + </tm:topic> + + <tm:topic id="zauberlehrling"> + tm:subjectIdentity + <tm:subjectIndicatorRef xlink:href="http://some.where/poem/Der_Zauberlehrling%22/%3E + </tm:subjectIdentity> + tm:instanceOf + <tm:topicRef xlink:href="#poem"/> + </tm:instanceOf> + </tm:topic> + + tm:association + tm:instanceOf + <tm:topicRef xlink:href="#wrote"/> + </tm:instanceOf> + tm:member + tm:roleSpec + <tm:topicRef xlink:href="#writer"/> + </tm:roleSpec> + <tm:topicRef xlink:href="#goethe"/> + </tm:member> + tm:member + tm:roleSpec + <tm:topicRef xlink:href="#written"/> + </tm:roleSpec> + <tm:topicRef xlink:href="#zauberlehrling"/> + </tm:member> + </tm:association> +</tm:topicMap>
Modified: trunk/src/unit_tests/unittests-constants.lisp ============================================================================== --- trunk/src/unit_tests/unittests-constants.lisp (original) +++ trunk/src/unit_tests/unittests-constants.lisp Sat Oct 16 12:15:50 2010 @@ -36,7 +36,8 @@ :*reification_xtm2.0.xtm* :*reification.rdf* :*poems_light_tm_ii.xtm* - :*poems_light_tm_ii_merge.xtm*)) + :*poems_light_tm_ii_merge.xtm* + :*poems_light_tm_reification_xtm1.0.xtm*))
(in-package :unittests-constants)
@@ -122,12 +123,14 @@ (asdf:component-pathname (asdf:find-component *unit-tests-component* "reification.rdf")))
- (defparameter *poems_light_tm_ii.xtm* (asdf:component-pathname (asdf:find-component *unit-tests-component* "poems_light_tm_ii.xtm")))
- (defparameter *poems_light_tm_ii_merge.xtm* (asdf:component-pathname (asdf:find-component *unit-tests-component* "poems_light_tm_ii_merge.xtm"))) + +(defparameter *poems_light_tm_reification_xtm1.0.xtm* + (asdf:component-pathname + (asdf:find-component *unit-tests-component* "poems_light_tm_reification_xtm1.0.xtm")))
Modified: trunk/src/xml/xtm/exporter.lisp ============================================================================== --- trunk/src/xml/xtm/exporter.lisp (original) +++ trunk/src/xml/xtm/exporter.lisp Sat Oct 16 12:15:50 2010 @@ -53,12 +53,14 @@ ,@body)))
-(defmacro with-xtm1.0 (&body body) +(defmacro with-xtm1.0 ((tm revision) &body body) "helper macro to build the Topic Map element" `(cxml:with-namespace ("t" *xtm1.0-ns*) (cxml:with-namespace ("xlink" *xtm1.0-xlink*) (cxml:with-element "t:topicMap" :empty + (when ,tm + (to-reifier-elem-xtm1.0 ,tm ,revision)) ,@body))))
@@ -98,7 +100,7 @@ (with-xtm2.0 (tm revision) (export-to-elem tm #'(lambda(elem) (to-elem elem revision)))) - (with-xtm1.0 + (with-xtm1.0 (tm revision) (export-to-elem tm #'(lambda(elem) (to-elem-xtm1.0 elem revision)))))))))))
@@ -117,7 +119,7 @@ (with-xtm2.0 (tm revision) (export-to-elem tm #'(lambda(elem) (to-elem elem revision)))) - (with-xtm1.0 + (with-xtm1.0 (tm revision) (export-to-elem tm #'(lambda(elem) (to-elem-xtm1.0 elem revision))))))))))
@@ -130,5 +132,5 @@ (if (eq xtm-format '2.0) (with-xtm2.0 (nil nil) (to-elem fragment (revision fragment))) - (with-xtm1.0 + (with-xtm1.0 (nil nil) (to-elem-xtm1.0 fragment (revision fragment)))))))) \ No newline at end of file
Modified: trunk/src/xml/xtm/importer_xtm1.0.lisp ============================================================================== --- trunk/src/xml/xtm/importer_xtm1.0.lisp (original) +++ trunk/src/xml/xtm/importer_xtm1.0.lisp Sat Oct 16 12:15:50 2010 @@ -549,4 +549,7 @@ (format t "a") (from-association-elem-xtm1.0 assoc-elem revision :tm tm - :xtm-id xtm-id)))))) + :xtm-id xtm-id)) + (let ((reifier-topic (get-reifier-topic-xtm1.0 xtm-dom revision))) + (when reifier-topic + (add-reifier tm reifier-topic :revision revision))))))) \ No newline at end of file