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;
017
018import org.ametys.plugins.repository.data.holder.group.impl.ModifiableModelAwareComposite;
019import org.ametys.plugins.repository.data.holder.group.impl.ModifiableModelAwareRepeater;
020import org.ametys.runtime.model.exception.BadDataPathCardinalityException;
021import org.ametys.runtime.model.exception.BadItemTypeException;
022import org.ametys.runtime.model.exception.UndefinedItemPathException;
023
024/**
025 * Interface for modifiable data containers with models
026 */
027public interface ModifiableModelAwareDataHolder extends ModifiableDataHolder, ModelAwareDataHolder
028{
029    @Override
030    public ModifiableModelAwareComposite getComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException;
031    
032    @Override
033    public ModifiableModelAwareRepeater getRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException;
034    
035    /**
036     * {@inheritDoc}
037     * @throws UndefinedItemPathException if the given composite path is not defined by the model
038     * @throws BadDataPathCardinalityException if the definition of a part of the data path is multiple. Only the last part can be multiple
039     */
040    @Override
041    public ModifiableModelAwareComposite getComposite(String compositePath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException;
042    
043    /**
044     * {@inheritDoc}
045     * @throws UndefinedItemPathException if the given composite path is not defined by the model
046     * @throws BadDataPathCardinalityException if the definition of a part of the data path is multiple. Only the last part can be multiple
047     */
048    @Override
049    public ModifiableModelAwareRepeater getRepeater(String repeaterPath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException;
050    
051    /**
052     * Sets the value of the data at the given path
053     * @param dataPath path of the data
054     * @param value the value to set. The type of this value will be given by the model, but if not model is associated to the path, an {@link UnsupportedOperationException} is thrown. Use the 3 arguments versions in that case.
055     * @throws IllegalArgumentException if the given data path is null or empty
056     * @throws UndefinedItemPathException if the given data path is not defined by the model
057     * @throws BadItemTypeException if the type defined by the model doesn't match the given value to set 
058     * @throws BadDataPathCardinalityException if the definition of a part of the data path is multiple. Only the last part can be multiple
059     */
060    public void setValue(String dataPath, Object value) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException;
061    
062    /**
063     * {@inheritDoc}
064     * @throws UndefinedItemPathException if the given data path is not defined by the model
065     * @throws BadDataPathCardinalityException if the definition of a part of the data path is multiple. Only the last part can be multiple
066     */
067    @Override
068    public void removeValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException;
069}