List of usage examples for com.liferay.portal.kernel.backgroundtask BackgroundTaskStatus getAttribute
public Serializable getAttribute(String key)
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 va 2s . 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) {//from www.ja v a2 s . c om 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
protected long getAllModelAdditionCountersTotal(BackgroundTaskStatus backgroundTaskStatus) { long allModelAdditionCountersTotal = GetterUtil .getLong(backgroundTaskStatus.getAttribute("allModelAdditionCountersTotal")); long currentModelAdditionCountersTotal = GetterUtil .getLong(backgroundTaskStatus.getAttribute("currentModelAdditionCountersTotal")); return allModelAdditionCountersTotal + currentModelAdditionCountersTotal; }
From source file:com.liferay.exportimport.internal.background.task.LayoutStagingBackgroundTaskStatusMessageTranslator.java
License:Open Source License
protected long getAllPortletAdditionCounter(BackgroundTaskStatus backgroundTaskStatus) { long allPortletAdditionCounter = GetterUtil .getLong(backgroundTaskStatus.getAttribute("allPortletAdditionCounter")); long currentPortletAdditionCounter = GetterUtil .getLong(backgroundTaskStatus.getAttribute("currentPortletAdditionCounter")); return allPortletAdditionCounter + currentPortletAdditionCounter; }
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 w ww .j a va 2 s . com*/ } 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.PortletStagingBackgroundTaskStatusMessageTranslator.java
License:Open Source License
@Override protected synchronized void translatePortletMessage(BackgroundTaskStatus backgroundTaskStatus, Message message) {//from www .j a v a2s. c o 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); }