当前位置: 首页>>代码示例>>Java>>正文


Java DBQuery类代码示例

本文整理汇总了Java中org.mongojack.DBQuery的典型用法代码示例。如果您正苦于以下问题:Java DBQuery类的具体用法?Java DBQuery怎么用?Java DBQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DBQuery类属于org.mongojack包,在下文中一共展示了DBQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteInput

import org.mongojack.DBQuery; //导入依赖的package包/类
public int deleteInput(String id, String inputId) {
    CollectorConfiguration collectorConfiguration = dbCollection.findOne(DBQuery.is("_id", id));
    List<CollectorInput> inputList = collectorConfiguration.inputs();
    int deleted = 0;
    if (inputList != null) {
        for (int i = 0; i < inputList.size(); i++) {
            CollectorInput input = inputList.get(i);
            if (input.inputId().equals(inputId)) {
                collectorConfiguration.inputs().remove(i);
                deleted++;
            }
        }
        save(collectorConfiguration);
    }
    return deleted;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:17,代码来源:CollectorConfigurationService.java

示例2: deleteOutput

import org.mongojack.DBQuery; //导入依赖的package包/类
public int deleteOutput(String id, String outputId) {
    CollectorConfiguration collectorConfiguration = dbCollection.findOne(DBQuery.is("_id", id));
    List<CollectorOutput> outputList = collectorConfiguration.outputs();
    List<CollectorInput> inputList = collectorConfiguration.inputs();
    if (inputList.stream().filter(input -> input.forwardTo().equals(outputId)).count() != 0) {
        return -1;
    }
    int deleted = 0;
    if (outputList != null) {
        for (int i = 0; i < outputList.size(); i++) {
            CollectorOutput output = outputList.get(i);
            if (output.outputId().equals(outputId)) {
                collectorConfiguration.outputs().remove(i);
                deleted++;
            }
        }
        save(collectorConfiguration);
    }
    return deleted;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:21,代码来源:CollectorConfigurationService.java

示例3: deleteSnippet

import org.mongojack.DBQuery; //导入依赖的package包/类
public int deleteSnippet(String id, String snippetId) {
    CollectorConfiguration collectorConfiguration = dbCollection.findOne(DBQuery.is("_id", id));
    List<CollectorConfigurationSnippet> snippetList = collectorConfiguration.snippets();
    int deleted = 0;
    if (snippetList != null) {
        for (int i = 0; i < snippetList.size(); i++) {
            CollectorConfigurationSnippet snippet = snippetList.get(i);
            if (snippet.snippetId().equals(snippetId)) {
                collectorConfiguration.snippets().remove(i);
                deleted++;
            }
        }
        save(collectorConfiguration);
    }
    return deleted;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:17,代码来源:CollectorConfigurationService.java

示例4: update

import org.mongojack.DBQuery; //导入依赖的package包/类
@Override
public ReportSchedule update(String name, ReportSchedule schedule) {		
	
	if (schedule instanceof ReportScheduleImpl) {
		final ReportScheduleImpl scheduleImpl = (ReportScheduleImpl) schedule;
		LOG.debug("updated schedule: " + scheduleImpl);
		final Set<ConstraintViolation<ReportScheduleImpl>> violations = validator.validate(scheduleImpl);
		if (violations.isEmpty()) {
			//return coll.update(DBQuery.is("name", name), ruleImpl, false, false).getSavedObject();
			return coll.findAndModify(DBQuery.is("name", name), new BasicDBObject(), new BasicDBObject(),
					false, scheduleImpl, true, false);
		} else {
			throw new IllegalArgumentException("Specified object failed validation: " + violations);
		}
	} else
		throw new IllegalArgumentException(
				"Specified object is not of correct implementation type (" + schedule.getClass() + ")!");
}
 
开发者ID:cvtienhoven,项目名称:graylog-plugin-aggregates,代码行数:19,代码来源:ReportScheduleServiceImpl.java

示例5: checkUsername

import org.mongojack.DBQuery; //导入依赖的package包/类
@POST
@Path("/register/check/username")
public Response checkUsername(CheckNameDTO nameDTO) {
    Preconditions.checkNotNull(nameDTO);

    if(CharMatcher.WHITESPACE.matchesAnyOf(nameDTO.getName())) {
        return Response.status(Response.Status.FORBIDDEN).entity("{\"space\":\"true\"}").build();
    }

    //If these doesn't match, then the username is unsafe
    if (!nameDTO.getName().equals(HtmlEscapers.htmlEscaper().escape(nameDTO.getName()))) {
        log.warn("Unsafe username " + nameDTO.getName());
        return Response.status(Response.Status.FORBIDDEN).entity("{\"invalidChars\":\"true\"}").build();
    }

    @Cleanup DBCursor<Player> dbPlayer = playerCollection.find(
            DBQuery.is("username", nameDTO.getName().trim()), new BasicDBObject());

    if (dbPlayer.hasNext()) {
        return Response.status(Response.Status.FORBIDDEN).entity("{\"isTaken\":\"true\"}").build();
    }

    return Response.ok().build();
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:25,代码来源:AuthResource.java

示例6: authenticate

import org.mongojack.DBQuery; //导入依赖的package包/类
@Override
public Optional<Player> authenticate(BasicCredentials credentials) {
    @Cleanup DBCursor<Player> dbPlayer = playerCollection.find(
            DBQuery.is("username", credentials.getUsername()), new BasicDBObject());

    if (dbPlayer == null || !dbPlayer.hasNext()) {
        return Optional.empty();
    }

    Player player = dbPlayer.next();

    CivSingleton.instance().playerCache().put(player.getId(), player.getUsername());

    if (player.getPassword().equals(DigestUtils.sha1Hex(credentials.getPassword()))) {
        return Optional.of(player);
    }
    return Optional.empty();
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:19,代码来源:CivAuthenticator.java

示例7: newPassword

import org.mongojack.DBQuery; //导入依赖的package包/类
public boolean newPassword(ForgotpassDTO forgotpassDTO) {
    Preconditions.checkNotNull(forgotpassDTO.getEmail());
    Preconditions.checkNotNull(forgotpassDTO.getNewpassword());

    Player player = playerCollection.findOne(DBQuery.is(Player.EMAIL, forgotpassDTO.getEmail()));
    if (player == null) {
        log.error("Couldn't find user by email " + forgotpassDTO.getEmail());
        throw new WebApplicationException(Response.Status.NOT_FOUND);
    }

    player.setNewPassword(forgotpassDTO.getNewpassword());
    playerCollection.updateById(player.getId(), player);
    return SendEmail.sendMessage(player.getEmail(),
            "Please verify your email",
            "Your password was requested to be changed. If you want to change your password then please press this link: "
                    + SendEmail.REST_URL + "api/auth/verify/" + player.getId(), player.getId());
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:18,代码来源:PlayerAction.java

示例8: getChat

import org.mongojack.DBQuery; //导入依赖的package包/类
public List<ChatDTO> getChat(String pbfId) {
    Preconditions.checkNotNull(pbfId);
    List<Chat> chats = chatCollection.find(DBQuery.is("pbfId", pbfId)).sort(DBSort.desc("created")).toArray();
    if (chats == null) {
        return new ArrayList<>();
    }
    PBF pbf = findPBFById(pbfId);
    Map<String, String> colorMap = pbf.getPlayers().stream()
            .collect(Collectors.toMap(Playerhand::getUsername, (playerhand) -> {
                return (playerhand.getColor() != null) ? playerhand.getColor() : "";
            }));

    List<ChatDTO> chatDTOs = new ArrayList<>(chats.size());
    for (Chat c : chats) {
        chatDTOs.add(new ChatDTO(c.getId(), c.getPbfId(), c.getUsername(), c.getMessage(), colorMap.get(c.getUsername()), c.getCreatedInMillis()));
    }

    //Sort newest date first
    chatDTOs.sort((o1, o2) -> -Long.valueOf(o1.getCreated()).compareTo(o2.getCreated()));
    return chatDTOs;
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:22,代码来源:GameAction.java

示例9: changeUserFromExistingGame

import org.mongojack.DBQuery; //导入依赖的package包/类
public void changeUserFromExistingGame(String gameid, String oldUsername, String newUsername) {
    Preconditions.checkNotNull(gameid);
    Preconditions.checkNotNull(oldUsername);
    Preconditions.checkNotNull(newUsername);

    PBF pbf = pbfCollection.findOneById(gameid);
    Player toPlayer = playerCollection.find(DBQuery.is("username", newUsername)).toArray(1).get(0);

    //Find all instance of ownerid, and replace with newUsername
    Playerhand playerhandToReplace = pbf.getPlayers().stream().filter(p -> p.getUsername().equals(oldUsername)).findFirst().orElseThrow(PlayerAction::cannotFindPlayer);

    playerhandToReplace.setUsername(newUsername);
    playerhandToReplace.setPlayerId(toPlayer.getId());
    playerhandToReplace.setEmail(toPlayer.getEmail());

    playerhandToReplace.getBarbarians().forEach(b -> b.setOwnerId(toPlayer.getId()));
    playerhandToReplace.getBattlehand().forEach(b -> b.setOwnerId(toPlayer.getId()));
    playerhandToReplace.getTechsChosen().forEach(b -> b.setOwnerId(toPlayer.getId()));
    playerhandToReplace.getItems().forEach(b -> b.setOwnerId(toPlayer.getId()));

    pbfCollection.updateById(pbf.getId(), pbf);
    createInfoLog(pbf.getId(), newUsername + " is now playing instead of " + oldUsername);
    SendEmail.sendMessage(playerhandToReplace.getEmail(), "You are now playing in " + pbf.getName(), "Please log in to http://playciv.com and start playing!", playerhandToReplace.getPlayerId());
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:25,代码来源:GameAction.java

示例10: createPlayer

import org.mongojack.DBQuery; //导入依赖的package包/类
@Test
public void createPlayer() throws JsonProcessingException {
    @Cleanup DBCursor<Player> foobar = getApp().playerCollection.find(DBQuery.is("username", "foobar"));
    if (foobar.hasNext()) {
        getApp().playerCollection.removeById(foobar.next().getId());
    }

    Form form = new Form();
    form.param("username", "foobar");
    form.param("password", "foobar");
    form.param("email", "[email protected]");

    URI uri = UriBuilder.fromPath(BASE_URL + "/auth/register").build();
    Response response = client().target(uri)
            .request()
            .post(Entity.form(form));

    assertThat(response.getStatus()).isEqualTo(HttpStatus.CREATED_201);
    assertThat(response.getLocation().getPath()).contains(uri.getPath());
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:21,代码来源:AuthResourceTest.java

示例11: loadNamed

import org.mongojack.DBQuery; //导入依赖的package包/类
@Override
public Collection<RuleDao> loadNamed(Collection<String> ruleNames) {
    try {
        final DBCursor<RuleDao> ruleDaos = dbCollection.find(DBQuery.in("title", ruleNames));
        return Sets.newHashSet(ruleDaos.iterator());
    } catch (MongoException e) {
        log.error("Unable to bulk load rules", e);
        return Collections.emptySet();
    }
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:11,代码来源:MongoDbRuleService.java

示例12: load

import org.mongojack.DBQuery; //导入依赖的package包/类
@Override
public PipelineConnections load(String streamId) throws NotFoundException {
    final PipelineConnections oneById = dbCollection.findOne(DBQuery.is("stream_id", streamId));
    if (oneById == null) {
        throw new NotFoundException("No pipeline connections with for stream " + streamId);
    }
    return oneById;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:9,代码来源:MongoDbPipelineStreamConnectionsService.java

示例13: updateInputFromRequest

import org.mongojack.DBQuery; //导入依赖的package包/类
public CollectorConfiguration updateInputFromRequest(String id, String inputId, CollectorInput request) {
    CollectorConfiguration collectorConfiguration = dbCollection.findOne(DBQuery.is("_id", id));

    ListIterator<CollectorInput> inputIterator = collectorConfiguration.inputs().listIterator();
    while (inputIterator.hasNext()) {
        int i = inputIterator.nextIndex();
        CollectorInput input = inputIterator.next();
        if (input.inputId().equals(inputId)) {
            collectorConfiguration.inputs().set(i, request);
        }
    }
    return collectorConfiguration;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:14,代码来源:CollectorConfigurationService.java

示例14: updateOutputFromRequest

import org.mongojack.DBQuery; //导入依赖的package包/类
public CollectorConfiguration updateOutputFromRequest(String id, String outputId, CollectorOutput request) {
    CollectorConfiguration collectorConfiguration = dbCollection.findOne(DBQuery.is("_id", id));

    ListIterator<CollectorOutput> outputIterator = collectorConfiguration.outputs().listIterator();
    while (outputIterator.hasNext()) {
        int i = outputIterator.nextIndex();
        CollectorOutput output = outputIterator.next();
        if (output.outputId().equals(outputId)) {
            collectorConfiguration.outputs().set(i, request);
        }
    }
    return collectorConfiguration;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:14,代码来源:CollectorConfigurationService.java

示例15: updateSnippetFromRequest

import org.mongojack.DBQuery; //导入依赖的package包/类
public CollectorConfiguration updateSnippetFromRequest(String id, String snippetId, CollectorConfigurationSnippet request) {
    CollectorConfiguration collectorConfiguration = dbCollection.findOne(DBQuery.is("_id", id));

    ListIterator<CollectorConfigurationSnippet> snippetIterator = collectorConfiguration.snippets().listIterator();
    while (snippetIterator.hasNext()) {
        int i = snippetIterator.nextIndex();
        CollectorConfigurationSnippet snippet = snippetIterator.next();
        if (snippet.snippetId().equals(snippetId)) {
            collectorConfiguration.snippets().set(i, request);
        }
    }
    return collectorConfiguration;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:14,代码来源:CollectorConfigurationService.java


注:本文中的org.mongojack.DBQuery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。