本文整理汇总了Java中fr.wseduc.webutils.Either类的典型用法代码示例。如果您正苦于以下问题:Java Either类的具体用法?Java Either怎么用?Java Either使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Either类属于fr.wseduc.webutils包,在下文中一共展示了Either类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: create
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Override
public void create(JsonObject data, UserInfos user, Handler<Either<String, JsonObject>> handler) {
String query =
"CREATE (c:Community {props}), " +
"c<-[:DEPENDS]-(cr:CommunityGroup:Group:Visible {name : c.name + '-read', type : 'read'}), " +
"c<-[:DEPENDS]-(cc:CommunityGroup:Group:Visible {name : c.name + '-contrib', type : 'contrib', users : ''}), " +
"c<-[:DEPENDS]-(cm:CommunityGroup:Group:Visible {name : c.name + '-manager', type : 'manager', users : ''}) " +
"SET cr.id = id(cr)+'-'+timestamp(), " +
"cc.id = id(cc)+'-'+timestamp(), cm.id = id(cm)+'-'+timestamp() " +
"WITH c, cm, cr, cc " +
"MATCH (u:User {id : {userId}}) " +
"CREATE u-[:IN]->cm, u-[:COMMUNIQUE]->cm, " +
"cc-[:COMMUNIQUE]->cr, cc-[:COMMUNIQUE]->cm, " +
"cm-[:COMMUNIQUE]->cr, cm-[:COMMUNIQUE]->cc " +
"RETURN c.id as id, cr.id as read, cc.id as contrib, cm.id as manager";
JsonObject params = new JsonObject()
.putString("userId", user.getUserId())
.putObject("props", data.putString("id", UUID.randomUUID().toString()));
neo4j.execute(query, params, validUniqueResultHandler(handler));
}
开发者ID:OPEN-ENT-NG,项目名称:community,代码行数:21,代码来源:DefaultCommunityService.java
示例2: update
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Override
public void update(String id, JsonObject data, Handler<Either<String, JsonObject>> handler) {
String name = data.getString("name");
String query;
if (name != null && !name.trim().isEmpty()) {
query = "MATCH (c:Community { id : {id}})<-[:DEPENDS]-(g:CommunityGroup) " +
"SET " + nodeSetPropertiesFromJson("c", data) +
", g.name = {name} + '-' + LAST(SPLIT(g.name, '-')) " +
"RETURN DISTINCT c.id as id, c.pageId as pageId";
} else {
query = "MATCH (c:Community { id : {id}}) " +
"SET " + nodeSetPropertiesFromJson("c", data) + " " +
"RETURN c.id as id";
}
data.putString("id", id);
neo4j.execute(query, data, validUniqueResultHandler(handler));
}
开发者ID:OPEN-ENT-NG,项目名称:community,代码行数:18,代码来源:DefaultCommunityService.java
示例3: updateShare
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Override
public void updateShare(String pageId, String userId, JsonObject value, Handler<Either<String, JsonObject>> handler) {
JsonArray shared = new JsonArray();
shared.add(new JsonObject().putString("groupId", value.getString("read")).
putBoolean("net-atos-entng-community-controllers-PagesController|get", true));
shared.add(new JsonObject().putString("groupId", value.getString("contrib")).
putBoolean("net-atos-entng-community-controllers-PagesController|get", true).
putBoolean("net-atos-entng-community-controllers-PagesController|update", true));
shared.add(new JsonObject().putString("groupId", value.getString("manager")).
putBoolean("net-atos-entng-community-controllers-PagesController|get", true).
putBoolean("net-atos-entng-community-controllers-PagesController|update", true).
putBoolean("net-atos-entng-community-controllers-PagesController|delete", true));
MongoUpdateBuilder updateQuery = new MongoUpdateBuilder().set("shared", shared);
QueryBuilder query = QueryBuilder.start("_id").is(pageId);
mongo.update(conf.getCollection(), MongoQueryBuilder.build(query), updateQuery.build(), MongoDbResult.validActionResultHandler(handler));
}
开发者ID:OPEN-ENT-NG,项目名称:community,代码行数:18,代码来源:DefaultCommunityService.java
示例4: update
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Put("/:id")
@SecuredAction(value = "", type = ActionType.RESOURCE)
public void update(final HttpServerRequest request) {
RequestUtils.bodyToJson(request, pathPrefix + "update", new Handler<JsonObject>() {
@Override
public void handle(JsonObject body) {
if (body.size() > 0) {
String name = body.getString("name");
Handler<Either<String, JsonObject>> handler = (name != null && !name.trim().isEmpty()) ?
updatePageHandler(request, name) : notEmptyResponseHandler(request);
communityService.update(request.params().get("id"), body, handler);
} else {
badRequest(request, "empty.json");
}
}
});
}
开发者ID:OPEN-ENT-NG,项目名称:community,代码行数:18,代码来源:CommunityController.java
示例5: listUsers
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Get("/:id/users")
@SecuredAction(value = "", type = ActionType.RESOURCE)
public void listUsers(final HttpServerRequest request) {
List<String> t = request.params().getAll("type");
JsonArray types = (t != null && !t.isEmpty()) ?
new JsonArray(t.toArray()) : resourcesTypes; //new JsonArray(RightsController.allowedSharingRights.toArray());
communityService.listUsers(request.params().get("id"), types, new Handler<Either<String, JsonObject>>() {
@Override
public void handle(final Either<String, JsonObject> event) {
final Handler<Either<String, JsonObject>> handler = defaultResponseHandler(request);
if (event.isRight()) {
final JsonObject res = event.right().getValue();
listVisible(request, I18n.acceptLanguage(request), new Handler<JsonObject>() {
@Override
public void handle(final JsonObject visibles) {
res.putObject("visibles", visibles);
handler.handle(event);
}
});
} else {
handler.handle(event);
}
}
});
}
开发者ID:OPEN-ENT-NG,项目名称:community,代码行数:26,代码来源:CommunityController.java
示例6: listUserBookings
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Override
public void listUserBookings(final UserInfos user, final Handler<Either<String, JsonArray>> handler){
StringBuilder query = new StringBuilder();
query.append("SELECT b.*, u.username AS owner_name, m.username AS moderator_name")
.append(" FROM rbs.booking AS b")
.append(" INNER JOIN rbs.users AS u ON b.owner = u.id")
.append(" LEFT JOIN rbs.users AS m on b.moderator_id = m.id")
.append(" WHERE b.owner = ?")
.append(" ORDER BY b.start_date, b.end_date");
JsonArray values = new JsonArray();
values.add(user.getUserId());
Sql.getInstance().prepared(query.toString(), values,
validResultHandler(handler));
}
开发者ID:OPEN-ENT-NG,项目名称:rbs,代码行数:17,代码来源:BookingServiceSqlImpl.java
示例7: listFullSlotsBooking
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Override
public void listFullSlotsBooking(final String bookingId,
final Handler<Either<String, JsonArray>> handler){
StringBuilder query = new StringBuilder();
JsonArray values = new JsonArray();
//find all booking without periodic booking
query.append("SELECT b.*, u.username AS owner_name, m.username AS moderator_name")
.append(" FROM rbs.booking AS b")
.append(" LEFT JOIN rbs.users AS u ON u.id = b.owner")
.append(" LEFT JOIN rbs.users AS m on b.moderator_id = m.id")
.append(" WHERE b.parent_booking_id=?");
values.add(parseId(bookingId));
query.append(" ORDER BY b.start_date, b.end_date");
Sql.getInstance().prepared(query.toString(), values,
validResultHandler(handler));
}
开发者ID:OPEN-ENT-NG,项目名称:rbs,代码行数:20,代码来源:BookingServiceSqlImpl.java
示例8: getDelaysAndTypeProperties
import fr.wseduc.webutils.Either; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void getDelaysAndTypeProperties(long resourceId, Handler<Either<String, JsonObject>> handler) {
StringBuilder query = new StringBuilder("SELECT r.min_delay, r.max_delay, t.owner, t.school_id,");
// Subquery to return managers
query.append(" (SELECT json_agg(DISTINCT ts.member_id) FROM rbs.resource_type_shares AS ts")
.append(" WHERE ts.resource_id = t.id")
.append(" AND ts.action = 'net-atos-entng-rbs-controllers-ResourceTypeController|shareJsonSubmit') AS managers");
query.append(" FROM rbs.resource AS r")
.append(" INNER JOIN rbs.resource_type AS t ON r.type_id = t.id")
.append(" WHERE r.id = ?");
JsonArray values = new JsonArray().add(resourceId);
Sql.getInstance().prepared(query.toString(), values, validUniqueResultHandler(handler));
}
开发者ID:OPEN-ENT-NG,项目名称:rbs,代码行数:21,代码来源:ResourceServiceSqlImpl.java
示例9: getModeratorsIds
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Override
public void getModeratorsIds(final String typeId, final Handler<Either<String, JsonArray>> handler) {
StringBuilder query = new StringBuilder();
JsonArray values = new JsonArray();
query.append("SELECT DISTINCT m.*")
.append(" FROM rbs.resource_type AS t")
.append(" INNER JOIN rbs.resource_type_shares AS ts ON t.id = ts.resource_id")
.append(" INNER JOIN rbs.members AS m ON (ts.member_id = m.id)")
.append(" WHERE ts.action = 'net-atos-entng-rbs-controllers-BookingController|processBooking'")
.append(" AND t.id = ?")
.append(" GROUP BY m.id");
values.add(parseId(typeId));
query.append(" UNION")
.append(" SELECT t.owner as id, t.owner as user_id, null as group_id")
.append(" FROM rbs.resource_type AS t")
.append(" WHERE t.id = ?");
values.add(parseId(typeId));
Sql.getInstance().prepared(query.toString(), values, validResultHandler(handler));
}
开发者ID:OPEN-ENT-NG,项目名称:rbs,代码行数:24,代码来源:ResourceTypeServiceSqlImpl.java
示例10: notifyOwner
import fr.wseduc.webutils.Either; //导入依赖的package包/类
private void notifyOwner(final HttpServerRequest request, final UserInfos user, final JsonObject resource, final String infoId, final String eventType) {
infoService.getOwnerInfo(infoId, new Handler<Either<String, JsonObject>>() {
@Override
public void handle(Either<String, JsonObject> event) {
if (event.isRight()) {
String ownerId = event.right().getValue().getString("owner");
if (!ownerId.equals(user.getUserId()) && resource.containsField("thread_id") && resource.containsField("title")) {
UserInfos owner = new UserInfos();
owner.setUserId(ownerId);
notifyTimeline(request, user, owner, resource.getNumber("thread_id").toString(), infoId, resource.getString("title"), eventType);
}
} else {
log.error("Unable to create notification : GetOwnerInfo failed");
}
}
});
// notifyTimeline(request, user, resource.getString("thread_id"), infoId, resource.getString("title"), NEWS_UPDATE_EVENT_TYPE);
}
开发者ID:OPEN-ENT-NG,项目名称:actualites,代码行数:19,代码来源:InfoController.java
示例11: deleteGroups
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Override
public void deleteGroups(JsonArray groups) {
if (groups != null && groups.size() > 0){
final JsonArray groupsIds = new JsonArray();
for (Object o : groups) {
if (!(o instanceof JsonObject)) continue;
final JsonObject j = (JsonObject) o;
groupsIds.add(j.getString("group"));
}
if (groupsIds.size() > 0) {
SqlStatementsBuilder statementsBuilder = new SqlStatementsBuilder();
statementsBuilder.prepared("DELETE FROM rbs.groups WHERE id IN " + Sql.listPrepared(groupsIds.toArray()), groupsIds);
Sql.getInstance().transaction(statementsBuilder.build(), SqlResult.validRowsResultHandler(new Handler<Either<String, JsonObject>>() {
@Override
public void handle(Either<String, JsonObject> event) {
if (event.isRight()) {
log.info("Removed share on ResourceTypes and Resources for groups : " + groupsIds.toList().toString());
} else {
log.error("Failed to remove share on ResourceTypes and Resources for groups : " + groupsIds.toList().toString() + " Error message : " + event.left().getValue());
}
}
}));
}
}
}
开发者ID:OPEN-ENT-NG,项目名称:rbs,代码行数:26,代码来源:RbsRepositoryEvents.java
示例12: retrieve
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Override
public void retrieve(String id, Handler<Either<String, JsonObject>> handler) {
String query;
JsonArray values = new JsonArray();
if (id != null) {
query = "SELECT t.id as _id, t.title, t.icon, t.mode, t.created, t.modified, t.owner, u.username" +
", json_agg(row_to_json(row(ts.member_id, ts.action)::actualites.share_tuple)) as shared" +
", array_to_json(array_agg(group_id)) as groups" +
" FROM actualites.thread AS t" +
" LEFT JOIN actualites.users AS u ON t.owner = u.id" +
" LEFT JOIN actualites.thread_shares AS ts ON t.id = ts.resource_id" +
" LEFT JOIN actualites.members AS m ON (ts.member_id = m.id AND m.group_id IS NOT NULL)" +
" WHERE t.id = ? " +
" GROUP BY t.id, u.username" +
" ORDER BY t.modified DESC";
values.add(Sql.parseId(id));
Sql.getInstance().prepared(query.toString(), values, SqlResult.parseSharedUnique(handler));
}
}
开发者ID:OPEN-ENT-NG,项目名称:actualites,代码行数:20,代码来源:ThreadServiceSqlImpl.java
示例13: searchResource
import fr.wseduc.webutils.Either; //导入依赖的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(ShareBigFilesSearchingEvents.class.getSimpleName())) {
final List<String> returnFields = new ArrayList<String>();
returnFields.add("fileNameLabel");
returnFields.add("description");
returnFields.add("modified");
returnFields.add("owner.userId");
returnFields.add("owner.displayName");
searchService.search(userId, groupIds.toList(), returnFields, searchWords.toList(), page, limit, new Handler<Either<String, JsonArray>>() {
@Override
public void handle(Either<String, JsonArray> event) {
if (event.isRight()) {
final JsonArray res = formatSearchResult(event.right().getValue(), columnsHeader, locale);
handler.handle(new Right<String, JsonArray>(res));
} else {
handler.handle(new Either.Left<String, JsonArray>(event.left().getValue()));
}
if (log.isDebugEnabled()) {
log.debug("[ShareBigFilesSearchingEvents][searchResource] The resources searched by user are finded");
}
}
});
} else {
handler.handle(new Right<String, JsonArray>(new JsonArray()));
}
}
开发者ID:OPEN-ENT-NG,项目名称:share-big-files,代码行数:30,代码来源:ShareBigFilesSearchingEvents.java
示例14: retrieves
import fr.wseduc.webutils.Either; //导入依赖的package包/类
public void retrieves(List<String> ids, final JsonObject projection, UserInfos user, Handler<Either<String, JsonArray>> handler) {
QueryBuilder builder = QueryBuilder.start("_id").in(new HashSet<String>(ids));
if (user == null) {
builder.put("visibility").is(VisibilityFilter.PUBLIC.name());
}
mongo.find(ShareBigFiles.SHARE_BIG_FILE_COLLECTION, MongoQueryBuilder.build(builder),
null, projection, validResultsHandler(handler));
}
开发者ID:OPEN-ENT-NG,项目名称:share-big-files,代码行数:9,代码来源:ShareBigFilesServiceImpl.java
示例15: list
import fr.wseduc.webutils.Either; //导入依赖的package包/类
/**
* Lists every object associated with the user.
* @param request Client request.
*/
@Get("/list")
@SecuredAction(value = read_only, type = ActionType.AUTHENTICATED)
public void list(final HttpServerRequest request) {
UserUtils.getUserInfos(eb, request, new Handler<UserInfos>() {
@Override
public void handle(final UserInfos user) {
String filter = request.params().get("filter");
VisibilityFilter v = VisibilityFilter.ALL;
if (filter != null) {
try {
v = VisibilityFilter.valueOf(filter.toUpperCase());
} catch (IllegalArgumentException | NullPointerException e) {
v = VisibilityFilter.ALL;
if (log.isDebugEnabled()) {
log.debug("Invalid filter " + filter);
}
}
}
shareBigFileCrudService.list(v, user, new Handler<Either<String, JsonArray>>() {
@Override
public void handle(Either<String, JsonArray> event) {
if (event.isRight()) {
Renders.renderJson(request, event.right().getValue());
} else {
leftToResponse(request, event.left());
}
}
});
}
});
}
开发者ID:OPEN-ENT-NG,项目名称:share-big-files,代码行数:38,代码来源:ShareBigFilesController.java
示例16: delete
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Override
public void delete(String id, Handler<Either<String, JsonObject>> handler) {
StatementsBuilder sb = new StatementsBuilder();
JsonObject params = new JsonObject().putString("id", id);
sb.add("MATCH (c:Community { id : {id}}) RETURN c.pageId as pageId", params);
String query =
"MATCH (c:Community { id : {id}})<-[r:DEPENDS]-(g:CommunityGroup) " +
"OPTIONAL MATCH g<-[r2:IN|COMMUNIQUE]-() " +
"DELETE c, r, g, r2 ";
sb.add(query, params);
neo4j.executeTransaction(sb.build(), null, true, validUniqueResultHandler(0, handler));
}
开发者ID:OPEN-ENT-NG,项目名称:community,代码行数:13,代码来源:DefaultCommunityService.java
示例17: list
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Override
public void list(UserInfos user, Handler<Either<String, JsonArray>> handler) {
String query =
"MATCH (u:User {id : {userId}})-[:IN]->(g:CommunityGroup)-[:DEPENDS]->(c:Community) " +
"RETURN c.id as id, c.name as name, c.description as description, " +
"c.icon as icon, c.pageId as pageId, COLLECT(g.type) as types, COLLECT(distinct {id: g.id, type: g.type, name: g.name}) as groups ";
JsonObject params = new JsonObject().putString("userId", user.getUserId());
neo4j.execute(query, params, validResultHandler(handler));
}
开发者ID:OPEN-ENT-NG,项目名称:community,代码行数:10,代码来源:DefaultCommunityService.java
示例18: get
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Override
public void get(String id, UserInfos user, Handler<Either<String,JsonObject>> handler) {
String query =
"MATCH (u:User {id : {userId}})-[:IN]->(g:CommunityGroup)-[:DEPENDS]->(c:Community {id: {id}}) " +
"RETURN c.id as id, c.name as name, c.description as description, " +
"c.icon as icon, c.pageId as pageId, COLLECT(g.type) as types, COLLECT(distinct {id: g.id, type: g.type, name: g.name}) as groups ";
JsonObject params = new JsonObject().putString("userId", user.getUserId()).putString("id", id);
neo4j.execute(query, params, validUniqueResultHandler(handler));
}
开发者ID:OPEN-ENT-NG,项目名称:community,代码行数:10,代码来源:DefaultCommunityService.java
示例19: listUsers
import fr.wseduc.webutils.Either; //导入依赖的package包/类
@Override
public void listUsers(String id, final JsonArray types, final Handler<Either<String, JsonObject>> handler) {
String query =
"MATCH (:Community {id: {id}})<-[:DEPENDS]-(:CommunityGroup {type : {type}})<-[:IN]-(u:User) " +
"RETURN u.id as id, u.displayName as displayName ";
JsonObject params = new JsonObject().putString("id", id);
StatementsBuilder sb = new StatementsBuilder();
for (Object o: types) {
if (!(o instanceof String)) continue;
sb.add(query, params.copy().putString("type", o.toString()));
}
neo4j.executeTransaction(sb.build(), null, true, new Handler<Message<JsonObject>>() {
@Override
public void handle(Message<JsonObject> r) {
if ("ok".equals(r.body().getString("status"))) {
JsonArray results = r.body().getArray("results");
JsonObject res = new JsonObject();
for (int i = 0; i < results.size(); i++) {
res.putArray(types.<String>get(i), results.<JsonArray>get(i));
}
handler.handle(new Either.Right<String, JsonObject>(res));
} else {
handler.handle(new Either.Left<String, JsonObject>(r.body().getString("message")));
}
}
});
}
开发者ID:OPEN-ENT-NG,项目名称:community,代码行数:28,代码来源:DefaultCommunityService.java
示例20: updatePageHandler
import fr.wseduc.webutils.Either; //导入依赖的package包/类
private Handler<Either<String, JsonObject>> updatePageHandler(final HttpServerRequest request, final String name) {
return new Handler<Either<String, JsonObject>>() {
@Override
public void handle(final Either<String, JsonObject> r) {
if (r.isRight()) {
String pageId = r.right().getValue().getString("pageId");
r.right().getValue().removeField("pageId");
JsonObject updatePage = new JsonObject()
.putString("action", "update")
.putString("pageId", pageId)
.putObject("page", new JsonObject()
.putString("title", name)
.putBoolean("hideInPages", true)
.putObject("markups", new JsonObject()
.putArray("view", new JsonArray()
.addObject(new JsonObject()
.putString("label", "community.edit")
.putString("resourceRight", "share")
.putString("href", "/community#/edit/" + pageId))
.addObject(new JsonObject()
.putString("label", "community.back.to")
.putString("resourceRight", "read")
.putString("href", "/community#/list")))));
eb.send("communityPages", updatePage, new Handler<Message<JsonObject>>() {
@Override
public void handle(Message<JsonObject> message) {
if (!"ok".equals(message.body().getString("status"))) {
log.error(message.body().getString("message"));
}
renderJson(request, r.right().getValue());
}
});
} else {
leftToResponse(request, r.left());
}
}
};
}
开发者ID:OPEN-ENT-NG,项目名称:community,代码行数:39,代码来源:CommunityController.java
注:本文中的fr.wseduc.webutils.Either类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论