From: Christian H. <ha...@in...> - 2009-11-03 12:51:49
|
Hi all, i tried to merge two topic maps and received an IdentityConstraintException because the same identifier was added to two different topics which in my opinion is correct behaviour according to the TMDM. So I wrote the following test program where I added the same subject identifier to two different topics which should be merged by the engine. The result was the same exception. Am I missing something? TopicMapSystemFactory factory = TopicMapSystemFactory.newInstance(); TopicMapSystem system = factory.newTopicMapSystem(); TopicMap testMap = system.createTopicMap("test:test"); String test_locator = "http://my.test"; Topic topic1 = testMap.createTopicBySubjectIdentifier(testMap.createLocator(test_locator)); topic1.createName("Test1"); Topic topic2 = testMap.createTopic(); topic2.createName("Test2"); topic2.addSubjectIdentifier(testMap.createLocator(test_locator)); Best, Christian -- Christian Haß, Msc. Abteilung Automatische Sprachverarbeitung Institut für Informatik | Universität Leipzig Johannisgasse 26 | Raum 00-18 | 04103 Leipzig phone: 0049 - 341 - 97 - 32298 fax: 0049 - 341 - 97 - 32299 mail: ha...@in... ====================================== Topic Maps Lab http://www.topicmapslab.de ====================================== |
From: Lars H. <he...@se...> - 2009-11-03 13:47:50
|
Hi Christian, > i tried to merge two topic maps and received an IdentityConstraintException > because the same identifier was added to two different topics which in my > opinion is correct behaviour according to the TMDM. > So I wrote the following test program where I added the same subject > identifier to two different topics which should be merged by the engine. The > result was the same exception. Am I missing something? Thanks for your e-mail. tinyTiM does not merge topics automatically. That means, the IdentityConstraintException is correct. You can always catch is and merge topics manually: Topic topic1 = testMap.createTopicBySubjectIdentifier(testMap.createLocator(test_locator)); topic1.createName("Test1"); Topic topic2 = testMap.createTopic(); topic2.createName("Test2"); try { topic2.addSubjectIdentifier(testMap.createLocator(test_locator)); catch (IdentityConstraintException ex) { Topic existing = (Topic) ex.getExisting(); topic2.mergeIn(existing); } An alternative, and much better approach would be: Topic topic1 = testMap.createTopicBySubjectIdentifier( testMap.createLocator(test_locator)); topic1.createName("Test1"); Topic topic2 = testMap.createTopicBySubjectIdentifier(test_locator); topic2.createName("Test2"); Here, topic2 would be equals to topic1 since the engine ensures that it either returns an existing topic with the provided subject identifier or creates a topic with that subject identifier in the "TopicMap.createTopicBySubjectIdentifier" method. TMAPI 2.0 supports also "createTopicByItemIdentifier" and "createTopicBySubjectLocator" with the same semantics. Best regards, Lars -- Semagia <http://www.semagia.com> |
From: Christian H. <ha...@in...> - 2009-11-03 14:03:41
|
Am Dienstag 03 November 2009 14:53:58 schrieb Lars Heuer: > Hi Christian, > > > i tried to merge two topic maps and received an > > IdentityConstraintException because the same identifier was added to two > > different topics which in my opinion is correct behaviour according to > > the TMDM. > > So I wrote the following test program where I added the same subject > > identifier to two different topics which should be merged by the engine. > > The result was the same exception. Am I missing something? > > Thanks for your e-mail. tinyTiM does not merge topics automatically. > That means, the IdentityConstraintException is correct. You can always > catch is and merge topics manually: > > Topic topic1 = > testMap.createTopicBySubjectIdentifier(testMap.createLocator(test_locator)) >; topic1.createName("Test1"); > > Topic topic2 = testMap.createTopic(); > topic2.createName("Test2"); > try { > topic2.addSubjectIdentifier(testMap.createLocator(test_locator)); > catch (IdentityConstraintException ex) { > Topic existing = (Topic) ex.getExisting(); > topic2.mergeIn(existing); > } > > > An alternative, and much better approach would be: > > Topic topic1 = testMap.createTopicBySubjectIdentifier( > testMap.createLocator(test_locator)); > topic1.createName("Test1"); > > Topic topic2 = testMap.createTopicBySubjectIdentifier(test_locator); > topic2.createName("Test2"); > > > Here, topic2 would be equals to topic1 since the engine ensures that > it either returns an existing topic with the provided subject > identifier or creates a topic with that subject identifier in the > "TopicMap.createTopicBySubjectIdentifier" method. TMAPI 2.0 supports > also "createTopicByItemIdentifier" and "createTopicBySubjectLocator" > with the same semantics. > > Best regards, > Lars Hi and thanks for the fast response. The actual problem is that I try to merge two topic maps which I deserialize from different files, in my case an topic map schema and a topic map which I want to verify according to that schema. The exception is thrown in the mergeIn method of the topic map. I assume that the engine tries to merge two topics by creating a third one which gets all properties of one of those topics, which cases the IdentityConstraintException to be thrown. I hope this specifies my problem more further. Best reguards, Christian -- Christian Haß, Msc. Abteilung Automatische Sprachverarbeitung Institut für Informatik | Universität Leipzig Johannisgasse 26 | Raum 00-18 | 04103 Leipzig phone: 0049 - 341 - 97 - 32298 fax: 0049 - 341 - 97 - 32299 mail: ha...@in... ====================================== Topic Maps Lab http://www.topicmapslab.de ====================================== |
From: Lars H. <he...@se...> - 2009-11-03 14:14:26
|
Hi Christian, [...] > The actual problem is that I try to merge two topic maps which I deserialize > from different files, in my case an topic map schema and a topic map which I > want to verify according to that schema. The exception is thrown in the > mergeIn method of the topic map. I assume that the engine tries to merge two > topics by creating a third one which gets all properties of one of those > topics, which cases the IdentityConstraintException to be thrown. Aha! :) tinyTiM should never create a 3rd topic, but anyway, we may have a problem. Is it possible provide the topic maps (maybe as private mail) or to provide more information? * Which deserializers do you use? (CTM, XTM, XTM 1.0, XTM 2.0 ...) * From which project do you use the deserializers (tinyTiM, TMAPIX)? * Which version? Best regards, Lars -- Semagia <http://www.semagia.com> |