use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class ContainsAllTest method performContainsAllStringValueTest.
private ExampleEntity performContainsAllStringValueTest(Set<String> entityStrings, Set<String> queryableStrings) throws Exception {
UnitOfWork creatingUOW = this.module.newUnitOfWork();
String[] entityStringsArray = new String[entityStrings.size()];
createEntityWithComplexValues(creatingUOW, this.module, entityStrings.toArray(entityStringsArray));
creatingUOW.complete();
UnitOfWork queryingUOW = this.module.newUnitOfWork();
try {
String[] queryableStringsArray = new String[queryableStrings.size()];
ExampleEntity entity = this.findEntityBasedOnValueStrings(queryableStrings.toArray(queryableStringsArray));
return entity;
} finally {
queryingUOW.discard();
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class ContainsTest method performContainsStringValueTest.
private ExampleEntity performContainsStringValueTest(Set<String> entityStrings, String queryableString) throws Exception {
UnitOfWork creatingUOW = this.module.newUnitOfWork();
String[] entityStringsArray = new String[entityStrings.size()];
ContainsAllTest.createEntityWithComplexValues(creatingUOW, this.module, entityStrings.toArray(entityStringsArray));
creatingUOW.complete();
UnitOfWork queryingUOW = this.module.newUnitOfWork();
try {
ExampleEntity entity = this.findEntityBasedOnValueString(queryableString);
return entity;
} finally {
queryingUOW.discard();
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class ContainsTest method performContainsStringTest.
private ExampleEntity performContainsStringTest(Set<String> entityStrings, String queryableString) throws Exception {
UnitOfWork creatingUOW = this.module.newUnitOfWork();
String[] entityStringsArray = new String[entityStrings.size()];
ContainsAllTest.createEntityWithStrings(creatingUOW, this.module, entityStrings.toArray(entityStringsArray));
creatingUOW.complete();
UnitOfWork queryingUOW = this.module.newUnitOfWork();
try {
ExampleEntity entity = this.findEntity(queryableString);
return entity;
} finally {
queryingUOW.discard();
}
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class RDFPerformanceTest method doList.
private List<ExampleEntity> doList(int howMany) {
List<ExampleEntity> list = new ArrayList<ExampleEntity>();
UnitOfWork uow = this.module.newUnitOfWork();
Iterator<ExampleEntity> iter = uow.newQuery(this.module.newQueryBuilder(ExampleEntity.class)).iterator();
int found = 0;
while (iter.hasNext()) {
found++;
ExampleEntity exampleEntity = iter.next();
if (exampleEntity != null)
list.add(exampleEntity);
}
uow.discard();
if (found != howMany) {
LOG.warn("Found " + found + " entities instead of " + howMany + ".");
}
return list;
}
use of org.qi4j.api.unitofwork.UnitOfWork in project qi4j-sdk by Qi4j.
the class DomainEventSourceResourceSample method generateTestData.
private static void generateTestData(UnitOfWorkFactory unitOfWorkFactory) throws UnitOfWorkCompletionException {
// Set principal for the UoW
Principal administratorPrincipal = new Principal() {
public String getName() {
return "administrator";
}
};
// Perform UoW with usecase defined
for (int i = 0; i < 43; i++) {
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(UsecaseBuilder.newUsecase("Change description " + (i + 1)));
uow.setMetaInfo(administratorPrincipal);
TestEntity entity = uow.newEntity(TestEntity.class);
entity.changedDescription("New description");
uow.complete();
}
}
Aggregations