提交 2befe36f 编写于 作者: L luojing

teamWork添加视图查询功能

上级 a3118f2a
package com.x.teamwork.assemble.control.jaxrs.task;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.core.entity.Task;
import com.x.teamwork.core.entity.TaskTag;
import com.x.teamwork.core.entity.tools.filter.QueryFilter;
import com.x.teamwork.core.entity.tools.filter.term.EqualsTerm;
import com.x.teamwork.core.entity.tools.filter.term.IsFalseTerm;
import com.x.teamwork.core.entity.tools.filter.term.LikeTerm;
import net.sf.ehcache.Element;
public class ActionViewAllListNextWithFilter extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionViewAllListNextWithFilter.class);
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, String flag, Integer count, String projectId, JsonElement jsonElement ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = new ArrayList<>();
ResultObject resultObject = null;
Wi wrapIn = null;
Boolean check = true;
String cacheKey = null;
Element element = null;
QueryFilter queryFilter = null;
List<TaskTag> tags = null;
if ( StringUtils.isEmpty( projectId ) ) {
check = false;
Exception exception = new TaskProjectFlagForQueryEmptyException();
result.error( exception );
}
if ( StringUtils.isEmpty( flag ) || "(0)".equals(flag)) {
flag = null;
}
try {
wrapIn = this.convertToWrapIn(jsonElement, Wi.class);
} catch (Exception e) {
check = false;
Exception exception = new TaskQueryException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
if( Boolean.TRUE.equals( check ) ){
if( Boolean.TRUE.equals( check ) ){
wrapIn.setProject(projectId);
queryFilter = wrapIn.getQueryFilter();
}
}
if( Boolean.TRUE.equals( check ) ){
cacheKey = ApplicationCache.concreteCacheKey( "ActionAllListNext", effectivePerson.getDistinguishedName(),
flag, count, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter.getContentSHA1() );
element = taskCache.get( cacheKey );
if ((null != element) && (null != element.getObjectValue())) {
resultObject = (ResultObject) element.getObjectValue();
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
} else {
try {
Long total = taskQueryService.countWithFilter( effectivePerson, queryFilter );
List<Task> taskList = taskQueryService.listWithFilter( effectivePerson, count, flag, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter );
if( ListTools.isNotEmpty( taskList )) {
wos = Wo.copier.copy(taskList);
for( Wo wo : wos ) {
tags = taskTagQueryService.listWithTaskAndPerson(effectivePerson, wo );
if( ListTools.isNotEmpty( tags )) {
wo.setTags( WoTaskTag.copier.copy( tags ));
}
}
}
resultObject = new ResultObject( total, wos );
taskCache.put(new Element( cacheKey, resultObject ));
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
} catch (Exception e) {
check = false;
logger.warn("系统查询工作任务信息列表时发生异常!");
result.error(e);
logger.error(e, effectivePerson, request, null);
}
}
}
return result;
}
public static class Wi extends GsonPropertyObject{
@FieldDescribe("用于排列的属性,非必填,默认为createTime.")
private String orderField = "createTime";
@FieldDescribe("排序方式:DESC | ASC,非必填,默认为DESC.")
private String orderType = "DESC";
@FieldDescribe("用于搜索的标题,单值,非必填.")
private String title = null;
private String project = null;
@FieldDescribe("用于搜索的上级工作任务ID,单值,非必填.")
private String parentId = null;
@FieldDescribe("用于搜索的工作标签:自定义标签,单值,非必填.")
private String tag = null;
@FieldDescribe("工作等级:普通-normal | 紧急-urgent | 特急-extraurgent,单值,非必填")
private String priority = null;
@FieldDescribe("用于搜索的工作状态:草稿- draft | 执行中- processing | 已完成- completed | 已归档- archived,单值,非必填")
private String workStatus = null;
@FieldDescribe("是否已完成,true|false,非必填")
private String completed = null;
@FieldDescribe("是否已超时,true|false,非必填")
private String overtime = null;
@FieldDescribe("是否已经删除,true|false,非必填")
private String deleted = null;
@FieldDescribe("执行者或者负责人,单值,非必填")
private String executor = null;
private Long rank = 0L;
public String getOrderField() {
return orderField;
}
public void setOrderField(String orderField) {
this.orderField = orderField;
}
public String getOrderType() {
return orderType;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
public String getProject() {
return project;
}
public void setProject(String project) {
this.project = project;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public String getWorkStatus() {
return workStatus;
}
public void setWorkStatus(String workStatus) {
this.workStatus = workStatus;
}
public String getCompleted() {
return completed;
}
public void setCompleted(String completed) {
this.completed = completed;
}
public String getOvertime() {
return overtime;
}
public void setOvertime(String overtime) {
this.overtime = overtime;
}
public String getDeleted() {
return deleted;
}
public void setDeleted(String deleted) {
this.deleted = deleted;
}
public String getExecutor() {
return executor;
}
public void setExecutor(String executor) {
this.executor = executor;
}
/**
* 根据传入的查询参数,组织一个完整的QueryFilter对象
* @return
*/
public QueryFilter getQueryFilter() {
QueryFilter queryFilter = new QueryFilter();
//组织查询条件对象
if( StringUtils.isNotEmpty( this.getTitle() )) {
queryFilter.addLikeTerm( new LikeTerm( "name", "%" + this.getTitle() + "%" ) );
}
if( StringUtils.isNotEmpty( this.getProject() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "project", this.getProject() ) );
}
if( StringUtils.isNotEmpty( this.getParentId() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "parent", this.getParentId() ) );
}
if( StringUtils.isNotEmpty( this.getPriority())) {
queryFilter.addEqualsTerm( new EqualsTerm( "priority", this.getPriority() ) );
}
if( StringUtils.isNotEmpty( this.getWorkStatus() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "workStatus", this.getWorkStatus() ) );
}else {
//默认查询所有的未归档的工作任务
queryFilter.addIsFalseTerm( new IsFalseTerm("archive"));
}
if( StringUtils.isNotEmpty( this.getExecutor())) {
queryFilter.addEqualsTerm( new EqualsTerm( "executor", this.getExecutor() ) );
}
if( StringUtils.isNotEmpty( this.getCompleted() )) {
if( "true".equalsIgnoreCase( this.getCompleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", false ) );
}
}
if( StringUtils.isNotEmpty( this.getDeleted() )) {
if( "true".equalsIgnoreCase( this.getDeleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", false ) );
}
}
if( StringUtils.isNotEmpty( this.getOvertime() )) {
if( "true".equalsIgnoreCase( this.getDeleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", false ) );
}
}
return queryFilter;
}
}
public static class Wo extends Task {
@FieldDescribe("任务标签")
private List<WoTaskTag> tags = null;
public List<WoTaskTag> getTags() {
return tags;
}
public void setTags(List<WoTaskTag> tags) {
this.tags = tags;
}
private Long rank;
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
static WrapCopier<Task, Wo> copier = WrapCopierFactory.wo( Task.class, Wo.class, null, ListTools.toList(JpaObject.FieldsInvisible));
}
public static class WoTaskTag extends TaskTag {
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
static WrapCopier<TaskTag, WoTaskTag> copier = WrapCopierFactory.wo( TaskTag.class, WoTaskTag.class, null, ListTools.toList(JpaObject.FieldsInvisible));
}
public static class ResultObject {
private Long total;
private List<Wo> wos;
public ResultObject() {}
public ResultObject(Long count, List<Wo> data) {
this.total = count;
this.wos = data;
}
public Long getTotal() {
return total;
}
public void setTotal(Long total) {
this.total = total;
}
public List<Wo> getWos() {
return wos;
}
public void setWos(List<Wo> wos) {
this.wos = wos;
}
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
......@@ -21,15 +22,17 @@ import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.core.entity.Task;
import com.x.teamwork.core.entity.TaskTag;
import com.x.teamwork.core.entity.tools.filter.QueryFilter;
import com.x.teamwork.core.entity.tools.filter.term.InTerm;
import com.x.teamwork.core.entity.tools.filter.term.EqualsTerm;
import com.x.teamwork.core.entity.tools.filter.term.IsFalseTerm;
import com.x.teamwork.core.entity.tools.filter.term.LikeTerm;
import net.sf.ehcache.Element;
public class ActionListPageWithFilter extends BaseAction {
public class ActionViewAllListPageWithFilter extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionListPageWithFilter.class);
private static Logger logger = LoggerFactory.getLogger(ActionViewAllListPageWithFilter.class);
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, Integer pageNum, Integer pageSize, JsonElement jsonElement ) throws Exception {
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, Integer pageNum, Integer pageSize, String projectId, JsonElement jsonElement ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = new ArrayList<>();
ResultObject resultObject = null;
......@@ -38,7 +41,13 @@ public class ActionListPageWithFilter extends BaseAction {
String cacheKey = null;
Element element = null;
QueryFilter queryFilter = null;
List<TaskTag> tags = null;
List<TaskTag> tags = null;
if ( StringUtils.isEmpty( projectId ) ) {
check = false;
Exception exception = new TaskProjectFlagForQueryEmptyException();
result.error( exception );
}
try {
wrapIn = this.convertToWrapIn(jsonElement, Wi.class);
......@@ -49,14 +58,15 @@ public class ActionListPageWithFilter extends BaseAction {
logger.error(e, effectivePerson, request, null);
}
if( check ) {
if( check ) {
if( Boolean.TRUE.equals( check ) ){
if( Boolean.TRUE.equals( check ) ){
wrapIn.setProject(projectId);
queryFilter = wrapIn.getQueryFilter();
}
}
if( check ) {
cacheKey = ApplicationCache.concreteCacheKey( "ActionListPage", effectivePerson.getDistinguishedName(),
if( Boolean.TRUE.equals( check ) ){
cacheKey = ApplicationCache.concreteCacheKey( "ActionAllListPage", effectivePerson.getDistinguishedName(),
pageNum, pageSize, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter.getContentSHA1() );
element = taskCache.get( cacheKey );
......@@ -66,16 +76,7 @@ public class ActionListPageWithFilter extends BaseAction {
result.setData( resultObject.getWos() );
} else {
try {
List<String> taskIds = null;
if( StringUtils.isNotEmpty( wrapIn.getTag() )) {
//查询该拥有该Tag的TaskId列表
taskIds = taskTagQueryService.listTaskIdsWithTagContent( wrapIn.getTag(), null, effectivePerson.getDistinguishedName() );
if( ListTools.isEmpty( taskIds )) {
taskIds = new ArrayList<>();
taskIds.add( "NoOne" );
}
queryFilter.addInTerm( new InTerm("id", new ArrayList<>(taskIds)) );
}
Long total = taskQueryService.countWithFilter( effectivePerson, queryFilter );
List<Task> taskList = taskQueryService.listWithFilter( effectivePerson, pageSize, pageNum, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter );
......@@ -105,7 +106,199 @@ public class ActionListPageWithFilter extends BaseAction {
return result;
}
public static class Wi extends WrapInQueryTask{
public static class Wi extends GsonPropertyObject{
@FieldDescribe("用于排列的属性,非必填,默认为createTime.")
private String orderField = "createTime";
@FieldDescribe("排序方式:DESC | ASC,非必填,默认为DESC.")
private String orderType = "DESC";
@FieldDescribe("用于搜索的标题,单值,非必填.")
private String title = null;
private String project = null;
@FieldDescribe("用于搜索的上级工作任务ID,单值,非必填.")
private String parentId = null;
@FieldDescribe("用于搜索的工作标签:自定义标签,单值,非必填.")
private String tag = null;
@FieldDescribe("工作等级:普通-normal | 紧急-urgent | 特急-extraurgent,单值,非必填")
private String priority = null;
@FieldDescribe("用于搜索的工作状态:草稿- draft | 执行中- processing | 已完成- completed | 已归档- archived,单值,非必填")
private String workStatus = null;
@FieldDescribe("是否已完成,true|false,非必填")
private String completed = null;
@FieldDescribe("是否已超时,true|false,非必填")
private String overtime = null;
@FieldDescribe("是否已经删除,true|false,非必填")
private String deleted = null;
@FieldDescribe("执行者或者负责人,单值,非必填")
private String executor = null;
private Long rank = 0L;
public String getOrderField() {
return orderField;
}
public void setOrderField(String orderField) {
this.orderField = orderField;
}
public String getOrderType() {
return orderType;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
public String getProject() {
return project;
}
public void setProject(String project) {
this.project = project;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public String getWorkStatus() {
return workStatus;
}
public void setWorkStatus(String workStatus) {
this.workStatus = workStatus;
}
public String getCompleted() {
return completed;
}
public void setCompleted(String completed) {
this.completed = completed;
}
public String getOvertime() {
return overtime;
}
public void setOvertime(String overtime) {
this.overtime = overtime;
}
public String getDeleted() {
return deleted;
}
public void setDeleted(String deleted) {
this.deleted = deleted;
}
public String getExecutor() {
return executor;
}
public void setExecutor(String executor) {
this.executor = executor;
}
/**
* 根据传入的查询参数,组织一个完整的QueryFilter对象
* @return
*/
public QueryFilter getQueryFilter() {
QueryFilter queryFilter = new QueryFilter();
//组织查询条件对象
if( StringUtils.isNotEmpty( this.getTitle() )) {
queryFilter.addLikeTerm( new LikeTerm( "name", "%" + this.getTitle() + "%" ) );
}
if( StringUtils.isNotEmpty( this.getProject() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "project", this.getProject() ) );
}
if( StringUtils.isNotEmpty( this.getParentId() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "parent", this.getParentId() ) );
}
if( StringUtils.isNotEmpty( this.getPriority())) {
queryFilter.addEqualsTerm( new EqualsTerm( "priority", this.getPriority() ) );
}
if( StringUtils.isNotEmpty( this.getWorkStatus() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "workStatus", this.getWorkStatus() ) );
}else {
//默认查询所有的未归档的工作任务
queryFilter.addIsFalseTerm( new IsFalseTerm("archive"));
}
if( StringUtils.isNotEmpty( this.getExecutor())) {
queryFilter.addEqualsTerm( new EqualsTerm( "executor", this.getExecutor() ) );
}
if( StringUtils.isNotEmpty( this.getCompleted() )) {
if( "true".equalsIgnoreCase( this.getCompleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", false ) );
}
}
if( StringUtils.isNotEmpty( this.getDeleted() )) {
if( "true".equalsIgnoreCase( this.getDeleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", false ) );
}
}
if( StringUtils.isNotEmpty( this.getOvertime() )) {
if( "true".equalsIgnoreCase( this.getDeleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", false ) );
}
}
return queryFilter;
}
}
public static class Wo extends Task {
......
package com.x.teamwork.assemble.control.jaxrs.taskview;
package com.x.teamwork.assemble.control.jaxrs.task;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
......@@ -18,72 +21,58 @@ import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.core.entity.Task;
import com.x.teamwork.core.entity.TaskTag;
import com.x.teamwork.core.entity.TaskView;
import com.x.teamwork.core.entity.tools.filter.QueryFilter;
import com.x.teamwork.core.entity.tools.filter.term.InTerm;
import com.x.teamwork.core.entity.tools.filter.term.EqualsTerm;
import com.x.teamwork.core.entity.tools.filter.term.IsFalseTerm;
import com.x.teamwork.core.entity.tools.filter.term.LikeTerm;
import net.sf.ehcache.Element;
public class ActionExecuteWithFilterNext extends BaseAction {
public class ActionViewCompletedListNextWithFilter extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionExecuteWithFilterNext.class);
private static Logger logger = LoggerFactory.getLogger(ActionViewCompletedListNextWithFilter.class);
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, String flag, Integer count, String viewId, JsonElement jsonElement ) throws Exception {
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, String flag, Integer count, String projectId, JsonElement jsonElement ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = new ArrayList<>();
ResultObject resultObject = null;
Wi wrapIn = null;
TaskView taskView = null;
Boolean check = true;
String cacheKey = null;
Element element = null;
QueryFilter queryFilter = null;
List<TaskTag> tags = null;
List<TaskTag> tags = null;
if( check ) {
try {
taskView = taskViewQueryService.get( viewId );
if ( taskView == null) {
check = false;
Exception exception = new TaskViewNotExistsException( viewId );
result.error( exception );
}
} catch (Exception e) {
check = false;
Exception exception = new TaskViewQueryException(e, "根据指定ID查询应用工作任务视图信息对象时发生异常。ID:" + viewId );
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
if ( StringUtils.isEmpty( projectId ) ) {
check = false;
Exception exception = new TaskProjectFlagForQueryEmptyException();
result.error( exception );
}
if ( StringUtils.isEmpty( flag ) || "(0)".equals(flag)) {
flag = null;
}
try {
wrapIn = this.convertToWrapIn( jsonElement, Wi.class );
wrapIn = this.convertToWrapIn(jsonElement, Wi.class);
} catch (Exception e) {
check = false;
Exception exception = new TaskViewQueryException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
Exception exception = new TaskQueryException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
if( check ) {
queryFilter = wrapIn.getQueryFilter(taskView);
}
if( check ) {
if( ListTools.isNotEmpty( taskView.getChooseWorkTag() )) {
//获取在该项目中符合标签条件的所有工作任务ID
List<String> taskIds = taskTagQueryService.listTaskIdsWithTagIds( taskView.getChooseWorkTag() );
if( ListTools.isEmpty( taskIds ) ) {
taskIds = new ArrayList<>();
taskIds.add("NoOne");
}
queryFilter.addInTerm( new InTerm("id", new ArrayList<>(taskIds )) );
if( Boolean.TRUE.equals( check ) ){
if( Boolean.TRUE.equals( check ) ){
wrapIn.setProject(projectId);
wrapIn.setCompleted("true");
queryFilter = wrapIn.getQueryFilter();
}
}
if( check ) {
cacheKey = ApplicationCache.concreteCacheKey( "ActionExecuteWithFilterNext", effectivePerson.getDistinguishedName(), flag, count, taskView.getOrderField(), taskView.getOrderType(), queryFilter.getContentSHA1() );
element = taskViewCache.get( cacheKey );
if( Boolean.TRUE.equals( check ) ){
cacheKey = ApplicationCache.concreteCacheKey( "ActionCompletedListNext", effectivePerson.getDistinguishedName(),
flag, count, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter.getContentSHA1() );
element = taskCache.get( cacheKey );
if ((null != element) && (null != element.getObjectValue())) {
resultObject = (ResultObject) element.getObjectValue();
......@@ -91,8 +80,9 @@ public class ActionExecuteWithFilterNext extends BaseAction {
result.setData( resultObject.getWos() );
} else {
try {
Long total = taskQueryService.countWithFilter( effectivePerson, queryFilter );
List<Task> taskList = taskQueryService.listWithFilter( effectivePerson, count, flag, taskView.getOrderField(), taskView.getOrderType(), queryFilter );
List<Task> taskList = taskQueryService.listWithFilter( effectivePerson, count, flag, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter );
if( ListTools.isNotEmpty( taskList )) {
wos = Wo.copier.copy(taskList);
......@@ -105,7 +95,7 @@ public class ActionExecuteWithFilterNext extends BaseAction {
}
resultObject = new ResultObject( total, wos );
taskViewCache.put(new Element( cacheKey, resultObject ));
taskCache.put(new Element( cacheKey, resultObject ));
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
......@@ -120,7 +110,198 @@ public class ActionExecuteWithFilterNext extends BaseAction {
return result;
}
public static class Wi extends WrapInQueryTask{
public static class Wi extends GsonPropertyObject{
@FieldDescribe("用于排列的属性,非必填,默认为createTime.")
private String orderField = "createTime";
@FieldDescribe("排序方式:DESC | ASC,非必填,默认为DESC.")
private String orderType = "DESC";
@FieldDescribe("用于搜索的标题,单值,非必填.")
private String title = null;
private String project = null;
@FieldDescribe("用于搜索的上级工作任务ID,单值,非必填.")
private String parentId = null;
@FieldDescribe("用于搜索的工作标签:自定义标签,单值,非必填.")
private String tag = null;
@FieldDescribe("工作等级:普通-normal | 紧急-urgent | 特急-extraurgent,单值,非必填")
private String priority = null;
@FieldDescribe("用于搜索的工作状态:草稿- draft | 执行中- processing | 已完成- completed | 已归档- archived,单值,非必填")
private String workStatus = null;
private String completed = null;
@FieldDescribe("是否已超时,true|false,非必填")
private String overtime = null;
@FieldDescribe("是否已经删除,true|false,非必填")
private String deleted = null;
@FieldDescribe("执行者或者负责人,单值,非必填")
private String executor = null;
private Long rank = 0L;
public String getOrderField() {
return orderField;
}
public void setOrderField(String orderField) {
this.orderField = orderField;
}
public String getOrderType() {
return orderType;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
public String getProject() {
return project;
}
public void setProject(String project) {
this.project = project;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public String getWorkStatus() {
return workStatus;
}
public void setWorkStatus(String workStatus) {
this.workStatus = workStatus;
}
public String getCompleted() {
return completed;
}
public void setCompleted(String completed) {
this.completed = completed;
}
public String getOvertime() {
return overtime;
}
public void setOvertime(String overtime) {
this.overtime = overtime;
}
public String getDeleted() {
return deleted;
}
public void setDeleted(String deleted) {
this.deleted = deleted;
}
public String getExecutor() {
return executor;
}
public void setExecutor(String executor) {
this.executor = executor;
}
/**
* 根据传入的查询参数,组织一个完整的QueryFilter对象
* @return
*/
public QueryFilter getQueryFilter() {
QueryFilter queryFilter = new QueryFilter();
//组织查询条件对象
if( StringUtils.isNotEmpty( this.getTitle() )) {
queryFilter.addLikeTerm( new LikeTerm( "name", "%" + this.getTitle() + "%" ) );
}
if( StringUtils.isNotEmpty( this.getProject() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "project", this.getProject() ) );
}
if( StringUtils.isNotEmpty( this.getParentId() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "parent", this.getParentId() ) );
}
if( StringUtils.isNotEmpty( this.getPriority())) {
queryFilter.addEqualsTerm( new EqualsTerm( "priority", this.getPriority() ) );
}
if( StringUtils.isNotEmpty( this.getWorkStatus() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "workStatus", this.getWorkStatus() ) );
}else {
//默认查询所有的未归档的工作任务
queryFilter.addIsFalseTerm( new IsFalseTerm("archive"));
}
if( StringUtils.isNotEmpty( this.getExecutor())) {
queryFilter.addEqualsTerm( new EqualsTerm( "executor", this.getExecutor() ) );
}
if( StringUtils.isNotEmpty( this.getCompleted() )) {
if( "true".equalsIgnoreCase( this.getCompleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", false ) );
}
}
if( StringUtils.isNotEmpty( this.getDeleted() )) {
if( "true".equalsIgnoreCase( this.getDeleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", false ) );
}
}
if( StringUtils.isNotEmpty( this.getOvertime() )) {
if( "true".equalsIgnoreCase( this.getDeleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", false ) );
}
}
return queryFilter;
}
}
public static class Wo extends Task {
......
package com.x.teamwork.assemble.control.jaxrs.task;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.core.entity.Task;
import com.x.teamwork.core.entity.TaskTag;
import com.x.teamwork.core.entity.tools.filter.QueryFilter;
import com.x.teamwork.core.entity.tools.filter.term.EqualsTerm;
import com.x.teamwork.core.entity.tools.filter.term.IsFalseTerm;
import com.x.teamwork.core.entity.tools.filter.term.LikeTerm;
import net.sf.ehcache.Element;
public class ActionViewMyExecutListNextWithFilter extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionViewMyExecutListNextWithFilter.class);
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, String flag, Integer count, String projectId, JsonElement jsonElement ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = new ArrayList<>();
ResultObject resultObject = null;
Wi wrapIn = null;
Boolean check = true;
String cacheKey = null;
Element element = null;
QueryFilter queryFilter = null;
List<TaskTag> tags = null;
if ( StringUtils.isEmpty( projectId ) ) {
check = false;
Exception exception = new TaskProjectFlagForQueryEmptyException();
result.error( exception );
}
if ( StringUtils.isEmpty( flag ) || "(0)".equals(flag)) {
flag = null;
}
try {
wrapIn = this.convertToWrapIn(jsonElement, Wi.class);
} catch (Exception e) {
check = false;
Exception exception = new TaskQueryException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
if( Boolean.TRUE.equals( check ) ){
if( Boolean.TRUE.equals( check ) ){
wrapIn.setProject(projectId);
wrapIn.setExecutor(effectivePerson.getDistinguishedName());
queryFilter = wrapIn.getQueryFilter();
//queryFilter.addEqualsTerm( new EqualsTerm( "executor", effectivePerson.getDistinguishedName() ) );
}
}
if( Boolean.TRUE.equals( check ) ){
cacheKey = ApplicationCache.concreteCacheKey( "ActionMyExecutListNext", effectivePerson.getDistinguishedName(),
flag, count, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter.getContentSHA1() );
element = taskCache.get( cacheKey );
if ((null != element) && (null != element.getObjectValue())) {
resultObject = (ResultObject) element.getObjectValue();
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
} else {
try {
Long total = taskQueryService.countWithFilter( effectivePerson, queryFilter );
List<Task> taskList = taskQueryService.listWithFilter( effectivePerson, count, flag, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter );
if( ListTools.isNotEmpty( taskList )) {
wos = Wo.copier.copy(taskList);
for( Wo wo : wos ) {
tags = taskTagQueryService.listWithTaskAndPerson(effectivePerson, wo );
if( ListTools.isNotEmpty( tags )) {
wo.setTags( WoTaskTag.copier.copy( tags ));
}
}
}
resultObject = new ResultObject( total, wos );
taskCache.put(new Element( cacheKey, resultObject ));
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
} catch (Exception e) {
check = false;
logger.warn("系统查询工作任务信息列表时发生异常!");
result.error(e);
logger.error(e, effectivePerson, request, null);
}
}
}
return result;
}
public static class Wi extends GsonPropertyObject{
@FieldDescribe("用于排列的属性,非必填,默认为createTime.")
private String orderField = "createTime";
@FieldDescribe("排序方式:DESC | ASC,非必填,默认为DESC.")
private String orderType = "DESC";
@FieldDescribe("用于搜索的标题,单值,非必填.")
private String title = null;
private String project = null;
@FieldDescribe("用于搜索的上级工作任务ID,单值,非必填.")
private String parentId = null;
@FieldDescribe("用于搜索的工作标签:自定义标签,单值,非必填.")
private String tag = null;
@FieldDescribe("工作等级:普通-normal | 紧急-urgent | 特急-extraurgent,单值,非必填")
private String priority = null;
@FieldDescribe("用于搜索的工作状态:草稿- draft | 执行中- processing | 已完成- completed | 已归档- archived,单值,非必填")
private String workStatus = null;
@FieldDescribe("是否已完成,true|false,非必填")
private String completed = null;
@FieldDescribe("是否已超时,true|false,非必填")
private String overtime = null;
@FieldDescribe("是否已经删除,true|false,非必填")
private String deleted = null;
private String executor = null;
private Long rank = 0L;
public String getOrderField() {
return orderField;
}
public void setOrderField(String orderField) {
this.orderField = orderField;
}
public String getOrderType() {
return orderType;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
public String getProject() {
return project;
}
public void setProject(String project) {
this.project = project;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public String getWorkStatus() {
return workStatus;
}
public void setWorkStatus(String workStatus) {
this.workStatus = workStatus;
}
public String getCompleted() {
return completed;
}
public void setCompleted(String completed) {
this.completed = completed;
}
public String getOvertime() {
return overtime;
}
public void setOvertime(String overtime) {
this.overtime = overtime;
}
public String getDeleted() {
return deleted;
}
public void setDeleted(String deleted) {
this.deleted = deleted;
}
public String getExecutor() {
return executor;
}
public void setExecutor(String executor) {
this.executor = executor;
}
/**
* 根据传入的查询参数,组织一个完整的QueryFilter对象
* @return
*/
public QueryFilter getQueryFilter() {
QueryFilter queryFilter = new QueryFilter();
//组织查询条件对象
if( StringUtils.isNotEmpty( this.getTitle() )) {
queryFilter.addLikeTerm( new LikeTerm( "name", "%" + this.getTitle() + "%" ) );
}
if( StringUtils.isNotEmpty( this.getProject() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "project", this.getProject() ) );
}
if( StringUtils.isNotEmpty( this.getParentId() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "parent", this.getParentId() ) );
}
if( StringUtils.isNotEmpty( this.getPriority())) {
queryFilter.addEqualsTerm( new EqualsTerm( "priority", this.getPriority() ) );
}
if( StringUtils.isNotEmpty( this.getWorkStatus() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "workStatus", this.getWorkStatus() ) );
}else {
//默认查询所有的未归档的工作任务
queryFilter.addIsFalseTerm( new IsFalseTerm("archive"));
}
if( StringUtils.isNotEmpty( this.getExecutor())) {
queryFilter.addEqualsTerm( new EqualsTerm( "executor", this.getExecutor() ) );
}
if( StringUtils.isNotEmpty( this.getCompleted() )) {
if( "true".equalsIgnoreCase( this.getCompleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", false ) );
}
}
if( StringUtils.isNotEmpty( this.getDeleted() )) {
if( "true".equalsIgnoreCase( this.getDeleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", false ) );
}
}
if( StringUtils.isNotEmpty( this.getOvertime() )) {
if( "true".equalsIgnoreCase( this.getDeleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", false ) );
}
}
return queryFilter;
}
}
public static class Wo extends Task {
@FieldDescribe("任务标签")
private List<WoTaskTag> tags = null;
public List<WoTaskTag> getTags() {
return tags;
}
public void setTags(List<WoTaskTag> tags) {
this.tags = tags;
}
private Long rank;
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
static WrapCopier<Task, Wo> copier = WrapCopierFactory.wo( Task.class, Wo.class, null, ListTools.toList(JpaObject.FieldsInvisible));
}
public static class WoTaskTag extends TaskTag {
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
static WrapCopier<TaskTag, WoTaskTag> copier = WrapCopierFactory.wo( TaskTag.class, WoTaskTag.class, null, ListTools.toList(JpaObject.FieldsInvisible));
}
public static class ResultObject {
private Long total;
private List<Wo> wos;
public ResultObject() {}
public ResultObject(Long count, List<Wo> data) {
this.total = count;
this.wos = data;
}
public Long getTotal() {
return total;
}
public void setTotal(Long total) {
this.total = total;
}
public List<Wo> getWos() {
return wos;
}
public void setWos(List<Wo> wos) {
this.wos = wos;
}
}
}
\ No newline at end of file
package com.x.teamwork.assemble.control.jaxrs.taskview;
package com.x.teamwork.assemble.control.jaxrs.task;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
......@@ -18,73 +21,55 @@ import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.core.entity.Task;
import com.x.teamwork.core.entity.TaskTag;
import com.x.teamwork.core.entity.TaskView;
import com.x.teamwork.core.entity.tools.filter.QueryFilter;
import com.x.teamwork.core.entity.tools.filter.term.InTerm;
import com.x.teamwork.core.entity.tools.filter.term.EqualsTerm;
import com.x.teamwork.core.entity.tools.filter.term.IsFalseTerm;
import com.x.teamwork.core.entity.tools.filter.term.LikeTerm;
import net.sf.ehcache.Element;
public class ActionExecuteWithFilterInPage extends BaseAction {
public class ActionViewMyExecutListPageWithFilter extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionExecuteWithFilterInPage.class);
private static Logger logger = LoggerFactory.getLogger(ActionViewMyExecutListPageWithFilter.class);
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, Integer pageNum, Integer pageSize, String viewId, JsonElement jsonElement ) throws Exception {
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, Integer pageNum, Integer pageSize, String projectId, JsonElement jsonElement ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = new ArrayList<>();
ResultObject resultObject = null;
Wi wrapIn = null;
TaskView taskView = null;
Boolean check = true;
String cacheKey = null;
Element element = null;
QueryFilter queryFilter = null;
List<TaskTag> tags = null;
List<TaskTag> tags = null;
if( check ) {
try {
taskView = taskViewQueryService.get( viewId );
if ( taskView == null) {
check = false;
Exception exception = new TaskViewNotExistsException( viewId );
result.error( exception );
}
} catch (Exception e) {
check = false;
Exception exception = new TaskViewQueryException(e, "根据指定ID查询应用工作任务视图信息对象时发生异常。ID:" + viewId );
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
if ( StringUtils.isEmpty( projectId ) ) {
check = false;
Exception exception = new TaskProjectFlagForQueryEmptyException();
result.error( exception );
}
try {
wrapIn = this.convertToWrapIn( jsonElement, Wi.class );
wrapIn = this.convertToWrapIn(jsonElement, Wi.class);
} catch (Exception e) {
check = false;
Exception exception = new TaskViewQueryException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
Exception exception = new TaskQueryException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
if( check ) {
queryFilter = wrapIn.getQueryFilter(taskView);
}
if( check ) {
if( ListTools.isNotEmpty( taskView.getChooseWorkTag() )) {
//获取在该项目中符合标签条件的所有工作任务ID
List<String> taskIds = taskTagQueryService.listTaskIdsWithTagIds( taskView.getChooseWorkTag() );
if( ListTools.isEmpty( taskIds ) ) {
taskIds = new ArrayList<>();
taskIds.add("NoOne");
}
queryFilter.addInTerm( new InTerm("id", new ArrayList<>(taskIds )) );
if( Boolean.TRUE.equals( check ) ){
if( Boolean.TRUE.equals( check ) ){
wrapIn.setProject(projectId);
queryFilter = wrapIn.getQueryFilter();
queryFilter.addEqualsTerm( new EqualsTerm( "executor", effectivePerson.getDistinguishedName() ) );
}
}
if( check ) {
cacheKey = ApplicationCache.concreteCacheKey( "ActionExecuteWithFilterInPage", effectivePerson.getDistinguishedName(),
pageNum, pageSize, taskView.getOrderField(), taskView.getOrderType(), queryFilter.getContentSHA1() );
element = taskViewCache.get( cacheKey );
if( Boolean.TRUE.equals( check ) ){
cacheKey = ApplicationCache.concreteCacheKey( "ActionMyExecutListPage", effectivePerson.getDistinguishedName(),
pageNum, pageSize, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter.getContentSHA1() );
element = taskCache.get( cacheKey );
if ((null != element) && (null != element.getObjectValue())) {
resultObject = (ResultObject) element.getObjectValue();
......@@ -92,8 +77,9 @@ public class ActionExecuteWithFilterInPage extends BaseAction {
result.setData( resultObject.getWos() );
} else {
try {
Long total = taskQueryService.countWithFilter( effectivePerson, queryFilter );
List<Task> taskList = taskQueryService.listWithFilter( effectivePerson, pageSize, pageNum, taskView.getOrderField(), taskView.getOrderType(), queryFilter );
List<Task> taskList = taskQueryService.listWithFilter( effectivePerson, pageSize, pageNum, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter );
if( ListTools.isNotEmpty( taskList )) {
wos = Wo.copier.copy(taskList);
......@@ -106,7 +92,7 @@ public class ActionExecuteWithFilterInPage extends BaseAction {
}
resultObject = new ResultObject( total, wos );
taskViewCache.put(new Element( cacheKey, resultObject ));
taskCache.put(new Element( cacheKey, resultObject ));
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
......@@ -121,7 +107,198 @@ public class ActionExecuteWithFilterInPage extends BaseAction {
return result;
}
public static class Wi extends WrapInQueryTask{
public static class Wi extends GsonPropertyObject{
@FieldDescribe("用于排列的属性,非必填,默认为createTime.")
private String orderField = "createTime";
@FieldDescribe("排序方式:DESC | ASC,非必填,默认为DESC.")
private String orderType = "DESC";
@FieldDescribe("用于搜索的标题,单值,非必填.")
private String title = null;
private String project = null;
@FieldDescribe("用于搜索的上级工作任务ID,单值,非必填.")
private String parentId = null;
@FieldDescribe("用于搜索的工作标签:自定义标签,单值,非必填.")
private String tag = null;
@FieldDescribe("工作等级:普通-normal | 紧急-urgent | 特急-extraurgent,单值,非必填")
private String priority = null;
@FieldDescribe("用于搜索的工作状态:草稿- draft | 执行中- processing | 已完成- completed | 已归档- archived,单值,非必填")
private String workStatus = null;
@FieldDescribe("是否已完成,true|false,非必填")
private String completed = null;
@FieldDescribe("是否已超时,true|false,非必填")
private String overtime = null;
@FieldDescribe("是否已经删除,true|false,非必填")
private String deleted = null;
private String executor = null;
private Long rank = 0L;
public String getOrderField() {
return orderField;
}
public void setOrderField(String orderField) {
this.orderField = orderField;
}
public String getOrderType() {
return orderType;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
public String getProject() {
return project;
}
public void setProject(String project) {
this.project = project;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public String getWorkStatus() {
return workStatus;
}
public void setWorkStatus(String workStatus) {
this.workStatus = workStatus;
}
public String getCompleted() {
return completed;
}
public void setCompleted(String completed) {
this.completed = completed;
}
public String getOvertime() {
return overtime;
}
public void setOvertime(String overtime) {
this.overtime = overtime;
}
public String getDeleted() {
return deleted;
}
public void setDeleted(String deleted) {
this.deleted = deleted;
}
public String getExecutor() {
return executor;
}
public void setExecutor(String executor) {
this.executor = executor;
}
/**
* 根据传入的查询参数,组织一个完整的QueryFilter对象
* @return
*/
public QueryFilter getQueryFilter() {
QueryFilter queryFilter = new QueryFilter();
//组织查询条件对象
if( StringUtils.isNotEmpty( this.getTitle() )) {
queryFilter.addLikeTerm( new LikeTerm( "name", "%" + this.getTitle() + "%" ) );
}
if( StringUtils.isNotEmpty( this.getProject() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "project", this.getProject() ) );
}
if( StringUtils.isNotEmpty( this.getParentId() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "parent", this.getParentId() ) );
}
if( StringUtils.isNotEmpty( this.getPriority())) {
queryFilter.addEqualsTerm( new EqualsTerm( "priority", this.getPriority() ) );
}
if( StringUtils.isNotEmpty( this.getWorkStatus() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "workStatus", this.getWorkStatus() ) );
}else {
//默认查询所有的未归档的工作任务
queryFilter.addIsFalseTerm( new IsFalseTerm("archive"));
}
if( StringUtils.isNotEmpty( this.getExecutor())) {
queryFilter.addEqualsTerm( new EqualsTerm( "executor", this.getExecutor() ) );
}
if( StringUtils.isNotEmpty( this.getCompleted() )) {
if( "true".equalsIgnoreCase( this.getCompleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", false ) );
}
}
if( StringUtils.isNotEmpty( this.getDeleted() )) {
if( "true".equalsIgnoreCase( this.getDeleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", false ) );
}
}
if( StringUtils.isNotEmpty( this.getOvertime() )) {
if( "true".equalsIgnoreCase( this.getDeleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", false ) );
}
}
return queryFilter;
}
}
public static class Wo extends Task {
......
......@@ -13,6 +13,7 @@ import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
......@@ -21,25 +22,32 @@ import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.core.entity.Task;
import com.x.teamwork.core.entity.TaskTag;
import com.x.teamwork.core.entity.tools.filter.QueryFilter;
import com.x.teamwork.core.entity.tools.filter.term.InTerm;
import com.x.teamwork.core.entity.tools.filter.term.EqualsTerm;
import com.x.teamwork.core.entity.tools.filter.term.IsFalseTerm;
import com.x.teamwork.core.entity.tools.filter.term.LikeTerm;
import net.sf.ehcache.Element;
public class ActionListNextWithFilter extends BaseAction {
public class ActionViewOverTimeListNextWithFilter extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionListNextWithFilter.class);
private static Logger logger = LoggerFactory.getLogger(ActionViewOverTimeListNextWithFilter.class);
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, String flag, Integer count, JsonElement jsonElement ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
ResultObject resultObject = null;
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, String flag, Integer count, String projectId, JsonElement jsonElement ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = new ArrayList<>();
Wi wrapIn = null;
ResultObject resultObject = null;
Wi wrapIn = null;
Boolean check = true;
String cacheKey = null;
Element element = null;
List<TaskTag> tags = null;
QueryFilter queryFilter = null;
List<TaskTag> tags = null;
if ( StringUtils.isEmpty( projectId ) ) {
check = false;
Exception exception = new TaskProjectFlagForQueryEmptyException();
result.error( exception );
}
if ( StringUtils.isEmpty( flag ) || "(0)".equals(flag)) {
flag = null;
}
......@@ -52,13 +60,17 @@ public class ActionListNextWithFilter extends BaseAction {
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
if( check ) {
queryFilter = wrapIn.getQueryFilter();
if( Boolean.TRUE.equals( check ) ){
if( Boolean.TRUE.equals( check ) ){
wrapIn.setProject(projectId);
wrapIn.setOvertime("true");
queryFilter = wrapIn.getQueryFilter();
}
}
if( check ) {
cacheKey = ApplicationCache.concreteCacheKey( "ActionListNext", effectivePerson.getDistinguishedName(),
if( Boolean.TRUE.equals( check ) ){
cacheKey = ApplicationCache.concreteCacheKey( "ActionOverTimeListNext", effectivePerson.getDistinguishedName(),
flag, count, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter.getContentSHA1() );
element = taskCache.get( cacheKey );
......@@ -66,21 +78,11 @@ public class ActionListNextWithFilter extends BaseAction {
resultObject = (ResultObject) element.getObjectValue();
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
} else {
} else {
try {
List<String> taskIds = null;
if( StringUtils.isNotEmpty( wrapIn.getTag() )) {
//查询该拥有该Tag的TaskId列表
taskIds = taskTagQueryService.listTaskIdsWithTagContent( wrapIn.getTag(), null, effectivePerson.getDistinguishedName() );
if( ListTools.isEmpty( taskIds )) {
taskIds = new ArrayList<>();
taskIds.add( "NoOne" );
}
queryFilter.addInTerm( new InTerm("id", new ArrayList<>(taskIds)) );
}
Long total = taskQueryService.countWithFilter( effectivePerson, queryFilter );
List<Task> taskList = taskQueryService.listWithFilter( effectivePerson, count, flag, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter );
List<Task> taskList = taskQueryService.listWithFilter( effectivePerson, count, flag, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter );
if( ListTools.isNotEmpty( taskList )) {
wos = Wo.copier.copy(taskList);
......@@ -91,7 +93,7 @@ public class ActionListNextWithFilter extends BaseAction {
}
}
}
resultObject = new ResultObject( total, wos );
taskCache.put(new Element( cacheKey, resultObject ));
......@@ -99,7 +101,7 @@ public class ActionListNextWithFilter extends BaseAction {
result.setData( resultObject.getWos() );
} catch (Exception e) {
check = false;
logger.warn("系统查询项目信息列表时发生异常!");
logger.warn("系统查询工作任务信息列表时发生异常!");
result.error(e);
logger.error(e, effectivePerson, request, null);
}
......@@ -108,7 +110,198 @@ public class ActionListNextWithFilter extends BaseAction {
return result;
}
public static class Wi extends WrapInQueryTask{
public static class Wi extends GsonPropertyObject{
@FieldDescribe("用于排列的属性,非必填,默认为createTime.")
private String orderField = "createTime";
@FieldDescribe("排序方式:DESC | ASC,非必填,默认为DESC.")
private String orderType = "DESC";
@FieldDescribe("用于搜索的标题,单值,非必填.")
private String title = null;
private String project = null;
@FieldDescribe("用于搜索的上级工作任务ID,单值,非必填.")
private String parentId = null;
@FieldDescribe("用于搜索的工作标签:自定义标签,单值,非必填.")
private String tag = null;
@FieldDescribe("工作等级:普通-normal | 紧急-urgent | 特急-extraurgent,单值,非必填")
private String priority = null;
@FieldDescribe("用于搜索的工作状态:草稿- draft | 执行中- processing | 已完成- completed | 已归档- archived,单值,非必填")
private String workStatus = null;
@FieldDescribe("是否已完成,true|false,非必填")
private String completed = null;
private String overtime = null;
@FieldDescribe("是否已经删除,true|false,非必填")
private String deleted = null;
@FieldDescribe("执行者或者负责人,单值,非必填")
private String executor = null;
private Long rank = 0L;
public String getOrderField() {
return orderField;
}
public void setOrderField(String orderField) {
this.orderField = orderField;
}
public String getOrderType() {
return orderType;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
public String getProject() {
return project;
}
public void setProject(String project) {
this.project = project;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public String getWorkStatus() {
return workStatus;
}
public void setWorkStatus(String workStatus) {
this.workStatus = workStatus;
}
public String getCompleted() {
return completed;
}
public void setCompleted(String completed) {
this.completed = completed;
}
public String getOvertime() {
return overtime;
}
public void setOvertime(String overtime) {
this.overtime = overtime;
}
public String getDeleted() {
return deleted;
}
public void setDeleted(String deleted) {
this.deleted = deleted;
}
public String getExecutor() {
return executor;
}
public void setExecutor(String executor) {
this.executor = executor;
}
/**
* 根据传入的查询参数,组织一个完整的QueryFilter对象
* @return
*/
public QueryFilter getQueryFilter() {
QueryFilter queryFilter = new QueryFilter();
//组织查询条件对象
if( StringUtils.isNotEmpty( this.getTitle() )) {
queryFilter.addLikeTerm( new LikeTerm( "name", "%" + this.getTitle() + "%" ) );
}
if( StringUtils.isNotEmpty( this.getProject() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "project", this.getProject() ) );
}
if( StringUtils.isNotEmpty( this.getParentId() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "parent", this.getParentId() ) );
}
if( StringUtils.isNotEmpty( this.getPriority())) {
queryFilter.addEqualsTerm( new EqualsTerm( "priority", this.getPriority() ) );
}
if( StringUtils.isNotEmpty( this.getWorkStatus() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "workStatus", this.getWorkStatus() ) );
}else {
//默认查询所有的未归档的工作任务
queryFilter.addIsFalseTerm( new IsFalseTerm("archive"));
}
if( StringUtils.isNotEmpty( this.getExecutor())) {
queryFilter.addEqualsTerm( new EqualsTerm( "executor", this.getExecutor() ) );
}
if( StringUtils.isNotEmpty( this.getCompleted() )) {
if( "true".equalsIgnoreCase( this.getCompleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", false ) );
}
}
if( StringUtils.isNotEmpty( this.getDeleted() )) {
if( "true".equalsIgnoreCase( this.getDeleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", false ) );
}
}
if( StringUtils.isNotEmpty( this.getOvertime() )) {
if( "true".equalsIgnoreCase( this.getOvertime() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", false ) );
}
}
return queryFilter;
}
}
public static class Wo extends Task {
......@@ -142,7 +335,7 @@ public class ActionListNextWithFilter extends BaseAction {
}
public static class WoTaskTag extends TaskTag {
public static class WoTaskTag extends TaskTag {
private static final long serialVersionUID = -5076990764713538973L;
......
package com.x.teamwork.assemble.control.jaxrs.task;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.core.entity.Task;
import com.x.teamwork.core.entity.TaskTag;
import com.x.teamwork.core.entity.tools.filter.QueryFilter;
import com.x.teamwork.core.entity.tools.filter.term.EqualsTerm;
import com.x.teamwork.core.entity.tools.filter.term.IsFalseTerm;
import com.x.teamwork.core.entity.tools.filter.term.LikeTerm;
import net.sf.ehcache.Element;
public class ActionViewUncompletedListNextWithFilter extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionViewUncompletedListNextWithFilter.class);
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, String flag, Integer count, String projectId, JsonElement jsonElement ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = new ArrayList<>();
ResultObject resultObject = null;
Wi wrapIn = null;
Boolean check = true;
String cacheKey = null;
Element element = null;
QueryFilter queryFilter = null;
List<TaskTag> tags = null;
if ( StringUtils.isEmpty( projectId ) ) {
check = false;
Exception exception = new TaskProjectFlagForQueryEmptyException();
result.error( exception );
}
if ( StringUtils.isEmpty( flag ) || "(0)".equals(flag)) {
flag = null;
}
try {
wrapIn = this.convertToWrapIn(jsonElement, Wi.class);
} catch (Exception e) {
check = false;
Exception exception = new TaskQueryException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
if( Boolean.TRUE.equals( check ) ){
if( Boolean.TRUE.equals( check ) ){
wrapIn.setProject(projectId);
wrapIn.setCompleted("false");
queryFilter = wrapIn.getQueryFilter();
}
}
if( Boolean.TRUE.equals( check ) ){
cacheKey = ApplicationCache.concreteCacheKey( "ActionUncompletedListNext", effectivePerson.getDistinguishedName(),
flag, count, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter.getContentSHA1() );
element = taskCache.get( cacheKey );
if ((null != element) && (null != element.getObjectValue())) {
resultObject = (ResultObject) element.getObjectValue();
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
} else {
try {
Long total = taskQueryService.countWithFilter( effectivePerson, queryFilter );
List<Task> taskList = taskQueryService.listWithFilter( effectivePerson, count, flag, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter );
if( ListTools.isNotEmpty( taskList )) {
wos = Wo.copier.copy(taskList);
for( Wo wo : wos ) {
tags = taskTagQueryService.listWithTaskAndPerson(effectivePerson, wo );
if( ListTools.isNotEmpty( tags )) {
wo.setTags( WoTaskTag.copier.copy( tags ));
}
}
}
resultObject = new ResultObject( total, wos );
taskCache.put(new Element( cacheKey, resultObject ));
result.setCount( resultObject.getTotal() );
result.setData( resultObject.getWos() );
} catch (Exception e) {
check = false;
logger.warn("系统查询工作任务信息列表时发生异常!");
result.error(e);
logger.error(e, effectivePerson, request, null);
}
}
}
return result;
}
public static class Wi extends GsonPropertyObject{
@FieldDescribe("用于排列的属性,非必填,默认为createTime.")
private String orderField = "createTime";
@FieldDescribe("排序方式:DESC | ASC,非必填,默认为DESC.")
private String orderType = "DESC";
@FieldDescribe("用于搜索的标题,单值,非必填.")
private String title = null;
private String project = null;
@FieldDescribe("用于搜索的上级工作任务ID,单值,非必填.")
private String parentId = null;
@FieldDescribe("用于搜索的工作标签:自定义标签,单值,非必填.")
private String tag = null;
@FieldDescribe("工作等级:普通-normal | 紧急-urgent | 特急-extraurgent,单值,非必填")
private String priority = null;
@FieldDescribe("用于搜索的工作状态:草稿- draft | 执行中- processing | 已完成- completed | 已归档- archived,单值,非必填")
private String workStatus = null;
private String completed = null;
@FieldDescribe("是否已超时,true|false,非必填")
private String overtime = null;
@FieldDescribe("是否已经删除,true|false,非必填")
private String deleted = null;
@FieldDescribe("执行者或者负责人,单值,非必填")
private String executor = null;
private Long rank = 0L;
public String getOrderField() {
return orderField;
}
public void setOrderField(String orderField) {
this.orderField = orderField;
}
public String getOrderType() {
return orderType;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
public String getProject() {
return project;
}
public void setProject(String project) {
this.project = project;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public String getWorkStatus() {
return workStatus;
}
public void setWorkStatus(String workStatus) {
this.workStatus = workStatus;
}
public String getCompleted() {
return completed;
}
public void setCompleted(String completed) {
this.completed = completed;
}
public String getOvertime() {
return overtime;
}
public void setOvertime(String overtime) {
this.overtime = overtime;
}
public String getDeleted() {
return deleted;
}
public void setDeleted(String deleted) {
this.deleted = deleted;
}
public String getExecutor() {
return executor;
}
public void setExecutor(String executor) {
this.executor = executor;
}
/**
* 根据传入的查询参数,组织一个完整的QueryFilter对象
* @return
*/
public QueryFilter getQueryFilter() {
QueryFilter queryFilter = new QueryFilter();
//组织查询条件对象
if( StringUtils.isNotEmpty( this.getTitle() )) {
queryFilter.addLikeTerm( new LikeTerm( "name", "%" + this.getTitle() + "%" ) );
}
if( StringUtils.isNotEmpty( this.getProject() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "project", this.getProject() ) );
}
if( StringUtils.isNotEmpty( this.getParentId() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "parent", this.getParentId() ) );
}
if( StringUtils.isNotEmpty( this.getPriority())) {
queryFilter.addEqualsTerm( new EqualsTerm( "priority", this.getPriority() ) );
}
if( StringUtils.isNotEmpty( this.getWorkStatus() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "workStatus", this.getWorkStatus() ) );
}else {
//默认查询所有的未归档的工作任务
queryFilter.addIsFalseTerm( new IsFalseTerm("archive"));
}
if( StringUtils.isNotEmpty( this.getExecutor())) {
queryFilter.addEqualsTerm( new EqualsTerm( "executor", this.getExecutor() ) );
}
if( StringUtils.isNotEmpty( this.getCompleted() )) {
if( "true".equalsIgnoreCase( this.getCompleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "completed", false ) );
}
}
if( StringUtils.isNotEmpty( this.getDeleted() )) {
if( "true".equalsIgnoreCase( this.getDeleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", false ) );
}
}
if( StringUtils.isNotEmpty( this.getOvertime() )) {
if( "true".equalsIgnoreCase( this.getDeleted() )) {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", true ) );
}else {
queryFilter.addEqualsTerm( new EqualsTerm( "overtime", false ) );
}
}
return queryFilter;
}
}
public static class Wo extends Task {
@FieldDescribe("任务标签")
private List<WoTaskTag> tags = null;
public List<WoTaskTag> getTags() {
return tags;
}
public void setTags(List<WoTaskTag> tags) {
this.tags = tags;
}
private Long rank;
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
static WrapCopier<Task, Wo> copier = WrapCopierFactory.wo( Task.class, Wo.class, null, ListTools.toList(JpaObject.FieldsInvisible));
}
public static class WoTaskTag extends TaskTag {
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
static WrapCopier<TaskTag, WoTaskTag> copier = WrapCopierFactory.wo( TaskTag.class, WoTaskTag.class, null, ListTools.toList(JpaObject.FieldsInvisible));
}
public static class ResultObject {
private Long total;
private List<Wo> wos;
public ResultObject() {}
public ResultObject(Long count, List<Wo> data) {
this.total = count;
this.wos = data;
}
public Long getTotal() {
return total;
}
public void setTotal(Long total) {
this.total = total;
}
public List<Wo> getWos() {
return wos;
}
public void setWos(List<Wo> wos) {
this.wos = wos;
}
}
}
\ No newline at end of file
......@@ -339,4 +339,109 @@ public class TaskAction extends StandardJaxrsAction {
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示(视图)当前项目所有工作任务信息,下一页.", action = ActionViewAllListNextWithFilter.class)
@PUT
@Path("listall/{id}/next/{count}/projectId/{projectId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listAllTaskNextWithFilter(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("最后一条信息数据的ID") @PathParam( "id" ) String id,
@JaxrsParameterDescribe("每页显示的条目数量") @PathParam( "count" ) Integer count,
@JaxrsParameterDescribe("当前项目ID") @PathParam( "projectId" ) String projectId,
@JaxrsParameterDescribe("查询过滤条件") JsonElement jsonElement ) {
ActionResult<List<ActionViewAllListNextWithFilter.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionViewAllListNextWithFilter().execute(request, effectivePerson, id, count, projectId, jsonElement );
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示(视图)当前项目我负责的工作任务信息,下一页.", action = ActionViewMyExecutListNextWithFilter.class)
@PUT
@Path("listmyexecut/{id}/next/{count}/projectId/{projectId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listMyExecutTaskNextWithFilter(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("最后一条信息数据的ID") @PathParam( "id" ) String id,
@JaxrsParameterDescribe("每页显示的条目数量") @PathParam( "count" ) Integer count,
@JaxrsParameterDescribe("当前项目ID") @PathParam( "projectId" ) String projectId,
@JaxrsParameterDescribe("查询过滤条件") JsonElement jsonElement ) {
ActionResult<List<ActionViewMyExecutListNextWithFilter.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionViewMyExecutListNextWithFilter().execute(request, effectivePerson, id, count, projectId, jsonElement );
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示(视图)当前项目未完成的工作任务信息,下一页.", action = ActionViewUncompletedListNextWithFilter.class)
@PUT
@Path("listuncompleted/{id}/next/{count}/projectId/{projectId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listUncompletedTaskNextWithFilter(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("最后一条信息数据的ID") @PathParam( "id" ) String id,
@JaxrsParameterDescribe("每页显示的条目数量") @PathParam( "count" ) Integer count,
@JaxrsParameterDescribe("当前项目ID") @PathParam( "projectId" ) String projectId,
@JaxrsParameterDescribe("查询过滤条件") JsonElement jsonElement ) {
ActionResult<List<ActionViewUncompletedListNextWithFilter.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionViewUncompletedListNextWithFilter().execute(request, effectivePerson, id, count, projectId, jsonElement );
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示(视图)当前项目已完成的工作任务信息,下一页.", action = ActionViewCompletedListNextWithFilter.class)
@PUT
@Path("listcompleted/{id}/next/{count}/projectId/{projectId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listCompletedTaskNextWithFilter(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("最后一条信息数据的ID") @PathParam( "id" ) String id,
@JaxrsParameterDescribe("每页显示的条目数量") @PathParam( "count" ) Integer count,
@JaxrsParameterDescribe("当前项目ID") @PathParam( "projectId" ) String projectId,
@JaxrsParameterDescribe("查询过滤条件") JsonElement jsonElement ) {
ActionResult<List<ActionViewCompletedListNextWithFilter.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionViewCompletedListNextWithFilter().execute(request, effectivePerson, id, count, projectId, jsonElement );
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示(视图)当前项目逾期的工作任务信息,下一页.", action = ActionViewOverTimeListNextWithFilter.class)
@PUT
@Path("listovertime/{id}/next/{count}/projectId/{projectId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listOverTimeTaskNextWithFilter(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("最后一条信息数据的ID") @PathParam( "id" ) String id,
@JaxrsParameterDescribe("每页显示的条目数量") @PathParam( "count" ) Integer count,
@JaxrsParameterDescribe("当前项目ID") @PathParam( "projectId" ) String projectId,
@JaxrsParameterDescribe("查询过滤条件") JsonElement jsonElement ) {
ActionResult<List<ActionViewOverTimeListNextWithFilter.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionViewOverTimeListNextWithFilter().execute(request, effectivePerson, id, count, projectId, jsonElement );
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
......@@ -2,11 +2,11 @@ package com.x.teamwork.assemble.control.jaxrs.task;
import com.x.base.core.project.exception.PromptException;
class TaskTagNotExistsException extends PromptException {
class TaskProjectFlagForQueryEmptyException extends PromptException {
private static final long serialVersionUID = 1859164370743532895L;
TaskTagNotExistsException( String id ) {
super("指定ID的工作任务标签信息不存在。ID:" + id );
TaskProjectFlagForQueryEmptyException() {
super("项目ID为空,无法继续查询数据。" );
}
}
......@@ -27,6 +27,7 @@ import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.teamwork.assemble.control.jaxrs.task.ActionListPageWithFilter;
@Path("task_view")
@JaxrsDescribe("工作任务视图信息管理")
......
package com.x.teamwork.assemble.control;
import com.x.base.core.container.EntityManagerContainer;
public abstract class AbstractFactory {
private Business business;
public AbstractFactory( Business business ) throws Exception {
try {
if ( null == business ) {
throw new Exception( "business can not be null. " );
}
this.business = business;
} catch ( Exception e ) {
throw new Exception( "can not instantiating factory." );
}
}
public EntityManagerContainer entityManagerContainer() throws Exception {
return this.business.entityManagerContainer();
}
}
\ No newline at end of file
package com.x.teamwork.assemble.control;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import com.x.base.core.project.Context;
@WebListener
public class ApplicationServletContextListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
try {
ThisApplication.context = Context.concrete(servletContextEvent);
ThisApplication.init();
ThisApplication.context().regist();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
try {
ThisApplication.destroy();
ThisApplication.context.destrory(servletContextEvent);
} catch (Exception e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
package com.x.teamwork.assemble.control;
import com.x.base.core.container.EntityManagerContainer;
import com.x.organization.core.express.Organization;
import com.x.teamwork.assemble.control.factory.AttachmentFactory;
import com.x.teamwork.assemble.control.factory.BatchOperationFactory;
import com.x.teamwork.assemble.control.factory.ChatFactory;
import com.x.teamwork.assemble.control.factory.DynamicFactory;
import com.x.teamwork.assemble.control.factory.ProjectExtFieldReleFactory;
import com.x.teamwork.assemble.control.factory.ProjectFactory;
import com.x.teamwork.assemble.control.factory.ProjectGroupFactory;
import com.x.teamwork.assemble.control.factory.ProjectGroupReleFactory;
import com.x.teamwork.assemble.control.factory.ReviewFactory;
import com.x.teamwork.assemble.control.factory.SystemConfigFactory;
import com.x.teamwork.assemble.control.factory.TaskFactory;
import com.x.teamwork.assemble.control.factory.TaskGroupFactory;
import com.x.teamwork.assemble.control.factory.TaskGroupReleFactory;
import com.x.teamwork.assemble.control.factory.TaskListFactory;
import com.x.teamwork.assemble.control.factory.TaskTagFactory;
import com.x.teamwork.assemble.control.factory.TaskViewFactory;
public class Business {
private EntityManagerContainer emc;
public Business(EntityManagerContainer emc) throws Exception {
this.emc = emc;
}
public EntityManagerContainer entityManagerContainer() {
return this.emc;
}
private Organization organization;
private ProjectFactory projectFactory;
private TaskFactory taskFactory;
private DynamicFactory dynamicFactory;
private SystemConfigFactory systemConfigFactory;
private ProjectGroupFactory projectGroupFactory;
private ProjectGroupReleFactory projectGroupReleFactory;
private TaskListFactory taskListFactory;
private ChatFactory chatFactory;
private TaskGroupFactory taskGroupFactory;
private TaskGroupReleFactory taskGroupReleFactory;
private TaskViewFactory taskViewFactory;
private ProjectExtFieldReleFactory projectExtFieldReleFactory;
private ReviewFactory reviewFactory;
private BatchOperationFactory batchOperationFactory;
private TaskTagFactory taskTagFactory;
private AttachmentFactory attachmentFactory;
public Organization organization() throws Exception {
if (null == this.organization) {
this.organization = new Organization(ThisApplication.context());
}
return organization;
}
/**
* 获取附件信息数据库访问类
* @return
* @throws Exception
*/
public AttachmentFactory attachmentFactory() throws Exception {
if (null == this.attachmentFactory) {
this.attachmentFactory = new AttachmentFactory( this );
}
return attachmentFactory;
}
/**
* 获取工作任务标签数据库访问类
* @return
* @throws Exception
*/
public TaskTagFactory taskTagFactory() throws Exception {
if (null == this.taskTagFactory) {
this.taskTagFactory = new TaskTagFactory( this );
}
return taskTagFactory;
}
/**
* 获取批处理任务数据库访问类
* @return
* @throws Exception
*/
public BatchOperationFactory batchOperationFactory() throws Exception {
if (null == this.batchOperationFactory) {
this.batchOperationFactory = new BatchOperationFactory( this );
}
return batchOperationFactory;
}
/**
* 获取Review信息数据库访问类
* @return
* @throws Exception
*/
public ReviewFactory reviewFactory() throws Exception {
if (null == this.reviewFactory) {
this.reviewFactory = new ReviewFactory( this );
}
return reviewFactory;
}
/**
* 获取项目扩展属性关联信息数据库访问类
* @return
* @throws Exception
*/
public ProjectExtFieldReleFactory projectExtFieldReleFactory() throws Exception {
if (null == this.projectExtFieldReleFactory) {
this.projectExtFieldReleFactory = new ProjectExtFieldReleFactory( this );
}
return projectExtFieldReleFactory;
}
/**
* 获取任务视图数据库访问类
* @return
* @throws Exception
*/
public TaskViewFactory taskViewFactory() throws Exception {
if (null == this.taskViewFactory) {
this.taskViewFactory = new TaskViewFactory( this );
}
return taskViewFactory;
}
/**
* 获取工作任务组关联信息数据库访问类
* @return
* @throws Exception
*/
public TaskGroupReleFactory taskGroupReleFactory() throws Exception {
if (null == this.taskGroupReleFactory) {
this.taskGroupReleFactory = new TaskGroupReleFactory( this );
}
return taskGroupReleFactory;
}
/**
* 获取工作任务组数据库访问类
* @return
* @throws Exception
*/
public TaskGroupFactory taskGroupFactory() throws Exception {
if (null == this.taskGroupFactory) {
this.taskGroupFactory = new TaskGroupFactory( this );
}
return taskGroupFactory;
}
/**
* 获取工作交流数据库访问类
* @return
* @throws Exception
*/
public ChatFactory chatFactory() throws Exception {
if (null == this.chatFactory) {
this.chatFactory = new ChatFactory( this );
}
return chatFactory;
}
/**
* 获取工作任务列表数据库访问类
* @return
* @throws Exception
*/
public TaskListFactory taskListFactory() throws Exception {
if (null == this.taskListFactory) {
this.taskListFactory = new TaskListFactory( this );
}
return taskListFactory;
}
/**
* 获取项目组数据库访问类
* @return
* @throws Exception
*/
public ProjectGroupFactory projectGroupFactory() throws Exception {
if (null == this.projectGroupFactory) {
this.projectGroupFactory = new ProjectGroupFactory( this );
}
return projectGroupFactory;
}
/**
* 获取项目与项目组关联信息数据库访问类
* @return
* @throws Exception
*/
public ProjectGroupReleFactory projectGroupReleFactory() throws Exception {
if (null == this.projectGroupReleFactory) {
this.projectGroupReleFactory = new ProjectGroupReleFactory( this );
}
return projectGroupReleFactory;
}
/**
* 获取系统配置信息数据库访问类
* @return
* @throws Exception
*/
public SystemConfigFactory systemConfigFactory() throws Exception {
if (null == this.systemConfigFactory) {
this.systemConfigFactory = new SystemConfigFactory( this );
}
return systemConfigFactory;
}
/**
* 获取工作任务信息数据库访问类
* @return
* @throws Exception
*/
public TaskFactory taskFactory() throws Exception {
if (null == this.taskFactory) {
this.taskFactory = new TaskFactory( this );
}
return taskFactory;
}
/**
* 获取项目信息数据库访问类
* @return
* @throws Exception
*/
public ProjectFactory projectFactory() throws Exception {
if (null == this.projectFactory) {
this.projectFactory = new ProjectFactory( this );
}
return projectFactory;
}
/**
* 获取动态信息数据库访问类
* @return
* @throws Exception
*/
public DynamicFactory dynamicFactory() throws Exception {
if (null == this.dynamicFactory) {
this.dynamicFactory = new DynamicFactory( this );
}
return dynamicFactory;
}
}
package com.x.teamwork.assemble.control;
import com.x.base.core.project.Context;
import com.x.base.core.project.message.MessageConnector;
import com.x.teamwork.assemble.control.queue.QueueBatchOperation;
import com.x.teamwork.assemble.control.service.SystemConfigPersistService;
import com.x.teamwork.assemble.control.timertask.Timertask_BatchOperationTask;
import com.x.teamwork.assemble.control.timertask.Timertask_CheckAllTaskOverTime;
import com.x.teamwork.assemble.control.timertask.Timertask_RefreshAllTaskReview;
public class ThisApplication {
protected static Context context;
public static QueueBatchOperation queueBatchOperation;
public static Context context() {
return context;
}
public static void init() {
try {
//执行消息操作
queueBatchOperation = new QueueBatchOperation();
MessageConnector.start(context());
context().startQueue( queueBatchOperation );
new SystemConfigPersistService().initSystemConfig();
//每隔5分钟检查是否有未完成的批处理工作需要完成以及是否有未review的task需要核对权限信息
context.schedule( Timertask_BatchOperationTask.class, "0 */2 * * * ?" );
//每天凌晨把所有项目的所有工作任务的权限和review信息核对一次
context.schedule( Timertask_RefreshAllTaskReview.class, "0 0 2 * * ?" );
//每30分钟核对一次所有的工作任务,判断工作任务是否已经超时
context.schedule( Timertask_CheckAllTaskOverTime.class, "0 0/30 * * * ?" );
} catch (Exception e) {
e.printStackTrace();
}
}
public static void destroy() {
try {
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.x.teamwork.assemble.control.factory;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.assemble.control.AbstractFactory;
import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.Attachment;
import com.x.teamwork.core.entity.Attachment_;
public class AttachmentFactory extends AbstractFactory {
public AttachmentFactory(Business business) throws Exception {
super(business);
}
public Attachment get( String id ) throws Exception {
return this.entityManagerContainer().find(id, Attachment.class, ExceptionWhen.none);
}
public List<String> listAll() throws Exception {
EntityManager em = this.entityManagerContainer().get(Attachment.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Attachment> root = cq.from( Attachment.class);
cq.select(root.get(Attachment_.id));
return em.createQuery(cq).getResultList();
}
public List<Attachment> list(List<String> ids) throws Exception {
if( ListTools.isEmpty( ids ) ){
return new ArrayList<Attachment>();
}
EntityManager em = this.entityManagerContainer().get(Attachment.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Attachment> cq = cb.createQuery(Attachment.class);
Root<Attachment> root = cq.from(Attachment.class);
Predicate p = root.get(Attachment_.id).in(ids);
return em.createQuery(cq.where(p)).getResultList();
}
public List<Attachment> listAttachmentWithProject(String project) throws Exception {
if( StringUtils.isEmpty( project ) ){
return new ArrayList<Attachment>();
}
EntityManager em = this.entityManagerContainer().get(Attachment.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Attachment> cq = cb.createQuery(Attachment.class);
Root<Attachment> root = cq.from(Attachment.class);
Predicate p = cb.equal( root.get(Attachment_.projectId), project );
p = cb.and( p, cb.equal( root.get(Attachment_.bundleObjType ), "PROJECT"));
return em.createQuery(cq.where(p)).getResultList();
}
public List<Attachment> listAttachmentWithTask(String taskId ) throws Exception {
if( StringUtils.isEmpty( taskId ) ){
return new ArrayList<Attachment>();
}
EntityManager em = this.entityManagerContainer().get(Attachment.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Attachment> cq = cb.createQuery(Attachment.class);
Root<Attachment> root = cq.from(Attachment.class);
Predicate p = cb.equal( root.get(Attachment_.taskId ), taskId );
p = cb.and( p, cb.equal( root.get(Attachment_.bundleObjType ), "TASK"));
return em.createQuery(cq.where(p)).getResultList();
}
}
package com.x.teamwork.assemble.control.factory;
import com.x.teamwork.assemble.control.AbstractFactory;
import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.BatchOperation;
import com.x.teamwork.core.entity.BatchOperation_;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.List;
/**
* 批处理操作信息记录,比如需要级联删除大量的工作重新计算权限等
*/
public class BatchOperationFactory extends AbstractFactory {
public BatchOperationFactory(Business business) throws Exception {
super(business);
}
public List<BatchOperation> list( List<String> ids ) throws Exception {
EntityManager em = this.entityManagerContainer().get( BatchOperation.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<BatchOperation> cq = cb.createQuery( BatchOperation.class );
Root<BatchOperation> root = cq.from( BatchOperation.class );
Predicate p = root.get( BatchOperation_.id).in( ids );
cq.orderBy( cb.asc( root.get( BatchOperation.createTime_FIELDNAME ) ) );
return em.createQuery(cq.where(p)).getResultList();
}
public List<BatchOperation> list(Integer maxCount) throws Exception {
EntityManager em = this.entityManagerContainer().get( BatchOperation.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<BatchOperation> cq = cb.createQuery( BatchOperation.class );
Root<BatchOperation> root = cq.from( BatchOperation.class );
cq.orderBy( cb.asc( root.get( BatchOperation.createTime_FIELDNAME ) ) );
return em.createQuery(cq).setMaxResults(maxCount).getResultList();
}
public List<BatchOperation> listNotRun(Integer maxCount) throws Exception {
EntityManager em = this.entityManagerContainer().get( BatchOperation.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<BatchOperation> cq = cb.createQuery( BatchOperation.class );
Root<BatchOperation> root = cq.from( BatchOperation.class );
Predicate p = cb.isFalse( root.get( BatchOperation_.isRunning ) );
cq.orderBy( cb.asc( root.get( BatchOperation.createTime_FIELDNAME ) ) );
return em.createQuery(cq.where(p)).setMaxResults(maxCount).getResultList();
}
}
\ No newline at end of file
package com.x.teamwork.assemble.control.factory;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Order;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.teamwork.assemble.control.AbstractFactory;
import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.Chat;
import com.x.teamwork.core.entity.ChatContent;
import com.x.teamwork.core.entity.Chat_;
import com.x.teamwork.core.entity.tools.CriteriaBuilderTools;
import com.x.teamwork.core.entity.tools.filter.QueryFilter;
public class ChatFactory extends AbstractFactory {
public ChatFactory( Business business ) throws Exception {
super(business);
}
/**
* 获取指定Id的Chat实体信息对象
* @param id
* @return
* @throws Exception
*/
public Chat get( String id ) throws Exception {
return this.entityManagerContainer().find( id, Chat.class, ExceptionWhen.none );
}
/**
* 根据ChatId获取LOB内容
* @param id
* @return
* @throws Exception
*/
public ChatContent getContent(String id) throws Exception {
return this.entityManagerContainer().find( id, ChatContent.class, ExceptionWhen.none );
}
/**
* 根据ChatId获取LOB内容
* @param id
* @return
* @throws Exception
*/
public String getContentString(String id) throws Exception {
ChatContent content = this.entityManagerContainer().find( id, ChatContent.class, ExceptionWhen.none );
if( content != null ) {
return content.getContent();
}
return null;
}
/**
* 根据条件查询符合条件的Chat数量
* @param personName
* @param unitNames
* @param groupNames
* @param queryFilter
* @return
* @throws Exception
*/
public Long countWithFilter( QueryFilter queryFilter) throws Exception {
EntityManager em = this.entityManagerContainer().get( Chat.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Chat> root = cq.from(Chat.class);
Predicate p = CriteriaBuilderTools.composePredicateWithQueryFilter( Chat_.class, cb, null, root, queryFilter );
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
/**
* 根据条件查询符合条件的项目信息ID(查询前N条内存分页支持)
* @param personName
* @param unitNames
* @param groupNames
* @param queryFilter
* @return
* @throws Exception
*/
public List<Chat> listWithFilter( Integer maxCount, String orderField, String orderType, QueryFilter queryFilter ) throws Exception {
EntityManager em = this.entityManagerContainer().get( Chat.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Chat> cq = cb.createQuery(Chat.class);
Root<Chat> root = cq.from(Chat.class);
Predicate p = CriteriaBuilderTools.composePredicateWithQueryFilter( Chat_.class, cb, null, root, queryFilter );
Order orderWithField = CriteriaBuilderTools.getOrder(cb, root, Chat_.class, orderField, orderType);
if( orderWithField != null ){
cq.orderBy( orderWithField );
}
return em.createQuery(cq.where(p)).setMaxResults( maxCount).getResultList();
}
/**
* 根据条件查询符合条件的项目信息ID(根据sequnce分页支持)
* @param maxCount
* @param sequenceFieldValue
* @param orderField
* @param orderType
* @param queryFilter
* @return
* @throws Exception
*/
public List<Chat> listWithFilter( Integer maxCount, Object sequenceFieldValue, String orderField, String orderType, QueryFilter queryFilter ) throws Exception {
EntityManager em = this.entityManagerContainer().get( Chat.class );
return CriteriaBuilderTools.listNextWithCondition( em, Chat.class, Chat_.class, maxCount, queryFilter, sequenceFieldValue, orderField, orderType );
}
}
package com.x.teamwork.assemble.control.factory;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Order;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.teamwork.assemble.control.AbstractFactory;
import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.Dynamic;
import com.x.teamwork.core.entity.DynamicDetail;
import com.x.teamwork.core.entity.Dynamic_;
import com.x.teamwork.core.entity.tools.CriteriaBuilderTools;
import com.x.teamwork.core.entity.tools.filter.QueryFilter;
public class DynamicFactory extends AbstractFactory {
public DynamicFactory( Business business ) throws Exception {
super(business);
}
/**
* 获取指定Id的Dynamic实体信息对象
* @param id
* @return
* @throws Exception
*/
public Dynamic get( String id ) throws Exception {
return this.entityManagerContainer().find( id, Dynamic.class, ExceptionWhen.none );
}
public DynamicDetail getDetail(String flag) throws Exception {
return this.entityManagerContainer().find( flag, DynamicDetail.class, ExceptionWhen.none );
}
/**
* 根据过滤条件查询符合要求的项目信息数量
* @param queryFilter
* @return
* @throws Exception
*/
public Long countWithFilter( QueryFilter queryFilter) throws Exception {
EntityManager em = this.entityManagerContainer().get( Dynamic.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Dynamic> root = cq.from(Dynamic.class);
Predicate p = CriteriaBuilderTools.composePredicateWithQueryFilter( Dynamic_.class, cb, null, root, queryFilter );
cq.select(cb.count(root));
return em.createQuery(cq.where(p)).getSingleResult();
}
/**
* 根据条件查询符合条件的项目信息ID(查询前N条内存分页支持)
* @param maxCount
* @param orderField
* @param orderType
* @param queryFilter
* @return
* @throws Exception
*/
public List<Dynamic> listWithFilter( Integer maxCount, String orderField, String orderType, QueryFilter queryFilter ) throws Exception {
EntityManager em = this.entityManagerContainer().get( Dynamic.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Dynamic> cq = cb.createQuery(Dynamic.class);
Root<Dynamic> root = cq.from(Dynamic.class);
Predicate p = CriteriaBuilderTools.composePredicateWithQueryFilter( Dynamic_.class, cb, null, root, queryFilter );
Order orderWithField = CriteriaBuilderTools.getOrder(cb, root, Dynamic_.class, orderField, orderType);
if( orderWithField != null ){
cq.orderBy( orderWithField );
}
return em.createQuery(cq.where(p)).setMaxResults( maxCount).getResultList();
}
/**
* 根据条件查询符合条件的项目信息ID(根据sequnce分页支持)
* @param maxCount
* @param sequenceFieldValue
* @param orderField
* @param orderType
* @param queryFilter
* @return
* @throws Exception
*/
public List<Dynamic> listWithFilter( Integer maxCount, Object sequenceFieldValue, String orderField, String orderType, QueryFilter queryFilter ) throws Exception {
EntityManager em = this.entityManagerContainer().get( Dynamic.class );
return CriteriaBuilderTools.listNextWithCondition( em, Dynamic.class, Dynamic_.class, maxCount, queryFilter, sequenceFieldValue, orderField, orderType );
}
}
package com.x.teamwork.assemble.control.factory;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.teamwork.assemble.control.AbstractFactory;
import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.ProjectExtFieldRele;
import com.x.teamwork.core.entity.ProjectExtFieldRele_;
public class ProjectExtFieldReleFactory extends AbstractFactory {
public ProjectExtFieldReleFactory( Business business ) throws Exception {
super(business);
}
/**
* 获取指定Id的ProjectExtFieldRele实体信息对象
* @param id
* @return
* @throws Exception
*/
public ProjectExtFieldRele get( String id ) throws Exception {
return this.entityManagerContainer().find( id, ProjectExtFieldRele.class, ExceptionWhen.none );
}
/**
* 列示指定Id的ProjectExtFieldRele实体信息列表
* @param ids
* @return
* @throws Exception
*/
public List<ProjectExtFieldRele> list( List<String> ids ) throws Exception {
if( ids == null || ids.size() == 0 ){
return new ArrayList<ProjectExtFieldRele>();
}
EntityManager em = this.entityManagerContainer().get(ProjectExtFieldRele.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ProjectExtFieldRele> cq = cb.createQuery(ProjectExtFieldRele.class);
Root<ProjectExtFieldRele> root = cq.from(ProjectExtFieldRele.class);
Predicate p = root.get(ProjectExtFieldRele_.id).in(ids);
cq.orderBy( cb.desc( root.get( ProjectExtFieldRele_.updateTime ) ) );
return em.createQuery(cq.where(p)).getResultList();
}
/**
* 根据项目ID列示项目扩展属性ID信息列表
* @param project
* @return
* @throws Exception
*/
public List<ProjectExtFieldRele> listFieldReleObjByProject( String project ) throws Exception {
if( StringUtils.isEmpty( project ) ){
throw new Exception("project can not be empty!");
}
EntityManager em = this.entityManagerContainer().get(ProjectExtFieldRele.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ProjectExtFieldRele> cq = cb.createQuery(ProjectExtFieldRele.class);
Root<ProjectExtFieldRele> root = cq.from(ProjectExtFieldRele.class);
Predicate p = cb.equal( root.get(ProjectExtFieldRele_.projectId), project );
return em.createQuery(cq.where(p)).getResultList();
}
/**
* 根据项目ID列示项目扩展属性ID信息列表
* @param project
* @return
* @throws Exception
*/
public List<String> listFieldReleIdsByProject( String project ) throws Exception {
if( StringUtils.isEmpty( project ) ){
throw new Exception("project can not be empty!");
}
EntityManager em = this.entityManagerContainer().get(ProjectExtFieldRele.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<ProjectExtFieldRele> root = cq.from(ProjectExtFieldRele.class);
Predicate p = cb.equal( root.get(ProjectExtFieldRele_.projectId), project );
cq.select( root.get(ProjectExtFieldRele_.projectId) );
return em.createQuery(cq.where(p)).getResultList();
}
/**
* 根据扩展属性名以及项目ID获取一组关联信息
* @param fieldName
* @param project
* @return
* @throws Exception
*/
public List<ProjectExtFieldRele> listWithFieldNameAndProject( String fieldName, String project ) throws Exception {
if( StringUtils.isEmpty( fieldName ) ){
throw new Exception("fieldName can not be empty!");
}
if( StringUtils.isEmpty( project ) ){
throw new Exception("project can not be empty!");
}
EntityManager em = this.entityManagerContainer().get(ProjectExtFieldRele.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ProjectExtFieldRele> cq = cb.createQuery(ProjectExtFieldRele.class);
Root<ProjectExtFieldRele> root = cq.from(ProjectExtFieldRele.class);
Predicate p = cb.equal( root.get(ProjectExtFieldRele_.extFieldName), fieldName );
p = cb.and( p, cb.equal( root.get(ProjectExtFieldRele_.projectId), project ));
return em.createQuery(cq.where(p)).getResultList();
}
}
package com.x.teamwork.assemble.control.factory;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Order;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.assemble.control.AbstractFactory;
import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.Dynamic_;
import com.x.teamwork.core.entity.Project;
import com.x.teamwork.core.entity.ProjectDetail;
import com.x.teamwork.core.entity.Project_;
import com.x.teamwork.core.entity.tools.CriteriaBuilderTools;
import com.x.teamwork.core.entity.tools.filter.QueryFilter;
public class ProjectFactory extends AbstractFactory {
public ProjectFactory( Business business ) throws Exception {
super(business);
}
/**
* 获取指定Id的Project实体信息对象
* @param id
* @return
* @throws Exception
*/
public Project get( String id ) throws Exception {
return this.entityManagerContainer().find( id, Project.class, ExceptionWhen.none );
}
public ProjectDetail getDetail(String id) throws Exception {
return this.entityManagerContainer().find( id, ProjectDetail.class, ExceptionWhen.none );
}
/**
* 列示指定Id的Project实体信息列表
* @param ids
* @return
* @throws Exception
*/
public List<Project> list( List<String> ids ) throws Exception {
if( ids == null || ids.size() == 0 ){
return new ArrayList<Project>();
}
EntityManager em = this.entityManagerContainer().get(Project.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Project> cq = cb.createQuery(Project.class);
Root<Project> root = cq.from(Project.class);
Predicate p = root.get(Project_.id).in(ids);
cq.orderBy( cb.desc( root.get( Project_.updateTime ) ) );
return em.createQuery(cq.where(p)).getResultList();
}
public List<String> listAllProjectIds() throws Exception {
EntityManager em = this.entityManagerContainer().get(Project.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Project> root = cq.from(Project.class);
cq.select( root.get( Project_.id) );
return em.createQuery(cq ).getResultList();
}
/**
* 根据条件查询符合条件的项目信息数量
* @param personName
* @param unitNames
* @param groupNames
* @param queryFilter
* @return
* @throws Exception
*/
public Long countWithFilter( String personName, List<String> identityNames, List<String> unitNames, List<String> groupNames, QueryFilter queryFilter) throws Exception {
EntityManager em = this.entityManagerContainer().get( Project.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Project> root = cq.from(Project.class);
Predicate p_permission = null;
if( StringUtils.isNotEmpty( personName )) {
//可以管理的栏目,肯定可以发布信息
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.isMember( personName, root.get( Project_.participantPersonList )) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.isMember( personName, root.get( Project_.manageablePersonList )) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.equal( root.get( Project_.creatorPerson ), personName ) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.equal( root.get( Project_.executor ), personName ) );
}
if( ListTools.isNotEmpty( identityNames )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, root.get( Project_.participantIdentityList).in(identityNames));
}
if( ListTools.isNotEmpty( unitNames )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, root.get( Project_.participantUnitList).in(unitNames));
}
if( ListTools.isNotEmpty( groupNames )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, root.get( Project_.participantGroupList).in(groupNames));
}
Predicate p = CriteriaBuilderTools.composePredicateWithQueryFilter( Project_.class, cb, p_permission, root, queryFilter );
cq.select(cb.count(root)).where(p);
Long count = em.createQuery(cq).getSingleResult();
return count;
}
/**
* 根据条件查询符合条件的项目信息ID
* @param maxCount
* @param orderField
* @param orderType
* @param personName
* @param identityNames
* @param unitNames
* @param groupNames
* @param queryFilter
* @return
* @throws Exception
*/
public List<Project> listWithFilter( Integer maxCount, String orderField, String orderType, String personName, List<String> identityNames, List<String> unitNames, List<String> groupNames, QueryFilter queryFilter) throws Exception {
EntityManager em = this.entityManagerContainer().get( Project.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Project> cq = cb.createQuery(Project.class);
Root<Project> root = cq.from(Project.class);
Predicate p_permission = null;
if( StringUtils.isNotEmpty( personName )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.isMember( personName, root.get( Project_.participantPersonList )) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.isMember( personName, root.get( Project_.manageablePersonList )) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.equal( root.get( Project_.creatorPerson ), personName ) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.equal( root.get( Project_.executor ), personName ) );
}
if( ListTools.isNotEmpty( identityNames )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, root.get( Project_.participantIdentityList).in(identityNames));
}
if( ListTools.isNotEmpty( unitNames )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, root.get( Project_.participantUnitList).in(unitNames));
}
if( ListTools.isNotEmpty( groupNames )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, root.get( Project_.participantGroupList).in(groupNames));
}
Predicate p = CriteriaBuilderTools.composePredicateWithQueryFilter( Project_.class, cb, p_permission, root, queryFilter );
Order orderWithField = CriteriaBuilderTools.getOrder(cb, root, Project_.class, orderField, orderType);
if( orderWithField != null ){
cq.orderBy( orderWithField );
}
return em.createQuery(cq.where(p)).setMaxResults( maxCount).getResultList();
}
/**
* 根据条件查询符合条件的项目信息ID,根据上一条的sequnce查询指定数量的信息
* @param maxCount
* @param sequenceFieldValue
* @param orderField
* @param orderType
* @param personName
* @param identityNames
* @param unitNames
* @param groupNames
* @param queryFilter
* @return
* @throws Exception
*/
public List<Project> listWithFilter( Integer maxCount, Object sequenceFieldValue, String orderField, String orderType, String personName, List<String> identityNames, List<String> unitNames, List<String> groupNames, QueryFilter queryFilter) throws Exception {
EntityManager em = this.entityManagerContainer().get( Project.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Project> cq = cb.createQuery(Project.class);
Root<Project> root = cq.from(Project.class);
Predicate p_permission = null;
if( StringUtils.isNotEmpty( personName )) {
//可以管理的栏目,肯定可以发布信息
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.isMember( personName, root.get( Project_.participantPersonList )) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.isMember( personName, root.get( Project_.manageablePersonList )) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.equal( root.get( Project_.creatorPerson ), personName ) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.equal( root.get( Project_.executor ), personName ) );
}
if( ListTools.isNotEmpty( identityNames )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, root.get( Project_.participantIdentityList).in(identityNames));
}
if( ListTools.isNotEmpty( unitNames )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, root.get( Project_.participantUnitList).in(unitNames));
}
if( ListTools.isNotEmpty( groupNames )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, root.get( Project_.participantGroupList).in(groupNames));
}
Predicate p = CriteriaBuilderTools.composePredicateWithQueryFilter( Project_.class, cb, p_permission, root, queryFilter );
if( sequenceFieldValue != null && StringUtils.isNotEmpty( sequenceFieldValue.toString() )) {
Predicate p_seq = cb.isNotNull( root.get( Dynamic_.sequence ) );
if( "desc".equalsIgnoreCase( orderType )){
p_seq = cb.and( p_seq, cb.lessThan( root.get( Project_.sequence ), sequenceFieldValue.toString() ));
}else{
p_seq = cb.and( p_seq, cb.greaterThan( root.get( Project_.sequence ), sequenceFieldValue.toString() ));
}
p = cb.and( p, p_seq);
}
Order orderWithField = CriteriaBuilderTools.getOrder( cb, root, Project_.class, orderField, orderType );
if( orderWithField != null ){
cq.orderBy( orderWithField );
}
System.out.println(">>>SQL:" + em.createQuery(cq.where(p)).setMaxResults( maxCount).toString() );
return em.createQuery(cq.where(p)).setMaxResults( maxCount).getResultList();
}
/**
* 根据条件查询所有符合条件的项目信息ID,项目信息不会很多 ,所以直接查询出来
* @param maxCount
* @param sequenceFieldValue
* @param orderField
* @param orderType
* @param personName
* @param identityNames
* @param unitNames
* @param groupNames
* @param queryFilter
* @return
* @throws Exception
*/
public List<String> listAllViewableProjectIds( Integer maxCount, String personName, List<String> identityNames, List<String> unitNames, List<String> groupNames, QueryFilter queryFilter) throws Exception {
EntityManager em = this.entityManagerContainer().get( Project.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Project> root = cq.from(Project.class);
Predicate p_permission = null;
if( StringUtils.isNotEmpty( personName )) {
//可以管理的栏目,肯定可以发布信息
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.isMember( personName, root.get( Project_.participantPersonList )) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.isMember( personName, root.get( Project_.manageablePersonList )) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.equal( root.get( Project_.creatorPerson ), personName ) );
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.equal( root.get( Project_.executor ), personName ) );
}
if( ListTools.isNotEmpty( identityNames )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, root.get( Project_.participantIdentityList).in(identityNames));
}
if( ListTools.isNotEmpty( unitNames )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, root.get( Project_.participantUnitList).in(unitNames));
}
if( ListTools.isNotEmpty( groupNames )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, root.get( Project_.participantGroupList).in(groupNames));
}
Predicate p = CriteriaBuilderTools.composePredicateWithQueryFilter( Project_.class, cb, p_permission, root, queryFilter );
cq.distinct(true).select( root.get(Project_.id) );
return em.createQuery(cq.where(p)).setMaxResults( maxCount).getResultList();
}
}
package com.x.teamwork.assemble.control.factory;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.teamwork.assemble.control.AbstractFactory;
import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.ProjectGroup;
import com.x.teamwork.core.entity.ProjectGroup_;
public class ProjectGroupFactory extends AbstractFactory {
public ProjectGroupFactory( Business business ) throws Exception {
super(business);
}
/**
* 获取指定Id的ProjectGroup实体信息对象
* @param id
* @return
* @throws Exception
*/
public ProjectGroup get( String id ) throws Exception {
return this.entityManagerContainer().find( id, ProjectGroup.class, ExceptionWhen.none );
}
/**
* 列示指定Id的ProjectGroup实体信息列表
* @param ids
* @return
* @throws Exception
*/
public List<ProjectGroup> list( List<String> ids ) throws Exception {
if( ids == null || ids.size() == 0 ){
return new ArrayList<ProjectGroup>();
}
EntityManager em = this.entityManagerContainer().get(ProjectGroup.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ProjectGroup> cq = cb.createQuery(ProjectGroup.class);
Root<ProjectGroup> root = cq.from(ProjectGroup.class);
Predicate p = root.get(ProjectGroup_.id).in(ids);
cq.orderBy( cb.desc( root.get( ProjectGroup_.updateTime ) ) );
return em.createQuery(cq.where(p)).getResultList();
}
/**
* 根据用户列示ProjectGroup实体信息列表
* @param person
* @return
* @throws Exception
*/
public List<String> listByPerson( String person ) throws Exception {
if( StringUtils.isEmpty( person ) ){
throw new Exception("person can not be empty!");
}
EntityManager em = this.entityManagerContainer().get(ProjectGroup.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<ProjectGroup> root = cq.from(ProjectGroup.class);
Predicate p = cb.equal( root.get(ProjectGroup_.owner), person );
cq.select( root.get(ProjectGroup_.id ) );
return em.createQuery(cq.where(p)).getResultList();
}
/**
* 根据用户列示ProjectGroup实体信息列表
* @param person
* @return
* @throws Exception
*/
public List<ProjectGroup> listGroupByPerson( String person ) throws Exception {
if( StringUtils.isEmpty( person ) ){
throw new Exception("person can not be empty!");
}
EntityManager em = this.entityManagerContainer().get(ProjectGroup.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ProjectGroup> cq = cb.createQuery(ProjectGroup.class);
Root<ProjectGroup> root = cq.from(ProjectGroup.class);
Predicate p = cb.equal( root.get(ProjectGroup_.owner), person );
return em.createQuery(cq.where(p)).getResultList();
}
}
package com.x.teamwork.assemble.control.factory;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.teamwork.assemble.control.AbstractFactory;
import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.ProjectGroupRele;
import com.x.teamwork.core.entity.ProjectGroupRele_;
public class ProjectGroupReleFactory extends AbstractFactory {
public ProjectGroupReleFactory( Business business ) throws Exception {
super(business);
}
/**
* 获取指定Id的ProjectGroupRele实体信息对象
* @param id
* @return
* @throws Exception
*/
public ProjectGroupRele get( String id ) throws Exception {
return this.entityManagerContainer().find( id, ProjectGroupRele.class, ExceptionWhen.none );
}
/**
* 列示指定Id的ProjectGroupRele实体信息列表
* @param ids
* @return
* @throws Exception
*/
public List<ProjectGroupRele> list( List<String> ids ) throws Exception {
if( ids == null || ids.size() == 0 ){
return new ArrayList<ProjectGroupRele>();
}
EntityManager em = this.entityManagerContainer().get(ProjectGroupRele.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ProjectGroupRele> cq = cb.createQuery(ProjectGroupRele.class);
Root<ProjectGroupRele> root = cq.from(ProjectGroupRele.class);
Predicate p = root.get(ProjectGroupRele_.id).in(ids);
cq.orderBy( cb.desc( root.get( ProjectGroupRele_.updateTime ) ) );
return em.createQuery(cq.where(p)).getResultList();
}
/**
* 根据项目组ID列示项目ID信息列表
* @param group
* @return
* @throws Exception
*/
public List<String> listProjectIdByGroup( String group ) throws Exception {
if( StringUtils.isEmpty( group ) ){
throw new Exception("group can not be empty!");
}
EntityManager em = this.entityManagerContainer().get(ProjectGroupRele.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<ProjectGroupRele> root = cq.from(ProjectGroupRele.class);
Predicate p = cb.equal( root.get(ProjectGroupRele_.groupId), group );
cq.select( root.get(ProjectGroupRele_.projectId) );
return em.createQuery(cq.where(p)).getResultList();
}
/**
* 根据项目组ID列示关联信息ID列表
* @param group
* @return
* @throws Exception
*/
public List<String> listByGroup( String group ) throws Exception {
if( StringUtils.isEmpty( group ) ){
throw new Exception("group can not be empty!");
}
EntityManager em = this.entityManagerContainer().get(ProjectGroupRele.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<ProjectGroupRele> root = cq.from(ProjectGroupRele.class);
Predicate p = cb.equal( root.get(ProjectGroupRele_.groupId), group );
cq.select( root.get(ProjectGroupRele_.id) );
return em.createQuery(cq.where(p)).getResultList();
}
/**
* 根据项目组ID以及项目ID获取一个关联信息
* @param group
* @param project
* @return
* @throws Exception
*/
public List<ProjectGroupRele> listWithGroupAndProject( String group, String project ) throws Exception {
if( StringUtils.isEmpty( group ) ){
throw new Exception("group can not be empty!");
}
if( StringUtils.isEmpty( project ) ){
throw new Exception("project can not be empty!");
}
EntityManager em = this.entityManagerContainer().get(ProjectGroupRele.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ProjectGroupRele> cq = cb.createQuery(ProjectGroupRele.class);
Root<ProjectGroupRele> root = cq.from(ProjectGroupRele.class);
Predicate p = cb.equal( root.get(ProjectGroupRele_.groupId), group );
p = cb.and( p, cb.equal( root.get(ProjectGroupRele_.projectId), project ));
return em.createQuery(cq.where(p)).getResultList();
}
public List<ProjectGroupRele> listReleWithProject(String projectId) throws Exception {
if( StringUtils.isEmpty( projectId ) ){
throw new Exception("projectId can not be empty!");
}
EntityManager em = this.entityManagerContainer().get(ProjectGroupRele.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ProjectGroupRele> cq = cb.createQuery(ProjectGroupRele.class);
Root<ProjectGroupRele> root = cq.from(ProjectGroupRele.class);
Predicate p = cb.equal( root.get(ProjectGroupRele_.projectId), projectId );
return em.createQuery(cq.where(p)).getResultList();
}
}
package com.x.teamwork.assemble.control.factory;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Order;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.assemble.control.AbstractFactory;
import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.Review;
import com.x.teamwork.core.entity.Review_;
import com.x.teamwork.core.entity.tools.CriteriaBuilderTools;
import com.x.teamwork.core.entity.tools.filter.QueryFilter;
/**
* 工作任务权限控制信息服务类
*/
public class ReviewFactory extends AbstractFactory {
public ReviewFactory( Business business) throws Exception {
super(business);
}
public List<String> listReviewByTask( String taskId, Integer maxCount ) throws Exception {
if( maxCount == null ) {
maxCount = 1000;
}
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery( String.class );
Root<Review> root = cq.from( Review.class );
Predicate p = cb.equal(root.get( Review_.taskId ), taskId );
cq.select( root.get( Review_.id) ).where(p);
return em.createQuery( cq ).setMaxResults(maxCount).getResultList();
}
public List<String> listTaskIdsWithPersonAndProject(String person, String project ) throws Exception {
if( StringUtils.isEmpty( person ) ) {
throw new Exception("person can not be empty!");
}
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery( String.class );
Root<Review> root = cq.from( Review.class );
Predicate p = cb.equal( root.get( Review_.permissionObj ), person );
p = cb.and( p, cb.equal( root.get( Review_.project ), project ));
cq.select(root.get( Review_.taskId)).where(p);
return em.createQuery( cq ).getResultList();
}
public List<String> listTaskIdsWithPersonAndProject( String project, String person, Integer maxCount ) throws Exception {
if( maxCount == null ) {
maxCount = 1000;
}
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery( String.class );
Root<Review> root = cq.from( Review.class );
Predicate p = cb.equal(root.get( Review_.project ), project );
p = cb.and( p, cb.equal(root.get( Review_.permissionObj ), person ));
cq.select( root.get( Review_.taskId) ).where(p);
return em.createQuery( cq ).setMaxResults(maxCount).getResultList();
}
public List<String> listPermissionByTask( String taskId, Integer maxCount ) throws Exception {
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery( String.class );
Root<Review> root = cq.from( Review.class );
Predicate p = cb.equal(root.get( Review_.taskId ), taskId );
cq.select(root.get( Review_.permissionObj )).where(p);
return em.createQuery( cq ).setMaxResults(maxCount).getResultList();
}
public List<String> listIdsByTaskAndPerson(String taskId, String person) throws Exception {
if( StringUtils.isEmpty( taskId ) ) {
throw new Exception("task id can not be empty!");
}
if( StringUtils.isEmpty( person ) ) {
throw new Exception("person can not be empty!");
}
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery( String.class );
Root<Review> root = cq.from( Review.class );
Predicate p = cb.equal(root.get( Review_.taskId ), taskId );
p = cb.and( p, cb.equal( root.get( Review_.permissionObj ), person));
cq.select(root.get( Review_.id)).where(p);
return em.createQuery( cq ).getResultList();
}
public List<Review> listByTaskAndPerson(String taskId, String person) throws Exception {
if( StringUtils.isEmpty( taskId ) ) {
throw new Exception("task id can not be empty!");
}
if( StringUtils.isEmpty( person ) ) {
throw new Exception("person can not be empty!");
}
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Review> cq = cb.createQuery( Review.class );
Root<Review> root = cq.from( Review.class );
Predicate p = cb.equal(root.get( Review_.taskId ), taskId );
p = cb.and( p, cb.equal( root.get( Review_.permissionObj ), person));
return em.createQuery( cq.where(p) ).getResultList();
}
public Long countByTask(String taskId) throws Exception {
if( StringUtils.isEmpty( taskId ) ) {
throw new Exception("task id can not be empty!");
}
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Review> root = cq.from(Review.class);
Predicate p = cb.equal( root.get(Review_.taskId), taskId );
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
public Long countWithFilter(String personName, QueryFilter queryFilter) throws Exception {
if( StringUtils.isEmpty( personName ) ) {
return 0L;
}
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Review> root = cq.from(Review.class);
Predicate p_permission = cb.equal( root.get(Review_.permissionObj), personName );
Predicate p = CriteriaBuilderTools.composePredicateWithQueryFilter( Review_.class, cb, p_permission, root, queryFilter );
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
public List<Review> listWithFilter( Integer maxCount, String orderField, String orderType, String personName, QueryFilter queryFilter) throws Exception {
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Review> cq = cb.createQuery(Review.class);
Root<Review> root = cq.from(Review.class);
Predicate p_permission = null;
if( StringUtils.isNotEmpty( personName )) {
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.equal( root.get( Review_.permissionObj ), personName ));
}
Predicate p = CriteriaBuilderTools.composePredicateWithQueryFilter( Review_.class, cb, p_permission, root, queryFilter );
//排序,添加排序列,默认使用sequence
List<Order> orders = new ArrayList<>();
Order orderWithField = CriteriaBuilderTools.getOrder( cb, root, Review_.class, orderField, orderType );
if( orderWithField != null ){
orders.add( orderWithField );
}
if( !Review.taskSequence_FIELDNAME.equalsIgnoreCase( orderField )) {
//如果是其他的列,很可能排序值不唯一,所以使用多一列排序列来确定每次查询的顺序
orderWithField = CriteriaBuilderTools.getOrder( cb, root, Review_.class, Review.id_FIELDNAME, orderType );
if( orderWithField != null ){
orders.add( orderWithField );
}
}
if( ListTools.isNotEmpty( orders )){
cq.orderBy( orders );
}
return em.createQuery(cq.where(p)).setMaxResults( maxCount).getResultList();
}
public List<String> checkTaskIdsWithPermission(List<String> taskIds, String personName) throws Exception {
if( ListTools.isEmpty( taskIds ) ) {
throw new Exception("taskIds can not be empty!");
}
if( StringUtils.isEmpty( personName ) ) {
throw new Exception("personName can not be empty!");
}
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery( String.class );
Root<Review> root = cq.from( Review.class );
Predicate p = cb.equal( root.get( Review_.permissionObj ), personName );
p = cb.and( p, root.get( Review_.taskId ).in( taskIds ));
cq.select(root.get( Review_.taskId)).where(p);
return em.createQuery( cq ).getResultList();
}
public List<Review> listTaskWithPersonAndParentId(String person, String taskId) throws Exception {
if( StringUtils.isEmpty( person ) ) {
throw new Exception("person can not be empty!");
}
if( StringUtils.isEmpty( taskId ) ) {
throw new Exception("taskId can not be empty!");
}
EntityManager em = this.entityManagerContainer().get( Review.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Review> cq = cb.createQuery( Review.class );
Root<Review> root = cq.from( Review.class );
Predicate p = cb.equal( root.get( Review_.permissionObj ), person );
p = cb.and( p, cb.equal( root.get( Review_.parent ), taskId ));
return em.createQuery( cq.where(p) ).getResultList();
}
}
\ No newline at end of file
package com.x.teamwork.assemble.control.factory;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.teamwork.assemble.control.AbstractFactory;
import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.SystemConfig;
import com.x.teamwork.core.entity.SystemConfig_;
public class SystemConfigFactory extends AbstractFactory {
public SystemConfigFactory( Business business) throws Exception {
super(business);
}
public SystemConfig get( String id ) throws Exception {
return this.entityManagerContainer().find(id, SystemConfig.class, ExceptionWhen.none);
}
public List<SystemConfig> listAll() throws Exception {
EntityManager em = this.entityManagerContainer().get(SystemConfig.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<SystemConfig> cq = cb.createQuery(SystemConfig.class);
@SuppressWarnings("unused")
Root<SystemConfig> root = cq.from( SystemConfig.class);
return em.createQuery(cq).getResultList();
}
public List<SystemConfig> list(List<String> ids) throws Exception {
if( ids == null || ids.size() == 0 ){
return new ArrayList<SystemConfig>();
}
EntityManager em = this.entityManagerContainer().get(SystemConfig.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<SystemConfig> cq = cb.createQuery(SystemConfig.class);
Root<SystemConfig> root = cq.from(SystemConfig.class);
Predicate p = root.get( SystemConfig_.id).in(ids);
return em.createQuery(cq.where(p)).getResultList();
}
public List<String> listIdsByCode(String code) throws Exception {
if( code == null || code.isEmpty() ){
return null;
}
EntityManager em = this.entityManagerContainer().get(SystemConfig.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<SystemConfig> root = cq.from(SystemConfig.class);
Predicate p = cb.equal(root.get(SystemConfig_.configCode), code);
cq.select(root.get(SystemConfig_.id));
return em.createQuery(cq.where(p)).getResultList();
}
public SystemConfig getWithConfigCode( String configCode ) throws Exception {
if( configCode == null || configCode.isEmpty() ){
return null;
}
SystemConfig attendanceSetting = null;
List<SystemConfig> settingList = null;
EntityManager em = this.entityManagerContainer().get(SystemConfig.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<SystemConfig> cq = cb.createQuery(SystemConfig.class);
Root<SystemConfig> root = cq.from(SystemConfig.class);
Predicate p = cb.equal(root.get( SystemConfig_.configCode ), configCode );
settingList = em.createQuery(cq.where(p)).getResultList();
if( settingList != null && settingList.size() > 0 ){
attendanceSetting = settingList.get(0);
}
return attendanceSetting;
}
}
\ No newline at end of file
package com.x.teamwork.assemble.control.jaxrs;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import com.x.base.core.project.jaxrs.AbstractActionApplication;
import com.x.teamwork.assemble.control.jaxrs.attachment.AttachmentAction;
import com.x.teamwork.assemble.control.jaxrs.chat.ChatAction;
import com.x.teamwork.assemble.control.jaxrs.config.SystemConfigAction;
import com.x.teamwork.assemble.control.jaxrs.dynamic.DynamicAction;
import com.x.teamwork.assemble.control.jaxrs.extfield.ProjectExtFieldReleAction;
import com.x.teamwork.assemble.control.jaxrs.list.TaskListAction;
import com.x.teamwork.assemble.control.jaxrs.project.ProjectAction;
import com.x.teamwork.assemble.control.jaxrs.projectgroup.ProjectGroupAction;
import com.x.teamwork.assemble.control.jaxrs.task.TaskAction;
import com.x.teamwork.assemble.control.jaxrs.taskgroup.TaskGroupAction;
import com.x.teamwork.assemble.control.jaxrs.tasktag.TaskTagAction;
import com.x.teamwork.assemble.control.jaxrs.taskview.TaskViewAction;
@ApplicationPath("jaxrs")
public class ActionApplication extends AbstractActionApplication {
public Set<Class<?>> getClasses() {
this.classes.add( ProjectAction.class );
this.classes.add( TaskAction.class );
this.classes.add( TaskTagAction.class );
this.classes.add( TaskViewAction.class );
this.classes.add( AttachmentAction.class );
this.classes.add( ProjectGroupAction.class );
this.classes.add( TaskGroupAction.class );
this.classes.add( TaskListAction.class );
this.classes.add( DynamicAction.class );
this.classes.add( ChatAction.class );
this.classes.add( SystemConfigAction.class );
this.classes.add( ProjectExtFieldReleAction.class );
return this.classes;
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册