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.plugins.repository.data.holder.group; 017 018import java.util.Collection; 019import java.util.List; 020import java.util.Map; 021import java.util.Optional; 022 023import org.xml.sax.ContentHandler; 024import org.xml.sax.SAXException; 025 026import org.ametys.plugins.repository.data.DataComment; 027import org.ametys.plugins.repository.data.external.ExternalizableDataProvider.ExternalizableDataStatus; 028import org.ametys.plugins.repository.data.holder.ModelAwareDataHolder; 029import org.ametys.plugins.repository.data.holder.ModifiableDataHolder; 030import org.ametys.plugins.repository.data.holder.values.SynchronizationContext; 031import org.ametys.runtime.model.ModelItem; 032import org.ametys.runtime.model.ModelItemContainer; 033import org.ametys.runtime.model.ViewItemAccessor; 034import org.ametys.runtime.model.ViewItemContainer; 035import org.ametys.runtime.model.exception.BadDataPathCardinalityException; 036import org.ametys.runtime.model.exception.BadItemTypeException; 037import org.ametys.runtime.model.exception.NotUniqueTypeException; 038import org.ametys.runtime.model.exception.UndefinedItemPathException; 039import org.ametys.runtime.model.exception.UnknownTypeException; 040import org.ametys.runtime.model.type.DataContext; 041 042/** 043 * Interface for model aware composites 044 */ 045public interface ModelAwareComposite extends ModelAwareDataHolder, Composite 046{ 047 @Override 048 public default ModelAwareComposite getComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 049 { 050 return getDefaultDataHolder().getComposite(compositePath); 051 } 052 053 @Override 054 public default ModelAwareComposite getLocalComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 055 { 056 return getDefaultDataHolder().getLocalComposite(compositePath); 057 } 058 059 @Override 060 public default ModelAwareComposite getExternalComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 061 { 062 return getDefaultDataHolder().getExternalComposite(compositePath); 063 } 064 065 @Override 066 public default ModelAwareRepeater getRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 067 { 068 return getDefaultDataHolder().getRepeater(repeaterPath); 069 } 070 071 @Override 072 public default ModelAwareRepeater getLocalRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 073 { 074 return getDefaultDataHolder().getLocalRepeater(repeaterPath); 075 } 076 077 @Override 078 public default ModelAwareRepeater getExternalRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 079 { 080 return getDefaultDataHolder().getExternalRepeater(repeaterPath); 081 } 082 083 @Override 084 public default <T> T getValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 085 { 086 return getDefaultDataHolder().getValue(dataPath); 087 } 088 089 @Override 090 public default <T> T getValue(String dataPath, boolean allowMultiValuedPathSegments) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 091 { 092 return getDefaultDataHolder().getValue(dataPath, allowMultiValuedPathSegments); 093 } 094 095 @Override 096 public default <T> T getValue(String dataPath, boolean useDefaultFromModel, T defaultValue) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 097 { 098 return getDefaultDataHolder().getValue(dataPath, useDefaultFromModel, defaultValue); 099 } 100 101 @Override 102 public default <T> T getLocalValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 103 { 104 return getDefaultDataHolder().getLocalValue(dataPath); 105 } 106 107 @Override 108 public default <T> T getExternalValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 109 { 110 return getDefaultDataHolder().getExternalValue(dataPath); 111 } 112 113 @Override 114 public default ExternalizableDataStatus getStatus(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, BadDataPathCardinalityException 115 { 116 return getDefaultDataHolder().getStatus(dataPath); 117 } 118 119 @Override 120 public default List<DataComment> getComments(String dataName) throws IllegalArgumentException, UndefinedItemPathException 121 { 122 return getDefaultDataHolder().getComments(dataName); 123 } 124 125 public default boolean hasValue(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException 126 { 127 return getDefaultDataHolder().hasValue(dataPath); 128 } 129 130 @Override 131 public default boolean hasLocalValue(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException 132 { 133 return getDefaultDataHolder().hasLocalValue(dataPath); 134 } 135 136 @Override 137 public default boolean hasExternalValue(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException 138 { 139 return getDefaultDataHolder().hasExternalValue(dataPath); 140 } 141 142 @Override 143 public default boolean hasValueOrEmpty(String dataPath) throws IllegalArgumentException 144 { 145 return getDefaultDataHolder().hasValueOrEmpty(dataPath); 146 } 147 148 @Override 149 public default boolean hasLocalValueOrEmpty(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException 150 { 151 return getDefaultDataHolder().hasLocalValueOrEmpty(dataPath); 152 } 153 154 @Override 155 public default boolean hasExternalValueOrEmpty(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException 156 { 157 return getDefaultDataHolder().hasExternalValueOrEmpty(dataPath); 158 } 159 160 @Override 161 public default boolean hasComments(String dataName) throws IllegalArgumentException, UndefinedItemPathException 162 { 163 return getDefaultDataHolder().hasComments(dataName); 164 } 165 166 @Override 167 public default Collection< ? extends ModelItemContainer> getModel() 168 { 169 return getDefaultDataHolder().getModel(); 170 } 171 172 @Override 173 public default ModelItem getDefinition(String path) throws IllegalArgumentException, UndefinedItemPathException 174 { 175 return getDefaultDataHolder().getDefinition(path); 176 } 177 178 @Override 179 public default boolean hasDefinition(String path) throws IllegalArgumentException 180 { 181 return getDefaultDataHolder().hasDefinition(path); 182 } 183 184 @Override 185 public default Collection<String> getDataNames() 186 { 187 return getDefaultDataHolder().getDataNames(); 188 } 189 190 @Override 191 public default void copyTo(ModifiableDataHolder dataHolder) throws UndefinedItemPathException, BadItemTypeException, UnknownTypeException, NotUniqueTypeException 192 { 193 getDefaultDataHolder().copyTo(dataHolder); 194 } 195 196 public default void dataToSAX(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context) throws SAXException, BadItemTypeException 197 { 198 getDefaultDataHolder().dataToSAX(contentHandler, viewItemAccessor, context); 199 } 200 201 public default void dataToSAXForEdition(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context) throws SAXException, BadItemTypeException 202 { 203 getDefaultDataHolder().dataToSAXForEdition(contentHandler, viewItemAccessor, context); 204 } 205 206 public default Map<String, Object> dataToJSON(ViewItemAccessor viewItemAccessor, DataContext context) throws BadItemTypeException 207 { 208 return getDefaultDataHolder().dataToJSON(viewItemAccessor, context); 209 } 210 211 public default Map<String, Object> dataToJSONForEdition(ViewItemAccessor viewItemAccessor, DataContext context) throws BadItemTypeException 212 { 213 return getDefaultDataHolder().dataToJSONForEdition(viewItemAccessor, context); 214 } 215 216 public default Map<String, Object> dataToMap(ViewItemAccessor viewItemAccessor, DataContext context) 217 { 218 return getDefaultDataHolder().dataToMap(viewItemAccessor, context); 219 } 220 221 public default boolean hasDifferences(ViewItemContainer viewItemContainer, Map<String, Object> values, SynchronizationContext context) throws UndefinedItemPathException, BadItemTypeException 222 { 223 return getDefaultDataHolder().hasDifferences(viewItemContainer, values, context); 224 } 225 226 @Override 227 public default Optional<? extends ModelAwareDataHolder> getParentDataHolder() 228 { 229 return getDefaultDataHolder().getParentDataHolder(); 230 } 231 232 @Override 233 public default ModelAwareDataHolder getRootDataHolder() 234 { 235 return getDefaultDataHolder().getRootDataHolder(); 236 } 237 238 @Override 239 public ModelAwareDataHolder getDefaultDataHolder(); 240}