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