mirror of https://github.com/apache/cloudstack.git
bug 14439: added search by name/description to listGuestOS and listGuestOSCategories apis
status 14439: resolved fixed reviewed-by: Frank Zhang
This commit is contained in:
parent
217e357c4e
commit
15019d1e5c
|
|
@ -45,6 +45,9 @@ public class ListGuestOsCategoriesCmd extends BaseListCmd {
|
|||
@IdentityMapper(entityTableName="guest_os_category")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list Os category by id")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="list os category by name")
|
||||
private String name;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -55,11 +58,15 @@ public class ListGuestOsCategoriesCmd extends BaseListCmd {
|
|||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ public class ListGuestOsCmd extends BaseListCmd {
|
|||
@IdentityMapper(entityTableName="guest_os_category")
|
||||
@Parameter(name=ApiConstants.OS_CATEGORY_ID, type=CommandType.LONG, description="list by Os Category id")
|
||||
private Long osCategoryId;
|
||||
|
||||
@Parameter(name=ApiConstants.DESCRIPTION, type=CommandType.STRING, description="list os by description")
|
||||
private String description;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -63,7 +66,10 @@ public class ListGuestOsCmd extends BaseListCmd {
|
|||
return osCategoryId;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -1739,19 +1739,25 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
Filter searchFilter = new Filter(GuestOSVO.class, "displayName", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
Long id = cmd.getId();
|
||||
Long osCategoryId = cmd.getOsCategoryId();
|
||||
String description = cmd.getDescription();
|
||||
String keyword = cmd.getKeyword();
|
||||
|
||||
SearchBuilder<GuestOSVO> sb = _guestOSDao.createSearchBuilder();
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
sb.and("categoryId", sb.entity().getCategoryId(), SearchCriteria.Op.EQ);
|
||||
|
||||
SearchCriteria<GuestOSVO> sc = sb.create();
|
||||
SearchCriteria<GuestOSVO> sc = _guestOSDao.createSearchCriteria();
|
||||
|
||||
if (id != null) {
|
||||
sc.setParameters("id", id);
|
||||
sc.addAnd("id", SearchCriteria.Op.EQ, id);
|
||||
}
|
||||
|
||||
if (osCategoryId != null) {
|
||||
sc.setParameters("categoryId", osCategoryId);
|
||||
sc.addAnd("categoryId", SearchCriteria.Op.EQ, osCategoryId);
|
||||
}
|
||||
|
||||
if (description != null) {
|
||||
sc.addAnd("displayName", SearchCriteria.Op.LIKE, "%" + description + "%");
|
||||
}
|
||||
|
||||
if (keyword != null) {
|
||||
sc.addAnd("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
}
|
||||
|
||||
return _guestOSDao.search(sc, searchFilter);
|
||||
|
|
@ -1761,14 +1767,21 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
public List<GuestOSCategoryVO> listGuestOSCategoriesByCriteria(ListGuestOsCategoriesCmd cmd) {
|
||||
Filter searchFilter = new Filter(GuestOSCategoryVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
Long id = cmd.getId();
|
||||
String name = cmd.getName();
|
||||
String keyword = cmd.getKeyword();
|
||||
|
||||
SearchBuilder<GuestOSCategoryVO> sb = _guestOSCategoryDao.createSearchBuilder();
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
|
||||
SearchCriteria<GuestOSCategoryVO> sc = sb.create();
|
||||
SearchCriteria<GuestOSCategoryVO> sc = _guestOSCategoryDao.createSearchCriteria();
|
||||
|
||||
if (id != null) {
|
||||
sc.setParameters("id", id);
|
||||
sc.addAnd("id", SearchCriteria.Op.EQ, id);
|
||||
}
|
||||
|
||||
if (name != null) {
|
||||
sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%");
|
||||
}
|
||||
|
||||
if (keyword != null) {
|
||||
sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
}
|
||||
|
||||
return _guestOSCategoryDao.search(sc, searchFilter);
|
||||
|
|
|
|||
Loading…
Reference in New Issue