001/*
002 *  Copyright 2022 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.cms.data.ametysobject;
017
018import java.util.Optional;
019
020import org.ametys.cms.data.holder.ModifiableIndexableDataHolder;
021import org.ametys.cms.data.holder.group.ModifiableIndexableComposite;
022import org.ametys.cms.data.holder.group.ModifiableIndexableRepeater;
023import org.ametys.plugins.repository.AmetysObject;
024import org.ametys.runtime.model.exception.BadDataPathCardinalityException;
025import org.ametys.runtime.model.exception.BadItemTypeException;
026import org.ametys.runtime.model.exception.UndefinedItemPathException;
027
028/**
029 * Model aware {@link AmetysObject} that can handle modifiable  indexable data.
030 */
031public interface ModifiableModelAwareDataAwareAmetysObject extends org.ametys.plugins.repository.data.ametysobject.ModifiableModelAwareDataAwareAmetysObject, ModelAwareDataAwareAmetysObject, ModifiableIndexableDataHolder
032{
033    @Override
034    public ModifiableIndexableDataHolder getDataHolder();
035
036    @Override
037    public default ModifiableIndexableComposite getComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
038    {
039        return getDataHolder().getComposite(compositePath);
040    }
041
042    @Override
043    public default ModifiableIndexableComposite getComposite(String compositePath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
044    {
045        return getDataHolder().getComposite(compositePath, createNew);
046    }
047
048    @Override
049    public default ModifiableIndexableComposite getLocalComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
050    {
051        return getDataHolder().getLocalComposite(compositePath);
052    }
053
054    @Override
055    public default ModifiableIndexableComposite getLocalComposite(String compositePath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
056    {
057        return getDataHolder().getLocalComposite(compositePath, createNew);
058    }
059
060    @Override
061    public default ModifiableIndexableComposite getExternalComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
062    {
063        return getDataHolder().getExternalComposite(compositePath);
064    }
065
066    @Override
067    public default ModifiableIndexableComposite getExternalComposite(String compositePath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
068    {
069        return getDataHolder().getExternalComposite(compositePath, createNew);
070    }
071
072    @Override
073    public default ModifiableIndexableRepeater getRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
074    {
075        return getDataHolder().getRepeater(repeaterPath);
076    }
077
078    @Override
079    public default ModifiableIndexableRepeater getRepeater(String repeaterPath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
080    {
081        return getDataHolder().getRepeater(repeaterPath, createNew);
082    }
083
084    @Override
085    public default ModifiableIndexableRepeater getLocalRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
086    {
087        return getDataHolder().getLocalRepeater(repeaterPath);
088    }
089
090    @Override
091    public default ModifiableIndexableRepeater getLocalRepeater(String repeaterPath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
092    {
093        return getDataHolder().getLocalRepeater(repeaterPath, createNew);
094    }
095    
096    @Override
097    public default ModifiableIndexableRepeater getExternalRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
098    {
099        return getDataHolder().getExternalRepeater(repeaterPath);
100    }
101
102    @Override
103    public default ModifiableIndexableRepeater getExternalRepeater(String repeaterPath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
104    {
105        return getDataHolder().getExternalRepeater(repeaterPath, createNew);
106    }
107    
108    @Override
109    public default Optional<? extends ModifiableIndexableDataHolder> getParentDataHolder()
110    {
111        return getDataHolder().getParentDataHolder();
112    }
113    
114    @Override
115    public default ModifiableIndexableDataHolder getRootDataHolder()
116    {
117        return getDataHolder().getRootDataHolder();
118    }
119}