logo
Adding Associations < A TMAPI Tutorial < < Home 

PrevUpNext

Adding Associations

Let us assume that we would like to connect our Sydney Airport topic with a new Tokyo Airport in an association of type "has flight from to". Sydney airport would play the role of the departure location and Tokyo airport that of the destination.

First we create an association in our map and give it a proper type

Association assoc = tMap.createAssociation();

Topic tAssType = tMap.createTopic();
tAssType.createTopicName( "has flight from to", null );

assoc.setType ( tAssType );
Assuming that we have created appropriate topics tDestination, tOrigin, tTime and tAirportToko, we can - one by one - add the association roles (together with the playing topic) to the association:
assoc.createAssociationRole( tAirportSydney, tOrigin );
assoc.createAssociationRole( tAirportTokyo,  tDestination );
assoc.createAssociationRole( tTue1015,       tTime );
The topic tTue1015 should represent a week time, Tuesday 10:15, and is also assumed to have been created before.

Realistically, we would like to scope this association only to be valid in summer. For this purpose we add a last topic and use that as scoping topic:

Topic tSummerTimetable = tMap.createTopic();
tSummerTimetable.createTopicName( "summer timetable", null );

assoc.addScopingTopic( tSummerTimetable );