001package systems.dmx.topicmaps;
002
003import systems.dmx.topicmaps.model.TopicmapViewmodel;
004
005import systems.dmx.core.Topic;
006import systems.dmx.core.model.topicmaps.ViewProperties;
007import systems.dmx.core.util.IdList;
008
009
010
011public interface TopicmapsService {
012
013    // ------------------------------------------------------------------------------------------------------- Constants
014
015    static final String DEFAULT_TOPICMAP_NAME     = "untitled";
016    static final String DEFAULT_TOPICMAP_RENDERER = "dmx.webclient.default_topicmap_renderer";
017
018    // -------------------------------------------------------------------------------------------------- Public Methods
019
020    /**
021     * @return  the created Topicmap topic.
022     *
023     * ### TODO: rename 2nd param into "topicmapTypeUri"
024     */
025    Topic createTopicmap(String name, String topicmapRendererUri, boolean isPrivate);
026
027    // ---
028
029    /**
030     * @param   includeChilds   if true the topics contained in the topicmap will include their child topics.
031     */
032    TopicmapViewmodel getTopicmap(long topicmapId, boolean includeChilds);
033
034    boolean isTopicInTopicmap(long topicmapId, long topicId);
035
036    boolean isAssociationInTopicmap(long topicmapId, long assocId);
037
038    // ---
039
040    /**
041     * Adds a topic to a topicmap. If the topic is added already an exception is thrown.
042     */
043    void addTopicToTopicmap(long topicmapId, long topicId, ViewProperties viewProps);
044
045    /**
046     * Convenience method to add a topic with the standard view properties.
047     */
048    void addTopicToTopicmap(long topicmapId, long topicId, int x, int y, boolean visibility);
049
050    /**
051     * Adds an association to a topicmap. If the association is added already an exception is thrown.
052     */
053    void addAssociationToTopicmap(long topicmapId, long assocId, ViewProperties viewProps);
054
055    // Note: this is needed in order to reveal a related topic in a *single* request. Otherwise client-sync might fail
056    // due to asynchronicity. A client might receive the "addAssoc" WebSocket message *before* the "addTopic" message.
057    void addRelatedTopicToTopicmap(long topicmapId, long topicId, long assocId, ViewProperties viewProps);
058
059    // ---
060
061    void setTopicViewProperties(long topicmapId, long topicId, ViewProperties viewProps);
062
063    void setAssociationViewProperties(long topicmapId, long assocId, ViewProperties viewProps);
064
065    /**
066     * Convenience method to update the "dmx.topicmaps.x" and "dmx.topicmaps.y" standard view properties.
067     */
068    void setTopicPosition(long topicmapId, long topicId, int x, int y);
069
070    /**
071     * Convenience method to update the "dmx.topicmaps.visibility" standard view property.
072     */
073    void setTopicVisibility(long topicmapId, long topicId, boolean visibility);
074
075    /**
076     * Removes an association from a topicmap.
077     * If the associationn is not contained in the topicmap nothing is performed.
078     */
079    void removeAssociationFromTopicmap(long topicmapId, long assocId);
080
081    // ---
082
083    void hideTopics(long topicmapId, IdList topicIds);
084    void hideAssocs(long topicmapId, IdList assocIds);
085    void hideMulti(long topicmapId, IdList topicIds, IdList assocIds);
086
087    // ---
088
089    void setClusterPosition(long topicmapId, ClusterCoords coords);
090
091    void setTopicmapTranslation(long topicmapId, int transX, int transY);
092
093    // ---
094
095    // ### TODO: refactor to registerTopicmapType(TopicmapType topicmapType)
096    void registerTopicmapRenderer(TopicmapRenderer renderer);
097
098    // ### TODO: unregister needed? Might a renderer hold a stale dmx instance?
099
100    // ---
101
102    void registerViewmodelCustomizer(ViewmodelCustomizer customizer);
103
104    void unregisterViewmodelCustomizer(ViewmodelCustomizer customizer);
105}