Created
May 15, 2012 21:28
-
-
Save tbml/2705290 to your computer and use it in GitHub Desktop.
Patch to upgrade qi4j dci-cargo sample_a from 1.4.1 -> 2.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/infrastructure/conversion/EntityToDTOService.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/infrastructure/conversion/EntityToDTOService.java (revision 63141ff27bf64d0acd5b2bbd7dca7f0e17baaf33) | |
+++ samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/infrastructure/conversion/EntityToDTOService.java (revision ) | |
@@ -1,33 +1,30 @@ | |
package com.marcgrue.dcisample_a.infrastructure.conversion; | |
-import org.qi4j.api.common.QualifiedName; | |
-import org.qi4j.api.composite.NoSuchCompositeException; | |
+import org.qi4j.api.association.AssociationDescriptor; | |
+import org.qi4j.api.association.AssociationStateHolder; | |
+import org.qi4j.api.association.ManyAssociation; | |
import org.qi4j.api.entity.EntityComposite; | |
+import org.qi4j.api.entity.EntityDescriptor; | |
import org.qi4j.api.entity.EntityReference; | |
-import org.qi4j.api.entity.association.Association; | |
+import org.qi4j.api.entity.Identity; | |
import org.qi4j.api.injection.scope.Structure; | |
import org.qi4j.api.mixin.Mixins; | |
-import org.qi4j.api.property.ComputedPropertyInstance; | |
-import org.qi4j.api.property.Property; | |
-import org.qi4j.api.property.StateHolder; | |
+import org.qi4j.api.property.PropertyDescriptor; | |
import org.qi4j.api.service.ServiceComposite; | |
+import org.qi4j.api.structure.Module; | |
+import org.qi4j.api.type.CollectionType; | |
+import org.qi4j.api.value.NoSuchValueException; | |
import org.qi4j.api.value.ValueBuilder; | |
import org.qi4j.api.value.ValueBuilderFactory; | |
-import org.qi4j.library.values.PropertyNotPresentException; | |
-import org.qi4j.library.values.Unqualified; | |
+import org.qi4j.api.value.ValueDescriptor; | |
+import org.qi4j.functional.Function; | |
+import org.qi4j.functional.Iterables; | |
+import org.qi4j.library.conversion.values.Unqualified; | |
import org.qi4j.spi.Qi4jSPI; | |
-import org.qi4j.spi.entity.EntityDescriptor; | |
-import org.qi4j.spi.entity.EntityState; | |
-import org.qi4j.spi.entity.association.AssociationDescriptor; | |
-import org.qi4j.spi.property.PropertyDescriptor; | |
-import org.qi4j.spi.structure.ModuleSPI; | |
-import org.qi4j.spi.value.ValueDescriptor; | |
-import java.lang.reflect.InvocationTargetException; | |
-import java.lang.reflect.Method; | |
-import java.lang.reflect.UndeclaredThrowableException; | |
import java.util.ArrayList; | |
-import java.util.Set; | |
+import java.util.Collections; | |
+import java.util.List; | |
/** | |
* Conversion of Entity objects to DTO's | |
@@ -53,176 +50,278 @@ | |
private Qi4jSPI spi; | |
@Structure | |
- private ModuleSPI module; | |
+ private Module module; | |
public <T> T convert( final Class<T> valueType, Object entity ) | |
{ | |
- | |
ValueDescriptor valueDescriptor = module.valueDescriptor( valueType.getName() ); | |
- if (valueDescriptor == null) | |
+ if( valueDescriptor == null ) | |
{ | |
- throw new NoSuchCompositeException( valueType.getName(), module.name() ); | |
+ throw new NoSuchValueException( valueType.getName(), module.name() ); | |
} | |
Unqualified unqualified = valueDescriptor.metaInfo( Unqualified.class ); | |
- Set<PropertyDescriptor> properties = valueDescriptor.state().properties(); | |
+ Iterable<? extends PropertyDescriptor> properties = valueDescriptor.state().properties(); | |
final EntityComposite composite = (EntityComposite) entity; | |
final EntityDescriptor entityDescriptor = spi.getEntityDescriptor( composite ); | |
- final EntityState entityState = spi.getEntityState( composite ); | |
- ValueBuilder builder = vbf.newValueBuilder( valueType ); | |
+ final AssociationStateHolder associationState = spi.getState( composite ); | |
+ ValueBuilder builder; | |
- if (unqualified == null || !unqualified.value()) | |
+ if( unqualified == null || !unqualified.value() ) | |
{ | |
- builder.withState( new StateHolder() | |
+ // Copy state using qualified names | |
+ builder = vbf.newValueBuilderWithState( valueType, new Function<PropertyDescriptor, Object>() | |
- { | |
+ { | |
- public <T> Property<T> getProperty( Method propertyMethod ) | |
+ @Override | |
+ public Object map( PropertyDescriptor descriptor ) | |
- { | |
- try | |
- { | |
+ { | |
+ try | |
+ { | |
- return (Property<T>) propertyMethod.invoke( composite ); | |
+ return associationState.propertyFor( descriptor.accessor() ) | |
+ .get(); | |
- } | |
+ } | |
- catch (IllegalAccessException e) | |
+ catch( IllegalArgumentException e ) | |
- { | |
+ { | |
- String message = propertyMethod + " is not present in " + entityDescriptor.type(); | |
- throw new PropertyNotPresentException( message, | |
- valueType, | |
- (Class<? extends EntityComposite>) composite.type() ); | |
+ if( descriptor.valueType() | |
+ .mainType() | |
+ .equals( String.class ) ) | |
+ { | |
+ // Find Association and convert to string | |
+ AssociationDescriptor associationDescriptor = null; | |
+ try | |
+ { | |
+ associationDescriptor = entityDescriptor.state() | |
+ .getAssociationByName( descriptor.qualifiedName() | |
+ .name() ); | |
- } | |
+ } | |
- catch (InvocationTargetException e) | |
+ catch( IllegalArgumentException e1 ) | |
- { | |
+ { | |
- String message = "Exception in property method. Internal Error? [" + propertyMethod + " / " + | |
- entityDescriptor.type(); | |
- throw new UndeclaredThrowableException( e.getTargetException(), message ); | |
+ return null; | |
- } | |
+ } | |
+ Object entity = associationState.associationFor( associationDescriptor | |
+ .accessor() ) | |
+ .get(); | |
+ if( entity != null ) | |
+ { | |
+ return ( (Identity) entity ).identity() | |
+ .get(); | |
- } | |
+ } | |
- | |
- public <T> Property<T> getProperty( final QualifiedName name ) | |
+ else | |
- { | |
+ { | |
- PropertyDescriptor info = entityDescriptor.state().getPropertyByQualifiedName( name ); | |
- return new ComputedPropertyInstance<T>( info ) | |
+ return null; | |
+ } | |
+ } | |
+ else if( descriptor.valueType() instanceof CollectionType && ( (CollectionType) descriptor | |
+ .valueType() ).collectedType() | |
+ .mainType() | |
+ .equals( String.class ) ) | |
- { | |
+ { | |
- @Override | |
- public T get() | |
+ AssociationDescriptor associationDescriptor = null; | |
+ try | |
- { | |
+ { | |
- return (T) entityState.getProperty( name ); | |
+ associationDescriptor = entityDescriptor.state() | |
+ .getManyAssociationByName( descriptor.qualifiedName() | |
+ .name() ); | |
- } | |
+ } | |
- }; | |
+ catch( IllegalArgumentException e1 ) | |
+ { | |
+ return Collections.emptyList(); | |
- } | |
+ } | |
- public <ThrowableType extends Throwable> void visitProperties( StateVisitor<ThrowableType> visitor ) | |
- throws ThrowableType | |
+ ManyAssociation state = associationState.manyAssociationFor( associationDescriptor | |
+ .accessor() ); | |
+ List<String> entities = new ArrayList<String>(); | |
+ for( Object entity : state ) | |
- { | |
+ { | |
- for (PropertyDescriptor descriptor : entityDescriptor.state().properties()) | |
- { | |
- QualifiedName name = descriptor.qualifiedName(); | |
- Object value = entityState.getProperty( name ); | |
- visitor.visitProperty( name, value ); | |
+ entities.add( ( (Identity) entity ).identity() | |
+ .get() ); | |
- } | |
+ } | |
+ return entities; | |
- } | |
+ } | |
- } ); | |
+ | |
+ return null; | |
- } | |
+ } | |
- else | |
+ } | |
+ }, new Function<AssociationDescriptor, EntityReference>() | |
- { | |
+ { | |
- for (PropertyDescriptor descriptor : entityDescriptor.state().properties()) | |
+ @Override | |
+ public EntityReference map( AssociationDescriptor associationDescriptor ) | |
- { | |
+ { | |
- QualifiedName name = descriptor.qualifiedName(); | |
- Object value = entityState.getProperty( name ); | |
- setUnqualifiedProperty( builder, properties, name, value ); | |
+ return EntityReference.getEntityReference( associationState | |
+ .associationFor( associationDescriptor | |
+ .accessor() ) | |
+ .get() ); | |
- } | |
+ } | |
+ }, new Function<AssociationDescriptor, Iterable<EntityReference>>() | |
+ { | |
+ @Override | |
+ public Iterable<EntityReference> map( AssociationDescriptor associationDescriptor ) | |
+ { | |
+ List<EntityReference> refs = new ArrayList<EntityReference>(); | |
+ for( Object entity : associationState.manyAssociationFor( associationDescriptor.accessor() ) ) | |
+ { | |
+ refs.add( EntityReference.getEntityReference( entity ) ); | |
- } | |
+ } | |
- for (AssociationDescriptor descriptor : entityDescriptor.state().associations()) | |
+ return refs; | |
+ } | |
+ } | |
+ ); | |
+ } | |
+ else | |
{ | |
- QualifiedName name = descriptor.qualifiedName(); | |
- | |
- Object propertyValue = null; | |
- | |
- PropertyDescriptor propertyDescriptor = findProperty( properties, name.name() ); | |
- Class<?> dtoClass = propertyDescriptor.accessor().getDeclaringClass(); | |
- Class propertyDtoClass = (Class) propertyDescriptor.type(); | |
- | |
- if (DTO.class.isAssignableFrom( propertyDtoClass )) | |
+ builder = vbf.newValueBuilderWithState( valueType, new Function<PropertyDescriptor, Object>() | |
- { | |
+ { | |
- Method associationMethod = descriptor.accessor(); | |
- Association<?> association; | |
+ @Override | |
+ public Object map( PropertyDescriptor descriptor ) | |
+ { | |
- try | |
- { | |
+ try | |
+ { | |
- association = (Association<?>) associationMethod.invoke( composite ); | |
+ PropertyDescriptor propertyDescriptor = entityDescriptor | |
+ .state() | |
+ .getPropertyByName( descriptor.qualifiedName() | |
+ .name() ); | |
+ return associationState.propertyFor( propertyDescriptor | |
+ .accessor() ) | |
+ .get(); | |
- } | |
+ } | |
- catch (IllegalAccessException e) | |
+ catch( Exception e ) | |
- { | |
+ { | |
- String message = associationMethod + " is not present in " + entityDescriptor.type(); | |
- throw new PropertyNotPresentException( message, | |
- valueType, | |
- (Class<? extends EntityComposite>) composite.type() ); | |
+ if( descriptor.valueType() | |
+ .mainType() | |
+ .equals( String.class ) ) | |
+ { | |
+ // Find Association and convert to string | |
+ AssociationDescriptor associationDescriptor = null; | |
+ try | |
+ { | |
+ associationDescriptor = entityDescriptor.state() | |
+ .getAssociationByName( descriptor.qualifiedName() | |
+ .name() ); | |
- } | |
+ } | |
- catch (InvocationTargetException e) | |
+ catch( IllegalArgumentException e1 ) | |
- { | |
+ { | |
- String message = "Exception in association method. Internal Error? [" + associationMethod + " / " + | |
- entityDescriptor.type(); | |
- throw new UndeclaredThrowableException( e.getTargetException(), message ); | |
+ return null; | |
- } | |
+ } | |
- Object associatedEntityInstance = association.get(); | |
- | |
- // Convert association value to DTO (recursively) | |
- if (associatedEntityInstance != null) | |
- propertyValue = convert( propertyDtoClass, associatedEntityInstance ); | |
+ Object entity = associationState.associationFor( associationDescriptor | |
+ .accessor() ) | |
+ .get(); | |
+ if( entity != null ) | |
+ { | |
+ return ( (Identity) entity ).identity() | |
+ .get(); | |
- } | |
- else | |
- { | |
+ } | |
+ else | |
+ { | |
- // Set property string to entity reference | |
- propertyValue = entityState.getAssociation( name ).toURI(); | |
+ return null; | |
- } | |
+ } | |
- | |
- setUnqualifiedProperty( builder, properties, name, propertyValue ); | |
- } | |
+ } | |
-// for (ManyAssociationDescriptor descriptor : entityDescriptor.state().manyAssociations()) | |
- for (AssociationDescriptor descriptor : entityDescriptor.state().manyAssociations()) | |
+ else if( descriptor.valueType() instanceof CollectionType && ( (CollectionType) descriptor | |
+ .valueType() ).collectedType() | |
+ .mainType() | |
+ .equals( String.class ) ) | |
- { | |
+ { | |
- ArrayList<String> entityURIs = new ArrayList<String>(); | |
- QualifiedName name = descriptor.qualifiedName(); | |
- for (EntityReference value : entityState.getManyAssociation( name )) | |
+ AssociationDescriptor associationDescriptor = null; | |
+ try | |
- { | |
+ { | |
- entityURIs.add( value.toURI() ); | |
+ associationDescriptor = entityDescriptor.state() | |
+ .getManyAssociationByName( descriptor.qualifiedName() | |
+ .name() ); | |
- } | |
+ } | |
- setUnqualifiedProperty( builder, properties, name, entityURIs ); | |
+ catch( IllegalArgumentException e1 ) | |
+ { | |
+ return null; | |
- } | |
+ } | |
- return (T) builder.newInstance(); | |
+ ManyAssociation state = associationState.manyAssociationFor( associationDescriptor | |
+ .accessor() ); | |
+ List<String> entities = new ArrayList<String>(); | |
+ for( Object entity : state ) | |
+ { | |
+ entities.add( ( (Identity) entity ).identity() | |
+ .get() ); | |
- } | |
+ } | |
+ return entities; | |
+ } | |
- private void setUnqualifiedProperty( ValueBuilder builder, Set<PropertyDescriptor> properties, QualifiedName name, Object value ) | |
+ // DTO | |
+ Class<?> type = descriptor.valueType().mainType(); | |
+ if ( DTO.class.isAssignableFrom(type)) { | |
+ AssociationDescriptor associationDescriptor = null; | |
+ try | |
- { | |
+ { | |
- PropertyDescriptor pd = findProperty( properties, name.name() ); | |
- if (pd == null) | |
+ associationDescriptor = entityDescriptor.state() | |
+ .getAssociationByName( descriptor.qualifiedName() | |
+ .name() ); | |
+ } | |
+ catch( IllegalArgumentException e1 ) | |
- { | |
+ { | |
- return; | |
+ return null; | |
- } | |
+ } | |
- Object prototype = builder.prototypeFor( pd.accessor().getDeclaringClass() ); | |
- try | |
+ | |
+ Object entity = associationState.associationFor( associationDescriptor | |
+ .accessor() ) | |
+ .get(); | |
+ if( entity != null ) | |
- { | |
+ { | |
- Property property = (Property) pd.accessor().invoke( prototype ); | |
- property.set( value ); | |
+ return convert( type, entity); | |
- } | |
+ } | |
- catch (IllegalAccessException e) | |
+ | |
+ | |
+ } | |
+ | |
+ return null; | |
+ } | |
+ } | |
+ }, new Function<AssociationDescriptor, EntityReference>() | |
- { | |
+ { | |
- e.printStackTrace(); | |
+ @Override | |
+ public EntityReference map( AssociationDescriptor descriptor ) | |
+ { | |
+ AssociationDescriptor associationDescriptor = null; | |
+ try | |
+ { | |
+ associationDescriptor = entityDescriptor.state() | |
+ .getAssociationByName( descriptor.qualifiedName() | |
+ .name() ); | |
- } | |
+ } | |
- catch (InvocationTargetException e) | |
+ catch( Exception e ) | |
- { | |
+ { | |
- e.printStackTrace(); | |
+ return null; | |
- } | |
+ } | |
- } | |
- private PropertyDescriptor findProperty( Set<PropertyDescriptor> properties, String name ) | |
+ return EntityReference.getEntityReference( associationState | |
+ .associationFor( associationDescriptor | |
+ .accessor() ) | |
+ .get() ); | |
+ } | |
+ }, new Function<AssociationDescriptor, Iterable<EntityReference>>() | |
- { | |
+ { | |
- for (PropertyDescriptor descriptor : properties) | |
+ @Override | |
+ public Iterable<EntityReference> map( AssociationDescriptor descriptor ) | |
- { | |
+ { | |
- if (descriptor.qualifiedName().name().equals( name )) | |
+ AssociationDescriptor associationDescriptor = null; | |
+ try | |
- { | |
+ { | |
- return descriptor; | |
+ associationDescriptor = entityDescriptor.state() | |
+ .getManyAssociationByName( descriptor.qualifiedName().name() ); | |
- } | |
+ } | |
+ catch( IllegalArgumentException e ) | |
+ { | |
+ return Iterables.empty(); | |
- } | |
+ } | |
- return null; | |
+ | |
+ List<EntityReference> refs = new ArrayList<EntityReference>(); | |
+ for( Object entity : associationState.manyAssociationFor( associationDescriptor.accessor() ) ) | |
+ { | |
+ refs.add( EntityReference.getEntityReference( entity ) ); | |
+ } | |
+ return refs; | |
+ } | |
+ } | |
+ ); | |
+ } | |
+ | |
+ return (T) builder.newInstance(); | |
} | |
} | |
} | |
Index: samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/HandlingQueries.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/HandlingQueries.java (revision 63141ff27bf64d0acd5b2bbd7dca7f0e17baaf33) | |
+++ samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/HandlingQueries.java (revision ) | |
@@ -7,6 +7,7 @@ | |
import com.marcgrue.dcisample_a.data.shipping.voyage.Voyage; | |
import com.marcgrue.dcisample_a.infrastructure.model.Queries; | |
import org.qi4j.api.query.Query; | |
+import org.qi4j.api.query.QueryBuilder; | |
import java.util.ArrayList; | |
import java.util.List; | |
@@ -23,8 +24,8 @@ | |
{ | |
public List<String> voyages() | |
{ | |
- Query<Voyage> voyages = qbf.newQueryBuilder( Voyage.class ) | |
- .newQuery( uowf.currentUnitOfWork() ) | |
+ QueryBuilder<Voyage> qb = qbf.newQueryBuilder(Voyage.class); | |
+ Query<Voyage> voyages = uowf.currentUnitOfWork().newQuery(qb) | |
.orderBy( orderBy( templateFor( Voyage.class ).voyageNumber() ) ); | |
List<String> voyageList = new ArrayList<String>(); | |
@@ -35,7 +36,8 @@ | |
public List<String> cargoIds() | |
{ | |
- Query<CargoEntity> cargos = qbf.newQueryBuilder( CargoEntity.class ).newQuery( uowf.currentUnitOfWork() ) | |
+ QueryBuilder<CargoEntity> qb = qbf.newQueryBuilder(CargoEntity.class); | |
+ Query<CargoEntity> cargos = uowf.currentUnitOfWork().newQuery(qb) | |
.orderBy( orderBy( templateFor( CargoEntity.class ).trackingId().get().id() ) ); | |
List<String> cargoList = new ArrayList<String>(); | |
for (CargoEntity cargo : cargos) | |
\ No newline at end of file | |
Index: samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/bootstrap/assembly/Assembler.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/bootstrap/assembly/Assembler.java (revision 63141ff27bf64d0acd5b2bbd7dca7f0e17baaf33) | |
+++ samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/bootstrap/assembly/Assembler.java (revision ) | |
@@ -1,5 +1,6 @@ | |
package com.marcgrue.dcisample_a.bootstrap.assembly; | |
+import com.marcgrue.dcisample_a.bootstrap.DCISampleApplication_a; | |
import com.marcgrue.dcisample_a.bootstrap.sampledata.BaseDataService; | |
import com.marcgrue.dcisample_a.bootstrap.sampledata.SampleDataService; | |
import com.marcgrue.dcisample_a.communication.query.BookingQueries; | |
@@ -116,7 +117,7 @@ | |
ModuleAssembly bootstrapModule = bootstrapLayer.module( "BOOTSTRAP-Bootstrap" ); | |
bootstrapModule | |
.objects( | |
- WicketQi4jApplication.class ); | |
+ DCISampleApplication_a.class); | |
// Load sample data on startup | |
bootstrapModule | |
Index: samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/infrastructure/model/JSONModel.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/infrastructure/model/JSONModel.java (revision 63141ff27bf64d0acd5b2bbd7dca7f0e17baaf33) | |
+++ samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/infrastructure/model/JSONModel.java (revision ) | |
@@ -1,6 +1,10 @@ | |
package com.marcgrue.dcisample_a.infrastructure.model; | |
+import org.json.JSONException; | |
+import org.qi4j.api.json.JSONObjectSerializer; | |
+import org.qi4j.api.structure.Module; | |
import org.qi4j.api.value.ValueComposite; | |
+import org.qi4j.runtime.value.ValueInstance; | |
/** | |
* Model that can serialize/de-serialize an object to/from a JSON string. | |
@@ -15,7 +19,13 @@ | |
@SuppressWarnings( "unchecked" ) | |
public JSONModel( T valueComposite, Class<U> valueCompositeClass ) | |
{ | |
- json = ( (U) valueComposite ).toJSON(); // Unchecked cast | |
+ JSONObjectSerializer jsonSerializer = new JSONObjectSerializer(); | |
+ try { | |
+ jsonSerializer.serialize((U) valueComposite); | |
+ } catch (JSONException e) { | |
+ throw new RuntimeException( "Cannot serialize ValueComposite: " + valueComposite ); | |
+ } | |
+ json = jsonSerializer.getRoot().toString(); | |
this.valueCompositeClass = valueCompositeClass; | |
} | |
@@ -26,7 +36,8 @@ | |
throw new RuntimeException( value + " has to be an instance of a ValueComposite." ); | |
// Get ValueComposite interface | |
- Class<U> valueCompositeClass = (Class<U>) ( (ValueComposite) value ).type(); // Unchecked cast | |
+ ValueInstance valueInstance = ValueInstance.getValueInstance( (ValueComposite) value ); | |
+ Class<U> valueCompositeClass = (Class<U>) valueInstance.descriptor().valueType().mainType(); | |
return new JSONModel<T, U>( value, valueCompositeClass); | |
} | |
\ No newline at end of file | |
Index: samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/TrackingQueries.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/TrackingQueries.java (revision 63141ff27bf64d0acd5b2bbd7dca7f0e17baaf33) | |
+++ samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/TrackingQueries.java (revision ) | |
@@ -10,6 +10,7 @@ | |
import com.marcgrue.dcisample_a.infrastructure.model.QueryModel; | |
import org.apache.wicket.model.IModel; | |
import org.qi4j.api.query.Query; | |
+import org.qi4j.api.query.QueryBuilder; | |
import org.qi4j.api.query.QueryExpressions; | |
import java.util.ArrayList; | |
@@ -28,10 +29,9 @@ | |
{ | |
Cargo cargoEntity = templateFor( CargoEntity.class ); | |
- Query<CargoEntity> cargos = qbf.newQueryBuilder( CargoEntity.class ) | |
- .where( isNotNull( cargoEntity.itinerary() ) ) | |
- .newQuery( uowf.currentUnitOfWork() ) | |
+ QueryBuilder<CargoEntity> qb = qbf.newQueryBuilder(CargoEntity.class).where(isNotNull(cargoEntity.itinerary())); | |
+ Query<CargoEntity> cargos = uowf.currentUnitOfWork().newQuery(qb) | |
- .orderBy( orderBy( cargoEntity.trackingId().get().id() ) ); | |
+ .orderBy(orderBy(cargoEntity.trackingId().get().id())); | |
List<String> cargoList = new ArrayList<String>(); | |
for (CargoEntity cargo : cargos) | |
@@ -48,9 +48,9 @@ | |
{ | |
HandlingEvent eventTemplate = templateFor( HandlingEvent.class ); | |
- return qbf.newQueryBuilder( HandlingEventEntity.class ) | |
- .where( QueryExpressions.eq( eventTemplate.trackingId().get().id(), trackingIdString ) ) | |
- .newQuery( uowf.currentUnitOfWork() ) | |
+ QueryBuilder<HandlingEventEntity> qb = qbf.newQueryBuilder(HandlingEventEntity.class) | |
+ .where(QueryExpressions.eq(eventTemplate.trackingId().get().id(), trackingIdString)); | |
+ return uowf.currentUnitOfWork().newQuery(qb) | |
.orderBy( orderBy( eventTemplate.completionTime() ) ); | |
} | |
}; | |
\ No newline at end of file | |
Index: samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/data/shipping/cargo/Cargo.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/data/shipping/cargo/Cargo.java (revision 63141ff27bf64d0acd5b2bbd7dca7f0e17baaf33) | |
+++ samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/data/shipping/cargo/Cargo.java (revision ) | |
@@ -4,7 +4,7 @@ | |
import com.marcgrue.dcisample_a.data.shipping.location.Location; | |
import com.marcgrue.dcisample_a.data.shipping.delivery.Delivery; | |
import org.qi4j.api.common.Optional; | |
-import org.qi4j.api.entity.association.Association; | |
+import org.qi4j.api.association.Association; | |
import org.qi4j.api.property.Immutable; | |
import org.qi4j.api.property.Property; | |
\ No newline at end of file | |
Index: samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/dto/HandlingEventDTO.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/dto/HandlingEventDTO.java (revision 63141ff27bf64d0acd5b2bbd7dca7f0e17baaf33) | |
+++ samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/dto/HandlingEventDTO.java (revision ) | |
@@ -6,7 +6,7 @@ | |
import com.marcgrue.dcisample_a.infrastructure.conversion.DTO; | |
import org.qi4j.api.common.Optional; | |
import org.qi4j.api.property.Property; | |
-import org.qi4j.library.values.Unqualified; | |
+import org.qi4j.library.conversion.values.Unqualified; | |
import java.util.Date; | |
Index: samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/infrastructure/WicketQi4jApplication.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/infrastructure/WicketQi4jApplication.java (revision 63141ff27bf64d0acd5b2bbd7dca7f0e17baaf33) | |
+++ samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/infrastructure/WicketQi4jApplication.java (revision ) | |
@@ -13,6 +13,7 @@ | |
import org.qi4j.api.injection.scope.Service; | |
import org.qi4j.api.injection.scope.Structure; | |
import org.qi4j.api.query.QueryBuilderFactory; | |
+import org.qi4j.api.structure.Application; | |
import org.qi4j.api.structure.Module; | |
import org.qi4j.api.unitofwork.ConcurrentEntityModificationException; | |
import org.qi4j.api.unitofwork.UnitOfWork; | |
@@ -22,7 +23,6 @@ | |
import org.qi4j.api.value.ValueBuilderFactory; | |
import org.qi4j.bootstrap.ApplicationAssembler; | |
import org.qi4j.bootstrap.Energy4Java; | |
-import org.qi4j.spi.structure.ApplicationSPI; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
@@ -36,7 +36,7 @@ | |
{ | |
public Logger logger = LoggerFactory.getLogger( WicketQi4jApplication.class ); | |
- protected ApplicationSPI qi4jApp; | |
+ protected Application qi4jApp; | |
protected Module qi4jModule; | |
@Structure | |
@@ -126,7 +126,8 @@ | |
qi4jModule = qi4jApp.findModule( defaultLayerName(), defaultModuleName() ); | |
// Qi4j injects @Structure and @Service elements into this application instance | |
- qi4jModule.objectBuilderFactory().newObjectBuilder( WicketQi4jApplication.class ).injectTo( this ); | |
+ //qi4jModule.newObject( WicketQi4jApplication.class ); | |
+ qi4jModule.injectTo( this); | |
logger.info( "Started Qi4j application" ); | |
} | |
\ No newline at end of file | |
Index: samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/bootstrap/sampledata/SampleDataService.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/bootstrap/sampledata/SampleDataService.java (revision 63141ff27bf64d0acd5b2bbd7dca7f0e17baaf33) | |
+++ samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/bootstrap/sampledata/SampleDataService.java (revision ) | |
@@ -14,6 +14,7 @@ | |
import org.qi4j.api.injection.scope.Structure; | |
import org.qi4j.api.mixin.Mixins; | |
import org.qi4j.api.query.Query; | |
+import org.qi4j.api.query.QueryBuilder; | |
import org.qi4j.api.query.QueryBuilderFactory; | |
import org.qi4j.api.service.Activatable; | |
import org.qi4j.api.service.ServiceComposite; | |
@@ -66,7 +67,8 @@ | |
try | |
{ | |
int i = 11; // starting at 11 for sortable tracking id prefix in lists | |
- for (Cargo cargo : qbf.newQueryBuilder( Cargo.class ).newQuery( uow )) | |
+ QueryBuilder<Cargo> qb = qbf.newQueryBuilder(Cargo.class); | |
+ for (Cargo cargo : uow.newQuery(qb)) | |
{ | |
String trackingId = cargo.trackingId().get().id().get(); | |
ExpectedHandlingEvent nextEvent; | |
@@ -230,7 +232,8 @@ | |
CargosEntity cargos = uow.get( CargosEntity.class, CargosEntity.CARGOS_ID ); | |
- Query<Location> allLocations = qbf.newQueryBuilder( Location.class ).newQuery( uow ); | |
+ QueryBuilder<Location> qb = qbf.newQueryBuilder(Location.class); | |
+ Query<Location> allLocations = uow.newQuery(qb); | |
int locationSize = (int) allLocations.count(); | |
// Make array for selection of location with random index | |
Index: samples/dci-cargo/dcisample_a/src/test/java/com/marcgrue/dcisample_a/bootstrap/test/TestApplication.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- samples/dci-cargo/dcisample_a/src/test/java/com/marcgrue/dcisample_a/bootstrap/test/TestApplication.java (revision 63141ff27bf64d0acd5b2bbd7dca7f0e17baaf33) | |
+++ samples/dci-cargo/dcisample_a/src/test/java/com/marcgrue/dcisample_a/bootstrap/test/TestApplication.java (revision ) | |
@@ -10,7 +10,7 @@ | |
import org.qi4j.api.unitofwork.UnitOfWork; | |
import org.qi4j.api.unitofwork.UnitOfWorkFactory; | |
import org.qi4j.bootstrap.Energy4Java; | |
-import org.qi4j.spi.structure.ApplicationSPI; | |
+import org.qi4j.api.structure.Application; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
@@ -23,7 +23,7 @@ | |
// Logger for sub classes | |
protected Logger logger = LoggerFactory.getLogger( getClass() ); | |
- protected static ApplicationSPI app; | |
+ protected static Application app; | |
protected static UnitOfWorkFactory uowf; | |
@BeforeClass | |
\ No newline at end of file | |
Index: samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/data/shipping/handling/HandlingEvent.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/data/shipping/handling/HandlingEvent.java (revision 63141ff27bf64d0acd5b2bbd7dca7f0e17baaf33) | |
+++ samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/data/shipping/handling/HandlingEvent.java (revision ) | |
@@ -5,7 +5,7 @@ | |
import com.marcgrue.dcisample_a.data.shipping.voyage.Voyage; | |
import org.qi4j.api.common.Optional; | |
import org.qi4j.api.common.UseDefaults; | |
-import org.qi4j.api.entity.association.Association; | |
+import org.qi4j.api.association.Association; | |
import org.qi4j.api.property.Immutable; | |
import org.qi4j.api.property.Property; | |
\ No newline at end of file | |
Index: samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/CommonQueries.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/CommonQueries.java (revision 63141ff27bf64d0acd5b2bbd7dca7f0e17baaf33) | |
+++ samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/CommonQueries.java (revision ) | |
@@ -8,6 +8,7 @@ | |
import com.marcgrue.dcisample_a.infrastructure.model.QueryModel; | |
import org.apache.wicket.model.IModel; | |
import org.qi4j.api.query.Query; | |
+import org.qi4j.api.query.QueryBuilder; | |
import java.util.ArrayList; | |
import java.util.List; | |
@@ -35,15 +36,17 @@ | |
{ | |
public Query<CargoEntity> getQuery() | |
{ | |
- return qbf.newQueryBuilder( CargoEntity.class ).newQuery( uowf.currentUnitOfWork() ) | |
+ QueryBuilder<CargoEntity> qb = qbf.newQueryBuilder(CargoEntity.class); | |
+ return uowf.currentUnitOfWork().newQuery( qb) | |
- .orderBy( orderBy( templateFor( CargoEntity.class ).trackingId().get().id() ) ); | |
+ .orderBy(orderBy(templateFor(CargoEntity.class).trackingId().get().id())); | |
} | |
}; | |
} | |
public List<String> unLocodes() | |
{ | |
- Query<Location> locations = qbf.newQueryBuilder( Location.class ).newQuery( uowf.currentUnitOfWork() ) | |
+ QueryBuilder<Location> qb = qbf.newQueryBuilder(Location.class); | |
+ Query<Location> locations = uowf.currentUnitOfWork().newQuery(qb) | |
.orderBy( orderBy( templateFor( Location.class ).unLocode().get().code() ) ); | |
List<String> unLocodeList = new ArrayList<String>(); | |
for (Location location : locations) | |
\ No newline at end of file | |
Index: samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/dto/CargoDTO.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/dto/CargoDTO.java (revision 63141ff27bf64d0acd5b2bbd7dca7f0e17baaf33) | |
+++ samples/dci-cargo/dcisample_a/src/main/java/com/marcgrue/dcisample_a/communication/query/dto/CargoDTO.java (revision ) | |
@@ -8,7 +8,7 @@ | |
import com.marcgrue.dcisample_a.infrastructure.conversion.DTO; | |
import org.qi4j.api.common.Optional; | |
import org.qi4j.api.property.Property; | |
-import org.qi4j.library.values.Unqualified; | |
+import org.qi4j.library.conversion.values.Unqualified; | |
/** | |
* Cargo DTO | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment