001/* 002 * Copyright 2019 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.web.frontoffice.search.metamodel.impl; 017 018import java.util.Collection; 019 020import org.ametys.cms.repository.Content; 021import org.ametys.web.frontoffice.search.metamodel.AdditionalParameterValueMap; 022import org.ametys.web.frontoffice.search.metamodel.Returnable; 023import org.ametys.web.frontoffice.search.metamodel.ReturnableSaxer; 024 025/** 026 * {@link Returnable} for {@link Content}s 027 */ 028public class ContentReturnable extends AbstractContentBasedReturnable 029{ 030 /** Avalon Role */ 031 public static final String ROLE = ContentReturnable.class.getName(); 032 033 /** The additional parameter for the view */ 034 public static final String PARAMETER_VIEW = "contentView"; 035 036 /** The prefix for the ids of facets and sorts */ 037 protected static final String __PREFIX_ID = "ContentReturnable$"; 038 039 @Override 040 protected String associatedContentSearchableRole() 041 { 042 return ContentSearchable.ROLE; 043 } 044 045 @Override 046 public String getId() 047 { 048 return ROLE; 049 } 050 051 @Override 052 protected Collection<String> getContentTypes(AdditionalParameterValueMap additionalParameterValues) 053 { 054 return additionalParameterValues.getValue(ContentSearchable.PARAMETER_CONTENT_TYPES); 055 } 056 057 @Override 058 public ReturnableSaxer getSaxer(Collection<Returnable> allReturnables, AdditionalParameterValueMap additionalParameterValues) 059 { 060 return new ContentSaxer(this, getViewForSax(additionalParameterValues), _contentTypesHelper, getContentTypes(additionalParameterValues)); 061 } 062 063 /** 064 * Gets the view for saxing 065 * @param additionalParameterValues The additional parameter values 066 * @return the view for saxing 067 */ 068 protected String getViewForSax(AdditionalParameterValueMap additionalParameterValues) 069 { 070 return additionalParameterValues.getValue(PARAMETER_VIEW); 071 } 072 073 @Override 074 protected String getDefinitionPrefix() 075 { 076 return __PREFIX_ID; 077 } 078}