Adding a new test suite for persistence, that is somewhat understandable and not totally non-sense. Also, it is a multi-layered application, to ensure that Type Lookups are handled correctly.
JDBM was first victim to get this new tests.
Signed-off-by: niclas <niclas@hedhman.org>
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java b/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
index 9952994..68e2232 100644
--- a/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
@@ -41,7 +41,7 @@
public static EntityReference parseEntityReference(String identityString)
{
Objects.requireNonNull( identityString, "identityString must not be null" );
- return new EntityReference( StringIdentity.fromString( identityString ) );
+ return new EntityReference( StringIdentity.identity( identityString ) );
}
/**
diff --git a/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java b/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java
index 7d85381..3eba611 100644
--- a/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java
+++ b/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java
@@ -55,7 +55,7 @@
return value;
}
- public static Identity fromString(String serializedState)
+ public static Identity identity( String serializedState )
{
return new StringIdentity( serializedState );
}
diff --git a/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java b/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java
index 0add4c6..6f85ca7 100644
--- a/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java
+++ b/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java
@@ -27,6 +27,6 @@
@Override
public Identity generate(Class<?> compositeType)
{
- return StringIdentity.fromString(UUID.randomUUID().toString());
+ return StringIdentity.identity( UUID.randomUUID().toString() );
}
}
diff --git a/core/api/src/test/java/org/apache/polygene/api/OperatorsTest.java b/core/api/src/test/java/org/apache/polygene/api/OperatorsTest.java
index 72f8c7f..f018907 100644
--- a/core/api/src/test/java/org/apache/polygene/api/OperatorsTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/OperatorsTest.java
@@ -63,7 +63,7 @@
try
{
- EntityBuilder<TestEntity> entityBuilder = uow.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "123" ) );
+ EntityBuilder<TestEntity> entityBuilder = uow.newEntityBuilder( TestEntity.class, StringIdentity.identity( "123" ) );
entityBuilder.instance().value().set( assembler.module().newValue( TestValue.class ) );
TestEntity testEntity = entityBuilder.newInstance();
diff --git a/core/api/src/test/java/org/apache/polygene/api/type/ValueTypeFactoryTest.java b/core/api/src/test/java/org/apache/polygene/api/type/ValueTypeFactoryTest.java
index bd9ce3b..48ac6a5 100644
--- a/core/api/src/test/java/org/apache/polygene/api/type/ValueTypeFactoryTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/type/ValueTypeFactoryTest.java
@@ -125,7 +125,7 @@
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
{
assertThat(
- valueTypeFactory.valueTypeOf( module, uow.newEntity( SomeState.class, StringIdentity.fromString( "abc" ) ) ),
+ valueTypeFactory.valueTypeOf( module, uow.newEntity( SomeState.class, StringIdentity.identity( "abc" ) ) ),
instanceOf( EntityCompositeType.class ) );
}
}
diff --git a/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java b/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java
index 97b78db..f3a01d9 100644
--- a/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java
@@ -49,7 +49,7 @@
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
try
{
- EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "123" ) );
+ EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, StringIdentity.identity( "123" ) );
builder.instance().test().set( "habba" );
TestEntity test = builder.newInstance();
uow.remove( test );
diff --git a/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToEntityConversionTest.java b/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToEntityConversionTest.java
index 055a1db..86ac547 100644
--- a/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToEntityConversionTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToEntityConversionTest.java
@@ -65,7 +65,7 @@
public void testPropertyConversionToEntity()
throws Exception
{
- Identity identity = StringIdentity.fromString( "Niclas" );
+ Identity identity = StringIdentity.identity( "Niclas" );
ValueBuilder<SomeType> vb = valueBuilderFactory.newValueBuilder( SomeType.class );
SomeType prototype = vb.prototype();
prototype.identity().set( identity );
diff --git a/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToValueConversionTest.java b/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToValueConversionTest.java
index ae9c7c2..910cf72 100644
--- a/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToValueConversionTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToValueConversionTest.java
@@ -73,11 +73,11 @@
SomeType value;
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(usecase) )
{
- SomeType entity1 = createEntity( uow, StringIdentity.fromString( "Niclas" ) );
- SomeType entity2 = createEntity( uow, StringIdentity.fromString( "Paul" ) );
- SomeType entity3 = createEntity( uow, StringIdentity.fromString( "Jiri" ) );
- SomeType entity4 = createEntity( uow, StringIdentity.fromString( "Kent" ) );
- SomeType entity5 = createEntity( uow, StringIdentity.fromString( "Stan" ) );
+ SomeType entity1 = createEntity( uow, StringIdentity.identity( "Niclas" ) );
+ SomeType entity2 = createEntity( uow, StringIdentity.identity( "Paul" ) );
+ SomeType entity3 = createEntity( uow, StringIdentity.identity( "Jiri" ) );
+ SomeType entity4 = createEntity( uow, StringIdentity.identity( "Kent" ) );
+ SomeType entity5 = createEntity( uow, StringIdentity.identity( "Stan" ) );
entity1.assoc().set( entity2 );
entity1.many().add( entity3 );
entity1.named().put( "kent", entity4 );
@@ -89,7 +89,7 @@
}
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(usecase) )
{
- assertThat( value.identity().get(), equalTo( StringIdentity.fromString( "Niclas" ) ) );
+ assertThat( value.identity().get(), equalTo( StringIdentity.identity( "Niclas" ) ) );
assertThat( value.name().get(), equalTo( "[Niclas]" ) );
assertThat( uow.toValue( SomeType.class, value.assoc().get()).name().get(), equalTo( "[Paul]" ));
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java
index e855c57..fffc760 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java
@@ -74,7 +74,14 @@
{
Objects.requireNonNull( entity, "entity" );
checkImmutable();
- checkType( entity );
+ try
+ {
+ checkType( entity );
+ }
+ catch( IllegalArgumentException e )
+ {
+ throw new IllegalArgumentException( "Named association [" + name +"] must have Identity: " + entity );
+ }
associationInfo.checkConstraints( entity );
return namedAssociationState.put( name, EntityReference.create( ( (HasIdentity) entity ).identity().get() ) );
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ImportedServiceAssemblyImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ImportedServiceAssemblyImpl.java
index 2c7905b..614df0b 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ImportedServiceAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ImportedServiceAssemblyImpl.java
@@ -78,7 +78,7 @@
}
else
{
- id = StringIdentity.fromString( identity );
+ id = StringIdentity.identity( identity );
}
ImportedServiceModel serviceModel = new ImportedServiceModel( module,
@@ -103,7 +103,7 @@
{
// Find reference that is not yet used
int idx = 0;
- Identity id = StringIdentity.fromString( serviceType.getSimpleName() );
+ Identity id = StringIdentity.identity( serviceType.getSimpleName() );
boolean invalid;
do
{
@@ -113,7 +113,7 @@
if( serviceModel.identity().equals( id ) )
{
idx++;
- id = StringIdentity.fromString( serviceType.getSimpleName() + "_" + idx );
+ id = StringIdentity.identity( serviceType.getSimpleName() + "_" + idx );
invalid = true;
break;
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
index f69fe9f..225857d 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
@@ -708,7 +708,7 @@
Class<?> serviceType = serviceTypes.findFirst()
.orElse(null); // Use the first, which *SHOULD* be the main serviceType
int idx = 0;
- Identity id = StringIdentity.fromString(serviceType.getSimpleName());
+ Identity id = StringIdentity.identity( serviceType.getSimpleName() );
boolean invalid;
do
{
@@ -718,7 +718,7 @@
if (serviceAssembly.identity() != null && serviceAssembly.identity().equals(id))
{
idx++;
- id = StringIdentity.fromString(serviceType.getSimpleName() + "_" + idx);
+ id = StringIdentity.identity( serviceType.getSimpleName() + "_" + idx );
invalid = true;
break;
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ServiceDeclarationImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ServiceDeclarationImpl.java
index e5e17bb..92db867 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ServiceDeclarationImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ServiceDeclarationImpl.java
@@ -59,7 +59,7 @@
for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
{
if( identity != null ) {
- serviceAssembly.identity = StringIdentity.fromString( identity );
+ serviceAssembly.identity = StringIdentity.identity( identity );
}
}
return this;
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java b/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
index b836f67..071d2c3 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
@@ -264,7 +264,7 @@
}
else
{
- identity = StringIdentity.fromString( propertyState );
+ identity = StringIdentity.identity( propertyState );
}
}
diff --git a/core/runtime/src/test/java/org/apache/polygene/api/common/RemovalTest.java b/core/runtime/src/test/java/org/apache/polygene/api/common/RemovalTest.java
index 0c67baa..6c514c9 100644
--- a/core/runtime/src/test/java/org/apache/polygene/api/common/RemovalTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/api/common/RemovalTest.java
@@ -48,7 +48,7 @@
throws Exception
{
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "123" ) );
+ EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, StringIdentity.identity( "123" ) );
builder.instance().test().set( "habba" );
TestEntity test = builder.newInstance();
uow.remove( test );
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/SetAssociationInSideEffectTest.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/SetAssociationInSideEffectTest.java
index 941099b..84b6aed 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/SetAssociationInSideEffectTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/SetAssociationInSideEffectTest.java
@@ -61,8 +61,8 @@
{
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Purchase Steinway" ) ) )
{
- Pianist chris = uow.newEntity( Pianist.class, StringIdentity.fromString( "Chris" ) );
- Steinway modelD = uow.newEntity( Steinway.class, StringIdentity.fromString( "ModelD-274" ) );
+ Pianist chris = uow.newEntity( Pianist.class, StringIdentity.identity( "Chris" ) );
+ Steinway modelD = uow.newEntity( Steinway.class, StringIdentity.identity( "ModelD-274" ) );
assertThat( modelD.owner().get(), is( nullValue() ) );
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
index 5e49acf..45e8658 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
@@ -36,7 +36,7 @@
extends AbstractPolygeneTest
{
- public static final Identity NICLAS = StringIdentity.fromString( "niclas" );
+ public static final Identity NICLAS = StringIdentity.identity( "niclas" );
@Override
public void assemble( ModuleAssembly module )
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
index dd818f9..140fd9d 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
@@ -44,8 +44,8 @@
public class Qi382Test extends AbstractPolygeneTest
{
- public static final Identity FERRARI = StringIdentity.fromString( "Ferrari" );
- public static final Identity NICLAS = StringIdentity.fromString( "Niclas" );
+ public static final Identity FERRARI = StringIdentity.identity( "Ferrari" );
+ public static final Identity NICLAS = StringIdentity.identity( "Niclas" );
@Override
public void assemble( ModuleAssembly module )
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
index ea15a4f..96f0cad 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
@@ -47,9 +47,9 @@
{
try( UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork() )
{
- unitOfWork.newEntity( Car.class, StringIdentity.fromString( "Ferrari" ) );
- unitOfWork.newEntity( Car.class, StringIdentity.fromString( "Ford" ) );
- unitOfWork.newEntity( Car.class, StringIdentity.fromString( "Ferrari" ) );
+ unitOfWork.newEntity( Car.class, StringIdentity.identity( "Ferrari" ) );
+ unitOfWork.newEntity( Car.class, StringIdentity.identity( "Ford" ) );
+ unitOfWork.newEntity( Car.class, StringIdentity.identity( "Ferrari" ) );
unitOfWork.complete();
}
}
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/activation/ImportedServiceActivationTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/activation/ImportedServiceActivationTest.java
index db3cca8..07674f0 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/activation/ImportedServiceActivationTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/activation/ImportedServiceActivationTest.java
@@ -179,7 +179,7 @@
module -> {
module.importedServices( TestedService.class ).
importedBy( ImportedServiceDeclaration.SERVICE_IMPORTER ).
- setMetaInfo( StringIdentity.fromString( "testimporter" ) ).
+ setMetaInfo( StringIdentity.identity( "testimporter" ) ).
withActivators( TestedActivator.class ).
importOnStartup();
module.services( TestedServiceImporterService.class ).identifiedBy( "testimporter" );
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityTypeTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityTypeTest.java
index ab7bf79..1c63573 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityTypeTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityTypeTest.java
@@ -40,9 +40,9 @@
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
try
{
- EntityBuilder<Rst> builder3 = uow.newEntityBuilder( Rst.class, StringIdentity.fromString( "123" ) );
- EntityBuilder<Def> builder2 = uow.newEntityBuilder( Def.class, StringIdentity.fromString( "456" ) );
- EntityBuilder<Abc> builder1 = uow.newEntityBuilder( Abc.class, StringIdentity.fromString( "789" ) );
+ EntityBuilder<Rst> builder3 = uow.newEntityBuilder( Rst.class, StringIdentity.identity( "123" ) );
+ EntityBuilder<Def> builder2 = uow.newEntityBuilder( Def.class, StringIdentity.identity( "456" ) );
+ EntityBuilder<Abc> builder1 = uow.newEntityBuilder( Abc.class, StringIdentity.identity( "789" ) );
}
finally
{
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityVisibilityTest.java
index 908e8f2..519d2a7 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityVisibilityTest.java
@@ -47,7 +47,7 @@
public class EntityVisibilityTest
{
- public static final Identity TEST_IDENTITY = StringIdentity.fromString( "123" );
+ public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
private Energy4Java polygene;
private Module module;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/injection/ServiceInjectionTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/injection/ServiceInjectionTest.java
index 9fa6411..637a141 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/injection/ServiceInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/injection/ServiceInjectionTest.java
@@ -82,7 +82,7 @@
ServiceUser user = factory.newObject( ServiceUser.class );
assertEquals( "X", user.testSingle() );
- assertThat( user.testIdentity(), equalTo( StringIdentity.fromString( "Foo" ) ) );
+ assertThat( user.testIdentity(), equalTo( StringIdentity.identity( "Foo" ) ) );
assertEquals( "FooX", user.testServiceReference() );
assertEquals( "Bar", user.testQualifier() );
assertEquals( "A", user.testStringIterable() );
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/injection/UnitOfWorkInjectionTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/injection/UnitOfWorkInjectionTest.java
index 105a698..cd61437 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/injection/UnitOfWorkInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/injection/UnitOfWorkInjectionTest.java
@@ -53,7 +53,7 @@
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase );
try
{
- Trial trial = uow.newEntity( Trial.class, StringIdentity.fromString( "123" ) );
+ Trial trial = uow.newEntity( Trial.class, StringIdentity.identity( "123" ) );
trial.doSomething();
uow.complete();
uow = unitOfWorkFactory.newUnitOfWork( usecase );
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyMixinTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyMixinTest.java
index 6432ccb..2b3b6af 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyMixinTest.java
@@ -62,11 +62,11 @@
throws UnitOfWorkCompletionException
{
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- FooEntity entity = uow.newEntity( FooEntity.class, StringIdentity.fromString( "123" ) );
+ FooEntity entity = uow.newEntity( FooEntity.class, StringIdentity.identity( "123" ) );
uow.complete();
uow = unitOfWorkFactory.newUnitOfWork();
- Foo foo = uow.get( Foo.class, StringIdentity.fromString( "123" ) );
+ Foo foo = uow.get( Foo.class, StringIdentity.identity( "123" ) );
try
{
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyRoleTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyRoleTest.java
index 965d8a8..f051aec 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyRoleTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyRoleTest.java
@@ -71,11 +71,11 @@
throws UnitOfWorkCompletionException
{
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- uow.newEntity( FooEntity.class, StringIdentity.fromString( "123" ) );
+ uow.newEntity( FooEntity.class, StringIdentity.identity( "123" ) );
uow.complete();
uow = unitOfWorkFactory.newUnitOfWork();
- Foo foo = uow.get( Foo.class, StringIdentity.fromString( "123" ) );
+ Foo foo = uow.get( Foo.class, StringIdentity.identity( "123" ) );
try
{
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/JDKMixinTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/JDKMixinTest.java
index 8bf7e41..831babd 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/JDKMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/JDKMixinTest.java
@@ -98,8 +98,8 @@
}
}
- private static final Identity EXTENDS_IDENTITY = StringIdentity.fromString( ExtendsJDKMixin.class.getName() );
- private static final Identity COMPOSE_IDENTITY = StringIdentity.fromString( ComposeWithJDKMixin.class.getName() );
+ private static final Identity EXTENDS_IDENTITY = StringIdentity.identity( ExtendsJDKMixin.class.getName() );
+ private static final Identity COMPOSE_IDENTITY = StringIdentity.identity( ComposeWithJDKMixin.class.getName() );
private static final Predicate<ServiceReference<?>> EXTENDS_IDENTITY_SPEC = new ServiceIdentitySpec(
EXTENDS_IDENTITY );
private static final Predicate<ServiceReference<?>> COMPOSE_IDENTITY_SPEC = new ServiceIdentitySpec(
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java
index 33785ea..d80d4e5 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java
@@ -47,7 +47,7 @@
public class ObjectVisibilityTest
{
- public static final Identity TEST_IDENTITY = StringIdentity.fromString( "123" );
+ public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
private Energy4Java polygene;
private Module module;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java
index 9f93dbd..9dbf52f 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java
@@ -214,7 +214,7 @@
{
QueryBuilder<Person> qb = qbf.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
- City kl = uow.get( City.class, StringIdentity.fromString( "kualalumpur" ));
+ City kl = uow.get( City.class, StringIdentity.identity( "kualalumpur" ) );
Query<Person> query = qb.where(
eq( person.mother().get().placeOfBirth(), kl )
).newQuery( Network.persons() );
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/query/Network.java b/core/runtime/src/test/java/org/apache/polygene/runtime/query/Network.java
index a84aca2..727d168 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/query/Network.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/query/Network.java
@@ -44,8 +44,8 @@
*/
class Network
{
- public static final Identity KUALALUMPUR = StringIdentity.fromString( "kualalumpur" );
- public static final Identity PENANG = StringIdentity.fromString( "penang" );
+ public static final Identity KUALALUMPUR = StringIdentity.identity( "kualalumpur" );
+ public static final Identity PENANG = StringIdentity.identity( "penang" );
private static List<Domain> domains;
private static List<Person> persons;
private static List<Male> males;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java
index f1d2f5c..289be4b 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java
@@ -46,7 +46,7 @@
public class ServiceVisibilityTest
{
- public static final Identity TEST_IDENTITY = StringIdentity.fromString( "123" );
+ public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
private Energy4Java polygene;
private Module module;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java
index 2a80ff1..6e6abab 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java
@@ -47,7 +47,7 @@
public class TransientVisibilityTest
{
- public static final Identity TEST_IDENTITY = StringIdentity.fromString( "123" );
+ public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
private Energy4Java polygene;
private Module module;
private Application app;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
index 8ee0fb0..425ae18 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
@@ -52,7 +52,7 @@
*/
public class PrivateEntityUnitOfWorkTest
{
- private static final Identity TEST_IDENTITY = StringIdentity.fromString( "1" );
+ private static final Identity TEST_IDENTITY = StringIdentity.identity( "1" );
@Structure
private UnitOfWorkFactory uowf;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/RemovalTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/RemovalTest.java
index 765fe6a..1a95f2f 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/RemovalTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/RemovalTest.java
@@ -40,7 +40,7 @@
extends AbstractPolygeneTest
{
- private static final Identity TEST_IDENTITY = StringIdentity.fromString( "123" );
+ private static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
public void assemble(ModuleAssembly module )
throws AssemblyException
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/value/AssociationToValueTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/value/AssociationToValueTest.java
index 2966ea5..ffbe234 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/value/AssociationToValueTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/value/AssociationToValueTest.java
@@ -151,7 +151,7 @@
public Person findPersonByName( String name )
{
UnitOfWork uow = unitOfWorkFactory.currentUnitOfWork();
- return uow.toValue( Person.class, uow.get( Person.class, StringIdentity.fromString( name ) ) );
+ return uow.toValue( Person.class, uow.get( Person.class, StringIdentity.identity( name ) ) );
}
}
@@ -206,7 +206,7 @@
private Person createPerson( String name )
{
UnitOfWork uow = uowf.currentUnitOfWork();
- return uow.newEntity( Person.class, StringIdentity.fromString( name ) );
+ return uow.newEntity( Person.class, StringIdentity.identity( name ) );
}
}
}
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueSerializationRegressionTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueSerializationRegressionTest.java
index f29895d..f48bfe3 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueSerializationRegressionTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueSerializationRegressionTest.java
@@ -50,7 +50,7 @@
throws UnitOfWorkCompletionException
{
ValueBuilder<DualFaced> builder = valueBuilderFactory.newValueBuilder( DualFaced.class );
- builder.prototype().identity().set( StringIdentity.fromString( "1234" ) );
+ builder.prototype().identity().set( StringIdentity.identity( "1234" ) );
builder.prototype().name().set( "Hedhman" );
DualFaced value = builder.newInstance();
}
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java
index b0d7336..191808b 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java
@@ -48,7 +48,7 @@
public class ValueVisibilityTest
{
- public static final Identity TEST_IDENTIY = StringIdentity.fromString( "123" );
+ public static final Identity TEST_IDENTIY = StringIdentity.identity( "123" );
private Energy4Java polygene;
private Module module;
private Application app;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueWithAssociationTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueWithAssociationTest.java
index 02067e5..655505c 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueWithAssociationTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueWithAssociationTest.java
@@ -113,7 +113,7 @@
throws UnitOfWorkCompletionException
{
ValueBuilder<DualFaced> builder = valueBuilderFactory.newValueBuilder( DualFaced.class );
- builder.prototype().identity().set( StringIdentity.fromString( "1234" ) );
+ builder.prototype().identity().set( StringIdentity.identity( "1234" ) );
builder.prototype().name().set( "Hedhman" );
DualFaced value = builder.newInstance();
@@ -125,8 +125,8 @@
try (UnitOfWork uow = unitOfWorkFactory.newUnitOfWork())
{
- DualFaced entity = uow.get( DualFaced.class, StringIdentity.fromString( "1234" ) );
- assertThat( entity.identity().get(), equalTo( StringIdentity.fromString( "1234" ) ) );
+ DualFaced entity = uow.get( DualFaced.class, StringIdentity.identity( "1234" ) );
+ assertThat( entity.identity().get(), equalTo( StringIdentity.identity( "1234" ) ) );
assertThat( entity.name().get(), equalTo( "Hedhman" ) );
uow.complete();
}
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/visibility/VisibilityInUnitOfWorkTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/visibility/VisibilityInUnitOfWorkTest.java
index 559605f..ec9d072 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/visibility/VisibilityInUnitOfWorkTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/visibility/VisibilityInUnitOfWorkTest.java
@@ -41,8 +41,8 @@
public class VisibilityInUnitOfWorkTest
{
- public static final Identity TEST_IDENTITY1 = StringIdentity.fromString( "123" );
- public static final Identity TEST_IDENTITY2 = StringIdentity.fromString( "345" );
+ public static final Identity TEST_IDENTITY1 = StringIdentity.identity( "123" );
+ public static final Identity TEST_IDENTITY2 = StringIdentity.identity( "345" );
@Test
public void givenTwoModulesWithServiceAndEntityInOneAndEntityInOtherWhenOtherEntityAccessServiceWhichUsesItsEntityExpectServiceToHaveVisibility()
diff --git a/core/runtime/src/test/java/org/apache/polygene/spi/service/importer/ServiceInstanceImporterTest.java b/core/runtime/src/test/java/org/apache/polygene/spi/service/importer/ServiceInstanceImporterTest.java
index 2c566b4..237e8ab 100644
--- a/core/runtime/src/test/java/org/apache/polygene/spi/service/importer/ServiceInstanceImporterTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/spi/service/importer/ServiceInstanceImporterTest.java
@@ -46,7 +46,7 @@
{
module.importedServices( TestService.class ).
identifiedBy( "test" ).
- setMetaInfo( StringIdentity.fromString( "testimporter" ) ).
+ setMetaInfo( StringIdentity.identity( "testimporter" ) ).
importedBy( ImportedServiceDeclaration.SERVICE_IMPORTER );
module.services( TestImporterService.class ).identifiedBy( "testimporter" );
diff --git a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/JSONMapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
index b88c189..cedcedc 100644
--- a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
@@ -419,7 +419,7 @@
String version = parsedState.getString( JSONKeys.VERSION );
Instant modified = Instant.ofEpochMilli( parsedState.getJsonNumber( JSONKeys.MODIFIED ).longValueExact() );
- Identity identity = StringIdentity.fromString( parsedState.getString( JSONKeys.IDENTITY ) );
+ Identity identity = StringIdentity.identity( parsedState.getString( JSONKeys.IDENTITY ) );
// Check if version is correct
JsonObject state;
diff --git a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/MapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/MapEntityStoreMixin.java
index 5e784f7..2c98677 100644
--- a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/MapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/MapEntityStoreMixin.java
@@ -382,7 +382,7 @@
String version = parsedState.getString( JSONKeys.VERSION );
Instant modified = Instant.ofEpochMilli( parsedState.getJsonNumber( JSONKeys.MODIFIED ).longValueExact() );
- Identity identity = StringIdentity.fromString( parsedState.getString( JSONKeys.IDENTITY ) );
+ Identity identity = StringIdentity.identity( parsedState.getString( JSONKeys.IDENTITY ) );
// Check if version is correct
JsonObject state;
diff --git a/core/spi/src/main/java/org/apache/polygene/spi/serialization/BuiltInConverters.java b/core/spi/src/main/java/org/apache/polygene/spi/serialization/BuiltInConverters.java
index 0c1b774..d86b81d 100644
--- a/core/spi/src/main/java/org/apache/polygene/spi/serialization/BuiltInConverters.java
+++ b/core/spi/src/main/java/org/apache/polygene/spi/serialization/BuiltInConverters.java
@@ -108,7 +108,7 @@
@Override
public Identity fromString( String string )
{
- return StringIdentity.fromString( string );
+ return StringIdentity.identity( string );
}
}
diff --git a/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java b/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
index 85bc744..b9030bd 100644
--- a/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
+++ b/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
@@ -61,7 +61,7 @@
value = serialization.deserialize( module, Regression142Type.class, serialized ); // ok
}
{
- Identity valueId = StringIdentity.fromString( "abcdefg" );
+ Identity valueId = StringIdentity.identity( "abcdefg" );
{
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "create" ) ) )
{
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java
new file mode 100644
index 0000000..507526d
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java
@@ -0,0 +1,546 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model;
+
+import java.util.Iterator;
+import org.apache.polygene.api.association.NamedAssociation;
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.constraint.ConstraintViolationException;
+import org.apache.polygene.api.identity.Identity;
+import org.apache.polygene.api.injection.scope.Service;
+import org.apache.polygene.api.injection.scope.Structure;
+import org.apache.polygene.api.object.ObjectFactory;
+import org.apache.polygene.api.structure.Application;
+import org.apache.polygene.api.structure.ApplicationDescriptor;
+import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.api.unitofwork.NoSuchEntityException;
+import org.apache.polygene.api.unitofwork.UnitOfWork;
+import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
+import org.apache.polygene.api.usecase.UsecaseBuilder;
+import org.apache.polygene.bootstrap.ApplicationAssembly;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.LayerAssembly;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.memory.MemoryEntityStoreService;
+import org.apache.polygene.spi.serialization.JsonSerialization;
+import org.apache.polygene.test.AbstractPolygeneBaseTest;
+import org.apache.polygene.test.entity.model.legal.LegalService;
+import org.apache.polygene.test.entity.model.legal.Will;
+import org.apache.polygene.test.entity.model.legal.WillAmount;
+import org.apache.polygene.test.entity.model.legal.WillItem;
+import org.apache.polygene.test.entity.model.legal.WillPercentage;
+import org.apache.polygene.test.entity.model.people.Address;
+import org.apache.polygene.test.entity.model.people.City;
+import org.apache.polygene.test.entity.model.people.Country;
+import org.apache.polygene.test.entity.model.people.PeopleRepository;
+import org.apache.polygene.test.entity.model.people.Person;
+import org.apache.polygene.test.entity.model.people.PhoneNumber;
+import org.apache.polygene.test.entity.model.people.Rent;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
+{
+ private static final String FRIEND = "Friend";
+ private static final String COLLEAGUE = "Colleague";
+
+ @Structure
+ private ObjectFactory obf;
+
+ @Service
+ private LegalService legalService;
+
+ @Service
+ private PeopleRepository peopleRepository;
+
+ @Structure
+ private UnitOfWorkFactory uowf;
+ private Identity baselId;
+ private Identity montpellierId;
+ private Identity hannoverId;
+ private Identity malmoId;
+ private Identity cherasId;
+
+ private Identity unknown3Id;
+ private Identity unknown2Id;
+ private Identity unknown1Id;
+ private Identity varnhemId;
+ private Identity canaryId;
+
+ private Identity switzerlandId;
+ private Identity franceId;
+ private Identity denmarkId;
+ private Identity germanyId;
+ private Identity swedenId;
+ private Identity usId;
+ private Identity malaysiaId;
+
+ @Before
+ public void setupTestData()
+ {
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "TestData Generation" ) ) )
+ {
+ testData();
+ uow.complete();
+ }
+ }
+
+ @Test
+ public void validateAllCountriesPresent()
+ {
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllCountriesPresent" ) ) )
+ {
+ assertThat( peopleRepository.findCountryByCountryCode( "my" ).name().get(), equalTo( "Malaysia" ) );
+ assertThat( peopleRepository.findCountryByCountryCode( "us" ).name().get(), equalTo( "United States" ) );
+ assertThat( peopleRepository.findCountryByCountryCode( "se" ).name().get(), equalTo( "Sweden" ) );
+ assertThat( peopleRepository.findCountryByCountryCode( "de" ).name().get(), equalTo( "Germany" ) );
+ assertThat( peopleRepository.findCountryByCountryCode( "dk" ).name().get(), equalTo( "Denmark" ) );
+ assertThat( peopleRepository.findCountryByCountryCode( "fr" ).name().get(), equalTo( "France" ) );
+ assertThat( peopleRepository.findCountryByCountryCode( "ch" ).name().get(), equalTo( "Switzerland" ) );
+ }
+ }
+
+ @Test
+ public void validateAllCitiesPresent()
+ {
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllCitiesPresent" ) ) )
+ {
+ assertThat( peopleRepository.findCity( baselId ).name().get(), equalTo( "Basel" ) );
+ assertThat( peopleRepository.findCity( malmoId ).name().get(), equalTo( "Malmo" ) );
+ assertThat( peopleRepository.findCity( cherasId ).name().get(), equalTo( "Cheras" ) );
+ assertThat( peopleRepository.findCity( hannoverId ).name().get(), equalTo( "Hannover" ) );
+ assertThat( peopleRepository.findCity( montpellierId ).name().get(), equalTo( "Montpellier" ) );
+ }
+ }
+
+ @Test
+ public void validateAllAddressesPresent()
+ {
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllAddressesPresent" ) ) )
+ {
+ Address canary = peopleRepository.findAddress( canaryId );
+ assertThat( canary.street().get(), equalTo( "10, CH5A, Jalan Cheras Hartamas" ) );
+ assertThat( canary.country().get().identity().get(), equalTo( malaysiaId ) );
+ assertThat( canary.city().get().identity().get(), equalTo( cherasId ) );
+ assertThat( canary.zipCode().get(), equalTo( "43200" ) );
+
+ Address varnhem = peopleRepository.findAddress( varnhemId );
+ assertThat( varnhem.street().get(), equalTo( "Varnhemsgatan 25" ) );
+ assertThat( varnhem.city().get().identity().get(), equalTo( malmoId ) );
+ assertThat( varnhem.country().get().identity().get(), equalTo( swedenId ) );
+ assertThat( varnhem.zipCode().get(), equalTo( "215 00" ) );
+
+ Address unknown = peopleRepository.findAddress( unknown1Id );
+ assertThat( unknown.street().get(), equalTo( "" ) );
+ assertThat( unknown.city().get().identity().get(), equalTo( montpellierId ) );
+ assertThat( unknown.country().get().identity().get(), equalTo( franceId ) );
+ assertThat( unknown.zipCode().get(), equalTo( "" ) );
+
+ unknown = peopleRepository.findAddress( unknown2Id );
+ assertThat( unknown.street().get(), equalTo( "" ) );
+ assertThat( unknown.city().get().identity().get(), equalTo( hannoverId ) );
+ assertThat( unknown.country().get().identity().get(), equalTo( germanyId ) );
+ assertThat( unknown.zipCode().get(), equalTo( "" ) );
+
+ unknown = peopleRepository.findAddress( unknown3Id );
+ assertThat( unknown.street().get(), equalTo( "" ) );
+ assertThat( unknown.city().get().identity().get(), equalTo( baselId ) );
+ assertThat( unknown.country().get().identity().get(), equalTo( switzerlandId ) );
+ assertThat( unknown.zipCode().get(), equalTo( "" ) );
+ }
+ }
+
+ @Test
+ public void validateAllPersonsPresent()
+ {
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllPersonsPresent" ) ) )
+ {
+ Person niclas = peopleRepository.findPersonByName( "Niclas" );
+ assertThat( niclas.name().get(), equalTo( "Niclas" ) );
+ Person eric = peopleRepository.findPersonByName( "Eric" );
+ assertThat( eric.name().get(), equalTo( "Eric" ) );
+ Person paul = peopleRepository.findPersonByName( "Paul" );
+ assertThat( paul.name().get(), equalTo( "Paul" ) );
+ Person toni = peopleRepository.findPersonByName( "Toni" );
+ assertThat( toni.name().get(), equalTo( "Toni" ) );
+ Person janna = peopleRepository.findPersonByName( "Janna" );
+ assertThat( janna.name().get(), equalTo( "Janna" ) );
+ Person peter = peopleRepository.findPersonByName( "Peter" );
+ assertThat( peter.name().get(), equalTo( "Peter" ) );
+ Person oscar = peopleRepository.findPersonByName( "Oscar" );
+ assertThat( oscar.name().get(), equalTo( "Oscar" ) );
+ Person kalle = peopleRepository.findPersonByName( "Kalle" );
+ assertThat( kalle.name().get(), equalTo( "Kalle" ) );
+ Person andreas = peopleRepository.findPersonByName( "Andreas" );
+ assertThat( andreas.name().get(), equalTo( "Andreas" ) );
+ }
+ }
+
+ @Test
+ public void givenTestDataWhenAddingNewNamedAssociationExpectAssociationAdded()
+ {
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenTestDataWhenAddingNewNamedAssociationExpectAssociationAdded" ) ) )
+ {
+ Person niclas = peopleRepository.findPersonByName( "Niclas" );
+ PhoneNumber newNumber = peopleRepository.createPhoneNumber( "+86-185-21320803" );
+ niclas.phoneNumbers().put( "Mobile", newNumber );
+ uow.complete();
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenTestDataWhenAddingNewNamedAssociationExpectAssociationAdded" ) ) )
+ {
+ Person niclas = peopleRepository.findPersonByName( "Niclas" );
+ NamedAssociation<PhoneNumber> numbers = niclas.phoneNumbers();
+ assertThat( numbers.count(), equalTo( 2 ) );
+ PhoneNumber mobile = numbers.get( "Mobile" );
+ assertThat( mobile.countryCode().get(), equalTo( 86 ) );
+ assertThat( mobile.areaCode().get(), equalTo( 185 ) );
+ assertThat( mobile.number().get(), equalTo( "21320803" ) );
+ PhoneNumber home = numbers.get( "Home" );
+ assertThat( home.countryCode().get(), equalTo( 60 ) );
+ assertThat( home.areaCode().get(), equalTo( 16 ) );
+ assertThat( home.number().get(), equalTo( "7636344" ) );
+ }
+ }
+
+ @Test
+ public void whenIteratingNamedAssociationExpectIterationInOrder()
+ {
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenIteratingNamedAssociationExpectIterationToSucceed" ) ) )
+ {
+ Person niclas = peopleRepository.findPersonByName( "Niclas" );
+ PhoneNumber newNumber1 = peopleRepository.createPhoneNumber( "+86-185-21320803" );
+ niclas.phoneNumbers().put( "Chinese", newNumber1 );
+ PhoneNumber newNumber2 = peopleRepository.createPhoneNumber( "+46-70-9876543" );
+ niclas.phoneNumbers().put( "Swedish", newNumber2 );
+ PhoneNumber newNumber3 = peopleRepository.createPhoneNumber( "+49-444-2832989823" );
+ niclas.phoneNumbers().put( "German", newNumber3 );
+ uow.complete();
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenIteratingNamedAssociationExpectIterationToSucceed" ) ) )
+ {
+ Person niclas = peopleRepository.findPersonByName( "Niclas" );
+ Iterator<String> numbers = niclas.phoneNumbers().iterator();
+ assertThat( numbers.hasNext(), is( true ) );
+ assertThat( numbers.next(), equalTo( "Home" ) );
+ assertThat( numbers.hasNext(), is( true ) );
+ assertThat( numbers.next(), equalTo( "Chinese" ) );
+ assertThat( numbers.hasNext(), is( true ) );
+ assertThat( numbers.next(), equalTo( "Swedish" ) );
+ assertThat( numbers.hasNext(), is( true ) );
+ assertThat( numbers.next(), equalTo( "German" ) );
+ }
+ }
+
+ @Test
+ public void givenTestDataWhenAddingSameNamedAssociationExpectAssociationModified()
+ {
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenTestDataWhenAddingSameNamedAssociationExpectAssociationModified" ) ) )
+ {
+ Person niclas = peopleRepository.findPersonByName( "Niclas" );
+ PhoneNumber newNumber = peopleRepository.createPhoneNumber( "+86-185-21320803" );
+ niclas.phoneNumbers().put( "Home", newNumber );
+ uow.complete();
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenTestDataWhenAddingSameNamedAssociationExpectAssociationModified" ) ) )
+ {
+ Person niclas = peopleRepository.findPersonByName( "Niclas" );
+ NamedAssociation<PhoneNumber> numbers = niclas.phoneNumbers();
+ assertThat( numbers.count(), equalTo( 1 ) );
+ PhoneNumber home = numbers.get( "Home" );
+ assertThat( home.countryCode().get(), equalTo( 86 ) );
+ assertThat( home.areaCode().get(), equalTo( 185 ) );
+ assertThat( home.number().get(), equalTo( "21320803" ) );
+ }
+ }
+
+ @Test
+ public void whenNullingOptionalAssociationExpectSuccess()
+ {
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenNullingOptionalAssociationExpectSuccess" ) ) )
+ {
+ Person toni = peopleRepository.findPersonByName( "Toni" );
+ toni.spouse().set( null );
+ uow.complete();
+ }
+ }
+
+ @Test( expected = ConstraintViolationException.class )
+ public void whenNullingNonOptionalAssociationExpectFailure()
+ {
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenNullingOptionalAssociationExpectSuccess" ) ) )
+ {
+ Person toni = peopleRepository.findPersonByName( "Toni" );
+ toni.nationality().set( null );
+ uow.complete();
+ }
+ }
+
+ @Test
+ public void whenRemovingEntityExpectAggregatedEntitiesToBeRemoved()
+ {
+ Identity homePhoneId;
+ Identity chinesePhoneId;
+ Identity germanPhoneId;
+ Identity swedishPhoneId;
+ Identity switzerlandId;
+ Identity malaysiaId;
+ Identity canaryId;
+ Identity despairStId;
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+ {
+ Person niclas = peopleRepository.findPersonByName( "Niclas" );
+ PhoneNumber newNumber1 = peopleRepository.createPhoneNumber( "+86-185-21320803" );
+ niclas.phoneNumbers().put( "Chinese", newNumber1 );
+ PhoneNumber newNumber2 = peopleRepository.createPhoneNumber( "+46-70-9876543" );
+ niclas.phoneNumbers().put( "Swedish", newNumber2 );
+ PhoneNumber newNumber3 = peopleRepository.createPhoneNumber( "+49-444-2832989823" );
+ niclas.phoneNumbers().put( "German", newNumber3 );
+ homePhoneId = niclas.phoneNumbers().get( "Home" ).identity().get();
+ swedishPhoneId = niclas.phoneNumbers().get( "Swedish" ).identity().get();
+ chinesePhoneId = niclas.phoneNumbers().get( "Chinese" ).identity().get();
+ germanPhoneId = niclas.phoneNumbers().get( "German" ).identity().get();
+
+ City basel = peopleRepository.findCity( baselId );
+ Country switzerland = peopleRepository.findCountryByCountryCode( "ch" );
+ niclas.movedToNewAddress( "DespairStreet 12A", "43HQ21", basel, switzerland, obf.newObject( Rent.Builder.class ).create( 1000, "EUR" ) );
+ uow.complete();
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+ {
+ Person niclas = peopleRepository.findPersonByName( "Niclas" );
+ assertThat( niclas.nationality().get().name().get(), equalTo( "Sweden" ) );
+ assertThat( niclas.oldAddresses().count(), equalTo( 1 ) );
+ assertThat( niclas.address().get().country().get().name().get(), equalTo( "Switzerland" ) );
+ canaryId = niclas.oldAddresses().get( 0 ).identity().get();
+ despairStId = niclas.address().get().identity().get();
+ malaysiaId = niclas.oldAddresses().get( 0 ).country().get().identity().get();
+ switzerlandId = niclas.address().get().country().get().identity().get();
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+ {
+ Person niclas = peopleRepository.findPersonByName( "Niclas" );
+ uow.remove( niclas );
+ uow.complete();
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+ {
+ Person niclas = peopleRepository.findPersonByName( "Niclas" );
+ }
+ catch( NoSuchEntityException e )
+ {
+ // expected
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+ {
+ peopleRepository.findPhoneNumberById( homePhoneId );
+ }
+ catch( NoSuchEntityException e )
+ {
+ // expected
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+ {
+ peopleRepository.findPhoneNumberById( chinesePhoneId );
+ }
+ catch( NoSuchEntityException e )
+ {
+ // expected
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+ {
+ peopleRepository.findPhoneNumberById( swedishPhoneId );
+ }
+ catch( NoSuchEntityException e )
+ {
+ // expected
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+ {
+ peopleRepository.findPhoneNumberById( germanPhoneId );
+ }
+ catch( NoSuchEntityException e )
+ {
+ // expected
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+ {
+ peopleRepository.findAddress( canaryId );
+ }
+ catch( NoSuchEntityException e )
+ {
+ // expected
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+ {
+ peopleRepository.findAddress( despairStId );
+ }
+ catch( NoSuchEntityException e )
+ {
+ // expected
+ }
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+ {
+ peopleRepository.findCountryByIdentity( switzerlandId );
+ peopleRepository.findCountryByIdentity( malaysiaId );
+
+ peopleRepository.findPersonByName( "Peter" );
+ peopleRepository.findPersonByName( "Andreas" );
+ peopleRepository.findPersonByName( "Toni" );
+ peopleRepository.findPersonByName( "Paul" );
+ }
+ }
+
+ @Test( expected = IllegalStateException.class )
+ public void whenNoActiveUnitOfWorkExpectIllegalStateException()
+ {
+ peopleRepository.findCountryByIdentity( switzerlandId );
+ }
+
+ private void testData()
+ {
+ Country malaysia = peopleRepository.createCountry( "my", "Malaysia" );
+ malaysiaId = malaysia.identity().get();
+ Country us = peopleRepository.createCountry( "us", "United States" );
+ usId = us.identity().get();
+ Country sweden = peopleRepository.createCountry( "se", "Sweden" );
+ swedenId = sweden.identity().get();
+ Country germany = peopleRepository.createCountry( "de", "Germany" );
+ germanyId = germany.identity().get();
+ Country denmark = peopleRepository.createCountry( "dk", "Denmark" );
+ denmarkId = denmark.identity().get();
+ Country france = peopleRepository.createCountry( "fr", "France" );
+ franceId = france.identity().get();
+ Country switzerland = peopleRepository.createCountry( "ch", "Switzerland" );
+ switzerlandId = switzerland.identity().get();
+ City cheras = peopleRepository.createCity( "Cheras" );
+ cherasId = cheras.identity().get();
+ City malmo = peopleRepository.createCity( "Malmo" );
+ malmoId = malmo.identity().get();
+ City hannover = peopleRepository.createCity( "Hannover" );
+ hannoverId = hannover.identity().get();
+ City montpellier = peopleRepository.createCity( "Montpellier" );
+ montpellierId = montpellier.identity().get();
+ City basel = peopleRepository.createCity( "Basel" );
+ baselId = basel.identity().get();
+ Rent.Builder rentBuilder = obf.newObject( Rent.Builder.class );
+ Rent rentCanary = rentBuilder.create( 3000, "MYR" );
+ Rent rentVarnhem = rentBuilder.create( 9000, "SEK" );
+ Rent rentUnknown1 = rentBuilder.create( 1200, "EUR" );
+ Rent rentUnknown2 = rentBuilder.create( 900, "EUR" );
+ Rent rentUnknown3 = rentBuilder.create( 2200, "EUR" );
+ Address canaryResidence = peopleRepository.createAddress( "10, CH5A, Jalan Cheras Hartamas", "43200", cheras, malaysia, rentCanary );
+ canaryId = canaryResidence.identity().get();
+ Address varnhem = peopleRepository.createAddress( "Varnhemsgatan 25", "215 00", malmo, sweden, rentVarnhem );
+ varnhemId = varnhem.identity().get();
+ Address unknown1 = peopleRepository.createAddress( "", "", montpellier, france, rentUnknown1 );
+ unknown1Id = unknown1.identity().get();
+ Address unknown2 = peopleRepository.createAddress( "", "", hannover, germany, rentUnknown2 );
+ unknown2Id = unknown2.identity().get();
+ Address unknown3 = peopleRepository.createAddress( "", "", basel, switzerland, rentUnknown3 );
+ unknown3Id = unknown3.identity().get();
+ Person eric = peopleRepository.createPerson( "Eric", malaysia, canaryResidence, null, null );
+ Person niclas = peopleRepository.createPerson( "Niclas", sweden, canaryResidence, null, peopleRepository.createPhoneNumber( "+60-16-7636344" ) );
+ niclas.children().add( eric );
+ Person kalle = peopleRepository.createPerson( "Kalle", sweden, varnhem, null, null );
+ Person oscar = peopleRepository.createPerson( "Oscar", sweden, varnhem, null, null );
+ Person peter = peopleRepository.createPerson( "Peter", germany, varnhem, null, peopleRepository.createPhoneNumber( "+46-70-1234567" ) );
+ peter.children().add( kalle );
+ peter.children().add( oscar );
+ Person paul = peopleRepository.createPerson( "Paul", france, unknown1, null, peopleRepository.createPhoneNumber( "+33-88-333666999" ) );
+ Person janna = peopleRepository.createPerson( "Janna", france, unknown2, null, peopleRepository.createPhoneNumber( "+49-11-22334455" ) );
+ Person toni = peopleRepository.createPerson( "Toni", france, unknown2, janna, peopleRepository.createPhoneNumber( "+49-12-99887766" ) );
+ janna.spouse().set( toni );
+ Person andreas = peopleRepository.createPerson( "Andreas", germany, unknown3, null, peopleRepository.createPhoneNumber( "+41-98-1234567" ) );
+ NamedAssociation<Person> niclasRels = niclas.relationships();
+ niclasRels.put( FRIEND, peter );
+ niclasRels.put( FRIEND, toni );
+ niclasRels.put( FRIEND, andreas );
+ niclasRels.put( FRIEND, paul );
+ niclasRels.put( COLLEAGUE, toni );
+ niclasRels.put( COLLEAGUE, andreas );
+ }
+
+ @Override
+ protected void defineApplication( ApplicationAssembly applicationAssembly )
+ throws AssemblyException
+ {
+ LayerAssembly accessLayer = applicationAssembly.layer( "Access Layer" );
+ LayerAssembly domainLayer = applicationAssembly.layer( "Domain Layer" );
+ LayerAssembly infrastructureLayer = applicationAssembly.layer( "Infrastructure Layer" );
+ LayerAssembly configLayer = applicationAssembly.layer( "Configuration Layer" );
+ accessLayer.uses( domainLayer.uses( infrastructureLayer.uses( configLayer ) ) );
+ defineConfigModule( configLayer.module( "Configuration Module" ) );
+ defineSerializationModule( configLayer.module( "Serialization Module" ) );
+ defineStorageModule( infrastructureLayer.module( "Storage Module" ) );
+ definePeopleModule( domainLayer.module( "People Module" ) );
+ defineLegalModule( domainLayer.module( "Legal Module" ) );
+ defineTestModule( accessLayer.module( "TestCase Module" ) );
+ }
+
+ @Override
+ protected Application newApplicationInstance( ApplicationDescriptor applicationModel )
+ {
+ Application application = super.newApplicationInstance( applicationModel );
+ Module module = application.findModule( "Access Layer", "TestCase Module" );
+ module.injectTo( this );
+ return application;
+ }
+
+ protected void defineTestModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ module.objects( this.getClass() );
+ }
+
+ protected void definePeopleModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ module.entities( Address.class, City.class, PhoneNumber.class );
+ module.entities( Country.class, Person.class );
+ module.services( PeopleRepository.class ).visibleIn( Visibility.application );
+ module.values( Rent.class );
+ module.objects( Rent.Builder.class ).visibleIn( Visibility.application );
+ }
+
+ protected void defineLegalModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ module.services( LegalService.class ).visibleIn( Visibility.application );
+ module.entities( Will.class, WillItem.class, WillPercentage.class, WillAmount.class );
+ }
+
+ protected void defineSerializationModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ module.services( JsonSerialization.class ).visibleIn( Visibility.application );
+ }
+
+ protected abstract void defineStorageModule( ModuleAssembly module );
+
+ protected void defineConfigModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.module );
+ }
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java
new file mode 100644
index 0000000..925e500
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.legal;
+
+import java.math.BigDecimal;
+import java.util.Map;
+import org.apache.polygene.api.entity.EntityBuilder;
+import org.apache.polygene.api.identity.Identity;
+import org.apache.polygene.api.identity.StringIdentity;
+import org.apache.polygene.api.injection.scope.Structure;
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.unitofwork.UnitOfWork;
+import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
+import org.apache.polygene.api.unitofwork.concern.UnitOfWorkPropagation;
+import org.apache.polygene.api.value.ValueBuilder;
+import org.apache.polygene.api.value.ValueBuilderFactory;
+import org.apache.polygene.test.entity.model.people.Person;
+
+@Mixins( LegalService.Mixin.class )
+public interface LegalService
+{
+ @UnitOfWorkPropagation
+ Identity createWill( Person principal, Map<Person, BigDecimal> amounts, Map<Person, Float> percentages, Map<Person, String> specificItems );
+
+ class Mixin
+ implements LegalService
+ {
+ @Structure
+ private ValueBuilderFactory vbf;
+
+ @Structure
+ private UnitOfWorkFactory uowf;
+
+ @Override
+ public Identity createWill( Person principal, Map<Person, BigDecimal> amounts, Map<Person, Float> percentages, Map<Person, String> specificItems )
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ Identity identity = StringIdentity.identity( "will-" + principal.name().get() );
+ EntityBuilder<Will> builder = uow.newEntityBuilder( Will.class, identity );
+ Will instance = builder.instance();
+ for( Map.Entry<Person, BigDecimal> entry : amounts.entrySet() )
+ {
+ WillAmount amount = createAmount( entry.getKey(), entry.getValue() );
+ instance.amounts().add( amount );
+ }
+ for( Map.Entry<Person, Float> entry : percentages.entrySet() )
+ {
+ WillPercentage amount = createPercentage( entry.getKey(), entry.getValue() );
+ instance.percentages().add( amount );
+ }
+ for( Map.Entry<Person, String> entry : specificItems.entrySet() )
+ {
+ String value = entry.getValue();
+ int pos = value.indexOf( '\n' );
+ String item = value.substring( 0, pos );
+ String description = value.substring( pos + 1 );
+ WillItem amount = createItem( entry.getKey(), item, description );
+ instance.items().add( amount );
+ }
+ builder.newInstance();
+ return identity;
+ }
+
+ private WillAmount createAmount( Person beneficiary, BigDecimal amount )
+ {
+ ValueBuilder<WillAmount> builder = vbf.newValueBuilder( WillAmount.class );
+ builder.prototype().amount().set( amount );
+ builder.prototype().beneficiary().set( beneficiary );
+ return builder.newInstance();
+ }
+
+ private WillPercentage createPercentage( Person beneficiary, Float percentage )
+ {
+ ValueBuilder<WillPercentage> builder = vbf.newValueBuilder( WillPercentage.class );
+ builder.prototype().percentage().set( percentage );
+ builder.prototype().beneficiary().set( beneficiary );
+ return builder.newInstance();
+ }
+
+ private WillItem createItem( Person beneficiary, String item, String description )
+ {
+ ValueBuilder<WillItem> builder = vbf.newValueBuilder( WillItem.class );
+ builder.prototype().item().set( item );
+ builder.prototype().item().set( description );
+ builder.prototype().beneficiary().set( beneficiary );
+ return builder.newInstance();
+ }
+ }
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/Will.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/Will.java
new file mode 100644
index 0000000..1c66efb
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/Will.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.legal;
+
+import org.apache.polygene.api.association.Association;
+import org.apache.polygene.api.association.ManyAssociation;
+import org.apache.polygene.test.entity.model.people.Person;
+
+public interface Will
+{
+
+ Association<Person> principal();
+
+ ManyAssociation<WillItem> items();
+
+ ManyAssociation<WillPercentage> percentages();
+
+ ManyAssociation<WillAmount> amounts();
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillAmount.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillAmount.java
new file mode 100644
index 0000000..6661375
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillAmount.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.legal;
+
+import java.math.BigDecimal;
+import org.apache.polygene.api.property.Property;
+
+public interface WillAmount extends WillBenefit
+{
+ Property<BigDecimal> amount();
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillBenefit.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillBenefit.java
new file mode 100644
index 0000000..0347a6c
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillBenefit.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.legal;
+
+import org.apache.polygene.api.association.Association;
+import org.apache.polygene.api.common.Optional;
+import org.apache.polygene.api.property.Property;
+import org.apache.polygene.test.entity.model.people.Person;
+
+public interface WillBenefit
+{
+ Association<Person> beneficiary();
+
+ @Optional
+ Property<String> condition();
+
+ @Optional
+ Association<Person> alternateBeneficiary();
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillItem.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillItem.java
new file mode 100644
index 0000000..abcafe3
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillItem.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.legal;
+
+import org.apache.polygene.api.property.Property;
+
+public interface WillItem extends WillBenefit
+{
+ Property<String> item();
+
+ Property<String> description();
+
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillPercentage.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillPercentage.java
new file mode 100644
index 0000000..dc34dd2
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/WillPercentage.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.legal;
+
+import org.apache.polygene.api.property.Property;
+
+public interface WillPercentage extends WillBenefit
+{
+ Property<Float> percentage();
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Address.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Address.java
new file mode 100644
index 0000000..cc6a426
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Address.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.people;
+
+import org.apache.polygene.api.association.Association;
+import org.apache.polygene.api.identity.HasIdentity;
+import org.apache.polygene.api.property.Property;
+
+public interface Address extends HasIdentity
+{
+ Property<Rent> rent();
+
+ Property<String> street();
+
+ Association<City> city();
+
+ Property<String> zipCode();
+
+ Association<Country> country();
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/City.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/City.java
new file mode 100644
index 0000000..25078c0
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/City.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.people;
+
+import org.apache.polygene.api.identity.HasIdentity;
+import org.apache.polygene.api.property.Property;
+
+public interface City extends HasIdentity
+{
+ Property<String> name();
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Country.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Country.java
new file mode 100644
index 0000000..cc0800b
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Country.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.people;
+
+import org.apache.polygene.api.identity.HasIdentity;
+import org.apache.polygene.api.property.Property;
+
+public interface Country extends HasIdentity
+{
+ Property<String> name();
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PeopleRepository.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PeopleRepository.java
new file mode 100644
index 0000000..0aeb8ea
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PeopleRepository.java
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.people;
+
+import org.apache.polygene.api.common.Optional;
+import org.apache.polygene.api.entity.EntityBuilder;
+import org.apache.polygene.api.identity.Identity;
+import org.apache.polygene.api.injection.scope.Structure;
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.unitofwork.UnitOfWork;
+import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
+
+import static org.apache.polygene.api.identity.StringIdentity.identity;
+
+@Mixins( PeopleRepository.Mixin.class )
+public interface PeopleRepository
+{
+ Person createPerson( String name, Country nationality, @Optional Address address, @Optional Person spouse, @Optional PhoneNumber homeNumber );
+
+ void addChild( Person parent, Person child );
+
+ Person findPersonByName( String name );
+
+ Country createCountry( String countryCode, String countryName );
+
+ Country findCountryByCountryCode( String countryCode );
+
+ Country findCountryByIdentity( Identity countryId );
+
+ Address createAddress( String street, String zipCode, City city, Country country, Rent rent );
+
+ Address findAddress( Identity addressId );
+
+ City createCity( String cityName );
+
+ City findCity( Identity cityId );
+
+ PhoneNumber createPhoneNumber( String phoneNumberString );
+
+ PhoneNumber findPhoneNumberById( Identity phoneNumberId );
+
+ class Mixin
+ implements PeopleRepository
+ {
+ @Structure
+ private UnitOfWorkFactory uowf;
+
+ @Override
+ public Person createPerson( String name, Country nationality, Address address, Person spouse, PhoneNumber homeNumber )
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ EntityBuilder<Person> builder = uow.newEntityBuilder( Person.class, identity( "person-" + name ) );
+ Person instance = builder.instance();
+ instance.name().set( name );
+ instance.nationality().set( nationality );
+ instance.address().set( address );
+ instance.spouse().set( spouse );
+ if( homeNumber != null )
+ {
+ instance.phoneNumbers().put( "Home", homeNumber );
+ }
+ return builder.newInstance();
+ }
+
+ @Override
+ public void addChild( Person parent, Person child )
+ {
+ parent.children().add( child );
+ }
+
+ @Override
+ public Person findPersonByName( String name )
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ return uow.get( Person.class, identity( "person-" + name ) );
+ }
+
+ @Override
+ public Country createCountry( String countryCode, String countryName )
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ EntityBuilder<Country> builder = uow.newEntityBuilder( Country.class, identity( "country-" + countryCode ) );
+ builder.instance().name().set( countryName );
+ return builder.newInstance();
+ }
+
+ @Override
+ public Country findCountryByCountryCode( String countryCode )
+ {
+
+ return findCountryByIdentity( identity( "country-" + countryCode ) );
+ }
+
+ @Override
+ public Country findCountryByIdentity( Identity countryId )
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ return uow.get( Country.class, countryId );
+ }
+
+ @Override
+ public Address createAddress( String street, String zipCode, City city, Country country, Rent rent )
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ EntityBuilder<Address> builder = uow.newEntityBuilder( Address.class );
+ Address prototype = builder.instance();
+ prototype.street().set( street );
+ prototype.zipCode().set( zipCode );
+ prototype.city().set( city );
+ prototype.country().set( country );
+ prototype.rent().set( rent );
+ return builder.newInstance();
+ }
+
+ @Override
+ public Address findAddress( Identity addressId )
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ return uow.get( Address.class, addressId );
+ }
+
+ @Override
+ public City createCity( String cityName )
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ EntityBuilder<City> builder = uow.newEntityBuilder( City.class );
+ builder.instance().name().set( cityName );
+ return builder.newInstance();
+ }
+
+ @Override
+ public City findCity( Identity cityId )
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ return uow.get( City.class, cityId );
+ }
+
+ @Override
+ public PhoneNumber createPhoneNumber( String phoneNumberString )
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ EntityBuilder<PhoneNumber> builder = uow.newEntityBuilder( PhoneNumber.class );
+ PhoneNumber prototype = builder.instance();
+
+ // Of course better parsing should be done for a real application.
+ int pos1 = phoneNumberString.indexOf( '-' );
+ int pos2 = phoneNumberString.indexOf( '-', pos1 + 1 );
+ String countryCode = phoneNumberString.substring( 1, pos1 );
+ String areaCode = phoneNumberString.substring( pos1 + 1, pos2 );
+ String number = phoneNumberString.substring( pos2 + 1 );
+
+ prototype.countryCode().set( Integer.parseInt( countryCode ) );
+ prototype.areaCode().set( Integer.parseInt( areaCode ) );
+ prototype.number().set( number );
+
+ return builder.newInstance();
+ }
+
+ @Override
+ public PhoneNumber findPhoneNumberById( Identity phoneNumberId )
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ return uow.get( PhoneNumber.class, phoneNumberId );
+ }
+ }
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Person.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Person.java
new file mode 100644
index 0000000..ac110a0
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Person.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.people;
+
+import org.apache.polygene.api.association.Association;
+import org.apache.polygene.api.association.ManyAssociation;
+import org.apache.polygene.api.association.NamedAssociation;
+import org.apache.polygene.api.common.Optional;
+import org.apache.polygene.api.entity.Aggregated;
+import org.apache.polygene.api.identity.HasIdentity;
+import org.apache.polygene.api.injection.scope.Service;
+import org.apache.polygene.api.injection.scope.Structure;
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.property.Property;
+import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
+import org.apache.polygene.api.unitofwork.concern.UnitOfWorkPropagation;
+
+@Mixins( Person.Mixin.class )
+public interface Person extends HasIdentity
+{
+ @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
+ void movedToNewAddress( String street, String zipCode, City city, Country country, Rent rent );
+
+ @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
+ void amendAddress( String street, String zipCode, City city, Country country );
+
+ Property<String> name();
+
+ Association<Country> nationality();
+
+ @Aggregated
+ Association<Address> address();
+
+ @Optional
+ Association<Person> spouse();
+
+ ManyAssociation<Person> children();
+
+ @Aggregated
+ ManyAssociation<Address> oldAddresses();
+
+ NamedAssociation<Person> relationships();
+
+ @Aggregated
+ NamedAssociation<PhoneNumber> phoneNumbers();
+
+ abstract class Mixin
+ implements Person
+ {
+ @Structure
+ private UnitOfWorkFactory uowf;
+
+ @Service
+ private PeopleRepository repository;
+
+ @Override
+ public void movedToNewAddress( String street, String zipCode, City city, Country country, Rent rent )
+ {
+ Address newAddress = repository.createAddress( street, zipCode, city, country, rent );
+ Address oldAddress = address().get();
+ oldAddresses().add( oldAddress );
+ address().set( newAddress );
+ }
+
+ @Override
+ public void amendAddress( String street, String zipCode, City city, Country country )
+ {
+ Address newAddress = repository.createAddress( street, zipCode, city, country, address().get().rent().get() );
+ address().set( newAddress );
+ }
+ }
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PhoneNumber.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PhoneNumber.java
new file mode 100644
index 0000000..c711eab
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PhoneNumber.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.people;
+
+import org.apache.polygene.api.identity.HasIdentity;
+import org.apache.polygene.api.injection.scope.Structure;
+import org.apache.polygene.api.property.Property;
+import org.apache.polygene.api.value.ValueBuilder;
+import org.apache.polygene.api.value.ValueBuilderFactory;
+
+public interface PhoneNumber extends HasIdentity
+{
+ Property<Integer> countryCode();
+
+ Property<Integer> areaCode();
+
+ Property<String> number();
+
+ class Builder
+ {
+ private final ValueBuilder<PhoneNumber> valueBuilder;
+ private final PhoneNumber prototype;
+
+ public Builder( @Structure ValueBuilderFactory vbf )
+ {
+ valueBuilder = vbf.newValueBuilder( PhoneNumber.class );
+ prototype = valueBuilder.prototype();
+ }
+
+ PhoneNumber create( int countryCode, int areaCode, String number )
+ {
+ prototype.countryCode().set( countryCode );
+ prototype.areaCode().set( areaCode );
+ prototype.number().set( number );
+ return valueBuilder.newInstance();
+ }
+ }
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Rent.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Rent.java
new file mode 100644
index 0000000..576b3dc
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/Rent.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.test.entity.model.people;
+
+import java.math.BigDecimal;
+import org.apache.polygene.api.injection.scope.Structure;
+import org.apache.polygene.api.property.Property;
+import org.apache.polygene.api.value.ValueBuilder;
+import org.apache.polygene.api.value.ValueBuilderFactory;
+
+public interface Rent
+{
+ Property<BigDecimal> amount();
+
+ Property<String> currency();
+
+ class Builder
+ {
+ @Structure
+ private ValueBuilderFactory vbf;
+
+ public Rent create( Integer amount, String currency )
+ {
+ ValueBuilder<Rent> builder = vbf.newValueBuilder( Rent.class );
+ Rent prototype = builder.prototype();
+ prototype.amount().set( new BigDecimal( amount ) );
+ prototype.currency().set( currency );
+ return builder.newInstance();
+ }
+ }
+}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractQueryTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractQueryTest.java
index 08abae0..0592b1d 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractQueryTest.java
@@ -465,7 +465,7 @@
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
- Domain gaming = unitOfWork.get( Domain.class, StringIdentity.fromString( "Gaming" ) );
+ Domain gaming = unitOfWork.get( Domain.class, StringIdentity.identity( "Gaming" ) );
Query<Person> query = unitOfWork.newQuery( qb.where( contains( person.interests(), gaming ) ) );
System.out.println( "*** script33: " + query );
@@ -477,7 +477,7 @@
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
- Female annDoe = unitOfWork.get( Female.class, StringIdentity.fromString( "anndoe" ) );
+ Female annDoe = unitOfWork.get( Female.class, StringIdentity.identity( "anndoe" ) );
Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.mother(), annDoe ) ) );
System.out.println( "*** script34: " + query );
@@ -500,7 +500,7 @@
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
- Account anns = unitOfWork.get( Account.class, StringIdentity.fromString( "accountOfAnnDoe" ) );
+ Account anns = unitOfWork.get( Account.class, StringIdentity.identity( "accountOfAnnDoe" ) );
Query<Person> query = unitOfWork.newQuery( qb.where( contains( person.accounts(), anns ) ) );
System.out.println( "*** script36: " + query );
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/indexing/TestData.java b/core/testsupport/src/main/java/org/apache/polygene/test/indexing/TestData.java
index bc275bb..40df6ba 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/indexing/TestData.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/indexing/TestData.java
@@ -59,7 +59,7 @@
NameableAssert.clear();
Domain gaming;
{
- EntityBuilder<Domain> domainBuilder = unitOfWork.newEntityBuilder( Domain.class, StringIdentity.fromString( "Gaming" ) );
+ EntityBuilder<Domain> domainBuilder = unitOfWork.newEntityBuilder( Domain.class, StringIdentity.identity( "Gaming" ) );
gaming = domainBuilder.instance();
gaming.name().set( "Gaming" );
gaming.description().set( "Gaming domain" );
@@ -121,7 +121,7 @@
Account annsAccount;
{
- EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, StringIdentity.fromString( "accountOfAnnDoe" ) );
+ EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, StringIdentity.identity( "accountOfAnnDoe" ) );
annsAccount = accountBuilder.instance();
annsAccount.number().set( "accountOfAnnDoe" );
annsAccount = accountBuilder.newInstance();
@@ -129,7 +129,7 @@
Account jacksAccount;
{
- EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, StringIdentity.fromString( "accountOfJackDoe" ) );
+ EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, StringIdentity.identity( "accountOfJackDoe" ) );
jacksAccount = accountBuilder.instance();
jacksAccount.number().set( "accountOfJackDoe" );
jacksAccount = accountBuilder.newInstance();
@@ -143,7 +143,7 @@
Female annDoe;
{
- EntityBuilder<Female> femaleBuilder = unitOfWork.newEntityBuilder( Female.class, StringIdentity.fromString( "anndoe" ) );
+ EntityBuilder<Female> femaleBuilder = unitOfWork.newEntityBuilder( Female.class, StringIdentity.identity( "anndoe" ) );
annDoe = femaleBuilder.instance();
annDoe.name().set( "Ann Doe" );
annDoe.title().set( Person.Title.MRS );
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/metrics/AbstractPolygeneMetricsTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/metrics/AbstractPolygeneMetricsTest.java
index 74c9e8c..f07a202 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/metrics/AbstractPolygeneMetricsTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/metrics/AbstractPolygeneMetricsTest.java
@@ -71,7 +71,7 @@
public interface PersonList
{
- Identity LIST_ID = StringIdentity.fromString( "person-list" );
+ Identity LIST_ID = StringIdentity.identity( "person-list" );
ManyAssociation<Person> all();
}
@@ -274,7 +274,7 @@
Commands commands = services.findService( Commands.class ).get();
Queries queries = services.findService( Queries.class ).get();
- Identity identity = StringIdentity.fromString( "1" );
+ Identity identity = StringIdentity.identity( "1" );
try (UnitOfWork uow = services.unitOfWorkFactory().newUnitOfWork( newUsecase( "Step 1" ) ) )
{
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java
index 3741fd2..ddea6d2 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java
@@ -253,7 +253,7 @@
// JSONEntityState does not allow for polymorphic serialization
public void valueAndEntityTypeEquality()
{
- Identity identity = StringIdentity.fromString( "42" );
+ Identity identity = StringIdentity.identity( "42" );
Some createdValue, loadedValue;
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "create" ) ) )
@@ -301,7 +301,7 @@
{
EntityBuilder<Some> builder = uow.newEntityBuilder( Some.class );
Some proto = builder.instance();
- proto.identity().set( StringIdentity.fromString( identity ) );
+ proto.identity().set( StringIdentity.identity( identity ) );
setSomeValueState( module, uow, proto );
return builder.newInstance();
}
@@ -313,7 +313,7 @@
{
ValueBuilder<Some> builder = module.newValueBuilder( Some.class );
Some proto = builder.prototype();
- proto.identity().set( StringIdentity.fromString( identity ) );
+ proto.identity().set( StringIdentity.identity( identity ) );
setSomeValueState( module, uow, proto );
return builder.newInstance();
}
@@ -322,7 +322,7 @@
{
ValueBuilder<SomeExtended> builder = module.newValueBuilder( SomeExtended.class );
SomeExtended proto = builder.prototype();
- proto.identity().set( StringIdentity.fromString( identity ) );
+ proto.identity().set( StringIdentity.identity( identity ) );
setSomeValueState( module, uow, proto );
proto.extraProperty().set( "extra property" );
proto.extraAssociation().set( buildBarEntity( module, uow, "extra association" ) );
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
index cde443c..2895d53 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
@@ -427,7 +427,7 @@
Identity newIdentity;
if( idGenerator == null )
{
- newIdentity = StringIdentity.fromString( UUID.randomUUID().toString() );
+ newIdentity = StringIdentity.identity( UUID.randomUUID().toString() );
}
else
{
diff --git a/extensions/entitystore-jdbm/src/test/java/org/apache/polygene/entitystore/jdbm/JdbmEntityStoreTestSuite.java b/extensions/entitystore-jdbm/src/test/java/org/apache/polygene/entitystore/jdbm/JdbmEntityStoreTestSuite.java
new file mode 100644
index 0000000..597bfe3
--- /dev/null
+++ b/extensions/entitystore-jdbm/src/test/java/org/apache/polygene/entitystore/jdbm/JdbmEntityStoreTestSuite.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.jdbm;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.jdbm.assembly.JdbmEntityStoreAssembler;
+import org.apache.polygene.library.fileconfig.FileConfigurationAssembler;
+import org.apache.polygene.library.fileconfig.FileConfigurationOverride;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+public class JdbmEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @Rule
+ public final TemporaryFolder tmpDir = new TemporaryFolder();
+ private ModuleAssembly configModule;
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new FileConfigurationAssembler()
+ .withOverride( new FileConfigurationOverride().withConventionalRoot( tmpDir.getRoot() ) )
+ .assemble( module );
+ new JdbmEntityStoreAssembler().visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+ }
+
+ @Override
+ protected void defineConfigModule( ModuleAssembly module )
+ {
+ configModule = module;
+ super.defineConfigModule( module );
+ }
+}
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java
index 36fe4ee..6a41cea 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java
@@ -36,7 +36,7 @@
public abstract class AbstractSQLEntityStoreAssembler<AssemblerType>
extends Assemblers.VisibilityIdentityConfig<AssemblerType>
{
- public static final Identity DEFAULT_ENTITYSTORE_IDENTITY = StringIdentity.fromString( "entitystore-sql" );
+ public static final Identity DEFAULT_ENTITYSTORE_IDENTITY = StringIdentity.identity( "entitystore-sql" );
private static final String DEFAULT_CHANGELOG_PATH = "org/apache/polygene/entitystore/sql/changelog.xml";
private String changelogPath = DEFAULT_CHANGELOG_PATH;
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RDFPerformanceTest.java b/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RDFPerformanceTest.java
index 96abf69..08e1db4 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RDFPerformanceTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RDFPerformanceTest.java
@@ -102,7 +102,7 @@
List<ExampleEntity> entities = new ArrayList<ExampleEntity>();
for (Integer x = 0; x < howMany; ++x)
{
- ExampleEntity exampleEntity = this.unitOfWorkFactory.currentUnitOfWork().newEntity( ExampleEntity.class, StringIdentity.fromString( "entity" + x ) );
+ ExampleEntity exampleEntity = this.unitOfWorkFactory.currentUnitOfWork().newEntity( ExampleEntity.class, StringIdentity.identity( "entity" + x ) );
for (ExampleEntity entity : entities)
{
@@ -188,7 +188,7 @@
UnitOfWork uow = this.unitOfWorkFactory.newUnitOfWork();
for (int i = 0; i < 1000; i++)
{
- ExampleEntity entity50 = uow.get(ExampleEntity.class, StringIdentity.fromString( "entity50" ) );
+ ExampleEntity entity50 = uow.get(ExampleEntity.class, StringIdentity.identity( "entity50" ) );
Query<ExampleEntity> query = uow.newQuery( this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class ).
where( QueryExpressions.contains( QueryExpressions.templateFor( ExampleEntity.class ).manyAssoc(), entity50) ));
System.out.println(query.count());
diff --git a/extensions/indexing-sql/src/main/java/org/apache/polygene/index/sql/assembly/AbstractSQLIndexQueryAssembler.java b/extensions/indexing-sql/src/main/java/org/apache/polygene/index/sql/assembly/AbstractSQLIndexQueryAssembler.java
index d3675a3..86790c9 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/polygene/index/sql/assembly/AbstractSQLIndexQueryAssembler.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/polygene/index/sql/assembly/AbstractSQLIndexQueryAssembler.java
@@ -35,7 +35,7 @@
public abstract class AbstractSQLIndexQueryAssembler<AssemblerType> extends Assemblers.VisibilityIdentityConfig<AssemblerType>
{
- public static final Identity DEFAULT_IDENTITY = StringIdentity.fromString( "indexing-sql" );
+ public static final Identity DEFAULT_IDENTITY = StringIdentity.identity( "indexing-sql" );
private Class<? extends ReindexingStrategy> reindexingStrategy = ReindexingStrategy.NeverNeed.class;
diff --git a/libraries/alarm/src/main/java/org/apache/polygene/library/alarm/AlarmSystem.java b/libraries/alarm/src/main/java/org/apache/polygene/library/alarm/AlarmSystem.java
index b275943..1b42452 100644
--- a/libraries/alarm/src/main/java/org/apache/polygene/library/alarm/AlarmSystem.java
+++ b/libraries/alarm/src/main/java/org/apache/polygene/library/alarm/AlarmSystem.java
@@ -214,7 +214,7 @@
public AlarmPoint createAlarm( String name, AlarmCategory category )
{
UnitOfWork uow = uowf.currentUnitOfWork();
- EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class, StringIdentity.fromString( name ) );
+ EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class, StringIdentity.identity( name ) );
builder.instance().category().set( category );
AlarmPoint.AlarmState state = builder.instanceFor( AlarmPoint.AlarmState.class );
state.systemName().set( name );
diff --git a/libraries/alarm/src/test/java/org/apache/polygene/library/alarm/AlarmProxyTest.java b/libraries/alarm/src/test/java/org/apache/polygene/library/alarm/AlarmProxyTest.java
index 30e9c35..5ec2236 100644
--- a/libraries/alarm/src/test/java/org/apache/polygene/library/alarm/AlarmProxyTest.java
+++ b/libraries/alarm/src/test/java/org/apache/polygene/library/alarm/AlarmProxyTest.java
@@ -60,7 +60,7 @@
try
{
// START SNIPPET: documentation
- myAlarmPoint = factory.create( StringIdentity.fromString( "This Alarm Identity" ), "ProActiveCRM", "Sales", AlarmClass.B );
+ myAlarmPoint = factory.create( StringIdentity.identity( "This Alarm Identity" ), "ProActiveCRM", "Sales", AlarmClass.B );
myAlarmPoint.history().maxSize().set( 20 );
// END SNIPPET: documentation
@@ -71,7 +71,7 @@
assertThat( myAlarmPoint.history().activateCounter(), equalTo( 1 ) );
AlarmEvent event = myAlarmPoint.history().firstEvent();
assertThat( event, notNullValue() );
- assertThat( event.identity().get(), equalTo( StringIdentity.fromString( "This Alarm Identity" ) ) );
+ assertThat( event.identity().get(), equalTo( StringIdentity.identity( "This Alarm Identity" ) ) );
assertThat( event.newStatus().get().name( null ), equalTo( "Activated" ) );
assertThat( event.oldStatus().get().name( null ), equalTo( "Normal" ) );
}
diff --git a/libraries/jmx/src/main/java/org/apache/polygene/library/jmx/ConfigurationManagerService.java b/libraries/jmx/src/main/java/org/apache/polygene/library/jmx/ConfigurationManagerService.java
index a8ce3bf..91025f0 100644
--- a/libraries/jmx/src/main/java/org/apache/polygene/library/jmx/ConfigurationManagerService.java
+++ b/libraries/jmx/src/main/java/org/apache/polygene/library/jmx/ConfigurationManagerService.java
@@ -243,7 +243,7 @@
EditableConfiguration( MBeanInfo info, String identity, Map<String, AccessibleObject> propertyNames )
{
this.info = info;
- this.identity = StringIdentity.fromString(identity);
+ this.identity = StringIdentity.identity( identity );
this.propertyNames = propertyNames;
}
diff --git a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java
index 59528e2..a48e272 100644
--- a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java
+++ b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java
@@ -109,14 +109,14 @@
valueBuilder.prototype().test3().set( valueBuilder2.newInstance() );
TestValue testValue = valueBuilder.newInstance();
- EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "test1" ) );
+ EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identity( "test1" ) );
TestEntity rickardTemplate = builder.instance();
rickardTemplate.name().set( "Rickard" );
rickardTemplate.title().set( "Mr" );
rickardTemplate.value().set( testValue );
TestEntity testEntity = builder.newInstance();
- EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "test2" ) );
+ EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identity( "test2" ) );
TestEntity niclasTemplate = builder2.instance();
niclasTemplate.name().set( "Niclas" );
niclasTemplate.title().set( "Mr" );
diff --git a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java
index e4a7efe..ae4c56e 100644
--- a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java
+++ b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java
@@ -95,14 +95,14 @@
valueBuilder.prototype().test3().set( vb2.newInstance() );
TestValue testValue = valueBuilder.newInstance();
- EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder(TestEntity.class, StringIdentity.fromString( "test1") );
+ EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder(TestEntity.class, StringIdentity.identity( "test1" ) );
TestEntity rickardTemplate = builder.instance();
rickardTemplate.name().set( "Rickard" );
rickardTemplate.title().set( "Mr" );
rickardTemplate.value().set( testValue );
TestEntity testEntity = builder.newInstance();
- EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder(TestEntity.class, StringIdentity.fromString( "test2") );
+ EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder(TestEntity.class, StringIdentity.identity( "test2" ) );
TestEntity niclasTemplate = builder2.instance();
niclasTemplate.name().set( "Niclas" );
niclasTemplate.title().set( "Mr" );
diff --git a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/RequestReaderDelegator.java b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/RequestReaderDelegator.java
index 7bfc77b..50db549 100644
--- a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/RequestReaderDelegator.java
+++ b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/RequestReaderDelegator.java
@@ -51,7 +51,7 @@
public void init( @Service Iterable<ServiceReference<RequestReader>> requestReaderReferences )
{
Logger logger = LoggerFactory.getLogger( getClass() );
- Identity requestreaderdelegator = StringIdentity.fromString("requestreaderdelegator");
+ Identity requestreaderdelegator = StringIdentity.identity( "requestreaderdelegator" );
// Add custom readers first
for( ServiceReference<RequestReader> requestReader : requestReaderReferences )
diff --git a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ResponseWriterDelegator.java b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ResponseWriterDelegator.java
index 14279c8..5809f66 100644
--- a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ResponseWriterDelegator.java
+++ b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ResponseWriterDelegator.java
@@ -48,7 +48,7 @@
public void init( @Service Iterable<ServiceReference<ResponseWriter>> resultWriters )
{
Logger logger = LoggerFactory.getLogger( getClass() );
- Identity responsewriterdelegator = StringIdentity.fromString( "responsewriterdelegator" );
+ Identity responsewriterdelegator = StringIdentity.identity( "responsewriterdelegator" );
// Add custom writers first
for( ServiceReference<ResponseWriter> resultWriter : resultWriters )
diff --git a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/requestreader/DefaultRequestReader.java b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/requestreader/DefaultRequestReader.java
index 8ed1666..65b31af 100644
--- a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/requestreader/DefaultRequestReader.java
+++ b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/requestreader/DefaultRequestReader.java
@@ -251,7 +251,7 @@
entityAsForm = new Form();
}
- Identity entityIdentity = StringIdentity.fromString( getValue( "entity", queryAsForm, entityAsForm ) );
+ Identity entityIdentity = StringIdentity.identity( getValue( "entity", queryAsForm, entityAsForm ) );
args[0] = uowf.currentUnitOfWork().get( method.getParameterTypes()[0], entityIdentity );
return args;
@@ -480,7 +480,7 @@
}
else if( parameterType.isInterface() )
{
- arg = uowf.currentUnitOfWork().get( parameterType, StringIdentity.fromString( argString ) );
+ arg = uowf.currentUnitOfWork().get( parameterType, StringIdentity.identity( argString ) );
}
else
{
diff --git a/libraries/rest/src/main/java/org/apache/polygene/library/rest/admin/EntityResource.java b/libraries/rest/src/main/java/org/apache/polygene/library/rest/admin/EntityResource.java
index 5401a54..a81e682 100644
--- a/libraries/rest/src/main/java/org/apache/polygene/library/rest/admin/EntityResource.java
+++ b/libraries/rest/src/main/java/org/apache/polygene/library/rest/admin/EntityResource.java
@@ -106,7 +106,7 @@
{
// /entity/{reference}
Map<String, Object> attributes = getRequest().getAttributes();
- identity = StringIdentity.fromString( (String) attributes.get( "reference" ) );
+ identity = StringIdentity.identity( (String) attributes.get( "reference" ) );
}
@Override
diff --git a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/DummyDataService.java b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/DummyDataService.java
index 14387d1..56004c4 100644
--- a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/DummyDataService.java
+++ b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/DummyDataService.java
@@ -77,13 +77,13 @@
valueBuilder.prototype().string().set( "Foo bar value" );
valueBuilder.prototype().map().set( new HashMap() );
- EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "test1" ) );
+ EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identity( "test1" ) );
builder.instance().name().set( "Foo bar" );
builder.instance().age().set( 42 );
builder.instance().value().set( valueBuilder.newInstance() );
TestEntity testEntity = builder.newInstance();
- EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "test2" ) );
+ EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identity( "test2" ) );
builder2.instance().name().set( "Xyzzy" );
builder2.instance().age().set( 12 );
builder2.instance().association().set( testEntity );
@@ -98,7 +98,7 @@
}
{
- EntityBuilder<TestEntity2> builder = unitOfWork.newEntityBuilder( TestEntity2.class, StringIdentity.fromString( "test3" ) );
+ EntityBuilder<TestEntity2> builder = unitOfWork.newEntityBuilder( TestEntity2.class, StringIdentity.identity( "test3" ) );
builder.instance().name().set( "Test3" );
builder.newInstance();
}
diff --git a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java
index 0364d18..206c0ef 100644
--- a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java
+++ b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java
@@ -111,13 +111,13 @@
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
try
{
- EntityBuilder<PersonEntity> builder1 = uow.newEntityBuilder( PersonEntity.class, StringIdentity.fromString( "P2" ) );
+ EntityBuilder<PersonEntity> builder1 = uow.newEntityBuilder( PersonEntity.class, StringIdentity.identity( "P2" ) );
PersonEntity maryDoe = builder1.instance();
maryDoe.firstname().set( "Mary" );
maryDoe.lastname().set( "Doe" );
maryDoe = builder1.newInstance();
- EntityBuilder<PersonEntity> builder2 = uow.newEntityBuilder( PersonEntity.class, StringIdentity.fromString( "P1" ) );
+ EntityBuilder<PersonEntity> builder2 = uow.newEntityBuilder( PersonEntity.class, StringIdentity.identity( "P1" ) );
PersonEntity joeDoe = builder2.instance();
joeDoe.firstname().set( "Joe" );
joeDoe.lastname().set( "Doe" );
@@ -162,7 +162,7 @@
UnitOfWork work = unitOfWorkFactory.newUnitOfWork();
try
{
- PersonEntity entity = work.get( PersonEntity.class, StringIdentity.fromString( "P1" ) );
+ PersonEntity entity = work.get( PersonEntity.class, StringIdentity.identity( "P1" ) );
assertEquals( "FirstName not changed.", "Jack", entity.firstname().get() );
assertEquals( "LastName not changed.", "Doe", entity.lastname().get() );
work.complete();
@@ -185,7 +185,7 @@
PersonEntity entity = null;
try
{
- entity = work.get( PersonEntity.class, StringIdentity.fromString( "P1" ) );
+ entity = work.get( PersonEntity.class, StringIdentity.identity( "P1" ) );
}
catch( NoSuchEntityException expected )
{
diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/EntityResource.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/EntityResource.java
index 8ed6fb1..c822892 100644
--- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/EntityResource.java
+++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/EntityResource.java
@@ -97,7 +97,7 @@
{
Class entityType = parameters.entityType().get();
String idOfEntity = parameters.id().get();
- locator.find( entityType ).delete( StringIdentity.fromString( idOfEntity ) );
+ locator.find( entityType ).delete( StringIdentity.identity( idOfEntity ) );
}
@Override
@@ -137,7 +137,7 @@
throw new RuntimeException( message, e );
}
Reference base = parameters.request().get().getResourceRef();
- return resourceBuilder.createRestLink( StringIdentity.fromString( "" ), base, org.restlet.data.Method.GET );
+ return resourceBuilder.createRestLink( StringIdentity.identity( "" ), base, org.restlet.data.Method.GET );
}
private Object createParametersComposite( RestForm form, Class argType )
diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/identity/IdentityManager.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/identity/IdentityManager.java
index b41df0c..ec2a6c0 100644
--- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/identity/IdentityManager.java
+++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/identity/IdentityManager.java
@@ -80,10 +80,10 @@
if( isIdentity( canonicalName ) )
{
// This is already an ID, and we simply return it.
- return StringIdentity.fromString( canonicalName );
+ return StringIdentity.identity( canonicalName );
}
String prefix = findPrefix( type );
- return StringIdentity.fromString( prefix + SEPARATOR + canonicalName );
+ return StringIdentity.identity( prefix + SEPARATOR + canonicalName );
}
@Override
diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/EntryPointResource.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/EntryPointResource.java
index 274ea9e..2204980 100644
--- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/EntryPointResource.java
+++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/EntryPointResource.java
@@ -80,18 +80,18 @@
RestLink link;
if( route.getDescription() == null )
{
- link = resourceBuilder.createRestLink( StringIdentity.fromString( template.getPattern() ), hostRef, Method.GET );
+ link = resourceBuilder.createRestLink( StringIdentity.identity( template.getPattern() ), hostRef, Method.GET );
}
else
{
- link = resourceBuilder.createRestLink( StringIdentity.fromString( template.getPattern() ), hostRef, Method.GET, route.getDescription() );
+ link = resourceBuilder.createRestLink( StringIdentity.identity( template.getPattern() ), hostRef, Method.GET, route.getDescription() );
}
entryPoints.put( route.getName(), link );
}
}
}
ValueBuilder<EntryPoint> builder = vbf.newValueBuilder( EntryPoint.class );
- builder.prototype().identity().set( StringIdentity.fromString( "/" ) );
+ builder.prototype().identity().set( StringIdentity.identity( "/" ) );
builder.prototype().api().set( entryPoints );
return builder.newInstance();
}
diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/ResourceBuilder.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/ResourceBuilder.java
index eb46bac..b59aac8 100644
--- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/ResourceBuilder.java
+++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/ResourceBuilder.java
@@ -143,7 +143,7 @@
public RestForm createNameForm( Reference base )
{
ValueBuilder<RestForm> builder = vbf.newValueBuilder( RestForm.class );
- builder.prototype().link().set( createRestLink( StringIdentity.fromString( "form" ), base, Method.POST ) );
+ builder.prototype().link().set( createRestLink( StringIdentity.identity( "form" ), base, Method.POST ) );
builder.prototype().fields().set( Collections.singletonList( createFormField( "name", FormField.TEXT ) ) );
return builder.newInstance();
}
diff --git a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java
index 31cb4bc..e3d8e73 100644
--- a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java
+++ b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java
@@ -70,7 +70,7 @@
{
module.importedServices( DataSource.class ).
importedBy( ServiceInstanceImporter.class ).
- setMetaInfo( StringIdentity.fromString( dataSourceServiceId ) ).
+ setMetaInfo( StringIdentity.identity( dataSourceServiceId ) ).
identifiedBy( identity() ).
visibleIn( visibility() );
if( circuitBreaker != null )
diff --git a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java
index ef6b93d..78cf765 100644
--- a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java
+++ b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java
@@ -65,7 +65,7 @@
{
if( circuitBreaker != null )
{
- externalDataSource = DataSources.wrapWithCircuitBreaker( StringIdentity.fromString(identity()), externalDataSource, circuitBreaker );
+ externalDataSource = DataSources.wrapWithCircuitBreaker( StringIdentity.identity( identity() ), externalDataSource, circuitBreaker );
}
module.importedServices( DataSource.class ).
identifiedBy( identity() ).
diff --git a/libraries/sql/src/main/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerService.java b/libraries/sql/src/main/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerService.java
index e008589..ec49c23 100644
--- a/libraries/sql/src/main/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerService.java
+++ b/libraries/sql/src/main/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerService.java
@@ -175,7 +175,7 @@
EditableConfiguration( MBeanInfo info, String identity, Map<String, AccessibleObject> propertyNames )
{
this.info = info;
- this.identity = StringIdentity.fromString( identity );
+ this.identity = StringIdentity.identity( identity );
this.propertyNames = propertyNames;
}
diff --git a/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext.java b/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext.java
index 5e7043f..9bd5878 100644
--- a/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext.java
+++ b/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext.java
@@ -133,8 +133,8 @@
{
// Creditor retrieval could be a use case in itself...
List<BalanceData> creditors = new ArrayList<BalanceData>();
- creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.fromString( "BakerAccount" ) ) );
- creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.fromString( "ButcherAccount" ) ) );
+ creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.identity( "BakerAccount" ) ) );
+ creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.identity( "ButcherAccount" ) ) );
return creditors;
}
diff --git a/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext2.java b/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext2.java
index 9a4fe3e..ba5a40d 100644
--- a/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext2.java
+++ b/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext2.java
@@ -126,8 +126,8 @@
{
// Creditor retrieval could be a use case in itself...
List<BalanceData> creditors = new ArrayList<>();
- creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.fromString( "BakerAccount" ) ) );
- creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.fromString( "ButcherAccount" ) ) );
+ creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.identity( "BakerAccount" ) ) );
+ creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.identity( "ButcherAccount" ) ) );
return creditors;
}
diff --git a/samples/dci/src/test/java/org/apache/polygene/dci/moneytransfer/test/AccountIds.java b/samples/dci/src/test/java/org/apache/polygene/dci/moneytransfer/test/AccountIds.java
index 1e69a86..4456660 100644
--- a/samples/dci/src/test/java/org/apache/polygene/dci/moneytransfer/test/AccountIds.java
+++ b/samples/dci/src/test/java/org/apache/polygene/dci/moneytransfer/test/AccountIds.java
@@ -24,9 +24,9 @@
public interface AccountIds
{
- Identity SAVINGS_ACCOUNT_ID = StringIdentity.fromString( "SavingsAccountId" );
- Identity CHECKING_ACCOUNT_ID = StringIdentity.fromString( "CheckingAccountId" );
- Identity CREDITOR_ID1 = StringIdentity.fromString( "BakerAccount" );
- Identity CREDITOR_ID2 = StringIdentity.fromString( "ButcherAccount" );
+ Identity SAVINGS_ACCOUNT_ID = StringIdentity.identity( "SavingsAccountId" );
+ Identity CHECKING_ACCOUNT_ID = StringIdentity.identity( "CheckingAccountId" );
+ Identity CREDITOR_ID1 = StringIdentity.identity( "BakerAccount" );
+ Identity CREDITOR_ID2 = StringIdentity.identity( "ButcherAccount" );
}
diff --git a/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Forums.java b/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Forums.java
index 5650376..cc70100 100644
--- a/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Forums.java
+++ b/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Forums.java
@@ -38,7 +38,7 @@
public interface Forums
extends Administrators, EntityComposite
{
- Identity FORUMS_ID = StringIdentity.fromString( "forums" );
+ Identity FORUMS_ID = StringIdentity.identity( "forums" );
Query<Forum> forums();
diff --git a/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Users.java b/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Users.java
index 42f0205..aa16c40 100644
--- a/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Users.java
+++ b/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Users.java
@@ -41,7 +41,7 @@
public interface Users
extends EntityComposite, Events
{
- Identity USERS_ID = StringIdentity.fromString( "users" );
+ Identity USERS_ID = StringIdentity.identity( "users" );
Query<User> users();
diff --git a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/BoardResource.java b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/BoardResource.java
index 7dd3e52..f748192 100644
--- a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/BoardResource.java
+++ b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/BoardResource.java
@@ -37,7 +37,7 @@
public void resource( String segment )
throws ResourceException
{
- selectFromManyAssociation( ObjectSelection.current().get( Forum.class ).boards(), StringIdentity.fromString( segment ) );
+ selectFromManyAssociation( ObjectSelection.current().get( Forum.class ).boards(), StringIdentity.identity( segment ) );
subResource( BoardResource.class );
}
}
diff --git a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumResource.java b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumResource.java
index a5c5977..abf7c18 100644
--- a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumResource.java
+++ b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumResource.java
@@ -37,7 +37,7 @@
public void resource( String segment )
throws ResourceException
{
- selectFromManyAssociation( ObjectSelection.current().get( Forum.class ).boards(), StringIdentity.fromString( segment ) );
+ selectFromManyAssociation( ObjectSelection.current().get( Forum.class ).boards(), StringIdentity.identity( segment ) );
subResource( BoardResource.class );
}
}
diff --git a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumsResource.java b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumsResource.java
index 931e5a2..5c14ec2 100644
--- a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumsResource.java
+++ b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumsResource.java
@@ -36,7 +36,7 @@
public void resource( String segment )
throws ResourceException
{
- select( Forum.class, StringIdentity.fromString( segment ) );
+ select( Forum.class, StringIdentity.identity( segment ) );
subResource( ForumResource.class );
}
}
diff --git a/samples/rental/src/main/java/org/apache/polygene/sample/rental/domain/dev/InitialData.java b/samples/rental/src/main/java/org/apache/polygene/sample/rental/domain/dev/InitialData.java
index 1db4d19..0ac3450 100644
--- a/samples/rental/src/main/java/org/apache/polygene/sample/rental/domain/dev/InitialData.java
+++ b/samples/rental/src/main/java/org/apache/polygene/sample/rental/domain/dev/InitialData.java
@@ -198,7 +198,7 @@
private RentalShop createShop( UnitOfWork uow )
throws UnitOfWorkCompletionException
{
- return uow.newEntity( RentalShop.class, StringIdentity.fromString( "SHOP" ) );
+ return uow.newEntity( RentalShop.class, StringIdentity.identity( "SHOP" ) );
}
private void createCustomers( RentalShop shop )
diff --git a/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/BookingPage.java b/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/BookingPage.java
index 78815b8..4c39f73 100644
--- a/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/BookingPage.java
+++ b/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/BookingPage.java
@@ -52,7 +52,7 @@
Element result = dom.createElementNS( Page.XHTML, "div" );
String bookingId = context.path();
UnitOfWork uow = uowf.currentUnitOfWork();
- Booking booking = uow.get( Booking.class, StringIdentity.fromString( bookingId ) );
+ Booking booking = uow.get( Booking.class, StringIdentity.identity( bookingId ) );
Car car = booking.car().get();
createChildNode( dom, result, car.model().get() );
createChildNode( dom, result, car.licensePlate().get() );
@@ -73,7 +73,7 @@
Element result = dom.createElementNS( Page.XHTML, "div" );
String bookingId = context.path();
UnitOfWork uow = uowf.currentUnitOfWork();
- Booking booking = uow.get( Booking.class, StringIdentity.fromString( bookingId ) );
+ Booking booking = uow.get( Booking.class, StringIdentity.identity( bookingId ) );
Customer customer = booking.customer().get();
createChildNode( dom, result, customer.name().get() );
createChildNode( dom, result, customer.address().get().line1().get() );
diff --git a/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/MainPage.java b/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/MainPage.java
index ebe24e6..328c41b 100644
--- a/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/MainPage.java
+++ b/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/MainPage.java
@@ -59,7 +59,7 @@
ArrayList<Node> nodes = new ArrayList<Node>();
Document dom = context.dom();
UnitOfWork uow = uowf.currentUnitOfWork();
- RentalShop shop = uow.get( RentalShop.class, StringIdentity.fromString( "SHOP" ) );
+ RentalShop shop = uow.get( RentalShop.class, StringIdentity.identity( "SHOP" ) );
for( Booking booking : shop.findAllBookings() )
{
String plate = booking.car().get().licensePlate().get();
diff --git a/tests/performance/src/main/java/org/apache/polygene/test/performance/entitystore/AbstractEntityStorePerformanceTest.java b/tests/performance/src/main/java/org/apache/polygene/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
index fcb9524..61de7ed 100644
--- a/tests/performance/src/main/java/org/apache/polygene/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
+++ b/tests/performance/src/main/java/org/apache/polygene/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
@@ -243,7 +243,7 @@
UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "readEntityWithComplexType PREPARE " + bulk ) );
for( int i = 0; i < ITERATIONS; i++ )
{
- ComplexProduct product = uow.newEntity( ComplexProduct.class, StringIdentity.fromString( "product" + i ) );
+ ComplexProduct product = uow.newEntity( ComplexProduct.class, StringIdentity.identity( "product" + i ) );
product.name().set( "Product " + i );
if( i % 1000 == 0 )
@@ -265,7 +265,7 @@
String id = rnd.nextInt( ITERATIONS ) + "";
for( int i = 0; i < ITERATIONS; i++ )
{
- ComplexProduct product = uow.get( ComplexProduct.class, StringIdentity.fromString( "product" + id ) );
+ ComplexProduct product = uow.get( ComplexProduct.class, StringIdentity.identity( "product" + id ) );
product.name().get();
if( i % 100 == 0 )
{
diff --git a/tools/envisage/src/test/java/org/apache/polygene/envisage/school/domain/person/initialdata/SamplePersonInitialData.java b/tools/envisage/src/test/java/org/apache/polygene/envisage/school/domain/person/initialdata/SamplePersonInitialData.java
index c150d2e..626415e 100644
--- a/tools/envisage/src/test/java/org/apache/polygene/envisage/school/domain/person/initialdata/SamplePersonInitialData.java
+++ b/tools/envisage/src/test/java/org/apache/polygene/envisage/school/domain/person/initialdata/SamplePersonInitialData.java
@@ -94,7 +94,7 @@
private void createPerson( UnitOfWork uow, String personId, String firstName, String lastName )
{
- EntityBuilder<Person> person = uow.newEntityBuilder( Person.class, StringIdentity.fromString( personId ) );
+ EntityBuilder<Person> person = uow.newEntityBuilder( Person.class, StringIdentity.identity( personId ) );
PersonEntity.PersonState state = person.instanceFor( PersonEntity.PersonState.class );
state.firstName().set( firstName );
diff --git a/tutorials/hello/src/test/java/org/apache/polygene/tutorials/hello/HelloTest4.java b/tutorials/hello/src/test/java/org/apache/polygene/tutorials/hello/HelloTest4.java
index 1608c96..dd103d8 100644
--- a/tutorials/hello/src/test/java/org/apache/polygene/tutorials/hello/HelloTest4.java
+++ b/tutorials/hello/src/test/java/org/apache/polygene/tutorials/hello/HelloTest4.java
@@ -35,7 +35,7 @@
public class HelloTest4 extends AbstractPolygeneTest
{
- public static final Identity TEST_IDENTITY = StringIdentity.fromString( "123" );
+ public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
@Override
public void assemble( ModuleAssembly module )