当前位置: 首页>>代码示例>>Java>>正文


Java GrProperty.setValue方法代码示例

本文整理汇总了Java中iot.jcypher.graph.GrProperty.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java GrProperty.setValue方法的具体用法?Java GrProperty.setValue怎么用?Java GrProperty.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在iot.jcypher.graph.GrProperty的用法示例。


在下文中一共展示了GrProperty.setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
	}
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:18,代码来源:ResultHandler.java

示例2: 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);
	}
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:20,代码来源:ValueAndTypeMapping.java

示例3: 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);
	}
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:27,代码来源:ListFieldMapping.java

示例4: 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;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:13,代码来源:ResultHandler.java

示例5: 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;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:13,代码来源:ResultHandler.java

示例6: 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);
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:8,代码来源:ListFieldMapping.java

示例7: testGraphRelConcurrency_06

import iot.jcypher.graph.GrProperty; //导入方法依赖的package包/类
@Test
public void testGraphRelConcurrency_06() {
	
	// second client changes relation
	// first client tries to delete same relation
	
	Locking lockingStrategy = Locking.OPTIMISTIC;
	initDB(lockingStrategy);
	
	/******* first client loading j_smith ******/
	IDomainAccess da1 = DomainAccessFactory.createDomainAccess(dbAccess, domainName)
			.setLockingStrategy(lockingStrategy);
	
	Person j_smith = ConcurrencyTest.findPerson(da1, "Smith", "John");
	long j_smithId = da1.getSyncInfo(j_smith).getId();
	
	QResult res = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, res, 0,0,0,0);
	
	/******* second client loading j_smith ******/
	QResult res2 = queryResult2(j_smithId, lockingStrategy, dbAccess);
	long relId = res2.relations.get(0).getId();
	
	/******* second client modifying relation ******/
	GrProperty prop2 = res2.relations.get(0).getProperty("key");
	prop2.setValue(100);
	
	List<JcError> errors = res2.graph.store();
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	QResult pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, pocRes, 1,0,0,0);
	assertEquals(100, ((Number)pocRes.relations.get(0).getProperty("key").getValue()).intValue());
	
	/******* first client deleting relation ******/
	assertEquals(relId, res.relations.get(0).getId());
	res.relations.get(0).remove();
	
	errors = res.graph.store();
	assertTrue(!errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		JcError error = errors.get(0);
		assertEquals("Optimistic locking failed (an element was changed by another client)", error.getMessage());
		//throw new JcResultException(errors);
	}
	
	pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, pocRes, 1,0,0,0);
	assertEquals(100, ((Number)pocRes.relations.get(0).getProperty("key").getValue()).intValue());
	
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:58,代码来源:ConcurrencyGraphTest.java

示例8: testGraphRelConcurrency_05

import iot.jcypher.graph.GrProperty; //导入方法依赖的package包/类
@Test
public void testGraphRelConcurrency_05() {
	
	// second client changes relation
	// first client tries to delete same relation
	
	Locking lockingStrategy = Locking.NONE;
	initDB(lockingStrategy);
	
	/******* first client loading j_smith ******/
	IDomainAccess da1 = DomainAccessFactory.createDomainAccess(dbAccess, domainName)
			.setLockingStrategy(lockingStrategy);
	
	Person j_smith = ConcurrencyTest.findPerson(da1, "Smith", "John");
	long j_smithId = da1.getSyncInfo(j_smith).getId();
	
	QResult res = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, res, 0,0,0,0);
	
	/******* second client loading j_smith ******/
	QResult res2 = queryResult2(j_smithId, lockingStrategy, dbAccess);
	long relId = res2.relations.get(0).getId();
	
	/******* second client modifying relation ******/
	GrProperty prop2 = res2.relations.get(0).getProperty("key");
	prop2.setValue(100);
	
	List<JcError> errors = res2.graph.store();
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	QResult pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, pocRes, 1,0,0,0);
	assertEquals(100, ((Number)pocRes.relations.get(0).getProperty("key").getValue()).intValue());
	
	/******* first client deleting relation ******/
	assertEquals(relId, res.relations.get(0).getId());
	res.relations.get(0).remove();
	
	errors = res.graph.store();
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	boolean del = testDeletedRelation(res.relations.get(0).getId(), dbAccess);
	assertTrue(del);
	
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:55,代码来源:ConcurrencyGraphTest.java

示例9: testGraphRelConcurrency_04

