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