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

Java tutorial

Introduction

Here is the source code for com.aimluck.eip.project.ProjectTaskFormData.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 static com.aimluck.eip.util.ALLocalizationUtils.*;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.cayenne.exp.ExpressionFactory;
import org.apache.commons.lang.StringUtils;
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.ALDateField;
import com.aimluck.commons.field.ALIllegalDateException;
import com.aimluck.commons.field.ALNumberField;
import com.aimluck.commons.field.ALStringField;
import com.aimluck.commons.utils.ALDateUtil;
import com.aimluck.eip.cayenne.om.portlet.EipTProject;
import com.aimluck.eip.cayenne.om.portlet.EipTProjectTask;
import com.aimluck.eip.cayenne.om.portlet.EipTProjectTaskFile;
import com.aimluck.eip.cayenne.om.portlet.EipTProjectTaskMember;
import com.aimluck.eip.cayenne.om.security.TurbineUser;
import com.aimluck.eip.common.ALAbstractFormData;
import com.aimluck.eip.common.ALDBErrorException;
import com.aimluck.eip.common.ALEipConstants;
import com.aimluck.eip.common.ALEipManager;
import com.aimluck.eip.common.ALEipPost;
import com.aimluck.eip.common.ALEipUser;
import com.aimluck.eip.common.ALPageNotFoundException;
import com.aimluck.eip.fileupload.beans.FileuploadBean;
import com.aimluck.eip.modules.actions.common.ALAction;
import com.aimluck.eip.orm.Database;
import com.aimluck.eip.orm.query.SelectQuery;
import com.aimluck.eip.project.util.ProjectFile;
import com.aimluck.eip.project.util.ProjectFormUtils;
import com.aimluck.eip.project.util.ProjectUtils;
import com.aimluck.eip.services.eventlog.ALEventlogConstants;
import com.aimluck.eip.services.eventlog.ALEventlogFactoryService;
import com.aimluck.eip.services.storage.ALStorageService;
import com.aimluck.eip.util.ALEipUtils;

/**
 *
 */
public class ProjectTaskFormData extends ALAbstractFormData {

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

    /**  */
    private ALStringField tracker;

    /** ?? */
    private ALStringField task_name;

    /**  */
    private ALStringField explanation;

    /**  */
    private ALStringField status;

    /**  */
    private ALStringField priority;

    /**  */
    private ALDateField start_plan_date;

    /**  */
    private ALDateField end_plan_date;

    /**  */
    private ALDateField start_date;

    /**  */
    private ALDateField end_date;

    /**  */
    private ALStringField start_plan_date_check;

    /**  */
    private ALStringField end_plan_date_check;

    /**  */
    private ALStringField start_date_check;

    /**  */
    private ALStringField end_date_check;

    /**  */
    private BigDecimal plan_workload;

    /**  */
    private String planWorkloadString;

    /** ? */
    private final DecimalFormat df = new DecimalFormat("#.0##");

    /** ? */
    private ALNumberField progress_rate;

    /** ID */
    private Integer projectId;

    /** ID */
    private Integer taskId;

    /**  */
    private EipTProject project;

    /**  */
    private ALEipUser loginUser;

    /** ID */
    private Integer parentTaskId;

    /** ??? */
    private boolean hasChildren;

    /**  */
    private List<ProjectTaskMemberResultData> taskMembers;

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

    /**  */
    private List<FileuploadBean> fileuploadList;

    /** ?? */
    private String folderName;

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

    private int uid;

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

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

        rundata.getUser().setTemp(ALEipConstants.MYGROUP, null);

        try {
            parentTaskId = Integer.valueOf(rundata.getParameters().getString("parent_task_id"));
        } catch (NumberFormatException e) {
            parentTaskId = null;
        }
        String _projectId = ALEipUtils.getParameter(rundata, context, "projectid");
        if (StringUtils.isNotEmpty(_projectId) && StringUtils.isNumeric(_projectId)) {
            projectId = Integer.valueOf((_projectId));
        } else {
            projectId = 0;
        }
        project = ProjectUtils.getEipTProject(projectId);
        loginUser = ALEipUtils.getALEipUser(rundata);
        folderName = rundata.getParameters().getString("folderName");
        uid = ALEipUtils.getUserId(rundata);
        projectMembers = ProjectUtils.getProjectMembers(projectId);
        allProject = ProjectUtils.getAllProject(); // 

