Search in sources :

Example 1 with ServerGroupAdapter

use of com.qlangtech.tis.runtime.pojo.ServerGroupAdapter 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)

Aggregations

ServerGroup (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup)1 ServerGroupCriteria (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria)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 ArrayList (java.util.ArrayList)1