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