bug 8577: Make listAlerts API take in id parameter.

This commit is contained in:
Jessica Wang 2011-02-16 15:35:34 -08:00
parent 35397d7176
commit eb7d531456
3 changed files with 16 additions and 6 deletions

View File

@ -27,6 +27,7 @@ import com.cloud.api.ApiConstants;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.AlertResponse;
import com.cloud.api.response.ListResponse;
@ -41,6 +42,9 @@ public class ListAlertsCmd extends BaseListCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the ID of the alert")
private Long id;
@Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, description="list by alert type")
private String type;
@ -48,6 +52,10 @@ public class ListAlertsCmd extends BaseListCmd {
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public String getType() {
return type;
}

View File

@ -3105,10 +3105,15 @@ public class ManagementServerImpl implements ManagementServer {
Filter searchFilter = new Filter(AlertVO.class, "lastSent", false, cmd.getStartIndex(), cmd.getPageSizeVal());
SearchCriteria<AlertVO> sc = _alertDao.createSearchCriteria();
Object id = cmd.getId();
Object type = cmd.getType();
Object keyword = cmd.getKeyword();
if (id != null) {
sc.addAnd("id", SearchCriteria.Op.EQ, id);
}
if (keyword != null) {
SearchCriteria<AlertVO> ssc = _alertDao.createSearchCriteria();
ssc.addOr("subject", SearchCriteria.Op.LIKE, "%" + keyword + "%");

View File

@ -67,9 +67,7 @@ function alertJsonToDetailsTab() {
var $thisTab = $("#right_panel_content").find("#tab_content_details");
$thisTab.find("#tab_container").hide();
$thisTab.find("#tab_spinning_wheel").show();
//uncomment the following section when Bug 8577("listAlerts API, listEvents API doesn't take in id parameter correctly") is fixed
/*
$.ajax({
data: createURL("command=listAlerts&id="+jsonObj.id),
dataType: "json",
@ -82,8 +80,7 @@ function alertJsonToDetailsTab() {
}
}
});
*/
$thisTab.find("#id").text(fromdb(jsonObj.id));
$thisTab.find("#type").text(toAlertType(jsonObj.type));
$thisTab.find("#typeid").text(fromdb(jsonObj.type));