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.Map; 019import java.util.Optional; 020 021import org.ametys.plugins.repository.AmetysObject; 022import org.ametys.plugins.repository.ModifiableAmetysObject; 023import org.ametys.plugins.repository.data.UnknownDataException; 024import org.ametys.plugins.repository.data.holder.ModifiableModelLessDataHolder; 025import org.ametys.plugins.repository.data.holder.group.impl.ModifiableModelLessComposite; 026import org.ametys.plugins.repository.data.repositorydata.ModifiableRepositoryData; 027import org.ametys.runtime.model.exception.BadDataPathCardinalityException; 028import org.ametys.runtime.model.exception.BadItemTypeException; 029import org.ametys.runtime.model.exception.NotUniqueTypeException; 030import org.ametys.runtime.model.exception.UnknownTypeException; 031 032/** 033 * Model less {@link AmetysObject} that can handle modifiable data. 034 */ 035public interface ModifiableModelLessDataAwareAmetysObject extends ModifiableModelLessDataHolder, ModelLessDataAwareAmetysObject, ModifiableAmetysObject 036{ 037 @Override 038 public ModifiableModelLessDataHolder getDataHolder(); 039 040 @Override 041 public default ModifiableModelLessComposite getComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException, BadDataPathCardinalityException 042 { 043 return getDataHolder().getComposite(compositePath); 044 } 045 046 public default ModifiableModelLessComposite getComposite(String compositePath, boolean createNew) throws IllegalArgumentException, BadItemTypeException, BadDataPathCardinalityException 047 { 048 return getDataHolder().getComposite(compositePath, createNew); 049 } 050 051 public default boolean synchronizeValues(Map<String, Object> values) throws UnknownTypeException, NotUniqueTypeException 052 { 053 return getDataHolder().synchronizeValues(values); 054 } 055 056 public default void setValue(String dataPath, Object value) throws IllegalArgumentException, UnknownTypeException, NotUniqueTypeException, UnknownDataException, BadDataPathCardinalityException 057 { 058 getDataHolder().setValue(dataPath, value); 059 } 060 061 public default void setValue(String dataPath, Object value, String dataType) throws IllegalArgumentException, BadItemTypeException, UnknownDataException, BadDataPathCardinalityException 062 { 063 getDataHolder().setValue(dataPath, value, dataType); 064 } 065 066 public default void removeValue(String dataPath) throws IllegalArgumentException, UnknownTypeException, BadItemTypeException, BadDataPathCardinalityException 067 { 068 getDataHolder().removeValue(dataPath); 069 } 070 071 public default ModifiableRepositoryData getRepositoryData() 072 { 073 return getDataHolder().getRepositoryData(); 074 } 075 076 public default Optional<? extends ModifiableModelLessDataHolder> getParentDataHolder() 077 { 078 return getDataHolder().getParentDataHolder(); 079 } 080 081 public default ModifiableModelLessDataHolder getRootDataHolder() 082 { 083 return getDataHolder().getRootDataHolder(); 084 } 085}