001/* 002 * Copyright 2019 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.ametysobject; 017 018import java.util.List; 019import java.util.Map; 020import java.util.Optional; 021 022import org.ametys.plugins.repository.AmetysObject; 023import org.ametys.plugins.repository.ModifiableAmetysObject; 024import org.ametys.plugins.repository.data.DataComment; 025import org.ametys.plugins.repository.data.UnknownDataException; 026import org.ametys.plugins.repository.data.external.ExternalizableDataProvider.ExternalizableDataStatus; 027import org.ametys.plugins.repository.data.holder.ModifiableModelAwareDataHolder; 028import org.ametys.plugins.repository.data.holder.group.ModifiableModelAwareComposite; 029import org.ametys.plugins.repository.data.holder.group.ModifiableModelAwareRepeater; 030import org.ametys.plugins.repository.data.holder.values.SynchronizationContext; 031import org.ametys.plugins.repository.data.holder.values.SynchronizationResult; 032import org.ametys.plugins.repository.data.repositorydata.ModifiableRepositoryData; 033import org.ametys.runtime.model.ViewItemContainer; 034import org.ametys.runtime.model.exception.BadDataPathCardinalityException; 035import org.ametys.runtime.model.exception.BadItemTypeException; 036import org.ametys.runtime.model.exception.UndefinedItemPathException; 037 038/** 039 * Model aware {@link AmetysObject} that can handle modifiable data. 040 */ 041public interface ModifiableModelAwareDataAwareAmetysObject extends ModelAwareDataAwareAmetysObject, ModifiableModelAwareDataHolder, ModifiableAmetysObject 042{ 043 @Override 044 public ModifiableModelAwareDataHolder getDataHolder(); 045 046 @Override 047 public default ModifiableModelAwareComposite getComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 048 { 049 return getDataHolder().getComposite(compositePath); 050 } 051 052 @Override 053 public default ModifiableModelAwareComposite getLocalComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 054 { 055 return getDataHolder().getLocalComposite(compositePath); 056 } 057 058 @Override 059 public default ModifiableModelAwareComposite getExternalComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 060 { 061 return getDataHolder().getExternalComposite(compositePath); 062 } 063 064 @Override 065 public default ModifiableModelAwareRepeater getRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 066 { 067 return getDataHolder().getRepeater(repeaterPath); 068 } 069 070 @Override 071 public default ModifiableModelAwareRepeater getLocalRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 072 { 073 return getDataHolder().getLocalRepeater(repeaterPath); 074 } 075 076 @Override 077 public default ModifiableModelAwareRepeater getExternalRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 078 { 079 return getDataHolder().getExternalRepeater(repeaterPath); 080 } 081 082 public default ModifiableModelAwareComposite getComposite(String compositePath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 083 { 084 return getDataHolder().getComposite(compositePath, createNew); 085 } 086 087 public default ModifiableModelAwareComposite getLocalComposite(String compositePath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 088 { 089 return getDataHolder().getLocalComposite(compositePath, createNew); 090 } 091 092 public default ModifiableModelAwareComposite getExternalComposite(String compositePath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 093 { 094 return getDataHolder().getExternalComposite(compositePath, createNew); 095 } 096 097 public default ModifiableModelAwareRepeater getRepeater(String repeaterPath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 098 { 099 return getDataHolder().getRepeater(repeaterPath, createNew); 100 } 101 102 public default ModifiableModelAwareRepeater getLocalRepeater(String repeaterPath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 103 { 104 return getDataHolder().getLocalRepeater(repeaterPath, createNew); 105 } 106 107 public default ModifiableModelAwareRepeater getExternalRepeater(String repeaterPath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 108 { 109 return getDataHolder().getExternalRepeater(repeaterPath, createNew); 110 } 111 112 public default <T extends SynchronizationResult> T synchronizeValues(Map<String, Object> values) throws UndefinedItemPathException, BadItemTypeException 113 { 114 return getDataHolder().synchronizeValues(values); 115 } 116 117 public default <T extends SynchronizationResult> T synchronizeValues(Map<String, Object> values, SynchronizationContext context) throws UndefinedItemPathException, BadItemTypeException 118 { 119 return getDataHolder().synchronizeValues(values, context); 120 } 121 122 public default <T extends SynchronizationResult> T synchronizeValues(ViewItemContainer viewItemContainer, Map<String, Object> values) throws UndefinedItemPathException, BadItemTypeException 123 { 124 return getDataHolder().synchronizeValues(viewItemContainer, values); 125 } 126 127 public default <T extends SynchronizationResult> T synchronizeValues(ViewItemContainer viewItemContainer, Map<String, Object> values, SynchronizationContext context) throws UndefinedItemPathException, BadItemTypeException 128 { 129 return getDataHolder().synchronizeValues(viewItemContainer, values, context); 130 } 131 132 public default void setValue(String dataPath, Object value) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 133 { 134 getDataHolder().setValue(dataPath, value); 135 } 136 137 public default void setLocalValue(String dataPath, Object localValue) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 138 { 139 getDataHolder().setLocalValue(dataPath, localValue); 140 } 141 142 public default void setExternalValue(String dataPath, Object externalValue) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 143 { 144 getDataHolder().setExternalValue(dataPath, externalValue); 145 } 146 147 public default void setStatus(String dataPath, ExternalizableDataStatus status) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 148 { 149 getDataHolder().setStatus(dataPath, status); 150 } 151 152 public default void setComments(String dataName, List<DataComment> comments) throws IllegalArgumentException, UndefinedItemPathException 153 { 154 getDataHolder().setComments(dataName, comments); 155 } 156 157 public default void removeValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, UnknownDataException, BadDataPathCardinalityException 158 { 159 getDataHolder().removeValue(dataPath); 160 } 161 162 public default void removeLocalValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, UnknownDataException, BadDataPathCardinalityException 163 { 164 getDataHolder().removeLocalValue(dataPath); 165 } 166 167 public default void removeExternalValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, UnknownDataException, BadDataPathCardinalityException 168 { 169 getDataHolder().removeExternalValue(dataPath); 170 } 171 172 default void removeExternalizableMetadataIfExists(String dataPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException 173 { 174 getDataHolder().removeExternalizableMetadataIfExists(dataPath); 175 } 176 177 public default ModifiableRepositoryData getRepositoryData() 178 { 179 return getDataHolder().getRepositoryData(); 180 } 181 182 public default Optional<? extends ModifiableModelAwareDataHolder> getParentDataHolder() 183 { 184 return getDataHolder().getParentDataHolder(); 185 } 186 187 public default ModifiableModelAwareDataHolder getRootDataHolder() 188 { 189 return getDataHolder().getRootDataHolder(); 190 } 191}