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 topic which has the given type.
044         *          If there is no such topic, null is returned.
045         *          <p>
046         *          If there are 2 such topics an exception is thrown.
047         */
048        Topic getTopicByType(String topicTypeUri);
049    
050        // ---
051    
052        /**
053         * Returns this association's role which refers to the same object as the given role model.
054         * The role returned is found by comparing topic IDs, topic URIs, or association IDs.
055         * The role types are <i>not</i> compared.
056         * <p>
057         * If the object refered by the given role model is not a player in this association an exception is thrown.
058         */
059        Role getRole(RoleModel roleModel);
060    
061        boolean isPlayer(TopicRoleModel roleModel);
062    
063        // ---
064    
065        Association loadChildTopics();
066        Association loadChildTopics(String childTypeUri);
067    
068        // ---
069    
070        AssociationModel getModel();
071    
072    
073    
074        // === Updating ===
075    
076        void update(AssociationModel model);
077    }