This talk introduces a new generation of the common Topic Maps API (TMAPI). It has evolved from version 1.0 and is now based on the meanwhile finalized Topic Maps Data Model (TMDM). A comprehensive developer experience allowed the design of a user-friendly API for Topic Maps application development independently of a specific Topic Maps processor.
Among TMDM compliance, the design objectives also covered the consideration of the TMDM constraints as well as developer convenience requirements, basic filtering and simplification. For more complex filter operations a filter language has been drafted.
Presentation on how to chat with PDF using ChatGPT code interpreter
TMAPI 2.0
1. TMAPI 2.0
Topic Maps API 2.0
Lars Heuer <heuer@semagia.com>
Johannes Schmidt <js@sixgroups.com>
TMRA 2008, Leipzig · 17.10.2008
2. Table of Contents
Introduction
Design Objectives
Core Interfaces
Details – Core
Details – Index
Questions / Answers
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 2
Johannes Schmidt · http://www.sixgroups.com
3. Introduction
TMAPI is a set of Java interfaces to interact with
topic maps
TMAPI makes applications Topic Maps engine
independent
TMAPI 1.0 has been implemented by several Open
Source and commercial Topic Maps engines
TMAPI 1.0 has been ported to other programming
languages
Not designed by a standards body but a de-facto
standard
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 3
Johannes Schmidt · http://www.sixgroups.com
4. Design Objectives
Topic Maps – Data Model (TMDM) compatible
(TMAPI 1.0 is not)
Respect TMDM constraints to some extend (i.e.
disallow quot;nullquot; in serveral places)
Java 1.5
Userfriendly (depends on the perspective, though)
More tests (TMAPI 1.0: 89 tests TMAPI 2.0: approx.
250 tests)
Apply lessons learned from TMAPI 1.0
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 4
Johannes Schmidt · http://www.sixgroups.com
6. Details – Topic Map
Object / Topic lookup methods moved from
the TopicsIndex to the TopicMap interface:
getConstructByItemIdentifier
getTopicBySubjectIdentifier
getTopicBySubjectLocator
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 6
Johannes Schmidt · http://www.sixgroups.com
7. Details – Topics
TMAPI 1.0: One method to create topics
(createTopic Topic without any identity)
TMAPI 2.0: Four methods to create topics:
createTopicBySubjectIdentifier
createTopicBySubjectLocator
createTopicByItemIdentifier
createTopic ( Topic with an automatically
generated item identifier)
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 7
Johannes Schmidt · http://www.sixgroups.com
8. Details – Topics
Create or reuse existing topic with a sid in TMAPI 1.0:
TopicsIndex tIdx =
(TopicsIndex) tm.getHelperObject(TopicsIndex.class);
if (!tIdx.isOpen()) { tIdx.open(); }
if (!tIdx.getIndexFlags().isAutoUpdated()) {
tIdx.reindex();
}
Topic topic = tIdx.getTopicBySubjectIdentifier(sid);
if (topic == null) {
TopicMapObject tmo = tm.getObjectBySourceLocator(sid);
if (tmo instanceof Topic) { topic = (Topic) tmo; }
}
if (topic == null) {
topic = tm.createTopic(); topic.addSubjectIdentifier(sid);
}
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 8
Johannes Schmidt · http://www.sixgroups.com
10. Details – Topic Creation
Algorithm
createTopicBySubjectIdentifier
Exists a topic with the specified subject identifier?
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 10
Johannes Schmidt · http://www.sixgroups.com
11. Details – Topic Creation
Algorithm
createTopicBySubjectIdentifier
Exists a topic with the specified subject identifier?
Yes
Return existing topic
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 11
Johannes Schmidt · http://www.sixgroups.com
12. Details – Topic Creation
Algorithm
createTopicBySubjectIdentifier
Exists a topic with the specified subject identifier?
Yes No
Return existing topic Exists a topic with an
item identifier == specified subject identifier?
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 12
Johannes Schmidt · http://www.sixgroups.com
13. Details – Topic Creation
Algorithm
createTopicBySubjectIdentifier
Exists a topic with the specified subject identifier?
Yes No
Return existing topic Exists a topic with an
item identifier == specified subject identifier?
Yes
Add the subject identifier to the
existing topic and return the topic
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 13
Johannes Schmidt · http://www.sixgroups.com
14. Details – Topic Creation
Algorithm
createTopicBySubjectIdentifier
Exists a topic with the specified subject identifier?
Yes No
Return existing topic Exists a topic with an
item identifier == specified subject identifier?
No
Yes
Add the subject identifier to the Create a topic with the subject identifier
existing topic and return the topic and return the topic
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 14
Johannes Schmidt · http://www.sixgroups.com
15. Details – Topics – Best
Practise
If possible use an explicit identity (subject
identifier, subject locator or item identifier)
createTopic() is implementation dependent
and not reliable
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 15
Johannes Schmidt · http://www.sixgroups.com
16. Details - Occurrences
TMAPI 1.0: Untyped occurrences possible,
only strings and locators are supported
TMAPI 2.0: Untyped occurrences are
disallowed, any datatype possible (c.f.
interface core.DatatypeAware)
occ.setValue(1) xsd:int
occ.setValue(quot;valuequot;) xsd:string
occ.setValue(1.0F) xsd:float
occ.setValue(quot;valuequot;, locator)
datatype = locator
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 16
Johannes Schmidt · http://www.sixgroups.com
17. Details - Associations
TMAPI 1.0: Untyped associations and roles
without a type or player are allowed
TMAPI 2.0: Untyped associations are
disallowed, every role has a type and a
player
Caution:
TMAPI 1.0: createAssociationRole(player, type)
TMAPI 2.0: createRole(type, player)
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 17
Johannes Schmidt · http://www.sixgroups.com
18. Details - Scope
TMAPI 1.0: quot;nullquot; represents the
unconstrained scope in factory methods:
createName(quot;The Beatlesquot;, null)
TMAPI 2.0: If the scope is not specified, the
statement is in the unconstrained scope
(variable argument):
createName(quot;The Beatlesquot;)
createName(quot;Pilzköpfequot;, nickname, german)
Scope definition works also for associations,
occurrences and variants
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 18
Johannes Schmidt · http://www.sixgroups.com
19. Details – Index
TMAPI 1.0: 8 indexes which implement a construct-centric view:
TopicMapObjectsIndex
ScopedObjectsIndex
TopicsIndex
TopicNamesIndex
VariantsIndex
OccurrencesIndex
AssociationsIndex
AssociationRolesIndex
TMAPI 2.0: 3 indexes which implement a generalized view on a
topic map:
LiteralIndex (Occurrences, Names, Variants)
ScopedIndex (Associations, Occurrences, Names, Variants)
TypeInstanceIndex (Topics, Associations, Roles, Occurrences,
Names)
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 19
Johannes Schmidt · http://www.sixgroups.com
20. Details – Index
TMAPI 1.0:
TopicsIndex idx = (TopicsIndex)
tm.getHelperObject(TopicsIndex.class);
(Exception handling omitted)
TMAPI 2.0:
TypeInstanceIndex idx =
tm.getIndex(TypeInstanceIndex.class);
(No checked exceptions)
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 20
Johannes Schmidt · http://www.sixgroups.com
21. Outlook
Notifications
Transactions
Advanced filter API (XPath aka TMPath
expressions are implemented by TMAPIX)
Participate! http://www.tmapi.org/
Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 21
Johannes Schmidt · http://www.sixgroups.com