workflowStateLabels.put("ws." + s.getName(), s.getDisplayName());
}
}
String state = page.pageParam(String.class, "state", null);
final ObjectType type = ObjectType.getInstance(page.pageParam(UUID.class, "typeId", null));
Query<?> draftsQuery;
if ("draft".equals(state)) {
draftsQuery = Query.
from(Object.class).
where("_type = ? or cms.content.draft = true", Draft.class);
} else if (state != null && state.startsWith("ws.")) {
draftsQuery = Query.
from(Object.class).
where("cms.workflow.currentState = ?", state.substring(3));
} else {
draftsQuery = Query.
from(Object.class).
where("_type = ? or cms.content.draft = true or cms.workflow.currentState != missing", Draft.class);
}
final UserType userType = page.pageParam(UserType.class, "userType", UserType.ANYONE);
String userParameter = userType + ".value";
final Object user = Query.from(Object.class).where("_id = ?", page.pageParam(UUID.class, userParameter, null)).first();
QueryFilter<Object> queryFilter = null;
if (type != null || userType != UserType.ANYONE) {
queryFilter = new QueryFilter<Object>() {
@Override
public boolean include(Object item) {
State itemState = State.getInstance(item);
boolean typeOk = true;
boolean userOk = true;
if (type != null) {
ObjectType itemType = item instanceof Draft ? ((Draft) item).getObjectType() : itemState.getType();
typeOk = itemType != null && itemType.getGroups().contains(type.getInternalName());
}
if (userType != UserType.ANYONE) {
ToolUser updateUser = itemState.as(Content.ObjectModification.class).getUpdateUser();