Coverage Report - pt.digitalis.dif.dem.managers.IMessageManager
 
Classes in this File Line Coverage Branch Coverage Complexity
IMessageManager
N/A
N/A
1
 
 1  
 /**
 2  
  * - Digitalis Internal Framework v2.0 - (C) 2007, Digitalis Informatica. Distribuicao e Gestao de Informatica, Lda.
 3  
  * Estrada de Paco de Arcos num.9 - Piso -1 2780-666 Paco de Arcos Telefone: (351) 21 4408990 Fax: (351) 21 4408999
 4  
  * http://www.digitalis.pt
 5  
  */
 6  
 package pt.digitalis.dif.dem.managers;
 7  
 
 8  
 import java.util.Map;
 9  
 import java.util.Set;
 10  
 
 11  
 import pt.digitalis.dif.dem.Entity;
 12  
 import pt.digitalis.dif.dem.interfaces.IApplication;
 13  
 import pt.digitalis.dif.dem.interfaces.IEntity;
 14  
 import pt.digitalis.dif.dem.interfaces.IProvider;
 15  
 import pt.digitalis.dif.dem.interfaces.IService;
 16  
 import pt.digitalis.dif.dem.interfaces.IStage;
 17  
 import pt.digitalis.dif.dem.objects.messages.MessageList;
 18  
 import pt.digitalis.dif.dem.objects.messages.MessageTranslations;
 19  
 import pt.digitalis.utils.inspection.exception.ResourceNotFoundException;
 20  
 
 21  
 /**
 22  
  * Manages the DEM messages, providing operations for access, pooling and persistence.
 23  
  * 
 24  
  * @author Pedro Viegas <a href="mailto:pviegas@digitalis.pt">pviegas@digitalis.pt</a>
 25  
  * @author Rodrigo Gonçalves <a href="mailto:rgoncalves@digitalis.pt">rgoncalves@digitalis.pt</a>
 26  
  * @created 2007/06/01
 27  
  */
 28  
 public interface IMessageManager {
 29  
 
 30  
     /**
 31  
      * Adds a new supported language to the manager.
 32  
      * 
 33  
      * @param language
 34  
      *            the new supported language to add
 35  
      */
 36  
     public void addSupportedLanguage(String language);
 37  
 
 38  
     /**
 39  
      * Collect entity messages from resource LanguageID, MessageID, theMessageObject
 40  
      * 
 41  
      * @param clazz
 42  
      *            the class to read the messages from
 43  
      * @return the collected messages
 44  
      */
 45  
     public MessageList collectEntityMessagesFromRepository(Class<?> clazz);
 46  
 
 47  
     /**
 48  
      * Collect entity messages from resource LanguageID, MessageID, theMessageObject
 49  
      * 
 50  
      * @param type
 51  
      *            the type of the entity or null if it's not a DEM entity
 52  
      * @param instance
 53  
      *            the entity instance
 54  
      * @return the collected messages
 55  
      */
 56  
     public MessageList collectEntityMessagesFromRepository(Entity type, Object instance);
 57  
 
 58  
     /**
 59  
      * Collect entity messages from resource LanguageID, MessageID, theMessageObject
 60  
      * 
 61  
      * @param type
 62  
      *            the type of the entity or null if it's not a DEM entity
 63  
      * @param id
 64  
      *            the entity id
 65  
      * @param className
 66  
      *            the class name
 67  
      * @param parentID
 68  
      *            the entity's parent ID
 69  
      * @return the collected messages
 70  
      * @throws ResourceNotFoundException
 71  
      *             if a needed resource for message collection can't be found
 72  
      */
 73  
     public MessageList collectEntityMessagesFromRepository(Entity type, String id, String className, String parentID)
 74  
             throws ResourceNotFoundException;
 75  
 
 76  
     /**
 77  
      * Collect entity messages from resource LanguageID, MessageID, theMessageObject
 78  
      * 
 79  
      * @param messagePath
 80  
      *            the messagePath for the message file (without the ".messages.xx" suffix)
 81  
      * @return the collected messages
 82  
      */
 83  
     public MessageList collectEntityMessagesFromRepository(String messagePath);
 84  
 
 85  
     /**
 86  
      * Gets the messages from the repository and collects them on first use
 87  
      * 
 88  
      * @param type
 89  
      *            the entity type
 90  
      * @param entity
 91  
      *            the entity object
 92  
      * @return the messages collected
 93  
      */
 94  
     public MessageList getMessageList(Entity type, IEntity entity);
 95  
 
 96  
     /**
 97  
      * Gets the messages of a given Provider with all translations.
 98  
      * 
 99  
      * @param application
 100  
      *            the application for which the messages should be retrieved
 101  
      * @return the application messages
 102  
      */
 103  
     public MessageList getMessageList(IApplication application);
 104  
 
 105  
     /**
 106  
      * Gets the messages of a given Provider with all translations.
 107  
      * 
 108  
      * @param provider
 109  
      *            the provider for which the messages should be retrieved
 110  
      * @return the provider messages
 111  
      */
 112  
     public MessageList getMessageList(IProvider provider);
 113  
 
 114  
     /**
 115  
      * Gets the messages of a given service with all translations.
 116  
      * 
 117  
      * @param service
 118  
      *            the service for which the messages should be retrieved
 119  
      * @return the service messages
 120  
      */
 121  
     public MessageList getMessageList(IService service);
 122  
 
 123  
     /**
 124  
      * Gets the messages of a given stage with all translations.
 125  
      * 
 126  
      * @param stage
 127  
      *            the stage for which the messages should be retrieved
 128  
      * @return the stage messages
 129  
      */
 130  
     public MessageList getMessageList(IStage stage);
 131  
 
 132  
     /**
 133  
      * Gets the messages of a given Application.
 134  
      * 
 135  
      * @param application
 136  
      *            the application for which the messages should be retrieved
 137  
      * @param language
 138  
      *            the language to filter
 139  
      * @return the application messages
 140  
      */
 141  
     public Map<String, String> getMessages(IApplication application, String language);
 142  
 
 143  
     /**
 144  
      * Gets the messages of a given Provider.
 145  
      * 
 146  
      * @param provider
 147  
      *            the provider for which the messages should be retrieved
 148  
      * @param language
 149  
      *            the language to search
 150  
      * @return the provider messages
 151  
      */
 152  
     public Map<String, String> getMessages(IProvider provider, String language);
 153  
 
 154  
     /**
 155  
      * Gets the messages of a given Service.
 156  
      * 
 157  
      * @param service
 158  
      *            the service for which the messages should be retrieved
 159  
      * @param language
 160  
      *            the language to filter
 161  
      * @return the service messages
 162  
      */
 163  
     public Map<String, String> getMessages(IService service, String language);
 164  
 
 165  
     /**
 166  
      * Gets the messages of a given Stage.
 167  
      * 
 168  
      * @param stage
 169  
      *            the stage for which the messages should be retrieved
 170  
      * @param language
 171  
      *            the language to filter
 172  
      * @return the stage messages
 173  
      */
 174  
     public Map<String, String> getMessages(IStage stage, String language);
 175  
 
 176  
     /**
 177  
      * Returns the list of supported languages.
 178  
      * 
 179  
      * @return the list of supported languages
 180  
      */
 181  
     public Set<String> getSupportedLanguages();
 182  
 
 183  
     /** Invalidates the messages, forcing their reloading. */
 184  
     public void invalidateMessages();
 185  
 
 186  
     /**
 187  
      * Checks if a given language is supported.
 188  
      * 
 189  
      * @param language
 190  
      *            the language to check
 191  
      * @return T if the passed language is supported, F otherwise
 192  
      */
 193  
     public boolean isLanguageSupported(String language);
 194  
 
 195  
     /**
 196  
      * @return T this implementation supports saving messages to a persistent media. If F changes will be lost after a
 197  
      *         server restart
 198  
      */
 199  
     public boolean isPersistent();
 200  
 
 201  
     /**
 202  
      * Updates a message with a given ID on a given class.
 203  
      * 
 204  
      * @param clazz
 205  
      *            the class
 206  
      * @param messageID
 207  
      *            the ID of the message to update
 208  
      * @param message
 209  
      *            the message (and it's translations) to update
 210  
      */
 211  
     public void updateMessage(Class<?> clazz, String messageID, MessageTranslations message);
 212  
 
 213  
     /**
 214  
      * Updates a message with a given ID on a given entity.
 215  
      * 
 216  
      * @param entity
 217  
      *            the entity
 218  
      * @param messageID
 219  
      *            the ID of the message to update
 220  
      * @param message
 221  
      *            the message (and it's translations) to update
 222  
      */
 223  
     public void updateMessage(IEntity entity, String messageID, MessageTranslations message);
 224  
 }