make project find more standard using performfind service
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose@628593 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.lang.*;
|
||||
import org.ofbiz.entity.*;
|
||||
import org.ofbiz.base.util.*;
|
||||
import org.ofbiz.base.util.UtilMisc;
|
||||
import org.ofbiz.service.LocalDispatcher;
|
||||
import org.ofbiz.entity.util.*;
|
||||
import org.ofbiz.base.util.*;
|
||||
import org.ofbiz.entity.condition.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
|
||||
EntityOperator checkCondition(String condition){
|
||||
|
||||
switch (condition) {
|
||||
case "equals": return EntityOperator.EQUALS; break;
|
||||
case "like": return EntityOperator.LIKE; break;
|
||||
case "contains": return EntityOperator.LIKE; break;
|
||||
case "empty": return EntityOperator.NOT; break;
|
||||
case "notEqual": return EntityOperator.NOT_EQUAL; break;
|
||||
default: return EntityOperator.EQUALS;break;
|
||||
}
|
||||
}
|
||||
|
||||
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
|
||||
fromDate = parameters.get("fromDate");
|
||||
projectId = parameters.get("projectId");
|
||||
subProjects = parameters.get("subProjects"); // if provided only give subprojects of a certain main project
|
||||
projectName = parameters.get("projectName");
|
||||
projectId_op = parameters.get("projectId_op");
|
||||
projectName_op = parameters.get("projectName_op");
|
||||
|
||||
conditions = UtilMisc.toList(new EntityExpr("workEffortTypeId", EntityOperator.EQUALS, "PROJECT"));
|
||||
|
||||
if (!UtilValidate.isEmpty(fromDate)) {
|
||||
conditions.add(new EntityExpr("lastStatusUpdate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate + " 00:00:00.0"));
|
||||
}
|
||||
|
||||
|
||||
if (subProjects != null) {
|
||||
conditions.add(new EntityExpr("workEffortParentId", EntityOperator.EQUALS, projectId));
|
||||
conditions.add(new EntityExpr("workEffortTypeId", EntityOperator.EQUALS, "PROJECT"));
|
||||
} else {
|
||||
if (!UtilValidate.isEmpty(projectId)) {
|
||||
if(!UtilValidate.isEmpty(projectId_op)){
|
||||
if( projectId_op.equals("contains") || projectId_op.equals("like") ) {
|
||||
conditions.add(new EntityExpr("workEffortId", EntityOperator.LIKE, "%"+projectId+"%"));
|
||||
}else{
|
||||
conditions.add(new EntityExpr("workEffortId", checkCondition(projectId_op), projectId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!UtilValidate.isEmpty(projectName)) {
|
||||
if(!UtilValidate.isEmpty(projectName_op)) {
|
||||
if( projectName_op.equals("contains") || projectName_op.equals("like") ) {
|
||||
conditions.add(new EntityExpr("workEffortName", EntityOperator.LIKE, "%"+projectName+"%"));
|
||||
}else{
|
||||
conditions.add(new EntityExpr("workEffortName", checkCondition(projectName_op), projectName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
entityName = "WorkEffort";
|
||||
if (security.hasPermission("PROJECTMGR_ROLE_VIEW", session)) {
|
||||
conditions.add(new EntityExpr("partyId", EntityOperator.EQUALS, userLogin.getString("partyId")));
|
||||
entityName = "WorkEffortAndPartyAssign";
|
||||
}
|
||||
|
||||
|
||||
allConditions = new EntityConditionList( conditions, EntityOperator.AND );
|
||||
orderBy = UtilMisc.toList("lastStatusUpdate DESC");
|
||||
projects = new LinkedList();
|
||||
listProjects = delegator.findByConditionCache(entityName, allConditions, UtilMisc.toList("workEffortId"), orderBy);
|
||||
|
||||
if (!UtilValidate.isEmpty(listProjects)) {
|
||||
itr = listProjects.iterator();
|
||||
while (itr.hasNext()) {
|
||||
project = itr.next();
|
||||
result = dispatcher.runSync("getProject", UtilMisc.toMap("userLogin", parameters.get("userLogin"), "projectId", project.getString("workEffortId")));
|
||||
projects.add(result.get("projectInfo"));
|
||||
}
|
||||
context.put("projects", projects);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -175,13 +175,17 @@
|
||||
<menu name="ProjectSubTabBar" type="simple" menu-container-style="button-bar button-style-2" default-selected-style="selected">
|
||||
<actions>
|
||||
<set field="projectId" from-field="parameters.projectId" default-value="${parameters.workEffortId}"/>
|
||||
<set field="hasUpdatePermission" value="${bsh:
|
||||
result = dispatcher.runSync("projectMgrPermission",
|
||||
org.ofbiz.base.util.UtilMisc.toMap("userLogin", parameters.get("userLogin"),
|
||||
"resourceDescription", "Project",
|
||||
"mainAction", "UPDATE",
|
||||
"projectId", projectId));
|
||||
return result.get("hasPermission"); }" type="Boolean"/>
|
||||
</actions>
|
||||
<menu-item name="newProject" title="${uiLabelMap.ProjectMgrNewProject}">
|
||||
<condition>
|
||||
<and>
|
||||
<not>
|
||||
<if-empty field-name="project"/>
|
||||
</not>
|
||||
<if-compare field-name="hasUpdatePermission" operator="equals" value="true"/>
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
@@ -19,7 +19,7 @@ under the License.
|
||||
-->
|
||||
|
||||
<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">
|
||||
xsi:noNamespaceSchemaLocation="../../../framework/widget/dtd/widget-screen.xsd">
|
||||
<screen name="ListSubProjects">
|
||||
<section>
|
||||
<actions>
|
||||
@@ -27,9 +27,12 @@ under the License.
|
||||
<set field="tabButtonItem" value="subprojects"/>
|
||||
<set field="labelTitleProperty" value="ProjectMgrProjectName"/>
|
||||
<set field="projectId" from-field="parameters.projectId" default-value="${parameters.workEffortId}"/>
|
||||
<script location="component://projectmgr/webapp/projectmgr/WEB-INF/actions/ListProjects.bsh"/>
|
||||
<set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer"/>
|
||||
<set field="viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="20"/>
|
||||
<entity-and entity-name="WorkEffort" list-name="projects">
|
||||
<field-map field-name="workEffortTypeId" value="PROJECT"/>
|
||||
<field-map field-name="workEffortParentId" env-name="projectId"/>
|
||||
</entity-and>
|
||||
</actions>
|
||||
<widgets>
|
||||
<decorator-screen name="CommonProjectDecorator" location="${parameters.mainDecoratorLocation}">
|
||||
@@ -126,15 +129,14 @@ under the License.
|
||||
<actions>
|
||||
<set field="titleProperty" value="PageTitleFindProject"/>
|
||||
<set field="labelTitleProperty" value="ProjectMgrProjectName"/>
|
||||
<set field="donePage" from-field="parameters.DONE_PAGE" default-value="/workeffort/control/FindProject"/>
|
||||
<set field="workEffortId" from-field="parameters.projectId"/>
|
||||
<script location="component://projectmgr/webapp/projectmgr/WEB-INF/actions/ListProjects.bsh"/>
|
||||
<set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer"/>
|
||||
<set field="viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="10"/>
|
||||
</actions>
|
||||
<widgets>
|
||||
<decorator-screen name="CommonProjectDecorator" location="${parameters.mainDecoratorLocation}">
|
||||
<decorator-section name="body">
|
||||
<include-menu name="ProjectSubTabBar" location="component://projectmgr/widget/Menus.xml"/>
|
||||
<screenlet name="findProject" collapsible="true" title="${uiLabelMap.PageTitleFindProject}">
|
||||
<include-form name="FindProject" location="component://projectmgr/widget/forms/ProjectForms.xml"/>
|
||||
</screenlet>
|
||||
@@ -771,10 +773,10 @@ under the License.
|
||||
<screen name="SubProjectsInfo">
|
||||
<section>
|
||||
<actions>
|
||||
<set field="parameters.projectId" from-field="parameters.projectId" default-value="${parameters.workEffortId}"/>
|
||||
<script location="component://projectmgr/webapp/projectmgr/WEB-INF/actions/FindProject.bsh"/>
|
||||
<set field="projectId" from-field="parameters.projectId" default-value="${parameters.workEffortId}"/>
|
||||
<set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer"/>
|
||||
<set field="viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="20"/>
|
||||
<set field="parameters.workEffortParentId" from-field="projectId" />
|
||||
</actions>
|
||||
<widgets>
|
||||
<container style="screenlet">
|
||||
|
||||
@@ -236,7 +236,7 @@ under the License.
|
||||
<widgets>
|
||||
<decorator-screen name="CommonMyTaskDecorator" location="${parameters.mainDecoratorLocation}">
|
||||
<decorator-section name="body">
|
||||
<screenlet title="${uiLabelMap.PageTitleFindTask}" collapsible="true" id="findTask">
|
||||
<screenlet title="${uiLabelMap.PageTitleFindTask}" collapsible="true" id="findTask">
|
||||
<include-form name="FindTask" location="component://projectmgr/widget/forms/TaskForms.xml"/>
|
||||
</screenlet>
|
||||
<section>
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-form.xsd">
|
||||
<forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../../framework/widget/dtd/widget-form.xsd">
|
||||
<form name="EditProject" type="single" target="updateProject" default-map-name="project"
|
||||
header-row-style="header-row" default-table-style="basic-table">
|
||||
<alt-target use-when="project==null" target="createProject"/>
|
||||
@@ -101,9 +101,9 @@
|
||||
</form>
|
||||
<form name="FindProject" type="single" target="FindProject" title="Find and List Project"
|
||||
header-row-style="header-row" default-table-style="basic-table">
|
||||
<field name="projectId" title="${uiLabelMap.ProjectMgrProjectId}"><text-find size="25" default-option="contains"></text-find></field>
|
||||
<field name="projectName" title="${uiLabelMap.ProjectMgrProjectName}"><text-find size="25" default-option="contains"></text-find></field>
|
||||
<field name="fromDate" title="${uiLabelMap.CommonFromDate}"><date-time type="date" /></field>
|
||||
<field name="projectId" title="${uiLabelMap.ProjectMgrProjectId}" parameter-name="workEffortId"><text-find size="25" default-option="contains"></text-find></field>
|
||||
<field name="projectName" title="${uiLabelMap.ProjectMgrProjectName}" parameter-name="workEffortName"><text-find size="25" default-option="contains"></text-find></field>
|
||||
<field name="fromDate" title="${uiLabelMap.CommonFromDate}" parameter-name="createdStamp"><date-find/></field>
|
||||
<field name="find" title="${uiLabelMap.CommonFind}"><submit/></field>
|
||||
</form>
|
||||
<form name="hoursNotYetBilled" type="list" list-name="entryList"
|
||||
@@ -117,20 +117,44 @@
|
||||
<field name="partyId"><display-entity entity-name="PartyNameView" description="${firstName} ${middleName} ${lastName}"/></field>
|
||||
<field name="fromDate"><display type="date"/></field>
|
||||
</form>
|
||||
<form name="ListProjects" type="list" list-name="projects" paginate-target="FindProject"
|
||||
odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
|
||||
<form name="ListProjects" type="list" list-name="listIt" paginate-target="FindProject"
|
||||
odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
|
||||
<actions>
|
||||
<set field="parameters.workEffortTypeId" value="PROJECT"/>
|
||||
<service service-name="performFind" result-map-name="result" result-map-list-name="listIt">
|
||||
<field-map field-name="inputFields" env-name="parameters"/>
|
||||
<field-map field-name="entityName" value="WorkEffort"/>
|
||||
<field-map field-name="orderBy" value="lastStatusUpdate DESC"/>
|
||||
</service>
|
||||
</actions>
|
||||
<row-actions>
|
||||
<service service-name="getProject" result-map-name="result">
|
||||
<field-map field-name="projectId" value="${workEffortId}"/>
|
||||
</service>
|
||||
<set field="projectName" from-field="result.projectInfo.projectName"/>
|
||||
<set field="projectId" from-field="result.projectInfo.projectId"/>
|
||||
<set field="currentStatusId" from-field="result.projectInfo.currentStatusId"/>
|
||||
<set field="priority" from-field="result.projectInfo.priority"/>
|
||||
<set field="plannedHours" from-field="result.projectInfo.plannedHours"/>
|
||||
<set field="actualHours" from-field="result.projectInfo.actualHours"/>
|
||||
<set field="createdStamp" from-field="result.projectInfo.createdStamp"/>
|
||||
<set field="estimatedStartDate" from-field="result.projectInfo.estimatedStartDate"/>
|
||||
<set field="estimatedCompletionDate" from-field="result.projectInfo.estimatedCompletionDate"/>
|
||||
<set field="actualStartDate" from-field="result.projectInfo.actualStartDate"/>
|
||||
<set field="actualCompletionDate" from-field="result.projectInfo.actualCompletionDate"/>
|
||||
</row-actions>
|
||||
<field name="projectName" title="${uiLabelMap.ProjectMgrProjectName}" widget-style="buttontext">
|
||||
<hyperlink also-hidden="false" description="${projectName}" target="projectView?projectId=${projectId}"/>
|
||||
<hyperlink description="${projectName}" target="projectView?projectId=${projectId}"/>
|
||||
</field>
|
||||
<field name="currentStatusId" title="${uiLabelMap.CommonStatus}"><display-entity entity-name="StatusItem" key-field-name="statusId" description="${description}"/></field>
|
||||
<field name="priority" title="${uiLabelMap.CommonPriority}"><display/></field>
|
||||
<field name="estimatedStartDate" title="${uiLabelMap.WorkEffortEstimatedStartDate}"><display type="date"/></field>
|
||||
<field name="estimatedCompletionDate" title="${uiLabelMap.WorkEffortEstimatedCompletionDate}"><display type="date"/></field>
|
||||
<field name="actualStartDate" title="${uiLabelMap.WorkEffortActualStartDate}"><display type="date"/></field>
|
||||
<field name="actualCompletionDate" title="${uiLabelMap.WorkEffortActualCompletionDate}"><display type="date"/></field>
|
||||
<field name="plannedHours"><display/></field>
|
||||
<field name="actualHours"><display/></field>
|
||||
<field name="createdStamp"><display type="date"/></field>
|
||||
<field name="currentStatusId" title="${uiLabelMap.CommonStatus}"><display-entity entity-name="StatusItem" key-field-name="statusId" description="${description}"/></field>
|
||||
<field name="priority" title="${uiLabelMap.CommonPriority}"><display/></field>
|
||||
<field name="estimatedStartDate" title="${uiLabelMap.FormFieldTitle_estimatedStartDate}"><display type="date"/></field>
|
||||
<field name="estimatedCompletionDate" title="${uiLabelMap.FormFieldTitle_estimatedCompletionDate}"><display type="date"/></field>
|
||||
<field name="actualStartDate" title="${uiLabelMap.FormFieldTitle_actualStartDate}"><display type="date"/></field>
|
||||
<field name="actualCompletionDate" title="${uiLabelMap.FormFieldTitle_actualCompletionDate}"><display type="date"/></field>
|
||||
<field name="plannedHours" title="${uiLabelMap.ProjectMgrPlannedHours}"><display/></field>
|
||||
<field name="actualHours" title="${uiLabelMap.ProjectMgrActualHours}"><display/></field>
|
||||
<field name="createdStamp" title="${uiLabelMap.FormFieldTitle_createdDate}"><display type="date"/></field>
|
||||
</form>
|
||||
<form name="EditSubProjects" list-name="projects" type="list" target="RemoveSubProject"
|
||||
odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
|
||||
|
||||
Reference in New Issue
Block a user