001 package de.deepamehta.core; 002 003 import de.deepamehta.core.model.AssociationModel; 004 import de.deepamehta.core.model.RoleModel; 005 import de.deepamehta.core.model.TopicRoleModel; 006 007 import java.util.List; 008 009 010 011 /** 012 * ### FIXDOC: Specification of an association -- A n-ary connection between topics and other associations. 013 * 014 * @author <a href="mailto:jri@deepamehta.de">Jörg Richter</a> 015 */ 016 public interface Association extends DeepaMehtaObject { 017 018 019 020 // === Model === 021 022 Role getRole1(); 023 024 Role getRole2(); 025 026 // --- 027 028 DeepaMehtaObject getPlayer1(); 029 030 DeepaMehtaObject getPlayer2(); 031 032 // --- 033 034 /** 035 * @teturn this association's topic which plays the given role. 036 * If there is no such topic, null is returned. 037 * <p> 038 * If there are 2 such topics an exception is thrown. 039 */ 040 Topic getTopic(String roleTypeUri); 041 042 /** 043 * @teturn this association's topics which play the given role. 044 * The resulting set can have 0, 1, or 2 elements. 045 */ 046 List<Topic> getTopics(String roleTypeUri); 047 048 // --- 049 050 /** 051 * Returns this association's role which refers to the same object as the given role model. 052 * The role returned is found by comparing topic IDs, topic URIs, or association IDs. 053 * The role types are <i>not</i> compared. 054 * <p> 055 * If the object refered by the given role model is not a player in this association an exception is thrown. 056 */ 057 Role getRole(RoleModel roleModel); 058 059 boolean isPlayer(TopicRoleModel roleModel); 060 061 // --- 062 063 Association loadChildTopics(); 064 Association loadChildTopics(String childTypeUri); 065 066 // --- 067 068 AssociationModel getModel(); 069 070 071 072 // === Updating === 073 074 void update(AssociationModel model); 075 }