本文整理汇总了Java中org.ektorp.support.View类的典型用法代码示例。如果您正苦于以下问题:Java View类的具体用法?Java View怎么用?Java View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
View类属于org.ektorp.support包,在下文中一共展示了View类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataFromDoc
import org.ektorp.support.View; //导入依赖的package包/类
@Override
@View(name = "get_data", map = "function(doc) {if (doc.data) {"
+ "emit(doc._id, doc.data)}}")
public byte[] getDataFromDoc(String id) {
ViewQuery q = new ViewQuery()
.viewName("get_data")
.designDocId("_design/JsonNode")
.key(id);
ViewResult result = db.queryView(q);
try {
return mapper.writeValueAsBytes(result.getRows().get(0).getValueAsNode());
} catch (JsonProcessingException ex) {
logger.error(ex);
}
return null;
}
示例2: getAttachments
import org.ektorp.support.View; //导入依赖的package包/类
@View(name = "get_attachments", map = "function(doc) {if (doc._attachments) {"
+ "emit(doc._id, doc._attachments)}}")
public byte[] getAttachments(String id) {
ViewQuery q = new ViewQuery()
.viewName("get_attachments")
.designDocId("_design/JsonNode")
.key(id);
ViewResult result = db.queryView(q);
try {
return mapper.writeValueAsBytes(result.getRows().get(0).getValueAsNode());
} catch (JsonProcessingException ex) {
logger.error(ex);
}
return null;
}
示例3: for
import org.ektorp.support.View; //导入依赖的package包/类
@Override
@View(name = "get_attachments_revs", map = "function(doc) {if (doc._attachments) { var revs = [];"
+ " for(var key in doc._attachments) {revs.push(key);}"
+ "emit(doc._id, revs)}}")
public List<String> getAttachmentRevisions(String id) {
ViewQuery q = new ViewQuery()
.viewName("get_attachments_revs")
.designDocId("_design/JsonNode")
.key(id);
ViewResult result = db.queryView(q);
try {
return mapper.treeToValue(result.getRows().get(0).getValueAsNode(), List.class);
} catch (JsonProcessingException ex) {
logger.error(ex);
}
return null;
}
示例4: getPermissionsFromDoc
import org.ektorp.support.View; //导入依赖的package包/类
@Override
@View(name = "get_permissions", map = "function(doc) {if (doc.workflow) { "
+ "emit(doc._id, doc.workflow.permissions)}}")
public Set<String> getPermissionsFromDoc(String id) {
ViewQuery q = new ViewQuery()
.viewName("get_permissions")
.designDocId("_design/JsonNode")
.key(id);
ViewResult result = db.queryView(q);
try {
return mapper.treeToValue(result.getRows().get(0).getValueAsNode(), Set.class);
} catch (JsonProcessingException ex) {
logger.error(ex);
}
return null;
}
示例5: if
import org.ektorp.support.View; //导入依赖的package包/类
@Override
@View(name = "all", map = "function(doc) { if (!doc.doc_template) emit(doc._id, "
+ "{id:doc._id, author:doc.metadata.author, title:doc.data.Title, permissions:doc.workflow.permissions})}")
public List<DocumentListData> getAllDocuments() {
ViewQuery q = new ViewQuery()
.viewName("all")
.designDocId("_design/JsonNode");
return viewToDocListData(q);
}
示例6: emit
import org.ektorp.support.View; //导入依赖的package包/类
@Override
@View(name = "get_workflow", map = "function(doc) { emit(doc._id, doc.workflow)}")
public Workflow getWorkflowFromDoc(String id) {
ViewQuery q = new ViewQuery()
.viewName("get_workflow")
.designDocId("_design/JsonNode")
.key(id);
ViewResult result = db.queryView(q);
String json = result.getRows().get(0).getValue();
return workflowService.serialize(json);
}
示例7: if
import org.ektorp.support.View; //导入依赖的package包/类
@Override
@View(name = "by_id", map = "function(doc) { if (" + DOCUMENT_ID + ") emit(doc.value.id, doc._id) }")
public EplAdapterDocument findById(String adapterId) {
List<EplAdapterDocument> adapters = queryView("by_id", adapterId);
if (adapters.isEmpty()) throw new DocumentNotFoundException("no adapter with id " + adapterId);
if (adapters.size() == 1) return adapters.get(0);
throw new IllegalStateException("found more than one adapter for id " + adapterId);
}
示例8: if
import org.ektorp.support.View; //导入依赖的package包/类
@View(name = "by_id", map = "function(doc) { if (" + DOCUMENT_ID + ") emit(doc.value.id, doc._id) }")
public OdsRegistrationDocument findById(String eventId) {
List<OdsRegistrationDocument> events = queryView("by_id", eventId);
if (events.isEmpty()) throw new DocumentNotFoundException("no registration with id " + eventId);
if (events.size() == 1) return events.get(0);
throw new IllegalStateException("found more than one registration for id " + eventId);
}
示例9: if
import org.ektorp.support.View; //导入依赖的package包/类
@Override
@View(name = "by_id", map = "function(doc) { if (" + DOCUMENT_ID + ") emit(doc.value.id, doc._id) }")
public ClientDocument findById(String clientId) {
List<ClientDocument> clients = queryView("by_id", clientId);
if (clients.isEmpty())
throw new DocumentNotFoundException("no client with id " + clientId);
if (clients.size() == 1) return clients.get(0);
throw new IllegalStateException("found more than one client for id " + clientId);
}
示例10: if
import org.ektorp.support.View; //导入依赖的package包/类
@View(name = "by_triggerkey", map = "function(doc) { if (doc.type === 'CouchDbTrigger') emit([doc.trigger_name, doc.trigger_group], doc._id); }")
public List<CouchDbTrigger> getTriggersByKeys(List<TriggerKey> triggerKeys) throws JobPersistenceException {
List<ComplexKey> keys = new ArrayList<ComplexKey>();
for (TriggerKey triggerKey : triggerKeys) {
keys.add(ComplexKey.of(triggerKey.getName(), triggerKey.getGroup()));
}
return db.queryView(createQuery("by_triggerkey").includeDocs(true).keys(keys), type);
}
示例11: if
import org.ektorp.support.View; //导入依赖的package包/类
@View(name = "by_jobkey", map = "function(doc) { if (doc.type === 'CouchDbJobDetail') emit([doc.name, doc.group], doc._id); }")
public List<CouchDbJobDetail> getJobs(List<JobKey> jobKeys) {
List<ComplexKey> keys = new ArrayList<ComplexKey>();
for (JobKey jobKey : jobKeys) {
keys.add(ComplexKey.of(jobKey.getName(), jobKey.getGroup()));
}
return db.queryView(createQuery("by_jobkey").includeDocs(true).keys(keys), type);
}
示例12: if
import org.ektorp.support.View; //导入依赖的package包/类
@Override
@View(name = "by_id", map = "function(doc) { if (" + DOCUMENT_ID + ") emit(doc.value.id, doc._id) }")
public PluginMetaDataDocument findById(String pluginId) {
List<PluginMetaDataDocument> plugins = queryView("by_id", pluginId);
if (plugins.isEmpty()) throw new DocumentNotFoundException(pluginId);
if (plugins.size() > 1) throw new IllegalStateException("found more than one plugin for id " + pluginId);
return plugins.get(0);
}
示例13: if
import org.ektorp.support.View; //导入依赖的package包/类
@Override
@View(name = "by_id", map = "function(doc) { if (" + DOCUMENT_ID + ") emit(doc.value.id, doc._id)}")
public DataSourceDocument findById(String sourceId) {
List<DataSourceDocument> sources = queryView("by_id", sourceId);
if (sources.isEmpty()) throw new DocumentNotFoundException(sourceId);
if (sources.size() > 1)
throw new IllegalStateException("found more than one source for id " + sourceId);
return sources.get(0);
}
示例14: if
import org.ektorp.support.View; //导入依赖的package包/类
@Override
@View(name = "by_id", map = "function(doc) { if (" + DOCUMENT_ID + ") emit(doc.value.id, doc._id) }")
public ProcessorReferenceChainDocument findById(String processorChainId) {
List<ProcessorReferenceChainDocument> chains = queryView("by_id", processorChainId);
if (chains.isEmpty()) throw new DocumentNotFoundException(processorChainId);
if (chains.size() > 1)
throw new IllegalStateException("found more than one chain for id " + processorChainId);
return chains.get(0);
}
示例15: if
import org.ektorp.support.View; //导入依赖的package包/类
@View(name = "by_id", map = "function(doc) { if (" + DOCUMENT_ID + ") emit(doc.value.id, doc._id)}")
public ClientDocument findById(String clientId) {
List<ClientDocument> clients = queryView("by_id", clientId);
if (clients.isEmpty()) throw new DocumentNotFoundException(clientId);
if (clients.size() > 1) throw new IllegalStateException("found more than one client for id " + clientId);
return clients.get(0);
}