本文整理汇总了Java中com.couchbase.client.java.subdoc.DocumentFragment类的典型用法代码示例。如果您正苦于以下问题:Java DocumentFragment类的具体用法?Java DocumentFragment怎么用?Java DocumentFragment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DocumentFragment类属于com.couchbase.client.java.subdoc包,在下文中一共展示了DocumentFragment类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeContact
import com.couchbase.client.java.subdoc.DocumentFragment; //导入依赖的package包/类
@ResponseBody
@RequestMapping(method = RequestMethod.PUT, path = "/developer/removeContact/{developerId}")
public String removeContact(final @PathVariable String developerId, final @RequestBody String json) throws Exception {
JsonObject jsonData = JsonObject.fromJson(json);
String contactId = jsonData.getString("contactId");
DocumentFragment<Lookup> fragment = bucket.lookupIn(developerId).get("contacts").execute();
JsonArray contactList = fragment.content("contacts", JsonArray.class);
List tempList = contactList.toList();
tempList.remove(contactId);
contactList = JsonArray.from(tempList);
bucket.mutateIn(developerId)
.replace("contacts", contactList).execute();
fragment = bucket.lookupIn(contactId).get("contacts").execute();
contactList = fragment.content("contacts", JsonArray.class);
tempList = contactList.toList();
tempList.remove(developerId);
contactList = JsonArray.from(tempList);
bucket.mutateIn(contactId)
.replace("contacts", contactList).execute();
return "{}";
}
示例2: findDomainEvents
import com.couchbase.client.java.subdoc.DocumentFragment; //导入依赖的package包/类
@Override
public List<? extends DomainEventData<?>> findDomainEvents(Bucket bucket, String aggregateIdentifier, long firstSequenceNumber, int batchSize) {
String docId = EVENT_PREFIX + aggregateIdentifier;
JsonDocument doc = bucket.get(docId);
List<EventEntry> eventEntries = new ArrayList<>();
if (doc != null) {
DocumentFragment<Lookup> fragment = bucket.lookupIn(docId)
.get("events")
.execute();
JsonArray events = fragment.content("events", JsonArray.class);
events.forEach((event) -> {
eventEntries.add(new EventEntry((JsonObject) event));
});
}
return eventEntries;
}
示例3: main
import com.couchbase.client.java.subdoc.DocumentFragment; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder().build();
clusterCouchbase = CouchbaseCluster.create(env, "192.168.4.246", "192.168.4.247", "192.168.4.248");
proteusBucket = clusterCouchbase.openBucket("proteus-testing");
String coil = "40101001";
DocumentFragment<Lookup> resultHSM = proteusBucket.lookupIn(coil).get("proteus-hsm").execute();
DocumentFragment<Lookup> resultFlatness = proteusBucket.lookupIn(coil).get("proteus-flatness").execute();
DocumentFragment<Lookup> resultRealtime = proteusBucket.lookupIn(coil).get("proteus-realtime").execute();
System.out.println("Resultado para la bobina < " + "40101022" + " > | < HSM > " + resultHSM.size()
+ " | < Flantess > " + resultFlatness.size() + " | < Realtime > " + resultRealtime.size());
// System.out.println(resultRealtime.toString());
// Thread.sleep(3000);
// System.out.println(resultFlatness.toString());
// Thread.sleep(3000);
System.out.println(resultHSM.toString());
Thread.sleep(3000);
ArrayList<String> coils = new ArrayList<String>();
coils.add("40101022");
coils.add("40101018");
for (String bobina : coils) {
CouchbaseUtils.checkDataInserted(bobina, proteusBucket);
}
}
示例4: checkDataInserted
import com.couchbase.client.java.subdoc.DocumentFragment; //导入依赖的package包/类
public static void checkDataInserted(String coilID, Bucket proteusBucket) {
DocumentFragment<Lookup> resultHSM = proteusBucket.lookupIn(coilID).get("proteus-hsm").execute();
DocumentFragment<Lookup> resultFlatness = proteusBucket.lookupIn(coilID).get("proteus-realtime").execute();
DocumentFragment<Lookup> resultRealtime = proteusBucket.lookupIn(coilID).get("proteus-flatness").execute();
System.out.println("Resultado para la bobina < " + coilID + " > | < HSM > " + resultHSM.size()
+ " | < Flantess > " + resultFlatness.size() + " | < Realtime > " + resultRealtime.size());
}