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