import iot.jcypher.graph.GrProperty; //导入方法依赖的package包/类
@Test
public void testGraphRelConcurrency_04() {
	
	// second client deletes relation
	// first client tries to change same relation
	
	Locking lockingStrategy = Locking.OPTIMISTIC;
	initDB(lockingStrategy);
	
	/******* first client loading j_smith ******/
	IDomainAccess da1 = DomainAccessFactory.createDomainAccess(dbAccess, domainName)
			.setLockingStrategy(lockingStrategy);
	
	Person j_smith = ConcurrencyTest.findPerson(da1, "Smith", "John");
	long j_smithId = da1.getSyncInfo(j_smith).getId();
	
	QResult res = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, res, 0,0,0,0);
	
	/******* second client loading j_smith ******/
	QResult res2 = queryResult2(j_smithId, lockingStrategy, dbAccess);
	
	/******* second client deleting relation ******/
	long relId = res2.relations.get(0).getId();
	res2.relations.get(0).remove();
	
	List<JcError> errors = res2.graph.store();
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	boolean del = testDeletedRelation(relId, dbAccess);
	assertTrue(del);
	
	/******* first client modifying relation ******/
	assertEquals(relId, res.relations.get(0).getId());
	GrProperty prop = res.relations.get(0).getProperty("key");
	prop.setValue(101);
	
	errors = res.graph.store();
	assertTrue(!errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		JcError error = errors.get(0);
		assertEquals("Optimistic locking failed (an element was deleted by another client)", error.getMessage());
		assertEquals("element id: " + res.relations.get(0).getId(), error.getAdditionalInfo());
		//throw new JcResultException(errors);
	}
	
	del = testDeletedRelation(res.relations.get(0).getId(), dbAccess);
	assertTrue(del);
	
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:57,代码来源:ConcurrencyGraphTest.java

示例10: testGraphRelConcurrency_03

import iot.jcypher.graph.GrProperty; //导入方法依赖的package包/类
/**
 * Note: Locking.NONE: changes to a changed relation will be applied,
 * changes to a deleted relation will be ignored, the relation is still deleted
 */
@Test
public void testGraphRelConcurrency_03() {
	
	// second client deletes relation
	// first client tries to change same relation
	
	Locking lockingStrategy = Locking.NONE;
	initDB(lockingStrategy);
	
	/******* first client loading j_smith ******/
	IDomainAccess da1 = DomainAccessFactory.createDomainAccess(dbAccess, domainName)
			.setLockingStrategy(lockingStrategy);
	
	Person j_smith = ConcurrencyTest.findPerson(da1, "Smith", "John");
	long j_smithId = da1.getSyncInfo(j_smith).getId();
	
	QResult res = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, res, 0,0,0,0);
	
	/******* second client loading j_smith ******/
	QResult res2 = queryResult2(j_smithId, lockingStrategy, dbAccess);
	long relId = res2.relations.get(0).getId();
	
	/******* second client deleting relation ******/
	res2.relations.get(0).remove();
	
	List<JcError> errors = res2.graph.store();
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	boolean del = testDeletedRelation(relId, dbAccess);
	assertTrue(del);
	
	/******* first client modifying relation ******/
	assertEquals(relId, res.relations.get(0).getId());
	GrProperty prop = res.relations.get(0).getProperty("key");
	prop.setValue(101);
	
	errors = res.graph.store();
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	del = testDeletedRelation(res.relations.get(0).getId(), dbAccess);
	assertTrue(del);
	
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:58,代码来源:ConcurrencyGraphTest.java

示例11: testGraphRelConcurrency_02

