List of usage examples for com.liferay.portal.kernel.util TextFormatter J
int J
To view the source code for com.liferay.portal.kernel.util TextFormatter J.
Click Source Link
From source file:com.fingence.slayer.service.impl.MyResultServiceImpl.java
License:Open Source License
public List<MyResult> getMyResults(String portfolioIds, int allocationBy) { List<MyResult> myResults = myResultFinder.findResults(portfolioIds); for (MyResult myResult : myResults) { String baseCurrency = myResult.getBaseCurrency(); if (!baseCurrency.equalsIgnoreCase("USD")) { double conversionFactor = CurrencyServiceUtil.getConversion(baseCurrency); myResult.setPurchasedMarketValue(myResult.getPurchasedMarketValue() * conversionFactor); myResult.setCurrentMarketValue(myResult.getCurrentMarketValue() * conversionFactor); myResult.setGain_loss(myResult.getGain_loss() * conversionFactor); }//w ww. j a v a 2 s . c o m long countryOfRisk = myResult.getCountryOfRisk(); if (countryOfRisk > 0l) { Country country = null; try { country = CountryServiceUtil.fetchCountry(countryOfRisk); } catch (SystemException e) { e.printStackTrace(); } if (Validator.isNotNull(country)) { myResult.setCountryOfRiskName(TextFormatter.format(country.getName(), TextFormatter.J)); } } else { myResult.setCountryOfRiskName(IConstants.UN_SPECIFIED); } if (Validator.isNull(myResult.getCurrency_())) { myResult.setCurrency_(IConstants.UN_SPECIFIED); } if (Validator.isNull(myResult.getIndustry_sector())) { myResult.setIndustry_sector(IConstants.UN_SPECIFIED); } if (allocationBy != IConstants.BREAKUP_BY_CURRENCY) { setCategoryFields(myResult, allocationBy); } } return myResults; }
From source file:com.liferay.exportimport.resources.importer.internal.util.ImporterFactory.java
License:Open Source License
protected void configureImporter(long companyId, Importer importer, ServletContext servletContext, PluginPackageProperties pluginPackageProperties) throws Exception { importer.setAppendVersion(pluginPackageProperties.isAppendVersion()); importer.setCompanyId(companyId);// ww w . ja va 2s . c om importer.setDeveloperModeEnabled(pluginPackageProperties.isDeveloperModeEnabled()); importer.setIndexAfterImport(pluginPackageProperties.indexAfterImport()); importer.setServletContext(servletContext); importer.setServletContextName(servletContext.getServletContextName()); importer.setTargetClassName(pluginPackageProperties.getTargetClassName()); String targetValue = pluginPackageProperties.getTargetValue(); if (Validator.isNull(targetValue)) { targetValue = TextFormatter.format(servletContext.getServletContextName(), TextFormatter.J); } importer.setTargetValue(targetValue); importer.setUpdateModeEnabled(pluginPackageProperties.isUpdateModeEnabled()); PluginPackage pluginPackage = DeployManagerUtil .getInstalledPluginPackage(servletContext.getServletContextName()); importer.setVersion(pluginPackage.getVersion()); importer.afterPropertiesSet(); }
From source file:com.liferay.portlet.expando.model.impl.ExpandoColumnImpl.java
License:Open Source License
public String getDisplayName(Locale locale) { String name = getName();/* w w w . j a v a 2s. c om*/ String displayName = LanguageUtil.get(locale, name); if (name.equals(displayName)) { displayName = TextFormatter.format(name, TextFormatter.J); } return displayName; }
From source file:com.liferay.resourcesimporter.messaging.HotDeployMessageListener.java
License:Open Source License
protected void doReceive(Message message) throws Exception { String command = message.getString("command"); if (!command.equals("deploy")) { return;//w ww . j av a2 s . co m } String servletContextName = message.getString("servletContextName"); ServletContext servletContext = ServletContextPool.get(servletContextName); URL resourcesDirURL = servletContext.getResource(_RESOURCES_DIR); if (resourcesDirURL == null) { return; } Properties pluginPackageProperties = getPluginPackageProperties(servletContext); String targetClassName = pluginPackageProperties.getProperty("resources-importer-target-class-name", LayoutSetPrototype.class.getName()); Set<String> resourcePaths = servletContext.getResourcePaths(_RESOURCES_DIR); URL privateLARURL = null; URL publicLARURL = servletContext.getResource(_RESOURCES_DIR.concat("archive.lar")); if (publicLARURL == null) { privateLARURL = servletContext.getResource(_RESOURCES_DIR.concat("private.lar")); publicLARURL = servletContext.getResource(_RESOURCES_DIR.concat("public.lar")); } List<Company> companies = CompanyLocalServiceUtil.getCompanies(); for (Company company : companies) { long companyId = CompanyThreadLocal.getCompanyId(); try { CompanyThreadLocal.setCompanyId(company.getCompanyId()); Importer importer = null; if ((privateLARURL != null) || (publicLARURL != null)) { LARImporter larImporter = getLARImporter(); URLConnection privateLARURLConnection = null; if (privateLARURL != null) { privateLARURLConnection = privateLARURL.openConnection(); larImporter.setPrivateLARInputStream(privateLARURLConnection.getInputStream()); } URLConnection publicLARURLConnection = null; if (publicLARURL != null) { publicLARURLConnection = publicLARURL.openConnection(); larImporter.setPublicLARInputStream(publicLARURLConnection.getInputStream()); } importer = larImporter; } else if ((resourcePaths != null) && !resourcePaths.isEmpty()) { importer = getResourceImporter(); importer.setResourcesDir(_RESOURCES_DIR); } else { String resourcesDir = pluginPackageProperties.getProperty("resources-importer-external-dir"); if (Validator.isNotNull(resourcesDir)) { importer = getFileSystemImporter(); importer.setResourcesDir(resourcesDir); } } if (importer == null) { throw new ImporterException("No valid importer found"); } importer.setCompanyId(company.getCompanyId()); importer.setServletContext(servletContext); importer.setServletContextName(servletContextName); importer.setTargetClassName(targetClassName); String targetValue = pluginPackageProperties.getProperty("resources-importer-target-value"); if (Validator.isNull(targetValue)) { targetValue = TextFormatter.format(servletContextName, TextFormatter.J); } importer.setTargetValue(targetValue); importer.afterPropertiesSet(); boolean developerModeEnabled = GetterUtil.getBoolean( pluginPackageProperties.getProperty("resources-importer-developer-mode-enabled")); if (!developerModeEnabled && importer.isExisting()) { if (_log.isInfoEnabled()) { _log.info("Group or layout set prototype already exists " + "for company " + company.getWebId()); } continue; } long startTime = 0; if (_log.isInfoEnabled()) { startTime = System.currentTimeMillis(); } importer.importResources(); if (_log.isInfoEnabled()) { long endTime = System.currentTimeMillis() - startTime; _log.info("Importing resources from " + servletContextName + " to group " + importer.getGroupId() + " takes " + endTime + " ms"); } Message newMessage = new Message(); newMessage.put("companyId", company.getCompanyId()); newMessage.put("servletContextName", servletContextName); newMessage.put("targetClassName", targetClassName); newMessage.put("targetClassPK", importer.getTargetClassPK()); if (message.getResponseId() != null) { Map<String, Object> responseMap = new HashMap<String, Object>(); responseMap.put("groupId", importer.getTargetClassPK()); newMessage.setPayload(responseMap); newMessage.setResponseId(message.getResponseId()); } MessageBusUtil.sendMessage("liferay/resources_importer", newMessage); } catch (ImporterException ie) { Message newMessage = new Message(); newMessage.put("companyId", company.getCompanyId()); newMessage.put("error", ie.getMessage()); newMessage.put("servletContextName", servletContextName); newMessage.put("targetClassName", targetClassName); newMessage.put("targetClassPK", 0); MessageBusUtil.sendMessage("liferay/resources_importer", newMessage); } finally { CompanyThreadLocal.setCompanyId(companyId); } } }
From source file:com.liferay.resourcesimporter.servlet.ResourcesImporterServletContextListener.java
License:Open Source License
protected void initialize(Message message) throws Exception { String servletContextName = message.getString("servletContextName"); ServletContext servletContext = ServletContextPool.get(servletContextName); URL url = servletContext.getResource(_RESOURCES_DIR); if (url == null) { return;/* ww w . jav a 2s .co m*/ } Properties pluginPackageProperties = getPluginPackageProperties(servletContext); String targetClassName = pluginPackageProperties.getProperty("resources-importer-target-class-name", LayoutSetPrototype.class.getName()); Set<String> resourcePaths = servletContext.getResourcePaths(_RESOURCES_DIR); URL privateLARURL = null; URL publicLARURL = servletContext.getResource(_RESOURCES_DIR.concat("archive.lar")); if (publicLARURL == null) { privateLARURL = servletContext.getResource(_RESOURCES_DIR.concat("private.lar")); publicLARURL = servletContext.getResource(_RESOURCES_DIR.concat("public.lar")); } List<Company> companies = CompanyLocalServiceUtil.getCompanies(); for (Company company : companies) { long companyId = CompanyThreadLocal.getCompanyId(); try { CompanyThreadLocal.setCompanyId(company.getCompanyId()); Importer importer = null; if ((privateLARURL != null) || (publicLARURL != null)) { LARImporter larImporter = getLARImporter(); URLConnection privateLARURLConnection = null; if (privateLARURL != null) { privateLARURLConnection = privateLARURL.openConnection(); larImporter.setPrivateLARInputStream(privateLARURLConnection.getInputStream()); } URLConnection publicLARURLConnection = null; if (publicLARURL != null) { publicLARURLConnection = publicLARURL.openConnection(); larImporter.setPublicLARInputStream(publicLARURLConnection.getInputStream()); } importer = larImporter; } else if ((resourcePaths != null) && !resourcePaths.isEmpty()) { importer = getResourceImporter(); importer.setResourcesDir(_RESOURCES_DIR); } else { String resourcesDir = pluginPackageProperties.getProperty("resources-importer-external-dir"); if (Validator.isNotNull(resourcesDir)) { importer = getFileSystemImporter(); importer.setResourcesDir(resourcesDir); } } if (importer == null) { throw new ImporterException("No valid importer found"); } importer.setCompanyId(company.getCompanyId()); importer.setServletContext(servletContext); importer.setServletContextName(servletContextName); importer.setTargetClassName(targetClassName); String targetValue = pluginPackageProperties.getProperty("resources-importer-target-value"); if (Validator.isNull(targetValue)) { targetValue = TextFormatter.format(servletContextName, TextFormatter.J); } importer.setTargetValue(targetValue); importer.afterPropertiesSet(); boolean developerModeEnabled = GetterUtil.getBoolean( pluginPackageProperties.getProperty("resources-importer-developer-mode-enabled")); if (!developerModeEnabled && importer.isExisting()) { if (_log.isInfoEnabled()) { _log.info("Group or layout set prototype already exists " + "for company " + company.getWebId()); } continue; } long startTime = 0; if (_log.isInfoEnabled()) { startTime = System.currentTimeMillis(); } importer.importResources(); if (_log.isInfoEnabled()) { long endTime = System.currentTimeMillis() - startTime; _log.info("Importing resources from " + servletContextName + " to group " + importer.getGroupId() + " takes " + endTime + " ms"); } Message newMessage = new Message(); newMessage.put("companyId", company.getCompanyId()); newMessage.put("servletContextName", servletContextName); newMessage.put("targetClassName", targetClassName); newMessage.put("targetClassPK", importer.getTargetClassPK()); if (message.getResponseId() != null) { Map<String, Object> responseMap = new HashMap<String, Object>(); responseMap.put("groupId", importer.getTargetClassPK()); newMessage.setPayload(responseMap); newMessage.setResponseId(message.getResponseId()); } MessageBusUtil.sendMessage("liferay/resources_importer", newMessage); } catch (ImporterException ie) { Message newMessage = new Message(); newMessage.put("companyId", company.getCompanyId()); newMessage.put("error", ie.getMessage()); newMessage.put("servletContextName", servletContextName); newMessage.put("targetClassName", targetClassName); newMessage.put("targetClassPK", 0); MessageBusUtil.sendMessage("liferay/resources_importer", newMessage); } finally { CompanyThreadLocal.setCompanyId(companyId); } } }
From source file:com.liferay.resourcesimporter.util.ImporterFactory.java
License:Open Source License
protected void configureImporter(long companyId, Importer importer, ServletContext servletContext, PluginPackageProperties pluginPackageProperties) throws Exception { importer.setAppendVersion(pluginPackageProperties.isAppendVersion()); importer.setCompanyId(companyId);/*from w w w.ja v a2 s. c o m*/ importer.setDeveloperModeEnabled(pluginPackageProperties.isDeveloperModeEnabled()); importer.setServletContext(servletContext); importer.setServletContextName(servletContext.getServletContextName()); importer.setTargetClassName(pluginPackageProperties.getTargetClassName()); String targetValue = pluginPackageProperties.getTargetValue(); if (Validator.isNull(targetValue)) { targetValue = TextFormatter.format(servletContext.getServletContextName(), TextFormatter.J); } importer.setTargetValue(targetValue); importer.setUpdateModeEnabled(pluginPackageProperties.isUpdateModeEnabled()); PluginPackage pluginPackage = DeployManagerUtil .getInstalledPluginPackage(servletContext.getServletContextName()); importer.setVersion(pluginPackage.getVersion()); importer.afterPropertiesSet(); }
From source file:com.liferay.tools.sourceformatter.BaseSourceProcessor.java
License:Open Source License
protected void checkEmptyCollection(String line, String fileName, int lineCount) { // LPS-46028/* w w w. j ava 2 s .com*/ Matcher matcher = emptyCollectionPattern.matcher(line); if (matcher.find()) { String collectionType = TextFormatter.format(matcher.group(1), TextFormatter.J); processErrorMessage(fileName, "Use Collections.empty" + collectionType + "(): " + fileName + " " + lineCount); } }