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.apache.cocoon.ProcessingException; 022 023import org.ametys.runtime.model.checker.ItemCheckerDescriptor; 024import org.ametys.runtime.model.type.ModelItemType; 025import org.ametys.runtime.util.ModifiableLabelable; 026 027/** 028 * Interface for model items 029 */ 030public interface ModelItem extends ModifiableLabelable, Comparable<ModelItem> 031{ 032 /** Separator used for item paths in definitions */ 033 public static final String ITEM_PATH_SEPARATOR = "/"; 034 035 /** 036 * Returns the {@link ItemCheckerDescriptor}s associated with this group. 037 * @return the {@link ItemCheckerDescriptor}s associated with this group. 038 */ 039 public Set<ItemCheckerDescriptor> getItemCheckers(); 040 041 /** 042 * Add an item checker to the group 043 * @param itemChecker the item checker to add 044 */ 045 public void addItemChecker(ItemCheckerDescriptor itemChecker); 046 047 /** 048 * Retrieves the path of the model item 049 * @return the item path 050 */ 051 public String getPath(); 052 053 /** 054 * Retrieves the model of the item 055 * @return the model 056 */ 057 public Model getModel(); 058 059 /** 060 * Sets the model of the element 061 * @param model the model to set 062 */ 063 public void setModel(Model model); 064 065 /** 066 * Retrieves the parent of the item 067 * @return the parent group 068 */ 069 public ModelItemGroup getParent(); 070 071 /** 072 * Sets the parent of the item 073 * @param parent the parent to set 074 */ 075 public void setParent(ModelItemGroup parent); 076 077 /** 078 * Converts the model item in a JSON map 079 * @param context the context of the definition 080 * @return The model item as a JSON map, or an empty map 081 * @throws ProcessingException If an error occurs when converting the model item 082 */ 083 public Map<String, Object> toJSON(DefinitionContext context) throws ProcessingException; 084 085 /** 086 * Retrieves the type. 087 * @return the type. 088 */ 089 public ModelItemType getType(); 090 091 /** 092 * Set the type. 093 * @param type the type. 094 */ 095 public void setType(ModelItemType type); 096}