本文整理汇总了Java中iot.jcypher.graph.GrProperty类的典型用法代码示例。如果您正苦于以下问题:Java GrProperty类的具体用法?Java GrProperty怎么用?Java GrProperty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GrProperty类属于iot.jcypher.graph包,在下文中一共展示了GrProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCreateNodeClause
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
private void addCreateNodeClause(GrNode node,
List<IClause> clauses, Map<GrNode, JcNode> localNodeMap,
List<GrNode2JcNode> nodesToCreate) {
String nm = "ln_".concat(String.valueOf(clauses.size()));
JcNode n = new JcNode(nm);
nodesToCreate.add(new GrNode2JcNode(node, n));
Node create = CREATE.node(n);
for (GrLabel label : node.getLabels()) {
create = create.label(label.getName());
}
for (GrProperty prop : node.getProperties()) {
create = create.property(prop.getName()).value(prop.getValue());
}
if (writeVersion || lockingStrategy == Locking.OPTIMISTIC)
create = create.property(ResultHandler.lockVersionProperty).value(0);
clauses.add(create);
localNodeMap.put(node, n);
}
示例2: addCreateRelationClause
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
private void addCreateRelationClause(GrRelation relation,
List<IClause> createRelationClauses,
Map<GrNode, JcNode> localNodeMap, Map<GrNode, JcNode> dbNodeMap,
List<IClause> startNodeClauses, List<GrRelation2JcRelation> relationsToCreate) {
String nm = "lr_".concat(String.valueOf(createRelationClauses.size()));
JcRelation r = new JcRelation(nm);
relationsToCreate.add(new GrRelation2JcRelation(relation, r));
GrNode sNode = relation.getStartNode();
GrNode eNode = relation.getEndNode();
JcNode sn = getNode(sNode, localNodeMap, dbNodeMap, startNodeClauses);
JcNode en = getNode(eNode, localNodeMap, dbNodeMap, startNodeClauses);
Relation create = CREATE.node(sn).relation(r).out();
if (relation.getType() != null)
create = create.type(relation.getType());
for (GrProperty prop : relation.getProperties()) {
create = create.property(prop.getName()).value(prop.getValue());
}
if (writeVersion || lockingStrategy == Locking.OPTIMISTIC)
create = create.property(ResultHandler.lockVersionProperty).value(0);
createRelationClauses.add(create.node(en));
}
示例3: handleVersionProperty
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
private void handleVersionProperty(GrPropertyContainer element, int curVersion) {
if (writeVersion || lockingStrategy == Locking.OPTIMISTIC) {
if (elementVersions == null)
elementVersions = new ElementVersions();
int oldVersion = curVersion;
GrProperty prop = element.getProperty(ResultHandler.lockVersionProperty);
if (prop != null)
prop.setValue(oldVersion + 1);
else
prop = element.addProperty(ResultHandler.lockVersionProperty, oldVersion + 1);
if (element instanceof GrNode)
elementVersions.nodeVersions.put(element, oldVersion);
else if (element instanceof GrRelation)
elementVersions.relationVersions.put(element, oldVersion);
}
}
示例4: mapPropertyFromField
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
@Override
public void mapPropertyFromField(Object domainObject, GrNode rNode) {
Object mapped = super.intMapPropertyFromField(domainObject, rNode);
String propName = getPropertyOrRelationName().concat(TypePostfix);
GrProperty prop = rNode.getProperty(propName);
if (mapped != null) {
String value = mapped.getClass().getName();
if (prop != null) {
Object propValue = prop.getValue(); // String need not be converted
if (!value.equals(propValue)) {
prop.setValue(value);
}
} else
rNode.addProperty(propName, value);
} else { // remove if needed
if (prop != null)
prop.setValue(null);
}
}
示例5: storeSimpleListComponentType
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
protected void storeSimpleListComponentType(Object value, GrNode rNode) {
// only called when a collection or an array is mapped to a property
Collection coll;
if (value instanceof Collection<?>)
coll = (Collection) this.getFieldType().cast(value);
else
coll = Arrays.asList((Object[])value);
if (coll.size() > 0) {
Object elem = coll.iterator().next();
Class<?> type = elem.getClass();
// test the first element,
// assuming all elements are of the same type !!!
String propName = getPropertyOrRelationName().concat(TypePostfix);
GrProperty prop = rNode.getProperty(propName);
String t_value = type.getName();
if (prop != null) {
Object propValue = prop.getValue(); // String need not be converted
if (!t_value.equals(propValue)) {
prop.setValue(t_value);
}
} else
rNode.addProperty(propName, t_value);
}
}
示例6: testBooking
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
@Test
public void testBooking() {
JCypherClient jCypherClient = new JCypherClient(dbAccess);
jCypherClient.insertBooking(new Booking(1l, "FRAUD", "CONTRACT", "[email protected]"));
jCypherClient.insertBooking(new Booking(2l, "LEGIT", "INIT", "[email protected]"));
jCypherClient = new JCypherClient(dbAccess);
List<GrRelation> bookingsRelated = jCypherClient.getBookingsRelated(1L, 6);
bookingsRelated = removeMultiples(bookingsRelated); // needed when duplicates are included
assertEquals(1, bookingsRelated.size());
GrRelation br = bookingsRelated.get(0);
GrNode sn = br.getStartNode();
GrProperty fr = sn.getProperty("fraud");
GrProperty stat = sn.getProperty("status");
Object frVal = fr.getValue();
Object statVal = stat.getValue();
assertEquals("FRAUD", frVal);
assertEquals("CONTRACT", statVal);
return;
}
示例7: checkDomainInfoNodeAgainst
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
private boolean checkDomainInfoNodeAgainst(String expected) {
JcNode info = new JcNode("info");
JcQuery query = new JcQuery();
query.setClauses(new IClause[] {
MATCH.node(info).label("DomainInfo"),
WHERE.valueOf(info.property("name"))
.EQUALS(domainName),
RETURN.value(info)
});
JcQueryResult result = dbAccess.execute(query);
List<JcError> errors = Util.collectErrors(result);
if (!errors.isEmpty()) {
throw new JcResultException(errors);
}
GrNode rInfo = result.resultOf(info).get(0);
GrProperty prop = rInfo.getProperty("label2ClassMap");
Object val = prop.getValue();
String returned = val.toString();
return expected.equals(returned);
}
示例8: save
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
@Test
public void save() throws Exception {
new MockUnit(IDBAccess.class, Session.class)
.expect(sid("sidfoo", ImmutableMap.of("foo", "bar"), 1L, 2L, 3L))
.expect(newNode("n"))
.expect(millis())
.expect(SAVE("sidfoo", "session", 1L, 2L, 3L, TimeUnit.MINUTES.toMillis(30)))
.expect(newQuery())
.expect(execute())
.expect(resultOf())
.expect(unit -> {
GrProperty foo = unit.mock(GrProperty.class);
expect(foo.getName()).andReturn("foo");
GrNode node = unit.get(GrNode.class);
expect(node.getProperties()).andReturn(ImmutableList.of(foo));
})
.run(unit -> {
new Neo4jSessionStore(unit.get(IDBAccess.class), "session", "30m")
.save(unit.get(Session.class));
});
}
示例9: saveDeleteUnsetProps
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
@Test
public void saveDeleteUnsetProps() throws Exception {
new MockUnit(IDBAccess.class, Session.class)
.expect(sid("sidfoo", ImmutableMap.of("foo", "bar"), 1L, 2L, 3L))
.expect(newNode("n"))
.expect(millis())
.expect(SAVE("sidfoo", "session", 1L, 2L, 3L, TimeUnit.MINUTES.toMillis(30)))
.expect(newQuery())
.expect(execute())
.expect(resultOf())
.expect(unit -> {
GrProperty bar = unit.mock(GrProperty.class);
expect(bar.getName()).andReturn("bar");
GrNode node = unit.get(GrNode.class);
expect(node.getProperties()).andReturn(ImmutableList.of(bar));
})
.expect(newQuery())
.expect(REMOVE("sidfoo", "session", "bar"))
.expect(execute())
.run(unit -> {
new Neo4jSessionStore(unit.get(IDBAccess.class), "session", "30m")
.save(unit.get(Session.class));
});
}
示例10: print
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
private static void print(List<GrNode> nodes, boolean distinct) {
List<Long> ids = new ArrayList<Long>();
StringBuilder sb = new StringBuilder();
boolean firstNode = true;
for (GrNode node : nodes) {
if (!ids.contains(node.getId()) || !distinct) {
ids.add(node.getId());
if (!firstNode)
sb.append("\n");
else
firstNode = false;
sb.append("---NODE---:\n");
sb.append('[');
sb.append(node.getId());
sb.append(']');
for (GrLabel label : node.getLabels()) {
sb.append(", ");
sb.append(label.getName());
}
sb.append("\n");
boolean first = true;
for (GrProperty prop : node.getProperties()) {
if (!first)
sb.append(", ");
else
first = false;
sb.append(prop.getName());
sb.append(" = ");
sb.append(prop.getValue());
}
}
}
System.out.println(sb.toString());
}
示例11: getNodeProperties
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
private List<GrProperty> getNodeProperties(long nodeId, int rowIndex) {
List<GrProperty> props = new ArrayList<GrProperty>();
Iterator<PropEntry> esIt = this.contentHandler.getPropertiesIterator(nodeId, rowIndex, ElemType.NODE);
while (esIt.hasNext()) {
PropEntry entry = esIt.next();
GrProperty prop = GrAccess.createProperty(entry.getPropName());
prop.setValue(this.contentHandler.convertContentValue(entry.getPropValue()));
GrAccess.setState(prop, SyncState.SYNC);
props.add(prop);
}
return props;
}
示例12: getRelationProperties
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
private List<GrProperty> getRelationProperties(long relationId, int rowIndex) {
List<GrProperty> props = new ArrayList<GrProperty>();
Iterator<PropEntry> esIt = this.contentHandler.getPropertiesIterator(relationId, rowIndex, ElemType.RELATION);
while (esIt.hasNext()) {
PropEntry entry = esIt.next();
GrProperty prop = GrAccess.createProperty(entry.getPropName());
prop.setValue(this.contentHandler.convertContentValue(entry.getPropValue()));
GrAccess.setState(prop, SyncState.SYNC);
props.add(prop);
}
return props;
}
示例13: addPropertyChild
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
/**
* @param fm
* @param obj
* @param node
* @return true if the property exists in the node
*/
public boolean addPropertyChild(FieldMapping fm, Object obj, GrNode node) {
if (!fm.isInnerClassRefField()) {
if (this.realObject == null) {
if (this.propertyChildren == null)
this.propertyChildren = new ArrayList<DeferredPropertyMapping>();
this.propertyChildren.add(new DeferredPropertyMapping(fm, obj, node));
GrProperty prop = node.getProperty(fm.getPropertyOrRelationName());
return prop != null;
} else {
return fm.mapPropertyToField(this.realObject, node);
}
}
return false;
}
示例14: clearAdditionalProperties
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
@Override
protected void clearAdditionalProperties(GrNode rNode) {
String propName = getPropertyOrRelationName().concat(TypePostfix);
GrProperty prop = rNode.getProperty(propName);
if (prop != null)
prop.setValue(null);
}
示例15: mapPropertyToField
import iot.jcypher.graph.GrProperty; //导入依赖的package包/类
/**
* @param domainObject
* @param rNode
* @return true if the property exists in the node
*/
public boolean mapPropertyToField(Object domainObject, GrNode rNode) {
boolean hasProperty = false;
if (domainObject instanceof InnerClassSurrogate) {
hasProperty = ((InnerClassSurrogate)domainObject).addPropertyChild(this, domainObject, rNode);
} else {
try {
prepare(domainObject);
Object value = this.field.get(domainObject);
GrProperty prop = rNode.getProperty(this.propertyName);
if (prop != null) {
hasProperty = true;
Object propValue = prop.getValue();
if (propValue != null) { // allow null values in properties
Class<?> typ = getFieldTypeInt(rNode);
propValue = MappingUtil.convertFromProperty(propValue, typ,
getComponentType(rNode), getConcreteFieldType());
if (!propValue.equals(value)) {
this.field.set(domainObject, convertFieldValue(propValue, domainObject));
}
}
}
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
return hasProperty;
}