@@ -0,0 +1,3319 @@
+package org.xcolab.portlets.admintasks;%0A%0Aimport java.io.Serializable;%0Aimport java.util.HashMap;%0Aimport java.util.HashSet;%0Aimport java.util.Map;%0Aimport java.util.Set;%0A%0Aimport com.ext.portlet.model.Contest;%0Aimport com.ext.portlet.model.PlanFan;%0Aimport com.ext.portlet.model.PlanItem;%0Aimport com.ext.portlet.service.ContestPhaseLocalServiceUtil;%0Aimport com.ext.portlet.service.PlanItemLocalServiceUtil;%0Aimport com.liferay.portal.kernel.exception.PortalException;%0Aimport com.liferay.portal.kernel.exception.SystemException;%0Aimport com.liferay.portal.kernel.log.Log;%0Aimport com.liferay.portal.kernel.log.LogFactoryUtil;%0Aimport com.liferay.portal.kernel.messaging.Message;%0Aimport com.liferay.portal.kernel.messaging.MessageListener;%0Aimport com.liferay.portal.kernel.messaging.MessageListenerException;%0A%0Apublic class SyncProposalSupportersBetweenPhasesTask implements MessageListener, Serializable %7B%0A    /**%0A%09 * %0A%09 */%0A%09private static final long serialVersionUID = 1L;%0A%09private Log _log = LogFactoryUtil.getLog(SyncProposalSupportersBetweenPhasesTask.class);%0A%09private static Boolean working = new Boolean(false);%0A%0A    public void receive(Message message) throws MessageListenerException %7B%0A        if (working) return;%0A        synchronized(working) %7B%0A            try %7B%0A                syncSupporters();%0A            %7D catch (SystemException e) %7B%0A                _log.error(e);%0A                e.printStackTrace();%0A            %7D catch (PortalException e) %7B%0A                _log.error(e);%0A            %7D%0A            %0A        %7D%0A        %0A    %7D%0A%0A    %0A    public String syncSupporters() throws SystemException, PortalException %7B%0A        _log.info(%22Syncing supporters%22);%0A        %0A        Map%3CString, Set%3CLong%3E%3E plansToMap = new HashMap%3CString, Set%3CLong%3E%3E();%0A        %0A        _log.info(%22fetching plans and their fans%22);%0A        for (PlanItem plan: PlanItemLocalServiceUtil.getPlans()) %7B%0A            Contest contest = PlanItemLocalServiceUtil.getContest(plan);%0A            %0A            String key = contest.getContestPK() + %22_%22 + PlanItemLocalServiceUtil.getName(plan).trim(); %0A            %0A            Set%3CLong%3E plans = plansToMap.get(key);%0A            if (plans == null) %7B%0A                plans = new HashSet%3CLong%3E();%0A                plansToMap.put(key, plans);%0A            %7D%0A            plans.add(plan.getPlanId());%0A        %7D%0A        _log.info(%22merging fans%22);%0A        for (String key: plansToMap.keySet()) %7B%0A            Set%3CLong%3E planIds = plansToMap.get(key);%0A            if (planIds.size() %3E 1) %7B%0A                Set%3CLong%3E fanIds = new HashSet%3CLong%3E();%0A                %0A                for (Long planId: planIds) %7B%0A                    PlanItem plan = PlanItemLocalServiceUtil.getPlan(planId);%0A                    %0A                    for (PlanFan fan: PlanItemLocalServiceUtil.getFans(plan)) %7B%0A                        fanIds.add(fan.getUserId());%0A                    %7D%0A                %7D%0A                for (Long fanId: fanIds) %7B%0A                    for (Long planId: planIds) %7B%0A                        PlanItem plan = PlanItemLocalServiceUtil.getPlan(planId);%0A                        PlanItemLocalServiceUtil.addFan(plan, fanId);%0A                    %7D%0A                %7D%0A            //System.out.println(key + %22%5Ct%22 + plansToMap.get(key));%0A            %7D%0A        %0A        %7D%0A        %0A        %0A        %0A        return null;%0A    %7D%0A    %0A%7D%0A

synchronize proposal supporters - missing file