Changeset 20523

Show
Ignore:
Timestamp:
03/04/10 08:18:56 (5 months ago)
Author:
nilesh
Message:

changes for adding three working time fields "Hours Per Day", "Hours Per Week", "Days Per Month" for removing hard coded values in schedule calculation.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/core/src/net/project/schedule/Schedule.java

    r20514 r20523  
    269269    private boolean isShared = false; 
    270270    private boolean editingWarning = true; 
    271     private boolean unAssignedWorkcapture = true; 
     271    private boolean unAssignedWorkcapture = false; 
     272    private BigDecimal hoursPerDay; 
     273    private BigDecimal hoursPerWeek; 
     274    private BigDecimal daysPerMonth; 
     275    private String resourceCalendar; 
    272276 
    273277    /** 
     
    317321        editingWarning = true; 
    318322        unAssignedWorkcapture = true; 
     323        hoursPerDay = BigDecimal.valueOf(8);  
     324        hoursPerWeek = BigDecimal.valueOf(40); 
     325        daysPerMonth = BigDecimal.valueOf(20); 
     326        resourceCalendar = SchedulePropertiesHelper.PERSONAL_RESOURCE_CALENDAR; 
     327 
    319328    } 
    320329 
     
    15351544        } 
    15361545 
    1537         db.prepareCall("{call SCHEDULE.STORE_PLAN(?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?)}"); 
     1546        db.prepareCall("{call SCHEDULE.STORE_PLAN(?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?)}"); 
    15381547 
    15391548        int index = 0; 
     
    15581567        db.cstmt.setBoolean(++index, editingWarning); 
    15591568        db.cstmt.setBoolean(++index, unAssignedWorkcapture); 
     1569        db.cstmt.setBigDecimal(++index, hoursPerDay); 
     1570        db.cstmt.setBigDecimal(++index, hoursPerWeek); 
     1571        db.cstmt.setBigDecimal(++index, daysPerMonth); 
     1572        db.cstmt.setString(++index, resourceCalendar); 
    15601573         
    15611574        db.cstmt.registerOutParameter((idIndex = ++index), Types.NUMERIC); 
     
    16201633            "    p.default_calendar_id, p.timezone_id, shp.space_id, p.default_task_calc_type_id, " + 
    16211634            "    p.earliest_start_date, p.earliest_finish_date, p.latest_start_date, " + 
    1622             "    p.latest_finish_date, p.constraint_type_id, p.constraint_date, SYSDATE, inline_editing_warning, un_assigned_workcapture " + 
     1635            "    p.latest_finish_date, p.constraint_type_id, p.constraint_date, SYSDATE, " +  
     1636            "    p.inline_editing_warning, p.un_assigned_workcapture, p.hours_per_day, " + 
     1637            "    p.hours_per_week, p.days_per_month, p.resource_calendar " + 
    16231638            "from " + 
    16241639            "    pn_space_has_plan shp, " + 
     
    16531668        int EDITING_WARNING_COL = colID++; 
    16541669        int UN_ASSIGNED_WORKCAPTURE_COL = colID++; 
     1670        int HOURS_PER_DAY_COL = colID++; 
     1671        int HOURS_PER_WEEK_COL = colID++; 
     1672        int DAYS_PER_MONTH_COL = colID++; 
     1673        int RESOURCE_CALENDAR_COL = colID++; 
    16551674 
    16561675 
     
    16821701            editingWarning = db.result.getBoolean(EDITING_WARNING_COL); 
    16831702            unAssignedWorkcapture = db.result.getBoolean(UN_ASSIGNED_WORKCAPTURE_COL); 
     1703            hoursPerDay = db.result.getBigDecimal(HOURS_PER_DAY_COL); 
     1704            hoursPerWeek = db.result.getBigDecimal(HOURS_PER_WEEK_COL); 
     1705            daysPerMonth = db.result.getBigDecimal(DAYS_PER_MONTH_COL); 
     1706            resourceCalendar = db.result.getString(RESOURCE_CALENDAR_COL); 
    16841707 
    16851708            String timeZoneID = db.result.getString(TIMEZONE_ID_COL); 
     
    25342557        clone.editingWarning = this.editingWarning; 
    25352558        clone.unAssignedWorkcapture = this.unAssignedWorkcapture; 
     2559        clone.hoursPerDay = this.hoursPerDay; 
     2560        clone.hoursPerWeek = this.hoursPerWeek; 
     2561        clone.daysPerMonth = this.daysPerMonth; 
     2562        clone.resourceCalendar = this.resourceCalendar; 
     2563 
    25362564        //Make copies of all the entries in the entry map 
    25372565        Map clonedEntryMap = new LinkedHashMap(); 
     
    26752703                this.editingWarning = editingWarning; 
    26762704        } 
     2705 
     2706        /** 
     2707         * @return the daysPerMonth 
     2708         */ 
     2709        public BigDecimal getDaysPerMonth() { 
     2710                return daysPerMonth; 
     2711        } 
     2712 
     2713        /** 
     2714         * @param daysPerMonth the daysPerMonth to set 
     2715         */ 
     2716        public void setDaysPerMonth(BigDecimal daysPerMonth) { 
     2717                this.daysPerMonth = daysPerMonth; 
     2718        } 
     2719 
     2720        /** 
     2721         * @return the hoursPerDay 
     2722         */ 
     2723        public BigDecimal getHoursPerDay() { 
     2724                return hoursPerDay; 
     2725        } 
     2726 
     2727        /** 
     2728         * @param hoursPerDay the hoursPerDay to set 
     2729         */ 
     2730        public void setHoursPerDay(BigDecimal hoursPerDay) { 
     2731                this.hoursPerDay = hoursPerDay; 
     2732        } 
     2733 
     2734        /** 
     2735         * @return the hoursPerWeek 
     2736         */ 
     2737        public BigDecimal getHoursPerWeek() { 
     2738                return hoursPerWeek; 
     2739        } 
     2740 
     2741        /** 
     2742         * @param hoursPerWeek the hoursPerWeek to set 
     2743         */ 
     2744        public void setHoursPerWeek(BigDecimal hoursPerWeek) { 
     2745                this.hoursPerWeek = hoursPerWeek; 
     2746        } 
     2747 
     2748        /** 
     2749         * @return the resourceCalendar 
     2750         */ 
     2751        public String getResourceCalendar() { 
     2752                return resourceCalendar; 
     2753        } 
     2754 
     2755        /** 
     2756         * @param resourceCalendar the resourceCalendar to set 
     2757         */ 
     2758        public void setResourceCalendar(String resourceCalendar) { 
     2759                this.resourceCalendar = resourceCalendar; 
     2760        } 
    26772761     
    26782762} 
  • trunk/core/src/net/project/schedule/SchedulePropertiesHelper.java

    r20514 r20523  
    4242public class SchedulePropertiesHelper { 
    4343 
    44     private User user; 
     44    public static final String PERSONAL_RESOURCE_CALENDAR = "PERSONAL"; 
     45    public static final String SCHEDULE_RESOURCE_CALENDAR = "SCHEDULE"; 
     46        private User user; 
    4547    private Date startDate; 
    4648    private Date endDate; 
     
    5254    private boolean editingWarning; 
    5355    private boolean unAssignedWorkcapture; 
     56    private String resourceCalendar; 
    5457 
    5558    /** 
     
    97100        this.editingWarning = schedule.isEditingWarning(); 
    98101        this.unAssignedWorkcapture = schedule.isUnAssignedWorkcapture(); 
     102        this.resourceCalendar = schedule.getResourceCalendar(); 
    99103    } 
    100104 
     
    254258     
    255259    /** 
    256      * Returns the "checked" attribute based on the autocalculation setting 
    257      * @return the string "checked" if auto calculate is on; 
     260     * Returns the "checked" attribute based on the editingWarning setting 
     261     * @return the string "checked" if Inline Editing Warning is on; 
    258262     * otherwise empty string 
    259263     */ 
     
    263267     
    264268    /** 
    265      * Returns the "checked" attribute based on the autocalculation setting 
    266      * @return the string "checked" if auto calculate is on; 
     269     * Returns the "checked" attribute based on the unAssignedWorkcapture setting 
     270     * @return the string "checked" if Un Assigned Task Work Capture is on; 
    267271     * otherwise empty string 
    268272     */ 
     
    270274        return (this.unAssignedWorkcapture ? "checked" : ""); 
    271275    } 
     276     
     277    /** 
     278     * Returns the "checked" attribute based on the resourceCalendar setting 
     279     * @return the string "checked" if auto Personal Resource Calendar is checked ; 
     280     * otherwise empty string 
     281     */ 
     282    public String getCheckedPersonalResourceCalendar(){ 
     283        return (PERSONAL_RESOURCE_CALENDAR.equals(this.resourceCalendar) ? "checked" : ""); 
     284    } 
     285     
     286    /** 
     287     * Returns the "checked" attribute based on the resourceCalendar setting 
     288     * @return the string "checked" if auto Schedule Resource Calendar is checked ; 
     289     * otherwise empty string 
     290     */ 
     291    public String getCheckedScheduleResourceCalendar(){ 
     292        return (SCHEDULE_RESOURCE_CALENDAR.equals(this.resourceCalendar) ? "checked" : ""); 
     293    } 
    272294 
    273295} 
  • trunk/core/src/net/project/schedule/mvc/handler/workingtime/WorkingTimeEditHandler.java

    r19181 r20523  
    2323package net.project.schedule.mvc.handler.workingtime; 
    2424 
     25import java.math.BigDecimal; 
    2526import java.util.HashMap; 
    2627import java.util.Map; 
     
    2930import javax.servlet.http.HttpServletResponse; 
    3031 
    31 import net.project.base.Module; 
    3232import net.project.base.PnetException; 
    3333import net.project.base.mvc.ControllerException; 
    34 import net.project.base.mvc.Handler; 
    3534import net.project.base.property.PropertyProvider; 
    36 import net.project.calendar.workingtime.IWorkingTimeCalendarProvider; 
    3735import net.project.calendar.workingtime.WorkingTimeCalendarCreateHelper; 
    3836import net.project.calendar.workingtime.WorkingTimeCalendarHelper; 
     
    192190            prepareEdit(model, helper); 
    193191 
     192        }else if (theAction.equals("workingtimes")) { 
     193            // User selected a preset calendar type 
     194 
     195                Schedule schedule = (Schedule) request.getSession().getAttribute("schedule"); 
     196            if (schedule == null) { 
     197                throw new ControllerException("Missing session attribute 'schedule'"); 
     198            } 
     199            if(!Validator.isBlankOrNull(request.getParameter("hoursPerDay")) 
     200                && !Validator.isBlankOrNull(request.getParameter("hoursPerDay")) 
     201                && !Validator.isBlankOrNull(request.getParameter("hoursPerDay"))){ 
     202                schedule.setHoursPerDay(BigDecimal.valueOf(Double.parseDouble(request.getParameter("hoursPerDay")))); 
     203                schedule.setHoursPerWeek(BigDecimal.valueOf(Double.parseDouble(request.getParameter("hoursPerWeek")))); 
     204                schedule.setDaysPerMonth(BigDecimal.valueOf(Double.parseDouble(request.getParameter("daysPerMonth")))); 
     205                schedule.store(); 
     206            }else{ 
     207                errorReporter.addError(PropertyProvider.get("prm.schedule.properties.workingtimes.required.message")); 
     208            } 
     209            prepareList(request, model); 
    194210        } else { 
    195211            throw new ControllerException("Unknown action '" + theAction + "'"); 
  • trunk/core/web/jsp/schedule/workingtime/List.jsp

    r19063 r20523  
    2727<%@ include file="/base/taglibInclude.jsp"%> 
    2828<jsp:useBean id="listHelper" type="net.project.calendar.workingtime.WorkingTimeCalendarListHelper" scope="request" /> 
    29  
     29<jsp:useBean id="schedule" class="net.project.schedule.Schedule" scope="session" /> 
    3030<security:verifyAccess action="view" module="<%=Module.SCHEDULE%>" /> 
    3131 
     
    3939<template:getSpaceCSS /> 
    4040 
     41<%-- Import Javascript --%> 
     42<template:import type="javascript" src="/src/errorHandler.js" /> 
     43<template:import type="javascript" src="/src/checkComponentForms.js" /> 
    4144<script language="javascript" type="text/javascript"> 
    4245    var theForm; 
     
    97100} 
    98101 
     102function submit() { 
     103        if(validateForm(theForm)) { 
     104            theAction("workingtimes"); 
     105            theForm.submit(); 
     106    } 
     107} 
     108function validateForm(theForm) { 
     109    if (!checkNumeric(theForm.hoursPerDay,'<display:get name="prm.schedule.properties.hoursperday.mumericrequired.message"/>')) return false; 
     110    if(theForm.hoursPerDay.value <=0 ||  theForm.hoursPerDay.value > 24){ 
     111        extAlert(errorTitle, '<display:get name="prm.schedule.properties.hoursperday.range.message"/>' , Ext.MessageBox.ERROR); 
     112        theForm.hoursPerDay.focus() 
     113        return false; 
     114    } 
     115    if (!checkNumeric(theForm.hoursPerWeek,'<display:get name="prm.schedule.properties.hoursperweek.mumericrequired.message"/>')) return false; 
     116    if(theForm.hoursPerWeek.value <=0 ||  theForm.hoursPerDay.value > 186){ 
     117        extAlert(errorTitle, '<display:get name="prm.schedule.properties.hoursperweek.range.message"/>' , Ext.MessageBox.ERROR); 
     118        theForm.hoursPerWeek.focus() 
     119        return false; 
     120    } 
     121    if (!checkNumeric(theForm.daysPerMonth,'<display:get name="prm.schedule.properties.dayspermonth.mumericrequired.message"/>')) return false; 
     122    if(theForm.daysPerMonth.value <=0 ||  theForm.hoursPerDay.value > 30){ 
     123        extAlert(errorTitle, '<display:get name="prm.schedule.properties.daysspermonth.range.message"/>' , Ext.MessageBox.ERROR); 
     124        theForm.daysPerMonth.focus() 
     125        return false; 
     126    } 
     127    return true; 
     128} 
    99129</script> 
    100130 
     
    165195            <td>&nbsp;</td> 
    166196        </tr> 
     197         
     198        <tr><td colspan="4">&nbsp;</td></tr> 
     199 
     200        <tr> 
     201            <td class="channelHeader" width="1%"><img  src="<%=SessionManager.getJSPRootURL()%>/images/icons/channelbar-left_end.gif" width=8 height=15></td> 
     202            <td nowrap class="channelHeader" align=left colspan="2"><display:get name="prm.schedule.properties.workingtimes.channltitle" /></td> 
     203            <td width="1%" align="right" class="channelHeader"><img src="<%=SessionManager.getJSPRootURL()%>/images/icons/channelbar-right_end.gif" width=8 height=15></td> 
     204        </tr> 
     205         
     206        <%-- Hours per day --%> 
     207        <tr> 
     208            <td>&nbsp;</td> 
     209                            <td class="tableHeader" width="24%"> 
     210                                <display:get name="prm.schedule.properties.hoursperday.label"/> 
     211                            </td> 
     212                            <td class="tableContent"> 
     213                                <input type="text" name="hoursPerDay" size="20" maxlength="80" value='<jsp:getProperty name="schedule" property="hoursPerDay"/>'> 
     214                            </td> 
     215            <td>&nbsp;</td> 
     216        </tr> 
     217        <%-- Hours per week --%> 
     218        <tr> 
     219            <td>&nbsp;</td> 
     220                            <td class="tableHeader"> 
     221                                <display:get name="prm.schedule.properties.hoursperweek.label"/> 
     222                            </td> 
     223                            <td class="tableContent"> 
     224                                <input type="text" name="hoursPerWeek" size="20" maxlength="80" value='<jsp:getProperty name="schedule" property="hoursPerWeek"/>'> 
     225                            </td> 
     226            <td>&nbsp;</td> 
     227        </tr> 
     228        <%-- Days per Month --%> 
     229        <tr> 
     230            <td>&nbsp;</td> 
     231                            <td class="tableHeader"> 
     232                                <display:get name="prm.schedule.properties.dayspermonth.label"/> 
     233                            </td> 
     234                            <td class="tableContent"> 
     235                                <input type="text" name="daysPerMonth" size="20" maxlength="80" value='<jsp:getProperty name="schedule" property="daysPerMonth"/>'> 
     236                            </td> 
     237            <td>&nbsp;</td> 
     238        </tr> 
     239         
    167240 
    168241        <tr><td colspan="4">&nbsp;</td></tr> 
     
    195268    <tb:band name="action"> 
    196269        <tb:button type="cancel"/> 
     270        <tb:button type="submit"/> 
    197271    </tb:band> 
    198272</tb:toolbar>