001package de.deepamehta.plugins.workspaces; 002 003import de.deepamehta.core.DeepaMehtaObject; 004import de.deepamehta.core.RelatedTopic; 005import de.deepamehta.core.Topic; 006import de.deepamehta.core.Type; 007import de.deepamehta.core.service.ResultList; 008import de.deepamehta.core.service.accesscontrol.SharingMode; 009 010 011 012public interface WorkspacesService { 013 014 // ------------------------------------------------------------------------------------------------------- Constants 015 016 static final String DEEPAMEHTA_WORKSPACE_NAME = "DeepaMehta"; 017 static final String DEEPAMEHTA_WORKSPACE_URI = "dm4.workspaces.deepamehta"; 018 static final SharingMode DEEPAMEHTA_WORKSPACE_SHARING_MODE = SharingMode.PUBLIC; 019 020 // -------------------------------------------------------------------------------------------------- Public Methods 021 022 /** 023 * @param uri may be null 024 */ 025 Topic createWorkspace(String name, String uri, SharingMode sharingMode); 026 027 // --- 028 029 /** 030 * Returns a workspace by URI. 031 * 032 * @return The workspace (a topic of type "Workspace"). 033 * 034 * @throws RuntimeException If no workspace exists for the given URI. 035 */ 036 Topic getWorkspace(String uri); 037 038 /** 039 * Returns all topics of the given type that are assigned to the given workspace. 040 */ 041 ResultList<RelatedTopic> getAssignedTopics(long workspaceId, String typeUri); 042 043 /** 044 * Returns the workspace a topic or association is assigned to. 045 * 046 * @param id a topic ID, or an association ID 047 * 048 * @return The assigned workspace (a topic of type "Workspace"), 049 * or <code>null</code> if no workspace is assigned. 050 */ 051 Topic getAssignedWorkspace(long objectId); 052 053 /** 054 * Checks weather the given topic or association is assigned to the given workspace. 055 */ 056 boolean isAssignedToWorkspace(long objectId, long workspaceId); 057 058 // --- 059 060 /** 061 * Assigns the given object to the given workspace. 062 */ 063 void assignToWorkspace(DeepaMehtaObject object, long workspaceId); 064 065 /** 066 * Assigns the given type and all its view configuration topics to the given workspace. 067 */ 068 void assignTypeToWorkspace(Type type, long workspaceId); 069}