        try {
            taskId = Integer.valueOf(ALEipUtils.getTemp(rundata, context, ALEipConstants.ENTITY_ID));
        } catch (NumberFormatException e) {
            taskId = null;
        }

        // ???
        hasChildren = (ProjectUtils.getCountChildrenTask(taskId) > 0);
    }

    /**
     * ?????
     */
    @Override
    public void initField() {
        // 
        tracker = new ALStringField();
        tracker.setFieldName(getl10n("PROJECT_CATEGORY"));
        tracker.setNotNull(true);
        // ??
        task_name = new ALStringField();
        task_name.setFieldName(getl10n("PROJECT_TASK_NAME"));
        task_name.setTrim(true);
        task_name.setNotNull(true);

        // 
        explanation = new ALStringField();
        explanation.setFieldName(getl10n("PROJECT_EXPLANATION"));
        explanation.setTrim(true);
        // 
        status = new ALStringField();
        status.setFieldName(getl10n("PROJECT_STATUS"));
        status.setNotNull(true);
        // 
        priority = new ALStringField();
        priority.setFieldName(getl10n("PROJECT_PRIORITY"));
        priority.setNotNull(true);
        // 
        start_plan_date = new ALDateField();
        start_plan_date.setFieldName(getl10n("PROJECT_START_PLAN_DATE"));
        start_plan_date.setValue(new Date());
        // 
        end_plan_date = new ALDateField();
        end_plan_date.setFieldName(getl10n("PROJECT_END_PLAN_DATE"));
        end_plan_date.setValue(new Date());
        // 
        start_date = new ALDateField();
        start_date.setFieldName(getl10n("PROJECT_START_DATE"));
        start_date.setValue(new Date());
        // 
        end_date = new ALDateField();
        end_date.setFieldName(getl10n("PROJECT_END_DATE"));
        end_date.setValue(new Date());
        // 
        start_plan_date_check = new ALStringField();
        start_plan_date_check.setFieldName(getl10n("PROJECT_NOT_SPECIFIED"));
        // 
        end_plan_date_check = new ALStringField();
        end_plan_date_check.setFieldName(getl10n("PROJECT_NOT_SPECIFIED"));
        // 
        start_date_check = new ALStringField();
        start_date_check.setFieldName(getl10n("PROJECT_NOT_SPECIFIED"));
        // 
        end_date_check = new ALStringField();
        end_date_check.setFieldName(getl10n("PROJECT_NOT_SPECIFIED"));
        // 
        plan_workload = null;
        // 
        planWorkloadString = null;
        // ?
        progress_rate = new ALNumberField();
        progress_rate.setFieldName(getl10n("PROJECT_PROGRESS_RATE"));
        progress_rate.setValue(0);
        progress_rate.limitMinValue(0);
        progress_rate.limitMaxValue(100);
        // ???
        hasChildren = false;
        // 
        taskMembers = new ArrayList<ProjectTaskMemberResultData>();
        // ?
        projectMembers = new ArrayList<ALEipUser>();
        // ??
        allProject = new ArrayList<ProjectResultData>();
        // 
        fileuploadList = new ArrayList<FileuploadBean>();
    }

    /**
     * ????????
     */
    @Override
    protected void setValidator() {
        // ??
        task_name.setNotNull(true);
        // ????
        task_name.limitMaxLength(50);
        // ???
        progress_rate.limitMaxValue(100);
        progress_rate.limitMinValue(0);

    }

    /**
     * ????
     * 
     * @param rundata
     *          RunData
     * @param context
     *          Context
     * @param msgList
     *          
     * @return TRUE ? FALSE 
     */
    @Override
    protected boolean setFormData(RunData rundata, Context context, List<String> msgList)
            throws ALPageNotFoundException, ALDBErrorException {
        boolean res = super.setFormData(rundata, context, msgList);
        try {
            if (res) {

                String members[] = rundata.getParameters().getStrings("task_member");
                String workload[] = rundata.getParameters().getStrings("workload");
                if (members != null) {
                    for (int i = 0; i < members.length; i++) {
                        if (members[i] == null || members[i].length() == 0) {
                            continue;
                        }

                        // 
                        ALEipUser user = ALEipUtils.getALEipUser(Integer.valueOf(members[i]));

                        // 
                        BigDecimal w = BigDecimal.valueOf(0);
                        try {
                            if (workload[i] != null && workload[i].length() > 0) {
                                w = new BigDecimal(workload[i]);
                            }

                            if (w.compareTo(BigDecimal.valueOf(0)) < 0) {
                                msgList.add(getl10n("PROJECT_VALIDATE_WORKLOAD"));
                            } else if (w.precision() - w.scale() > 5) {
                                msgList.add(getl10n("PROJECT_VALIDATE_WORKLOAD_RATIONAL_INTEGER"));
                            } else if (w.scale() > 3) {
                                msgList.add(getl10n("PROJECT_VALIDATE_WORKLOAD_DECIMAL"));
                            }
                        } catch (Exception e) {
                            msgList.add(getl10n("PROJECT_VALIDATE_WORKLOAD_INTEGER"));
                        }

                        ProjectTaskMemberResultData member = new ProjectTaskMemberResultData();
                        member.initField();
                        member.setUserId(user.getUserId().getValue());
                        member.setUserName(user.getAliasName().getValue());
                        member.setWorkload(w);

                        taskMembers.add(member);
                    }
                }

                planWorkloadString = rundata.getParameters().getString("plan_workload");

                // 
                fileuploadList = pfile.getFileuploadList(rundata);

                if (ALEipConstants.MODE_NEW_FORM.equals(getMode())) {
                    String nullStr = null;
                    start_date_check.setValue("TRUE");
                    start_date.setValue(nullStr);
                    end_date_check.setValue("TRUE");
                    end_date.setValue(nullStr);
                }
            }
        } catch (RuntimeException ex) {
            logger.error("RuntimeException", ex);
            res = false;
        } catch (Exception ex) {
            logger.error("Exception", ex);
            res = false;
        }
        return res;
    }

    /**
     * ????????
     * 
     * @param msgList
     *          
     * @return TRUE ? FALSE 
     */
    @Override
    protected boolean validate(List<String> msgList) {

        tracker.validate(msgList);
        task_name.validate(msgList);
        status.validate(msgList);
        priority.validate(msgList);
        progress_rate.validate(msgList);

        if (!hasChildren) {
            if (!taskMembers.isEmpty()) {
                // ??

                List<Long> checkMemberId = new ArrayList<Long>();
                for (Iterator<ProjectTaskMemberResultData> iter = taskMembers.iterator(); iter.hasNext();) {
                    ProjectTaskMemberResultData data = iter.next();
                    long id = data.getUserId().getValue();

                    if (checkMemberId.contains(id)) {
                        msgList.add(getl10n("PROJECT_VALIDATE_TASKMEMBER_DUPLICATE"));
                        break;
                    }

                    checkMemberId.add(id);
                }
            }

            // ??
            try {
                if (start_plan_date.getYear().length() > 0 && end_plan_date.getYear().length() > 0
                        && !ProjectUtils.isEmptyDate(start_plan_date.getValue().getDate())
                        && !ProjectUtils.isEmptyDate(end_plan_date.getValue().getDate())) {

                    Calendar start = Calendar.getInstance();
                    Calendar end = Calendar.getInstance();
                    start.setTime(start_plan_date.getValue().getDate());
                    end.setTime(end_plan_date.getValue().getDate());

                    if (start.compareTo(end) > 0) {
                        msgList.add(getl10n("PROJECT_VALIDATE_PLAN_START_DATE"));
                    }
                }
            } catch (NumberFormatException e1) {
                logger.error("ProjectTaskFormData.validate", e1);
            } catch (ALIllegalDateException e1) {
                logger.error("ProjectTaskFormData.validate", e1);
            }

            // ??
            try {
                if (start_date.getYear().length() > 0 && end_date.getYear().length() > 0
                        && !ProjectUtils.isEmptyDate(start_date.getValue().getDate())
                        && !ProjectUtils.isEmptyDate(end_date.getValue().getDate())) {

                    Calendar start = Calendar.getInstance();
                    Calendar end = Calendar.getInstance();
                    start.setTime(start_date.getValue().getDate());
                    end.setTime(end_date.getValue().getDate());

                    if (start.compareTo(end) > 0) {
                        msgList.add(getl10n("PROJECT_VALIDATE_START_DATE"));
                    }
                }
            } catch (NumberFormatException e1) {
                logger.error("ProjectTaskFormData.validate", e1);
            } catch (ALIllegalDateException e1) {
                logger.error("ProjectTaskFormData.validate", e1);
            }

            try {
                if (planWorkloadString.equals("")) {
                    plan_workload = new BigDecimal(0);
                } else {
                    plan_workload = new BigDecimal(planWorkloadString);
                }
                if (plan_workload.compareTo(BigDecimal.valueOf(0)) < 0) {
                    msgList.add(getl10n("PROJECT_VALIDATE_PLAN_WORKLOAD"));
                } else if (plan_workload.precision() - plan_workload.scale() > 5) {
                    msgList.add(getl10n("PROJECT_VALIDATE_PLAN_WORKLOAD_RATIONAL_INTEGER"));
                } else if (plan_workload.scale() > 3) {
                    msgList.add(getl10n("PROJECT_VALIDATE_PLAN_WORKLOAD_DECIMAL"));
                }
            } catch (Exception e) {
                msgList.add(getl10n("PROJECT_VALIDATE_PLAN_WORKLOAD_INTEGER"));
            }

        }

        boolean isProjectMember = false;
        if (!taskMembers.isEmpty()) {
            for (ProjectTaskMemberResultData data : taskMembers) {
                for (ALEipUser user : projectMembers) {
                    if (data.getUserId().toString().equals(user.getUserId().toString())) {
                        isProjectMember = true;
                        break;
                    }
                }
            }
        } else {
            isProjectMember = true;
        }

        // ????????
        if (!isProjectMember) {
            msgList.add(getl10n("PROJECT_VALIDATE_TASKMEMBER_NOT_EXIST"));
        }

        return msgList.isEmpty();
    }

    /**
     * ?????
     * 
     * @param rundata
     *          RunData
     * @param context
     *          Context
     * @param msgList
     *          
     * @return TRUE ? FALSE 
     */
    @Override
    protected boolean loadFormData(RunData rundata, Context context, List<String> msgList) {
        try {
            // ?
            EipTProjectTask task = ProjectUtils.getEipTProjectTask(rundata, context);
            if (task == null) {
                return false;
            }
            // 
            tracker.setValue(task.getTracker());
            // ??
            task_name.setValue(task.getTaskName());
            // 
            explanation.setValue(task.getExplanation());
            // 
            status.setValue(task.getStatus());
            // 
            priority.setValue(task.getPriority());
            // 
            String nullStr = null;
            if (ProjectUtils.isEmptyDate(task.getStartPlanDate())) {
                start_plan_date_check.setValue("TRUE");
                start_plan_date.setValue(nullStr);
            } else {
                start_plan_date.setValue(task.getStartPlanDate());
            }
            // 
            if (ProjectUtils.isEmptyDate(task.getEndPlanDate())) {
                end_plan_date_check.setValue("TRUE");
                end_plan_date.setValue(nullStr);
            } else {
                end_plan_date.setValue(task.getEndPlanDate());
            }
            // 
            if (ProjectUtils.isEmptyDate(task.getStartDate())) {
                start_date_check.setValue("TRUE");
                start_date.setValue(nullStr);
            } else {
                start_date_check.setValue("FALSE");
                start_date.setValue(task.getStartDate());
            }
            // 
            if (ProjectUtils.isEmptyDate(task.getEndDate())) {
                end_date_check.setValue("TRUE");
                end_date.setValue(nullStr);
            } else {
                end_date_check.setValue("FALSE");
                end_date.setValue(task.getEndDate());
            }
            // 
            plan_workload = new BigDecimal(df.format(task.getPlanWorkload()));
            // ?
            progress_rate.setValue(task.getProgressRate());

            // ?
            taskMembers = ProjectUtils.getProjectTaskMembers(String.valueOf(task.getTaskId()));

            // 
            List<EipTProjectTaskFile> files = pfile
                    .getSelectQueryForFiles(EipTProjectTask.TASK_ID_PK_COLUMN, task.getTaskId()).fetchList();
            fileuploadList = pfile.getFileList(files);

        } catch (Exception ex) {
            logger.error("Exception", ex);
            return false;
        }
        return true;
    }

    /**
     * ?????
     * 
     * @param rundata
     *          RunData
     * @param context
     *          Context
     * @param msgList
     *          
     * @return TRUE ? FALSE 
     */
    @Override
    protected boolean insertFormData(RunData rundata, Context context, List<String> msgList) {
        try {

            // ??
            TurbineUser tuser = Database.get(TurbineUser.class, loginUser.getUserId().getValueWithInt());

            // ?
            EipTProjectTask task = Database.create(EipTProjectTask.class);

            // ??
            setInsertUpdate(task);

            // ?
            task.setTurbineUser(tuser);

            // ?
            task.setCreateDate(Calendar.getInstance().getTime());

            if (parentTaskId != null) {
                // ID
                task.setParentTaskId(Integer.valueOf(parentTaskId));
            }

            // No?
            int orderNo = 1;
            SelectQuery<EipTProjectTask> query = Database.query(EipTProjectTask.class);
            query.andQualifier(ExpressionFactory.matchExp(EipTProjectTask.PARENT_TASK_ID_PROPERTY, parentTaskId));
            query.orderDesending(EipTProjectTask.ORDER_NO_PROPERTY);
            EipTProjectTask parentTask = query.fetchSingle();
            if (parentTask != null) {
                orderNo = parentTask.getOrderNo() + 1;
            }
            task.setOrderNo(orderNo);

            List<ProjectTaskMemberResultData> mailUserList = new ArrayList<ProjectTaskMemberResultData>();

            // 
            for (int i = 0; i < taskMembers.size(); i++) {
                ProjectTaskMemberResultData member = taskMembers.get(i);
                EipTProjectTaskMember data = new EipTProjectTaskMember();
                data.setEipTProjectTask(task);
                data.setUserId((int) member.getUserId().getValue());
                data.setWorkload(member.getWorkload());
                if (!tuser.getUserId().equals(member.getUserId().getValueWithInt())) {
                    mailUserList.add(member);
                }
            }

            if (mailUserList.size() > 0) {
                ProjectUtils.sendMailForTaskMembers(rundata, context, task, project, mailUserList);
            }

            // ?
            pfile.insertAttachmentFiles(fileuploadList, folderName, uid, task, msgList);

            // 
            Database.commit();

            // 
            ProjectFormUtils.updateProject(project.getProjectId(), loginUser.getUserId().getValueWithInt());

            // ??
            ALEventlogFactoryService.getInstance().getEventlogHandler().log(task.getTaskId(),
                    ALEventlogConstants.PORTLET_TYPE_PROJECT,
                    getl10nFormat("PROJECT_EVENTLOG_TASK_ADD", task.getTaskName()));

        } catch (Exception ex) {
            Database.rollback();
            logger.error("Exception", ex);
            return false;
        }
        return true;
    }

    /**
     * ????
     * 
     * @param task
     *          
     * @param msgList
     *          
     * @return TRUE:? FALSE:
     * @throws Exception
     *           
     */
    private boolean setInsertUpdate(EipTProjectTask task) {

        // ID
        task.setEipTProject(project);
        // 
        task.setTracker(tracker.getValue());
        // ??
        task.setTaskName(task_name.getValue());
        // 
        task.setExplanation(explanation.getValue());
        // 
        task.setStatus(status.getValue());
        // 
        task.setPriority(priority.getValue());

        if (!hasChildren) {
            // ????????

            // 
            task.setStartPlanDate(getInputDate(start_plan_date_check, start_plan_date));
            // 
            task.setEndPlanDate(getInputDate(end_plan_date_check, end_plan_date));
            // 
            task.setStartDate(getInputDate(start_date_check, start_date));
            // 
            task.setEndDate(getInputDate(end_date_check, end_date));
            // 
            task.setPlanWorkload(plan_workload);
            // ?
            task.setProgressRate((int) progress_rate.getValue());
        }
        // 
        task.setUpdateUserId(loginUser.getUserId().getValueWithInt());
        // 
        task.setUpdateDate(Calendar.getInstance().getTime());

        return true;
    }

    /**
     * ???
     * 
     * @param check
     *          ?
     * @param date
     *          
     * @return 
     */
    private Date getInputDate(ALStringField check, ALDateField date) {
        try {
            if (check.getValue() == null) {
                return date.getValue().getDate();
            } else {
                return ProjectUtils.getEmptyDate();
            }
        } catch (Exception e) {
            return ProjectUtils.getEmptyDate();
        }
    }

    /**
     * ???
     * 
     * @param rundata
     *          RunData
     * @param context
     *          Context
     * @param msgList
     *          
     * @return TRUE ? FALSE 
     */
    @Override
    protected boolean updateFormData(RunData rundata, Context context, List<String> msgList) {
        try {
            // ?
            EipTProjectTask task = ProjectUtils.getEipTProjectTask(rundata, context);
            if (task == null) {
                return false;
            }

            // ??
            setInsertUpdate(task);

            if (!hasChildren) {
                // ????????

                // 
                ProjectUtils.removeProjectTaskMember(task);

                List<ProjectTaskMemberResultData> mailUserList = new ArrayList<ProjectTaskMemberResultData>();

                // 
                List<ProjectTaskMemberResultData> oldMenber = ProjectUtils
                        .getProjectTaskMembers(task.getTaskId().toString());
                List<Integer> oldMemberIdList = new ArrayList<Integer>();
                for (ProjectTaskMemberResultData rd : oldMenber) {
                    oldMemberIdList.add(rd.getUserId().getValueWithInt());
                }
                TurbineUser tuser = Database.get(TurbineUser.class, loginUser.getUserId().getValueWithInt());

                for (int i = 0; i < taskMembers.size(); i++) {
                    ProjectTaskMemberResultData member = taskMembers.get(i);
                    EipTProjectTaskMember data = Database.create(EipTProjectTaskMember.class);
                    data.setEipTProjectTask(task);
                    data.setUserId((int) member.getUserId().getValue());
                    data.setWorkload(member.getWorkload());
                    if (!oldMemberIdList.contains(member.getUserId().getValueWithInt())
                            && !tuser.getUserId().equals(member.getUserId().getValueWithInt())) {
                        mailUserList.add(member);
                    }
                }

                if (mailUserList.size() > 0) {
                    ProjectUtils.sendMailForTaskMembers(rundata, context, task, project, mailUserList);
                }
            }

            // ????ID
            List<Integer> attIdList = pfile.getRequestedHasFileIdList(fileuploadList);
            // ??????????
            List<EipTProjectTaskFile> files = pfile
                    .getSelectQueryForFiles(EipTProjectTask.TASK_ID_PK_COLUMN, task.getTaskId()).fetchList();
            if (files != null) {
                for (int i = 0; i < files.size(); i++) {
                    EipTProjectTaskFile file = files.get(i);
                    if (!attIdList.contains(file.getFileId())) {
                        // ?
                        ALStorageService.deleteFile(ProjectFile.getSaveDirPath(uid) + file.getFilePath());

                        // DB?
                        Database.delete(file);

                    }
                }
            }

            // ?
            pfile.insertAttachmentFiles(fileuploadList, folderName, uid, task, msgList);

            // 
            Database.commit();

            // 
            ProjectFormUtils.updateProject(project.getProjectId(), loginUser.getUserId().getValueWithInt());

            // ??
            ALEventlogFactoryService.getInstance().getEventlogHandler().log(task.getTaskId(),
                    ALEventlogConstants.PORTLET_TYPE_PROJECT,
                    getl10nFormat("PROJECT_EVENTLOG_TASK_UPDATE", task.getTaskName()));

        } catch (Exception ex) {
            Database.rollback();
            logger.error("Exception", ex);
            return false;
        }
        return true;
    }

    /**
     * ????
     * 
     * @param rundata
     *          RunData
     * @param context
     *          Context
     * @param msgList
     *          
     * @return TRUE ? FALSE 
     */
    @Override
    protected boolean deleteFormData(RunData rundata, Context context, List<String> msgList) {
        try {
            // ?
            EipTProjectTask task = ProjectUtils.getEipTProjectTask(rundata, context);
            if (task == null) {
                return false;
            }

            if (hasChildren) {
                msgList.add(getl10n("PROJECT_VALIDATE_HAS_CHILD"));
                return false;
            }

            // ?????
            ProjectUtils.removeProjectTaskMember(task);

            // ?????
            ProjectUtils.removeProjectTaskComment(rundata, task);

            // ?????
            pfile.removeFile(rundata, EipTProjectTaskFile.EIP_TPROJECT_TASK_PROPERTY, task.getTaskId());

            // 
            Database.delete(task);
            Database.commit();

            // ??
            ALEventlogFactoryService.getInstance().getEventlogHandler().log(task.getTaskId(),
                    ALEventlogConstants.PORTLET_TYPE_PROJECT,
                    getl10nFormat("PROJECT_EVENTLOG_TASK_DELETE", task.getTaskName()));

        } catch (Exception ex) {
            Database.rollback();
            logger.error("Exception", ex);
            return false;
        }
        return true;
    }

    /**
     * ????
     * 
     * @return 
     */
    public ALStringField getTracker() {
        return tracker;
    }

    /**
     * ??????
     * 
     * @return ??
     */
    public ALStringField getTaskName() {
        return task_name;
    }

    /**
     * ????
     * 
     * @return 
     */
    public ALStringField getExplanation() {
        return explanation;
    }

    /**
     * ????
     * 
     * @return 
     */
    public ALStringField getStatus() {
        return status;
    }

    /**
     * ????
     * 
     * @return 
     */
    public ALStringField getPriority() {
        return priority;
    }

    /**
     * ????
     * 
     * @return 
     */
    public ALDateField getStartPlanDate() {
        return start_plan_date;
    }

    /**
     * ????
     * 
     * @return 
     */
    public ALDateField getEndPlanDate() {
        return end_plan_date;
    }

    /**
     * ????
     * 
     * @return 
     */
    public ALDateField getStartDate() {
        return start_date;
    }

    /**
     * ????
     * 
     * @return 
     */
    public ALDateField getEndDate() {
        return end_date;
    }

    /**
     * ?????
     * 
     * @return 
     */
    public String getStartPlanDateString() {
        try {
            return ALDateUtil.format(start_plan_date.getValue().getDate(), ProjectUtils.DISP_DATE_FORMAT);
        } catch (Exception e) {
            return "";
        }
    }

    /**
     * ?????
     * 
     * @return 
     */
    public String getEndPlanDateString() {
        try {
            return ALDateUtil.format(end_plan_date.getValue().getDate(), ProjectUtils.DISP_DATE_FORMAT);
        } catch (Exception e) {
            return "";
        }
    }

    /**
     * ?????
     * 
     * @return 
     */
    public String getStartDateString() {
        try {
            return ALDateUtil.format(start_date.getValue().getDate(), ProjectUtils.DISP_DATE_FORMAT);
        } catch (Exception e) {
            return "";
        }
    }

    /**
     * ?????
     * 
     * @return 
     */
    public String getEndDateString() {
        try {
            return ALDateUtil.format(end_date.getValue().getDate(), ProjectUtils.DISP_DATE_FORMAT);
        } catch (Exception e) {
            return "";
        }
    }

    /**
     * ???? <BR>
     * 
     * @return
     */
    public ALStringField getStartPlanDateCheck() {
        return start_plan_date_check;
    }

    /**
     * ???? <BR>
     * 
     * @return
     */
    public ALStringField getEndPlanDateCheck() {
        return end_plan_date_check;
    }

    /**
     * ???? <BR>
     * 
     * @return
     */
    public ALStringField getStartDateCheck() {
        return start_date_check;
    }

    /**
     * ???? <BR>
     * 
     * @return
     */
    public ALStringField getEndDateCheck() {
        return end_date_check;
    }

    /**
     * ????
     * 
     * @return 
     */
    public BigDecimal getPlanWorkload() {
        return plan_workload;
    }

    /**
     * ????
     * 
     * @return 
     */
    public String getPlanWorkloadString() {
        if (plan_workload == null) {
            return "";
        }
        return plan_workload.toString();
    }

    /**
     * ?????
     * 
     * @return ?
     */
    public ALNumberField getProgressRate() {
        return progress_rate;
    }

    /**
     * ??
     * 
     * @return 
     */
    public Map<Integer, ALEipPost> getPostMap() {
        return ALEipManager.getInstance().getPostMap();
    }

    /**
     * ID???
     * 
     * @return ID
     */
    public int getLoginUserId() {
        return loginUser.getUserId().getValueWithInt();
    }

    /**
     * ID????
     * 
     * @return ID
     */
    public Integer getParentTaskId() {
        return parentTaskId;
    }

    /**
     * ???????
     * 
     * @return ???
     */
    public boolean getHasChildren() {
        return hasChildren;
    }

    /**
     * id????
     * 
     * @return ID
     */
    public Integer getProjectId() {
        return projectId;
    }

    /**
     * ???
     * 
     * @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");
    }

    /**
     * ???
     * 
     * @return 
     */
    public List<ProjectTaskMemberResultData> getTaskMembers() {
        return taskMembers;
    }

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

    /**
     * ???
     * 
     * @return 
     */
    public List<FileuploadBean> getAttachmentFileNameList() {
        return fileuploadList;
    }

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

    public boolean isProjectExists() {
        return allProject != null && allProject.size() > 0;
    }
}