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.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.impl.DefaultModelAwareDataHolder; 023import org.ametys.plugins.repository.data.holder.DataHolder; 024import org.ametys.plugins.repository.data.holder.group.Composite; 025import org.ametys.plugins.repository.data.repositorydata.RepositoryData; 026import org.ametys.runtime.model.ModelItemGroup; 027 028/** 029 * Class for model aware composites 030 */ 031public class DefaultModelAwareComposite implements IndexableComposite 032{ 033 /** The repository data of the repeater entry */ 034 protected RepositoryData _repositoryData; 035 036 /** the default implementation of a {@link IndexableDataHolder} to use */ 037 protected IndexableDataHolder _defaultDataHolder; 038 039 /** the definition of this composite */ 040 protected ModelItemGroup _definition; 041 042 /** 043 * Creates a model aware composite 044 * @param repositoryData the repository data of the composite 045 * @param parent the parent of the created {@link Composite} 046 * @param root the root {@link DataHolder} 047 * @param definition the definition of the composite 048 */ 049 public DefaultModelAwareComposite(RepositoryData repositoryData, IndexableDataHolder parent, IndexableDataHolder root, ModelItemGroup definition) 050 { 051 _repositoryData = repositoryData; 052 _defaultDataHolder = new DefaultModelAwareDataHolder(repositoryData, Optional.of(parent), Optional.of(root), definition); 053 _definition = definition; 054 } 055 056 @Override 057 public RepositoryData getRepositoryData() 058 { 059 return _repositoryData; 060 } 061 062 @Override 063 public IndexableDataHolder getDefaultDataHolder() 064 { 065 return _defaultDataHolder; 066 } 067}