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


Java DataUpdateRequest.where方法代码示例

本文整理汇总了Java中com.redhat.lightblue.client.request.data.DataUpdateRequest.where方法的典型用法代码示例。如果您正苦于以下问题:Java DataUpdateRequest.where方法的具体用法?Java DataUpdateRequest.where怎么用?Java DataUpdateRequest.where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.redhat.lightblue.client.request.data.DataUpdateRequest的用法示例。


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

示例1: notificationStatusIfCurrent

import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入方法依赖的package包/类
/** "Status" here means status and corresponding date(s) to go along with it. */
public static DataUpdateRequest notificationStatusIfCurrent(NotificationEntity entity,
        @Nullable Date originalProcessingDate) {
    DataUpdateRequest request = new DataUpdateRequest(
            NotificationEntity.ENTITY_NAME,
            NotificationEntity.ENTITY_VERSION);

    request.where(Query.and(
            Query.withValue("_id", BinOp.eq, entity.get_id()),
            Query.withValue("processingDate", BinOp.eq, originalProcessingDate)
    ));

    List<Update> setStatusAndDates = new ArrayList<>(3);
    setStatusAndDates.add(Update.set("processingDate", entity.getProcessingDate()));
    setStatusAndDates.add(Update.set("status", entity.getStatus().toString()));

    if (entity.getProcessedDate() != null){
        setStatusAndDates.add(Update.set("processedDate", entity.getProcessedDate()));
    }

    request.updates(setStatusAndDates);

    return request;
}
 
开发者ID:esbtools,项目名称:event-handler,代码行数:25,代码来源:UpdateRequests.java

示例2: notificationsStatusAndProcessedDate

import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入方法依赖的package包/类
public static Collection<DataUpdateRequest> notificationsStatusAndProcessedDate(
        Collection<NotificationEntity> updatedNotificationEntities) {
    List<DataUpdateRequest> requests = new ArrayList<>(updatedNotificationEntities.size());

    for (NotificationEntity entity : updatedNotificationEntities) {
        DataUpdateRequest request = new DataUpdateRequest(
                NotificationEntity.ENTITY_NAME,
                NotificationEntity.ENTITY_VERSION);

        if (entity.get_id() == null) {
            logger.warn("Tried to update an entity's status and processed date, but entity " +
                    "has no id. Entity was: " + entity);
            continue;
        }

        request.where(Query.withValue("_id", BinOp.eq, entity.get_id()));

        List<Update> updates = new ArrayList<>(2);
        updates.add(Update.set("status", entity.getStatus().toString()));

        Date processedDate = entity.getProcessedDate();

        if (processedDate != null) {
            updates.add(Update.set("processedDate", processedDate));
        }

        // Work around client bug.
        request.updates(updates.toArray(new Update[updates.size()]));

        requests.add(request);
    }

    return requests;
}
 
开发者ID:esbtools,项目名称:event-handler,代码行数:35,代码来源:UpdateRequests.java

示例3: documentEventsStatusAndProcessedDate

import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入方法依赖的package包/类
public static Collection<DataUpdateRequest> documentEventsStatusAndProcessedDate(
        Collection<DocumentEventEntity> updatedEventEntities) {
    List<DataUpdateRequest> requests = new ArrayList<>(updatedEventEntities.size());

    for (DocumentEventEntity entity : updatedEventEntities) {
        DataUpdateRequest request = new DataUpdateRequest(
                DocumentEventEntity.ENTITY_NAME,
                DocumentEventEntity.VERSION);

        if (entity.get_id() == null) {
            logger.warn("Tried to update an entity's status and processed date, but entity " +
                    "has no id. Entity was: " + entity);
            continue;
        }

        request.where(Query.withValue("_id", BinOp.eq, entity.get_id()));

        List<Update> updates = new ArrayList<>(2);
        updates.add(Update.set("status", entity.getStatus().toString()));

        ZonedDateTime processedDate = entity.getProcessedDate();

        if (processedDate != null) {
            updates.add(Update.set("processedDate", Date.from(processedDate.toInstant())));
        }

        // Work around client bug.
        // https://github.com/lightblue-platform/lightblue-client/issues/225
        request.updates(updates.toArray(new Update[updates.size()]));

        requests.add(request);
    }

    return requests;
}
 
开发者ID:esbtools,项目名称:event-handler,代码行数:36,代码来源:UpdateRequests.java

示例4: testWithRange

