You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2008/10/21 16:46:24 UTC
svn commit: r706643 - in /ofbiz/trunk/specialpurpose/projectmgr:
script/org/ofbiz/project/ProjectPermissionServices.xml
webapp/projectmgr/WEB-INF/actions/EditWeekTimesheet.groovy
widget/forms/TimeSheetForms.xml
Author: hansbak
Date: Tue Oct 21 07:46:23 2008
New Revision: 706643
URL: http://svn.apache.org/viewvc?rev=706643&view=rev
Log:
correct timesheet groovy file and drop down, also took out some permission check because they cause a database lockup
Modified:
ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectPermissionServices.xml
ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/EditWeekTimesheet.groovy
ofbiz/trunk/specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml
Modified: ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectPermissionServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectPermissionServices.xml?rev=706643&r1=706642&r2=706643&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectPermissionServices.xml (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectPermissionServices.xml Tue Oct 21 07:46:23 2008
@@ -148,7 +148,8 @@
<set field="phaseId" from-field="parameters.workEffortParentId"/>
</if-empty>
<set field="partyId" from-field="parameters.userLogin.partyId"/>
- <call-simple-method method-name="checkProjectMembership"></call-simple-method>
+ <!--call-simple-method method-name="checkProjectMembership"/-->
+ <set field="isMember" value="true" type="Boolean"/>
<!--log level="info" message="======ProjectMGR Security===== action: ${parameters.mainAction} object: ${sec_object} Id: ${parameters.taskId} PhaseId: ${parameters.workEffortParentId} resourceDescription: ${parameters.resourceDescription} isMember: ${isMember}"/-->
<entity-and list-name="custRequests" entity-name="WorkEffortCustRequestView">
<field-map field-name="workEffortId" env-name="taskId"/>
@@ -229,7 +230,7 @@
<!-- TIMESHEET -->
<if-compare field="sec_object" value="TIMESHEET" operator="equals">
- <entity-one entity-name="Timesheet" value-name="timesheet"/>
+ <entity-one entity-name="Timesheet" value-name="timesheet" use-cache="true"/>
<!-- log level="info" message="======ProjectMGR Security===== action: ${mainAction} object: ${sec_object} timesheetId: ${timesheet.timesheetId} partyId: ${timesheet.partyId} resourceDescription: ${parameters.resourceDescription}"/-->
<if>
<condition>
@@ -274,11 +275,12 @@
<!-- TIMEENTRY -->
<if-compare field="sec_object" value="TIMEENTRY" operator="equals">
- <entity-one entity-name="Timesheet" value-name="timesheet"/>
+ <entity-one entity-name="Timesheet" value-name="timesheet" use-cache="true"/>
<set field="timesheetId" from-field="timesheet.timesheetId"/>
<set field="taskId" from-field="parameters.workEffortId"/>
<set field="partyId" from-field="timesheet.partyId"/>
- <call-simple-method method-name="checkProjectMembership"/>
+ <!--call-simple-method method-name="checkProjectMembership"/-->
+ <set field="isMember" value="true" type="Boolean"/>
<!-- log level="info" message="======ProjectMGR Security===== action: ${mainAction} object: ${sec_object} timesheetId: ${timesheetId} from partyId: ${partyId} workEffortId: ${parameters.workEffortId} resourceDescription: ${parameters.resourceDescription}"/-->
<if>
<condition>
@@ -337,32 +339,34 @@
<simple-method method-name="checkProjectMembership" short-description="check if a party is member of a project, input either 'taskId', 'phaseId' or 'projectId', returns 'isMember' ">
<!--log level="always" message="==========object = ${sec_object}, check project membershhip with the following data.. taskId: ${taskId} phaseId: ${phaseId} projectId: ${projectId} party: ${partyId}"></log-->
- <if-not-empty field="taskId">
- <entity-one entity-name="WorkEffort" value-name="task">
- <field-map field-name="workEffortId" env-name="taskId"/>
- </entity-one>
- <set field="phaseId" from-field="task.workEffortParentId"/>
- </if-not-empty>
- <if-not-empty field="phaseId">
- <entity-one entity-name="WorkEffort" value-name="phase">
+ <set field="isMember" value="false" type="Boolean"/>
+ <if-empty field="projectId">
+ <if-empty field="phaseId">
+ <if-empty field="taskId">
+ <return/>
+ <else>
+ <entity-one entity-name="WorkEffort" value-name="task" use-cache="true" >
+ <field-map field-name="workEffortId" env-name="taskId"/>
+ </entity-one>
+ <set field="phaseId" from-field="task.workEffortParentId"/>
+ </else>
+ </if-empty>
+ </if-empty>
+ </if-empty>
+ <if-empty field="projectId">
+ <entity-one entity-name="WorkEffort" value-name="phase" use-cache="true">
<field-map field-name="workEffortId" env-name="phaseId"/>
</entity-one>
<set field="projectId" from-field="phase.workEffortParentId"/>
- </if-not-empty>
+ </if-empty>
<if-not-empty field="projectId">
- <entity-and entity-name="WorkEffortPartyAssignment" list-name="projectAssigns" filter-by-date="true">
+ <entity-and entity-name="WorkEffortPartyAssignment" list-name="projectAssigns" filter-by-date="true" use-cache="true">
<field-map field-name="workEffortId" env-name="projectId"/>
<field-map field-name="partyId" env-name="partyId"/>
</entity-and>
- <if-empty field="projectAssigns">
- <set field="isMember" value="false" type="Boolean"/>
- <else>
- <set field="isMember" value="true" type="Boolean"/>
- </else>
- </if-empty>
- <else>
- <set field="isMember" value="false" type="Boolean"/>
- </else>
+ <if-not-empty field="projectAssigns">
+ <set field="isMember" value="true" type="Boolean"/>
+ </if-not-empty>
</if-not-empty>
</simple-method>
</simple-methods>
Modified: ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/EditWeekTimesheet.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/EditWeekTimesheet.groovy?rev=706643&r1=706642&r2=706643&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/EditWeekTimesheet.groovy (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/EditWeekTimesheet.groovy Tue Oct 21 07:46:23 2008
@@ -28,12 +28,6 @@
import org.ofbiz.entity.util.*;
import org.ofbiz.entity.condition.*;
import java.sql.Timestamp;
-import javolution.util.FastList;
-import javolution.util.FastMap;
-
-delegator = parameters.delegator;
-locale = parameters.locale;
-timeZone = parameters.timeZone;
partyId = parameters.partyId;
if (!partyId) {
@@ -45,13 +39,13 @@
timesheetId = parameters.timesheetId;
//Debug.logInfo("====editweek: " + partyId + " timesheetId: " + timesheetId +"==========");
if (timesheetId) {
- timesheet = delegator.findByPrimaryKey("Timesheet", ["timesheetId" : timesheetId]);
- partyId = timesheet.partyId; // use the party from this timesheet
+ timesheet = delegator.findByPrimaryKey("Timesheet", ["timesheetId" : timesheetId]);
+ partyId = timesheet.partyId; // use the party from this timesheet
} else {
start = UtilDateTime.getWeekStart(UtilDateTime.nowTimestamp());
timesheets = delegator.findByAnd("Timesheet", ["partyId" : partyId, "fromDate" : start]);
- if (!UtilValidate.isEmpty(timesheets)) {
- timesheet = timesheets.get(0);
+ if (timesheets) {
+ timesheet = timesheets[0];
} else {
result = dispatcher.runSync("createProjectTimesheet", ["userLogin" : parameters.userLogin, "partyId" : partyId]);
if (result && result.timesheetId) {
@@ -59,21 +53,20 @@
}
}
}
+if (!timesheet) return;
+context.timesheet = timesheet;
+context.weekNumber = UtilDateTime.weekNumber(timesheet.fromDate);
+
// get the user names
context.partyNameView = delegator.findByPrimaryKey("PartyNameView",["partyId" : partyId]);
// get the default rate for this person
rateTypes = EntityUtil.filterByDate(delegator.findByAnd("PartyRate", ["partyId" : partyId, "defaultRate" : "Y"]));
-if (UtilValidate.isNotEmpty(rateTypes)) {
- rateType = rateTypes.get(0);
- context.defaultRateTypeId = rateType.rateTypeId;
+if (rateTypes) {
+ context.defaultRateTypeId = rateTypes[0].rateTypeId;
}
-if (!timesheet) return;
-context.timesheet = timesheet;
-context.weekNumber = UtilDateTime.weekNumber(timesheet.fromDate);
-
-entries = new LinkedList();
-entry = ["timesheetId" : timesheet.timesheetId, "check" : "true"];
+entries = [];
+entry = ["timesheetId" : timesheet.timesheetId];
taskTotal = 0.00;
day0Total = 0.00; day1Total=0.00; day2Total=0.00; day3Total=0.00; day4Total=0.00; day5Total=0.00; day6Total=0.00;
pHours = 0.00;
@@ -82,7 +75,6 @@
// retrieve work effort data when the workeffortId has changed.
void retrieveWorkEffortData() {
-
// get the planned number of hours
entryWorkEffort = lastTimeEntry.getRelatedOne("WorkEffort");
if (entryWorkEffort) {
@@ -94,11 +86,10 @@
}
}
entry.plannedHours = pHours;
-
// get party assignment data to be able to set the task to complete
workEffortPartyAssigns = EntityUtil.filterByDate(entryWorkEffort.getRelatedByAnd("WorkEffortPartyAssignment", ["partyId" : partyId]));
- if (UtilValidate.isNotEmpty(workEffortPartyAssigns)) {
- workEffortPartyAssign = workEffortPartyAssigns.get(0);
+ if (workEffortPartyAssigns) {
+ workEffortPartyAssign = workEffortPartyAssigns[0];
entry.fromDate = workEffortPartyAssign.getTimestamp("fromDate");
entry.roleTypeId = workEffortPartyAssign.roleTypeId;
if ("PAS_COMPLETED".equals(workEffortPartyAssign.statusId)) {
@@ -121,8 +112,9 @@
entries.add(entry);
// start new entry
taskTotal = 0.00;
- entry = ["timesheetId" : timesheet.timesheetId, "check" : "true"];
+ entry = ["timesheetId" : timesheet.timesheetId];
}
+
timeEntries = timesheet.getRelated("TimeEntry", ["workEffortId", "rateTypeId", "fromDate"]);
te = timeEntries.iterator();
while (te.hasNext()) {
@@ -161,13 +153,13 @@
// add empty lines if timesheet not completed
if (!timesheet.statusId.equals("TIMESHEET_COMPLETED")) {
for (c=0; c < 3; c++) { // add empty lines
- entries.add(["timesheetId" : timesheet.timesheetId,"check" : "false"]);
+ entries.add(["timesheetId" : timesheet.timesheetId]);
}
}
// add the totals line if at least one entry
if (timeEntry) {
- entry = ["timesheetId" : timesheet.timesheetId, "check" : "true"];
+ entry = ["timesheetId" : timesheet.timesheetId];
entry."0" = day0Total;
entry."1" = day1Total;
entry."2" = day2Total;
@@ -175,17 +167,18 @@
entry."4" = day4Total;
entry."5" = day5Total;
entry."6" = day6Total;
- entry."phaseName" = "Totals";
- entry."workEffortId" = "Totals";
- entry."total" = day0Total + day1Total + day2Total + day3Total + day4Total + day5Total + day6Total;
+ entry.phaseName = "Totals";
+ entry.workEffortId = "Totals";
+ entry.total = day0Total + day1Total + day2Total + day3Total + day4Total + day5Total + day6Total;
entries.add(entry);
}
+Debug.log("=====entries: " + entries);
context.timeEntries = entries;
// get all timesheets of this user, including the planned hours
timesheetsDb = delegator.findByAnd("Timesheet", ["partyId" : partyId], ["fromDate DESC"]);
timesheets = new LinkedList();
timesheetsDb.each { timesheetDb ->
- timesheet = FastMap.newInstance();
+ timesheet = [:];
timesheet.putAll(timesheetDb);
entries = timesheetDb.getRelated("TimeEntry");
hours = 0.00;
@@ -199,81 +192,3 @@
timesheets.add(timesheet);
}
context.timesheets = timesheets;
-
-//add task to Dropdown Lists
-tasks = [];
-orderByList = ["projectName", "phaseName", "workEffortName"];
-projectPhaseTasks = [];
-dataAdd = [];
-
-if (!"mytasks".equals(headerItem)) {
- nowDate = UtilDateTime.nowTimestamp();
- taskCond = EntityCondition.makeCondition ([EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId),
- EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "PROJECT"),
- EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowDate),
- EntityCondition.makeCondition ([EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowDate),
- EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null)
- ], EntityOperator.OR),
- ], EntityOperator.AND);
-
- projectList = delegator.findList("WorkEffortAndPartyAssign", taskCond, (HashSet) ["workEffortId"], ["workEffortId"], null, false);
- projects = [];
- projectList.each { project ->
- projects.add(project.workEffortId);
- }
- if (projects) {
- taskPartyCond =
- EntityCondition.makeCondition (
- [EntityCondition.makeCondition("projectId", EntityOperator.IN, projects),
- EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "PTS_CREATED"),
- EntityCondition.makeCondition(
- [EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, null),
- EntityCondition.makeCondition(
- [EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId),
- EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowDate),
- EntityCondition.makeCondition ([EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowDate),
- EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null)
- ], EntityOperator.OR),
- ],EntityOperator.AND),
- ],EntityOperator.OR),
- ],EntityOperator.AND);
- orderByList = ["projectId", "phaseId", "workEffortId"];
- HashSet fields = ["workEffortId", "projectName", "phaseName", "workEffortName"];
- projectPhaseTasks = delegator.findList ("ProjectAndPhaseAndTaskParty", taskPartyCond, fields, orderByList, null, false);
- }
-} else {//Don't assign tasks
- tasksAss = [];
- tasksAss.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PTS_COMPLETED"));
- tasksAss.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PTS_CANCELED"));
- tasksAss.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PTS_ON_HOLD"));
- taskAssCond = EntityCondition.makeCondition(tasks, EntityOperator.AND);
- projectPhaseTaskChecks = delegator.findList("ProjectAndPhaseAndTask", taskAssCond, null, orderByList, null, false);
- projectPhaseTaskChecks.each { projectPhaseTaskCheck ->
- taskNotAs = [];
- workEffortAssignments = delegator.findList("WorkEffortPartyAssignment", null, null, null, null, false);
- found = false;
- workEffortAssignments.each { workEffortAssignment ->
- if (workEffortAssignment.workEffortId.equals(projectPhaseTaskCheck.workEffortId)) {
- found = true;
- }
- }
- if (!found) {
- dataAdd.add(projectPhaseTaskCheck);
- }
- }
- dataAdd.each { dataCheck ->
- found = false;
- //Don't Inprogress tasks
- timeEntries.each { timeEntryAdd ->
- if (dataCheck.workEffortId.equals(timeEntryAdd.workEffortId)) {
- found = true;
- }
- }
- if (!found) {
- projectPhaseTasks.add(dataCheck);
- }
- }
-}
-if (projectPhaseTasks) {//Add task to lists
- context.projectTaskLists = projectPhaseTasks;
-}
Modified: ofbiz/trunk/specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml?rev=706643&r1=706642&r2=706643&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml Tue Oct 21 07:46:23 2008
@@ -24,24 +24,18 @@
<field name="timesheetId"><hidden/></field>
<field name="roleTypeId"><hidden/></field>
<field name="fromDate"><hidden/></field>
- <field name="workEffortId" title="${uiLabelMap.ProjectMgrTaskName}" use-when=""true".equals("${check}")">
- <drop-down allow-empty="false" current="selected">
- <entity-options entity-name="ProjectPartyAndPhaseAndTask" description="" >
+ <field name="workEffortId" title="${uiLabelMap.ProjectMgrTaskName}">
+ <drop-down allow-empty="true">
+ <entity-options entity-name="ProjectPartyAndPhaseAndTask" description="${projectName}-${phaseName}-${workEffortName}">
<entity-constraint name="workEffortTypeId" operator="not-equals" value="TASK_TEMPLATE"/>
<entity-constraint name="partyId" env-name="timesheet.partyId"/>
+ <entity-constraint name="currentStatusId" value="PTS_CREATED"/>
<entity-order-by field-name="projectName"/>
<entity-order-by field-name="phaseName"/>
<entity-order-by field-name="workEffortName"/>
</entity-options>
- <option key="${workEffortId}" description="${projectName}-${phaseName}-${workEffortName}"/>
- <sub-hyperlink target="taskView?workEffortId=${workEffortId}" link-style="buttontext" description="${bsh:workEffortId != void && !workEffortId.equals("Totals") ? workEffortId : ""}"/>
</drop-down>
</field>
- <field name="workEffortId" title="${uiLabelMap.ProjectMgrTaskName}" parameter-name="workEffortId" use-when=""false".equals("${check}")">
- <drop-down allow-empty="true" >
- <list-options list-name="projectTaskLists" key-name="workEffortId" description="${projectName}-${phaseName}-${workEffortName}"/>
- </drop-down>
- </field>
<field name="checkComplete" title="${uiLabelMap.ProjectMgrCheckComplete}"><check/></field>
<field name="rateTypeId" title="${uiLabelMap.ProjectMgrRateTypeId}">
<drop-down allow-empty="false" no-current-selected-key="${defaultRateTypeId}">