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.IndexableComposite; 022import org.ametys.cms.data.holder.group.IndexableRepeater; 023import org.ametys.cms.data.holder.impl.DefaultIndexableDataHolder; 024import org.ametys.plugins.repository.data.holder.group.Composite; 025import org.ametys.plugins.repository.data.holder.group.impl.DefaultModelAwareComposite; 026import org.ametys.plugins.repository.data.repositorydata.RepositoryData; 027import org.ametys.runtime.model.ModelItemGroup; 028import org.ametys.runtime.model.exception.BadDataPathCardinalityException; 029import org.ametys.runtime.model.exception.BadItemTypeException; 030import org.ametys.runtime.model.exception.UndefinedItemPathException; 031 032/** 033 * Class for indexable model aware composites 034 */ 035public class DefaultIndexableComposite extends DefaultModelAwareComposite implements IndexableComposite 036{ 037 /** 038 * Creates a default indexable composite 039 * @param repositoryData the repository data of the composite 040 * @param definition the definition of the composite 041 * @param parent the parent of the created {@link Composite} 042 * @param root the root {@link IndexableDataHolder} 043 */ 044 public DefaultIndexableComposite(RepositoryData repositoryData, ModelItemGroup definition, IndexableDataHolder parent, IndexableDataHolder root) 045 { 046 super(repositoryData, definition, parent, root); 047 // Override with an Indexable implementation 048 _defaultDataHolder = new DefaultIndexableDataHolder(repositoryData, definition, Optional.of(parent), Optional.of(root)); 049 } 050 051 @Override 052 public IndexableDataHolder getDefaultDataHolder() 053 { 054 return (IndexableDataHolder) _defaultDataHolder; 055 } 056 057 public IndexableRepeater getRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 058 { 059 return (IndexableRepeater) super.getRepeater(repeaterPath); 060 } 061 062 public IndexableRepeater getLocalRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 063 { 064 return (IndexableRepeater) super.getLocalRepeater(repeaterPath); 065 } 066 067 public IndexableRepeater getExternalRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException 068 { 069 return (IndexableRepeater) super.getExternalRepeater(repeaterPath); 070 } 071}