import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入方法依赖的package包/类
@Test
public void testWithRange() throws Exception {
    Country c1 = new Country();
    c1.setName("Poland");
    c1.setIso2Code("PL");
    c1.setIso3Code("POL");

    Country c2 = new Country();
    c2.setName("United States");
    c2.setIso2Code("US");
    c2.setIso3Code("USA");

    DataInsertRequest insertRequest = new DataInsertRequest("country");
    insertRequest.create(c1, c2);
    getLightblueClient().data(insertRequest);

    //Do test
    DataUpdateRequest updateRequest = new DataUpdateRequest("country");
    updateRequest.updates(Update.set("name", "Canada"));
    updateRequest.where(Query.withValue("objectType", Query.eq, "country"));
    updateRequest.returns(new Projection[]{Projection.includeFieldRecursively("*")}, 0, 1);
    Country[] countries = getLightblueClient().data(updateRequest, Country[].class);

    assertNotNull(countries);
    assertEquals(1, countries.length);
    assertEquals("Canada", countries[0].getName());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-client,代码行数:28,代码来源:TestDataUpdateRequest.java

示例5: update

import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入方法依赖的package包/类
private void update(List<MigrationJob> mjList) throws Exception {
    batchCreate(mjList);
    DataUpdateRequest upd = new DataUpdateRequest("migrationConfiguration", null);
    upd.where(Query.withValue("_id", Query.eq, migrationConfiguration.get_id()));
    upd.updates(Update.set("timestampInitialValue", Literal.value(migrationConfiguration.getTimestampInitialValue())));
    lbClient.data(upd);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-migrator,代码行数:8,代码来源:ConsistencyCheckerController.java

示例6: documentEventStatusDatesAndSurvivorOfIfCurrent

import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入方法依赖的package包/类
/** "Status" here means status and corresponding date(s) to go along with it. */
public static DataUpdateRequest documentEventStatusDatesAndSurvivorOfIfCurrent(DocumentEventEntity entity,
        @Nullable ZonedDateTime originalProcessingDate) {
    DataUpdateRequest request = new DataUpdateRequest(
            DocumentEventEntity.ENTITY_NAME,
            DocumentEventEntity.VERSION);

    List<Query> idStatusAndDateMatch = new ArrayList<>();
    List<Update> updateStatusDateAndSurvivorOf = new ArrayList<>(2);

    ZonedDateTime processedDate = entity.getProcessedDate();

    idStatusAndDateMatch.add(Query.withValue("_id", BinOp.eq, entity.get_id()));

    if (originalProcessingDate != null) {
        idStatusAndDateMatch.add(Query.withValue(
                "processingDate", BinOp.eq,
                Date.from(originalProcessingDate.toInstant())));

        // We don't care if original event was processing or unprocessed. Unprocessed happens
        // when event is manually unprocessed. Matching timestamp still ensures we prevent
        // double processing.
        idStatusAndDateMatch.add(Query.withValues("status", Query.NaryOp.in, Literal.values(
                DocumentEventEntity.Status.processing.toString(),
                DocumentEventEntity.Status.unprocessed.toString())));
    } else {
        idStatusAndDateMatch.add(
                Query.withValue("processingDate", BinOp.eq, Literal.value(null)));
        idStatusAndDateMatch.add(
                Query.withValue("status", BinOp.eq, DocumentEventEntity.Status.unprocessed.toString()));
    }

    if (processedDate != null) {
        updateStatusDateAndSurvivorOf.add(
                Update.set("processedDate", Date.from(processedDate.toInstant())));
    }

    updateStatusDateAndSurvivorOf.add(
            Update.set("status", entity.getStatus().toString()));
    updateStatusDateAndSurvivorOf.add(
            Update.set("processingDate", Date.from(entity.getProcessingDate().toInstant())));

    if (entity.getSurvivorOfIds() != null) {
        String[] survivorOfIds = entity.getSurvivorOfIds().stream().toArray(String[]::new);
        updateStatusDateAndSurvivorOf.add(Update.set("survivorOfIds",
                // https://github.com/lightblue-platform/lightblue-client/issues/289
                Literal.value(Literal.toJson(Literal.values(survivorOfIds)))));
    }

    request.where(Query.and(idStatusAndDateMatch));
    request.updates(updateStatusDateAndSurvivorOf);

    return request;
}
 
开发者ID:esbtools,项目名称:event-handler,代码行数:55,代码来源:UpdateRequests.java


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