001// -------------------------------------------------------------------------------- 002// Copyright 2002-2024 Echo Three, LLC 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// -------------------------------------------------------------------------------- 016 017package com.echothree.control.user.search.server.command; 018 019import com.echothree.control.user.search.common.form.BaseCheckSpellingForm; 020import com.echothree.model.control.search.server.control.SearchControl; 021import com.echothree.model.control.search.server.logic.SearchLogic; 022import com.echothree.model.data.party.server.entity.Party; 023import com.echothree.model.data.search.server.entity.PartySearchTypePreference; 024import com.echothree.model.data.search.server.entity.PartySearchTypePreferenceDetail; 025import com.echothree.model.data.search.server.entity.SearchDefaultOperator; 026import com.echothree.model.data.search.server.entity.SearchType; 027import com.echothree.model.data.user.common.pk.UserVisitPK; 028import com.echothree.util.common.validation.FieldDefinition; 029import com.echothree.util.common.command.BaseResult; 030import com.echothree.util.server.control.BaseSimpleCommand; 031import com.echothree.util.server.control.CommandSecurityDefinition; 032import java.util.List; 033 034public abstract class BaseCheckSpellingCommand<F extends BaseCheckSpellingForm, R extends BaseResult> 035 extends BaseSimpleCommand<F> { 036 037 protected BaseCheckSpellingCommand(UserVisitPK userVisitPK, F form, CommandSecurityDefinition COMMAND_SECURITY_DEFINITION, 038 List<FieldDefinition> FORM_FIELD_DEFINITIONS, boolean allowLimits) { 039 super(userVisitPK, form, COMMAND_SECURITY_DEFINITION, FORM_FIELD_DEFINITIONS, allowLimits); 040 } 041 042 protected BaseCheckSpellingCommand(UserVisitPK userVisitPK, CommandSecurityDefinition COMMAND_SECURITY_DEFINITION, boolean allowLimits) { 043 super(userVisitPK, COMMAND_SECURITY_DEFINITION, allowLimits); 044 } 045 046 protected PartySearchTypePreference getPartySearchTypePreference(SearchControl searchControl, SearchType searchType) { 047 Party party = getParty(); 048 049 return party == null ? null : searchControl.getPartySearchTypePreference(party, searchType); 050 } 051 052 protected SearchDefaultOperator getDefaultSearchDefaultOperator(SearchLogic searchLogic, boolean rememberPreferences, 053 PartySearchTypePreferenceDetail partySearchTypePreferenceDetail) { 054 SearchDefaultOperator searchDefaultOperator = partySearchTypePreferenceDetail == null || rememberPreferences ? null 055 : partySearchTypePreferenceDetail.getSearchDefaultOperator(); 056 057 if(searchDefaultOperator == null) { 058 searchDefaultOperator = searchLogic.getDefaultSearchDefaultOperator(this); 059 } 060 061 return searchDefaultOperator; 062 } 063 064}