Skip to content

Instantly share code, notes, and snippets.

@ryanschuhler
Created September 29, 2014 18:06
Show Gist options
  • Select an option

  • Save ryanschuhler/d1694f00290e8466572e to your computer and use it in GitHub Desktop.

Select an option

Save ryanschuhler/d1694f00290e8466572e to your computer and use it in GitHub Desktop.
## Get Country from Locale
#set ($country_from_locale = "")
#if ($locale == "de_DE")
#set ($country_from_locale = "germany")
#elseif ($locale == "en_GB")
#set ($country_from_locale = "united-kingdom")
#elseif ($locale == "es_ES")
#set ($country_from_locale = "spain")
#elseif ($locale == "fr_FR")
#set ($country_from_locale = "france")
#elseif ($locale == "it_IT")
#set ($country_from_locale = "italy")
#elseif ($locale == "jp_JA")
#set ($country_from_locale = "japan")
#elseif ($locale == "pt_BR")
#set ($country_from_locale = "brazil")
#elseif ($locale == "zh_CN")
#set ($country_from_locale = "china")
#end
## Get Country from IP Address
#set ($ip_geocoder_util = $portal.getClass().forName("com.liferay.ipgeocoder.util.IPGeocoderUtil"))
## pulling the IP address that we put in the request
#set ($ip_info = $ip_geocoder_util.getIPInfo($request.attributes.OSB_REMOTE_ADDRESS))
#set ($country_from_ip = "")
#if ($ip_info)
#set ($country_from_ip = $ip_info.getCountryName())
#end
## Get Country, Industry, and Persona from Login Info
#set ($company_role = "")
#set ($country_from_login = "")
#set ($department = "")
#set ($industry_from_login = "")
#set ($persona_from_login = "")
#if ($request.attributes.USER_ID)
#set ($user_id = $getterUtil.getLong($request.attributes.USER_ID))
#set ($expando_column_local_service_util = $portal.getClass().forName('com.liferay.portlet.expando.service.ExpandoColumnLocalServiceUtil'))
#set ($expando_table_local_service_util = $portal.getClass().forName('com.liferay.portlet.expando.service.ExpandoTableLocalServiceUtil'))
#set ($expando_value_local_service_util = $portal.getClass().forName('com.liferay.portlet.expando.service.ExpandoValueLocalServiceUtil'))
#set ($class_name_id = $portalUtil.getClassNameId("com.liferay.portal.model.User"))
#set ($expando_table = $expando_table_local_service_util.getDefaultTable($companyId, $class_name_id))
## Get company role from expando table
#set ($company_role_expando_column = $expando_column_local_service_util.getColumn($expando_table.getTableId(), "osbCompanyRole"))
#set ($company_role_expando_value = $expando_value_local_service_util.getValue($expando_table.getTableId(), $company_role_expando_column.getColumnId(), $user_id))
#if ($company_role_expando_value)
#set ($company_role = $company_role_expando_value.getData())
#end
## Get country from expando table
#set ($country_expando_column = $expando_column_local_service_util.getColumn($expando_table.getTableId(), "osbCountry"))
#set ($country_expando_value = $expando_value_local_service_util.getValue($expando_table.getTableId(), $country_expando_column.getColumnId(), $user_id))
#if ($country_expando_value)
#set ($country_from_login = $country_expando_value.getData())
#end
## Get department from expando table
#set ($department_expando_column = $expando_column_local_service_util.getColumn($expando_table.getTableId(), "osbDepartment"))
#set ($department_expando_value = $expando_value_local_service_util.getValue($expando_table.getTableId(), $department_expando_column.getColumnId(), $user_id))
#if ($department_expando_value)
#set ($department = $department_expando_value.getData())
#end
## Get industry from expando table
#set ($industry_expando_column = $expando_column_local_service_util.getColumn($expando_table.getTableId(), "osbIndustry"))
#set ($industry_expando_value = $expando_value_local_service_util.getValue($expando_table.getTableId(), $industry_expando_column.getColumnId(), $user_id))
#if ($industry_expando_value)
#set ($industry_from_login = $industry_expando_value.getData())
#end
## Define personas
#set ($COMPANY_ROLES_DECISION_MAKER = ["C-Level/Executive/VP", "Director/Manager"])
#set ($COMPANY_ROLES_END_USER = ["Administrator", "Associate/Analyst", "Developer/Engineer", "Independent Contractor", "Project Manager"])
#set ($DEPARTMENTS_BUSINESS = ["finance", "hr", "legal-procurement", "marketing", "operations", "sales"])
#set ($DEPARTMENTS_TECHNICAL = ["development-engineering", "it-support"])
## Set persona
#if ($DEPARTMENTS_BUSINESS.contains($department) && $COMPANY_ROLES_DECISION_MAKER.contains($company_role))
#set ($persona_from_login = "Business Decision Maker")
#elseif ($DEPARTMENTS_BUSINESS.contains($department) && $COMPANY_ROLES_END_USER.contains($company_role))
#set ($persona_from_login = "Business End User")
#elseif ($DEPARTMENTS_TECHNICAL.contains($department) && $COMPANY_ROLES_DECISION_MAKER.contains($company_role))
#set ($persona_from_login = "Technical Decision Maker")
#elseif ($DEPARTMENTS_TECHNICAL.contains($department) && $COMPANY_ROLES_END_USER.contains($company_role))
#set ($persona_from_login = "Technical End User")
#end
#end
## Get Country and Persona from Hubspot
#set ($portlet_bean_locator = $portal.getClass().forName('com.liferay.portal.kernel.bean.PortletBeanLocatorUtil'))
#set ($hs_contact_local_service = $portlet_bean_locator.locate("hubspot-portlet", "com.liferay.hubspot.service.HSContactLocalService.velocity"))
#set ($hsutk = $request.attributes.OSB_HUBSPOT_UTK)
#set ($hs_contact = $hs_contact_local_service.fetchHSContactByUserToken($hsutk))
#set ($hs_contact_object = $hs_contact.getHSContactJSONObject())
#set ($country_from_hubspot = "")
#if ($hs_contact.getSFLeadCountry())
#set ($country_from_hubspot = $hs_contact.getSFLeadCountry())
#end
#set ($industry_from_hubspot = "")
#if ($hs_contact_object && $hs_contact_object.getJSONObject("hs_industry"))
#set ($industry_from_hubspot = $hs_contact_object.getJSONObject("hs_industry").getString("value"))
#end
#set ($persona_from_hubspot = "")
#if ($hs_contact_object && $hs_contact_object.getJSONObject("hs_persona"))
#set ($persona_from_hubspot = $hs_contact_object.getJSONObject("hs_persona").getString("value"))
#end
## Set Target Country, Industry, and Persona with info available
#set ($target_country = "")
#if ($country_from_hubspot != "")
#set ($target_country = $country_from_hubspot)
#elseif ($country_from_login != "")
#set ($target_country = $country_from_login)
#elseif ($country_from_ip != "")
#set ($target_country = $country_from_ip)
#elseif ($country_from_locale != "")
#set ($target_country = $country_from_locale)
#end
#set ($target_country = $stringUtil.replace($target_country, " ", "-").toLowerCase())
#set ($target_industry = "")
#if ($industry_from_hubspot != "")
#set ($target_industry = $industry_from_hubspot)
#elseif ($industry_from_login != "")
#set ($target_industry = $industry_from_login)
#end
#set ($target_industry = $stringUtil.replace($target_industry, " ", "-").toLowerCase())
#set ($target_industry = "")
#if ($persona_from_hubspot != "")
#set ($target_persona = $persona_from_hubspot)
#elseif ($persona_from_login != "")
#set ($target_persona = $persona_from_login)
#end
#set ($target_persona = $stringUtil.replace($target_persona, " ", "-").toLowerCase())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment