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;
}
Aggregations