import iot.jcypher.graph.GrProperty; //导入方法依赖的package包/类
@Test
public void testGraphRelConcurrency_02() {
	
	// second client changes relation
	// first client tries to change same relation
	
	Locking lockingStrategy = Locking.OPTIMISTIC;
	initDB(lockingStrategy);
	
	/******* first client loading j_smith ******/
	IDomainAccess da1 = DomainAccessFactory.createDomainAccess(dbAccess, domainName)
			.setLockingStrategy(lockingStrategy);
	
	Person j_smith = ConcurrencyTest.findPerson(da1, "Smith", "John");
	long j_smithId = da1.getSyncInfo(j_smith).getId();
	
	QResult res = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, res, 0,0,0,0);
	
	/******* second client loading j_smith ******/
	QResult res2 = queryResult2(j_smithId, lockingStrategy, dbAccess);
	long relId = res2.relations.get(0).getId();
	
	/******* second client modifying relation ******/
	GrProperty prop2 = res2.relations.get(0).getProperty("key");
	prop2.setValue(100);
	
	List<JcError> errors = res2.graph.store();
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	QResult pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, pocRes, 1,0,0,0);
	assertEquals(100, ((Number)pocRes.relations.get(0).getProperty("key").getValue()).intValue());
	
	/******* first client modifying relation ******/
	assertEquals(relId, res.relations.get(0).getId());
	GrProperty prop = res.relations.get(0).getProperty("key");
	prop.setValue(101);
	
	errors = res.graph.store();
	assertTrue(!errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		JcError error = errors.get(0);
		assertEquals("Optimistic locking failed (an element was changed by another client)", error.getMessage());
		assertEquals("element id: " + res.relations.get(0).getId(), error.getAdditionalInfo());
		//throw new JcResultException(errors);
	}
	
	pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, pocRes, 1,0,0,0);
	assertEquals(100, ((Number)pocRes.relations.get(0).getProperty("key").getValue()).intValue());
	
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:60,代码来源:ConcurrencyGraphTest.java

示例12: testGraphRelConcurrency_01

import iot.jcypher.graph.GrProperty; //导入方法依赖的package包/类
@Test
public void testGraphRelConcurrency_01() {
	
	// second client changes relation
	// first client tries to change same relation
	
	Locking lockingStrategy = Locking.NONE;
	try {
		Thread.sleep(1000);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
	initDB(lockingStrategy);
	
	/******* first client loading j_smith ******/
	IDomainAccess da1 = DomainAccessFactory.createDomainAccess(dbAccess, domainName)
			.setLockingStrategy(lockingStrategy);
	
	Person j_smith = ConcurrencyTest.findPerson(da1, "Smith", "John");
	long j_smithId = da1.getSyncInfo(j_smith).getId();
	
	QResult res = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, res, 0,0,0,0);
	
	/******* second client loading j_smith ******/
	QResult res2 = queryResult2(j_smithId, lockingStrategy, dbAccess);
	long relId = res2.relations.get(0).getId();
	
	/******* second client modifying relation ******/
	GrProperty prop2 = res2.relations.get(0).getProperty("key");
	prop2.setValue(100);
	
	List<JcError> errors = res2.graph.store();
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	QResult pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, pocRes, 1,0,0,0);
	assertEquals(100, ((Number)pocRes.relations.get(0).getProperty("key").getValue()).intValue());
	
	/******* first client modifying relation ******/
	assertEquals(relId, res.relations.get(0).getId());
	GrProperty prop = res.relations.get(0).getProperty("key");
	prop.setValue(101);
	
	errors = res.graph.store();
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, pocRes, 2,0,0,0);
	assertEquals(101, ((Number)pocRes.relations.get(0).getProperty("key").getValue()).intValue());
	
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:62,代码来源:ConcurrencyGraphTest.java

示例13: testGraphConcurrency_06

import iot.jcypher.graph.GrProperty; //导入方法依赖的package包/类
@Test
public void testGraphConcurrency_06() {
	
	// second client changes node
	// first client tries to delete same node
	
	Locking lockingStrategy = Locking.OPTIMISTIC;
	initDB(lockingStrategy);
	
	/******* first client loading j_smith ******/
	IDomainAccess da1 = DomainAccessFactory.createDomainAccess(dbAccess, domainName)
			.setLockingStrategy(lockingStrategy);
	
	Person j_smith = ConcurrencyTest.findPerson(da1, "Smith", "John");
	long j_smithId = da1.getSyncInfo(j_smith).getId();
	
	QResult pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, pocRes, 0,0,0,0);
	
	QResult res = queryResult(j_smithId, lockingStrategy, dbAccess);
	
	/******* second client loading j_smith ******/
	QResult res2 = queryResult(j_smithId, lockingStrategy, dbAccess);
	
	/******* second client modifying j_smith ******/
	GrProperty prop2 = res2.node.getProperty("firstName");
	prop2.setValue("Johnny");
	
	List<JcError> errors = res2.graph.store();
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(1, pocRes, 0,0,0,0);
	assertEquals("Johnny", pocRes.node.getProperty("firstName").getValue().toString());
	
	/******* first client trying to delete j_smith ******/
	for (GrRelation relat : res.relations) {
		relat.remove();
	}
	res.node.remove();
	
	errors = res.graph.store();
	assertTrue(!errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		JcError error = errors.get(0);
		assertEquals("Optimistic locking failed (an element was changed by another client)", error.getMessage());
		//throw new JcResultException(errors);
	}
	
	pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(1, pocRes, 0,0,0,0);
	assertEquals("Johnny", pocRes.node.getProperty("firstName").getValue().toString());
	
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:61,代码来源:ConcurrencyGraphTest.java

