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.party.client.helper; 018 019import com.echothree.control.user.party.common.PartyUtil; 020import com.echothree.control.user.party.common.form.GetNameSuffixChoicesForm; 021import com.echothree.control.user.party.common.form.PartyFormFactory; 022import com.echothree.control.user.party.common.result.GetNameSuffixChoicesResult; 023import com.echothree.model.control.party.common.choice.NameSuffixChoicesBean; 024import com.echothree.model.data.user.common.pk.UserVisitPK; 025import com.echothree.util.common.command.CommandResult; 026import com.echothree.util.common.command.ExecutionResult; 027import javax.naming.NamingException; 028 029public class NameSuffixesHelper { 030 031 private NameSuffixesHelper() { 032 super(); 033 } 034 035 private static class NameSuffixesHelperHolder { 036 static NameSuffixesHelper instance = new NameSuffixesHelper(); 037 } 038 039 public static NameSuffixesHelper getInstance() { 040 return NameSuffixesHelperHolder.instance; 041 } 042 043 public NameSuffixChoicesBean getNameSuffixChoices(final UserVisitPK userVisitPK, final Boolean allowNullChoice) 044 throws NamingException { 045 NameSuffixChoicesBean nameSuffixChoices = null; 046 GetNameSuffixChoicesForm commandForm = PartyFormFactory.getGetNameSuffixChoicesForm(); 047 048 commandForm.setAllowNullChoice(allowNullChoice.toString()); 049 050 CommandResult commandResult = PartyUtil.getHome().getNameSuffixChoices(userVisitPK, commandForm); 051 if(!commandResult.hasErrors()) { 052 ExecutionResult executionResult = commandResult.getExecutionResult(); 053 GetNameSuffixChoicesResult result = (GetNameSuffixChoicesResult)executionResult.getResult(); 054 055 nameSuffixChoices = result.getNameSuffixChoices(); 056 } 057 058 return nameSuffixChoices; 059 } 060 061}