提交 b5c1478f 编写于 作者: L luojing

teamwork后台服务

上级 95264445
......@@ -11,6 +11,7 @@ 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.PriorityFactory;
import com.x.teamwork.assemble.control.factory.ProjectExtFieldReleFactory;
import com.x.teamwork.assemble.control.factory.ProjectFactory;
import com.x.teamwork.assemble.control.factory.ProjectGroupFactory;
......@@ -56,6 +57,7 @@ public class Business {
private BatchOperationFactory batchOperationFactory;
private TaskTagFactory taskTagFactory;
private AttachmentFactory attachmentFactory;
private PriorityFactory priorityFactory;
public Organization organization() throws Exception {
if (null == this.organization) {
......@@ -196,6 +198,18 @@ public class Business {
return projectGroupFactory;
}
/**
* 获取优先级数据库访问类
* @return
* @throws Exception
*/
public PriorityFactory priorityFactory() throws Exception {
if (null == this.priorityFactory) {
this.priorityFactory = new PriorityFactory( this );
}
return priorityFactory;
}
/**
* 获取项目模板数据库访问类
* @return
......
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.Priority;
import com.x.teamwork.core.entity.Priority_;
import com.x.teamwork.core.entity.ProjectGroup;
import com.x.teamwork.core.entity.ProjectGroup_;
public class PriorityFactory extends AbstractFactory {
public PriorityFactory( Business business ) throws Exception {
super(business);
}
/**
* 获取指定Id的ProjectGroup实体信息对象
* @param id
* @return
* @throws Exception
*/
public Priority get( String id ) throws Exception {
return this.entityManagerContainer().find( id, Priority.class, ExceptionWhen.none );
}
/**
* 列示指定Id的ProjectGroup实体信息列表
* @param ids
* @return
* @throws Exception
*/
public List<Priority> list( List<String> ids ) throws Exception {
if( ids == null || ids.size() == 0 ){
return new ArrayList<Priority>();
}
EntityManager em = this.entityManagerContainer().get(Priority.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Priority> cq = cb.createQuery(Priority.class);
Root<Priority> root = cq.from(Priority.class);
Predicate p = root.get(Priority_.id).in(ids);
cq.orderBy( cb.desc( root.get( Priority_.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();
}
/**
* 根据用户列示Priority实体信息列表
* @param person
* @return
* @throws Exception
*/
public List<Priority> listPriorityByPerson( String person ) throws Exception {
EntityManager em = this.entityManagerContainer().get(Priority.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Priority> cq = cb.createQuery(Priority.class);
Root<Priority> root = cq.from(Priority.class);
//Predicate p = cb.equal( root.get(Priority_.owner), person );
return em.createQuery(cq).getResultList();
}
}
......@@ -20,6 +20,8 @@ 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.Task;
import com.x.teamwork.core.entity.Task_;
import com.x.teamwork.core.entity.tools.CriteriaBuilderTools;
import com.x.teamwork.core.entity.tools.filter.QueryFilter;
......@@ -158,6 +160,28 @@ public class ProjectFactory extends AbstractFactory {
return em.createQuery(cq.where(p)).setMaxResults( maxCount).getResultList();
}
/**
* 根据条件查询符合条件的项目信息ID
* @param projectId
* @param deleted
* @return
* @throws Exception
*/
public List<Task> listAllTasks(String projectId, Boolean deleted) throws Exception {
if( StringUtils.isEmpty( projectId ) ){
return new ArrayList<Task>();
}
EntityManager em = this.entityManagerContainer().get(Task.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Task> cq = cb.createQuery(Task.class);
Root<Task> root = cq.from(Task.class);
Predicate p = root.get(Task_.project).in(projectId);
p = cb.and( p, cb.isFalse( root.get(Task_.deleted )));
cq.orderBy( cb.desc( root.get( Task_.updateTime ) ) );
return em.createQuery(cq.where(p)).getResultList();
}
/**
* 根据条件查询符合条件的项目信息ID,根据上一条的sequnce查询指定数量的信息
* @param maxCount
......
......@@ -10,6 +10,7 @@ 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.global.GlobalAction;
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.projectTemplate.ProjectTemplateAction;
......@@ -39,6 +40,7 @@ public class ActionApplication extends AbstractActionApplication {
this.classes.add( ProjectExtFieldReleAction.class );
this.classes.add( ProjectTemplateAction.class );
this.classes.add( TaskListTemplateAction.class );
this.classes.add( GlobalAction.class );
return this.classes;
}
......
......@@ -18,6 +18,7 @@ import com.x.base.core.project.jaxrs.ManagerUserJaxrsFilter;
"/jaxrs/task_list/*",
"/jaxrs/config/*",
"/jaxrs/extfield/*",
"/jaxrs/global/*",
"/jaxrs/dynamic/*"
}, asyncSupported = true)
public class JaxrsManagerUserFilter extends ManagerUserJaxrsFilter {
......
package com.x.teamwork.assemble.control.jaxrs.global;
import javax.servlet.http.HttpServletRequest;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.teamwork.assemble.control.Business;
public class ActionIsManager extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionIsManager.class);
protected ActionResult<String> execute(HttpServletRequest request, EffectivePerson effectivePerson) throws Exception {
ActionResult<String> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()){
Business business = new Business(emc);
if(business.isManager(effectivePerson)){
result.setData( "yes" );
}else{
result.setData( "no" );
}
} catch (Exception e) {
result.error(e);
logger.error(e, effectivePerson, request, null);
}
return result;
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.teamwork.assemble.control.jaxrs.global;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.teamwork.core.entity.Dynamic;
import com.x.teamwork.core.entity.Priority;
import com.x.teamwork.core.entity.Project;
import com.x.teamwork.core.entity.ProjectGroup;
public class ActionPriorityDelete extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionPriorityDelete.class);
protected ActionResult<Wo> execute(HttpServletRequest request, EffectivePerson effectivePerson, String flag) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Priority priority = null;
Boolean check = true;
Wo wo = new Wo();
if ( StringUtils.isEmpty( flag ) ) {
check = false;
Exception exception = new PriorityFlagForQueryEmptyException();
result.error( exception );
}
if( Boolean.TRUE.equals( check ) ){
try {
priority = priorityQueryService.get(flag);
if ( priority == null) {
check = false;
Exception exception = new PriorityNotExistsException(flag);
result.error( exception );
}
} catch (Exception e) {
check = false;
Exception exception = new PriorityQueryException(e, "根据指定flag查询优先级信息对象时发生异常。flag:" + flag);
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
if( Boolean.TRUE.equals( check ) ){
try {
priorityPersistService.delete(flag, effectivePerson );
// 更新缓存
ApplicationCache.notify( Priority.class );
wo.setId( priority.getId() );
} catch (Exception e) {
check = false;
Exception exception = new PriorityQueryException(e, "根据指定flag删除优先级信息对象时发生异常。flag:" + flag);
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
result.setData( wo );
return result;
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.teamwork.assemble.control.jaxrs.global;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.entity.JpaObject;
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.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.Priority;
import com.x.teamwork.core.entity.ProjectGroup;
import net.sf.ehcache.Element;
public class ActionPriorityGet extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionPriorityGet.class);
protected ActionResult<Wo> execute(HttpServletRequest request, EffectivePerson effectivePerson, String id ) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
Priority priority = null;
Boolean check = true;
if ( StringUtils.isEmpty( id ) ) {
check = false;
Exception exception = new PriorityFlagForQueryEmptyException();
result.error( exception );
}
if( Boolean.TRUE.equals( check ) ){
try {
priority = priorityQueryService.get( id );
if ( priority == null) {
check = false;
Exception exception = new PriorityNotExistsException( id );
result.error( exception );
}
} catch (Exception e) {
check = false;
Exception exception = new PriorityQueryException(e, "根据指定flag查询优先级信息对象时发生异常。id:" + id );
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
if( Boolean.TRUE.equals( check ) ){
try {
wo = Wo.copier.copy( priority );
result.setData(wo);
} catch (Exception e) {
Exception exception = new PriorityQueryException(e, "将查询出来的优先级信息对象转换为可输出的数据信息时发生异常。");
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
return result;
}
public static class Wo extends Priority {
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
static WrapCopier<Priority, Wo> copier = WrapCopierFactory.wo( Priority.class, Wo.class, null, ListTools.toList(JpaObject.FieldsInvisible));
}
}
\ No newline at end of file
package com.x.teamwork.assemble.control.jaxrs.global;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.x.base.core.entity.JpaObject;
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.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.base.core.project.tools.SortTools;
import com.x.teamwork.core.entity.Priority;
import com.x.teamwork.core.entity.ProjectGroup;
import net.sf.ehcache.Element;
public class ActionPriorityList extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionPriorityList.class);
@SuppressWarnings("unchecked")
protected ActionResult<List<Wo>> execute(HttpServletRequest request, EffectivePerson effectivePerson ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wos = null;
List<Priority> prioritys = null;
try {
prioritys = priorityQueryService.listPriorityByPerson( effectivePerson.getDistinguishedName() );
if( ListTools.isNotEmpty( prioritys )) {
wos = Wo.copier.copy( prioritys );
SortTools.asc( wos, "createTime");
result.setData(wos);
}
result.setData(wos);
} catch (Exception e) {
Exception exception = new PriorityQueryException(e, "根据用户拥有的优先级信息列表时发生异常。");
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
return result;
}
public static class Wo extends Priority {
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<Priority, Wo> copier = WrapCopierFactory.wo( Priority.class, Wo.class, null, ListTools.toList(JpaObject.FieldsInvisible));
}
}
\ No newline at end of file
package com.x.teamwork.assemble.control.jaxrs.global;
import javax.servlet.http.HttpServletRequest;
import com.google.gson.JsonElement;
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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.teamwork.core.entity.Priority;
public class ActionPrioritySave extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionPrioritySave.class);
protected ActionResult<Wo> execute(HttpServletRequest request, EffectivePerson effectivePerson, JsonElement jsonElement ) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Priority priority = null;
Wi wi = null;
Wo wo = new Wo();
try {
wi = this.convertToWrapIn( jsonElement, Wi.class );
} catch (Exception e) {
Exception exception = new PriorityPersistException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
try {
priority = priorityPersistService.save( wi, effectivePerson );
// 更新缓存
ApplicationCache.notify( Priority.class );
wo.setId( priority.getId() );
} catch (Exception e) {
Exception exception = new PriorityPersistException(e, "优先级信息保存时发生异常。");
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
result.setData( wo );
return result;
}
public static class Wi extends Priority {
private static final long serialVersionUID = -6314932919066148113L;
public static WrapCopier<Wi, Priority> copier = WrapCopierFactory.wi( Wi.class, Priority.class, null, null );
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.teamwork.assemble.control.jaxrs.global;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.teamwork.assemble.control.service.DynamicPersistService;
import com.x.teamwork.assemble.control.service.PriorityPersistService;
import com.x.teamwork.assemble.control.service.PriorityQueryService;
import com.x.teamwork.assemble.control.service.SystemConfigQueryService;
import com.x.teamwork.core.entity.Priority;
import net.sf.ehcache.Ehcache;
public class BaseAction extends StandardJaxrsAction {
protected Ehcache priorityCache = ApplicationCache.instance().getCache( Priority.class );
protected PriorityQueryService priorityQueryService = new PriorityQueryService();
protected PriorityPersistService priorityPersistService = new PriorityPersistService();
protected DynamicPersistService dynamicPersistService = new DynamicPersistService();
protected SystemConfigQueryService systemConfigQueryService = new SystemConfigQueryService();
}
package com.x.teamwork.assemble.control.jaxrs.global;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
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;
@Path("global")
@JaxrsDescribe("全局信息管理")
public class GlobalAction extends StandardJaxrsAction {
private Logger logger = LoggerFactory.getLogger(GlobalAction.class);
@JaxrsMethodDescribe(value = "查询当前用户是否具有管理员权限.", action = ActionIsManager.class)
@GET
@Path("isManager")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void isManager(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request ) {
ActionResult<String> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionIsManager().execute( request, effectivePerson );
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "根据ID查询优先级信息.", action = ActionPriorityGet.class)
@GET
@Path("priority/{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void priorityGet(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("优先级ID") @PathParam("id") String id ) {
ActionResult<ActionPriorityGet.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionPriorityGet().execute( request, effectivePerson, id );
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "查询所有优先级信息列表.", action = ActionPriorityList.class)
@GET
@Path("priority/list")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void priorityList(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request ) {
ActionResult<List<ActionPriorityList.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionPriorityList().execute( request, effectivePerson );
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "创建或者更新一个优先级信息.", action = ActionPrioritySave.class)
@POST
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void prioritySave(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("需要保存的优先级信息") JsonElement jsonElement ) {
ActionResult<ActionPrioritySave.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionPrioritySave().execute(request, effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "根据标识删除优先级信息.", action = ActionPriorityDelete.class)
@DELETE
@Path("priority/{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void priorityDelete(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id ) {
ActionResult<ActionPriorityDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionPriorityDelete().execute(request, effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
package com.x.teamwork.assemble.control.jaxrs.global;
import com.x.base.core.project.exception.PromptException;
class PriorityFlagForQueryEmptyException extends PromptException {
private static final long serialVersionUID = 1859164370743532895L;
PriorityFlagForQueryEmptyException() {
super("查询的优先级组信息ID为空,无法继续查询数据。" );
}
}
package com.x.teamwork.assemble.control.jaxrs.global;
import com.x.base.core.project.exception.PromptException;
class PriorityNotExistsException extends PromptException {
private static final long serialVersionUID = 1859164370743532895L;
PriorityNotExistsException( String id ) {
super("指定ID的优先级信息不存在。ID:" + id );
}
}
package com.x.teamwork.assemble.control.jaxrs.global;
import com.x.base.core.project.exception.PromptException;
class PriorityPersistException extends PromptException {
private static final long serialVersionUID = 1859164370743532895L;
PriorityPersistException( Throwable e ) {
super("系统在保存项目组信息时发生异常。" , e );
}
PriorityPersistException( Throwable e, String message ) {
super("系统在保存项目组信息时发生异常。Message:" + message, e );
}
PriorityPersistException( String message ) {
super("系统在保存项目组信息时发生异常。Message:" + message );
}
}
package com.x.teamwork.assemble.control.jaxrs.global;
import com.x.base.core.project.exception.PromptException;
class PriorityQueryException extends PromptException {
private static final long serialVersionUID = 1859164370743532895L;
PriorityQueryException( Throwable e ) {
super("系统在查询优先级信息时发生异常。" , e );
}
PriorityQueryException( Throwable e, String message ) {
super("系统在查询优先级信息时发生异常。Message:" + message, e );
}
}
......@@ -14,6 +14,7 @@ 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.Project;
import com.x.teamwork.core.entity.TaskList;
......@@ -32,7 +33,7 @@ public class ActionListWithTaskGroup extends BaseAction {
if ((null != element) && (null != element.getObjectValue())) {
System.out.println("111");
wos = (List<Wo>) element.getObjectValue();
wos = (List<Wo>) element.getObjectValue();
result.setData( wos );
} else {*/
if( Boolean.TRUE.equals( check ) ){
......@@ -49,6 +50,11 @@ public class ActionListWithTaskGroup extends BaseAction {
}else {
wo.setControl( new Control(true, true, true, true ));
}
Project project = null;
project = projectQueryService.get(wo.getProject());
if(project != null && (project.getDeleted() || project.getCompleted())){
wo.setControl( new Control(false, false, false, false ));
}
}
}
//taskListCache.put(new Element(cacheKey, wos));
......
......@@ -3,6 +3,7 @@ package com.x.teamwork.assemble.control.jaxrs.list;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.teamwork.assemble.control.service.DynamicPersistService;
import com.x.teamwork.assemble.control.service.ProjectQueryService;
import com.x.teamwork.assemble.control.service.SystemConfigQueryService;
import com.x.teamwork.assemble.control.service.TaskGroupQueryService;
import com.x.teamwork.assemble.control.service.TaskListPersistService;
......@@ -31,4 +32,6 @@ public class BaseAction extends StandardJaxrsAction {
protected SystemConfigQueryService systemConfigQueryService = new SystemConfigQueryService();
protected ProjectQueryService projectQueryService = new ProjectQueryService();
}
package com.x.teamwork.assemble.control.jaxrs.project;
import javax.servlet.http.HttpServletRequest;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.teamwork.core.entity.Project;
public class ActionComplete extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionComplete.class);
protected ActionResult<Wo> execute(HttpServletRequest request, EffectivePerson effectivePerson, String projectId, JsonElement jsonElement ) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = null;
Project project = null;
Boolean check = true;
try {
wi = this.convertToWrapIn( jsonElement, Wi.class );
} catch (Exception e) {
check = false;
Exception exception = new ProjectPersistException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
if( Boolean.TRUE.equals( check ) ){
try {
project = projectQueryService.get( projectId );
if ( project == null) {
check = false;
Exception exception = new ProjectNotExistsException( projectId );
result.error( exception );
}
} catch (Exception e) {
check = false;
Exception exception = new ProjectQueryException(e, "根据指定flag查询应用项目信息对象时发生异常。ID:" + projectId );
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
if( Boolean.TRUE.equals( check ) ){
try {
projectPersistService.completeProject( projectId,wi.getCompleted());
// 更新缓存
ApplicationCache.notify( Project.class );
Wo wo = new Wo();
wo.setId( project.getId() );
result.setData( wo );
} catch (Exception e) {
check = false;
Exception exception = new ProjectPersistException(e, "项目状态信息更新时发生异常。");
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
try {
dynamicPersistService.projectCompleteDynamic( project, effectivePerson ,wi.getCompleted());
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
}
}
return result;
}
public static class Wi {
@FieldDescribe("已完成/未完成")
private Boolean completed = true;
public Boolean getCompleted() {
return completed;
}
public void setCompleted(Boolean completed) {
this.completed = completed;
}
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
package com.x.teamwork.assemble.control.jaxrs.project;
import javax.servlet.http.HttpServletRequest;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.teamwork.core.entity.Project;
public class ActionCreateable extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionCreateable.class);
protected ActionResult<Wo> execute(HttpServletRequest request, EffectivePerson effectivePerson, String projectId, JsonElement jsonElement ) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = null;
Project project = null;
Boolean check = true;
try {
wi = this.convertToWrapIn( jsonElement, Wi.class );
} catch (Exception e) {
check = false;
Exception exception = new ProjectPersistException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
if( Boolean.TRUE.equals( check ) ){
try {
project = projectQueryService.get( projectId );
if ( project == null) {
check = false;
Exception exception = new ProjectNotExistsException( projectId );
result.error( exception );
}
} catch (Exception e) {
check = false;
Exception exception = new ProjectQueryException(e, "根据指定flag查询应用项目信息对象时发生异常。ID:" + projectId );
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
if( Boolean.TRUE.equals( check ) ){
try {
projectPersistService.createableProject( projectId,wi.getCreateable());
// 更新缓存
ApplicationCache.notify( Project.class );
Wo wo = new Wo();
wo.setId( project.getId() );
result.setData( wo );
} catch (Exception e) {
check = false;
Exception exception = new ProjectPersistException(e, "项目状态信息更新时发生异常。");
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
try {
dynamicPersistService.projectCreateableDynamic( project, effectivePerson ,wi.getCreateable());
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
}
}
return result;
}
public static class Wi {
@FieldDescribe("是否可新建任务")
private Boolean createable = true;
public Boolean getCreateable() {
return createable;
}
public void setCreateable(Boolean createable) {
this.createable = createable;
}
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
......@@ -10,9 +10,9 @@ import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
......@@ -22,8 +22,8 @@ import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.Project;
import com.x.teamwork.core.entity.ProjectDetail;
import com.x.teamwork.core.entity.ProjectGroup;
import com.x.teamwork.core.entity.Task;
import net.sf.ehcache.Element;
public class ActionGet extends BaseAction {
......@@ -36,8 +36,14 @@ public class ActionGet extends BaseAction {
ProjectDetail projectDetail = null;
List<String> groupIds = null;
List<ProjectGroup> groups = null;
List<Task> taskList = null;
WrapOutControl control = null;
Boolean check = true;
Integer taskTotal = 0;
Integer progressTotal = 0;
Integer completedTotal = 0;
Integer overtimeTotal = 0;
if ( StringUtils.isEmpty( flag ) ) {
check = false;
......@@ -68,6 +74,25 @@ public class ActionGet extends BaseAction {
}
}
if( Boolean.TRUE.equals( check ) ){
taskList = projectQueryService.listAllTasks(flag , true);
if( ListTools.isNotEmpty( taskList )) {
for( Task task : taskList ) {
taskTotal ++;
if( "completed".equalsIgnoreCase(task.getWorkStatus()) ) {
completedTotal++;
}
if( "processing".equalsIgnoreCase(task.getWorkStatus()) ) {
progressTotal++;
}
if( task.getOvertime() ) {
overtimeTotal++;
}
}
}
}
if( Boolean.TRUE.equals( check ) ){
try {
wo = Wo.copier.copy( project );
......@@ -89,6 +114,7 @@ public class ActionGet extends BaseAction {
try (EntityManagerContainer bc = EntityManagerContainerFactory.instance().create()) {
business = new Business(bc);
}
control = new WrapOutControl();
if( business.isManager(effectivePerson)
|| effectivePerson.getDistinguishedName().equalsIgnoreCase( project.getCreatorPerson() )
......@@ -96,10 +122,20 @@ public class ActionGet extends BaseAction {
control.setDelete( true );
control.setEdit( true );
control.setSortable( true );
control.setCreateable(true);
}else{
control.setDelete( false );
control.setEdit( false );
control.setSortable( false );
if(project.getCreateable()){
control.setCreateable(true);
}else{
control.setCreateable(false);
}
}
if(project.getDeleted() || project.getCompleted()){
control.setCreateable(false);
}
if(effectivePerson.getDistinguishedName().equalsIgnoreCase( project.getCreatorPerson())){
control.setFounder( true );
......@@ -107,7 +143,11 @@ public class ActionGet extends BaseAction {
control.setFounder( false );
}
wo.setControl(control);
//projectCache.put(new Element(cacheKey, wo));
wo.setProgressTotal(progressTotal);
wo.setCompletedTotal(completedTotal);
wo.setOvertimeTotal(overtimeTotal);
wo.setTaskTotal(taskTotal);
result.setData(wo);
} catch (Exception e) {
Exception exception = new ProjectQueryException(e, "将查询出来的应用项目信息对象转换为可输出的数据信息时发生异常。");
......@@ -122,6 +162,51 @@ public class ActionGet extends BaseAction {
public static class Wo extends WrapOutProject {
private static final long serialVersionUID = -5076990764713538973L;
@FieldDescribe("所有任务数量")
private Integer taskTotal = 0;
@FieldDescribe("执行中任务数量")
private Integer progressTotal = 0;
@FieldDescribe("已完成任务数量")
private Integer completedTotal = 0;
@FieldDescribe("超时任务数量")
private Integer overtimeTotal = 0;
public Integer getTaskTotal() {
return taskTotal;
}
public void setTaskTotal(Integer taskTotal) {
this.taskTotal = taskTotal;
}
public Integer getProgressTotal() {
return progressTotal;
}
public void setProgressTotal(Integer progressTotal) {
this.progressTotal = progressTotal;
}
public Integer getCompletedTotal() {
return completedTotal;
}
public void setCompletedTotal( Integer completedTotal ) {
this.completedTotal = completedTotal;
}
public Integer getOvertimeTotal() {
return overtimeTotal;
}
public void setOvertimeTotal( Integer overtimeTotal ) {
this.overtimeTotal = overtimeTotal;
}
public static List<String> Excludes = new ArrayList<String>();
......
package com.x.teamwork.assemble.control.jaxrs.project;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.teamwork.core.entity.Project;
public class ActionRecovery extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionRecovery.class);
protected ActionResult<Wo> execute(HttpServletRequest request, EffectivePerson effectivePerson, String projectId) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Project project = null;
Boolean check = true;
if ( StringUtils.isEmpty( projectId )) {
check = false;
Exception exception = new ProjectFlagForQueryEmptyException();
result.error( exception );
}
if( Boolean.TRUE.equals( check ) ){
try {
project = projectQueryService.get( projectId );
if ( project == null) {
check = false;
Exception exception = new ProjectNotExistsException( projectId );
result.error( exception );
}
} catch (Exception e) {
check = false;
Exception exception = new ProjectQueryException(e, "根据指定flag查询应用项目信息对象时发生异常。ID:" + projectId );
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
if( Boolean.TRUE.equals( check ) ){
try {
projectPersistService.recoveryProject( projectId);
// 更新缓存
ApplicationCache.notify( Project.class );
Wo wo = new Wo();
wo.setId( project.getId() );
result.setData( wo );
} catch (Exception e) {
check = false;
Exception exception = new ProjectPersistException(e, "项目图标信息更新时发生异常。");
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
try {
dynamicPersistService.projectRecoveryDynamic( project, effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
}
}
return result;
}
public static class Wo extends WoId {
}
}
\ No newline at end of file
......@@ -367,6 +367,45 @@ public class ProjectAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "根据标识恢复项目.", action = ActionRecovery.class)
@GET
@Path("{id}/recovery")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void recoveryProject(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionRecovery.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionRecovery().execute(request, effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "根据标识更改项目状态为已完成或未完成.", action = ActionComplete.class)
@PUT
@Path("{id}/complete")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void completeProject(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id,
@JaxrsParameterDescribe("需要保存的项目状态信息") JsonElement jsonElement ) {
ActionResult<ActionComplete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionComplete().execute(request, effectivePerson, id, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "根据标识删除项目信息.", action = ActionDelete.class)
@DELETE
@Path("{id}")
......
......@@ -16,6 +16,9 @@ public class WrapOutControl {
@FieldDescribe("是否创始人")
private Boolean founder = false;
@FieldDescribe("是否可新建任务")
private Boolean createable = false;
public Boolean getDelete() {
return delete;
}
......@@ -48,4 +51,12 @@ public class WrapOutControl {
this.founder = founder;
}
public Boolean getCreateable() {
return createable;
}
public void setCreateable(Boolean createable) {
this.createable = createable;
}
}
......@@ -115,6 +115,9 @@ public class ActionCopyTask extends BaseAction {
//调整负责人为当前用户
newTask.setExecutor(effectivePerson.getDistinguishedName());
newTask.setExecutorIdentity(userManagerService.getIdentityWithPerson( newTask.getExecutor(), "min"));
//调整创建人为当前用户
newTask.setCreatorPerson(effectivePerson.getDistinguishedName());
//调整ID
newTask.setId( Task.createId() );
......
......@@ -144,17 +144,16 @@ public class ActionGet extends BaseAction {
control = new WrapOutControl();
if( business.isManager(effectivePerson)
|| effectivePerson.getDistinguishedName().equalsIgnoreCase( task.getCreatorPerson() )
|| task.getManageablePersonList().contains( effectivePerson.getDistinguishedName() )){
control.setDelete( true );
control.setEdit( true );
|| (ListTools.isNotEmpty(task.getManageablePersonList()) && task.getManageablePersonList().contains( effectivePerson.getDistinguishedName() ))){
control.setDelete( true );
control.setSortable( true );
control.setChangeExecutor( true );
}else{
control.setDelete( false );
control.setEdit( false );
control.setSortable( false );
control.setChangeExecutor( false );
}
control.setEdit( true );
if(effectivePerson.getDistinguishedName().equalsIgnoreCase( task.getExecutor())){
control.setChangeExecutor( true );
}
......@@ -163,6 +162,16 @@ public class ActionGet extends BaseAction {
}else{
control.setFounder( false );
}
Project project = null;
project = projectQueryService.get(wo.getProject());
if(project != null && (project.getDeleted() || project.getCompleted())){
control.setEdit( false );
control.setDelete( false );
control.setSortable( false );
control.setChangeExecutor( false );
}
wo.setControl(control);
} catch (Exception e) {
check = false;
......
......@@ -80,17 +80,16 @@ public class ActionListMyTaskWithTaskList extends BaseAction {
control = new WrapOutControl();
if( business.isManager(effectivePerson)
|| effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getCreatorPerson() )
|| wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() )){
|| (ListTools.isNotEmpty(wo.getManageablePersonList()) && wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() ))){
control.setDelete( true );
control.setEdit( true );
control.setSortable( true );
control.setChangeExecutor(true);
}else{
control.setDelete( false );
control.setEdit( false );
control.setSortable( false );
control.setChangeExecutor(false);
}
control.setEdit( true );
if(effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getExecutor())){
control.setChangeExecutor( true );
}
......
......@@ -110,17 +110,16 @@ public class ActionListNextWithFilter extends BaseAction {
control = new WrapOutControl();
if( business.isManager(effectivePerson)
|| effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getCreatorPerson() )
|| wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() )){
control.setDelete( true );
control.setEdit( true );
|| (ListTools.isNotEmpty(wo.getManageablePersonList()) && wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() ))){
control.setDelete( true );
control.setSortable( true );
control.setChangeExecutor(true);
}else{
control.setDelete( false );
control.setEdit( false );
control.setSortable( false );
control.setChangeExecutor(false);
}
control.setEdit( true );
if(effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getExecutor())){
control.setChangeExecutor( true );
}
......
......@@ -106,17 +106,16 @@ public class ActionListPageWithFilter extends BaseAction {
control = new WrapOutControl();
if( business.isManager(effectivePerson)
|| effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getCreatorPerson() )
|| wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() )){
|| (ListTools.isNotEmpty(wo.getManageablePersonList()) && wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() ))){
control.setDelete( true );
control.setEdit( true );
control.setSortable( true );
control.setChangeExecutor(true);
}else{
control.setDelete( false );
control.setEdit( false );
control.setSortable( false );
control.setChangeExecutor(false);
}
control.setEdit( true );
if(effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getExecutor())){
control.setChangeExecutor( true );
}
......
......@@ -81,17 +81,16 @@ public class ActionListWithTaskList extends BaseAction {
control = new WrapOutControl();
if( business.isManager(effectivePerson)
|| effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getCreatorPerson() )
|| wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() )){
control.setDelete( true );
control.setEdit( true );
|| (ListTools.isNotEmpty(wo.getManageablePersonList()) && wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() ))){
control.setDelete( true );
control.setSortable( true );
control.setChangeExecutor(true);
}else{
control.setDelete( false );
control.setEdit( false );
control.setSortable( false );
control.setChangeExecutor(false);
}
control.setEdit( true );
if(effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getExecutor())){
control.setChangeExecutor( true );
}
......
......@@ -103,17 +103,16 @@ public class ActionViewAllListNextWithFilter extends BaseAction {
control = new WrapOutControl();
if( business.isManager(effectivePerson)
|| effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getCreatorPerson() )
|| wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() )){
|| (ListTools.isNotEmpty(wo.getManageablePersonList()) && wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() ))){
control.setDelete( true );
control.setEdit( true );
control.setSortable( true );
control.setChangeExecutor(true);
}else{
control.setDelete( false );
control.setEdit( false );
control.setSortable( false );
control.setChangeExecutor(false);
}
control.setEdit( true );
if(effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getExecutor())){
control.setChangeExecutor( true );
}
......
......@@ -104,17 +104,16 @@ public class ActionViewCompletedListNextWithFilter extends BaseAction {
control = new WrapOutControl();
if( business.isManager(effectivePerson)
|| effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getCreatorPerson() )
|| wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() )){
control.setDelete( true );
control.setEdit( true );
|| (ListTools.isNotEmpty(wo.getManageablePersonList()) && wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() ))){
control.setDelete( true );
control.setSortable( true );
control.setChangeExecutor(true);
}else{
control.setDelete( false );
control.setEdit( false );
control.setSortable( false );
control.setChangeExecutor(false);
}
control.setEdit( true );
if(effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getExecutor())){
control.setChangeExecutor( true );
}
......
......@@ -104,17 +104,16 @@ public class ActionViewMyExecutListNextWithFilter extends BaseAction {
control = new WrapOutControl();
if( business.isManager(effectivePerson)
|| effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getCreatorPerson() )
|| wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() )){
control.setDelete( true );
control.setEdit( true );
|| (ListTools.isNotEmpty(wo.getManageablePersonList()) && wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() ))){
control.setDelete( true );
control.setSortable( true );
control.setChangeExecutor(true);
}else{
control.setDelete( false );
control.setEdit( false );
control.setSortable( false );
control.setChangeExecutor(false);
}
control.setEdit( true );
if(effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getExecutor())){
control.setChangeExecutor( true );
}
......
......@@ -104,17 +104,16 @@ public class ActionViewOverTimeListNextWithFilter extends BaseAction {
control = new WrapOutControl();
if( business.isManager(effectivePerson)
|| effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getCreatorPerson() )
|| wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() )){
|| (ListTools.isNotEmpty(wo.getManageablePersonList()) && wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() ))){
control.setDelete( true );
control.setEdit( true );
control.setSortable( true );
control.setChangeExecutor(true);
}else{
control.setDelete( false );
control.setEdit( false );
control.setSortable( false );
control.setChangeExecutor(false);
}
control.setEdit( true );
if(effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getExecutor())){
control.setChangeExecutor( true );
}
......
......@@ -105,17 +105,16 @@ public class ActionViewUncompletedListNextWithFilter extends BaseAction {
control = new WrapOutControl();
if( business.isManager(effectivePerson)
|| effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getCreatorPerson() )
|| wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() )){
|| (ListTools.isNotEmpty(wo.getManageablePersonList()) && wo.getManageablePersonList().contains( effectivePerson.getDistinguishedName() ))){
control.setDelete( true );
control.setEdit( true );
control.setSortable( true );
control.setChangeExecutor(true);
}else{
control.setDelete( false );
control.setEdit( false );
control.setSortable( false );
control.setChangeExecutor(false);
}
control.setEdit( true );
if(effectivePerson.getDistinguishedName().equalsIgnoreCase( wo.getExecutor())){
control.setChangeExecutor( true );
}
......
......@@ -204,17 +204,17 @@ public class BatchOperationProcessService {
* @throws Exception
*/
private void deleteTaskInProject( String id, String projectId ) throws Exception {
Integer totalWhileCount = 0;
/*Integer totalWhileCount = 0;
Integer currenteWhileCount = 0;
List<String> taskIds = null;
Task task = null;*/
BatchOperation batchOperation = null;
Task task = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
//Business business = new Business(emc);
batchOperation = emc.find( id, BatchOperation.class );
taskIds = business.taskFactory().listByProject(projectId);
/*taskIds = business.taskFactory().listByProject(projectId);
if( ListTools.isNotEmpty( taskIds )) {
for( String taskId : taskIds ) {
......@@ -227,7 +227,7 @@ public class BatchOperationProcessService {
logger.info( "deleteTaskInApp -> task processing batch operation: remove task("+ currenteWhileCount +"/" + totalWhileCount + "): " + taskId );
}
}
}
}*/
if( batchOperation != null ) {
emc.beginTransaction( BatchOperation.class );
emc.remove( batchOperation, CheckRemoveType.all );
......
......@@ -128,6 +128,75 @@ public class DynamicPersistService {
return dynamic;
}
/**
* 恢复项目操作动态
* @param object
* @param effectivePerson
* @return
* @throws Exception
*/
public Dynamic projectRecoveryDynamic( Project object, EffectivePerson effectivePerson ) throws Exception {
if ( object == null) {
throw new Exception("object is null.");
}
if ( effectivePerson == null ) {
throw new Exception("effectivePerson is null.");
}
Dynamic dynamic = dynamicService.getProjectRecoveryDynamic( object, effectivePerson );
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
dynamic = dynamicService.save( emc, dynamic, null );
} catch (Exception e) {
throw e;
}
return dynamic;
}
/**
* 更改项目状态操作动态
* @param object
* @param effectivePerson
* @return
* @throws Exception
*/
public Dynamic projectCompleteDynamic( Project object, EffectivePerson effectivePerson ,Boolean status) throws Exception {
if ( object == null) {
throw new Exception("object is null.");
}
if ( effectivePerson == null ) {
throw new Exception("effectivePerson is null.");
}
Dynamic dynamic = dynamicService.getCompleteDynamic( object, effectivePerson ,status);
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
dynamic = dynamicService.save( emc, dynamic, null );
} catch (Exception e) {
throw e;
}
return dynamic;
}
/**
* 是否可创建任务操作动态
* @param object
* @param effectivePerson
* @return
* @throws Exception
*/
public Dynamic projectCreateableDynamic( Project object, EffectivePerson effectivePerson ,Boolean status) throws Exception {
if ( object == null) {
throw new Exception("object is null.");
}
if ( effectivePerson == null ) {
throw new Exception("effectivePerson is null.");
}
Dynamic dynamic = dynamicService.getCreateableDynamic( object, effectivePerson ,status);
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
dynamic = dynamicService.save( emc, dynamic, null );
} catch (Exception e) {
throw e;
}
return dynamic;
}
/**
* 保存项目扩展信息保存操作动态信息
* @param object_old
......
......@@ -498,6 +498,57 @@ class DynamicService {
return composeNewDynamic( objectType, title, description, viewUrl, optType, object, effectivePerson, false );
}
/**
* 组织一个项目恢复操作动态
* @param object
* @param effectivePerson
* @return
*/
protected Dynamic getProjectRecoveryDynamic( Project object, EffectivePerson effectivePerson ) {
String objectType = "PROJECT";
String title = "项目恢复";
String viewUrl = null;
String optType = "RECOVERY";
String description = effectivePerson.getName() +"恢复了项目:" + object.getTitle();
return composeNewDynamic( objectType, title, description, viewUrl, optType, object, effectivePerson, false );
}
/**
* 组织一个项目更改状态操作动态
* @param object
* @param effectivePerson
* @return
*/
protected Dynamic getCompleteDynamic( Project object, EffectivePerson effectivePerson ,Boolean status) {
String objectType = "PROJECT";
String title = "项目状态更改";
String viewUrl = null;
String optType = "COMPLETE";
String description = effectivePerson.getName() +"项目:" + object.getTitle()+",状态更改为:未完成";
if(status){
description = effectivePerson.getName() +"项目:" + object.getTitle()+",状态更改为:已完成";
}
return composeNewDynamic( objectType, title, description, viewUrl, optType, object, effectivePerson, false );
}
/**
* 组织一个项目更改是否可创建任务操作动态
* @param object
* @param effectivePerson
* @return
*/
protected Dynamic getCreateableDynamic( Project object, EffectivePerson effectivePerson ,Boolean status) {
String objectType = "PROJECT";
String title = "项目权限设置";
String viewUrl = null;
String optType = "CREATEABLE";
String description = effectivePerson.getName() +"项目:" + object.getTitle()+",权限设置为:不可创建任务";
if(status){
description = effectivePerson.getName() +"项目:" + object.getTitle()+",权限设置为:可创建任务";
}
return composeNewDynamic( objectType, title, description, viewUrl, optType, object, effectivePerson, false );
}
/**
* 保存和根据项目组信息操作动态
* @param object_old
......
package com.x.teamwork.assemble.control.service;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.core.entity.Priority;
import com.x.teamwork.core.entity.ProjectGroup;
import com.x.teamwork.core.entity.ProjectGroupRele;
public class PriorityPersistService {
private PriorityService priorityService = new PriorityService();
/**
* 删除优先级信息
* @param flag
* @param effectivePerson
* @throws Exception
*/
public void delete( String id, EffectivePerson effectivePerson ) throws Exception {
if ( StringUtils.isEmpty( id )) {
throw new Exception("id is empty.");
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
priorityService.delete( emc, id );
} catch (Exception e) {
throw e;
}
}
/**
* 保存优先级信息
* @param object
* @param effectivePerson
* @return
* @throws Exception
*/
public Priority save( Priority object, EffectivePerson effectivePerson ) throws Exception {
if ( object == null) {
throw new Exception("object is null.");
}
if ( effectivePerson == null ) {
throw new Exception("effectivePerson is null.");
}
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
object.setOwner( effectivePerson.getDistinguishedName() );
object = priorityService.save( emc, object );
} catch (Exception e) {
throw e;
}
return object;
}
/**
* 将项目添加到项目组中去
* @param projectId
* @param groupId
* @return
* @throws Exception
*/
public ProjectGroupRele addToGroup( String projectId, String groupId ) throws Exception {
if ( StringUtils.isEmpty( projectId )) {
throw new Exception("projectId is empty.");
}
if ( StringUtils.isEmpty( groupId )) {
throw new Exception("groupId is empty.");
}
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
return priorityService.addToGroup(emc, projectId, groupId);
} catch (Exception e) {
throw e;
}
}
/**
* 将项目从项目组中除去
* @param emc
* @param projectId
* @param groupId
* @throws Exception
*/
public void removeFromGroup( String projectId, String groupId ) throws Exception {
if ( StringUtils.isEmpty( projectId )) {
throw new Exception("projectId is empty.");
}
if ( StringUtils.isEmpty( groupId )) {
throw new Exception("groupId is empty.");
}
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
priorityService.removeFromGroup( emc, groupId, projectId );
} catch (Exception e) {
throw e;
}
}
/**
* 先删除项目所有已经关联的项目组,然后再将新的项目组与项目关联
* @param projectId
* @param groups
* @throws Exception
*/
public void releProjectToGroup( String projectId, List<String> groups ) throws Exception {
if ( StringUtils.isEmpty( projectId )) {
return;
}
ProjectGroupRele projectGroupRele = null;
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
//查询项目所有已经关联的项目组关联信息
List<ProjectGroupRele> reles = priorityService.listReleWithProject( emc, projectId );
emc.beginTransaction( ProjectGroupRele.class );
//删除项目所有已经关联的项目组关联信息
if( ListTools.isNotEmpty( reles )) {
for( ProjectGroupRele rele : reles ) {
emc.remove( rele, CheckRemoveType.all );
}
}
//将新的项目组与项目关联
if( ListTools.isNotEmpty( groups )) {
for( String group : groups ) {
projectGroupRele = new ProjectGroupRele();
projectGroupRele.setProjectId( projectId );
projectGroupRele.setGroupId( group );
emc.persist( projectGroupRele, CheckPersistType.all );
}
}
emc.commit();
} catch (Exception e) {
throw e;
}
}
}
package com.x.teamwork.assemble.control.service;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.core.entity.ProjectGroupRele;
import com.x.teamwork.core.entity.Priority;
import com.x.teamwork.core.entity.ProjectGroup;
/**
* 对项目组信息查询的服务
*
* @author O2LEE
*/
public class PriorityQueryService {
private PriorityService priorityService = new PriorityService();
public List<ProjectGroup> list(List<String> groupIds) throws Exception {
if ( ListTools.isEmpty( groupIds )) {
return null;
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
return priorityService.list( emc, groupIds );
} catch (Exception e) {
throw e;
}
}
/**
* 根据项目组的标识查询项目组信息
* @param id
* @return
* @throws Exception
*/
public Priority get( String id ) throws Exception {
if ( StringUtils.isEmpty( id )) {
return null;
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
return priorityService.get(emc, id );
} catch (Exception e) {
throw e;
}
}
/**
* 根据用户列示优先级信息列表
* @param person
* @return
* @throws Exception
*/
public List<Priority> listPriorityByPerson( String person ) throws Exception {
if (StringUtils.isEmpty(person)) {
return new ArrayList<>();
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
return priorityService.listPriorityByPerson(emc, person);
} catch (Exception e) {
throw e;
}
}
/**
* 根据项目组ID,查询项目组内所有的项目ID列表
* @param emc
* @param group
* @return
* @throws Exception
*/
public List<String> listProjectIdByGroup(String group ) throws Exception {
if (StringUtils.isEmpty(group)) {
return new ArrayList<>();
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
return priorityService.listProjectIdByGroup(emc, group);
} catch (Exception e) {
throw e;
}
}
public List<String> listGroupIdByProject( String projectId ) throws Exception {
List<String> result = new ArrayList<>();
if (StringUtils.isEmpty( projectId )) {
return result;
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
List<ProjectGroupRele> reles = priorityService.listReleWithProject(emc, projectId);
if( ListTools.isNotEmpty( reles )) {
for( ProjectGroupRele rele : reles ) {
if( !result.contains( rele.getGroupId() )) {
result.add( rele.getGroupId() );
}
}
}
} catch (Exception e) {
throw e;
}
return result;
}
/**
* 判断是否存在分组和项目的关联
* @param groupId
* @param projectId
* @return
* @throws Exception
*/
public boolean existsWithProjectAndGroup(String groupId, String projectId) throws Exception {
if (StringUtils.isEmpty( groupId )) {
return false;
}
if (StringUtils.isEmpty( projectId )) {
return false;
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
List<ProjectGroupRele> reles = priorityService.listReleWithProjectAndGroup(emc, projectId, groupId );
if( ListTools.isNotEmpty( reles )) {
return true;
}
} catch (Exception e) {
throw e;
}
return false;
}
}
package com.x.teamwork.assemble.control.service;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.Priority;
import com.x.teamwork.core.entity.ProjectGroup;
import com.x.teamwork.core.entity.ProjectGroupRele;
/**
* 对项目组查询信息的服务
*
* @author O2LEE
*/
class PriorityService {
protected List<ProjectGroup> list(EntityManagerContainer emc, List<String> groupIds) throws Exception {
Business business = new Business( emc );
return business.projectGroupFactory().list(groupIds);
}
/**
* 根据优先级ID查询优先级的信息
* @param emc
* @param id
* @return
* @throws Exception
*/
protected Priority get( EntityManagerContainer emc, String id ) throws Exception {
Business business = new Business( emc );
return business.priorityFactory().get( id );
}
/**
* 根据优先级ID删除优先级信息
* @param emc
* @param id
* @throws Exception
*/
protected void delete( EntityManagerContainer emc, String id ) throws Exception {
Priority priority = emc.find( id, Priority.class );
emc.beginTransaction( Priority.class );
if( priority != null ) {
emc.remove( priority , CheckRemoveType.all );
}
emc.commit();
}
/**
* 向数据库持久化优先级信息
* @param emc
* @param projectGroup
* @return
* @throws Exception
*/
protected Priority save( EntityManagerContainer emc, Priority object ) throws Exception {
Priority priority = null;
if( StringUtils.isEmpty( object.getId() ) ){
object.setId( Priority.createId() );
}
priority = emc.find( object.getId(), Priority.class );
emc.beginTransaction( Priority.class );
if( priority == null ){ // 保存一个新的对象
priority = new Priority();
object.copyTo( priority );
priority.setId( object.getId() );
emc.persist( priority, CheckPersistType.all);
}else{ //对象已经存在,更新对象信息
if( StringUtils.isNotEmpty( priority.getOwner() )) {
object.setOwner( priority.getOwner() );
}
object.copyTo( priority, JpaObject.FieldsUnmodify );
emc.check( priority, CheckPersistType.all );
}
emc.commit();
return priority;
}
/**
* 将项目添加到项目组中去
* @param emc
* @param projectId
* @param groupId
* @return
* @throws Exception
*/
protected ProjectGroupRele addToGroup( EntityManagerContainer emc, String projectId, String groupId ) throws Exception {
List<ProjectGroupRele> reles = null;
Business business = new Business( emc );
ProjectGroupRele projectGroupRele = null;
ProjectGroup projectGroup = emc.find( groupId, ProjectGroup.class );
if( projectGroup != null ){
reles = business.projectGroupReleFactory().listWithGroupAndProject(groupId, projectId);
if( ListTools.isEmpty( reles )) {
emc.beginTransaction( ProjectGroup.class );
projectGroupRele = new ProjectGroupRele();
projectGroupRele.setId( ProjectGroupRele.createId() );
projectGroupRele.setProjectId(projectId);
projectGroupRele.setGroupId(groupId);
emc.persist( projectGroupRele, CheckPersistType.all );
emc.commit();
}
}
return projectGroupRele;
}
/**
* 将项目从项目组中除去
* @param emc
* @param projectId
* @param groupId
* @throws Exception
*/
protected void removeFromGroup( EntityManagerContainer emc, String projectId, String groupId ) throws Exception {
Business business = new Business( emc );
List<ProjectGroupRele> reles = business.projectGroupReleFactory().listWithGroupAndProject(groupId, projectId);
if( ListTools.isNotEmpty( reles )) {
emc.beginTransaction( ProjectGroup.class );
for( ProjectGroupRele rele : reles ) {
emc.remove( rele, CheckRemoveType.all );
}
emc.commit();
}
}
/**
* 根据用户列示所有的优先级信息列表
* @param emc
* @param person
* @return
* @throws Exception
*/
protected List<Priority> listPriorityByPerson( EntityManagerContainer emc, String person) throws Exception {
Business business = new Business( emc );
return business.priorityFactory().listPriorityByPerson(person);
}
/**
* 根据用户列示所有的项目组信息ID列表
* @param emc
* @param person
* @return
* @throws Exception
*/
protected List<String> listGroupIdsByPerson( EntityManagerContainer emc, String person) throws Exception {
Business business = new Business( emc );
return business.projectGroupFactory().listByPerson(person);
}
/**
* 根据项目组ID,查询项目组内所有的项目ID列表
* @param emc
* @param group
* @return
* @throws Exception
*/
protected List<String> listProjectIdByGroup(EntityManagerContainer emc, String group) throws Exception {
Business business = new Business( emc );
return business.projectGroupReleFactory().listProjectIdByGroup(group);
}
/**
* 根据项目ID查询项目所有的项目组关联信息对象列表
* @param emc
* @param projectId
* @return
* @throws Exception
*/
protected List<ProjectGroupRele> listReleWithProject(EntityManagerContainer emc, String projectId) throws Exception {
Business business = new Business( emc );
return business.projectGroupReleFactory().listReleWithProject( projectId );
}
/**
* 判断是否存在分组和项目的关联
* @param emc
* @param projectId
* @param groupId
* @return
* @throws Exception
*/
protected List<ProjectGroupRele> listReleWithProjectAndGroup(EntityManagerContainer emc, String projectId, String groupId) throws Exception {
Business business = new Business( emc );
return business.projectGroupReleFactory().listWithGroupAndProject( groupId, projectId );
}
}
package com.x.teamwork.assemble.control.service;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
......@@ -8,8 +10,10 @@ import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.assemble.common.date.DateOperation;
import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.Project;
import com.x.teamwork.core.entity.ProjectDetail;
import com.x.teamwork.core.entity.Task;
/**
* 对项目信息查询的服务
......@@ -136,6 +140,93 @@ public class ProjectPersistService {
}
}
/**
* 根据项目ID恢复项目
* @param projectId
* @param icon
* @throws Exception
*/
public void recoveryProject( String projectId ) throws Exception {
if ( StringUtils.isEmpty( projectId )) {
throw new Exception("projectId is empty!");
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Project project = emc.find( projectId, Project.class );
Business business = new Business( emc );
if( project == null ) {
throw new Exception("Project not exists.id:" + projectId );
}else {
emc.beginTransaction( Project.class );
emc.beginTransaction( Task.class );
project.setDeleted(false);
emc.check( project, CheckPersistType.all );
List<String> ids = business.taskFactory().listByProject( projectId );
List<Task> tasks = business.taskFactory().list(ids);
if( ListTools.isNotEmpty(tasks)) {
for( Task task : tasks ) {
task.setRelation(false);
emc.check( task, CheckPersistType.all );
}
}
emc.commit();
}
} catch (Exception e) {
throw e;
}
}
/**
* 根据项目更改项目为已完成或未
* @param projectId
* @param icon
* @throws Exception
*/
public void completeProject( String projectId ,Boolean status) throws Exception {
if ( StringUtils.isEmpty( projectId )) {
throw new Exception("projectId is empty!");
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Project project = emc.find( projectId, Project.class );
if( project == null ) {
throw new Exception("Project not exists.id:" + projectId );
}else {
emc.beginTransaction( Project.class );
project.setCompleted(status);
emc.check( project, CheckPersistType.all );
emc.commit();
}
} catch (Exception e) {
throw e;
}
}
/**
* 根据项目设置项目是否可创建任务
* @param projectId
* @param icon
* @throws Exception
*/
public void createableProject( String projectId ,Boolean status) throws Exception {
if ( StringUtils.isEmpty( projectId )) {
throw new Exception("projectId is empty!");
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Project project = emc.find( projectId, Project.class );
if( project == null ) {
throw new Exception("Project not exists.id:" + projectId );
}else {
emc.beginTransaction( Project.class );
project.setCreateable(status);
emc.check( project, CheckPersistType.all );
emc.commit();
}
} catch (Exception e) {
throw e;
}
}
/**
* 保存或者更新项目的图标信息
* @param projectId
......
......@@ -11,6 +11,7 @@ import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.core.entity.Project;
import com.x.teamwork.core.entity.ProjectDetail;
import com.x.teamwork.core.entity.Task;
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.InTerm;
......@@ -177,6 +178,26 @@ public class ProjectQueryService {
}
}
/**
* 根据项目ID查询任务信息列表
* @param projectId
* @param deleted
* @return
* @throws Exception
*/
public List<Task> listAllTasks(String projectId, Boolean deleted) throws Exception{
if ( StringUtils.isEmpty( projectId )) {
return null;
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
return projectService.listAllTasks(emc, projectId, deleted );
}catch (Exception e) {
throw e;
}
}
/**
* 判断用户是否为指定项目的管理员
* @param projectId
......
......@@ -76,6 +76,19 @@ class ProjectService {
return business.projectFactory().listWithFilter(maxCount, orderField, orderType, personName, identityNames, unitNames, groupNames, queryFilter);
}
/**
* 根据过滤条件查询符合要求的项目信息列表
* @param emc
* @param projectId
* @param deleted
* @return
* @throws Exception
*/
protected List<Task> listAllTasks( EntityManagerContainer emc, String projectId, Boolean deleted) throws Exception {
Business business = new Business( emc );
return business.projectFactory().listAllTasks(projectId, deleted);
}
/**
* 根据条件查询符合条件的项目信息ID,根据上一条的sequnce查询指定数量的信息
* @param emc
......@@ -156,36 +169,24 @@ class ProjectService {
protected void delete(EntityManagerContainer emc, String id ) throws Exception {
Business business = new Business( emc );
Project project = emc.find( id, Project.class );
ProjectDetail projectDetail = emc.find( id, ProjectDetail.class );
if( project != null ) {
//这里要先递归删除所有的任务信息
emc.beginTransaction( Task.class );
emc.beginTransaction( Project.class );
emc.beginTransaction( ProjectDetail.class );
emc.beginTransaction( ProjectExtFieldRele.class );
if( project != null ) {
//emc.remove( project , CheckRemoveType.all );
//改为软删除
project.setDeleted(true);
emc.check( project , CheckPersistType.all );
}
if( projectDetail != null ) {
emc.remove( projectDetail , CheckRemoveType.all );
}
}
//还需要删除所有的Task
List<String> ids = business.taskFactory().listByProject( id );
List<Task> tasks = business.taskFactory().list(ids);
if( ListTools.isNotEmpty(tasks)) {
for( Task task : tasks ) {
//emc.remove( task , CheckRemoveType.all );
this.remove( emc, task.getId() );
}
}
//还需要删除所有的ProjectExtFieldRele
List<ProjectExtFieldRele> releList = business.projectExtFieldReleFactory().listFieldReleObjByProject( id );
if( ListTools.isNotEmpty(releList)) {
for( ProjectExtFieldRele rele : releList ) {
emc.remove( rele , CheckRemoveType.all );
//this.remove( emc, task.getId() );
task.setRelation(true);
emc.check( task, CheckPersistType.all );
}
}
emc.commit();
......@@ -199,10 +200,10 @@ class ProjectService {
*/
public void remove( EntityManagerContainer emc, String flag ) throws Exception {
emc.beginTransaction( Task.class );
emc.beginTransaction( Review.class );
/* emc.beginTransaction( Review.class );
emc.beginTransaction( TaskDetail.class );
emc.beginTransaction( TaskListRele.class );
emc.beginTransaction( TaskGroupRele.class );
emc.beginTransaction( TaskGroupRele.class );*/
removeTaskWithChildren( emc, flag);
emc.commit();
}
......@@ -223,7 +224,7 @@ class ProjectService {
}
}
//任务列表中的关联信息
/*//任务列表中的关联信息
List<TaskListRele> listReles = business.taskListFactory().listReleWithTask( id );
if( ListTools.isNotEmpty( listReles )) {
for( TaskListRele taskListRele : listReles ) {
......@@ -238,8 +239,6 @@ class ProjectService {
emc.remove( taskGroupRele , CheckRemoveType.all );
}
}
Task task = emc.find( id, Task.class );
TaskDetail taskDetail = emc.find( id, TaskDetail.class );
List<Review> reviewList = null;
List<List<String>> reviewIdBatchs = null;
......@@ -260,15 +259,18 @@ class ProjectService {
}
}
}
if( taskDetail != null ) {
emc.remove( taskDetail , CheckRemoveType.all );
}*/
Task task = emc.find( id, Task.class );
if( task != null ) {
//emc.remove( task , CheckRemoveType.all );
//改为软删除
task.setDeleted(true);
//task.setDeleted(true);
task.setRelation(true);
emc.check( task, CheckPersistType.all );
}
if( taskDetail != null ) {
emc.remove( taskDetail , CheckRemoveType.all );
}
}
/**
......
......@@ -39,7 +39,11 @@ public final class PersistenceProperties extends AbstractPersistenceProperties {
public static class TaskTag {
public static final String table = "TEW_TAG";
}
public static class Priority {
public static final String table = "TEW_PIORITY";
}
public static class TaskDetail {
public static final String table = "TEW_TASKDETAIL";
}
......
package com.x.teamwork.core.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.apache.openjpa.persistence.jdbc.Index;
import com.x.base.core.entity.AbstractPersistenceProperties;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.SliceJpaObject;
import com.x.base.core.entity.annotation.CheckPersist;
import com.x.base.core.entity.annotation.ContainerEntity;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.tools.DateTools;
/**
* 优先级信息
*
* @author O2LJ
*
*/
@ContainerEntity
@Entity
@Table(name = PersistenceProperties.Priority.table, uniqueConstraints = {
@UniqueConstraint(name = PersistenceProperties.Priority.table + JpaObject.IndexNameMiddle
+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Priority extends SliceJpaObject {
private static final long serialVersionUID = 3856138316794473794L;
private static final String TABLE = PersistenceProperties.Priority.table;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@FieldDescribe("数据库主键,自动生成.")
@Id
@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
private String id = createId();
public void onPersist() throws Exception {
/** 生成默认排序号 */
if (null == this.order) {
this.order = DateTools.timeOrderNumber();
}
}
/*
* =========================================================================
* ========= 以上为 JpaObject 默认字段
* =========================================================================
* =========
*/
/*
* =========================================================================
* ========= 以下为具体不同的业务及数据表字段要求
* =========================================================================
* =========
*/
public static final String priority_FIELDNAME = "priority";
@FieldDescribe("优先级名称.")
@Column(length = length_id, name = ColumnNamePrefix + priority_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + priority_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String priority;
public static final String color_FIELDNAME = "priorityColor";
@FieldDescribe("优先级颜色")
@Column( length = JpaObject.length_16B, name = ColumnNamePrefix + color_FIELDNAME)
@CheckPersist( allowEmpty = false )
private String priorityColor;
public static final String order_FIELDNAME = "order";
@FieldDescribe("排序号")
@Column( name = ColumnNamePrefix + order_FIELDNAME )
private Integer order;
public static final String owner_FIELDNAME = "owner";
@FieldDescribe("创建者")
@Column( length = AbstractPersistenceProperties.organization_name_length, name = ColumnNamePrefix + owner_FIELDNAME)
@Index( name = TABLE + IndexNameMiddle + owner_FIELDNAME )
@CheckPersist(allowEmpty = true)
private String owner;
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getPriorityColor() {
return priorityColor;
}
public void setPriorityColor(String priorityColor) {
this.priorityColor = priorityColor;
}
}
\ No newline at end of file
......@@ -120,6 +120,12 @@ public class Project extends SliceJpaObject {
@Index( name = TABLE + IndexNameMiddle + archive_FIELDNAME )
private Boolean archive = false;
public static final String createable_FIELDNAME = "createable";
@FieldDescribe("是否可新建任务")
@Column( name = ColumnNamePrefix + createable_FIELDNAME)
@Index( name = TABLE + IndexNameMiddle + createable_FIELDNAME )
private Boolean createable = false;
public static final String creatorPerson_FIELDNAME = "creatorPerson";
@FieldDescribe("创建者,可能为System,如果由系统创建。")
@Column( length = AbstractPersistenceProperties.organization_name_length, name = ColumnNamePrefix + creatorPerson_FIELDNAME)
......@@ -334,6 +340,14 @@ public class Project extends SliceJpaObject {
this.archive = archive;
}
public Boolean getCreateable() {
return createable;
}
public void setCreateable(Boolean createable) {
this.createable = createable;
}
public String getIcon() {
return icon;
}
......
......@@ -177,6 +177,12 @@ public class Task extends SliceJpaObject {
@Index( name = TABLE + IndexNameMiddle + archive_FIELDNAME )
private Boolean archive = false;
public static final String relation_FIELDNAME = "relation";
@FieldDescribe("是否项目关联操作")
@Column( name = ColumnNamePrefix + relation_FIELDNAME)
@Index( name = TABLE + IndexNameMiddle + relation_FIELDNAME )
private Boolean relation = false;
public static final String reviewed_FIELDNAME = "reviewed";
@FieldDescribe("是否检查过review信息")
@Column( name = ColumnNamePrefix + reviewed_FIELDNAME)
......@@ -346,6 +352,14 @@ public class Task extends SliceJpaObject {
public void setOvertime(Boolean overtime) {
this.overtime = overtime;
}
public Boolean getRelation() {
return relation;
}
public void setRelation(Boolean relation) {
this.relation = relation;
}
public Boolean getRemindRelevance() {
return remindRelevance;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册