List of usage examples for com.liferay.portal.kernel.service CountryServiceUtil fetchCountryByA2
public static com.liferay.portal.kernel.model.Country fetchCountryByA2(String a2)
From source file:com.bemis.portal.migration.customer.service.impl.CustomerMigrationLocalServiceImpl.java
License:Open Source License
protected Organization addOrganizationFromCustomer(long userId, CustomerOrg aCustomerOrgParent, long setPrototypeId, long parentOrganizationId) { String organizationType = OrganizationConstants.TYPE_ORGANIZATION; long statusId = ListTypeConstants.ORGANIZATION_STATUS_DEFAULT; long countryId = CountryServiceUtil.fetchCountryByA2(aCustomerOrgParent.getCountry()).getCountryId(); long regionId = RegionServiceUtil.fetchRegion(countryId, aCustomerOrgParent.getState()).getRegionId(); String bemisCustomerId = aCustomerOrgParent.getBemisCustomerId(); String bemisParentOrg = aCustomerOrgParent.getBemisParentId(); Organization anOrganization = null;//from w ww. j a v a2 s. co m String name = ""; // @TODO Custom fields need to be finalized from the customer profile // Only parent organizations get the default and the short name if (parentOrganizationId == OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID) { name = aCustomerOrgParent.getCustomerName(); organizationType = PARENT_LOCATION_TYPE; } else { name = aCustomerOrgParent.getCustomerName() + " - " + aCustomerOrgParent.getCity(); organizationType = CUSTOMER_LOCATION_TYPE; } try { anOrganization = _organizationLocalService.getOrganization(_bemisPortalService.getDefaultCompanyId(), name); if (_log.isDebugEnabled()) { _log.debug(">>> Organization with id [" + anOrganization.getOrganizationId() + "] already exists"); } } catch (NoSuchOrganizationException nsoe) { // If we are a new organization, let us add it. try { // Create an organization with a site anOrganization = addOrganization(userId, parentOrganizationId, name, organizationType, regionId, countryId, statusId, null, true, null, bemisCustomerId, bemisParentOrg); // Now we map the site to the customer template Group organizationGroup = anOrganization.getGroup(); SitesUtil.updateLayoutSetPrototypesLinks(organizationGroup, 0, setPrototypeId, true, true); _log.debug(">>> Created an Organization with id [" + anOrganization.getOrganizationId() + "]"); } catch (Exception pe) { _log.error(pe); } } catch (PortalException pe) { _log.error(">>> Error creating Organization for Customer [" + name + "]", pe); } return anOrganization; }