001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.model.Country;
020    import com.liferay.portal.model.ListType;
021    import com.liferay.portal.model.Region;
022    import com.liferay.portal.service.CountryServiceUtil;
023    import com.liferay.portal.service.ListTypeServiceUtil;
024    import com.liferay.portal.service.RegionServiceUtil;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class AddressImpl extends AddressBaseImpl {
030    
031            public AddressImpl() {
032            }
033    
034            public Country getCountry() {
035                    Country country = null;
036    
037                    try {
038                            country = CountryServiceUtil.getCountry(getCountryId());
039                    }
040                    catch (Exception e) {
041                            country = new CountryImpl();
042    
043                            _log.warn(e);
044                    }
045    
046                    return country;
047            }
048    
049            public Region getRegion() {
050                    Region region = null;
051    
052                    try {
053                            region = RegionServiceUtil.getRegion(getRegionId());
054                    }
055                    catch (Exception e) {
056                            region = new RegionImpl();
057    
058                            _log.warn(e);
059                    }
060    
061                    return region;
062            }
063    
064            public ListType getType() {
065                    ListType type = null;
066    
067                    try {
068                            type = ListTypeServiceUtil.getListType(getTypeId());
069                    }
070                    catch (Exception e) {
071                            type = new ListTypeImpl();
072    
073                            _log.warn(e);
074                    }
075    
076                    return type;
077            }
078    
079            private static Log _log = LogFactoryUtil.getLog(AddressImpl.class);
080    
081    }