本文整理汇总了Java中com.redhat.lightblue.client.request.data.DataUpdateRequest类的典型用法代码示例。如果您正苦于以下问题:Java DataUpdateRequest类的具体用法?Java DataUpdateRequest怎么用?Java DataUpdateRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataUpdateRequest类属于com.redhat.lightblue.client.request.data包,在下文中一共展示了DataUpdateRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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());
}
示例5: testUpdateToString
import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入依赖的package包/类
@Test
public void testUpdateToString() {
DataUpdateRequest request = new DataUpdateRequest("fake");
request.updates(Arrays.asList(Update.set("fakeField1", true)));
assertEquals(request.toString(), "POST /update/fake, body: {\"update\":{\"$set\":{\"fakeField1\":true}}}");
}
示例6: testUpdatesAsList
import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入依赖的package包/类
@Test
public void testUpdatesAsList() {
DataUpdateRequest request = new DataUpdateRequest("fake");
request.updates(Arrays.asList(Update.set("fakeField1", true)));
assertTrue(request.getBody(), request.getBody().contains("\"fakeField1\":true"));
}
示例7: testUpdateIfCurrent
import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入依赖的package包/类
@Test
public void testUpdateIfCurrent() {
DataUpdateRequest request = new DataUpdateRequest("fake");
request.ifCurrent("blah");
assertTrue(request.getBody(), request.getBody().contains("\"onlyIfCurrent\":true"));
assertTrue(request.getBody(), request.getBody().contains("\"documentVersions\":[\"blah\"]"));
}
示例8: testUpdatesAsArray
import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入依赖的package包/类
@Test
public void testUpdatesAsArray() {
DataUpdateRequest request = new DataUpdateRequest("fake");
request.updates(Update.set("fakeField1", true));
assertTrue(request.getBody(), request.getBody().contains("\"fakeField1\":true"));
}
示例9: testProjectionsAsList
import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入依赖的package包/类
@Test
public void testProjectionsAsList() {
DataUpdateRequest request = new DataUpdateRequest("fake");
request.returns(Arrays.asList(Projection.includeField("*")));
assertTrue(request.getBody(), request.getBody().contains(
"\"projection\":{\"field\":\"*\",\"include\":true,\"recursive\":false}"));
}
示例10: testProjectionsAsArray
import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入依赖的package包/类
@Test
public void testProjectionsAsArray() {
DataUpdateRequest request = new DataUpdateRequest("fake");
request.returns(Projection.includeField("*"));
assertTrue(request.getBody(), request.getBody().contains(
"\"projection\":{\"field\":\"*\",\"include\":true,\"recursive\":false}"));
}
示例11: testExecutionReadPreference
import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入依赖的package包/类
@Test
public void testExecutionReadPreference() {
DataUpdateRequest request = new DataUpdateRequest("fake");
request.execution(MongoExecution.withReadPreference(MongoExecution.ReadPreference.primaryPreferred));
assertTrue(request.getBody(), request.getBody().contains(
"\"execution\":{\"readPreference\":\"primaryPreferred\"}"));
}
示例12: testExecutionWriteConcern
import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入依赖的package包/类
@Test
public void testExecutionWriteConcern() {
DataUpdateRequest request = new DataUpdateRequest("fake");
request.execution(MongoExecution.withWriteConcern(WriteConcern.majority));
assertTrue(request.getBody(), request.getBody().contains(
"\"execution\":{\"writeConcern\":\"majority\"}"));
}
示例13: testExecutionMaxQueryTimeMS
import com.redhat.lightblue.client.request.data.DataUpdateRequest; //导入依赖的package包/类
@Test
public void testExecutionMaxQueryTimeMS() {
DataUpdateRequest request = new DataUpdateRequest("fake");
request.execution(MongoExecution.withMaxQueryTimeMS(1000));
assertTrue(request.getBody(), request.getBody().contains(
"\"execution\":{\"maxQueryTimeMS\":1000"));
}
示例14: 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);
}
示例15: 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;
}