Search in sources :

Example 1 with ServerGroupCriteria

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;
}
Also used : ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) ServerGroupCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria)

Example 2 with ServerGroupCriteria

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;
}
Also used : Snapshot(com.qlangtech.tis.manage.biz.dal.pojo.Snapshot) ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) Criteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria.Criteria) ServerGroupAdapter(com.qlangtech.tis.runtime.pojo.ServerGroupAdapter) ServerGroupCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria) ArrayList(java.util.ArrayList)

Example 3 with ServerGroupCriteria

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);
}
Also used : ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) ServerGroupCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria) Date(java.util.Date)

Example 4 with ServerGroupCriteria

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));
}
Also used : ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) ServerGroupCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria)

Example 5 with ServerGroupCriteria

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);
}
Also used : ServerGroupCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria) Func(com.qlangtech.tis.manage.spring.aop.Func)

Aggregations

ServerGroupCriteria (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria)7 ServerGroup (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup)5 Func (com.qlangtech.tis.manage.spring.aop.Func)2 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)1 ApplicationCriteria (com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria)1 Criteria (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria.Criteria)1 Snapshot (com.qlangtech.tis.manage.biz.dal.pojo.Snapshot)1 ServerGroupAdapter (com.qlangtech.tis.runtime.pojo.ServerGroupAdapter)1 IWorkflowDAOFacade (com.qlangtech.tis.workflow.dao.IWorkflowDAOFacade)1 DatasourceDbCriteria (com.qlangtech.tis.workflow.pojo.DatasourceDbCriteria)1 DatasourceTableCriteria (com.qlangtech.tis.workflow.pojo.DatasourceTableCriteria)1 WorkFlowCriteria (com.qlangtech.tis.workflow.pojo.WorkFlowCriteria)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1