001/* 002 * Copyright 2017 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.workspaces.project.modules; 017 018import java.util.List; 019import java.util.Map; 020import java.util.Set; 021 022import org.ametys.plugins.explorer.resources.ModifiableResourceCollection; 023import org.ametys.plugins.workspaces.project.objects.Project; 024import org.ametys.plugins.workspaces.util.StatisticColumn; 025import org.ametys.runtime.i18n.I18nizableText; 026import org.ametys.web.repository.sitemap.Sitemap; 027 028/** 029 * Manager for the Workspaces modules 030 */ 031public interface WorkspaceModule extends Comparable<WorkspaceModule> 032{ 033 /** Order of module */ 034 static int ORDER_WALLCONTENT = 0; 035 /** Order of module */ 036 static int ORDER_NEWS = 5; 037 /** Order of module */ 038 static int ORDER_ALERTS = 5; 039 /** Order of module */ 040 static int ORDER_MEMBERS = 10; 041 /** Order of module */ 042 static int ORDER_DOCUMENTS = 20; 043 /** Order of module */ 044 static int ORDER_THREADS = 30; 045 /** Order of module */ 046 static int ORDER_CALENDAR = 40; 047 /** Order of module */ 048 static int ORDER_TASKS = 50; 049 /** Order of module */ 050 static int ORDER_MINISITE = 60; 051 /** Order of module */ 052 static int ORDER_ABOUT = 70; 053 /** Header id for elements group header */ 054 static String GROUP_HEADER_ELEMENTS_ID = "general$elements"; 055 /** Header id for size group header */ 056 static String GROUP_HEADER_SIZE_ID = "general$size"; 057 /** Header id for activated group header */ 058 static String GROUP_HEADER_ACTIVATED_ID = "general$activated"; 059 /** Header id for last activity group header */ 060 static String GROUP_HEADER_LAST_ACTIVITY_ID = "general$lastActivity"; 061 062 063 064 /** 065 * Get the module Id 066 * @return The module ID 067 */ 068 String getId(); 069 070 /** 071 * Get the module title 072 * @return The title 073 */ 074 I18nizableText getModuleTitle(); 075 076 /** 077 * Get the module title 078 * @return The title 079 */ 080 I18nizableText getModuleDescription(); 081 082 /** 083 * Get the module name 084 * @return the module name 085 */ 086 String getModuleName(); 087 088 /** 089 * Get the module order 090 * @return the priority in menus 091 */ 092 int getOrder(); 093 094 /** 095 * Activate the module for the project, creating the module pages 096 * @param project The project 097 * @param additionalValues A list of optional additional values. Accepted values are : description, mailingList, inscriptionStatus, defaultProfile, tags, categoryTags, keywords and language 098 */ 099 void activateModule(Project project, Map<String, Object> additionalValues); 100 /** 101 * Initialize the sitemap for the module 102 * @param project The project of the module 103 * @param sitemap The sitemap 104 */ 105 void initializeSitemap(Project project, Sitemap sitemap); 106 107 /** 108 * Deactivate a module 109 * @param project The project 110 */ 111 void deactivateModule(Project project); 112 113 /** 114 * Delete a module and all related data (pages, events, resources, ...) 115 * @param project The project 116 */ 117 void deleteData(Project project); 118 119 /** 120 * Get the set of allowed event type for the module 121 * @return The set of allowed event types 122 */ 123 Set<String> getAllowedEventTypes(); 124 125 /** 126 * Get the set of all event type for the module 127 * @return The set of all event types 128 */ 129 Set<String> getAllEventTypes(); 130 131 /** 132 * Get the module root node for the given project 133 * @param project The project containing the module 134 * @param create True to create the node if it does not exists 135 * @return The root node, or null if it does not exists and was not created 136 */ 137 ModifiableResourceCollection getModuleRoot(Project project, boolean create); 138 139 /** 140 * Get the URL of the first module's page 141 * @param project The project 142 * @return the module url 143 */ 144 String getModuleUrl(Project project); 145 146 /** 147 * Determines if the module is unactivated by default 148 * @return true if the module is not proposed by default 149 */ 150 default boolean isUnactivatedByDefault() 151 { 152 return false; 153 } 154 155 default int compareTo(WorkspaceModule that) 156 { 157 if (this.getOrder() == that.getOrder()) 158 { 159 return this.getId().compareTo(that.getId()); 160 } 161 else 162 { 163 return this.getOrder() - that.getOrder(); 164 } 165 } 166 167 /** 168 * Get the statistics of the module 169 * @param project The project 170 * @return a map of statistics 171 */ 172 Map<String, Object> getStatistics(Project project); 173 174 /** 175 * Get the headers of statistics 176 * @return a list of statistics headers 177 */ 178 List<StatisticColumn> getStatisticModel(); 179 180 /** 181 * Returns the key to get module size in statistics 182 * @return The key to get module size in statistics 183 */ 184 public String getModuleSizeKey(); 185}