Author: hansbak
Date: Tue Dec 25 02:40:38 2007 New Revision: 606781 URL: http://svn.apache.org/viewvc?rev=606781&view=rev Log: updated version of the sheduler, still not perfect but it gets better Added: ofbiz/trunk/specialpurpose/projectmgr/src/ ofbiz/trunk/specialpurpose/projectmgr/src/org/ ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/ ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/ ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java Modified: ofbiz/trunk/specialpurpose/build.xml ofbiz/trunk/specialpurpose/projectmgr/build.xml ofbiz/trunk/specialpurpose/projectmgr/ofbiz-component.xml ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml Modified: ofbiz/trunk/specialpurpose/build.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/build.xml?rev=606781&r1=606780&r2=606781&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/build.xml (original) +++ ofbiz/trunk/specialpurpose/build.xml Tue Dec 25 02:40:38 2007 @@ -20,7 +20,7 @@ <project name="OFBiz Special Purpose Applications Build" default="build" basedir="."> <filelist id="application-builds" dir="." - files="pos/build.xml, hhfacility/build.xml, assetmaint/build.xml, oagis/build.xml, bi/build.xml, googlebase/build.xml, ebay/build.xml"/> + files="pos/build.xml, hhfacility/build.xml, assetmaint/build.xml, oagis/build.xml, bi/build.xml, googlebase/build.xml, ebay/build.xml, projectmgr/build.xml"/> <!-- ================================================================== --> <!-- Removes all created files and directories --> @@ -50,7 +50,7 @@ <filelist refid="application-builds"/> </subant> <delete file="ofbiz.jar"/> - <echo message="[clean] ========== Done Cleaning Applications =========="/> + <echo message="[clean] ========== Done Cleaning Special purpose =========="/> </target> <!-- ================================================================== --> @@ -58,13 +58,13 @@ <!-- ================================================================== --> <target name="build" depends=""> - <echo message="[build] ========== Start Building Applications (Compile) =========="/> + <echo message="[build] ========== Start Building Special Purpose (Compile) =========="/> <subant inheritall="false"> <filelist refid="application-builds"/> </subant> - <echo message="[build] ========== Done Building Applications (Compile) =========="/> + <echo message="[build] ========== Done Building Special Purpose (Compile) =========="/> </target> <!-- ================================================================== --> @@ -72,12 +72,12 @@ <!-- ================================================================== --> <target name="docs" depends=""> - <echo message="[docs] ========== Start Building Applications (JavaDoc) =========="/> + <echo message="[docs] ========== Start Building Special Purpose (JavaDoc) =========="/> <subant target="docs"> <filelist refid="application-builds"/> </subant> - <echo message="[docs] ========== Done Building Applications (JavaDocs) =========="/> + <echo message="[docs] ========== Done Building Special Purpose (JavaDocs) =========="/> </target> </project> Modified: ofbiz/trunk/specialpurpose/projectmgr/build.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/build.xml?rev=606781&r1=606780&r2=606781&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/projectmgr/build.xml (original) +++ ofbiz/trunk/specialpurpose/projectmgr/build.xml Tue Dec 25 02:40:38 2007 @@ -109,7 +109,7 @@ <!-- ================================================================== --> <target name="docs" depends="prepare-docs,classpath"> - <javadoc packagenames="org.ofbiz.projectmgr.*" + <javadoc packagenames="org.ofbiz.project.*" classpathref="local.class.path" destdir="${build.dir}/javadocs" Windowtitle="Open for Business - ${desc}"> Modified: ofbiz/trunk/specialpurpose/projectmgr/ofbiz-component.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/ofbiz-component.xml?rev=606781&r1=606780&r2=606781&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/projectmgr/ofbiz-component.xml (original) +++ ofbiz/trunk/specialpurpose/projectmgr/ofbiz-component.xml Tue Dec 25 02:40:38 2007 @@ -24,6 +24,7 @@ <resource-loader name="main" type="component"/> <classpath type="dir" location="script"/> <classpath type="dir" location="config"/> + <classpath type="jar" location="build/lib/*"/> <entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel.xml"/> <entity-resource type="group" reader-name="main" loader="main" location="entitydef/entitygroup.xml"/> Modified: ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml?rev=606781&r1=606780&r2=606781&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml (original) +++ ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml Tue Dec 25 02:40:38 2007 @@ -102,10 +102,10 @@ 1. a workday has 8 hours. 2. a workweek has 40 hours and 5 days. 3. The order of the execution of the tasks is set by the workeffortassociation. + 4. The default start of the project is today The steps of the program are: - 1. read all tasks into a list with the following fields: - name, id, length in hours, sequence + 1. read all tasks and check if there are predesessors, when not set he estimated dates for critical path processing: * ES - Earliest Start time * EF - Earliest Finish time @@ -114,82 +114,39 @@ EF = LF task is on the critical path - 2. define the length of every task: skillstandard duration/persons or when zero - default od a task is 3 days. - - 3. define the order of execution according tha workeffortAssociation - 4. set the planned start and end date when no actual dates set yet. - 5. store the start/end dates. - + 2. call a recursive java function to set all the dependant tasks. --> - <!-- constants --> - <set field="nameOrder" value="10" type="Integer"/> + <field-to-result map-name="parameters" field-name="projectId"/> <!-- create the tasklist --> - <field-to-result map-name="parameters" field-name="projectId"/> <entity-one entity-name="WorkEffort" value-name="project"> <field-map field-name="workEffortId" env-name="parameters.projectId"/> </entity-one> - <set field="seq" value="0" type="Double"/> - <string-to-list string="workEffortName" list-name="order"/> <get-related value-name="project" relation-name="ChildWorkEffort" list-name="phases" order-by-list-name="order"/> <iterate entry-name="phase" list-name="phases"> <get-related value-name="phase" relation-name="ChildWorkEffort" list-name="tasks" order-by-list-name="order"/> <iterate entry-name="task" list-name="tasks"> - <clear-field field-name="t"/> - <set field="t.workEffortId" from-field="task.workEffortId"/> - <set field="t.seq" from-field="seq"/> - <calculate field-name="seq"> - <calcop operator="get" field-name="seq"/> - <calcop operator="add" field-name="nameOrder"/> - </calculate> - <!-- get estimated hours --> - <get-related value-name="task" relation-name="WorkEffortSkillStandard" list-name="estimates"/> - <set field="total" value="0" type="Double"/> - <iterate entry-name="estimate" list-name="estimates"> - <calculate field-name="total"> - <calcop operator="get" field-name="total"/> - <calcop operator="add" field-name="estimate.estimatedDuration"></calcop> - </calculate> - </iterate> - <if-compare field-name="total" operator="not-equals" value="0"> - <calculate field-name="t.estimatedDays"> - <calcop operator="divide" field-name="total"> - <number value="8"/> - </calcop> - </calculate> - <else> - <set field="t.estimatedDays" value="1" type="Double"/> - </else> - </if-compare> - <field-to-list field-name="t" list-name="taskList"/> + <get-related value-name="task" relation-name="ToWorkEffortAssoc" list-name="t.prevTasks"/> + <if-empty field-name="t.prevTasks"> + <!-- no predecessors so i can set the dates --> + <now-timestamp-to-env env-name="upd.estimatedStartDate"/> + <now-timestamp-to-env env-name="currentDate"/> + <call-class-method class-name="org.ofbiz.project.Various" method-name="calculateCompletionDate" ret-field-name="upd.estimatedCompletionDate"> + <field field-name="task" type="org.ofbiz.entity.GenericValue"/> + <field field-name="currentDate" type="java.sql.Timestamp"/> + </call-class-method> + <set field="upd.workEffortId" from-field="task.workEffortId"/> + <call-service service-name="updateWorkEffort" in-map-name="upd"/> + <entity-one entity-name="WorkEffort" value-name="newTask"> + <field-map field-name="workEffortId" env-name="task.workEffortId"/> + </entity-one> + <call-class-method class-name="org.ofbiz.project.Various" method-name="setDatesFollowingTasks"> + <field field-name="newTask" type="org.ofbiz.entity.GenericValue"/> + </call-class-method> + </if-empty> </iterate> </iterate> - - <!-- rearrange according dependencies which override the default sequence--> - <!-- to be added --> - - - <!-- order the list--> - <order-map-list list-name="taskList"> - <order-by field-name="seq"/> - </order-map-list> - - <now-timestamp-to-env env-name="currentDate"/> - <!-- iterate through the sorted list and set estimated start and end dates --> - <iterate entry-name="listItem" list-name="taskList"> - <set field="listItem.estimatedStartDate" from-field="currentDate"/> - <calculate field-name="dayNbr"></calculate> - <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field-name="currentDate"> - <field field-name="currentDate" type="java.sql.Timestamp"/> - <field field-name="listItem.estimatedDays" type="Double"/> - </call-class-method> - <set field="listItem.estimatedCompletionDate" from-field="currentDate"/> - <clear-field field-name="upd"/> - <set-service-fields service-name="updateWorkEffort" map-name="listItem" to-map-name="upd"/> - <call-service service-name="updateWorkEffort" in-map-name="upd"/> - </iterate> </simple-method> <simple-method method-name="updateTimeEntryByWorkeffort" short-description="Update workeffort by workeffort and timesheetId "> Added: ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java?rev=606781&view=auto ============================================================================== --- ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java (added) +++ ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java Tue Dec 25 02:40:38 2007 @@ -0,0 +1,82 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *******************************************************************************/ +package org.ofbiz.project; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.*; + +import javolution.util.FastList; +import javolution.util.FastMap; + +import org.ofbiz.base.util.*; +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.entity.GenericEntity; +import org.ofbiz.entity.GenericEntityException; +import org.ofbiz.entity.GenericValue; + +public class Various { + + public static final String module = Various.class.getName(); + + + public static void setDatesFollowingTasks(GenericValue task) { + + try { + List assocs = task.getRelated("FromWorkEffortAssoc"); + if (UtilValidate.isNotEmpty(assocs)) { + Iterator a = assocs.iterator(); + while (a.hasNext()) { + GenericValue assoc = (GenericValue) a.next(); + GenericValue nextTask = assoc.getRelatedOne("ToWorkEffort"); + nextTask.put("estimatedStartDate", task.getTimestamp("estimatedCompletionDate")); + nextTask.put("estimatedCompletionDate", calculateCompletionDate(nextTask, task.getTimestamp("estimatedCompletionDate"))); + nextTask.store(); + setDatesFollowingTasks(nextTask); + } + } + + } catch (GenericEntityException e) { + Debug.logError("Could not updte task: " + e.getMessage(), module); + } + } + + public static Timestamp calculateCompletionDate(GenericValue task, Timestamp startDate) { + + Double plannedHours = 0.00; + try { + // get planned hours + List standards = task.getRelated("WorkEffortSkillStandard"); + Iterator t = standards.iterator(); + while (t.hasNext()) { + GenericValue standard = (GenericValue) t.next(); + if (standard.getDouble("estimatedNumPeople") == null) { + standard.put("estimatedNumPeople", new Double("1")); + } + plannedHours += standard.getDouble("estimatedDuration") / standard.getDouble("estimatedNumPeople"); + } + + } catch (GenericEntityException e) { + Debug.logError("Could not updte task: " + e.getMessage(), module); + } + return UtilDateTime.addDaysToTimestamp(startDate, plannedHours / 8); + } + + +} |
Free forum by Nabble | Edit this page |