本文整理汇总了Java中com.redhat.lightblue.client.response.LightblueDataResponse类的典型用法代码示例。如果您正苦于以下问题:Java LightblueDataResponse类的具体用法?Java LightblueDataResponse怎么用?Java LightblueDataResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LightblueDataResponse类属于com.redhat.lightblue.client.response包,在下文中一共展示了LightblueDataResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromClientResponse
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
/**
* Wraps a response from the lightblue client library which may or may not be successful in a
* type which allows easily querying whether or not the response was successful and getting at
* the right type of response.
*/
static LightblueResponse fromClientResponse(
com.redhat.lightblue.client.response.LightblueResponse response) {
if (response instanceof LightblueErrorResponse) {
LightblueErrorResponse errorResponse = (LightblueErrorResponse) response;
DataError[] dataErrors = Optional.ofNullable(errorResponse.getDataErrors())
.orElse(new DataError[0]);
Error[] lightblueErrors = Optional.ofNullable(errorResponse.getLightblueErrors())
.orElse(new Error[0]);
if (dataErrors.length + lightblueErrors.length > 0) {
return new FailedLightblueResponse(errorResponse, dataErrors, lightblueErrors);
}
}
if (response instanceof LightblueDataResponse) {
return new SuccessLightblueResponse((LightblueDataResponse) response);
}
throw new IllegalArgumentException("LightblueResponse was neither a data response nor an " +
"error response.");
}
示例2: configure
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
@Override
public void configure() throws Exception {
from("timer:" + deleterLockResourceId + "?period=" + deleteInterval.toMillis())
.routeId(deleterLockResourceId)
.routePolicy(new LockingRoutePolicy(deleterLockResourceId, lockStrategy))
.process(exchange -> {
Instant tooOld = clock.instant().minus(deleteOlderThan);
log.debug("Deleting {} entities with {} before {}", entityName, entityDateField, tooOld);
DataDeleteRequest deleteRequest = new DataDeleteRequest(entityName, entityVersion);
deleteRequest.where(Query.withValue(entityDateField, Query.BinOp.lt, Date.from(tooOld)));
LightblueDataResponse response = client.data(deleteRequest);
log.info("Deleted {} {} entities with {} before {}",
response.parseModifiedCount(), entityName, entityDateField, tooOld);
});
}
示例3: testBulkData
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
@Test
public void testBulkData() throws Exception {
DataBulkRequest request = new DataBulkRequest();
for (int x = 0; x < 100; x++) {
DataInsertRequest insert = new DataInsertRequest(Country.objectType, Country.objectVersion);
insert.create(new Country(String.valueOf(x), "123" + x, "456" + x, null));
insert.returns(Projection.includeField("name"));
request.add(insert);
}
DefaultLightblueBulkDataResponse bulkResp = getLightblueClient().bulkData(request);
assertNotNull(bulkResp);
//Responses should be in the same order.
int n = 0;
for (LightblueDataResponse response : bulkResp.getResponses()) {
assertNotNull(response);
assertEquals(String.valueOf(n), response.parseProcessed(Country.class).getName());
n++;
}
}
示例4: testWithIdentityManager
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
@Test
public void testWithIdentityManager() throws Exception {
lightblue.changeIdentityManager(
new FakeIdentityManager().add("fakeuser", "fakepassword"));
Country c = new Country();
c.setName("Poland");
c.setIso2Code("PL");
c.setIso3Code("POL");
DataInsertRequest insert = new DataInsertRequest(Country.objectType, Country.objectVersion);
insert.create(c);
insert.returns(Projection.includeFieldRecursively("*"));
LightblueDataResponse insertResponse = lightblue.getLightblueClient("fakeuser", "fakepassword").data(insert);
assertEquals(1, insertResponse.parseModifiedCount());
}
示例5: migrationJobsExist
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
private boolean migrationJobsExist() {
LOGGER.debug("Checking if there are migration jobs for {}", migrationConfiguration.getConfigurationName());
DataFindRequest req = new DataFindRequest("migrationJob", null);
req.where(Query.and(Query.withValue("configurationName", Query.eq, migrationConfiguration.getConfigurationName()),
Query.withValue("generated", Query.eq, false),
Query.withValue("status", Query.eq, MigrationJob.STATE_AVAILABLE)));
req.select(Projection.includeField("_id"));
req.range(1, 1);
try {
LightblueDataResponse resp = lbClient.data(req);
return resp.parseMatchCount() > 0;
} catch (Exception e) {
LOGGER.error("Cannot query migration jobs:{}", e, e);
return true;
}
}
示例6: data
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
@Override
public <T> T data(LightblueDataRequest lightblueRequest, Class<T> type)
throws LightblueParseException, LightblueResponseException, LightblueHttpClientException, LightblueException {
LightblueDataResponse response = data(lightblueRequest);
return response.parseProcessed(type);
}
示例7: testBulkFind
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
@Test
public void testBulkFind() throws LightblueException, LightblueParseException {
Country country = insertPL();
DataFindRequest request = new DataFindRequest(Country.objectType, Country.objectVersion);
request.select(Projection.includeField("*"));
request.where(Query.withValue("iso2Code", Query.eq, "PL"));
DataFindRequest request2 = new DataFindRequest(Country.objectType, Country.objectVersion);
request2.select(Projection.includeField("*"));
request2.where(Query.withValue("name", Query.eq, "Poland"));
DataFindRequest request3 = new DataFindRequest(Country.objectType, Country.objectVersion);
request3.select(Projection.includeField("*"));
request3.where(Query.withValue("name", Query.eq, "Russia"));
DataBulkRequest bulkRequest = new DataBulkRequest();
bulkRequest.add(request);
bulkRequest.add(request2);
bulkRequest.add(request3);
System.out.println(bulkRequest);
LightblueBulkDataResponse bulkResponse = client.bulkData(bulkRequest);
List<LightblueDataResponse> responses = bulkResponse.getResponses();
assertEquals(3, responses.size());
assertEquals(1, responses.get(0).parseMatchCount());
assertEquals(1, responses.get(1).parseMatchCount());
assertEquals(0, responses.get(2).parseMatchCount());
Country c1 = responses.get(0).parseProcessed(Country.class);
Country c2 = responses.get(1).parseProcessed(Country.class);
assertEquals("PL", c1.getIso2Code());
assertEquals("PL", c2.getIso2Code());
assertEquals(responses.get(0), bulkResponse.getResponse(request));
}
示例8: test
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
@Test
public void test() throws Exception {
Country c = new Country();
c.setName("Poland");
c.setIso2Code("PL");
c.setIso3Code("POL");
DataInsertRequest insert = new DataInsertRequest(Country.objectType, Country.objectVersion);
insert.create(c);
insert.returns(Projection.includeFieldRecursively("*"));
LightblueDataResponse insertResponse = lightblue.getLightblueClient().data(insert);
assertEquals(1, insertResponse.parseModifiedCount());
}
示例9: countMigrationJobs
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
private int countMigrationJobs(String configurationName, Date startDate, Date endDate) throws LightblueException {
DataFindRequest findJobs = new DataFindRequest(MigrationJob.ENTITY_NAME);
findJobs.where(
Query.and(
Query.withValue("configurationName", Query.eq, configurationName),
Query.withValue("scheduledDate", Query.gte, startDate),
Query.withValue("scheduledDate", Query.lte, endDate)
)
);
findJobs.select(new Projection[]{Projection.excludeFieldRecursively("*")}, 0, 0);
LightblueDataResponse response = lightblueClient.data(findJobs);
return response.parseMatchCount();
}
示例10: getSuccess
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
@Override
public LightblueDataResponse getSuccess() {
// TODO: maybe dif exception?
throw new LightblueResponseException(errors);
}
示例11: SuccessLightblueResponse
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
SuccessLightblueResponse(LightblueDataResponse response) {
this.response = response;
}
示例12: getSuccess
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
@Override
public LightblueDataResponse getSuccess() {
return response;
}
示例13: BulkDataResponses
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
BulkDataResponses(Map<CRUDRequest, LightblueDataResponse> responseMap) {
super(responseMap);
}
示例14: data
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
@Override
public LightblueDataResponse data(LightblueDataRequest request) throws LightblueException {
return responseOnceFlushedOrLightblueException(() -> delegate.data(request));
}
示例15: run
import com.redhat.lightblue.client.response.LightblueDataResponse; //导入依赖的package包/类
@Override
protected LightblueDataResponse run() throws Exception {
return client.data(request);
}