mirror of https://github.com/apache/cloudstack.git
bug 5701: listNetworkGroups api - apply page size parameter to the NetworkGroup instead of IngressRule.
status 5701: resolved fixed
This commit is contained in:
parent
9640f12cce
commit
9fefa33a36
|
|
@ -26,4 +26,10 @@ public interface NetworkGroupRulesDao extends GenericDao<NetworkGroupRulesVO, Lo
|
|||
* @return the list of network groups with associated ingress rules
|
||||
*/
|
||||
List<NetworkGroupRulesVO> listNetworkGroupRules();
|
||||
|
||||
/**
|
||||
* List all network rules belonging to the specific group
|
||||
* @return the network group with associated ingress rules
|
||||
*/
|
||||
List<NetworkGroupRulesVO> listNetworkRulesByGroupId(long groupId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import com.cloud.utils.db.SearchCriteria;
|
|||
public class NetworkGroupRulesDaoImpl extends GenericDaoBase<NetworkGroupRulesVO, Long> implements NetworkGroupRulesDao {
|
||||
private SearchBuilder<NetworkGroupRulesVO> AccountGroupNameSearch;
|
||||
private SearchBuilder<NetworkGroupRulesVO> AccountSearch;
|
||||
private SearchBuilder<NetworkGroupRulesVO> GroupSearch;
|
||||
|
||||
|
||||
protected NetworkGroupRulesDaoImpl() {
|
||||
AccountGroupNameSearch = createSearchBuilder();
|
||||
|
|
@ -24,6 +26,11 @@ public class NetworkGroupRulesDaoImpl extends GenericDaoBase<NetworkGroupRulesVO
|
|||
AccountSearch = createSearchBuilder();
|
||||
AccountSearch.and("accountId", AccountSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
AccountSearch.done();
|
||||
|
||||
GroupSearch = createSearchBuilder();
|
||||
GroupSearch.and("groupId", GroupSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
GroupSearch.done();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -48,7 +55,14 @@ public class NetworkGroupRulesDaoImpl extends GenericDaoBase<NetworkGroupRulesVO
|
|||
Filter searchFilter = new Filter(NetworkGroupRulesVO.class, "id", true, null, null);
|
||||
SearchCriteria<NetworkGroupRulesVO> sc = AccountSearch.create();
|
||||
sc.setParameters("accountId", accountId);
|
||||
|
||||
return listBy(sc, searchFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkGroupRulesVO> listNetworkRulesByGroupId(long groupId) {
|
||||
Filter searchFilter = new Filter(NetworkGroupRulesVO.class, "id", true, null, null);
|
||||
SearchCriteria<NetworkGroupRulesVO> sc = GroupSearch.create();
|
||||
sc.setParameters("groupId", groupId);
|
||||
return listBy(sc, searchFilter);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1251,10 +1251,10 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
}
|
||||
}
|
||||
|
||||
Filter searchFilter = new Filter(NetworkGroupRulesVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
Filter searchFilter = new Filter(NetworkGroupVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
Object keyword = cmd.getKeyword();
|
||||
|
||||
SearchBuilder<NetworkGroupRulesVO> sb = _networkGroupRulesDao.createSearchBuilder();
|
||||
SearchBuilder<NetworkGroupVO> sb = _networkGroupDao.createSearchBuilder();
|
||||
sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ);
|
||||
sb.and("domainId", sb.entity().getDomainId(), SearchCriteria.Op.EQ);
|
||||
|
|
@ -1266,7 +1266,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
sb.join("domainSearch", domainSearch, sb.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
}
|
||||
|
||||
SearchCriteria<NetworkGroupRulesVO> sc = sb.create();
|
||||
SearchCriteria<NetworkGroupVO> sc = sb.create();
|
||||
if (accountId != null) {
|
||||
sc.setParameters("accountId", accountId);
|
||||
if (networkGroup != null) {
|
||||
|
|
@ -1277,8 +1277,6 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
|
||||
}
|
||||
} else if (instanceId != null) {
|
||||
return listNetworkGroupRulesByVM(instanceId.longValue());
|
||||
} else if (domainId != null) {
|
||||
if (Boolean.TRUE.equals(recursive)) {
|
||||
DomainVO domain = _domainDao.findById(domainId);
|
||||
|
|
@ -1287,8 +1285,18 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
|||
sc.setParameters("domainId", domainId);
|
||||
}
|
||||
}
|
||||
|
||||
return _networkGroupRulesDao.search(sc, searchFilter);
|
||||
|
||||
List<NetworkGroupVO> networkGroups = _networkGroupDao.search(sc, searchFilter);
|
||||
List<NetworkGroupRulesVO> networkRulesList = new ArrayList<NetworkGroupRulesVO>();
|
||||
for (NetworkGroupVO group : networkGroups) {
|
||||
networkRulesList.addAll(_networkGroupRulesDao.listNetworkRulesByGroupId(group.getId()));
|
||||
}
|
||||
|
||||
if (instanceId != null) {
|
||||
return listNetworkGroupRulesByVM(instanceId.longValue());
|
||||
}
|
||||
|
||||
return networkRulesList;
|
||||
}
|
||||
|
||||
private List<NetworkGroupRulesVO> listNetworkGroupRulesByVM(long vmId) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue