PriorityQueryService.java 4.2 KB
Newer Older
L
luojing 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
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;
		}
	}	
	
	/**
L
luojing 已提交
38
	 * 根据优先级的标识查询优先级信息
L
luojing 已提交
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
	 * @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;
		}
	}
	
L
luojing 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
	/**
	 * 根据优先级的名称查询优先级信息
	 * @param name
	 * @return
	 * @throws Exception
	 */
	public List<Priority> getByName( String name ) throws Exception {
		if ( StringUtils.isEmpty( name )) {
			return null;
		}
		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
			return priorityService.getByName(emc, name );
		} catch (Exception e) {
			throw e;
		}
	}
	
L
luojing 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83 84
	/**
	 * 根据用户列示优先级信息列表
	 * @param person
	 * @return
	 * @throws Exception
	 */
	public List<Priority> listPriority() throws Exception {
		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
			return priorityService.listPriority(emc);
		} catch (Exception e) {
			throw e;
		}
	}
	
L
luojing 已提交
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
	/**
	 * 根据用户列示优先级信息列表
	 * @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;
	}

}