com.aimluck.eip.project.ProjectTaskSimpleSelectData.java Source code

Java tutorial

Introduction

Here is the source code for com.aimluck.eip.project.ProjectTaskSimpleSelectData.java

Source

/*
 * Aipo is a groupware program developed by Aimluck,Inc.
 * Copyright (C) 2004-2015 Aimluck,Inc.
 * http://www.aipo.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.aimluck.eip.project;

import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.jar.Attributes;

import org.apache.cayenne.exp.Expression;
import org.apache.cayenne.exp.ExpressionFactory;
import org.apache.commons.lang.StringUtils;
import org.apache.jetspeed.portal.portlets.VelocityPortlet;
import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
import org.apache.jetspeed.services.logging.JetspeedLogger;
import org.apache.turbine.util.RunData;
import org.apache.velocity.context.Context;

import com.aimluck.commons.field.ALDateTimeField;
import com.aimluck.eip.cayenne.om.portlet.EipTProjectMember;
import com.aimluck.eip.cayenne.om.portlet.EipTProjectTask;
import com.aimluck.eip.cayenne.om.portlet.EipTProjectTaskFile;
import com.aimluck.eip.common.ALAbstractMultiFilterSelectData;
import com.aimluck.eip.common.ALDBErrorException;
import com.aimluck.eip.common.ALData;
import com.aimluck.eip.common.ALEipConstants;
import com.aimluck.eip.common.ALEipHolidaysManager;
import com.aimluck.eip.common.ALEipUser;
import com.aimluck.eip.common.ALPageNotFoundException;
import com.aimluck.eip.modules.actions.common.ALAction;
import com.aimluck.eip.orm.Database;
import com.aimluck.eip.orm.query.ResultList;
import com.aimluck.eip.orm.query.SelectQuery;
import com.aimluck.eip.project.util.ProjectFile;
import com.aimluck.eip.project.util.ProjectUtils;
import com.aimluck.eip.util.ALEipUtils;

/**
 * ????? <BR>
 * 
 */
