• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DBQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: copyConfiguration

import org.mongojack.DBQuery; //导入依赖的package包/类
public CollectorConfiguration copyConfiguration(String id, String name) {
    CollectorConfiguration collectorConfigurationA = dbCollection.findOne(DBQuery.is("_id", id));
    HashMap<String, String> outputIdTranslation= new HashMap<>();
    List<CollectorOutput> outputList = new ArrayList<>();
    List<CollectorInput> inputList = new ArrayList<>();
    List<CollectorConfigurationSnippet> snippetList = new ArrayList<>();

    collectorConfigurationA.outputs().stream()
            .forEach(output -> {
                CollectorOutput copiedOutput = CollectorOutput.create(output.backend(), output.type(), output.name(), output.properties());
                outputIdTranslation.put(output.outputId(), copiedOutput.outputId());
                outputList.add(copiedOutput);
            });
    collectorConfigurationA.inputs().stream()
            .forEach(input -> inputList.add(CollectorInput.create(input.type(), input.backend(), input.name(), outputIdTranslation.get(input.forwardTo()), input.properties())));
    collectorConfigurationA.snippets().stream()
            .forEach(snippet -> snippetList.add(CollectorConfigurationSnippet.create(snippet.backend(), snippet.name(), snippet.snippet())));

    List<String> tags = Collections.emptyList();
    CollectorConfiguration collectorConfigurationB = CollectorConfiguration.create(
            name,
            tags,
            inputList,
            outputList,
            snippetList);
    return collectorConfigurationB;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:28,代码来源:CollectorConfigurationService.java


示例17: copyOutput

import org.mongojack.DBQuery; //导入依赖的package包/类
public CollectorConfiguration copyOutput(String id, String outputId, String name) {
    CollectorConfiguration collectorConfiguration = dbCollection.findOne(DBQuery.is("_id", id));
    List<CollectorOutput> outputList = new ArrayList<>();

    collectorConfiguration.outputs().stream()
            .filter(output -> output.outputId().equals(outputId))
            .forEach(output -> outputList.add(CollectorOutput.create(output.backend(), output.type(), name, output.properties())));
    collectorConfiguration.outputs().addAll(outputList);
    return collectorConfiguration;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:11,代码来源:CollectorConfigurationService.java


示例18: copyInput

import org.mongojack.DBQuery; //导入依赖的package包/类
public CollectorConfiguration copyInput(String id, String inputId, String name) {
    CollectorConfiguration collectorConfiguration = dbCollection.findOne(DBQuery.is("_id", id));
    List<CollectorInput> inputList = new ArrayList<>();

    collectorConfiguration.inputs().stream()
            .filter(input -> input.inputId().equals(inputId))
            .forEach(input -> inputList.add(CollectorInput.create(input.type(), input.backend(), name, input.forwardTo(), input.properties())));
    collectorConfiguration.inputs().addAll(inputList);
    return collectorConfiguration;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:11,代码来源:CollectorConfigurationService.java


示例19: copySnippet

import org.mongojack.DBQuery; //导入依赖的package包/类
public CollectorConfiguration copySnippet(String id, String snippetId, String name) {
    CollectorConfiguration collectorConfiguration = dbCollection.findOne(DBQuery.is("_id", id));
    List<CollectorConfigurationSnippet> snippetList = new ArrayList<>();

    collectorConfiguration.snippets().stream()
            .filter(snippet -> snippet.snippetId().equals(snippetId))
            .forEach(snippet -> snippetList.add(CollectorConfigurationSnippet.create(snippet.backend(), name, snippet.snippet())));
    collectorConfiguration.snippets().addAll(snippetList);
    return collectorConfiguration;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:11,代码来源:CollectorConfigurationService.java


示例20: save

import org.mongojack.DBQuery; //导入依赖的package包/类
@Override
public Collector save(Collector collector) {
    if (collector instanceof CollectorImpl) {
        final CollectorImpl collectorImpl = (CollectorImpl) collector;
        final Set<ConstraintViolation<CollectorImpl>> violations = validator.validate(collectorImpl);
        if (violations.isEmpty()) {
            return coll.findAndModify(DBQuery.is("id", collector.getId()), new BasicDBObject(), new BasicDBObject(), false, collectorImpl, true, true);
        } else {
            throw new IllegalArgumentException("Specified object failed validation: " + violations);
        }
    } else
        throw new IllegalArgumentException("Specified object is not of correct implementation type (" + collector.getClass() + ")!");
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:14,代码来源:CollectorServiceImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FinishedCallback类代码示例发布时间:2022-05-22
下一篇:
Java ValidateNestedProperties类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap