001/* 002 * Copyright 2018 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.runtime.model; 017 018import java.util.Map; 019import java.util.Set; 020 021import org.xml.sax.ContentHandler; 022import org.xml.sax.SAXException; 023 024import org.ametys.runtime.i18n.I18nizableText; 025import org.ametys.runtime.model.checker.ItemCheckerDescriptor; 026import org.ametys.runtime.model.disableconditions.DisableConditions; 027import org.ametys.runtime.model.type.ModelItemType; 028import org.ametys.runtime.util.ModifiableLabelable; 029 030/** 031 * Interface for model items 032 */ 033public interface ModelItem extends ModifiableLabelable, Comparable<ModelItem> 034{ 035 /** Separator used for item paths in definitions */ 036 public static final String ITEM_PATH_SEPARATOR = "/"; 037 038 /** 039 * Returns the {@link ItemCheckerDescriptor}s associated with this group. 040 * @return the {@link ItemCheckerDescriptor}s associated with this group. 041 */ 042 public Set<ItemCheckerDescriptor> getItemCheckers(); 043 044 /** 045 * Add an item checker to the group 046 * @param itemChecker the item checker to add 047 */ 048 public void addItemChecker(ItemCheckerDescriptor itemChecker); 049 050 /** 051 * Retrieves the path of the model item 052 * @return the item path 053 */ 054 public String getPath(); 055 056 /** 057 * Retrieves the model of the item 058 * @return the model 059 */ 060 public Model getModel(); 061 062 /** 063 * Sets the model of the element 064 * @param model the model to set 065 */ 066 public void setModel(Model model); 067 068 /** 069 * Retrieves the parent of the item 070 * @return the parent group 071 */ 072 public ModelItemGroup getParent(); 073 074 /** 075 * Sets the parent of the item 076 * @param parent the parent to set 077 */ 078 public void setParent(ModelItemGroup parent); 079 080 /** 081 * Converts the model item in a JSON map 082 * @param context the context of the definition 083 * @return The model item as a JSON map, or an empty map 084 */ 085 public Map<String, Object> toJSON(DefinitionContext context); 086 087 /** 088 * Generates SAX events for the model item 089 * @param contentHandler the {@link ContentHandler} that will receive the SAX events 090 * @param context the context of the definition 091 * @throws SAXException if an error occurs during the SAX events generation 092 */ 093 public void toSAX(ContentHandler contentHandler, DefinitionContext context) throws SAXException; 094 095 /** 096 * Retrieves the type. 097 * @return the type. 098 */ 099 public ModelItemType getType(); 100 101 /** 102 * Set the type. 103 * @param type the type. 104 */ 105 public void setType(ModelItemType type); 106 107 /** 108 * Retrieves the name of the plugin declaring this element. 109 * @return the plugin name. 110 */ 111 public String getPluginName(); 112 113 /** 114 * Set the name of the plugin declaring this element. 115 * @param pluginName the plugin name. 116 */ 117 public void setPluginName(String pluginName); 118 119 120 /** 121 * Retrieves the widget to use for rendering. 122 * @return the widget or <code>null</code> if none is defined. 123 */ 124 public String getWidget(); 125 126 /** 127 * Set the widget. 128 * @param widget the widget. 129 */ 130 public void setWidget(String widget); 131 132 /** 133 * Get the widget's parameters 134 * @return the widget's parameters 135 */ 136 public Map<String, I18nizableText> getWidgetParameters(); 137 138 /** 139 * Set the widget's parameters 140 * @param params the parameters to set 141 */ 142 public void setWidgetParameters (Map<String, I18nizableText> params); 143 144 /** 145 * Retrieves the disable condition. 146 * @return the disable condition or <code>null</code> if none is defined. 147 */ 148 public DisableConditions getDisableConditions(); 149 150 /** 151 * Sets the disable condition. 152 * @param disableConditions the disable condition. 153 */ 154 public void setDisableConditions(DisableConditions disableConditions); 155}