本文整理汇总了Java中com.redhat.lightblue.util.Path类的典型用法代码示例。如果您正苦于以下问题:Java Path类的具体用法?Java Path怎么用?Java Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Path类属于com.redhat.lightblue.util包,在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTranslate_UnsupportedField
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Test(expected = UnsupportedOperationException.class)
public void testTranslate_UnsupportedField() throws JSONException{
SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{new Attribute("fake")});
@SuppressWarnings("serial")
EntityMetadata md = fakeEntityMetadata("fakeMetadata", new Field("fake"){
@Override
public boolean hasChildren() {
throw new UnsupportedOperationException("Method should never be called.");
}
@Override
public Iterator<? extends FieldTreeNode> getChildren() {
throw new UnsupportedOperationException("Method should never be called.");
}
@Override
public FieldTreeNode resolve(Path p, int level) {
throw new UnsupportedOperationException("Method should never be called.");
}
});
new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);
}
示例2: addArrayIdentities
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
private Projection addArrayIdentities(Projection p,EntityMetadata md) {
// If an array is included in the projection, make sure its identity is also included
Map<Path,List<Path>> arrayIdentities=md.getEntitySchema().getArrayIdentities();
List<Projection> addFields=new ArrayList<>();
for(Map.Entry<Path,List<Path>> entry:arrayIdentities.entrySet()) {
Path array=entry.getKey();
List<Path> identities=new ArrayList<>();
for(Path x:entry.getValue())
identities.add(new Path(array,new Path(Path.ANYPATH,x)));
if(isProjected(array,p)) {
for(Path id:identities) {
if(!isProjected(id,p)) {
addFields.add(new FieldProjection(id,true,true));
}
}
}
}
if(!addFields.isEmpty()) {
LOGGER.debug("Excluded array identities are added to projection:{}",addFields);
// Need to first add the original projection, then the included fields.
// This is order sensitive
return Projection.add(p,new ProjectionList(addFields));
} else
return p;
}
示例3: flatten
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
private void flatten(String prefix, JsonNode node, List<PathAndValue> entityData) {
if (node.size() == 0) {
return;
}
JsonNodeCursor cursor = new JsonNodeCursor(Path.EMPTY, node);
while(cursor.next()) {
String p=cursor.getCurrentPath().toString();
JsonNode value=cursor.getCurrentNode();
if(value.isValueNode()) {
String path = prefix.isEmpty() ? p : (prefix + "." + p);
PathAndValue data = new PathAndValue(path, value.asText(null));
// TODO(ahenning): Consider using Set instead of List for entityData
if (!entityData.contains(data)) {
entityData.add(data);
}
}
}
}
示例4: shouldNotCreateNotificationsIfSomethingNotWatchedChanged
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Test
public void shouldNotCreateNotificationsIfSomethingNotWatchedChanged() throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode pre = loadJsonNode("userdata.json");
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'personalInfo','recursive':1}"),
null,
false);
JsonNode post = loadJsonNode("userdata.json");
JsonDoc.modify(post, new Path("login"), JsonNodeFactory.instance.textNode("blah"), true);
List<HookDoc> docs= new ArrayList<>();
HookDoc doc = new HookDoc(md, new JsonDoc(pre), new JsonDoc(post), CRUDOperation.UPDATE, "me");
docs.add(doc);
hook.processHook(md,cfg,docs);
Assert.assertNull(insertCapturingMediator.capturedInsert);
}
示例5: shouldCaptureWatchedNonContainerNodeChangesInEntityData
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Test
public void shouldCaptureWatchedNonContainerNodeChangesInEntityData() throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode pre = loadJsonNode("userdata.json");
JsonNode post = loadJsonNode("userdata.json");
JsonDoc.modify(post, new Path("sites.0.streetAddress.city"), JsonNodeFactory.instance.textNode("blah"), true);
List<HookDoc> docs= new ArrayList<>();
HookDoc doc = new HookDoc(md, new JsonDoc(pre), new JsonDoc(post), CRUDOperation.UPDATE, "me");
docs.add(doc);
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'sites','recursive':1}"),
projection("{'field':'sites','recursive':1}"),
false);
hook.processHook(md, cfg, docs);
Assert.assertNotNull(insertCapturingMediator.capturedInsert);
JsonNode data=insertCapturingMediator.capturedInsert.getEntityData();
Assert.assertEquals("sites.0.streetAddress.city",data.get("updatedPaths").get(0).asText());
Assert.assertEquals(1,data.get("updatedPaths").size());
}
示例6: shouldOnlyIncludeWhatChangedOfArrayElementIfElementIdentityNotWatched
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Test
public void shouldOnlyIncludeWhatChangedOfArrayElementIfElementIdentityNotWatched()
throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode pre = loadJsonNode("userdata.json");
JsonNode post = loadJsonNode("userdata.json");
JsonDoc.modify(post, new Path("sites.0.streetAddress.city"), JsonNodeFactory.instance.textNode("blah"), true);
List<HookDoc> docs= new ArrayList<>();
HookDoc doc = new HookDoc(md, new JsonDoc(pre), new JsonDoc(post), CRUDOperation.UPDATE, "me");
docs.add(doc);
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'sites.*.streetAddress.city','recursive':1}"),
null,
false);
hook.processHook(md, cfg, docs);
Assert.assertNotNull(insertCapturingMediator.capturedInsert);
JsonNode data=insertCapturingMediator.capturedInsert.getEntityData();
Truth.assertThat(
Iterables.transform(data.get("updatedPaths"), toTextValue()))
.containsExactly("sites.0.streetAddress.city");
}
示例7: shouldCaptureWatchedArrayElementRemovalInRemovedEntityDataAndRemovedElements
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Test
public void shouldCaptureWatchedArrayElementRemovalInRemovedEntityDataAndRemovedElements() throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode pre = loadJsonNode("userdata.json");
JsonNode post = loadJsonNode("userdata.json");
JsonDoc.modify(post,new Path("sites.1"),null,true);
List<HookDoc> docs= new ArrayList<>();
HookDoc doc = new HookDoc(md, new JsonDoc(pre), new JsonDoc(post), CRUDOperation.UPDATE, "me");
docs.add(doc);
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'sites','recursive':1}"),
projection("{'field':'sites','recursive':1}"),
false);
hook.processHook(md, cfg, docs);
JsonNode data=insertCapturingMediator.capturedInsert.getEntityData();
Assert.assertEquals(1,data.get("removedPaths").size());
Assert.assertEquals("sites.1",data.get("removedPaths").get(0).asText());
// Check we also have sites.1 contents
assertEntityDataValueEquals( (ArrayNode)data.get("removedEntityData"),"sites.1.siteId","2");
assertEntityDataValueEquals( (ArrayNode)data.get("removedEntityData"),"sites.1.siteType","billing");
}
示例8: shouldIncludeRemovedEntityDataForModifications
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Test
public void shouldIncludeRemovedEntityDataForModifications() throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode pre = loadJsonNode("userdata.json");
JsonNode post = loadJsonNode("userdata.json");
JsonDoc.modify(post, new Path("sites.0.streetAddress.city"),
JsonNodeFactory.instance.textNode("new city"), true);
List<HookDoc> docs= new ArrayList<>();
HookDoc doc = new HookDoc(md, new JsonDoc(pre), new JsonDoc(post), CRUDOperation.UPDATE, "me");
docs.add(doc);
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'sites','recursive':1}"),
projection("{'field':'sites','recursive':1}"),
false);
hook.processHook(md, cfg, docs);
JsonNode data=insertCapturingMediator.capturedInsert.getEntityData();
Assert.assertEquals(0,data.get("removedPaths").size());
// Check we also have sites.1 contents
assertEntityDataValueEquals((ArrayNode) data.get("removedEntityData"),
"sites.0.streetAddress.city", "Denver");
}
示例9: shouldCaptureNullsAsNull
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Test
public void shouldCaptureNullsAsNull() throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode post = loadJsonNode("userdata.json");
JsonDoc.modify(post, new Path("personalInfo.company"),
JsonNodeFactory.instance.nullNode(), true);
List<HookDoc> docs= new ArrayList<>();
HookDoc doc = new HookDoc(md, null, new JsonDoc(post), CRUDOperation.INSERT, "me");
docs.add(doc);
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'personalInfo','recursive':1}"),
projection("{'field':'personalInfo','recursive':1}"),
false);
hook.processHook(md, cfg, docs);
JsonNode data=insertCapturingMediator.capturedInsert.getEntityData();
// Check we also have sites.1 contents
assertEntityDataValueEquals((ArrayNode) data.get("entityData"), "personalInfo.company", null);
}
示例10: itrNaryValueRelationalExpression
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Override
protected Filter itrNaryValueRelationalExpression(NaryValueRelationalExpression query, Path path){
String attributeName = fieldNameTranslator.translateFieldName(query.getField());
List<Filter> filters = new ArrayList<>();
for(Value value : query.getValues()){
filters.add(Filter.createEqualityFilter(attributeName, value.getValue().toString()));
}
switch (query.getOp()){
case _in:
return Filter.createORFilter(filters);
case _not_in:
return Filter.createNOTFilter(Filter.createORFilter(filters));
default:
throw new UnsupportedOperationException("Unsupported operation: " + query.getOp());
}
}
示例11: convertArrayFieldToBson
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
private void convertArrayFieldToBson(JsonNode node, JsonNodeCursor cursor, BasicDBObject ret, FieldTreeNode fieldMdNode, Path path, EntityMetadata md,ResultMetadata rmd) {
if (node != null) {
if (node instanceof ArrayNode) {
if (cursor.firstChild()) {
ret.append(path.tail(0), arrayToBson(cursor, ((ArrayField) fieldMdNode).getElement(), md,rmd));
cursor.parent();
} else {
// empty array! add an empty list.
ret.append(path.tail(0), new ArrayList());
}
} else if (node instanceof NullNode) {
ret.append(path.tail(0), null);
} else {
throw Error.get(ERR_INVALID_FIELD, path.toString());
}
}
}
示例12: testSortKey_Desc
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Test
public void testSortKey_Desc(){
String fieldName = "fakeField";
Sort sort = new SortKey(new Path(fieldName), true);
com.unboundid.ldap.sdk.controls.SortKey[] translatedSorts = new SortTranslator(new TrivialLdapFieldNameTranslator()).translate(sort);
assertNotNull(translatedSorts);
assertEquals(1, translatedSorts.length);
com.unboundid.ldap.sdk.controls.SortKey translatedSort = translatedSorts[0];
assertNotNull(translatedSort);
assertEquals(fieldName, translatedSort.getAttributeName());
assertTrue(translatedSort.reverseOrder());
}
示例13: processNestedArrays
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
private Block processNestedArrays(Context ctx,Path field,Block parent,Name arrayFieldName) {
MutablePath pathSegment=new MutablePath();
for(int i=0;i<field.numSegments();i++) {
String seg=field.head(i);
if(Path.ANY.equals(seg)) {
Name name=ctx.varName(arrayFieldName);
ArrForLoop loop=new ArrForLoop(ctx.newName("ri"),name);
parent.add(IfStatement.ifDefined(name,loop));
parent=loop;
pathSegment.push(Path.ANY);
arrayFieldName.add(loop.loopVar,true);
} else {
arrayFieldName.add(seg,field.isIndex(i));
pathSegment.push(seg);
}
}
return parent;
}
示例14: translateArrayElemMatch
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
/**
* <pre>
* var r0=false;
* for(var i=0;i<this.arr.length;i++) {
* elemMatchQuery
* if(resultOfElemMatch) {
* r0=true;break;
* }
* }
* return r0;
* </pre>
*/
private Block translateArrayElemMatch(Context ctx,ArrayMatchExpression query) {
// An elemMatch expression is a for-loop
Block block=new Block(ctx.topLevel.newGlobalBoolean(ctx));
// for (elem:array)
Name arrName=ctx.varName(new Name(query.getArray()));
ArrForLoop loop=new ArrForLoop(ctx.newName("i"),arrName);
Context newCtx=ctx.enter(ctx.contextNode.resolve(new Path(query.getArray(),Path.ANYPATH)),loop);
Block queryBlock=translateQuery(newCtx,query.getElemMatch());
loop.replace(queryBlock);
loop.add(new IfStatement(new SimpleExpression(queryBlock.resultVar),
new SimpleStatement("%s=true",block.resultVar),
SimpleStatement.S_BREAK));
block.add(IfStatement.ifDefined(arrName,loop));
return block;
}
示例15: varName
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
public Name varName(Name localName) {
FieldTreeNode current=contextNode;
Name p=new Name();
if(contextBlock!=null)
p.add(contextBlock.getDocumentLoopVarAsPrefix());
int n=localName.length();
for(int i=0;i<n;i++) {
Name.Part seg=localName.getPart(i);
if(Path.PARENT.equals(seg.name)) {
p.removeLast();
current=current.getParent();
if(current==null)
throw Error.get(JSQueryTranslator.ERR_INVALID_FIELD,localName.toString());
} else if(Path.THIS.equals(seg.name)) {
; // Stay here
} else {
p.add(seg);
// This will throw an exception if it cannot resolve seg
if(seg.index)
current=current.resolve(Path.ANYPATH);
else
current=current.resolve(new Path(seg.name));
}
}
return p;
}