001package systems.dmx.workspaces;
002
003import systems.dmx.core.Association;
004import systems.dmx.core.DMXObject;
005import systems.dmx.core.DMXType;
006import systems.dmx.core.Topic;
007import systems.dmx.core.service.accesscontrol.SharingMode;
008
009import java.util.List;
010
011
012
013public interface WorkspacesService {
014
015    // ------------------------------------------------------------------------------------------------------- Constants
016
017    static final String      DMX_WORKSPACE_NAME = "DMX";
018    static final String      DMX_WORKSPACE_URI = "dmx.workspaces.deepamehta";
019    static final SharingMode DMX_WORKSPACE_SHARING_MODE = SharingMode.PUBLIC;
020
021    // Property URIs
022    static final String PROP_WORKSPACE_ID = "dmx.workspaces.workspace_id";
023
024    // -------------------------------------------------------------------------------------------------- Public Methods
025
026    /**
027     * @param   uri     may be null
028     */
029    Topic createWorkspace(String name, String uri, SharingMode sharingMode);
030
031    // ---
032
033    /**
034     * Returns a workspace by URI.
035     *
036     * @return  The workspace (a topic of type "Workspace").
037     *
038     * @throws  RuntimeException    If no workspace exists for the given URI.
039     */
040    Topic getWorkspace(String uri);
041
042    /**
043     * Returns the workspace a topic or association is assigned to.
044     *
045     * @param   id      a topic ID, or an association ID
046     *
047     * @return  The assigned workspace (a topic of type "Workspace"),
048     *          or <code>null</code> if no workspace is assigned.
049     */
050    Topic getAssignedWorkspace(long objectId);
051
052    // ---
053
054    /**
055     * Assigns the given object to the given workspace.
056     */
057    void assignToWorkspace(DMXObject object, long workspaceId);
058
059    /**
060     * Assigns the given type and all its view configuration topics to the given workspace.
061     */
062    void assignTypeToWorkspace(DMXType type, long workspaceId);
063
064    // ---
065
066    /**
067     * Returns all topics assigned to the given workspace.
068     */
069    List<Topic> getAssignedTopics(long workspaceId);
070
071    /**
072     * Returns all associations assigned to the given workspace.
073     */
074    List<Association> getAssignedAssociations(long workspaceId);
075
076    // ---
077
078    /**
079     * Returns all topics of the given type that are assigned to the given workspace.
080     */
081    List<Topic> getAssignedTopics(long workspaceId, String topicTypeUri);
082
083    /**
084     * Returns all associations of the given type that are assigned to the given workspace.
085     */
086    List<Association> getAssignedAssociations(long workspaceId, String assocTypeUri);
087}