public class ProjectTaskSimpleSelectData extends ALAbstractMultiFilterSelectData<EipTProjectTask, EipTProjectTask>
        implements ALData {

    /** logger */
    private static final JetspeedLogger logger = JetspeedLogFactoryService
            .getLogger(ProjectTaskSimpleSelectData.class.getName());

    /** ?? */
    private int taskCount;

    /** ? */
    private List<ProjectResultData> allProject;

    /** ????ID */
    private Integer selectedProjectId;

    /** ? */
    private final ProjectFile<EipTProjectTaskFile, EipTProjectTask> pfile = new ProjectFile<EipTProjectTaskFile, EipTProjectTask>(
            EipTProjectTaskFile.class);

    /** ? */
    private List<ALEipUser> projectMembers;

    /** From */
    private ALDateTimeField base_date_from;

    /** To */
    private ALDateTimeField base_date_to;

    /**  */
    private String target_keyword;

    /**  */
    private String target_user_id;

    /**  */
    private String target_tracker;

    /**  */
    private String target_priority;

    /**  */
    private String target_status;

    /** ?FROM */
    private String target_progress_rate_from;

    /** ?TO */
    private String target_progress_rate_to;

    /** ?? */
    private String target_delay;

    /**  */
    private String progress_line_checked;

    /** ? */
    private int viewDateMaxYear;

    /**  */
    private final boolean indentFlg = true;

    private Calendar calFrom;

    private Calendar calTo;

    private boolean topView = false;

    private Integer loginUserId = null;

    /**
     * ?
     * 
     * @param action
     *          ALAction
     * @param rundata
     *          RunData
     * @param context
     *          Context
     */
    @Override
    public void init(ALAction action, RunData rundata, Context context)
            throws ALPageNotFoundException, ALDBErrorException {

        // ??
        String resetCondition = rundata.getParameters().get("reset_condition");
        if (resetCondition != null && resetCondition.length() > 0) {
            ALEipUtils.setTemp(rundata, context, "target_keyword", "");
            ALEipUtils.setTemp(rundata, context, LIST_SORT_STR, "");
            ALEipUtils.setTemp(rundata, context, LIST_SORT_TYPE_STR, "");
        }

        allProject = ProjectUtils.getAllProject(); // 
        setProject(rundata, context);

        super.init(action, rundata, context);

        // 
        Calendar cal = Calendar.getInstance();
        viewDateMaxYear = cal.get(Calendar.YEAR) + 10;

        // ?
        if (0 != selectedProjectId.intValue()) {
            projectMembers = ProjectUtils.getProjectMembers(selectedProjectId);
        } else {
            projectMembers = ALEipUtils.getUsers("LoginUser");
        }

        // (From,To)
        calFrom = ProjectUtils.getViewCalendar(rundata, context, "base_date_from");
        calTo = ProjectUtils.getViewCalendar(rundata, context, "base_date_to");
        calFrom.set(Calendar.DAY_OF_MONTH, 1);
        calTo.set(Calendar.DAY_OF_MONTH, calTo.getActualMaximum(Calendar.DATE));
        base_date_from = new ALDateTimeField();
        base_date_to = new ALDateTimeField();
        base_date_from.setValue(calFrom.getTime());
        base_date_to.setValue(calTo.getTime());
        // 
        progress_line_checked = ProjectUtils.getParameter(rundata, context, "progress_line_checked");

        loginUserId = ALEipUtils.getUserId(rundata);
    }

    /**
     * ???? <BR>
     * 
     * @param rundata
     *          RunData
     * @param context
     *          Context
     * @return ResultList
     */
    @Override
    protected ResultList<EipTProjectTask> selectList(RunData rundata, Context context) {
        try {
            if (null == selectedProjectId) {
                return null;
            }

            setSessionParams(rundata, context);
            SelectQuery<EipTProjectTask> query = getSelectQuery(rundata, context);
            buildSelectQueryForListView(query);
            buildSelectQueryForListViewSortOrder(query, rundata, context);
            // ??????
            ResultList<EipTProjectTask> list = query.getResultList();
            // ?
            taskCount = list.getTotalCount();
            return list;
        } catch (Exception ex) {
            logger.error("ProjectTaskSimpleSelectData", ex);
            return null;
        }
    }

    private void setSessionParams(RunData rundata, Context context) {
        // 
        target_keyword = ProjectUtils.getParameter(rundata, context, "target_keyword");
        // 
        target_user_id = ProjectUtils.getParameter(rundata, context, "target_user_id");
        // 
        target_tracker = ProjectUtils.getParameter(rundata, context, "target_tracker");
        // 
        target_priority = ProjectUtils.getParameter(rundata, context, "target_priority");
        // 
        target_status = ProjectUtils.getParameter(rundata, context, "target_status");
        // ?FROM
        target_progress_rate_from = ProjectUtils.getParameter(rundata, context, "target_progress_rate_from");
        // ?TO
        target_progress_rate_to = ProjectUtils.getParameter(rundata, context, "target_progress_rate_to");
        // ??
        target_delay = ProjectUtils.getParameter(rundata, context, "target_delay");

        /** for sql injection */
        {
            if (isRejectParameter(target_user_id)) {
                target_user_id = "0";
            }

            if (isRejectParameter(target_tracker)) {
                target_tracker = "0";
            }

            if (isRejectParameter(target_priority)) {
                target_priority = "0";
            }

            if (isRejectParameter(target_status)) {
                target_status = "0";
            }

            if (isRejectParameter(target_progress_rate_from)) {
                target_progress_rate_from = "0";
            }

            if (isRejectParameter(target_progress_rate_to)) {
                target_progress_rate_to = "0";
            }
        }
    }

    /**
     * ??? SelectQuery ??? <BR>
     * 
     * @param rundata
     * @param context
     * @return
     */

    private SelectQuery<EipTProjectTask> getSelectQuery(RunData rundata, Context context) {

        SelectQuery<EipTProjectTask> query = Database.query(EipTProjectTask.class);
        query.setQualifier(ExpressionFactory.matchExp(EipTProjectTask.PARENT_TASK_ID_PROPERTY, null));

        // 
        if (0 != selectedProjectId) {
            Expression ex1 = ExpressionFactory.matchExp(EipTProjectTask.PROJECT_ID_PROPERTY, selectedProjectId);
            query.andQualifier(ex1);
        }

        // 
        if (target_keyword != null && target_keyword.trim().length() > 0) {
            Expression ex1 = ExpressionFactory.likeExp(EipTProjectTask.TASK_NAME_PROPERTY,
                    "%" + target_keyword + "%");
            query.andQualifier(ex1);
        }

        // 
        if (StringUtils.isNotEmpty(target_user_id) && !target_user_id.equals("all")) {
            Expression exp2 = ExpressionFactory.matchExp(
                    EipTProjectTask.EIP_TPROJECT_TASK_MEMBER_PROPERTY + "." + EipTProjectMember.USER_ID_PROPERTY,
                    Integer.valueOf(target_user_id));
            query.andQualifier(exp2);
        }

        // 
        if (StringUtils.isNotEmpty(target_tracker) && !target_tracker.equals("all")) {
            Expression ex3 = ExpressionFactory.matchExp(EipTProjectTask.TRACKER_PROPERTY, target_tracker);
            query.andQualifier(ex3);
        }

        // 
        if (StringUtils.isNotEmpty(target_priority) && !target_priority.equals("all")) {
            Expression ex4 = ExpressionFactory.matchExp(EipTProjectTask.PRIORITY_PROPERTY, target_priority);
            query.andQualifier(ex4);
        }

        // 
        if (StringUtils.isNotEmpty(target_status) && !target_status.equals("all")) {
            Expression ex5 = ExpressionFactory.matchExp(EipTProjectTask.STATUS_PROPERTY, target_status);
            query.andQualifier(ex5);
        }

        // ?FROM
        if (StringUtils.isNotEmpty(target_progress_rate_from) && !target_progress_rate_from.equals("0")) {
            Expression ex6 = ExpressionFactory.greaterOrEqualExp(EipTProjectTask.PROGRESS_RATE_PROPERTY,
                    Integer.valueOf(target_progress_rate_from));
            query.andQualifier(ex6);
        }

        // ?TO
        if (StringUtils.isNotEmpty(target_progress_rate_to) && !target_progress_rate_to.equals("100")) {
            Expression ex7 = ExpressionFactory.lessOrEqualExp(EipTProjectTask.PROGRESS_RATE_PROPERTY,
                    Integer.valueOf(target_progress_rate_to));
            query.andQualifier(ex7);
        }

        // ??
        if (StringUtils.isNotEmpty(target_delay) && target_delay.equals(ProjectUtils.FLG_ON)) {
            /**
             * CURRENT_DATE in SQL depend on Database locale, so unify the time in
             * java
             */
            // @Todo fix

            StringBuilder sl = new StringBuilder();
            sl.append("(");
            sl.append("( CASE WHEN task.end_plan_date - task.start_plan_date + 1 < 0");
            sl.append("    THEN 0");
            sl.append("    ELSE task.end_plan_date - task.start_plan_date + 1");
            sl.append("  END)"); // 
            sl.append(" <> 0 ");
            sl.append(" AND ");
            sl.append("(");

            sl.append("    ( CASE");
            sl.append("    WHEN task.start_plan_date IS NULL OR task.end_plan_date IS NULL");
            sl.append("      THEN 0");
            sl.append("    WHEN ").append(ProjectUtils.getCurrentDateWithCast()).append(" < task.end_plan_date");
            sl.append("      THEN");
            sl.append("        CASE WHEN ").append(ProjectUtils.getCurrentDateWithCast())
                    .append(" - task.start_plan_date + 1 < 0");
            sl.append("          THEN 0");
            sl.append("          ELSE ").append(ProjectUtils.getCurrentDateWithCast())
                    .append(" - task.start_plan_date + 1");
            sl.append("        END");
            sl.append("      ELSE");
            sl.append("        task.end_plan_date - task.start_plan_date + 1");
            sl.append("  END )"); // ????
            sl.append("  * 100 / ");
            sl.append(" ( CASE WHEN task.end_plan_date - task.start_plan_date + 1 < 0");
            sl.append("    THEN 0");
            sl.append("    ELSE task.end_plan_date - task.start_plan_date + 1");
            sl.append("  END ) "); // 
            sl.append("   > progress_rate ");
            Expression exp = Expression.fromString(sl.toString());
            query.andQualifier(exp);
        }

        if (topView) {
            /** ?????????????? */
            Expression exp9 = ExpressionFactory.matchExp(
                    EipTProjectTask.EIP_TPROJECT_TASK_MEMBER_PROPERTY + "." + EipTProjectMember.USER_ID_PROPERTY,
                    Integer.valueOf(loginUserId));
            query.andQualifier(exp9);
            Expression exp10 = ExpressionFactory.inExp(EipTProjectTask.STATUS_PROPERTY,
                    ProjectUtils.incompleteStatus);
            query.andQualifier(exp10);
        }

        return query;
    }

    /**
     * ????
     * 
     * @param crt
     * @return
     */
    protected SelectQuery<EipTProjectTask> buildSelectQueryForListViewSortOrder(SelectQuery<EipTProjectTask> query,
            RunData rundata, Context context) {
        buildSelectQueryForListViewSort(query, rundata, context);

        String sort = ALEipUtils.getTemp(rundata, context, LIST_SORT_STR);
        String crt_key = null;

        Attributes map = getColumnMap();
        if (sort != null && sort.length() > 0) {
            crt_key = map.getValue(sort);
        }
        if (crt_key == null) {
            if (topView) {
                query.orderAscending(EipTProjectTask.END_PLAN_DATE_PROPERTY);
                query.orderAscending(EipTProjectTask.ORDER_NO_PROPERTY);
            } else {
                query.orderAscending(EipTProjectTask.ORDER_NO_PROPERTY);
            }
        }
        return query;
    }

    /**
     * ???? <BR>
     * 
     * @param rundata
     *          RunData
     * @param context
     *          Context
     * @return 
     */
    @Override
    protected EipTProjectTask selectDetail(RunData rundata, Context context) {
        // ?
        return ProjectUtils.getEipTProjectTask(rundata, context);
    }

    /**
     * ResultData???? <BR>
     * 
     * @param record
     *          
     * @return ResultData
     */
    @Override
    protected Object getResultData(EipTProjectTask record) {
        ProjectTaskResultData data = ProjectUtils.getProjectTaskResultData(record);
        Integer taskId = (int) data.getTaskId().getValue();

        // ?
        int cntChild = ProjectUtils.getCountChildrenTask(taskId);

        // ??2??true
        // ??
        data.setHasChildren(cntChild >= 2);

        // ?
        data.setHasChildrenForForm(cntChild > 0);

        // ?
        int lapsedDays = ProjectUtils.getLapsedDays(ProjectUtils.toString(record.getStartPlanDate()),
                ProjectUtils.toString(Calendar.getInstance().getTime()));
        // 
        int taskDays = ProjectUtils.getLapsedDays(ProjectUtils.toString(record.getStartPlanDate()),
                ProjectUtils.toString(record.getEndPlanDate()));
        data.setPlanTerm(taskDays);

        if (lapsedDays > taskDays) {
            // ???
            lapsedDays = taskDays;
        }

        // ?
        data.setPlanProgressRate(ProjectUtils.getPlanWorkload(lapsedDays, taskDays));

        // 
        List<ProjectTaskMemberResultData> memberList = data.getMemberList();
        BigDecimal workload = BigDecimal.valueOf(0);
        workload = workload.setScale(1);
        for (int i = 0; i < memberList.size(); i++) {
            ProjectTaskMemberResultData member = memberList.get(i);
            workload = workload.add(member.getWorkload());
        }
        data.setWorkload(workload);

        // 
        BigDecimal forecastWorkload = BigDecimal.valueOf(0);
        if (data.getProgressRate().getValue() != 0) {
            forecastWorkload = workload.multiply(BigDecimal.valueOf(100))
                    .divide(BigDecimal.valueOf(data.getProgressRate().getValue()), 2, BigDecimal.ROUND_HALF_UP);
        }
        data.setForecastWorkload(forecastWorkload);

        // 
        data.setIndentFlg(indentFlg);

        return data;
    }

    /**
     * ResultData???? <BR>
     * 
     * @param record
     *          
     * @return ResultData
     */
    @Override
    protected Object getResultDataDetail(EipTProjectTask record) {
        ProjectTaskResultData data = ProjectUtils.getProjectTaskResultData(record);
        int taskId = (int) data.getTaskId().getValue();
        // 
        List<EipTProjectTaskFile> list = pfile.getSelectQueryForFiles(EipTProjectTask.TASK_ID_PK_COLUMN, taskId)
                .fetchList();
        data.setAttachmentFiles(pfile.getFileList(list));
        // 
        data.setCommentList(ProjectUtils.getProjectTaskCommentList("" + taskId));
        // ???
        data.setTopicPath(ProjectUtils.getTaskTopicPath(record.getProjectId()));
        return data;
    }

    /**
     * ??
     * 
     * @return 
     */
    @Override
    protected Attributes getColumnMap() {
        Attributes map = new Attributes();
        map.putValue("task_name", "task_name");
        map.putValue("progress_rate", "progress_rate");
        return map;
    }

    /**
     * ????
     * 
     * @return ?
     */
    public int getTaskCount() {
        return taskCount;
    }

    /**
     * ??
     * 
     * @return ?
     */
    public List<ProjectResultData> getAllProject() {
        return allProject;
    }

    /**
     * ????ID??
     * 
     * @return ID
     */
    public Integer getSelectedProjectId() {
        return selectedProjectId;
    }

    /**
     * ?????
     * 
     * @return ?
     */
    public List<ALEipUser> getProjectMembers() {
        return projectMembers;
    }

    /**
     * ??????
     * 
     * @return 
     */
    public String getTargetKeyword() {
        return target_keyword;
    }

    /**
     * ??????
     * 
     * @return 
     */
    public String getTargetUserId() {
        return target_user_id;
    }

    /**
     * ??????
     * 
     * @return 
     */
    public String getTargetTracker() {
        return target_tracker;
    }

    /**
     * ??????
     * 
     * @return 
     */
    public String getTargetPriority() {
        return target_priority;
    }

    /**
     * ??????
     * 
     * @return 
     */
    public String getTargetStatus() {
        return target_status;
    }

    /**
     * ???FROM????
     * 
     * @return ?FROM
     */
    public String getTargetProgressRateFrom() {
        return target_progress_rate_from;
    }

    /**
     * ???TO????
     * 
     * @return ?TO
     */
    public String getTargetProgressRateTo() {
        return target_progress_rate_to;
    }

    /**
     * ????????
     * 
     * @return ??
     */
    public String getTargetDelay() {
        return target_delay;
    }

    /**
     * ????
     * 
     * @return 
     */
    public String getProgressLineChecked() {
        return progress_line_checked;
    }

    /**
     * ???
     * 
     * @return 
     */
    public int getViewDateMaxYear() {
        return viewDateMaxYear;
    }

    /**
     * From??
     * 
     * @return From
     */
    public ALDateTimeField getBaseDateFrom() {
        return base_date_from;
    }

    /**
     * To??
     * 
     * @return To
     */
    public ALDateTimeField getBaseDateTo() {
        return base_date_to;
    }

    /**
     * From???
     * 
     * @return From?
     */
    public int getBaseDateFromYear() {
        return calFrom.get(Calendar.YEAR);
    }

    /**
     * To???
     * 
     * @return To?
     */
    public int getBaseDateToYear() {
        return calTo.get(Calendar.YEAR);
    }

    /**
     * ????
     * 
     * @return ?
     */
    public int getDay(int days) {
        Calendar cal = (Calendar) calFrom.clone();
        cal.add(Calendar.DAY_OF_MONTH, days - 1);
        return cal.get(Calendar.DAY_OF_MONTH);
    }

    /**
     * ??????
     * 
     * @return TRUE:??
     */
    public boolean isToday(int days) {
        Calendar today = Calendar.getInstance();
        Calendar cal = (Calendar) calFrom.clone();
        cal.add(Calendar.DAY_OF_MONTH, days - 1);

        return today.get(Calendar.YEAR) == cal.get(Calendar.YEAR)
                && today.get(Calendar.MONTH) == cal.get(Calendar.MONTH)
                && today.get(Calendar.DAY_OF_MONTH) == cal.get(Calendar.DAY_OF_MONTH);
    }

    /**
     * ???
     * 
     * @return 
     */
    public int getDays() {
        return ProjectUtils.getLapsedDays(calFrom, calTo);
    }

    /**
     * ???
     * 
     * @return 
     */
    public int getDays(Date dateTo) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(dateTo);
        return ProjectUtils.getLapsedDays(calFrom, cal);
    }

    /**
     * ??
     * 
     * @return ?
     */
    public int getYear(int days) {
        Calendar cal = (Calendar) calFrom.clone();
        cal.add(Calendar.DAY_OF_MONTH, days - 1);
        return cal.get(Calendar.YEAR);
    }

    /**
     * ??
     * 
     * @return 
     */
    public int getMonth(int days) {
        Calendar cal = (Calendar) calFrom.clone();
        cal.add(Calendar.DAY_OF_MONTH, days - 1);
        return cal.get(Calendar.MONTH);
    }

    /**
     * ??
     * 
     * @return ?
     */
    public int getWeek(int days) {
        Calendar cal = (Calendar) calFrom.clone();
        cal.add(Calendar.DAY_OF_MONTH, days - 1);
        return cal.get(Calendar.WEEK_OF_YEAR);
    }

    /**
     * ???
     * 
     * @return 
     */
    public Map<String, String> getTrackerMap() {
        return ProjectUtils.getKubunMap("tracker");
    }

    /**
     * ???
     * 
     * @return 
     */
    public Map<String, String> getStatusMap() {
        return ProjectUtils.getKubunMap("status");
    }

    /**
     * ???
     * 
     * @return 
     */
    public Map<String, String> getPriorityMap() {
        return ProjectUtils.getKubunMap("priority");
    }

    /**
     * ?? long ???
     * 
     * @return ?? long 
     */
    public long getNowTime() {
        return Calendar.getInstance().getTimeInMillis();
    }

    /**
     * ??????
     * 
     * @return TRUE:??
     */

    public boolean isHoliday(int days) {
        Calendar cal = (Calendar) calFrom.clone();
        cal.add(Calendar.DAY_OF_MONTH, days - 1);

        // ??????
        ALEipHolidaysManager holidaysManager = ALEipHolidaysManager.getInstance();
        return holidaysManager.isHoliday(cal.getTime()) != null;
    }

    /**
     * ??????
     * 
     * @return TRUE:??
     */

    public boolean isSaturday(int days) {
        Calendar cal = (Calendar) calFrom.clone();
        cal.add(Calendar.DAY_OF_MONTH, days - 1);
        return Calendar.SATURDAY == cal.get(Calendar.DAY_OF_WEEK);
    }

    /**
     * ??????
     * 
     * @return TRUE:??
     */

    public boolean isSunday(int days) {
        Calendar cal = (Calendar) calFrom.clone();
        cal.add(Calendar.DAY_OF_MONTH, days - 1);
        return Calendar.SUNDAY == cal.get(Calendar.DAY_OF_WEEK);
    }

    /**
     * ??
     * 
     * @return 
     */
    public String getViewtype() {
        return "project";
    }

    private boolean isRejectParameter(String numeric) {
        return StringUtils.isNotEmpty(numeric) && !"all".equals(numeric) && !StringUtils.isNumeric(numeric);
    }

    public void setFiltersFromPSML(VelocityPortlet portlet, Context context, RunData rundata) {
        ALEipUtils.setTemp(rundata, context, LIST_FILTER_STR,
                portlet.getPortletConfig().getInitParameter("p12f-filters"));

        ALEipUtils.setTemp(rundata, context, LIST_FILTER_TYPE_STR,
                portlet.getPortletConfig().getInitParameter("p12g-filtertypes"));
    }

    public boolean isProjectEmpty() {
        return allProject.isEmpty();
    }

    public boolean isTaskEmpty() {
        return null == getList() || getList().isEmpty();
    }

    public void setProject(RunData rundata, Context context) {
        // validate projectId and reset projectId

        String filter = rundata.getParameters().getString("filter", "");
        String filterType = rundata.getParameters().getString("filtertype", "");
        String sesFilter = ALEipUtils.getTemp(rundata, context, LIST_FILTER_STR);
        String sesFilterType = ALEipUtils.getTemp(rundata, context, LIST_FILTER_TYPE_STR);

        sesFilter = sesFilter == null ? "" : sesFilter;
        sesFilterType = sesFilterType == null ? "" : sesFilterType;

        if (filterType.isEmpty()) {
            filter = sesFilter;
            filterType = sesFilterType;
        }

        if (StringUtils.isEmpty(filter) || StringUtils.isEmpty(filterType)) {
            selectedProjectId = 0;
            setFilter(rundata, context);
            return;
        }

        boolean existProject = false;
        for (ProjectResultData data : allProject) {
            if (filter.equals(data.getProjectId().toString())) {
                existProject = true;
                break;
            }
        }

        if (!existProject) {
            selectedProjectId = 0;
        } else {
            selectedProjectId = Integer.valueOf(filter);
        }
        setFilter(rundata, context);

    }

    private void setFilter(RunData rundata, Context context) {
        ALEipUtils.setTemp(rundata, context, LIST_FILTER_STR, String.valueOf(selectedProjectId));
        ALEipUtils.setTemp(rundata, context, LIST_FILTER_TYPE_STR, "project_id");

        ALEipUtils.setTemp(rundata, context, new StringBuffer().append(ProjectTaskSelectData.class.getName())
                .append(ALEipConstants.LIST_FILTER).toString(), String.valueOf(selectedProjectId));
        ALEipUtils.setTemp(rundata, context, new StringBuffer().append(ProjectTaskSelectData.class.getName())
                .append(ALEipConstants.LIST_FILTER_TYPE).toString(), "project_id");
    }

    public void setTopView(boolean bool) {
        this.topView = bool;
    }

}