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.UnknownDataException;
019import org.ametys.plugins.repository.data.holder.group.impl.ModifiableModelLessComposite;
020import org.ametys.plugins.repository.data.holder.group.impl.ModifiableModelLessRepeater;
021import org.ametys.runtime.model.exception.BadDataPathCardinalityException;
022import org.ametys.runtime.model.exception.BadItemTypeException;
023import org.ametys.runtime.model.exception.NotUniqueTypeException;
024import org.ametys.runtime.model.exception.UnknownTypeException;
025
026/**
027 * Interface for modifiable data containers without models
028 */
029public interface ModifiableModelLessDataHolder extends ModifiableDataHolder, ModelLessDataHolder
030{
031    @Override
032    public ModifiableModelLessComposite getComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException, BadDataPathCardinalityException;
033    
034    @Override
035    public ModifiableModelLessRepeater getRepeater(String repeaterPath) throws IllegalArgumentException, BadItemTypeException, BadDataPathCardinalityException;
036    
037    /**
038     * {@inheritDoc}
039     * @throws BadDataPathCardinalityException if the value of a part of the data path is multiple. Only the last part can be multiple
040     */
041    @Override
042    public ModifiableModelLessComposite getComposite(String compositePath, boolean createNew) throws IllegalArgumentException, BadItemTypeException, BadDataPathCardinalityException;
043    
044    /**
045     * {@inheritDoc}
046     * @throws BadDataPathCardinalityException if the value of a part of the data path is multiple. Only the last part can be multiple
047     */
048    @Override
049    public ModifiableModelLessRepeater getRepeater(String repeaterPath, boolean createNew) throws IllegalArgumentException, 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
055     * @throws IllegalArgumentException if the given data path is null or empty
056     * @throws UnknownTypeException if there is no available type compatible with the given value for this data holder's type extension point
057     * @throws NotUniqueTypeException if there is more than one available types compatibles with the given value for this data holder's type extension point
058     * @throws UnknownDataException if given the data path is composed of an inexisting group
059     * @throws BadDataPathCardinalityException if the value of a part of the data path is multiple. Only the last part can be multiple
060     */
061    public void setValue(String dataPath, Object value) throws IllegalArgumentException, UnknownTypeException, NotUniqueTypeException, UnknownDataException, BadDataPathCardinalityException;
062    
063    /**
064     * Sets the value of the data at the given path
065     * @param dataPath path of the data
066     * @param value the value to set
067     * @param dataTypeId type identifier of the data
068     * @throws IllegalArgumentException if the given data path is null or empty
069     * @throws UnknownTypeException if the given type is not available for this data holder's type extension point
070     * @throws BadItemTypeException if the given type doesn't match the given value to set
071     * @throws UnknownDataException if the given data path is composed of an inexisting group
072     * @throws BadDataPathCardinalityException if the value of a part of the data path is multiple. Only the last part can be multiple
073     */
074    public void setValue(String dataPath, Object value, String dataTypeId) throws IllegalArgumentException, UnknownTypeException, BadItemTypeException, UnknownDataException, BadDataPathCardinalityException;
075
076    /**
077     * {@inheritDoc}
078     * @throws BadDataPathCardinalityException if the value of a part of the data path is multiple. Only the last part can be multiple
079     */
080    @Override
081    public void removeValue(String dataPath) throws IllegalArgumentException, UnknownDataException, BadDataPathCardinalityException;
082}