001/* 002 * Copyright 2016 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.web.administration.welcome; 017 018import java.util.LinkedHashMap; 019import java.util.Map; 020import java.util.Set; 021 022import org.ametys.runtime.i18n.I18nizableText; 023 024/** 025 * Interface for steps to be performed after a fresh installation of Ametys has been done. 026 */ 027public interface WelcomeStep 028{ 029 /** 030 * Checks if the step is performed. 031 * @return true if the step is performed 032 */ 033 public boolean isPerformed(); 034 035 /** 036 * Gets the title of the step. 037 * @return The title as HTML 038 */ 039 public I18nizableText getTitle(); 040 041 /** 042 * Gets the text describing how to perform the step. 043 * @return The description as HTML 044 */ 045 public I18nizableText getDescription(); 046 047 /** 048 * Gets the JS actions to execute when clicking on '<a>' elements of description. 049 * @return The JS actions to execute when clicking on '<a>' elements of description 050 */ 051 public String[] getActions(); 052 053 /** 054 * Gets the paths of the images to insert in the '<img/>' elements of description. 055 * @return The paths of the images to insert in the '<img/>' elements of description. 056 */ 057 public String[] getImages(); 058 059 /** 060 * Gets the JS target ids (as regular expressions) to listen for each message type for potential changes in the steps and thus refresh the admin welcome tool. 061 * For example, {"modified": ["^site$"], "deleted": ["^site$", "^user$"]} 062 * @return A map { messageType : [targetIds]} 063 */ 064 public Map<String, Set<String>> getListenedTargetIds(); 065 066 /** 067 * Gets the order of the step. 068 * @return The order of the step 069 */ 070 public int getOrder(); 071 072 /** 073 * Gets the representation of the step as a map. 074 * @return The step as a map 075 */ 076 public default Map<String, Object> toMap() 077 { 078 Map<String, Object> map = new LinkedHashMap<>(); 079 map.put("order", getOrder()); 080 map.put("title", getTitle()); 081 map.put("description", getDescription()); 082 map.put("actions", getActions()); 083 map.put("images", getImages()); 084 map.put("targetIds", getListenedTargetIds()); 085 map.put("performed", isPerformed()); 086 return map; 087 } 088}