[507] | 1 | package gov.hhs.fha.nhinc.util;
|
---|
| 2 |
|
---|
| 3 |
|
---|
| 4 |
|
---|
| 5 | import org.apache.commons.logging.Log;
|
---|
| 6 | import org.apache.commons.logging.LogFactory;
|
---|
| 7 | import gov.hhs.fha.nhinc.connectmgr.ConnectionManagerCache;
|
---|
| 8 | import gov.hhs.fha.nhinc.connectmgr.data.CMBusinessEntity;
|
---|
| 9 |
|
---|
| 10 | /**
|
---|
| 11 | * This class is used to map a home community ID to the
|
---|
| 12 | * textual name of the home community. The information
|
---|
| 13 | * is stored in a properties file so that it can be tweaked
|
---|
| 14 | * and changed without having to recompile...
|
---|
| 15 | *
|
---|
| 16 | * @author Les Westberg
|
---|
| 17 | */
|
---|
| 18 | public class HomeCommunityMap
|
---|
| 19 | {
|
---|
| 20 | private static Log log = LogFactory.getLog(HomeCommunityMap.class);
|
---|
| 21 |
|
---|
| 22 | /**
|
---|
| 23 | * This method retrieves the name of the home community baased on the
|
---|
| 24 | * home community Id.
|
---|
| 25 | *
|
---|
| 26 | * @param sHomeCommunityId The home community ID to be looked up.
|
---|
| 27 | * @return The textual name of the home community.
|
---|
| 28 | */
|
---|
| 29 | public String getHomeCommunityName(String sHomeCommunityId)
|
---|
| 30 | {
|
---|
| 31 | String sHomeCommunityName = "";
|
---|
| 32 |
|
---|
| 33 | try
|
---|
| 34 | {
|
---|
| 35 | CMBusinessEntity oEntity = ConnectionManagerCache.getBusinessEntity(sHomeCommunityId);
|
---|
| 36 | if ((oEntity != null) &&
|
---|
| 37 | (oEntity.getNames() != null) &&
|
---|
| 38 | (oEntity.getNames().getBusinessName() != null) &&
|
---|
| 39 | (oEntity.getNames().getBusinessName().size() > 0) &&
|
---|
| 40 | (oEntity.getNames().getBusinessName().get(0) != null) &&
|
---|
| 41 | (oEntity.getNames().getBusinessName().get(0).length() > 0))
|
---|
| 42 | {
|
---|
| 43 | sHomeCommunityName = oEntity.getNames().getBusinessName().get(0);
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 | catch (Exception e)
|
---|
| 47 | {
|
---|
| 48 | log.warn("Failed to retrieve textual name for home community ID: " + sHomeCommunityId, e);
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | return sHomeCommunityName;
|
---|
| 52 | }
|
---|
| 53 | }
|
---|