001/*
002 *  Copyright 2026 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.holder.group.impl;
017
018import java.util.Optional;
019
020import org.ametys.cms.data.holder.IndexableDataHolder;
021import org.ametys.cms.data.holder.group.IndexableRepeater;
022import org.ametys.cms.data.holder.group.IndexableRepeaterEntry;
023import org.ametys.cms.data.holder.impl.DefaultIndexableDataHolder;
024import org.ametys.plugins.repository.data.holder.group.impl.DefaultRepeaterEntry;
025import org.ametys.plugins.repository.data.repositorydata.RepositoryData;
026import org.ametys.runtime.model.ModelItemGroup;
027
028/**
029 * Class for indexable model aware repeater entries
030 */
031public class DefaultIndexableRepeaterEntry extends DefaultRepeaterEntry implements IndexableRepeaterEntry
032{
033    /**
034     * Creates a default indexable repeater entry
035     * @param repositoryData the repository data of the repeater entry
036     * @param definition the definition of the repeater
037     * @param repeater the repeater containing this entry
038     */
039    public DefaultIndexableRepeaterEntry(RepositoryData repositoryData, ModelItemGroup definition, DefaultIndexableRepeater repeater)
040    {
041        super(repositoryData, definition, repeater);
042        // Override with an Indexable data holder implementation
043        _defaultDataHolder = new DefaultIndexableDataHolder(repositoryData, definition, Optional.of(repeater.getParentDataHolder()), Optional.of(repeater.getRootDataHolder()));
044    }
045
046    @Override
047    public IndexableDataHolder getDefaultDataHolder()
048    {
049        return (IndexableDataHolder) _defaultDataHolder;
050    }
051
052    @Override
053    public IndexableRepeater getHoldingRepeater()
054    {
055        return (IndexableRepeater) _repeater;
056    }
057}