mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
Refactor listEvents API to new framework.
This commit is contained in:
parent
9eeabb701a
commit
4bb71d2a0c
@ -21,42 +21,21 @@ package com.cloud.api.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.api.response.EventResponse;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.server.Criteria;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
public class ListEventsCmd extends BaseCmd {
|
||||
import com.cloud.serializer.SerializerHelper;
|
||||
|
||||
@Implementation(method="searchForEvents")
|
||||
public class ListEventsCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListEventsCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listeventsresponse";
|
||||
private static final List<Pair<Enum, Boolean>> s_properties = new ArrayList<Pair<Enum, Boolean>>();
|
||||
|
||||
static {
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ACCOUNT_OBJ, Boolean.FALSE));
|
||||
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ACCOUNT, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.DOMAIN_ID, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.DURATION, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.END_DATE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ENTRY_TIME, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.LEVEL, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.START_DATE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.TYPE, Boolean.FALSE));
|
||||
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.KEYWORD, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGE, Boolean.FALSE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.PAGESIZE, Boolean.FALSE));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
@ -77,6 +56,9 @@ public class ListEventsCmd extends BaseCmd {
|
||||
@Parameter(name="entrytime", type=CommandType.INTEGER)
|
||||
private Integer entryTime;
|
||||
|
||||
@Parameter(name="level", type=CommandType.STRING)
|
||||
private String level;
|
||||
|
||||
@Parameter(name="startdate", type=CommandType.DATE)
|
||||
private Date startDate;
|
||||
|
||||
@ -108,6 +90,10 @@ public class ListEventsCmd extends BaseCmd {
|
||||
return entryTime;
|
||||
}
|
||||
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
@ -120,127 +106,39 @@ public class ListEventsCmd extends BaseCmd {
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
public List<Pair<Enum, Boolean>> getProperties() {
|
||||
return s_properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||
Account account = (Account)params.get(BaseCmd.Properties.ACCOUNT_OBJ.getName());
|
||||
String accountName = (String)params.get(BaseCmd.Properties.ACCOUNT.getName());
|
||||
Long domainId = (Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
|
||||
String eventType = (String)params.get(BaseCmd.Properties.TYPE.getName());
|
||||
String eventLevel = (String)params.get(BaseCmd.Properties.LEVEL.getName());
|
||||
// String eventLevel = (String)params.get(BaseCmd.Properties.DESCRIPTION.getName());
|
||||
Date startDate = (Date)params.get(BaseCmd.Properties.START_DATE.getName());
|
||||
Date endDate = (Date)params.get(BaseCmd.Properties.END_DATE.getName());
|
||||
String keyword = (String)params.get(BaseCmd.Properties.KEYWORD.getName());
|
||||
Integer entryTime = (Integer)params.get(BaseCmd.Properties.ENTRY_TIME.getName());
|
||||
Integer duration = (Integer)params.get(BaseCmd.Properties.DURATION.getName());
|
||||
Integer page = (Integer)params.get(BaseCmd.Properties.PAGE.getName());
|
||||
Integer pageSize = (Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
|
||||
boolean isAdmin = false;
|
||||
|
||||
Long[] accountIds = null;
|
||||
Long accountId = null;
|
||||
if ((account == null) || isAdmin(account.getType())) {
|
||||
isAdmin = true;
|
||||
// validate domainId before proceeding
|
||||
if (domainId != null) {
|
||||
if ((account != null) && !getManagementServer().isChildDomain(account.getDomainId(), domainId)) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Invalid domain id (" + domainId + ") given, unable to list events.");
|
||||
}
|
||||
if (accountName != null) {
|
||||
Account userAccount = getManagementServer().findAccountByName(accountName, domainId);
|
||||
if (userAccount != null) {
|
||||
accountId = userAccount.getId();
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to find account " + accountName + " in domain " + domainId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
domainId = ((account == null) ? DomainVO.ROOT_DOMAIN : account.getDomainId());
|
||||
}
|
||||
} else {
|
||||
accountId = account.getId();
|
||||
}
|
||||
|
||||
if (accountId != null) {
|
||||
accountIds = new Long[1];
|
||||
accountIds[0] = accountId;
|
||||
}
|
||||
|
||||
Long startIndex = Long.valueOf(0);
|
||||
int pageSizeNum = 50;
|
||||
if (pageSize != null) {
|
||||
pageSizeNum = pageSize.intValue();
|
||||
}
|
||||
if (page != null) {
|
||||
int pageNum = page.intValue();
|
||||
if (pageNum > 0) {
|
||||
startIndex = Long.valueOf(pageSizeNum * (pageNum-1));
|
||||
}
|
||||
}
|
||||
Criteria c = new Criteria("createDate", Boolean.FALSE, startIndex, Long.valueOf(pageSizeNum));
|
||||
c.addCriteria(Criteria.ACCOUNTID, accountIds);
|
||||
if (keyword != null) {
|
||||
c.addCriteria(Criteria.KEYWORD, keyword);
|
||||
} else {
|
||||
if (isAdmin) {
|
||||
c.addCriteria(Criteria.DOMAINID, domainId);
|
||||
}
|
||||
c.addCriteria(Criteria.TYPE, eventType);
|
||||
c.addCriteria(Criteria.LEVEL, eventLevel);
|
||||
c.addCriteria(Criteria.STARTDATE, startDate);
|
||||
c.addCriteria(Criteria.ENDDATE, endDate);
|
||||
}
|
||||
}
|
||||
|
||||
List<EventVO> events;
|
||||
|
||||
if(entryTime != null && duration != null){
|
||||
if(entryTime <= duration){
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Entry time shoule be greater than duration");
|
||||
}
|
||||
events = getManagementServer().listPendingEvents(entryTime, duration);
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
public String getResponse() {
|
||||
List<EventVO> events = (List<EventVO>)getResponseObject();
|
||||
|
||||
List<EventResponse> response = new ArrayList<EventResponse>();
|
||||
for (EventVO event : events) {
|
||||
EventResponse responseEvent = new EventResponse();
|
||||
responseEvent.setAccountName(event.getAccountName());
|
||||
responseEvent.setCreated(event.getCreateDate());
|
||||
responseEvent.setDescription(event.getDescription());
|
||||
responseEvent.setDomainId(event.getDomainId());
|
||||
responseEvent.setEventType(event.getType());
|
||||
responseEvent.setId(event.getId());
|
||||
responseEvent.setLevel(event.getLevel());
|
||||
responseEvent.setParentId(event.getStartId());
|
||||
responseEvent.setState(event.getState());
|
||||
// TODO: implement
|
||||
// responseEvent.setDomainName(event.getDomainName());
|
||||
// eventData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(acct.getDomainId()).getName()));
|
||||
// responseEvent.setUsername(event.getUserId());
|
||||
// User user = getManagementServer().findUserById(event.getUserId());
|
||||
// if (user != null) {
|
||||
// eventData.add(new Pair<String, Object>(BaseCmd.Properties.USERNAME.getName(), user.getUsername() ));
|
||||
// }
|
||||
|
||||
response.add(responseEvent);
|
||||
}
|
||||
else {
|
||||
events = getManagementServer().searchForEvents(c);
|
||||
}
|
||||
|
||||
if (events == null) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Internal error searching for events");
|
||||
}
|
||||
List<Pair<String, Object>> eventTags = new ArrayList<Pair<String, Object>>();
|
||||
Object[] eTag = new Object[events.size()];
|
||||
int i = 0;
|
||||
for (EventVO event : events) {
|
||||
List<Pair<String, Object>> eventData = new ArrayList<Pair<String, Object>>();
|
||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), (new Long(event.getId())).toString()));
|
||||
User user = getManagementServer().findUserById(event.getUserId());
|
||||
if (user != null) {
|
||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.USERNAME.getName(), user.getUsername() ));
|
||||
}
|
||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.TYPE.getName(), event.getType()));
|
||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.LEVEL.getName(), event.getLevel()));
|
||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.DESCRIPTION.getName(), event.getDescription()));
|
||||
Account acct = getManagementServer().findAccountById(Long.valueOf(event.getAccountId()));
|
||||
if (acct != null) {
|
||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.ACCOUNT.getName(), acct.getAccountName()));
|
||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN_ID.getName(), acct.getDomainId().toString()));
|
||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(acct.getDomainId()).getName()));
|
||||
}
|
||||
if (event.getCreateDate() != null) {
|
||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.CREATED.getName(), getDateString(event.getCreateDate())));
|
||||
}
|
||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.STATE.getName(), event.getState().toString()));
|
||||
eventData.add(new Pair<String, Object>(BaseCmd.Properties.PARENT_ID.getName(), (new Long(event.getStartId())).toString()));
|
||||
eTag[i++] = eventData;
|
||||
}
|
||||
Pair<String, Object> eventTag = new Pair<String, Object>("event", eTag);
|
||||
eventTags.add(eventTag);
|
||||
return eventTags;
|
||||
|
||||
return SerializerHelper.toSerializedString(response);
|
||||
}
|
||||
}
|
||||
|
||||
130
server/src/com/cloud/api/response/EventResponse.java
Normal file
130
server/src/com/cloud/api/response/EventResponse.java
Normal file
@ -0,0 +1,130 @@
|
||||
package com.cloud.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.api.ResponseObject;
|
||||
import com.cloud.event.EventState;
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class EventResponse implements ResponseObject {
|
||||
@Param(name="id")
|
||||
private Long id;
|
||||
|
||||
@Param(name="username")
|
||||
private String username;
|
||||
|
||||
@Param(name="type")
|
||||
private String eventType;
|
||||
|
||||
@Param(name="level")
|
||||
private String level;
|
||||
|
||||
@Param(name="description")
|
||||
private String description;
|
||||
|
||||
@Param(name="account")
|
||||
private String accountName;
|
||||
|
||||
@Param(name="domainid")
|
||||
private Long domainId;
|
||||
|
||||
@Param(name="domain")
|
||||
private String domainName;
|
||||
|
||||
@Param(name="created")
|
||||
private Date created;
|
||||
|
||||
@Param(name="state")
|
||||
private EventState state;
|
||||
|
||||
@Param(name="parentid")
|
||||
private Long parentId;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getEventType() {
|
||||
return eventType;
|
||||
}
|
||||
|
||||
public void setEventType(String eventType) {
|
||||
this.eventType = eventType;
|
||||
}
|
||||
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public void setDomainId(Long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public String getDomainName() {
|
||||
return domainName;
|
||||
}
|
||||
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public EventState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(EventState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
}
|
||||
@ -38,6 +38,7 @@ import com.cloud.api.commands.ListCfgsByCmd;
|
||||
import com.cloud.api.commands.ListClustersCmd;
|
||||
import com.cloud.api.commands.ListDiskOfferingsCmd;
|
||||
import com.cloud.api.commands.ListDomainsCmd;
|
||||
import com.cloud.api.commands.ListEventsCmd;
|
||||
import com.cloud.api.commands.LockAccountCmd;
|
||||
import com.cloud.api.commands.LockUserCmd;
|
||||
import com.cloud.api.commands.RebootSystemVmCmd;
|
||||
@ -1173,7 +1174,7 @@ public interface ManagementServer {
|
||||
* @param c
|
||||
* @return List of Events.
|
||||
*/
|
||||
List<EventVO> searchForEvents(Criteria c);
|
||||
List<EventVO> searchForEvents(ListEventsCmd c) throws PermissionDeniedException, InvalidParameterValueException;
|
||||
|
||||
List<EventVO> listPendingEvents(int entryTime, int duration);
|
||||
|
||||
|
||||
@ -77,6 +77,7 @@ import com.cloud.api.commands.ListCfgsByCmd;
|
||||
import com.cloud.api.commands.ListClustersCmd;
|
||||
import com.cloud.api.commands.ListDiskOfferingsCmd;
|
||||
import com.cloud.api.commands.ListDomainsCmd;
|
||||
import com.cloud.api.commands.ListEventsCmd;
|
||||
import com.cloud.api.commands.LockAccountCmd;
|
||||
import com.cloud.api.commands.LockUserCmd;
|
||||
import com.cloud.api.commands.PrepareForMaintenanceCmd;
|
||||
@ -4243,10 +4244,6 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
return _configMgr.changePrivateIPRange(add, podId, startIP, endIP);
|
||||
}
|
||||
|
||||
private List<UserVO> findUsersLike(String username) {
|
||||
return _userDao.findUsersLike(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User findUserById(Long userId) {
|
||||
return _userDao.findById(userId);
|
||||
@ -5104,37 +5101,65 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventVO> searchForEvents(Criteria c) {
|
||||
Filter searchFilter = new Filter(EventVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit());
|
||||
public List<EventVO> searchForEvents(ListEventsCmd cmd) throws PermissionDeniedException, InvalidParameterValueException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Long accountId = null;
|
||||
boolean isAdmin = false;
|
||||
String accountName = cmd.getAccountName();
|
||||
Long domainId = cmd.getDomainId();
|
||||
|
||||
Object[] userIds = (Object[]) c.getCriteria(Criteria.USERID);
|
||||
Object[] accountIds = (Object[]) c.getCriteria(Criteria.ACCOUNTID);
|
||||
Object username = c.getCriteria(Criteria.USERNAME);
|
||||
Object accountName = c.getCriteria(Criteria.ACCOUNTNAME);
|
||||
Object type = c.getCriteria(Criteria.TYPE);
|
||||
Object level = c.getCriteria(Criteria.LEVEL);
|
||||
// Object description = c.getCriteria(Criteria.DESCRIPTION);
|
||||
Date startDate = (Date) c.getCriteria(Criteria.STARTDATE);
|
||||
Date endDate = (Date) c.getCriteria(Criteria.ENDDATE);
|
||||
Object domainId = c.getCriteria(Criteria.DOMAINID);
|
||||
Object keyword = c.getCriteria(Criteria.KEYWORD);
|
||||
if ((account == null) || isAdmin(account.getType())) {
|
||||
isAdmin = true;
|
||||
// validate domainId before proceeding
|
||||
if (domainId != null) {
|
||||
if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
||||
throw new PermissionDeniedException("Invalid domain id (" + domainId + ") given, unable to list events.");
|
||||
}
|
||||
|
||||
if (accountName != null) {
|
||||
Account userAccount = _accountDao.findActiveAccount(accountName, domainId);
|
||||
if (userAccount != null) {
|
||||
accountId = userAccount.getId();
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "Unable to find account " + accountName + " in domain " + domainId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
domainId = ((account == null) ? DomainVO.ROOT_DOMAIN : account.getDomainId());
|
||||
}
|
||||
} else {
|
||||
accountId = account.getId();
|
||||
}
|
||||
|
||||
Filter searchFilter = new Filter(EventVO.class, "createDate", false, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
|
||||
Object type = cmd.getType();
|
||||
Object level = cmd.getLevel();
|
||||
Date startDate = cmd.getStartDate();
|
||||
Date endDate = cmd.getEndDate();
|
||||
Object keyword = cmd.getKeyword();
|
||||
Integer entryTime = cmd.getEntryTime();
|
||||
Integer duration = cmd.getDuration();
|
||||
|
||||
if ((entryTime != null) && (duration != null)) {
|
||||
if (entryTime <= duration){
|
||||
throw new InvalidParameterValueException("Entry time must be greater than duration");
|
||||
}
|
||||
return listPendingEvents(entryTime, duration);
|
||||
}
|
||||
|
||||
SearchBuilder<EventVO> sb = _eventDao.createSearchBuilder();
|
||||
sb.and("levelL", sb.entity().getLevel(), SearchCriteria.Op.LIKE);
|
||||
sb.and("userIdEQ", sb.entity().getUserId(), SearchCriteria.Op.EQ);
|
||||
sb.and("userIdIN", sb.entity().getUserId(), SearchCriteria.Op.IN);
|
||||
sb.and("accountIdEQ", sb.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
sb.and("accountIdIN", sb.entity().getAccountId(), SearchCriteria.Op.IN);
|
||||
sb.and("levelEQ", sb.entity().getLevel(), SearchCriteria.Op.EQ);
|
||||
sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
sb.and("accountName", sb.entity().getAccountName(), SearchCriteria.Op.LIKE);
|
||||
sb.and("domainIdEQ", sb.entity().getDomainId(), SearchCriteria.Op.EQ);
|
||||
sb.and("type", sb.entity().getType(), SearchCriteria.Op.EQ);
|
||||
sb.and("levelEQ", sb.entity().getLevel(), SearchCriteria.Op.EQ);
|
||||
// sb.and("description", sb.entity().getDescription(), SearchCriteria.Op.LIKE);
|
||||
sb.and("createDateB", sb.entity().getCreateDate(), SearchCriteria.Op.BETWEEN);
|
||||
sb.and("createDateG", sb.entity().getCreateDate(), SearchCriteria.Op.GTEQ);
|
||||
sb.and("createDateL", sb.entity().getCreateDate(), SearchCriteria.Op.LTEQ);
|
||||
|
||||
if ((accountIds == null) && (accountName == null) && (domainId != null)) {
|
||||
if ((accountId == null) && (accountName == null) && (domainId != null) && isAdmin) {
|
||||
// if accountId isn't specified, we can do a domain match for the admin case
|
||||
SearchBuilder<DomainVO> domainSearch = _domainDao.createSearchBuilder();
|
||||
domainSearch.and("path", domainSearch.entity().getPath(), SearchCriteria.Op.LIKE);
|
||||
@ -5150,58 +5175,23 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
sc.addAnd("level", SearchCriteria.Op.SC, ssc);
|
||||
}
|
||||
|
||||
// if (keyword != null) {
|
||||
// sc.setParameters("levelL", "%" + keyword + "%");
|
||||
// } else if (level != null) {
|
||||
// sc.setParameters("levelEQ", level);
|
||||
// }
|
||||
|
||||
// if (description != null) {
|
||||
// sc.setParameters("description", "%" + description + "%");
|
||||
// }
|
||||
|
||||
if(level!=null)
|
||||
if (level != null)
|
||||
sc.setParameters("levelEQ", level);
|
||||
|
||||
if (userIds == null && username != null) {
|
||||
List<UserVO> users = findUsersLike((String) username);
|
||||
if (users == null || users.size() == 0) {
|
||||
return new ArrayList<EventVO>();
|
||||
}
|
||||
userIds = new Long[users.size()];
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
userIds[i] = users.get(i).getId();
|
||||
}
|
||||
}
|
||||
|
||||
if (userIds != null) {
|
||||
if (userIds.length == 1) {
|
||||
if ((userIds[0] != null) && !((Long) userIds[0]).equals(Long.valueOf(-1))) {
|
||||
sc.setParameters("userIdEQ", userIds[0]);
|
||||
}
|
||||
} else {
|
||||
sc.setParameters("userIdIN", userIds);
|
||||
}
|
||||
}
|
||||
if (accountIds != null) {
|
||||
if (accountIds.length == 1) {
|
||||
if ((accountIds[0] != null) && !((Long) accountIds[0]).equals(Long.valueOf(-1))) {
|
||||
sc.setParameters("accountIdEQ", accountIds[0]);
|
||||
}
|
||||
} else {
|
||||
sc.setParameters("accountIdIN", accountIds);
|
||||
}
|
||||
if (accountId != null) {
|
||||
sc.setParameters("accountId", accountId);
|
||||
} else if (domainId != null) {
|
||||
if (accountName != null) {
|
||||
sc.setParameters("domainIdEQ", domainId);
|
||||
sc.setParameters("accountName", "%" + accountName + "%");
|
||||
sc.addAnd("removed", SearchCriteria.Op.NULL);
|
||||
} else {
|
||||
} else if (isAdmin) {
|
||||
DomainVO domain = _domainDao.findById((Long)domainId);
|
||||
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
|
||||
}
|
||||
}
|
||||
|
||||
if (type != null) {
|
||||
sc.setParameters("type", type);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user