use of com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria in project tis by qlangtech.
the class DownloadServlet method getServerGroup.
public static ServerGroup getServerGroup(Integer appid, Short groupIndex, Short runtime, IServerGroupDAO serverGroupDAO) {
ServerGroupCriteria gcriteria = new ServerGroupCriteria();
gcriteria.createCriteria().andGroupIndexEqualTo(groupIndex).andRuntEnvironmentEqualTo(runtime).andAppIdEqualTo(appid);
List<ServerGroup> groupList = serverGroupDAO.selectByExample(gcriteria);
for (ServerGroup g : groupList) {
return g;
}
return null;
}
use of com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria in project tis by qlangtech.
the class BasicScreen method createServerGroupAdapterList.
public static List<ServerGroupAdapter> createServerGroupAdapterList(ServerGroupCriteriaSetter setter, final boolean publishSnapshotIdIsNotNull, RunContext daoContext) {
ServerGroupCriteria criteria = new ServerGroupCriteria();
ServerGroupCriteria.Criteria query = criteria.createCriteria();
query.andNotDelete();
setter.process(query);
// query.andAppIdEqualTo(domain.getAppid()).andRuntEnvironmentEqualTo(
// domain.getRunEnvironment().getId());
//
// if (publishSnapshotIdIsNotNull) {
// query.andPublishSnapshotIdIsNotNull();
// }
List<ServerGroup> groupList = daoContext.getServerGroupDAO().selectByExample(criteria, 1, 400);
List<ServerGroupAdapter> groupAdapterList = new ArrayList<ServerGroupAdapter>();
for (ServerGroup group : groupList) {
Snapshot snapshot = new Snapshot();
int maxSnapshotId = 0;
if (publishSnapshotIdIsNotNull) {
snapshot = daoContext.getSnapshotDAO().selectByPrimaryKey(group.getPublishSnapshotId());
// SnapshotCriteria snapshotCriteria = new SnapshotCriteria();
// snapshotCriteria.createCriteria().andAppidEqualTo(
// group.getGid());
// maxSnapshotId = daoContext.getSnapshotDAO().getMaxSnapshotId(
// snapshotCriteria);
maxSnapshotId = setter.getMaxSnapshotId(group, daoContext);
if (snapshot == null) {
throw new IllegalStateException("group:" + group.getGid() + " has not set PublishSnapshotId,or group.getPublishSnapshotId():" + group.getPublishSnapshotId() + " has any snapshot in db");
}
}
ServerGroupAdapter adapter = new ServerGroupAdapter(group, snapshot);
// maxSnapshotId
adapter.setMaxSnapshotId(maxSnapshotId);
// ServerCriteria scrit = new ServerCriteria();
// scrit.createCriteria(false).andGidEqualTo(group.getGid());
// ;
// adapter.addServer(daoContext.getServerDAO().selectByExample(scrit));
adapter.addServer(setter.getServers(daoContext, group));
groupAdapterList.add(adapter);
}
return groupAdapterList;
}
use of com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria in project tis by qlangtech.
the class GroupAction method createGroup.
public static Integer createGroup(RunEnvironment runtime, Integer groupIndex, Integer appid, Integer publishSnapshotId, IServerGroupDAO serverGroupDAO) {
Assert.assertNotNull(appid);
ServerGroupCriteria query = new ServerGroupCriteria();
query.createCriteria().andRuntEnvironmentEqualTo(runtime.getId()).andGroupIndexEqualTo(groupIndex.shortValue()).andAppIdEqualTo(appid).andNotDelete();
int serverGroupCount;
if ((serverGroupCount = serverGroupDAO.countByExample(query)) > 0) {
// basicModule.addErrorMessage(context, "gruop index重复");
throw new IllegalStateException("appid:" + appid + ",groupIndex:" + groupIndex + " relevant group can not duplicate,current serverGroupCount:" + serverGroupCount);
}
ServerGroup group = new ServerGroup();
group.setRuntEnvironment(runtime.getId());
group.setGroupIndex(groupIndex.shortValue());
group.setCreateTime(new Date());
group.setAppId(appid);
if (publishSnapshotId > 0) {
group.setPublishSnapshotId(publishSnapshotId);
}
return serverGroupDAO.insertSelective(group);
}
use of com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria in project tis by qlangtech.
the class GroupAction method doChangeEnvironment.
// @Func(PermissionConstant.PERMISSION_BASE_DATA_MANAGE)
public void doChangeEnvironment(Context context) throws Exception {
Integer appid = this.getInt("appid");
Integer runtime = this.getInt("runtime");
ServerGroupCriteria query = new ServerGroupCriteria();
query.createCriteria().andRuntEnvironmentEqualTo(runtime.shortValue()).andAppIdEqualTo(appid).andNotDelete();
query.setOrderByClause("group_index desc");
List<ServerGroup> queryResult = this.getServerGroupDAO().selectByExample(query);
int groupIndex = 0;
for (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup group : queryResult) {
groupIndex = group.getGroupIndex() + 1;
break;
}
getResponse().getWriter().write(String.valueOf(groupIndex));
}
use of com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria in project tis by qlangtech.
the class GroupAction method doDeleteGroup.
/**
* 删除服务器组
*
* @param context
* @throws Exception
*/
@Func(PermissionConstant.APP_SERVER_GROUP_SET)
public void doDeleteGroup(Context context) throws Exception {
final Integer groupid = this.getInt("groupid");
Assert.assertNotNull("groupid can not be null", groupid);
ServerGroupCriteria query = new ServerGroupCriteria();
query.createCriteria().andGidEqualTo(groupid);
// 删除group
this.getServerGroupDAO().deleteByExample(query);
this.addActionMessage(context, "成功删除组ID:" + groupid);
}
Aggregations