List of usage examples for com.liferay.portal.kernel.backgroundtask BackgroundTaskStatus setAttribute
public void setAttribute(String key, Serializable value)
From source file:ca.efendi.datafeeds.web.util.MyBackgroundTaskStatusMessageTranslator.java
License:Apache License
/** * @see BackgroundTaskStatusMessageTranslator#translate(BackgroundTaskStatus, * Message)/*from w w w .j ava 2 s .co m*/ */ @Override public void translate(final BackgroundTaskStatus backgroundTaskStatus, final Message message) { backgroundTaskStatus.setAttribute("xy", doTranslate(message.getString("xy"))); }
From source file:com.liferay.adaptive.media.web.internal.background.task.OptimizeImagesBackgroundTaskStatusMessageTranslator.java
License:Open Source License
@Override public void translate(BackgroundTaskStatus backgroundTaskStatus, Message message) { String phase = message.getString(OptimizeImagesBackgroundTaskConstants.PHASE); if (Validator.isNotNull(phase)) { setPhaseAttributes(backgroundTaskStatus, message); return;/*from ww w . j a v a2s. c o m*/ } String className = message.getString(OptimizeImagesBackgroundTaskConstants.CLASS_NAME); backgroundTaskStatus.setAttribute(OptimizeImagesBackgroundTaskConstants.CLASS_NAME, className); long count = message.getLong(OptimizeImagesBackgroundTaskConstants.COUNT); backgroundTaskStatus.setAttribute(OptimizeImagesBackgroundTaskConstants.COUNT, count); long total = message.getLong(OptimizeImagesBackgroundTaskConstants.TOTAL); backgroundTaskStatus.setAttribute(OptimizeImagesBackgroundTaskConstants.TOTAL, total); int percentage = 100; if ((count != 0) && (total != 0)) { percentage = (int) (count / total); } backgroundTaskStatus.setAttribute("percentage", percentage); }
From source file:com.liferay.adaptive.media.web.internal.background.task.OptimizeImagesBackgroundTaskStatusMessageTranslator.java
License:Open Source License
protected void setPhaseAttributes(BackgroundTaskStatus backgroundTaskStatus, Message message) { backgroundTaskStatus.setAttribute(ReindexBackgroundTaskConstants.COMPANY_ID, message.getLong(ReindexBackgroundTaskConstants.COMPANY_ID)); backgroundTaskStatus.setAttribute(ReindexBackgroundTaskConstants.PHASE, message.getString(ReindexBackgroundTaskConstants.PHASE)); }
From source file:com.liferay.exportimport.internal.background.task.DefaultExportImportBackgroundTaskStatusMessageTranslator.java
License:Open Source License
protected void clearBackgroundTaskStatus(BackgroundTaskStatus backgroundTaskStatus) { backgroundTaskStatus.clearAttributes(); backgroundTaskStatus.setAttribute("allModelAdditionCountersTotal", 0L); backgroundTaskStatus.setAttribute("allPortletAdditionCounter", 0L); backgroundTaskStatus.setAttribute("allPortletModelAdditionCounters", new HashMap<String, LongWrapper>()); backgroundTaskStatus.setAttribute("currentModelAdditionCountersTotal", 0L); backgroundTaskStatus.setAttribute("currentPortletAdditionCounter", 0L); backgroundTaskStatus.setAttribute("currentPortletModelAdditionCounters", new HashMap<String, LongWrapper>()); }
From source file:com.liferay.exportimport.internal.background.task.DefaultExportImportBackgroundTaskStatusMessageTranslator.java
License:Open Source License
protected synchronized void translateLayoutMessage(BackgroundTaskStatus backgroundTaskStatus, Message message) { Map<String, LongWrapper> modelAdditionCounters = (Map<String, LongWrapper>) message .get("modelAdditionCounters"); backgroundTaskStatus.setAttribute("allModelAdditionCountersTotal", getTotal(modelAdditionCounters)); long allPortletAdditionCounter = 0; String[] portletIds = (String[]) message.get("portletIds"); if (portletIds != null) { allPortletAdditionCounter = portletIds.length; }/*from w ww . j a va2 s. co m*/ backgroundTaskStatus.setAttribute("allPortletAdditionCounter", allPortletAdditionCounter); }
From source file:com.liferay.exportimport.internal.background.task.DefaultExportImportBackgroundTaskStatusMessageTranslator.java
License:Open Source License
protected synchronized void translatePortletMessage(BackgroundTaskStatus backgroundTaskStatus, Message message) {/*from w ww. j a v a 2 s. c o m*/ String portletId = message.getString("portletId"); HashMap<String, Long> allPortletModelAdditionCounters = (HashMap<String, Long>) backgroundTaskStatus .getAttribute("allPortletModelAdditionCounters"); long portletModelAdditionCountersTotal = GetterUtil .getLong(message.get("portletModelAdditionCountersTotal")); allPortletModelAdditionCounters.put(portletId, portletModelAdditionCountersTotal); backgroundTaskStatus.setAttribute("allPortletModelAdditionCounters", allPortletModelAdditionCounters); long allPortletAdditionCounter = GetterUtil .getLong(backgroundTaskStatus.getAttribute("allPortletAdditionCounter")); long currentPortletAdditionCounter = GetterUtil .getLong(backgroundTaskStatus.getAttribute("currentPortletAdditionCounter")); if (currentPortletAdditionCounter < allPortletAdditionCounter) { backgroundTaskStatus.setAttribute("currentPortletAdditionCounter", ++currentPortletAdditionCounter); } HashMap<String, Long> currentPortletModelAdditionCounters = (HashMap<String, Long>) backgroundTaskStatus .getAttribute("currentPortletModelAdditionCounters"); currentPortletModelAdditionCounters.put(portletId, 0L); backgroundTaskStatus.setAttribute("currentPortletModelAdditionCounters", currentPortletModelAdditionCounters); backgroundTaskStatus.setAttribute("portletId", portletId); backgroundTaskStatus.setAttribute("stagedModelName", StringPool.BLANK); backgroundTaskStatus.setAttribute("stagedModelType", StringPool.BLANK); backgroundTaskStatus.setAttribute("uuid", StringPool.BLANK); }
From source file:com.liferay.exportimport.internal.background.task.DefaultExportImportBackgroundTaskStatusMessageTranslator.java
License:Open Source License
protected synchronized void translateStagedModelMessage(BackgroundTaskStatus backgroundTaskStatus, Message message) {/*w w w. j a va2s. c o m*/ String portletId = (String) backgroundTaskStatus.getAttribute("portletId"); if (Validator.isNull(portletId)) { return; } long allModelAdditionCountersTotal = GetterUtil .getLong(backgroundTaskStatus.getAttribute("allModelAdditionCountersTotal")); long currentModelAdditionCountersTotal = GetterUtil .getLong(backgroundTaskStatus.getAttribute("currentModelAdditionCountersTotal")); Map<String, Long> allPortletModelAdditionCounters = (HashMap<String, Long>) backgroundTaskStatus .getAttribute("allPortletModelAdditionCounters"); long allPortletModelAdditionCounter = MapUtil.getLong(allPortletModelAdditionCounters, portletId); HashMap<String, Long> currentPortletModelAdditionCounters = (HashMap<String, Long>) backgroundTaskStatus .getAttribute("currentPortletModelAdditionCounters"); long currentPortletModelAdditionCounter = MapUtil.getLong(currentPortletModelAdditionCounters, portletId); if ((allModelAdditionCountersTotal > currentModelAdditionCountersTotal) && (allPortletModelAdditionCounter > currentPortletModelAdditionCounter)) { backgroundTaskStatus.setAttribute("currentModelAdditionCountersTotal", ++currentModelAdditionCountersTotal); currentPortletModelAdditionCounters.put(portletId, ++currentPortletModelAdditionCounter); backgroundTaskStatus.setAttribute("currentPortletModelAdditionCounters", currentPortletModelAdditionCounters); } backgroundTaskStatus.setAttribute("stagedModelName", message.getString("stagedModelName")); backgroundTaskStatus.setAttribute("stagedModelType", message.getString("stagedModelType")); backgroundTaskStatus.setAttribute("uuid", message.getString("uuid")); }
From source file:com.liferay.exportimport.internal.background.task.LayoutStagingBackgroundTaskStatusMessageTranslator.java
License:Open Source License
@Override protected synchronized void translateLayoutMessage(BackgroundTaskStatus backgroundTaskStatus, Message message) { String phase = GetterUtil.getString(backgroundTaskStatus.getAttribute("phase")); if (Validator.isNull(phase)) { clearBackgroundTaskStatus(backgroundTaskStatus); phase = Constants.EXPORT;//from ww w . j a v a 2 s . c o m } else { phase = Constants.IMPORT; } backgroundTaskStatus.setAttribute("phase", phase); super.translateLayoutMessage(backgroundTaskStatus, message); if (phase.equals(Constants.IMPORT)) { backgroundTaskStatus.setAttribute("allModelAdditionCountersTotal", getAllModelAdditionCountersTotal(backgroundTaskStatus)); backgroundTaskStatus.setAttribute("allPortletAdditionCounter", getAllPortletAdditionCounter(backgroundTaskStatus)); backgroundTaskStatus.setAttribute("allPortletModelAdditionCounters", new HashMap<String, LongWrapper>()); backgroundTaskStatus.setAttribute("currentPortletModelAdditionCounters", new HashMap<String, LongWrapper>()); } }
From source file:com.liferay.exportimport.internal.background.task.PortletExportImportBackgroundTaskStatusMessageTranslator.java
License:Open Source License
@Override protected synchronized void translatePortletMessage(BackgroundTaskStatus backgroundTaskStatus, Message message) {//w w w .j a va 2s . c o m clearBackgroundTaskStatus(backgroundTaskStatus); long portletModelAdditionCountersTotal = GetterUtil .getLong(message.get("portletModelAdditionCountersTotal")); backgroundTaskStatus.setAttribute("allModelAdditionCountersTotal", portletModelAdditionCountersTotal); super.translatePortletMessage(backgroundTaskStatus, message); }
From source file:com.liferay.exportimport.internal.background.task.PortletStagingBackgroundTaskStatusMessageTranslator.java
License:Open Source License
@Override protected synchronized void translatePortletMessage(BackgroundTaskStatus backgroundTaskStatus, Message message) {//www . j a v a 2 s . co m String phase = GetterUtil.getString(backgroundTaskStatus.getAttribute("phase")); if (Validator.isNull(phase)) { clearBackgroundTaskStatus(backgroundTaskStatus); phase = Constants.EXPORT; } else { phase = Constants.IMPORT; } backgroundTaskStatus.setAttribute("phase", phase); if (phase.equals(Constants.EXPORT)) { long portletModelAdditionCountersTotal = GetterUtil .getLong(message.get("portletModelAdditionCountersTotal")); backgroundTaskStatus.setAttribute("allModelAdditionCountersTotal", portletModelAdditionCountersTotal); } else { backgroundTaskStatus.setAttribute("allModelAdditionCountersTotal", getAllModelAdditionCountersTotal(backgroundTaskStatus)); backgroundTaskStatus.setAttribute("allPortletModelAdditionCounters", new HashMap<String, LongWrapper>()); backgroundTaskStatus.setAttribute("currentPortletModelAdditionCounters", new HashMap<String, LongWrapper>()); } super.translatePortletMessage(backgroundTaskStatus, message); }