001/* 002 * Copyright 2015 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.search.systemprop; 017 018import org.ametys.cms.data.ametysobject.ModelAwareDataAwareAmetysObject; 019import org.ametys.cms.data.type.ModelItemTypeConstants; 020import org.ametys.cms.search.model.SystemProperty; 021import org.ametys.core.user.UserIdentity; 022 023/** 024 * Abstract class providing base functionality for a user-typed {@link SystemProperty}. 025 * @param <X> type of ametys object supported by this property 026 */ 027public abstract class AbstractUserSystemProperty<X extends ModelAwareDataAwareAmetysObject> extends AbstractSystemProperty<UserIdentity, X> 028{ 029 @Override 030 public String getRenderer() 031 { 032 return "Ametys.grid.GridColumnHelper.renderUser"; 033 } 034 035 /** 036 * Get the value as {@link UserIdentity} 037 * @param ametysObject the ametys object 038 * @return the user identity 039 */ 040 protected abstract UserIdentity _getUserIdentityValue(X ametysObject); 041 042 @Override 043 public Object getValue(X ametysObject) 044 { 045 return _getUserIdentityValue(ametysObject); 046 } 047 048 @Override 049 protected String getTypeId() 050 { 051 return ModelItemTypeConstants.USER_ELEMENT_TYPE_ID; 052 } 053}