本文整理汇总了Java中com.redhat.lightblue.util.Path类的典型用法代码示例。如果您正苦于以下问题:Java Path类的具体用法?Java Path怎么用?Java Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Path类属于com.redhat.lightblue.util包,在下文中一共展示了Path类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:27,代码来源:ResultTranslatorToJsonTest.java
示例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;
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:27,代码来源:NotificationHook.java
示例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);
}
}
}
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:23,代码来源:NotificationHook.java
示例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);
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:22,代码来源:NotificationHookTest.java
示例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());
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:23,代码来源:NotificationHookTest.java
示例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");
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:26,代码来源:NotificationHookTest.java
示例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");
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:26,代码来源:NotificationHookTest.java
示例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");
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:26,代码来源:NotificationHookTest.java
示例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);
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:23,代码来源:NotificationHookTest.java
示例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());
}
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:18,代码来源:FilterBuilder.java
示例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());
}
}
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:18,代码来源:DocTranslator.java
示例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());
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:17,代码来源:SortTranslatorTest.java
示例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;
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:19,代码来源:JSQueryTranslator.java
示例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;
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:29,代码来源:JSQueryTranslator.java
示例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;
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:27,代码来源:Context.java
示例16: itrValueComparisonExpression
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Override
protected Filter itrValueComparisonExpression(ValueComparisonExpression query, Path path){
String attributeName = fieldNameTranslator.translateFieldName(query.getField());
String rValue = query.getRvalue().getValue().toString();
switch(query.getOp()){
case _eq:
return Filter.createEqualityFilter(attributeName, rValue);
case _neq:
return Filter.createNOTFilter(Filter.createEqualityFilter(attributeName, rValue));
case _gte:
return Filter.createGreaterOrEqualFilter(attributeName, rValue);
case _lte:
return Filter.createLessOrEqualFilter(attributeName, rValue);
case _gt: //aka. !lte
return Filter.createNOTFilter(Filter.createLessOrEqualFilter(attributeName, rValue));
case _lt: //aka. !gte
return Filter.createNOTFilter(Filter.createGreaterOrEqualFilter(attributeName, rValue));
default:
throw new UnsupportedOperationException("Unsupported operation: " + query.getOp());
}
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:23,代码来源:FilterBuilder.java
示例17: testSortKey_Asc
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Test
public void testSortKey_Asc(){
String fieldName = "fakeField";
Sort sort = new SortKey(new Path(fieldName), false);
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());
assertFalse(translatedSort.reverseOrder());
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:17,代码来源:SortTranslatorTest.java
示例18: parse
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Override
public <T> If parse(MetadataParser<T> p, T ifT) {
If x = null;
T pathvalue = p.getObjectProperty(ifT, "fieldCheckValue");
if (pathvalue != null) {
x = new IfFieldCheckValue();
String fieldString = p.getStringProperty(pathvalue, "field");
String valueString = p.getStringProperty(pathvalue, "value");
String opString = p.getStringProperty(pathvalue, "op");
if (fieldString == null || fieldString.isEmpty()) {
throw com.redhat.lightblue.util.Error.get(RDBMSConstants.ERR_FIELD_REQUIRED, "fieldCheckValue: field not informed");
}
if (valueString == null || valueString.isEmpty()) {
throw com.redhat.lightblue.util.Error.get(RDBMSConstants.ERR_FIELD_REQUIRED, "fieldCheckValue: value not informed");
}
if (opString == null || opString.isEmpty()) {
throw com.redhat.lightblue.util.Error.get(RDBMSConstants.ERR_FIELD_REQUIRED, "fieldCheckValue: op not informed");
}
((IfFieldCheckValue) x).setField(new Path(fieldString));
((IfFieldCheckValue) x).setValue(valueString);
((IfFieldCheckValue) x).setOp(opString);
}
return x;
}
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:25,代码来源:IfFieldCheckValue.java
示例19: testCompositeSortKey
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Test
public void testCompositeSortKey(){
String fieldName1 = "fakeField1";
String fieldName2 = "fakeField2";
Sort sort = new CompositeSortKey(
Arrays.asList(
new SortKey(new Path(fieldName1), true),
new SortKey(new Path(fieldName2), false))
);
com.unboundid.ldap.sdk.controls.SortKey[] translatedSorts = new SortTranslator(new TrivialLdapFieldNameTranslator()).translate(sort);
assertNotNull(translatedSorts);
assertEquals(2, translatedSorts.length);
com.unboundid.ldap.sdk.controls.SortKey translatedSort1 = translatedSorts[0];
assertNotNull(translatedSort1);
assertEquals(fieldName1, translatedSort1.getAttributeName());
assertTrue(translatedSort1.reverseOrder());
com.unboundid.ldap.sdk.controls.SortKey translatedSort2 = translatedSorts[1];
assertNotNull(translatedSort2);
assertEquals(fieldName2, translatedSort2.getAttributeName());
assertFalse(translatedSort2.reverseOrder());
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:27,代码来源:SortTranslatorTest.java
示例20: projectionFields
import com.redhat.lightblue.util.Path; //导入依赖的package包/类
@Test
public void projectionFields() throws Exception {
Set<Path> fields = ExpressionTranslator.getRequiredFields(md, projection("{'field':'*','recursive':1}"), null, null);
System.out.println(fields);
Assert.assertTrue(fields.contains(new Path("objectType")));
Assert.assertTrue(fields.contains(new Path("_id")));
Assert.assertTrue(fields.contains(new Path("field1")));
Assert.assertTrue(fields.contains(new Path("field2")));
Assert.assertTrue(fields.contains(new Path("field3")));
Assert.assertTrue(fields.contains(new Path("field4")));
Assert.assertTrue(fields.contains(new Path("field5")));
Assert.assertTrue(fields.contains(new Path("field6.nf1")));
Assert.assertTrue(fields.contains(new Path("field6.nf2")));
Assert.assertTrue(fields.contains(new Path("field6.nf3")));
Assert.assertTrue(fields.contains(new Path("field6.nf4")));
Assert.assertTrue(fields.contains(new Path("field6.nf5")));
Assert.assertTrue(fields.contains(new Path("field6.nf6")));
Assert.assertTrue(fields.contains(new Path("field6.nf7.nnf1")));
Assert.assertTrue(fields.contains(new Path("field6.nf7.nnf2")));
Assert.assertTrue(fields.contains(new Path("field7.*.elemf1")));
Assert.assertTrue(fields.contains(new Path("field7.*.elemf2")));
Assert.assertTrue(fields.contains(new Path("field7.*.elemf3")));
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:24,代码来源:TranslatorTest.java
注:本文中的com.redhat.lightblue.util.Path类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论