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.List; 019import java.util.Optional; 020 021import org.apache.solr.common.SolrInputDocument; 022 023import org.ametys.cms.data.holder.IndexableDataHolder; 024import org.ametys.cms.model.CMSDataContext; 025import org.ametys.cms.search.model.SystemPropertyExtensionPoint; 026import org.ametys.plugins.repository.AmetysObject; 027import org.ametys.plugins.repository.data.ametysobject.ModelAwareAmetysObject; 028import org.ametys.runtime.model.exception.BadItemTypeException; 029 030/** 031 * Model aware {@link AmetysObject} that can handle indexable data. 032 */ 033public interface IndexableAmetysObject extends ModelAwareAmetysObject, IndexableDataHolder 034{ 035 /** 036 * Retrieves the system properties extension point of this {@link AmetysObject}, or an empty {@link Optional} if this object does not support system properties 037 * @return the system properties extension point of this {@link AmetysObject} 038 */ 039 public default Optional<SystemPropertyExtensionPoint> getSystemPropertyExtensionPoint() 040 { 041 return Optional.empty(); 042 } 043 044 /** 045 * Indexes all data and properties of this {@link AmetysObject} 046 * @param document the solr document representing this {@link AmetysObject} 047 * @return additional solr documents that may have been created (ex: repeater entries) 048 * @throws BadItemTypeException if the saxed value's type does not matches the stored data 049 */ 050 public default List<SolrInputDocument> indexData(SolrInputDocument document) throws BadItemTypeException 051 { 052 return indexData(document, CMSDataContext.newInstance()); 053 } 054 055 /** 056 * Indexes all data and properties of this {@link AmetysObject} 057 * @param document the solr document representing this {@link AmetysObject} 058 * @param context The context of the data to index 059 * @return additional solr documents that may have been created (ex: repeater entries) 060 * @throws BadItemTypeException if the saxed value's type does not matches the stored data 061 */ 062 public List<SolrInputDocument> indexData(SolrInputDocument document, CMSDataContext context) throws BadItemTypeException; 063}