示例14: testGraphConcurrency_05

import iot.jcypher.graph.GrProperty; //导入方法依赖的package包/类
@Test
public void testGraphConcurrency_05() {
	
	// second client changes node
	// first client tries to delete same node
	
	Locking lockingStrategy = Locking.NONE;
	initDB(lockingStrategy);
	
	/******* first client loading j_smith ******/
	IDomainAccess da1 = DomainAccessFactory.createDomainAccess(dbAccess, domainName)
			.setLockingStrategy(lockingStrategy);
	
	Person j_smith = ConcurrencyTest.findPerson(da1, "Smith", "John");
	long j_smithId = da1.getSyncInfo(j_smith).getId();
	
	QResult pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, pocRes, 0,0,0,0);
	
	QResult res = queryResult(j_smithId, lockingStrategy, dbAccess);
	
	/******* second client loading j_smith ******/
	QResult res2 = queryResult(j_smithId, lockingStrategy, dbAccess);
	
	/******* second client modifying j_smith ******/
	GrProperty prop2 = res2.node.getProperty("firstName");
	prop2.setValue("Johnny");
	
	List<JcError> errors = res2.graph.store();
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(1, pocRes, 0,0,0,0);
	assertEquals("Johnny", pocRes.node.getProperty("firstName").getValue().toString());
	
	/******* first client trying to delete j_smith ******/
	for (GrRelation relat : res.relations) {
		relat.remove();
	}
	res.node.remove();
	
	errors = res.graph.store();
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	boolean del = testDeleted(j_smithId, dbAccess);
	assertTrue(del);
	
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:58,代码来源:ConcurrencyGraphTest.java

示例15: testGraphConcurrency_04

import iot.jcypher.graph.GrProperty; //导入方法依赖的package包/类
@Test
public void testGraphConcurrency_04() {
	
	// second client deletes node (+ adjacent relations)
	// first client tries to change same node
	
	Locking lockingStrategy = Locking.OPTIMISTIC;
	initDB(lockingStrategy);
	
	/******* modifying j_smith to increment version ******/
	IDomainAccess da1 = DomainAccessFactory.createDomainAccess(dbAccess, domainName)
			.setLockingStrategy(lockingStrategy);
	
	Person j_smith = ConcurrencyTest.findPerson(da1, "Smith", "John");
	long j_smithId = da1.getSyncInfo(j_smith).getId();
	
	QResult pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(0, pocRes, 0,0,0,0);
	
	List<PointOfContact> pocs = j_smith.getPointsOfContact();
	PointOfContact poc = pocs.remove(0);
	pocs.add(poc);
	j_smith.setFirstName("Johnny");
	List<JcError> errors = da1.store(j_smith);
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	pocRes = queryResult2(j_smithId, lockingStrategy, dbAccess);
	assertVersions(1, pocRes, 1,1,1,1);
	
	/******* first client loading j_smith ******/
	QResult res = queryResult(j_smithId, lockingStrategy, dbAccess);
	
	/******* second client loading j_smith ******/
	QResult res2 = queryResult(j_smithId, lockingStrategy, dbAccess);
	
	/******* second client deleting j_smith ******/
	for (GrRelation relat : res2.relations) {
		relat.remove();
	}
	res2.node.remove();
	
	errors = res2.graph.store();
	assertTrue(errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		//throw new JcResultException(errors);
	}
	
	boolean del = testDeleted(j_smithId, dbAccess);
	assertTrue(del);
	
	/******* first client modifying j_smith ******/
	GrProperty prop = res.node.getProperty("firstName");
	prop.setValue("Johnny Boy");
	
	errors = res.graph.store();
	assertTrue(!errors.isEmpty());
	if (errors.size() > 0) {
		printErrors(errors);
		JcError error = errors.get(0);
		assertEquals("Optimistic locking failed (an element was deleted by another client)", error.getMessage());
		assertEquals("element id: " + j_smithId, error.getAdditionalInfo());
		//throw new JcResultException(errors);
	}
	
	del = testDeleted(j_smithId, dbAccess);
	assertTrue(del);
	
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:75,代码来源:ConcurrencyGraphTest.java


注:本文中的iot.jcypher.graph.GrProperty.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。