本文整理汇总了Java中org.vertx.java.core.json.JsonArray.toList方法的典型用法代码示例。如果您正苦于以下问题:Java JsonArray.toList方法的具体用法?Java JsonArray.toList怎么用?Java JsonArray.toList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.vertx.java.core.json.JsonArray
的用法示例。
在下文中一共展示了JsonArray.toList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatSearchResult
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
private JsonArray formatSearchResult(final JsonArray results, final JsonArray columnsHeader, final String locale) {
final List<String> aHeader = columnsHeader.toList();
final JsonArray traity = new JsonArray();
for (int i=0;i<results.size();i++) {
final JsonObject j = results.get(i);
final JsonObject jr = new JsonObject();
if (j != null) {
jr.putString(aHeader.get(0), j.getString("fileNameLabel"));
jr.putString(aHeader.get(1), j.getString("description", ""));
jr.putObject(aHeader.get(2), j.getObject("modified"));
jr.putString(aHeader.get(3), j.getObject("owner").getString("displayName"));
jr.putString(aHeader.get(4), j.getObject("owner").getString("userId"));
jr.putString(aHeader.get(5), "/sharebigfiles#/view/" + j.getString("_id"));
traity.add(jr);
}
}
return traity;
}
示例2: formatSearchResult
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
private JsonArray formatSearchResult(final JsonArray results, final JsonArray columnsHeader, final String userId) {
final List<String> aHeader = columnsHeader.toList();
final JsonArray traity = new JsonArray();
for (int i=0;i<results.size();i++) {
final JsonObject j = results.get(i);
//Only published (status == 3) or owner
if (j != null && (j.getInteger("status", 0).equals(3) || j.getString("owner", "").equals(userId))) {
final JsonObject jr = new JsonObject();
jr.putString(aHeader.get(0), j.getString("title"));
jr.putString(aHeader.get(1), j.getString("content"));
jr.putObject(aHeader.get(2), new JsonObject().putValue("$date",
DatatypeConverter.parseDateTime(j.getString("modified")).getTime().getTime()));
jr.putString(aHeader.get(3), j.getString("username"));
jr.putString(aHeader.get(4), j.getString("owner"));
jr.putString(aHeader.get(5), "/actualites#/view/thread/"+
j.getNumber("thread_id",0) + "/info/"+j.getNumber("id",0));
traity.add(jr);
}
}
return traity;
}
示例3: formatSearchResult
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
private void formatSearchResult(final JsonArray results, final JsonArray columnsHeader, final Handler<Either<String, JsonArray>> handler) {
final List<String> aHeader = columnsHeader.toList();
final JsonArray traity = new JsonArray();
if (results.size() == 0) {
handler.handle(new Right<String, JsonArray>(traity));
} else {
for (int i = 0; i < results.size(); i++) {
final JsonObject j = results.get(i);
final JsonObject jr = new JsonObject();
if (j != null) {
jr.putString(aHeader.get(0), j.getString("name"));
jr.putString(aHeader.get(1), j.getString("description", ""));
jr.putObject(aHeader.get(2), j.getObject("modified"));
jr.putString(aHeader.get(3), j.getObject("owner").getString("displayName"));
jr.putString(aHeader.get(4), j.getObject("owner").getString("userId"));
jr.putString(aHeader.get(5), "/collaborativeeditor#/view/" + j.getString("_id"));
traity.add(jr);
}
}
handler.handle(new Right<String, JsonArray>(traity));
}
}
示例4: formatSearchResult
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
private JsonArray formatSearchResult(final JsonArray results, final JsonArray columnsHeader, String locale) {
final List<String> aHeader = columnsHeader.toList();
final JsonArray traity = new JsonArray();
final String dateFormat = "EEEEE dd MMMMM yyyy " + i18n.translate("rbs.search.date.to", I18n.DEFAULT_DOMAIN, locale) + " HH:mm";
final DateFormat dateFormatFromDB = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
for (int i=0;i<results.size();i++) {
final JsonObject j = results.get(i);
final JsonObject jr = new JsonObject();
if (j != null) {
Long start = 0L;
Long end = 0L;
try {
start = dateFormatFromDB.parse(j.getString("start_date")).getTime();
end = dateFormatFromDB.parse(j.getString("end_date")).getTime();
} catch (ParseException e) {
log.error("Can't parse date form RBS DB", e);
}
jr.putString(aHeader.get(0), formatTitle(j, start, end, dateFormat, locale));
jr.putString(aHeader.get(1), j.getString("booking_reason"));
jr.putObject(aHeader.get(2), new JsonObject().putValue("$date",
DatatypeConverter.parseDateTime(j.getString("modified")).getTime().getTime()));
jr.putString(aHeader.get(3), j.getString("owner_name"));
jr.putString(aHeader.get(4), j.getString("owner"));
jr.putString(aHeader.get(5), formatUrl(j.getNumber("id",0), start));
traity.add(jr);
}
}
return traity;
}
示例5: searchResource
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
@Override
public void searchResource(List<String> appFilters, String userId, JsonArray groupIds, JsonArray searchWords, Integer page, Integer limit, final JsonArray columnsHeader,
final String locale, final Handler<Either<String, JsonArray>> handler) {
if (appFilters.contains(RbsSearchingEvents.class.getSimpleName())) {
final List<String> idsUsers = new ArrayList<String>(groupIds.toList());
idsUsers.add(userId);
final StringBuilder query = new StringBuilder();
final String iLikeTemplate = "ILIKE ALL " + Sql.arrayPrepared(searchWords.toArray(), true);
final List<String> searchFields = new ArrayList<String>();
searchFields.add("r.name");
searchFields.add("t.name");
searchFields.add("b.booking_reason");
final String searchWhere = "b.parent_booking_id IS NULL AND (" + searchWherePrepared(searchFields, iLikeTemplate) + ")";
//find all booking without slots
query.append("SELECT b.id, b.start_date, b.end_date, b.booking_reason, b.modified, b.owner, r.name as resource_name, t.name as resource_type, u.username AS owner_name")
.append(" FROM rbs.booking AS b")
.append(" INNER JOIN rbs.resource AS r ON r.id = b.resource_id")
.append(" INNER JOIN rbs.resource_type AS t ON r.type_id = t.id")
.append(" LEFT JOIN rbs.resource_type_shares AS rs ON rs.resource_id = r.type_id")
.append(" LEFT JOIN rbs.users AS u ON u.id = b.owner")
.append(" WHERE (").append(searchWhere).append(") AND (rs.member_id IN ").append(Sql.listPrepared(idsUsers.toArray()))
.append(" OR t.owner = ?");
// fixme it is important for search : A local administrator of a given school can see all resources of the school's types, even if he is not owner or manager of these types or resources
// if necessary modify common to add userinfos.getFunctions
/*List<String> scope = getLocalAdminScope(user);
if (scope!=null && !scope.isEmpty()) {
query.append(" OR t.school_id IN ").append(Sql.listPrepared(scope.toArray()));
for (String schoolId : scope) {
values.addString(schoolId);
}
}
*/
query.append(") GROUP BY b.id, u.username, r.name, t.name ORDER BY modified DESC LIMIT ? OFFSET ?");
final JsonArray values = new JsonArray();
final List<String> valuesWildcard = searchValuesWildcard(searchWords.toList());
for (int i=0;i<searchFields.size();i++) {
for (final String value : valuesWildcard) {
values.addString(value);
}
}
for (String groupOruser : idsUsers) {
values.addString(groupOruser);
}
values.addString(userId);
final int offset = page * limit;
values.add(limit).add(offset);
Sql.getInstance().prepared(query.toString(), values, new Handler<Message<JsonObject>>() {
@Override
public void handle(Message<JsonObject> event) {
final Either<String, JsonArray> ei = validResult(event);
if (ei.isRight()) {
final JsonArray res = formatSearchResult(ei.right().getValue(), columnsHeader, locale);
handler.handle(new Right<String, JsonArray>(res));
} else {
handler.handle(new Either.Left<String, JsonArray>(ei.left().getValue()));
}
if (log.isDebugEnabled()) {
log.debug("[RbsSearchingEvents][searchResource] The resources searched by user are finded");
}
}
});
} else {
handler.handle(new Right<String, JsonArray>(new JsonArray()));
}
}