本文整理汇总了Java中fr.wseduc.webutils.Either类的典型用法代码示例。如果您正苦于以下问题:Java Either类的具体用法?Java Either怎么用?Java Either使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Either类属于fr.wseduc.webutils包,在下文中一共展示了Either类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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));
}
示例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));
}
示例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");
}
}
});
}
示例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);
}
}
});
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
示例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());
}
}
}));
}
}
}
示例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));
}
}
示例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()));
}
}
示例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));
}
示例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());
}
}
});
}
});
}