You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(6) |
Aug
(41) |
Sep
(44) |
Oct
(31) |
Nov
(54) |
Dec
(53) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(71) |
Feb
(66) |
Mar
(65) |
Apr
(73) |
May
(68) |
Jun
(69) |
Jul
(28) |
Aug
(49) |
Sep
(44) |
Oct
(77) |
Nov
(64) |
Dec
(78) |
| 2009 |
Jan
(50) |
Feb
(28) |
Mar
(41) |
Apr
(30) |
May
(5) |
Jun
(30) |
Jul
(6) |
Aug
(2) |
Sep
(18) |
Oct
(11) |
Nov
(6) |
Dec
(10) |
| 2010 |
Jan
(5) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <tri...@us...> - 2009-06-23 14:10:56
|
Revision: 1134
http://equanda.svn.sourceforge.net/equanda/?rev=1134&view=rev
Author: triathlon98
Date: 2009-06-23 14:10:45 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
EQ-130 fix CloneableTest (11 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-client/src/main/java/org/equanda/persistence/EquandaProxy.java
branches/EQ-130/equanda-generate/src/main/velocity/docs/ProxyInterface.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectProxy.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectSelectorBean.java.vm
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/CloneableTest.java
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java
Modified: branches/EQ-130/equanda-client/src/main/java/org/equanda/persistence/EquandaProxy.java
===================================================================
--- branches/EQ-130/equanda-client/src/main/java/org/equanda/persistence/EquandaProxy.java 2009-06-23 08:22:57 UTC (rev 1133)
+++ branches/EQ-130/equanda-client/src/main/java/org/equanda/persistence/EquandaProxy.java 2009-06-23 14:10:45 UTC (rev 1134)
@@ -156,8 +156,8 @@
return obj1.equals( obj2 );
}
- public PROXY equandaClone() { return equandaClone( true ); }
- public abstract PROXY equandaClone( boolean cloneUoid );
+ public PROXY equandaClone() { return equandaClone( getEquandaType() ); }
+ public abstract PROXY equandaClone( String type );
/**
* Update the proxy state, client changes are persisted, and server changes retrieved.
Modified: branches/EQ-130/equanda-generate/src/main/velocity/docs/ProxyInterface.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/docs/ProxyInterface.java.vm 2009-06-23 08:22:57 UTC (rev 1133)
+++ branches/EQ-130/equanda-generate/src/main/velocity/docs/ProxyInterface.java.vm 2009-06-23 14:10:45 UTC (rev 1134)
@@ -56,7 +56,8 @@
public interface ${table.Name}
implements Serializable #if( "x" != "x$!{table.ProxyInterface}" ) , ${table.ProxyInterface}#end
{
- public ${table.Name} equandaClone( boolean cloneUoid );
+ public ${table.Name} equandaClone();
+ public ${table.Name} equandaClone( String type );
/**
* Set the type of object which should be used. This is a helper routine to allow using isEquandaType()
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectProxy.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectProxy.java.vm 2009-06-23 08:22:57 UTC (rev 1133)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectProxy.java.vm 2009-06-23 14:10:45 UTC (rev 1134)
@@ -68,15 +68,15 @@
Equanda${table.Name}State getEquandaProxy() { return proxy; }
- public ${table.Name} equandaClone( boolean cloneUoid )
+ public ${table.Name} equandaClone( String type )
{
${table.Name} clone = new ${table.Name}(
- new Equanda${table.Name}State( cloneUoid ? id : null, equandaType.getType(),
- cloneUoid ? proxy.equandaCreationDate : new java.sql.Timestamp( System.currentTimeMillis() ),
- equandaModificationDate, cloneUoid ? equandaVersion : 0 )
+ new Equanda${table.Name}State( null, type, new java.sql.Timestamp( System.currentTimeMillis() ),
+ equandaModificationDate, 0 )
);
// clone fields
#foreach( $field in $table.FieldsNotInternal )
+#if( $field.isCloneable() )
#set( $fieldtype=$field.JavaFieldType )
#if ( $field.isLink() ) #set( $fieldtype="${field.JavaFieldType}" ) #end
#if( $field.isMultiple() || $field.isLink() )
@@ -105,8 +105,9 @@
#end ## is multiple
#if ( !$field.isCalculated() && !$field.isMultiple())
## if we have not cloned the id then set the modified field to all fields
- clone.proxy._modified$field.Name = cloneUoid ? proxy._modified$field.Name : true;
+ clone.proxy._modified$field.Name = true;
#end
+#end
#end
return clone;
}
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectSelectorBean.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectSelectorBean.java.vm 2009-06-23 08:22:57 UTC (rev 1133)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectSelectorBean.java.vm 2009-06-23 14:10:45 UTC (rev 1134)
@@ -387,13 +387,8 @@
*/
#buildSecurityRole( $build )
public ${package}.client.${table.Name} equandaClone( String type, Uoid base ) throws EquandaException {
- //DM${table.Name} base = HR${table.Name}.selectId( entityManager, base );
- DM${table.Name} entity = getNewEntity( type );
- //setAutoFields(entity); @todo
- //mediator.equandaClone( other ); @todo
- #parse("ObjectSelector-build.java.vm")
- entityManager.flush(); // force save to have correct equandaModification and equandaStatus fields
- return get( entity);
+ DM${table.Name} entity = HR${table.Name}.selectId( entityManager, base );
+ return get( entity ).equandaClone( type );
}
#end ##if isCloneable
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/CloneableTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/CloneableTest.java 2009-06-23 08:22:57 UTC (rev 1133)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/CloneableTest.java 2009-06-23 14:10:45 UTC (rev 1134)
@@ -43,13 +43,12 @@
obj.setTestStringCloneable( "aaa" );
obj.setTestStringNotCloneable( "bbb" );
obj.equandaUpdate();
- Cloneable clone = obj.equandaClone( false );
+ Cloneable clone = obj.equandaClone();
assertEquals( "clone.TestStringCloneable should be \"aaa\"", "aaa", clone.getTestStringCloneable() );
assertNull( "clone.TestStringNotCloneable should be null", clone.getTestStringNotCloneable() );
CloneableSelectorEJB objSelector = EquandaGlobal.getCloneableSelector();
Cloneable cloneVal = objSelector.equandaClone( " ", obj.getId() );
- assertTrue( "cloneVal.TestStringCloneable should be \"aaa\"",
- cloneVal.getTestStringCloneable().equals( "aaa" ) );
+ assertEquals( "cloneVal.TestStringCloneable should be \"aaa\"", "aaa", cloneVal.getTestStringCloneable() );
assertNull( "cloneVal.TestStringNotCloneable should be null", cloneVal.getTestStringNotCloneable() );
}
}
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java 2009-06-23 08:22:57 UTC (rev 1133)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java 2009-06-23 14:10:45 UTC (rev 1134)
@@ -434,7 +434,7 @@
cm.setCar( car1 );
cm.equandaUpdate();
- car2 = car1.equandaClone();
+ car2 = Car.selectBrand( car1.getBrand() );
// it's the same id and proxies are not modified... but cm.car is not initialized, so is null when comparing inside the setter
cm.setCar( car2 );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-23 08:24:08
|
Revision: 1133
http://equanda.svn.sourceforge.net/equanda/?rev=1133&view=rev
Author: triathlon98
Date: 2009-06-23 08:22:57 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
EQ-130 fix ChoicesTest, choice on multiple field (13 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMField.java.vm
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMField.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMField.java.vm 2009-06-20 09:00:06 UTC (rev 1132)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMField.java.vm 2009-06-23 08:22:57 UTC (rev 1133)
@@ -32,8 +32,11 @@
package ${package}.server.pm;
+import org.equanda.client.EquandaException;
+import org.equanda.client.ExceptionCodes;
import org.equanda.persistence.Uoid;
import org.equanda.persistence.UoidGenerator;
+import org.equanda.persistence.EquandaConstraintViolation;
import org.equanda.persistence.EquandaFieldBean;
import org.equanda.util.StringUtil;
@@ -70,6 +73,7 @@
}
public DM${table.Name}_${field.Name}($field.JavaFieldType value)
+ throws EquandaException
{
this();
set${field.Name}(value);
@@ -88,6 +92,7 @@
}
/** @ejb.interface-method */
public void set${field.Name}( $field.JavaFieldType ${field.VarName} )
+ throws EquandaException
{
#* force strings in field width, and do case conversion *#
#if ( $field.isString() )
@@ -117,6 +122,8 @@
}
#end
#end
+#set( $chosenValue = "${field.VarName}" )
+#parse("DMObject-choices.java.vm")
this.${field.VarName} = ${field.VarName};
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-20 09:00:08
|
Revision: 1132
http://equanda.svn.sourceforge.net/equanda/?rev=1132&view=rev
Author: triathlon98
Date: 2009-06-20 09:00:06 +0000 (Sat, 20 Jun 2009)
Log Message:
-----------
EQ-130 fix TypeTest (dm had changed) (13 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/TypeTest.java
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/TypeTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/TypeTest.java 2009-06-20 08:22:02 UTC (rev 1131)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/TypeTest.java 2009-06-20 09:00:06 UTC (rev 1132)
@@ -53,10 +53,10 @@
assertTrue( ImmutableIfGlobalInheritedType.isTypeStatic( "IIGI" ) );
assertFalse( ImmutableIfGlobalInheritedType.isTypeStatic( "BLA" ) );
- assertTrue( AirplaneType.isTypeStatic( "" ) );
- assertTrue( AirplaneType.isTypeStatic( "VWWH" ) );
- assertTrue( AirplaneType.isTypeStatic( "VWWI" ) );
- assertTrue( AirplaneType.isTypeStatic( "AIRP" ) );
+ assertTrue( AirplaneType.isTypeStatic( VehicleConstants.TYPE_Vehicle ) );
+ assertFalse( AirplaneType.isTypeStatic( VehicleConstants.TYPE_VehicleWithWheels ) );
+ assertTrue( AirplaneType.isTypeStatic( VehicleConstants.TYPE_VehicleWithWings ) );
+ assertTrue( AirplaneType.isTypeStatic( VehicleConstants.TYPE_Airplane ) );
assertFalse( ImmutableIfGlobalType.isParentTypeStatic( null ) );
assertTrue( ImmutableIfGlobalType.isParentTypeStatic( " " ) );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-20 08:22:09
|
Revision: 1131
http://equanda.svn.sourceforge.net/equanda/?rev=1131&view=rev
Author: triathlon98
Date: 2009-06-20 08:22:02 +0000 (Sat, 20 Jun 2009)
Log Message:
-----------
EQ-130 re-enable unlinked test (14 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-19 15:55:26 UTC (rev 1130)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-20 08:22:02 UTC (rev 1131)
@@ -73,7 +73,7 @@
{
ito.equandaUpdate();
}
- #if( $field.isBidirectional() )
+ #if( $field.isBidirectional() && !$field.isOwner() )
DM${field.LinkTableName} link = em.find( DM${field.LinkTableName}.class, ito.getId() );
// before updating the bidir proxy set the bidir link in case this is required
#if ($field.linkField.isMultiple())
@@ -200,13 +200,15 @@
#if( $field.linkField.isEmbedded() )
if ( null != spec.get${field.Name}() ) throw new EquandaConstraintViolation( ECV_OTHERSIDE_EMBEDDED_FIELD_IMMUTABLE_ONCE_SET, "${table.Name}", "${field.Name}" );
#else
+#if( !$field.isOwner() )
#if( $field.LinkField.isMultiple() )
if ( null != spec.get${field.Name}() ) spec.get${field.Name}().get${field.LinkField.Name}().remove( spec );
#else
if ( null != spec.get${field.Name}() ) spec.get${field.Name}().set${field.LinkField.Name}( null );
#end
#end
-#end
+#end
+#end
#if( $field.isEmbedded() )
if ( null != spec.get${field.Name}() ) em.remove( spec.get${field.Name}() );
#end
@@ -222,7 +224,7 @@
${field.JavaEntityType} current = spec.get${field.Name}();
if ( null != current && current.getId().equals( linkField.getId() ) )
{
-#if( $field.isBidirectional() )
+#if( $field.isBidirectional() && !$field.isOwner() )
#if( $field.LinkField.isMultiple() )
current.get${field.LinkField.Name}().remove( spec );
#else
@@ -235,7 +237,7 @@
}
DM${field.LinkTableName} link = em.find( DM${field.LinkTableName}.class, linkField.getId() );
// before updating the bidir proxy set the bidir link in case this is required
-#if( $field.isBidirectional() )
+#if( $field.isBidirectional() && !$field.isOwner() )
#if ($field.linkField.isMultiple())
link.get${field.linkField.Name}().add( spec );
#else
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java 2009-06-19 15:55:26 UTC (rev 1130)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java 2009-06-20 08:22:02 UTC (rev 1131)
@@ -392,7 +392,6 @@
assertTrue( owner.getCarsWichHeLikes().isEmpty() );
// check for infinite updates
- /* fails because version changed by indirect links...
owner.setPreferredCar( preferredCar );
ArrayList<Owner> owners = new ArrayList<Owner>();
owners.add( owner );
@@ -400,7 +399,6 @@
owner.equandaUpdate();
assertNotNull( owner.getPreferredCar() );
assertEquals( 1, preferredCar.getOwners().size() );
- */
// clean up
owner.getPreferredCar().removeEntityBean();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-19 15:55:32
|
Revision: 1130
http://equanda.svn.sourceforge.net/equanda/?rev=1130&view=rev
Author: triathlon98
Date: 2009-06-19 15:55:26 +0000 (Fri, 19 Jun 2009)
Log Message:
-----------
EQ-130 fix linktests (14 tests to go, though one test needs to be disabled now)
Modified Paths:
--------------
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/LinkableMediator.java
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/LinkTest.java
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-19 06:19:14 UTC (rev 1129)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-19 15:55:26 UTC (rev 1130)
@@ -6,16 +6,17 @@
public static void update( EntityManager em, DM${table.Name} entity, ${table.Name} obj )
throws EquandaException
{
- if ( obj != null && obj.getId() != null )
+ Equanda${table.Name}State proxy = obj.getEquandaProxy();
+ if ( proxy.updateInProgress ) return;
+ proxy.updateInProgress = true;
+ if ( obj.getId() != null )
{
- if ( entity.getEquandaVersion() != obj.getEquandaProxy().equandaVersion )
+ if ( entity.getEquandaVersion() != proxy.equandaVersion )
{
throw new ConcurrentModificationException(CME_DATA_HAS_BEEN_ALREADY_CHANGED,
obj.getEquandaVersion() + "," + entity.getEquandaVersion() );
}
}
- Equanda${table.Name}State proxy = obj.getEquandaProxy();
- proxy.updateInProgress = true;
String errorField = "";
try
{
@@ -52,154 +53,130 @@
errorField = "$field.Name";
Collection<$fieldtype> al = proxy.${field.VarName};
if ( al == null ) al = new ArrayList<$fieldtype>();
-#* if ( al == null || al.isEmpty() )
+ Collection<$fieldtype2> last = spec.get${field.Name}();
+ for ( $fieldtype ito : al )
{
- Collection<$fieldtype2> fvl = spec.get${field.Name}();
-#if( $field.isEmbedded() || !$field.isLink())
- for ( $fieldtype2 rem : fvl ) em.remove( rem );
-#end
-#if( $field.isLink() && $field.isBidirectional() )
- for ( $fieldtype2 rem : fvl )
+ if ( ito != null )
{
- DM${field.LinkTableName} link = em.find( DM${field.LinkTableName}.class, ito.getId() );
- // before updating the bidir proxy set the bidir link in case this is required
- #if ($field.linkField.isMultiple())
- link.get${field.linkField.Name}().add( spec );
- #else
- link.set${field.linkField.Name}( spec );
- #end
- }
-#end
- fvl.clear();
- }
- else
-*#
- {
- Collection<$fieldtype2> last = spec.get${field.Name}();
- for ( $fieldtype ito : al )
- {
- if ( ito != null )
+ #if( !$field.isLink() )
+ boolean contains = false;
+ for ( $fieldtype2 test : last )
{
- #if( !$field.isLink() )
- boolean contains = false;
- for ( $fieldtype2 test : last )
- {
- contains |= ito.equals( test.get${field.Name}() );
- }
- if ( !contains )
- {
- spec.get${field.Name}().add( new $fieldtype2( ito ) );
- }
- #else
- if ( !ito.getEquandaProxy().updateInProgress && ( ito.getId() == null || ito.isModified() ) )
- {
- ito.equandaUpdate();
- }
- #if( $field.isBidirectional() )
- DM${field.LinkTableName} link = em.find( DM${field.LinkTableName}.class, ito.getId() );
- // before updating the bidir proxy set the bidir link in case this is required
- #if ($field.linkField.isMultiple())
- link.get${field.linkField.Name}().add( spec );
- #else
- link.set${field.linkField.Name}( spec );
- #end
+ contains |= ito.equals( test.get${field.Name}() );
+ }
+ if ( !contains )
+ {
+ spec.get${field.Name}().add( new $fieldtype2( ito ) );
+ }
+ #else
+ if ( !ito.getEquandaProxy().updateInProgress && ( ito.getId() == null || ito.isModified() ) )
+ {
+ ito.equandaUpdate();
+ }
+ #if( $field.isBidirectional() )
+ DM${field.LinkTableName} link = em.find( DM${field.LinkTableName}.class, ito.getId() );
+ // before updating the bidir proxy set the bidir link in case this is required
+ #if ($field.linkField.isMultiple())
+ link.get${field.linkField.Name}().add( spec );
+ #else
+ link.set${field.linkField.Name}( spec );
#end
- boolean contains = false;
- for ( $fieldtype2 test : last )
- {
- if ( ito.getId().equals( test.getId() ) ) {
- contains = true;
- break;
- }
- }
- if ( !contains )
- {
- spec.get${field.Name}().add( em.find( DM${field.LinkTableName}.class,ito.getId() ) );
- }
-
#end
+ boolean contains = false;
+ for ( $fieldtype2 test : last )
+ {
+ if ( ito.getId().equals( test.getId() ) ) {
+ contains = true;
+ break;
+ }
}
+ if ( !contains )
+ {
+ spec.get${field.Name}().add( em.find( DM${field.LinkTableName}.class,ito.getId() ) );
+ }
+
+ #end
}
- Collection<$fieldtype2> fvl = spec.get${field.Name}();
- if ( !( al instanceof EquandaList ) )
- {
+ }
+ Collection<$fieldtype2> fvl = spec.get${field.Name}();
+ if ( !( al instanceof EquandaList ) )
+ {
#if( $field.isBidirectional() && $field.linkField.isEmbedded() )
- if ( al.size() != fvl.size() ) throw new EquandaConstraintViolation( ECV_OTHERSIDE_EMBEDDED_FIELD_IMMUTABLE_ONCE_SET, "${table.Name}", "${field.Name}" );
+ if ( al.size() != fvl.size() ) throw new EquandaConstraintViolation( ECV_OTHERSIDE_EMBEDDED_FIELD_IMMUTABLE_ONCE_SET, "${table.Name}", "${field.Name}" );
#else
- while ( al.size() != fvl.size() ) // while to prevent ConcurrentModificationException
+ while ( al.size() != fvl.size() ) // while to prevent ConcurrentModificationException
+ {
+ for ( $fieldtype2 inst : fvl )
{
- for ( $fieldtype2 inst : fvl )
- {
- #if( $field.isLink() )
- boolean found = false;
- for ( $fieldtype uv : al )
+ #if( $field.isLink() )
+ boolean found = false;
+ for ( $fieldtype uv : al )
+ {
+ if ( inst.getId().equals( uv.getId() ) )
{
- if ( inst.getId().equals( uv.getId() ) )
- {
- found = true;
- break;
- }
+ found = true;
+ break;
}
- if ( !found ) {
- fvl.remove( inst );
+ }
+ if ( !found ) {
+ fvl.remove( inst );
#if( $field.isEmbedded() )
- em.remove( inst );
+ em.remove( inst );
#end
- break; // prevent ConcurrentModificationException
- }
- #else##if isLink
- if ( !al.contains( inst.get${field.Name}() ) )
- {
- fvl.remove( inst );
- em.remove( inst );
- break; // prevent ConcurrentModificationException
- }
- #end
- }
+ break; // prevent ConcurrentModificationException
+ }
+ #else##if isLink
+ if ( !al.contains( inst.get${field.Name}() ) )
+ {
+ fvl.remove( inst );
+ em.remove( inst );
+ break; // prevent ConcurrentModificationException
+ }
+ #end
}
-#end
}
- else
+#end
+ }
+ else
+ {
+ EquandaList<$fieldtype> fval = (EquandaList<$fieldtype>) al;
+ if ( fval.isModified() )
{
- EquandaList<$fieldtype> fval = (EquandaList<$fieldtype>) al;
- if ( fval.isModified() )
- {
- Collection<$fieldtype> rem = fval.getRemoveSet();
+ Collection<$fieldtype> rem = fval.getRemoveSet();
#if( $field.isBidirectional() && $field.linkField.isEmbedded() )
- if ( !rem.isEmpty() ) throw new EquandaConstraintViolation( ECV_OTHERSIDE_EMBEDDED_FIELD_IMMUTABLE_ONCE_SET, "${table.Name}", "${field.Name}" );
+ if ( !rem.isEmpty() ) throw new EquandaConstraintViolation( ECV_OTHERSIDE_EMBEDDED_FIELD_IMMUTABLE_ONCE_SET, "${table.Name}", "${field.Name}" );
#else
- for ( $fieldtype ro : rem )
+ for ( $fieldtype ro : rem )
+ {
+ #if( $field.isLink() )
+ if ( ro != null && ro.getId() != null )
{
- #if( $field.isLink() )
- if ( ro != null && ro.getId() != null )
- {
- DM${field.LinkTableName} item = em.find( DM${field.LinkTableName}.class, ro.getId() );
+ DM${field.LinkTableName} item = em.find( DM${field.LinkTableName}.class, ro.getId() );
#if( $field.isOwner() || !$field.isBidirectional() )
- spec.get${field.Name}().remove( item );
+ spec.get${field.Name}().remove( item );
#elseif( $field.LinkField.isMultiple() )
- item.get${field.LinkField.Name}().remove( spec );
+ item.get${field.LinkField.Name}().remove( spec );
#else
- item.set${field.LinkField.Name}( null );
+ item.set${field.LinkField.Name}( null );
#end
#if( $field.isEmbedded() )
- em.remove( item );
+ em.remove( item );
#end
- }
- #else
- for ( $fieldtype2 test : spec.get${field.Name}() )
+ }
+ #else
+ for ( $fieldtype2 test : spec.get${field.Name}() )
+ {
+ if ( ro.equals( test.get${field.Name}() ) )
{
- if ( ro.equals( test.get${field.Name}() ) )
- {
- spec.get${field.Name}().remove( test );
- em.remove( test );
- break;
- }
+ spec.get${field.Name}().remove( test );
+ em.remove( test );
+ break;
}
- #end
}
- fval.reset();
-#end
+ #end
}
+ fval.reset();
+#end
}
}
#else ## if (isMultiple...)
@@ -219,9 +196,17 @@
#else ## isLink single
if ( proxy.${field.VarName} == null )
{
-#if( $field.isBidirectional() && $field.linkField.isEmbedded() )
+#if( $field.isBidirectional() )
+#if( $field.linkField.isEmbedded() )
if ( null != spec.get${field.Name}() ) throw new EquandaConstraintViolation( ECV_OTHERSIDE_EMBEDDED_FIELD_IMMUTABLE_ONCE_SET, "${table.Name}", "${field.Name}" );
+#else
+#if( $field.LinkField.isMultiple() )
+ if ( null != spec.get${field.Name}() ) spec.get${field.Name}().get${field.LinkField.Name}().remove( spec );
+#else
+ if ( null != spec.get${field.Name}() ) spec.get${field.Name}().set${field.LinkField.Name}( null );
#end
+#end
+#end
#if( $field.isEmbedded() )
if ( null != spec.get${field.Name}() ) em.remove( spec.get${field.Name}() );
#end
@@ -234,26 +219,30 @@
{
linkField.equandaUpdate();
}
- #if( $field.isBidirectional() )
- DM${field.LinkTableName} link = em.find( DM${field.LinkTableName}.class, linkField.getId() );
- // before updating the bidir proxy set the bidir link in case this is required
- #if ($field.linkField.isMultiple())
- link.get${field.linkField.Name}().add( spec );
- #else
- link.set${field.linkField.Name}( spec );
- #end
- #end
${field.JavaEntityType} current = spec.get${field.Name}();
- if ( null == current || !current.getId().equals( linkField.getId() ) )
+ if ( null != current && current.getId().equals( linkField.getId() ) )
{
+#if( $field.isBidirectional() )
+#if( $field.LinkField.isMultiple() )
+ current.get${field.LinkField.Name}().remove( spec );
+#else
+ current.set${field.LinkField.Name}( null );
+#end
+#end
#if( $field.isEmbedded() )
- if ( null != current ) em.remove( current );
+ em.remove( current );
#end
- if ( linkField.getId() != null )
- {
- spec.set${field.Name}( em.find( DM${field.LinkTableName}.class, linkField.getId() ) );
- }
}
+ DM${field.LinkTableName} link = em.find( DM${field.LinkTableName}.class, linkField.getId() );
+ // before updating the bidir proxy set the bidir link in case this is required
+#if( $field.isBidirectional() )
+#if ($field.linkField.isMultiple())
+ link.get${field.linkField.Name}().add( spec );
+#else
+ link.set${field.linkField.Name}( spec );
+#end
+#end
+ spec.set${field.Name}( link );
}
#end
#end
Modified: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/LinkableMediator.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/LinkableMediator.java 2009-06-19 06:19:14 UTC (rev 1129)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/LinkableMediator.java 2009-06-19 15:55:26 UTC (rev 1130)
@@ -24,10 +24,6 @@
package org.equanda.test.dm.server;
-import org.equanda.client.EquandaException;
-import org.equanda.persistence.EquandaConstraintViolation;
-import org.equanda.persistence.Uoid;
-import static org.equanda.test.TestExceptionCodes.ECV_REMOVE2_NOT_ALOWED_STRING_TO_ADD;
//import org.equanda.test.dm.server.pm.DMRemove2Bean;
/**
@@ -39,11 +35,11 @@
public class LinkableMediator
//extends LinkableMediatorBase
{
- public static final String REMOVE2_NOT_ALOWED_STRING_TO_ADD = "REMOVE2_NOT_ALOWED_STRING_TO_ADD";
- public static final String REMOVE2_NOT_ALOWED_STRING_TO_REMOVE = "REMOVE2_NOT_ALOWED_STRING_TO_REMOVE";
-
- public void dummy() {}
+ public static final String REMOVE2_NOT_ALLOWED_STRING_TO_ADD = "REMOVE2_NOT_ALLOWED_STRING_TO_ADD";
+ public static final String REMOVE2_NOT_ALLOWED_STRING_TO_REMOVE = "REMOVE2_NOT_ALLOWED_STRING_TO_REMOVE";
+ public void dummy() {}
+
/*
public void setEquandaLinkSingleBidirectional( Uoid value )
throws EquandaException
@@ -81,10 +77,10 @@
if ( value != null )
{
DMRemove2Bean obj = DMRemove2Selector.selectId( em, value );
- if ( REMOVE2_NOT_ALOWED_STRING_TO_ADD.equals( obj.getTheString() ) )
+ if ( REMOVE2_NOT_ALLOWED_STRING_TO_ADD.equals( obj.getTheString() ) )
{
throw new EquandaConstraintViolation( ECV_REMOVE2_NOT_ALOWED_STRING_TO_ADD,
- REMOVE2_NOT_ALOWED_STRING_TO_ADD );
+ REMOVE2_NOT_ALLOWED_STRING_TO_ADD );
}
}
}
@@ -95,10 +91,10 @@
if ( value != null )
{
DMRemove2Bean obj = DMRemove2Selector.selectId( em, value );
- if ( REMOVE2_NOT_ALOWED_STRING_TO_REMOVE.equals( obj.getTheString() ) )
+ if ( REMOVE2_NOT_ALLOWED_STRING_TO_REMOVE.equals( obj.getTheString() ) )
{
throw new EquandaConstraintViolation( ECV_REMOVE2_NOT_ALOWED_STRING_TO_ADD,
- REMOVE2_NOT_ALOWED_STRING_TO_ADD );
+ REMOVE2_NOT_ALLOWED_STRING_TO_ADD );
}
}
}
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/LinkTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/LinkTest.java 2009-06-19 06:19:14 UTC (rev 1129)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/LinkTest.java 2009-06-19 15:55:26 UTC (rev 1130)
@@ -58,42 +58,42 @@
mercedes.equandaUpdate();
bmw.getOwners().add( nick );
bmw.equandaUpdate();
- assertEquals( "nick's number of cars should be 2", 2, nick.getCars().size() );
- assertEquals( "paul's number of cars should be 1", 1, paul.getCars().size() );
- assertEquals( "mercedes's number of owners should be 2", 2, mercedes.getOwners().size() );
- assertEquals( "bmw's number of owners should be 1", 1, bmw.getOwners().size() );
+ assertEquals( "nick's number of cars should be 2" , 2, nick.getCars().size() );
+ assertEquals( "paul's number of cars should be 1" , 1, paul.getCars().size() );
+ assertEquals( "mercedes's number of owners should be 2" , 2, mercedes.getOwners().size() );
+ assertEquals( "bmw's number of owners should be 1" , 1, bmw.getOwners().size() );
mercedes.getOwners().clear();
mercedes.equandaUpdate();
bmw.getOwners().clear();
bmw.equandaUpdate();
nick.equandaUpdate(); // update to refresh data
- assertEquals( "nick's number of cars should be 0", 0, nick.getCars().size() );
+ assertEquals( "nick's number of cars should be 0" , 0, nick.getCars().size() );
paul.equandaUpdate(); // update to refresh data
- assertEquals( "paul's number of cars should be 0", 0, paul.getCars().size() );
- assertEquals( "mercedes's number of owners should be 0", 0, mercedes.getOwners().size() );
- assertEquals( "bmw's number of owners should be 0", 0, bmw.getOwners().size() );
+ assertEquals( "paul's number of cars should be 0" , 0, paul.getCars().size() );
+ assertEquals( "mercedes's number of owners should be 0" , 0, mercedes.getOwners().size() );
+ assertEquals( "bmw's number of owners should be 0" , 0, bmw.getOwners().size() );
nick.getCars().add( mercedes );
nick.getCars().add( bmw );
nick.equandaUpdate();
paul.getCars().add( mercedes );
paul.equandaUpdate();
- assertEquals( "nick's number of cars should be 2", 2, nick.getCars().size() );
- assertEquals( "paul's number of cars should be 1", 1, paul.getCars().size() );
+ assertEquals( "nick's number of cars should be 2" , 2, nick.getCars().size() );
+ assertEquals( "paul's number of cars should be 1" , 1, paul.getCars().size() );
mercedes.equandaUpdate(); // update to refresh data
- assertEquals( "mercedes's number of owners should be 2", 2, mercedes.getOwners().size() );
+ assertEquals( "mercedes's number of owners should be 2" , 2, mercedes.getOwners().size() );
bmw.equandaUpdate(); // update to refresh data
- assertEquals( "bmw's number of owners should be 1", 1, bmw.getOwners().size() );
+ assertEquals( "bmw's number of owners should be 1" , 1, bmw.getOwners().size() );
nick.getCars().clear();
nick.equandaUpdate();
paul.getCars().clear();
paul.equandaUpdate();
- assertEquals( "nick's number of cars should be 0", 0, nick.getCars().size() );
- assertEquals( "paul's number of cars should be 0", 0, paul.getCars().size() );
+ assertEquals( "nick's number of cars should be 0" , 0, nick.getCars().size() );
+ assertEquals( "paul's number of cars should be 0" , 0, paul.getCars().size() );
mercedes.equandaUpdate(); // update to refresh data
- assertEquals( "mercedes's number of owners should be 0", 0, mercedes.getOwners().size() );
+ assertEquals( "mercedes's number of owners should be 0" , 0, mercedes.getOwners().size() );
bmw.equandaUpdate(); // update to refresh data
- assertEquals( "bmw's number of owners should be 0", 0, bmw.getOwners().size() );
+ assertEquals( "bmw's number of owners should be 0" , 0, bmw.getOwners().size() );
}
public void test11Link()
@@ -106,25 +106,28 @@
pass.equandaUpdate();
joe.setPassport( pass );
joe.equandaUpdate();
- assertEquals( "There should be a bidirectional link, thus equal uoids: ", joe.getId(),
+ assertEquals( "There should be a bidirectional link, thus equal uoids: " , joe.getId(),
pass.getOwner().getId() );
- assertEquals( "There should be a bidirectional link, thus equal uoids: ", pass.getId(),
+ assertEquals( "There should be a bidirectional link, thus equal uoids: " , pass.getId(),
joe.getPassport().getId() );
joe.setPassport( null );
joe.equandaUpdate();
- assertNull( "The link should be null: ", joe.getPassport() );
- assertNull( "The link should be null: ", pass.getOwner() );
+ assertNull( "The link should be null: " , joe.getPassport() );
+ pass.equandaUpdate();
+ assertNull( "The link should be null: " , pass.getOwner() );
// now check the other side
pass.setOwner( joe );
pass.equandaUpdate();
- assertEquals( "There should be a bidirectional link, thus equal uoids: ", joe.getId(),
- pass.getOwner().getId() );
- assertEquals( "There should be a bidirectional link, thus equal uoids: ", pass.getId(),
+ joe.equandaUpdate();
+ assertEquals( "There should be a bidirectional link, thus equal uoids: " , pass.getId(),
joe.getPassport().getId() );
+ assertEquals( "There should be a bidirectional link, thus equal uoids: " , joe.getId(),
+ pass.getOwner().getId() );
pass.setOwner( null );
pass.equandaUpdate();
- assertNull( "The link should be null: ", joe.getPassport() );
- assertNull( "The link should be null: ", pass.getOwner() );
+ assertNull( "The link should be null: " , pass.getOwner() );
+ joe.equandaUpdate();
+ assertNull( "The link should be null: " , joe.getPassport() );
}
public void test1NLink()
@@ -142,7 +145,7 @@
mercedes.equandaUpdate(); // need to update as it has changed (thanks to change in george)
mercedes.getFans().add( mike );
mercedes.equandaUpdate();
- assertEquals( "number of fans should be 2", 2, mercedes.getFans().size() );
+ assertEquals( "number of fans should be 2" , 2, mercedes.getFans().size() );
for ( Owner fan : mercedes.getFans() )
{
if ( fan.getId().equals( george.getId() ) )
@@ -159,57 +162,41 @@
public void testNotOwnerLink()
throws Exception
{
- /*
- if we set a value to the not owner side of a link then the set must be done on the owner side
- and then also the owner side mediator must be called
- */
+ /* if we set a value to the not owner side of a link then the set must be done on the owner side */
Remove2 r = Remove2.equandaCreate();
- r.setTheString( LinkableMediator.REMOVE2_NOT_ALOWED_STRING_TO_ADD );
+ r.setTheString( LinkableMediator.REMOVE2_NOT_ALLOWED_STRING_TO_ADD );
r.equandaUpdate();
Remove2 r2 = Remove2.equandaCreate();
- r2.setTheString( LinkableMediator.REMOVE2_NOT_ALOWED_STRING_TO_REMOVE );
+ r2.setTheString( LinkableMediator.REMOVE2_NOT_ALLOWED_STRING_TO_REMOVE );
r2.equandaUpdate();
Linkable l = Linkable.equandaCreate();
l.equandaUpdate();
- // try to make the set through asingle field (other side is single)
- try
- {
- r.setField1Bidirectional( l );
- r.equandaUpdate();
- fail( "the set should not be accepted" );
- }
- catch ( Exception e )
- {/*expected*/}
+ // try to make the set through a single field (other side is single)
+ r.setField1Bidirectional( l );
+ r.equandaUpdate();
+ l.equandaUpdate();
+ assertEquals( r.getId(), l.getSingleBidirectional().getId() );
+
// try to make the set through a multiple field (other side is single)
- try
- {
- r.getCallLinkableFacade().add( l );
- r.equandaUpdate();
- fail( "the add should not be accepted" );
- }
- catch ( Exception e )
- {/*expected*/}
+ r.getCallLinkableFacade().add( l );
+ r.equandaUpdate();
+ l.equandaUpdate();
+ assertEquals( r.getId(), l.getOtherSideCallFacade().getId() );
+
// try to make the set through a multiple field (other side is multiple)
- try
- {
- r.getCallLinkableFacade2().add( l );
- r.equandaUpdate();
- fail( "the add should not be accepted" );
- }
- catch ( Exception e )
- {/*expected*/}
+ r.getCallLinkableFacade2().add( l );
+ r.equandaUpdate();
+ l.equandaUpdate();
+ assertEquals( r.getId(), l.getOtherSideCallFacadeMultiple().iterator().next().getId() );
r2.getCallLinkableFacade2().add( l );
r2.equandaUpdate();
- try
- {
- r2.getCallLinkableFacade2().remove( l );
- r2.equandaUpdate();
- fail( "the remove should not be accepted" );
- }
- catch ( Exception e )
- {/*expected*/}
+ r2.getCallLinkableFacade2().remove( l );
+ r2.equandaUpdate();
+ assertEquals( 0, r2.getCallLinkableFacade2().size() );
+ l.equandaUpdate();
+ assertEquals( 1, l.getOtherSideCallFacadeMultiple().size() );
}
}
\ No newline at end of file
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java 2009-06-19 06:19:14 UTC (rev 1129)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java 2009-06-19 15:55:26 UTC (rev 1130)
@@ -392,6 +392,7 @@
assertTrue( owner.getCarsWichHeLikes().isEmpty() );
// check for infinite updates
+ /* fails because version changed by indirect links...
owner.setPreferredCar( preferredCar );
ArrayList<Owner> owners = new ArrayList<Owner>();
owners.add( owner );
@@ -399,6 +400,7 @@
owner.equandaUpdate();
assertNotNull( owner.getPreferredCar() );
assertEquals( 1, preferredCar.getOwners().size() );
+ */
// clean up
owner.getPreferredCar().removeEntityBean();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-19 06:19:41
|
Revision: 1129
http://equanda.svn.sourceforge.net/equanda/?rev=1129&view=rev
Author: triathlon98
Date: 2009-06-19 06:19:14 +0000 (Fri, 19 Jun 2009)
Log Message:
-----------
EQ-130 fix two linktests (16 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
Removed Paths:
-------------
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/EquandaRoleMediator.java
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-17 12:41:42 UTC (rev 1128)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-19 06:19:14 UTC (rev 1129)
@@ -51,15 +51,29 @@
#if( $field.isMultiple() )
errorField = "$field.Name";
Collection<$fieldtype> al = proxy.${field.VarName};
- if ( al == null || al.isEmpty() )
+ if ( al == null ) al = new ArrayList<$fieldtype>();
+#* if ( al == null || al.isEmpty() )
{
Collection<$fieldtype2> fvl = spec.get${field.Name}();
#if( $field.isEmbedded() || !$field.isLink())
for ( $fieldtype2 rem : fvl ) em.remove( rem );
#end
+#if( $field.isLink() && $field.isBidirectional() )
+ for ( $fieldtype2 rem : fvl )
+ {
+ DM${field.LinkTableName} link = em.find( DM${field.LinkTableName}.class, ito.getId() );
+ // before updating the bidir proxy set the bidir link in case this is required
+ #if ($field.linkField.isMultiple())
+ link.get${field.linkField.Name}().add( spec );
+ #else
+ link.set${field.linkField.Name}( spec );
+ #end
+ }
+#end
fvl.clear();
}
else
+*#
{
Collection<$fieldtype2> last = spec.get${field.Name}();
for ( $fieldtype ito : al )
@@ -81,7 +95,7 @@
{
ito.equandaUpdate();
}
- #if ($field.isBidirectional())
+ #if( $field.isBidirectional() )
DM${field.LinkTableName} link = em.find( DM${field.LinkTableName}.class, ito.getId() );
// before updating the bidir proxy set the bidir link in case this is required
#if ($field.linkField.isMultiple())
@@ -160,7 +174,13 @@
if ( ro != null && ro.getId() != null )
{
DM${field.LinkTableName} item = em.find( DM${field.LinkTableName}.class, ro.getId() );
+#if( $field.isOwner() || !$field.isBidirectional() )
spec.get${field.Name}().remove( item );
+#elseif( $field.LinkField.isMultiple() )
+ item.get${field.LinkField.Name}().remove( spec );
+#else
+ item.set${field.LinkField.Name}( null );
+#end
#if( $field.isEmbedded() )
em.remove( item );
#end
Deleted: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/EquandaRoleMediator.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/EquandaRoleMediator.java 2009-06-17 12:41:42 UTC (rev 1128)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/EquandaRoleMediator.java 2009-06-19 06:19:14 UTC (rev 1129)
@@ -1,260 +0,0 @@
-/**
- * This file is part of the equanda project.
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
- * ANY KIND, either express or implied. See the License for the specific language governing rights and
- * limitations under the License.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- */
-
-package org.equanda.test.dm.server;
-
-import org.equanda.client.EquandaException;
-import org.equanda.test.TestExceptionCodes;
-
-
-/**
- * Mediator for EquandaRole. Implementation for functions mergeRights & mergeRestrictions
- *
- * @author NetRom team
- */
-public class EquandaRoleMediator
- //extends EquandaRoleMediatorBase
- //implements TestExceptionCodes
-{
- private org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger( getClass() );
-
- public void mergeRestrictions( String mergeName, String resultName )
- throws EquandaException
- {
- //mergeRoles( mergeName, resultName, true );
- }
-
- public void mergeRights( String mergeName, String resultName )
- throws EquandaException
- {
- //mergeRoles( mergeName, resultName, false );
- }
-
- /*
- private void mixRights( Collection<EquandaRight> col1, Collection<EquandaRight> col2,
- Collection<EquandaRight> result, boolean restrict )
- throws EquandaException
- {
- for ( EquandaRight right1 : col1 )
- {
- boolean found = false;
- for ( EquandaRight right2 : col2 )
- {
- // for rights existing in both roles, mix them, depending on the value of restrict
-
- if ( right1.getIdentifier().equals( right2.getIdentifier() ) )
- {
- if ( !right1.getEquandaType().equals( right2.getEquandaType() ) )
- {
- throw new EquandaException( EPE_SAME_IDENTIFIER_USED_FOR_EDIT_AND_RUN_ACCESS );
- }
- if ( right1.getEquandaType().equals( "EDIT" ) )
- {
- if ( right1.getEditAccess().equals( right2.getEditAccess() ) )
- {
- result.add( copy( right1 ) );
- break;
- }
- }
- if ( right1.getEquandaType().equals( "RUNN" ) )
- {
- if ( right1.getRunAccess().equals( right2.getRunAccess() ) )
- {
- result.add( copy( right1 ) );
- break;
- }
- }
- if ( restrict )
- {
- if ( right1.getEquandaType().equals( "EDIT" ) )
- {
- if ( right1.getEditAccess().equals( EditableRights.NONE ) ||
- right2.getEditAccess().equals( EditableRights.NONE ) )
- {
- result.add(
- right1.getEditAccess().equals( EditableRights.NONE )
- ? copy( right1 )
- : copy( right2 ) );
- found = true;
- break;
- }
- if ( right1.getEditAccess().equals( EditableRights.VIEW ) ||
- right2.getEditAccess().equals( EditableRights.VIEW ) )
- {
- result.add(
- right1.getEditAccess().equals( EditableRights.VIEW )
- ? copy( right1 )
- : copy( right2 ) );
- found = true;
- break;
- }
- // EDITABLE_ACCESS_EDIT is not saved
- found = true;
- break;
- }
- if ( right1.getEquandaType().equals( "RUNN" ) )
- {
- if ( right1.getRunAccess().equals( RunnableRights.NONE ) ||
- right2.getRunAccess().equals( RunnableRights.NONE ) )
- {
- result.add(
- right1.getRunAccess().equals( RunnableRights.NONE ) ? copy( right1 ) : copy(
- right2 ) );
- found = true;
- break;
- }
-
- // RunnableRights.RUN is not saved
- found = true;
- break;
- }
- }
- else
- {
- if ( right1.getEquandaType().equals( "EDIT" ) )
- {
- if ( right1.getEditAccess().equals( EditableRights.EDIT ) ||
- right2.getEditAccess().equals( EditableRights.EDIT ) )
- {
- found = true;
- break;
- }
- if ( right1.getEditAccess().equals( EditableRights.VIEW ) ||
- right1.getEditAccess().equals( EditableRights.VIEW ) )
- {
- result.add(
- right1.getEditAccess().equals( EditableRights.VIEW )
- ? copy( right1 )
- : copy( right2 ) );
- found = true;
- break;
- }
- result.add( copy( right1 ) );
- found = true;
- break;
- }
- if ( right1.getEquandaType().equals( "RUNN" ) )
- {
- if ( right1.getRunAccess().equals( RunnableRights.RUN ) ||
- right2.getRunAccess().equals( RunnableRights.RUN ) )
- {
- found = true;
- break;
- }
-
- result.add( copy( right1 ) );
- found = true;
- break;
- }
- }
- }
- }
- // if restrict, copy all restrictions which are in col1 and not in col2
- if ( restrict )
- {
- if ( !found )
- {
- result.add( copy( right1 ) );
- }
- }
- }
-
- // if restrict, copy all restrictions which are in col2 and not in col1
-
- if ( restrict )
- {
- for ( EquandaRight right1 : col2 )
- {
- boolean found = false;
- for ( EquandaRight right2 : col1 )
- {
- if ( right1.getIdentifier().equals( right2.getIdentifier() ) )
- {
- if ( !right1.getEquandaType().equals( right2.getEquandaType() ) )
- {
- throw new EquandaException( EPE_SAME_IDENTIFIER_USED_FOR_EDIT_AND_RUN_ACCESS );
- }
- found = true;
- break;
- }
- }
- if ( !found )
- {
- result.add( copy( right1 ) );
- }
- }
- } // if restrict
- }
-
- private EquandaRight copy( EquandaRight src ) throws EquandaException
- {
- EquandaRight ret = new EquandaRight();
- ret.setEquandaType( src.getEquandaType() );
- ret.setIdentifier( src.getIdentifier() );
- ret.setRunAccess( src.getRunAccess() );
- ret.setEditAccess( src.getEditAccess() );
- return ret;
- }
-
- private void mergeRoles( String mergeName, String resultName, boolean restrict )
- throws EquandaException
- {
- if ( resultName == null )
- {
- log.error( "Cannot merge roles, resultName must be a name for a new role, not null" );
- throw new EquandaException( EPE_RESULTNAME_CANNOT_BE_NULL );
- }
- if ( mergeName == null )
- {
- log.error( "mergeName must be the name of an existing role, not null" );
- throw new EquandaException( EPE_MERGENAME_MUST_EXIST_CANNOT_BE_NULL );
- }
- try
- {
- EquandaRoleSelectorEJB sel = EquandaGlobal.getEquandaRoleSelector();
- EquandaRole mergeVal = sel.selectRole( mergeName );
- sel.remove();
- if ( mergeVal == null )
- {
- log.error( "role " + mergeName + " not found" );
- throw new EquandaException( EPE_ROLE_NOT_FOUND, mergeName );
- }
- Collection<EquandaRight> mergeRights = mergeVal.getRights();
- Collection<EquandaRight> ourRights = object.getEquanda().getRights();
-
- ArrayList<EquandaRight> result = new ArrayList<EquandaRight>();
- mixRights( ourRights, mergeRights, result, restrict );
- EquandaRole resultProxy = new EquandaRole();
- resultProxy.setRoleName( resultName );
- resultProxy.setRights( result );
- resultProxy.equandaUpdate();
- }
- catch ( Exception e )
- {
- log.error( "error merging roles", e );
- throw new EquandaException( e );
- }
- }
- */
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-17 14:18:32
|
Revision: 1128
http://equanda.svn.sourceforge.net/equanda/?rev=1128&view=rev
Author: triathlon98
Date: 2009-06-17 12:41:42 +0000 (Wed, 17 Jun 2009)
Log Message:
-----------
EQ-130 fix EquandaQuery tests (18 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/EquandaQueryTest.java
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/EquandaQueryTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/EquandaQueryTest.java 2009-06-17 11:33:57 UTC (rev 1127)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/EquandaQueryTest.java 2009-06-17 12:41:42 UTC (rev 1128)
@@ -96,7 +96,7 @@
query.setTypeFilter( new VehicleType() );
assertEquals( 3, selector.selectEquanda( query ).size() );
query.setTypeFilter( new VehicleWithWheelsType() );
- assertEquals( 2, selector.selectEquanda( query ).size() );
+ assertEquals( 1, selector.selectEquanda( query ).size() );
// check limit
query.setTypeFilter( null ); // no filter
@@ -127,6 +127,8 @@
query.setParameter( "speed", 200 );
assertEquals( 1, selector.selectEquanda( query ).size() );
query.setParameter( "speed", 300 );
+ assertEquals( 0, selector.selectEquanda( query ).size() );
+ query.setTypeFilter( null );
assertEquals( 1, selector.selectEquanda( query ).size() );
}
finally
@@ -267,40 +269,15 @@
EquandaQueryImpl query = new EquandaQueryImpl( "SELECT o FROM DMVehicle o WHERE o.colourCode = 1" );
List<Vehicle> coll = selector.selectEquanda( query );
assertEquals( 6, coll.size() );
-
- // check collection when results are altered
- int count = 0;
- try
- {
- for ( Vehicle veh : selector.selectEquanda( query ) )
- {
- veh.setColourCode( 5 );
- count++;
- }
- fail( "Lazy collection should be modified " + count );
- }
- catch ( ConcurrentModificationException cme )
- {
- assertEquals( count, 5 );
- }
-
- query = new EquandaQueryImpl( "SELECT o FROM DMVehicle o WHERE o.speed = 100" );
- try
- {
- coll = selector.selectEquanda( query );
- for ( Vehicle aColl : coll ) aColl.setSpeed( 110 );
- fail( "Lazy collection should be modified" );
- }
- catch ( ConcurrentModificationException cme ) {}
}
finally
{
- if ( val1 != null && val1.getId() != null ) selector.removeEntityBean( val1.getId() );
- if ( val2 != null && val2.getId() != null ) selector.removeEntityBean( val2.getId() );
- if ( val3 != null && val3.getId() != null ) selector.removeEntityBean( val3.getId() );
- if ( val4 != null && val4.getId() != null ) selector.removeEntityBean( val4.getId() );
- if ( val5 != null && val5.getId() != null ) selector.removeEntityBean( val5.getId() );
- if ( val6 != null && val6.getId() != null ) selector.removeEntityBean( val6.getId() );
+ if ( val1.getId() != null ) selector.removeEntityBean( val1.getId() );
+ if ( val2.getId() != null ) selector.removeEntityBean( val2.getId() );
+ if ( val3.getId() != null ) selector.removeEntityBean( val3.getId() );
+ if ( val4.getId() != null ) selector.removeEntityBean( val4.getId() );
+ if ( val5.getId() != null ) selector.removeEntityBean( val5.getId() );
+ if ( val6.getId() != null ) selector.removeEntityBean( val6.getId() );
}
}
@@ -321,7 +298,7 @@
car2.setBrand( "UpdateQueryB" );
car2.equandaUpdate();
- // delete old records (shoulld keep car2
+ // delete old records (should keep car2)
EquandaQueryImpl query = new EquandaQueryImpl( "delete from DMCar o where o.brand <= :brand" );
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put( "brand", car1.getBrand() );
@@ -331,20 +308,15 @@
// verify that car1 is deleted and car2 is still available
Car check;
- check = sel.selectId( car2.getId() );
+ check = Car.selectId( car2.getId() );
assertNotNull( check );
assertEquals( car2.getBrand(), check.getBrand() );
// verify that car1 is deleted
- try
- {
- sel.selectId( car1.getId() );
- fail( "car1 should have been deleted" );
- }
- catch ( EquandaException upe ) {}
+ check = sel.selectId( car1.getId() );
+ assertNull( "car1 should have been deleted", check );
car2.removeEntityBean();
-
sel.remove();
}
@@ -377,13 +349,8 @@
assertNotNull( check );
assertEquals( car2.getBrand(), check.getBrand() );
- // verify that car1 is deleted
- try
- {
- sel.selectId( car1.getId() );
- fail( "car1 should have been deleted" );
- }
- catch ( EquandaException upe ) {}
+ check = sel.selectId( car1.getId() );
+ assertNull( "car1 should have been deleted", check );
car2.removeEntityBean();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-17 11:34:01
|
Revision: 1127
http://equanda.svn.sourceforge.net/equanda/?rev=1127&view=rev
Author: triathlon98
Date: 2009-06-17 11:33:57 +0000 (Wed, 17 Jun 2009)
Log Message:
-----------
EQ-130 fix default auto (22 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObject.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/ymport/ImportTest.java
branches/EQ-130/equanda-util/src/main/java/org/equanda/util/ymport/ImportUtil.java
Added Paths:
-----------
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/HTDefault.java
Removed Paths:
-------------
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/DefaultMediator.java
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-16 13:00:32 UTC (rev 1126)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-17 11:33:57 UTC (rev 1127)
@@ -141,17 +141,18 @@
#set( $fieldtype=$field.JavaEntityType )
#if( !$field.isLink() && $field.isMultiple() ) #set( $fieldtype="${package}.server.pm.DM${table.Name}_${field.Name}" )#end
#set( $value = "new java.util.ArrayList<$fieldtype>()" )
-#if( $field.isAuto() )
+#if( $field.isAuto() || $field.isDefaultAuto() )
#set( $value = "ht.auto${field.Name}()" )
#end
set${field.Name}( $value ); // no default values allowed just yet
#elseif( $field.isLink() ) ##isSingle
#set( $value = "null" )
-#if( $field.isAuto() )
+#if( $field.isAuto() || $field.isDefaultAuto() )
#set( $value = "ht.auto${field.Name}()" )
#end
set${field.Name}( $value ); // no default values allowed just yet
#else## is single and !link
+// $field.Name, auto $field.isAuto(), defaultAuto $field.isDefaultAuto()
#set( $value="0" )
#if( $field.isString() || $field.isDate() || $field.isTimestamp() || $field.isBlob() || $field.isClob() ) #set( $value="null" )
#elseif( $field.isBoolean() ) #set( $value="false" ) #end
@@ -172,7 +173,7 @@
throw new RuntimeException ("cannot load class $field.Default");
}
#end ##default class
-#if( $field.isAuto() )
+#if( $field.isAuto() || $field.isDefaultAuto() )
#set( $value = "ht.auto${field.Name}()" )
#end
set${field.Name}( $value );
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObject.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObject.java.vm 2009-06-16 13:00:32 UTC (rev 1126)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObject.java.vm 2009-06-17 11:33:57 UTC (rev 1127)
@@ -55,7 +55,7 @@
#if( $field.isLink() ) #set( $fieldtype="${field.JavaEntityType}" ) #end
#if( !$field.isMultiple() )
-#if( $field.isAuto() )
+#if( $field.isAuto() || $field.isDefaultAuto() )
public $fieldtype auto${field.Name}() throws EquandaException {
// @todo implementation to be provided
#set( $value="0" )
@@ -84,7 +84,7 @@
#end
#else
-#if( $field.isAuto() )
+#if( $field.isAuto() || $field.isDefaultAuto() )
public Collection auto${field.Name}() throws EquandaException {
// @todo implementation to be provided
return new ArrayList();
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm 2009-06-16 13:00:32 UTC (rev 1126)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm 2009-06-17 11:33:57 UTC (rev 1127)
@@ -114,7 +114,7 @@
#if( $field.isLink() ) #set( $fieldtype="${field.JavaEntityType}" ) #end
#if( !$field.isMultiple() )
-#if( $field.isAuto() )
+#if( $field.isAuto() || $field.isDefaultAuto() )
public abstract $fieldtype auto${field.Name}() throws EquandaException;
#end
@@ -123,7 +123,7 @@
#end
#else
-#if( $field.isAuto() )
+#if( $field.isAuto() || $field.isDefaultAuto() )
public abstract Collection auto${field.Name}() throws EquandaException;
#end
Deleted: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/DefaultMediator.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/DefaultMediator.java 2009-06-16 13:00:32 UTC (rev 1126)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/DefaultMediator.java 2009-06-17 11:33:57 UTC (rev 1127)
@@ -1,48 +0,0 @@
-/**
- * This file is part of the equanda project.
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
- * ANY KIND, either express or implied. See the License for the specific language governing rights and
- * limitations under the License.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- */
-
-package org.equanda.test.dm.server;
-
-import org.equanda.client.EquandaException;
-
-/**
- * Overwritten function autoTestIntDefaultAuto, to return -1
- * This is assumed in the testcase DefaultTest.
- * The purpose is to test the functionality of default type=auto for fields
- *
- * mediator object to allow specific functionality depending on object equandaType
- * this class is intended to be modified manually (not overwritten when created)
- * only protected methods should be overwritten, class private methods should not be touched!
- *
- * @author NetRom team
- */
-public class DefaultMediator
- //extends DefaultMediatorBase
-{
- protected int autoTestIntDefaultAuto()
- throws EquandaException
- {
- return -1;
- }
-}
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/HTDefault.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/HTDefault.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/HTDefault.java 2009-06-17 11:33:57 UTC (rev 1127)
@@ -0,0 +1,38 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.dm.server;
+
+import org.equanda.client.EquandaException;
+
+/** Table level helper class for Default.table */
+public class HTDefault
+ extends HTDefaultBase
+{
+ public int autoTestIntDefaultAuto()
+ throws EquandaException
+ {
+ return -1;
+ }
+}
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/ymport/ImportTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/ymport/ImportTest.java 2009-06-16 13:00:32 UTC (rev 1126)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/ymport/ImportTest.java 2009-06-17 11:33:57 UTC (rev 1127)
@@ -609,7 +609,7 @@
public void testDefaultUpdateFields()
throws Exception
{
- String brand = "Test Brand";
+ String brand = "ImportTest Brand";
String extra = "extra info";
String lines[] = {
@@ -626,14 +626,12 @@
assertNull( ImportUtil.importStrings( updateLines, URL, getImportCredentials() ) );
// verify import
- CarSelectorEJB carSelector = EquandaGlobal.getCarSelector();
- Car car = carSelector.selectBrand( brand );
+ Car car = Car.selectBrand( brand );
assertNotNull( car );
assertEquals( " update should have set Extra ", car.getExtra(), extra );
// clean
car.removeEntityBean();
- carSelector.remove();
}
/*
@@ -642,7 +640,7 @@
public void testDefaultIdUpdateFields()
throws Exception
{
- String brand = "Test Brand 2";
+ String brand = "ImportTest Brand";
String extra = "extra info 2";
String lines[] = {
@@ -650,8 +648,7 @@
ImportUtil.quote( brand )
};
assertNull( ImportUtil.importStrings( lines, URL, getImportCredentials() ) );
- CarSelectorEJB carSelector = EquandaGlobal.getCarSelector();
- Car car = carSelector.selectBrand( brand );
+ Car car = Car.selectBrand( brand );
Uoid uoid = car.getId();
// update the previous car and add extra ( using selectIdValue selector )
String updateLines[] = {
@@ -661,14 +658,13 @@
assertNull( ImportUtil.importStrings( updateLines, URL, getImportCredentials() ) );
// verify import
- Car carProxy = carSelector.selectId( uoid );
+ Car carProxy = Car.selectId( uoid );
assertNotNull( carProxy );
assertEquals( " should have Brand set ", car.getBrand(), brand );
assertEquals( " update should have set Extra ", car.getExtra(), extra );
// clean
car.removeEntityBean();
- carSelector.remove();
}
/*
@@ -678,7 +674,7 @@
public void testSelectorWithImmutableParams()
throws Exception
{
- String brand = "Test Brand to update";
+ String brand = "ImportTest Brand";
String extra = "extra";
String lines[] = {
@@ -693,13 +689,11 @@
assertNull( ImportUtil.importStrings( lines, URL, getImportCredentials() ) );
// check the record looks ok
- CarSelectorEJB carSelector = EquandaGlobal.getCarSelector();
- Car car = carSelector.selectBrand( brand );
+ Car car = Car.selectBrand( brand );
assertEquals( extra, car.getExtra() );
// clean
car.removeEntityBean();
- carSelector.remove();
}
/*
@@ -709,7 +703,7 @@
public void testImmutableFields()
throws Exception
{
- String brand = "Test Brand to update";
+ String brand = "ImportTest Brand";
String extra = "extra";
String lines[] = {
@@ -724,12 +718,10 @@
assertNull( ImportUtil.importStrings( lines, URL, getImportCredentials() ) );
// check the record looks ok
- CarSelectorEJB carSelector = EquandaGlobal.getCarSelector();
- Car car = carSelector.selectBrand( brand );
+ Car car = Car.selectBrand( brand );
assertEquals( extra, car.getExtra() );
// clean
car.removeEntityBean();
- carSelector.remove();
}
}
Modified: branches/EQ-130/equanda-util/src/main/java/org/equanda/util/ymport/ImportUtil.java
===================================================================
--- branches/EQ-130/equanda-util/src/main/java/org/equanda/util/ymport/ImportUtil.java 2009-06-16 13:00:32 UTC (rev 1126)
+++ branches/EQ-130/equanda-util/src/main/java/org/equanda/util/ymport/ImportUtil.java 2009-06-17 11:33:57 UTC (rev 1127)
@@ -137,6 +137,7 @@
responseBody = post.getResponseBodyAsString();
post.releaseConnection();
+ System.out.println( "ImportUtil.importData res " + responseBody );
return responseBody.startsWith( "OK" ) ? null : responseBody;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-16 13:00:53
|
Revision: 1126
http://equanda.svn.sourceforge.net/equanda/?rev=1126&view=rev
Author: triathlon98
Date: 2009-06-16 13:00:32 +0000 (Tue, 16 Jun 2009)
Log Message:
-----------
EQ-130 fix issues with ProxyTest (23 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Field.java
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java
Added Paths:
-----------
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/HTAutoFields.java
Removed Paths:
-------------
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/AutoFieldsMediator.java
Modified: branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Field.java
===================================================================
--- branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Field.java 2009-06-15 22:30:41 UTC (rev 1125)
+++ branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Field.java 2009-06-16 13:00:32 UTC (rev 1126)
@@ -416,7 +416,7 @@
{
if ( !choice.isFromClass() && choice.getValue().length() > getLength() )
{
- err( "choice " + choice.getName() + " is too long for field" );
+ err( "choice " + choice.getName() + " is too long for field" );
}
}
}
@@ -1388,7 +1388,7 @@
return table;
}
- public void setOMTable( Table table )
+ public void setDmTable( Table table )
{
this.table = table;
}
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-15 22:30:41 UTC (rev 1125)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-16 13:00:32 UTC (rev 1126)
@@ -140,9 +140,17 @@
#if( $field.isMultiple() )
#set( $fieldtype=$field.JavaEntityType )
#if( !$field.isLink() && $field.isMultiple() ) #set( $fieldtype="${package}.server.pm.DM${table.Name}_${field.Name}" )#end
- set${field.Name}( new java.util.ArrayList<$fieldtype>() ); // no default values allowed just yet
+#set( $value = "new java.util.ArrayList<$fieldtype>()" )
+#if( $field.isAuto() )
+#set( $value = "ht.auto${field.Name}()" )
+#end
+ set${field.Name}( $value ); // no default values allowed just yet
#elseif( $field.isLink() ) ##isSingle
- set${field.Name}( null ); // no default values allowed just yet
+#set( $value = "null" )
+#if( $field.isAuto() )
+#set( $value = "ht.auto${field.Name}()" )
+#end
+ set${field.Name}( $value ); // no default values allowed just yet
#else## is single and !link
#set( $value="0" )
#if( $field.isString() || $field.isDate() || $field.isTimestamp() || $field.isBlob() || $field.isClob() ) #set( $value="null" )
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-15 22:30:41 UTC (rev 1125)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-16 13:00:32 UTC (rev 1126)
@@ -259,12 +259,47 @@
}
#macro( typefield $fld $type )
-#if( !$field.isCalculated() && $type.Type == $fld.TableType )
+#set( $tfset = false )
+#set( $tftbl = $type )
+#if( $tftbl.Type == $fld.TableType )
+#set( $tfset = true )
+#elseif( $tftbl.isInherited() )
+#set( $tftbl = $tftbl.ParentTable )
+#if( $tftbl.Type == $fld.TableType )
+#set( $tfset = true )
+#elseif( $tftbl.isInherited() )
+#set( $tftbl = $tftbl.ParentTable )
+#if( $tftbl.Type == $fld.TableType )
+#set( $tfset = true )
+#elseif( $tftbl.isInherited() )
+#set( $tftbl = $tftbl.ParentTable )
+#if( $tftbl.Type == $fld.TableType )
+#set( $tfset = true )
+#elseif( $tftbl.isInherited() )
+#set( $tftbl = $tftbl.ParentTable )
+#if( $tftbl.Type == $fld.TableType )
+#set( $tfset = true )
+#elseif( $tftbl.isInherited() )
+#set( $tftbl = $tftbl.ParentTable )
+#if( $tftbl.Type == $fld.TableType )
+#set( $tfset = true )
+#elseif( $tftbl.isInherited() )
+#set( $tftbl = $tftbl.ParentTable )
+#if( $tftbl.Type == $fld.TableType )
+#set( $tfset = true )
+#end
+#end
+#end
+#end
+#end
+#end
+#end
+#if( !$fld.isCalculated() && $tfset )
, spec.get${field.Name}()
#else
-#if( $field.isInt() || $field.isDouble() )
+#if( $fld.isInt() || $fld.isDouble() )
, 0
-#elseif( $field.isBoolean() )
+#elseif( $fld.isBoolean() )
, false
#else
, null
Deleted: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/AutoFieldsMediator.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/AutoFieldsMediator.java 2009-06-15 22:30:41 UTC (rev 1125)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/AutoFieldsMediator.java 2009-06-16 13:00:32 UTC (rev 1126)
@@ -1,78 +0,0 @@
-/**
- * This file is part of the equanda project.
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
- * ANY KIND, either express or implied. See the License for the specific language governing rights and
- * limitations under the License.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- */
-
-package org.equanda.test.dm.server;
-
-import org.equanda.client.EquandaException;
-import org.equanda.test.TestExceptionCodes;
-import org.equanda.test.dm.client.constants.PassportConstants;
-//import org.equanda.test.dm.server.pm.DMAutoFields_MultipleAutoBean;
-//import org.equanda.test.dm.server.pm.DMPassportBean;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * mediator object to overwrite functions for auto fields
- *
- * @author NetRom team
- */
-public class AutoFieldsMediator
- //extends AutoFieldsMediatorBase
- implements TestExceptionCodes
-{
- /*
- protected int autoAutoInt()
- throws EquandaException
- {
- return 0;
- }
-
- protected Collection<DMAutoFields_MultipleAutoBean> autoMultipleAuto()
- throws EquandaException
- {
- ArrayList<DMAutoFields_MultipleAutoBean> array = new ArrayList<DMAutoFields_MultipleAutoBean>();
-
- DMAutoFields_MultipleAutoBean obj = new DMAutoFields_MultipleAutoBean();
- try
- {
- obj.setMultipleAuto( "test" );
- }
- catch ( Exception e )
- {
- throw new EquandaException( EPE_PROBLEM_IN_AUTOMULTIPLEAUTO, e );
- }
- array.add( obj );
- return array;
- }
-
- protected Collection<DMPassportBean> autoMultiplePassport()
- throws EquandaException
- {
- ArrayList<DMPassportBean> array = new ArrayList<DMPassportBean>();
- array.add( new DMPassportBean( PassportConstants.TYPE_Passport ) );
- return array;
- }
- */
-}
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/HTAutoFields.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/HTAutoFields.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/HTAutoFields.java 2009-06-16 13:00:32 UTC (rev 1126)
@@ -0,0 +1,79 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.dm.server;
+
+import org.equanda.client.EquandaException;
+import org.equanda.test.TestExceptionCodes;
+import org.equanda.test.dm.client.constants.PassportConstants;
+import org.equanda.test.dm.server.pm.DMAutoFields_MultipleAuto;
+import org.equanda.test.dm.server.pm.DMPassport;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * table level helper class for AutoFields
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class HTAutoFields
+ extends HTAutoFieldsBase
+{
+ public int autoAutoInt()
+ throws EquandaException
+ {
+ return 0;
+ }
+
+ public Collection<DMAutoFields_MultipleAuto> autoMultipleAuto()
+ throws EquandaException
+ {
+ ArrayList<DMAutoFields_MultipleAuto> array = new ArrayList<DMAutoFields_MultipleAuto>();
+
+ DMAutoFields_MultipleAuto obj = new DMAutoFields_MultipleAuto();
+ try
+ {
+ obj.setMultipleAuto( "test" );
+ }
+ catch ( Exception e )
+ {
+ throw new EquandaException( TestExceptionCodes.EPE_PROBLEM_IN_AUTOMULTIPLEAUTO, e );
+ }
+ array.add( obj );
+ return array;
+ }
+
+ public Collection<DMPassport> autoMultiplePassport()
+ throws EquandaException
+ {
+ ArrayList<DMPassport> array = new ArrayList<DMPassport>();
+ array.add( new DMPassport( "M" ) );
+ return array;
+ }
+
+ public DMPassport autoPassport()
+ throws EquandaException
+ { return null;}
+}
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java 2009-06-15 22:30:41 UTC (rev 1125)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ProxyTest.java 2009-06-16 13:00:32 UTC (rev 1126)
@@ -32,6 +32,7 @@
import java.sql.Date;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
/**
* JUnit tests for Proxies
@@ -96,9 +97,7 @@
assertNull( auto.getPassport() );
auto.equandaUpdate();
- AutoFieldsSelectorEJB sel = EquandaGlobal.getAutoFieldsSelector();
- auto = sel.selectId( auto.getId() );
- sel.remove();
+ auto = AutoFields.selectId( auto.getId() );
assertEquals( 1, auto.getMultipleAuto().size() );
assertEquals( "test", auto.getMultipleAuto().iterator().next() );
@@ -156,16 +155,16 @@
air.setEquandaType( "AIRP" );
air.setName( AIRPLANE_NAME );
air.setRadius( 10 );
- air.setSpeed( 300 );
+ air.setSpeed( 307 );
air.setSpanWidth( 15 );
air.equandaUpdate();
VehicleSelectorEJB sel = EquandaGlobal.getVehicleSelector();
- Collection col = sel.selectName( AIRPLANE_NAME );
- assertEquals( col.size(), 1 );
- Vehicle obj = (Vehicle) col.iterator().next();
+ List<Vehicle> list = Vehicle.selectName( AIRPLANE_NAME );
+ assertEquals( list.size(), 1 );
+ Vehicle obj = list.get( 0 );
assertEquals( 10, obj.getRadius() );
- assertEquals( 300, obj.getSpeed() );
+ assertEquals( 307, obj.getSpeed() );
assertEquals( 15.0, obj.getSpanWidth() );
sel.selectId( air.getId() ).removeEntityBean();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-15 22:30:54
|
Revision: 1125
http://equanda.svn.sourceforge.net/equanda/?rev=1125&view=rev
Author: triathlon98
Date: 2009-06-15 22:30:41 +0000 (Mon, 15 Jun 2009)
Log Message:
-----------
EQ-130 auto field provisions
Modified Paths:
--------------
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObject.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectRoot.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectSelectorBean.java.vm
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-15 14:02:59 UTC (rev 1124)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-15 22:30:41 UTC (rev 1125)
@@ -135,6 +135,7 @@
super( modifiedStatus );
#end
// initialise all CMP fields
+ HT${table.Name} ht = new HT${table.Name}();
#foreach( $field in $table.FieldsNotCalculated )
#if( $field.isMultiple() )
#set( $fieldtype=$field.JavaEntityType )
@@ -146,7 +147,7 @@
#set( $value="0" )
#if( $field.isString() || $field.isDate() || $field.isTimestamp() || $field.isBlob() || $field.isClob() ) #set( $value="null" )
#elseif( $field.isBoolean() ) #set( $value="false" ) #end
- #if( $field.hasDefault() && !$field.isAuto() )
+ #if( $field.hasDefault() )
{
#if( $field.isDefaultValue() )
#if( $field.isBlob() )
@@ -163,7 +164,9 @@
throw new RuntimeException ("cannot load class $field.Default");
}
#end ##default class
-
+#if( $field.isAuto() )
+#set( $value = "ht.auto${field.Name}()" )
+#end
set${field.Name}( $value );
}
#end ##default
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObject.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObject.java.vm 2009-06-15 14:02:59 UTC (rev 1124)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObject.java.vm 2009-06-15 22:30:41 UTC (rev 1125)
@@ -36,17 +36,11 @@
package ${package}.server;
import ${package}.client.*;
-import org.equanda.persistence.ObjectType;
-import org.equanda.persistence.query.EquandaQuery;
-import org.equanda.persistence.query.EquandaQueryImpl;
-import org.equanda.persistence.Uoid;
-import org.equanda.persistence.ObjectSelector;
-import org.equanda.persistence.SelectorsState;
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
+import ${package}.server.pm.*;
+import org.equanda.client.EquandaException;
+
import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.util.Collection;
/**
* Helper class for $table.Name
@@ -55,4 +49,49 @@
public class HT${table.Name}
extends HT${table.Name}Base
{
+#foreach( $field in $table.Fields )
+#if( $field.Table == $table.Name )
+#set( $fieldtype=$field.JavaFieldType )
+#if( $field.isLink() ) #set( $fieldtype="${field.JavaEntityType}" ) #end
+#if( !$field.isMultiple() )
+
+#if( $field.isAuto() )
+ public $fieldtype auto${field.Name}() throws EquandaException {
+ // @todo implementation to be provided
+ #set( $value="0" )
+ #if( $field.isString() || $field.isDate() || $field.isTimestamp() || $field.isLink() ) #set( $value="null" )
+ #elseif( $field.isBoolean() ) #set( $value="false" )
+ #end
+ #if( $field.hasDefault() )
+ #set( $value=$field.Default )
+ #end
+ return $value;
+ }
+#end
+
+#if( $field.isCalculated() )
+ public $fieldtype get${field.Name}( DM${table.Name} entity ) {
+ // @todo implementation to be provided
+ #set( $value="0" )
+ #if( $field.isString() || $field.isDate() || $field.isTimestamp() || $field.isLink() ) #set( $value="null" )
+ #elseif( $field.isBoolean() ) #set( $value="false" )
+ #end
+ #if( $field.hasDefault() )
+ #set( $value=$field.Default )
+ #end
+ return $value;
+ }
+#end
+
+#else
+#if( $field.isAuto() )
+ public Collection auto${field.Name}() throws EquandaException {
+ // @todo implementation to be provided
+ return new ArrayList();
+ }
+#end
+
+#end
+#end
+#end
}
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm 2009-06-15 14:02:59 UTC (rev 1124)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm 2009-06-15 22:30:41 UTC (rev 1125)
@@ -47,7 +47,7 @@
* Base helper class for $table.Name
* $table.Description
*/
-public class HT${table.Name}Base
+public abstract class HT${table.Name}Base
#if( $table.isInherited() )
extends HT${table.ParentTable.Name}
#else
@@ -108,4 +108,26 @@
super.equandaCheckRules( entity );
}
+#foreach( $field in $table.Fields )
+#if( $field.Table == $table.Name )
+#set( $fieldtype=$field.JavaFieldType )
+#if( $field.isLink() ) #set( $fieldtype="${field.JavaEntityType}" ) #end
+#if( !$field.isMultiple() )
+
+#if( $field.isAuto() )
+ public abstract $fieldtype auto${field.Name}() throws EquandaException;
+#end
+
+#if( $field.isCalculated() )
+ public abstract $fieldtype get${field.Name}( DM${table.Name} entity );
+#end
+
+#else
+#if( $field.isAuto() )
+ public abstract Collection auto${field.Name}() throws EquandaException;
+#end
+
+#end
+#end
+#end
}
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectRoot.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectRoot.java.vm 2009-06-15 14:02:59 UTC (rev 1124)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectRoot.java.vm 2009-06-15 22:30:41 UTC (rev 1125)
@@ -44,7 +44,7 @@
* Root helper class for $table.Name
* $table.Description
*/
-public class HT${table.Name}Root
+public abstract class HT${table.Name}Root
{
#foreach( $action in $table.Actions )
public $action.Return ${action.Name}( DM${table.Name} entity
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectSelectorBean.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectSelectorBean.java.vm 2009-06-15 14:02:59 UTC (rev 1124)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectSelectorBean.java.vm 2009-06-15 22:30:41 UTC (rev 1125)
@@ -389,8 +389,8 @@
public ${package}.client.${table.Name} equandaClone( String type, Uoid base ) throws EquandaException {
//DM${table.Name} base = HR${table.Name}.selectId( entityManager, base );
DM${table.Name} entity = getNewEntity( type );
- //setAutoFields(entity);
- //mediator.equandaClone( other );
+ //setAutoFields(entity); @todo
+ //mediator.equandaClone( other ); @todo
#parse("ObjectSelector-build.java.vm")
entityManager.flush(); // force save to have correct equandaModification and equandaStatus fields
return get( entity);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-15 14:11:10
|
Revision: 1124
http://equanda.svn.sourceforge.net/equanda/?rev=1124&view=rev
Author: triathlon98
Date: 2009-06-15 14:02:59 +0000 (Mon, 15 Jun 2009)
Log Message:
-----------
EQ-130 fix some ImmutableIf tests (28 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject-mutable.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ImmutableIfGlobalTest.java
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/ymport/ImportTest.java
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject-mutable.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject-mutable.java.vm 2009-06-14 21:38:02 UTC (rev 1123)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject-mutable.java.vm 2009-06-15 14:02:59 UTC (rev 1124)
@@ -34,24 +34,31 @@
*#
#if( $field.hasImmutableIf() )
#foreach( $ii in $field.ImmutableIf )
-#if( "x" != "x$!ii.FieldName" && $table.Name == $ii.Field.Table )
+#if( "x" != "x$!ii.FieldName" )
+#set( $iitarget = "" )
+#if( $table.Name != $ii.Field.Table )
+#set( $iitarget = "((DM${ii.Field.Table})this)." )
+ if ( this instanceof DM${ii.Field.Table} )
+ {
+#end
#if( $ii.Field.isBoolean() )
- if ( get${ii.FieldName}() )
+ if ( ${iitarget}get${ii.FieldName}() )
#elseif( $ii.Field.isMultiple() )
- if ( !get${ii.FieldName}().isEmpty() )
+ if ( !${iitarget}get${ii.FieldName}().isEmpty() )
#elseif( $ii.Field.isLink() || $ii.Field.isString() )
- if ( null != get${ii.FieldName}() )
+ if ( null != ${iitarget}get${ii.FieldName}() )
#else
- if ( 0 != get${ii.FieldName}() )
+ if ( 0 != ${iitarget}get${ii.FieldName}() )
#end
{
throw new EquandaConstraintViolation( ExceptionCodes.ECV_IMMUTABLE_IF_OTHER_FIELD_IS_SET, "field.${table.Name}.${field.Name}", "field.${table.Name}.${ii.Name}" );
}
-#else ## todo handle calculate for test
-// skipped, todo "x" != "x$!ii.FieldName" && $table.Name == $ii.Field.Table
+#if( $table.Name != $ii.Field.Table )
+ }
#end
#end
#end
+#end
#if( $field.hasMutableEvenIf() )
String exclude="";
#foreach( $ii in $field.MutableEvenIf )
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-14 21:38:02 UTC (rev 1123)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-15 14:02:59 UTC (rev 1124)
@@ -399,7 +399,6 @@
#set( $count = $count + 1 )
#end
this.${field.VarName} = ${field.VarName};
-
}
#else## field.isLink()
#set( $count = 0 )
@@ -421,18 +420,25 @@
#end
#if( $table.hasImmutableIf() )
#foreach( $ii in $table.ImmutableIf )
-#if( "x" != "x$!ii.FieldName" && $table.Name == $ii.Field.Table )
+#if( "x" != "x$!ii.FieldName" )
+#set( $iitarget = "" )
+#if( $table.Name != $ii.Field.Table )
+#set( $iitarget = "((DM${ii.Field.Table})this)." )
+ if ( this instanceof DM${ii.Field.Table} )
+ {
+#end
if ( exclude.indexOf( "|$ii.Name|" ) == -1 )
{
- if ( ${ii.Field.VarName} )
+ if ( ${iitarget}get${ii.FieldName}() )
{
throw new EquandaConstraintViolation( ExceptionCodes.ECV_IMMUTABLE_IF_OTHER_FIELD_IS_SET,
"field.${table.Name}."+field, "field.${table.Name}.${ii.Name}");
}
}
-#else ## todo handle calculate for test
-// skipped, todo "x" != "x$!ii.FieldName" && $table.Name == $ii.Field.Table $ii.Field
+#if( $table.Name != $ii.Field.Table )
+ }
#end
+#end
#end
#end
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ImmutableIfGlobalTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ImmutableIfGlobalTest.java 2009-06-14 21:38:02 UTC (rev 1123)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ImmutableIfGlobalTest.java 2009-06-15 14:02:59 UTC (rev 1124)
@@ -48,6 +48,7 @@
obj.equandaUpdate();
try
{
+ assertTrue( obj.getLocked() );
obj.setLocked( false );
obj.equandaUpdate();
fail( "can unlock 'Locked'" );
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/ymport/ImportTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/ymport/ImportTest.java 2009-06-14 21:38:02 UTC (rev 1123)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/ymport/ImportTest.java 2009-06-15 14:02:59 UTC (rev 1124)
@@ -677,7 +677,6 @@
*/
public void testSelectorWithImmutableParams()
throws Exception
-
{
String brand = "Test Brand to update";
String extra = "extra";
@@ -709,7 +708,6 @@
*/
public void testImmutableFields()
throws Exception
-
{
String brand = "Test Brand to update";
String extra = "extra";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-14 21:39:10
|
Revision: 1123
http://equanda.svn.sourceforge.net/equanda/?rev=1123&view=rev
Author: triathlon98
Date: 2009-06-14 21:38:02 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
EQ-130 fix some ImmutableIf tests (31 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Table.java
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject-mutable.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
branches/EQ-130/equanda-test/src/main/dm/ImmutableIfGlobal.table
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ImmutableIfGlobalTest.java
Modified: branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Table.java
===================================================================
--- branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Table.java 2009-06-14 20:55:21 UTC (rev 1122)
+++ branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Table.java 2009-06-14 21:38:02 UTC (rev 1123)
@@ -182,7 +182,6 @@
if ( createRootTable( dm ) == null ) return;
for ( Page page : getPages() ) page.handleRootTransformation( this );
- if ( constraints == null ) constraints = new Constraints();
isRootTransformed = true;
}
}
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject-mutable.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject-mutable.java.vm 2009-06-14 20:55:21 UTC (rev 1122)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject-mutable.java.vm 2009-06-14 21:38:02 UTC (rev 1123)
@@ -32,7 +32,6 @@
* Contributor(s):
* @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
*#
-// field $field.Name hasImmutableIf $field.hasImmutableIf() $field.ImmutableIf.size()
#if( $field.hasImmutableIf() )
#foreach( $ii in $field.ImmutableIf )
#if( "x" != "x$!ii.FieldName" && $table.Name == $ii.Field.Table )
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-14 20:55:21 UTC (rev 1122)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-14 21:38:02 UTC (rev 1123)
@@ -424,10 +424,10 @@
#if( "x" != "x$!ii.FieldName" && $table.Name == $ii.Field.Table )
if ( exclude.indexOf( "|$ii.Name|" ) == -1 )
{
- if ( get${ii.FieldName}() )
+ if ( ${ii.Field.VarName} )
{
throw new EquandaConstraintViolation( ExceptionCodes.ECV_IMMUTABLE_IF_OTHER_FIELD_IS_SET,
- "field.${table.Name}."+field+"", "field.${table.Name}.${ii.Name}");
+ "field.${table.Name}."+field, "field.${table.Name}.${ii.Name}");
}
}
#else ## todo handle calculate for test
Modified: branches/EQ-130/equanda-test/src/main/dm/ImmutableIfGlobal.table
===================================================================
--- branches/EQ-130/equanda-test/src/main/dm/ImmutableIfGlobal.table 2009-06-14 20:55:21 UTC (rev 1122)
+++ branches/EQ-130/equanda-test/src/main/dm/ImmutableIfGlobal.table 2009-06-14 21:38:02 UTC (rev 1123)
@@ -29,7 +29,7 @@
</constraints>
</field>
- <field name="Release" type="boolean"/>
+ <field name="Release" type="boolean" priority="4"/> <!-- set prio to force update before locked -->
<field name="Released" length="10">
<constraints>
<mutable-even-if field="Locked" when="Release"/>
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ImmutableIfGlobalTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ImmutableIfGlobalTest.java 2009-06-14 20:55:21 UTC (rev 1122)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/ImmutableIfGlobalTest.java 2009-06-14 21:38:02 UTC (rev 1123)
@@ -50,7 +50,7 @@
{
obj.setLocked( false );
obj.equandaUpdate();
- fail( "can unlock" );
+ fail( "can unlock 'Locked'" );
}
catch ( EquandaConstraintViolation ucv )
{ /* expected result */ }
@@ -67,7 +67,7 @@
{
obj.setName( "something" );
obj.equandaUpdate();
- fail( "locked field still mutable" );
+ fail( "locked field 'name' still mutable" );
}
catch ( EquandaConstraintViolation ucv )
{ /* expected result */ }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-14 20:56:20
|
Revision: 1122
http://equanda.svn.sourceforge.net/equanda/?rev=1122&view=rev
Author: triathlon98
Date: 2009-06-14 20:55:21 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
EQ-130 fix some ImmutableIf tests (31+1 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Constraints.java
branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Table.java
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject-mutable.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
Modified: branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Constraints.java
===================================================================
--- branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Constraints.java 2009-06-11 11:45:06 UTC (rev 1121)
+++ branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Constraints.java 2009-06-14 20:55:21 UTC (rev 1122)
@@ -114,7 +114,12 @@
}
}
}
- RootTable root = field.getDmTable().getRoot();
+ handleFieldsTransformation( dm, field.getDmTable().getRoot() );
+ }
+
+ private void handleFieldsTransformation( DomainModel dm, RootTable root )
+ {
+
for ( ImmutableIf ii : getImmutableIf() )
{
Field f = root.getField( ii.getFieldName() );
@@ -175,6 +180,7 @@
compare.setTableLevel( true );
}
}
+ handleFieldsTransformation( dm, table.getRoot() );
}
public void handleValidation( Parser parser )
Modified: branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Table.java
===================================================================
--- branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Table.java 2009-06-11 11:45:06 UTC (rev 1121)
+++ branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Table.java 2009-06-14 20:55:21 UTC (rev 1122)
@@ -183,7 +183,6 @@
if ( createRootTable( dm ) == null ) return;
for ( Page page : getPages() ) page.handleRootTransformation( this );
if ( constraints == null ) constraints = new Constraints();
- constraints.handleTransformation( dm, this );
isRootTransformed = true;
}
}
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject-mutable.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject-mutable.java.vm 2009-06-11 11:45:06 UTC (rev 1121)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject-mutable.java.vm 2009-06-14 20:55:21 UTC (rev 1122)
@@ -32,22 +32,24 @@
* Contributor(s):
* @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
*#
+// field $field.Name hasImmutableIf $field.hasImmutableIf() $field.ImmutableIf.size()
#if( $field.hasImmutableIf() )
#foreach( $ii in $field.ImmutableIf )
-#if( "x" != "x$!ii.Field" && $table.Name == $ii.Field.Table )
+#if( "x" != "x$!ii.FieldName" && $table.Name == $ii.Field.Table )
#if( $ii.Field.isBoolean() )
- if ( this.${ii.Field.VarName} )
+ if ( get${ii.FieldName}() )
#elseif( $ii.Field.isMultiple() )
- if ( !this.${ii.Field.VarName}.isEmpty() )
+ if ( !get${ii.FieldName}().isEmpty() )
#elseif( $ii.Field.isLink() || $ii.Field.isString() )
- if ( this.${ii.Field.VarName} != null )
+ if ( null != get${ii.FieldName}() )
#else
- if ( this.${ii.Field.VarName} != 0 )
+ if ( 0 != get${ii.FieldName}() )
#end
{
throw new EquandaConstraintViolation( ExceptionCodes.ECV_IMMUTABLE_IF_OTHER_FIELD_IS_SET, "field.${table.Name}.${field.Name}", "field.${table.Name}.${ii.Name}" );
}
#else ## todo handle calculate for test
+// skipped, todo "x" != "x$!ii.FieldName" && $table.Name == $ii.Field.Table
#end
#end
#end
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-11 11:45:06 UTC (rev 1121)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-14 20:55:21 UTC (rev 1122)
@@ -421,16 +421,17 @@
#end
#if( $table.hasImmutableIf() )
#foreach( $ii in $table.ImmutableIf )
-#if( "x" != "x$!ii.Field" )
+#if( "x" != "x$!ii.FieldName" && $table.Name == $ii.Field.Table )
if ( exclude.indexOf( "|$ii.Name|" ) == -1 )
{
- if ( ${ii.Field.VarName} )
+ if ( get${ii.FieldName}() )
{
throw new EquandaConstraintViolation( ExceptionCodes.ECV_IMMUTABLE_IF_OTHER_FIELD_IS_SET,
"field.${table.Name}."+field+"", "field.${table.Name}.${ii.Name}");
}
}
#else ## todo handle calculate for test
+// skipped, todo "x" != "x$!ii.FieldName" && $table.Name == $ii.Field.Table $ii.Field
#end
#end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-11 11:45:09
|
Revision: 1121
http://equanda.svn.sourceforge.net/equanda/?rev=1121&view=rev
Author: triathlon98
Date: 2009-06-11 11:45:06 +0000 (Thu, 11 Jun 2009)
Log Message:
-----------
EQ-352 fixes when Tapestry not fully loaded
Modified Paths:
--------------
trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.js
Modified: trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.js
===================================================================
--- trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.js 2009-06-11 07:22:08 UTC (rev 1120)
+++ trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.js 2009-06-11 11:45:06 UTC (rev 1121)
@@ -1,10 +1,5 @@
// script.aculo.us slider.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008
-// Copyright (c) 2005-2008 Marty Haught, Thomas Fuchs
-//
-// script.aculo.us is freely distributable under the terms of an MIT-style license.
-// For details, see the script.aculo.us web site: http://script.aculo.us/
-
// slightly modified from original to assure the increment is used and to allow the slider to be initially hidden
// for this, two extra parameters "trackLength" and "handleLength" are introduced, which set the style of the elements.
// There is now an input box, and the input box has localized numbers.
@@ -134,7 +129,10 @@
return value;
},
valueTyped: function(event){
- this.setValue( parseFloat( Tapestry.formatLocalizedNumber( event.target.value, false ) ) );
+ if ( Tapestry.decimalFormatSymbols )
+ this.setValue( parseFloat( Tapestry.formatLocalizedNumber( event.target.value, false ) ) );
+ else
+ this.setValue( parseFloat( event.target.value, false ) );
},
setValue: function(sliderValue, handleIdx){
if (!this.active) {
@@ -256,7 +254,7 @@
this.event = event;
this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
this.input.value = this.values.length>1 ? this.values : this.value, this;
- this.input.value = this.input.value.replace( /\./g, Tapestry.decimalFormatSymbols.decimalSeparator );
+ if ( Tapestry.decimalFormatSymbols ) this.input.value = this.input.value.replace( /\./g, Tapestry.decimalFormatSymbols.decimalSeparator );
if (this.initialized && this.options.onSlide)
this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
},
@@ -275,7 +273,7 @@
},
updateFinished: function() {
this.input.value = this.values.length>1 ? this.values : this.value, this;
- this.input.value = this.input.value.replace( /\./g, Tapestry.decimalFormatSymbols.decimalSeparator );
+ if ( Tapestry.decimalFormatSymbols ) this.input.value = this.input.value.replace( /\./g, Tapestry.decimalFormatSymbols.decimalSeparator );
if (this.initialized && this.options.onSlide)
this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
if (this.initialized && this.options.onChange)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-11 07:22:16
|
Revision: 1120
http://equanda.svn.sourceforge.net/equanda/?rev=1120&view=rev
Author: triathlon98
Date: 2009-06-11 07:22:08 +0000 (Thu, 11 Jun 2009)
Log Message:
-----------
EQ-130
Modified Paths:
--------------
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectSelectorBean.java.vm
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectSelectorBean.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectSelectorBean.java.vm 2009-06-09 12:51:45 UTC (rev 1119)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ObjectSelectorBean.java.vm 2009-06-11 07:22:08 UTC (rev 1120)
@@ -375,6 +375,9 @@
#foreach( $type in $table.TablesNotInternal )
if ( "${type.Type}".equals( type ) ) entity = new DM${type.Name}( "M" );
#end
+ //obj.init( proxy.getEquandaType() #foreach( $field in $table.ImmutableFields ), proxy.get${field.Name}() #set( $sep="," )#end );
+ // @todo should immutable fields be initialised here ?
+ // @todo need to set auto fields ? or is this done in the DMObject ?
return entity;
}
@@ -404,16 +407,11 @@
Uoid id = proxy.getId();
if ( null == id )
entity = getNewEntity( proxy.getEquandaType() );
- //obj.init( proxy.getEquandaType() #foreach( $field in $table.ImmutableFields ), proxy.get${field.Name}() #set( $sep="," )#end );
else
entity = HR${table.Name}.selectId( entityManager, id );
HR${table.Name}.update( entityManager, entity, proxy );
if ( null == id ) entityManager.persist( entity );
entityManager.flush(); // force save to have correct equandaModification and equandaStatus fields
- //if ( objProxy == null )
- //{
- // throw new EquandaException( EE_FAILED_TO_UPDATE_VALUE, id.toString() );
- //}
return get( entity );
}
@@ -502,7 +500,6 @@
if ( null != entity )
{
#foreach( $ck in $table.CascadeKeep )
-// CascadeKeep bidi $ck.isBidirectional() fieldname $ck.FieldName linkedfieldname $ck.LinkedFieldName table $ck.TableName varname $ck.VarName owner $ck.isOwner
#if ( $ck.isBidirectional() )
#if( $ck.isMultiple() )
if ( !entity.get${ck.linkedFieldName}().isEmpty() )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-09 13:22:38
|
Revision: 1118
http://equanda.svn.sourceforge.net/equanda/?rev=1118&view=rev
Author: triathlon98
Date: 2009-06-09 12:29:14 +0000 (Tue, 09 Jun 2009)
Log Message:
-----------
EQ-130 fix some issues with embedded (39 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/EmbeddedTest.java
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-09 10:06:21 UTC (rev 1117)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-09 12:29:14 UTC (rev 1118)
@@ -130,7 +130,7 @@
#end
break; // prevent ConcurrentModificationException
}
- #else
+ #else##if isLink
if ( !al.contains( inst.get${field.Name}() ) )
{
fvl.remove( inst );
@@ -191,6 +191,9 @@
#else ## isLink single
if ( proxy.${field.VarName} == null )
{
+#if( $field.isEmbedded() )
+ if ( null != spec.get${field.Name}() ) em.remove( spec.get${field.Name}() );
+#end
spec.set${field.Name}( null );
}
else
@@ -210,8 +213,11 @@
#end
#end
${field.JavaEntityType} current = spec.get${field.Name}();
- if ( current == null || !current.getId().equals( linkField.getId() ) )
+ if ( null == current || !current.getId().equals( linkField.getId() ) )
{
+#if( $field.isEmbedded() )
+ if ( null != current ) em.remove( current );
+#end
if ( linkField.getId() != null )
{
spec.set${field.Name}( em.find( DM${field.LinkTableName}.class, linkField.getId() ) );
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/EmbeddedTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/EmbeddedTest.java 2009-06-09 10:06:21 UTC (rev 1117)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/EmbeddedTest.java 2009-06-09 12:29:14 UTC (rev 1118)
@@ -8,7 +8,7 @@
import org.equanda.test.dm.client.Owner;
/**
- * Description!!!
+ * Test for the embedded links.
*
* @author <a href="mailto:an...@pa...">Andrei Chiritescu</a>
*/
@@ -38,19 +38,8 @@
ownerProxy.equandaUpdate();
LazyInstSelectorEJB sel = EquandaGlobal.getLazyInstSelector();
- try
- {
- assertNull( sel.selectId( lazyProxy.getId() ) );
- fail( "the embedded object should have been deleted" );
- }
- catch ( EquandaException e )
- {
- assertEquals( ExceptionCodes.EPE_UOID_NOT_FOUND, e.getExceptionCode() );
- }
- finally
- {
- sel.remove();
- }
+ assertNull( sel.selectId( lazyProxy.getId() ) );
+ sel.remove();
}
public void testEmbeddedBiBehaviourWhenOtherSideNulled()
@@ -98,19 +87,8 @@
ownerProxy.removeEntityBean();
LazyInstSelectorEJB sel = EquandaGlobal.getLazyInstSelector();
- try
- {
- assertNull( sel.selectId( lazyProxy.getId() ) );
- fail( "the embedded object should have been deleted" );
- }
- catch ( EquandaException e )
- {
- assertEquals( ExceptionCodes.EPE_UOID_NOT_FOUND, e.getExceptionCode() );
- }
- finally
- {
- sel.remove();
- }
+ assertNull( sel.selectId( lazyProxy.getId() ) );
+ sel.remove();
}
/*
@@ -136,19 +114,8 @@
ownerProxy.equandaUpdate();
LazyInstSelectorEJB sel = EquandaGlobal.getLazyInstSelector();
- try
- {
- assertNull( sel.selectId( lazyProxy.getId() ) );
- fail( "the embedded object should have been deleted" );
- }
- catch ( EquandaException e )
- {
- assertEquals( ExceptionCodes.EPE_UOID_NOT_FOUND, e.getExceptionCode() );
- }
- finally
- {
- sel.remove();
- }
+ assertNull( sel.selectId( lazyProxy.getId() ) );
+ sel.remove();
}
public void testEmbeddedBehaviourWhenOwnerDeleted()
@@ -168,19 +135,8 @@
ownerProxy.removeEntityBean();
LazyInstSelectorEJB sel = EquandaGlobal.getLazyInstSelector();
- try
- {
- assertNull( sel.selectId( lazyProxy.getId() ) );
- fail( "the embedded object should have been deleted" );
- }
- catch ( EquandaException e )
- {
- assertEquals( ExceptionCodes.EPE_UOID_NOT_FOUND, e.getExceptionCode() );
- }
- finally
- {
- sel.remove();
- }
+ assertNull( sel.selectId( lazyProxy.getId() ) );
+ sel.remove();
}
/*
@@ -206,19 +162,8 @@
ownerProxy.equandaUpdate();
LazyInstSelectorEJB sel = EquandaGlobal.getLazyInstSelector();
- try
- {
- assertNull( sel.selectId( lazyProxy.getId() ) );
- fail( "the embedded object should have been deleted" );
- }
- catch ( EquandaException e )
- {
- assertEquals( ExceptionCodes.EPE_UOID_NOT_FOUND, e.getExceptionCode() );
- }
- finally
- {
- sel.remove();
- }
+ assertNull( sel.selectId( lazyProxy.getId() ) );
+ sel.remove();
}
public void testEmbeddedMulBiBehaviourWhenOtherSideNulled()
@@ -268,19 +213,8 @@
ownerProxy.removeEntityBean();
LazyInstSelectorEJB sel = EquandaGlobal.getLazyInstSelector();
- try
- {
- assertNull( sel.selectId( lazyProxy.getId() ) );
- fail( "the embedded object should have been deleted" );
- }
- catch ( EquandaException e )
- {
- assertEquals( ExceptionCodes.EPE_UOID_NOT_FOUND, e.getExceptionCode() );
- }
- finally
- {
- sel.remove();
- }
+ assertNull( sel.selectId( lazyProxy.getId() ) );
+ sel.remove();
}
/*
@@ -306,19 +240,8 @@
ownerProxy.equandaUpdate();
LazyInstSelectorEJB sel = EquandaGlobal.getLazyInstSelector();
- try
- {
- assertNull( sel.selectId( lazyProxy.getId() ) );
- fail( "the embedded object should have been deleted" );
- }
- catch ( EquandaException e )
- {
- assertEquals( ExceptionCodes.EPE_UOID_NOT_FOUND, e.getExceptionCode() );
- }
- finally
- {
- sel.remove();
- }
+ assertNull( sel.selectId( lazyProxy.getId() ) );
+ sel.remove();
}
public void testEmbeddedMulBehaviourWhenOwnerDeleted()
@@ -338,18 +261,7 @@
ownerProxy.removeEntityBean();
LazyInstSelectorEJB sel = EquandaGlobal.getLazyInstSelector();
- try
- {
- assertNull( sel.selectId( lazyProxy.getId() ) );
- fail( "the embedded object should have been deleted" );
- }
- catch ( EquandaException e )
- {
- assertEquals( ExceptionCodes.EPE_UOID_NOT_FOUND, e.getExceptionCode() );
- }
- finally
- {
- sel.remove();
- }
+ assertNull( sel.selectId( lazyProxy.getId() ) );
+ sel.remove();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-09 13:13:07
|
Revision: 1119
http://equanda.svn.sourceforge.net/equanda/?rev=1119&view=rev
Author: triathlon98
Date: 2009-06-09 12:51:45 +0000 (Tue, 09 Jun 2009)
Log Message:
-----------
EQ-130 fix issues with embedded (37 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-09 12:29:14 UTC (rev 1118)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-09 12:51:45 UTC (rev 1119)
@@ -109,6 +109,9 @@
Collection<$fieldtype2> fvl = spec.get${field.Name}();
if ( !( al instanceof EquandaList ) )
{
+#if( $field.isBidirectional() && $field.linkField.isEmbedded() )
+ if ( al.size() != fvl.size() ) throw new EquandaConstraintViolation( ECV_OTHERSIDE_EMBEDDED_FIELD_IMMUTABLE_ONCE_SET, "${table.Name}", "${field.Name}" );
+#else
while ( al.size() != fvl.size() ) // while to prevent ConcurrentModificationException
{
for ( $fieldtype2 inst : fvl )
@@ -140,6 +143,7 @@
#end
}
}
+#end
}
else
{
@@ -147,6 +151,9 @@
if ( fval.isModified() )
{
Collection<$fieldtype> rem = fval.getRemoveSet();
+#if( $field.isBidirectional() && $field.linkField.isEmbedded() )
+ if ( !rem.isEmpty() ) throw new EquandaConstraintViolation( ECV_OTHERSIDE_EMBEDDED_FIELD_IMMUTABLE_ONCE_SET, "${table.Name}", "${field.Name}" );
+#else
for ( $fieldtype ro : rem )
{
#if( $field.isLink() )
@@ -171,6 +178,7 @@
#end
}
fval.reset();
+#end
}
}
}
@@ -191,6 +199,9 @@
#else ## isLink single
if ( proxy.${field.VarName} == null )
{
+#if( $field.isBidirectional() && $field.linkField.isEmbedded() )
+ if ( null != spec.get${field.Name}() ) throw new EquandaConstraintViolation( ECV_OTHERSIDE_EMBEDDED_FIELD_IMMUTABLE_ONCE_SET, "${table.Name}", "${field.Name}" );
+#end
#if( $field.isEmbedded() )
if ( null != spec.get${field.Name}() ) em.remove( spec.get${field.Name}() );
#end
@@ -203,7 +214,7 @@
{
linkField.equandaUpdate();
}
- #if ($field.isBidirectional())
+ #if( $field.isBidirectional() )
DM${field.LinkTableName} link = em.find( DM${field.LinkTableName}.class, linkField.getId() );
// before updating the bidir proxy set the bidir link in case this is required
#if ($field.linkField.isMultiple())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-09 10:06:25
|
Revision: 1117
http://equanda.svn.sourceforge.net/equanda/?rev=1117&view=rev
Author: triathlon98
Date: 2009-06-09 10:06:21 +0000 (Tue, 09 Jun 2009)
Log Message:
-----------
EQ-352 localized numbers in input field
Modified Paths:
--------------
trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.js
trunk/equanda-tapestry5/src/site/wiki/slider.wiki
Removed Paths:
-------------
trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.js
Deleted: trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.js
===================================================================
--- trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.js 2009-06-09 09:57:49 UTC (rev 1116)
+++ trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.js 2009-06-09 10:06:21 UTC (rev 1117)
@@ -1,274 +0,0 @@
-// script.aculo.us slider.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008
-
-// Copyright (c) 2005-2008 Marty Haught, Thomas Fuchs
-//
-// script.aculo.us is freely distributable under the terms of an MIT-style license.
-// For details, see the script.aculo.us web site: http://script.aculo.us/
-
-// slightly modified from original to assure the increment is used and to allow the slider to be initially hidden
-// for this, two extra parameters "trackLength" and "handleLength" are introduced, which set the style of the elements.
-
-if (!Control) var Control = { };
-
-// options:
-// axis: 'vertical', or 'horizontal' (default)
-//
-// callbacks:
-// onChange(value)
-// onSlide(value)
-Control.ckSlider = Class.create({
- initialize: function(handle, track, options) {
- var slider = this;
-
- if (Object.isArray(handle)) {
- this.handles = handle.collect( function(e) { return $(e) });
- } else {
- this.handles = [$(handle)];
- }
-
- this.track = $(track);
- this.options = options || { };
-
- this.axis = this.options.axis || 'horizontal';
- this.increment = this.options.increment || 1;
- this.step = parseInt(this.options.step || '1');
- this.range = this.options.range || $R(0,1);
-
- this.trackLength = parseInt(this.options.trackLength || '200');
- this.handleLength = parseInt(this.options.handleLength || '5');
-
- this.value = 0; // assure backwards compat
- this.values = this.handles.map( function() { return 0 });
- this.spans = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
- this.options.startSpan = $(this.options.startSpan || null);
- this.options.endSpan = $(this.options.endSpan || null);
-
- this.restricted = this.options.restricted || false;
-
- this.maximum = this.options.maximum || this.range.end;
- this.minimum = this.options.minimum || this.range.start;
-
- // Will be used to align the handle onto the track, if necessary
- this.alignX = parseInt(this.options.alignX || '0');
- this.alignY = parseInt(this.options.alignY || '0');
-
- if ( this.isVertical() ) {
- this.track.style.height=""+this.trackLength+"px";
- this.handles[0].style.height=""+this.handleLength+"px";
- } else {
- this.track.style.width=""+this.trackLength+"px"
- this.handles[0].style.width=""+this.handleLength+"px";
- }
-
- this.active = false;
- this.dragging = false;
- this.disabled = false;
-
- if (this.options.disabled) this.setDisabled();
-
- // Allowed values array
- this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
- if (this.allowedValues) {
- this.minimum = this.allowedValues.min();
- this.maximum = this.allowedValues.max();
- }
-
- this.eventMouseDown = this.startDrag.bindAsEventListener(this);
- this.eventMouseUp = this.endDrag.bindAsEventListener(this);
- this.eventMouseMove = this.update.bindAsEventListener(this);
-
- // Initialize handles in reverse (make sure first handle is active)
- this.handles.each( function(h,i) {
- i = slider.handles.length-1-i;
- slider.setValue(parseFloat(
- (Object.isArray(slider.options.sliderValue) ?
- slider.options.sliderValue[i] : slider.options.sliderValue) ||
- slider.range.start), i);
- h.makePositioned().observe("mousedown", slider.eventMouseDown);
- });
-
- this.track.observe("mousedown", this.eventMouseDown);
- document.observe("mouseup", this.eventMouseUp);
- document.observe("mousemove", this.eventMouseMove);
-
- this.initialized = true;
- },
- dispose: function() {
- var slider = this;
- Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
- Event.stopObserving(document, "mouseup", this.eventMouseUp);
- Event.stopObserving(document, "mousemove", this.eventMouseMove);
- this.handles.each( function(h) {
- Event.stopObserving(h, "mousedown", slider.eventMouseDown);
- });
- },
- setDisabled: function(){
- this.disabled = true;
- },
- setEnabled: function(){
- this.disabled = false;
- },
- getNearestValue: function(value){
- value=Math.round(value/this.increment)*this.increment;
- if (this.allowedValues){
- if (value >= this.allowedValues.max()) return(this.allowedValues.max());
- if (value <= this.allowedValues.min()) return(this.allowedValues.min());
-
- var offset = Math.abs(this.allowedValues[0] - value);
- var newValue = this.allowedValues[0];
- this.allowedValues.each( function(v) {
- var currentOffset = Math.abs(v - value);
- if (currentOffset <= offset){
- newValue = v;
- offset = currentOffset;
- }
- });
- return newValue;
- }
- if (value > this.range.end) return this.range.end;
- if (value < this.range.start) return this.range.start;
- return value;
- },
- setValue: function(sliderValue, handleIdx){
- if (!this.active) {
- this.activeHandleIdx = handleIdx || 0;
- this.activeHandle = this.handles[this.activeHandleIdx];
- this.updateStyles();
- }
- handleIdx = handleIdx || this.activeHandleIdx || 0;
- if (this.initialized && this.restricted) {
- if ((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
- sliderValue = this.values[handleIdx-1];
- if ((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
- sliderValue = this.values[handleIdx+1];
- }
- sliderValue = this.getNearestValue(sliderValue);
- this.values[handleIdx] = sliderValue;
- this.value = this.values[0]; // assure backwards compat
-
- this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
- this.translateToPx(sliderValue);
-
- this.drawSpans();
- if (!this.dragging || !this.event) this.updateFinished();
- },
- setValueBy: function(delta, handleIdx) {
- this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
- handleIdx || this.activeHandleIdx || 0);
- },
- translateToPx: function(value) {
- return Math.round(
- ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
- (value - this.range.start)) + "px";
- },
- translateToValue: function(offset) {
- return ((offset/(this.trackLength-this.handleLength) *
- (this.range.end-this.range.start)) + this.range.start);
- },
- getRange: function(range) {
- var v = this.values.sortBy(Prototype.K);
- range = range || 0;
- return $R(v[range],v[range+1]);
- },
- isVertical: function(){
- return (this.axis == 'vertical');
- },
- drawSpans: function() {
- var slider = this;
- if (this.spans)
- $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
- if (this.options.startSpan)
- this.setSpan(this.options.startSpan,
- $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
- if (this.options.endSpan)
- this.setSpan(this.options.endSpan,
- $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
- },
- setSpan: function(span, range) {
- if (this.isVertical()) {
- span.style.top = this.translateToPx(range.start);
- span.style.height = this.translateToPx(range.end - range.start + this.range.start);
- } else {
- span.style.left = this.translateToPx(range.start);
- span.style.width = this.translateToPx(range.end - range.start + this.range.start);
- }
- },
- updateStyles: function() {
- this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
- Element.addClassName(this.activeHandle, 'selected');
- },
- startDrag: function(event) {
- if (Event.isLeftClick(event)) {
- if (!this.disabled){
- this.active = true;
-
- var handle = Event.element(event);
- var pointer = [Event.pointerX(event), Event.pointerY(event)];
- var track = handle;
- if (track==this.track) {
- var offsets = Position.cumulativeOffset(this.track);
- this.event = event;
- this.setValue(this.translateToValue(
- (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
- ));
- var offsets = Position.cumulativeOffset(this.activeHandle);
- this.offsetX = (pointer[0] - offsets[0]);
- this.offsetY = (pointer[1] - offsets[1]);
- } else {
- // find the handle (prevents issues with Safari)
- while((this.handles.indexOf(handle) == -1) && handle.parentNode)
- handle = handle.parentNode;
-
- if (this.handles.indexOf(handle)!=-1) {
- this.activeHandle = handle;
- this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
- this.updateStyles();
-
- var offsets = Position.cumulativeOffset(this.activeHandle);
- this.offsetX = (pointer[0] - offsets[0]);
- this.offsetY = (pointer[1] - offsets[1]);
- }
- }
- }
- Event.stop(event);
- }
- },
- update: function(event) {
- if (this.active) {
- if (!this.dragging) this.dragging = true;
- this.draw(event);
- if (Prototype.Browser.WebKit) window.scrollBy(0,0);
- Event.stop(event);
- }
- },
- draw: function(event) {
- var pointer = [Event.pointerX(event), Event.pointerY(event)];
- var offsets = Position.cumulativeOffset(this.track);
- pointer[0] -= this.offsetX + offsets[0];
- pointer[1] -= this.offsetY + offsets[1];
- this.event = event;
- this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
- if (this.initialized && this.options.onSlide)
- this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
- },
- endDrag: function(event) {
- if (this.active && this.dragging) {
- this.finishDrag(event, true);
- Event.stop(event);
- }
- this.active = false;
- this.dragging = false;
- },
- finishDrag: function(event, success) {
- this.active = false;
- this.dragging = false;
- this.updateFinished();
- },
- updateFinished: function() {
- if (this.initialized && this.options.onSlide)
- this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
- if (this.initialized && this.options.onChange)
- this.options.onChange(this.values.length>1 ? this.values : this.value, this);
- this.event = null;
- }
-});
Modified: trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.js
===================================================================
--- trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.js 2009-06-09 09:57:49 UTC (rev 1116)
+++ trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.js 2009-06-09 10:06:21 UTC (rev 1117)
@@ -7,6 +7,7 @@
// slightly modified from original to assure the increment is used and to allow the slider to be initially hidden
// for this, two extra parameters "trackLength" and "handleLength" are introduced, which set the style of the elements.
+// There is now an input box, and the input box has localized numbers.
if (!Control) var Control = { };
@@ -133,7 +134,7 @@
return value;
},
valueTyped: function(event){
- this.setValue( parseFloat( event.target.value ) );
+ this.setValue( parseFloat( Tapestry.formatLocalizedNumber( event.target.value, false ) ) );
},
setValue: function(sliderValue, handleIdx){
if (!this.active) {
@@ -255,6 +256,7 @@
this.event = event;
this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
this.input.value = this.values.length>1 ? this.values : this.value, this;
+ this.input.value = this.input.value.replace( /\./g, Tapestry.decimalFormatSymbols.decimalSeparator );
if (this.initialized && this.options.onSlide)
this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
},
@@ -273,6 +275,7 @@
},
updateFinished: function() {
this.input.value = this.values.length>1 ? this.values : this.value, this;
+ this.input.value = this.input.value.replace( /\./g, Tapestry.decimalFormatSymbols.decimalSeparator );
if (this.initialized && this.options.onSlide)
this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
if (this.initialized && this.options.onChange)
Modified: trunk/equanda-tapestry5/src/site/wiki/slider.wiki
===================================================================
--- trunk/equanda-tapestry5/src/site/wiki/slider.wiki 2009-06-09 09:57:49 UTC (rev 1116)
+++ trunk/equanda-tapestry5/src/site/wiki/slider.wiki 2009-06-09 10:06:21 UTC (rev 1117)
@@ -1,2 +1,18 @@
h1. Slider
+The slider component allows you to include a number in a form allowing the value to be entered either by typing or by indicating the value on a slider.
+
+There are a couple of possible parameters :
+- value : property which has the current value and needs to be updated when the form is submitted.
+- min : minimum value for the value.
+- max : maximum value for the value.
+- inc : increment which should be used, indicating the possible values.
+- disabled : allows making the field display only.
+
+<code>
+<span t:type="equanda/Slider" value="slider1" min="1" max="100" inc="1" disabled="literal:false" />
+<span t:type="equanda/Slider" value="slider2" min="0" max="1" inc=".05" />
+<span t:type="equanda/Slider" value="slider3" min="1" max="100" inc="1" disabled="literal:true" />
+<span t:type="equanda/Slider" value="slider4" min="1" max="100" inc="10" />
+<span t:type="equanda/Slider" value="slider5" min="0" max="5" inc=".1" />
+</code>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-09 09:57:53
|
Revision: 1116
http://equanda.svn.sourceforge.net/equanda/?rev=1116&view=rev
Author: triathlon98
Date: 2009-06-09 09:57:49 +0000 (Tue, 09 Jun 2009)
Log Message:
-----------
EQ-352 slider with input box demo
Modified Paths:
--------------
t5-equanda-example/pom.xml
t5-equanda-example/src/main/java/org/equanda/example/t5/pages/Start.java
t5-equanda-example/src/main/resources/org/equanda/example/t5/pages/Start.tml
Modified: t5-equanda-example/pom.xml
===================================================================
--- t5-equanda-example/pom.xml 2009-06-09 08:15:32 UTC (rev 1115)
+++ t5-equanda-example/pom.xml 2009-06-09 09:57:49 UTC (rev 1116)
@@ -158,7 +158,7 @@
</pluginRepositories>
<properties>
- <equanda-release-version>0.9.4-SNAPSHOT</equanda-release-version>
+ <equanda-release-version>0.9.5-SNAPSHOT</equanda-release-version>
<tapestry-release-version>5.1.0.1</tapestry-release-version>
<chenillekit-version>1.0.0</chenillekit-version>
</properties>
Modified: t5-equanda-example/src/main/java/org/equanda/example/t5/pages/Start.java
===================================================================
--- t5-equanda-example/src/main/java/org/equanda/example/t5/pages/Start.java 2009-06-09 08:15:32 UTC (rev 1115)
+++ t5-equanda-example/src/main/java/org/equanda/example/t5/pages/Start.java 2009-06-09 09:57:49 UTC (rev 1116)
@@ -42,7 +42,7 @@
*
* @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
*/
-public class Start /*implements ObjectCreatorDelegate<String>*/
+public class Start
{
@Inject
@Path( "context:images/smiley.gif" )
@@ -54,7 +54,15 @@
@Persist
private List<String> list;
private String current;
+
+ @Persist
+ @Property
+ private int slider1, slider3, slider4;
+ @Persist
+ @Property
+ private double slider2, slider5;
+
public DemoTree getNode()
{
return node;
@@ -133,6 +141,7 @@
list.add( "paging" );
list.add( "in" );
list.add( "action." );
+ slider3 = 30;
}
public List<String> getList()
Modified: t5-equanda-example/src/main/resources/org/equanda/example/t5/pages/Start.tml
===================================================================
--- t5-equanda-example/src/main/resources/org/equanda/example/t5/pages/Start.tml 2009-06-09 08:15:32 UTC (rev 1115)
+++ t5-equanda-example/src/main/resources/org/equanda/example/t5/pages/Start.tml 2009-06-09 09:57:49 UTC (rev 1116)
@@ -140,6 +140,21 @@
<blockquote><span t:type="equanda/TextAreaAutoExpander"/></blockquote> somewhere in your page
(or layout component).</p>
</t:parameter>
+ <t:parameter name="title8">Slider</t:parameter>
+ <t:parameter name="content8">
+ <p>The Slider component allows selecting a numeric value</p>
+
+ <p>A value between one and hundred with precision of one.<br /> <span t:type="equanda/Slider" value="slider1" min="1" max="100" inc="1"/></p>
+ <span t:type="equanda/Slider" value="slider1" min="1" max="100" inc="1" disabled="literal:false"/>
+ <p>A value between zero and one with precision of .5.<br /> <span t:type="equanda/Slider" value="slider2" min="0" max="1" inc=".05"/></p>
+ <span t:type="equanda/Slider" value="slider2" min="0" max="1" inc=".05" disabled="literal:false"/>
+ <p>A disabled slider.<br /> <span t:type="equanda/Slider" value="slider3" min="1" max="100" inc="1" disabled="literal:true"/></p>
+ <span t:type="equanda/Slider" value="slider3" min="1" max="100" inc="1" disabled="literal:true"/>
+ <p>A value between one and hundred, incrementing by 10.<br /> <span t:type="equanda/Slider" value="slider4" min="1" max="100" inc="10"/></p>
+ <span t:type="equanda/Slider" value="slider4" min="1" max="100" inc="10" disabled="literal:false"/>
+ <p>A value between zero and five with precision of .1.<br /> <span t:type="equanda/Slider" value="slider5" min="0" max="5" inc=".1"/></p>
+ <span t:type="equanda/Slider" value="slider5" min="0" max="5" inc=".1" disabled="literal:false"/>
+ </t:parameter>
</span>
</t:form>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-09 08:15:39
|
Revision: 1115
http://equanda.svn.sourceforge.net/equanda/?rev=1115&view=rev
Author: triathlon98
Date: 2009-06-09 08:15:32 +0000 (Tue, 09 Jun 2009)
Log Message:
-----------
EQ-352 mostly working now, still needs localization support
Modified Paths:
--------------
trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Slider.java
trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/Slider.tml
trunk/equanda-tapestry5/src/site/site.xml
trunk/equanda-tapestry5/src/site/wiki/index.wiki
Added Paths:
-----------
trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.css
trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.js
trunk/equanda-tapestry5/src/site/wiki/slider.wiki
Removed Paths:
-------------
trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.css
Modified: trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Slider.java
===================================================================
--- trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Slider.java 2009-06-08 10:34:11 UTC (rev 1114)
+++ trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Slider.java 2009-06-09 08:15:32 UTC (rev 1115)
@@ -1,3 +1,27 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
package org.equanda.tapestry5.components;
import org.apache.tapestry5.*;
@@ -14,8 +38,9 @@
*
* @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
*/
-@IncludeJavaScriptLibrary( value = { "${tapestry.scriptaculous}/controls.js", "/slider.js" } )
-@IncludeStylesheet( value = { "slider.css" } )
+@IncludeJavaScriptLibrary( value = { "${tapestry.scriptaculous}/controls.js",
+ "classpath:/org/equanda/tapestry5/resources/slider.js" } )
+@IncludeStylesheet( value = { "classpath:/org/equanda/tapestry5/resources/slider.css" } )
public class Slider
implements ClientElement
{
@@ -74,13 +99,12 @@
void afterRender( MarkupWriter writer )
{
String jsCommand =
- "new Control.ckSlider('handle_%s','track_%s',{sliderValue:" + getNumberPattern( value ) + ",range:" +
+ "new Control.eqSlider('handle_%s','track_%s','%s',{sliderValue:" + getNumberPattern( value ) + ",range:" +
"$R(" + getNumberPattern( min ) + "," + getNumberPattern( max ) + "),increment:" +
- getNumberPattern( inc ) +
- ",onSlide:function(v){ $('output_%s').innerHTML = v; $('%s').value=v; }";
+ getNumberPattern( inc );
jsCommand = String
- .format( Locale.US, jsCommand, getClientId(), getClientId(), value, min, max, inc, getClientId(),
- formValue.getClientId() );
+ .format( Locale.US, jsCommand, getClientId(), getClientId(), formValue.getClientId(), value, min, max,
+ inc );
if ( disabled )
{
Modified: trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/Slider.tml
===================================================================
--- trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/Slider.tml 2009-06-08 10:34:11 UTC (rev 1114)
+++ trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/Slider.tml 2009-06-09 08:15:32 UTC (rev 1115)
@@ -3,6 +3,5 @@
<div id="handle_${clientId}" class="eqslider-handle">
</div>
</div>
- <div id="output_${clientId}" class="eqslider-value">${value}</div>
- <t:TextField t:id="formValue" style="display:none;"/>
+ <t:TextField t:id="formValue" class="eqslider-value" />
</t:container>
\ No newline at end of file
Deleted: trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.css
===================================================================
--- trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.css 2009-06-08 10:34:11 UTC (rev 1114)
+++ trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.css 2009-06-09 08:15:32 UTC (rev 1115)
@@ -1,19 +0,0 @@
-DIV.eqslider-handle {
- /*width: 5px;*/
- height: 15px;
- top: -5px;
- background-color: #f00;
- cursor: move;
-}
-
-DIV.eqslider-track {
- /*width: 200px;*/
- background-color: #aaa;
- height: 5px;
-}
-
-DIV.eqslider-value {
- position: relative;
- top: -10px;
- left: 210px;
-}
Copied: trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.css (from rev 1114, trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.css)
===================================================================
--- trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.css (rev 0)
+++ trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.css 2009-06-09 08:15:32 UTC (rev 1115)
@@ -0,0 +1,20 @@
+DIV.eqslider-handle {
+ /*width: 5px;*/
+ height: 15px;
+ top: -5px;
+ background-color: #f00;
+ cursor: move;
+}
+
+DIV.eqslider-track {
+ /*width: 200px;*/
+ background-color: #aaa;
+ height: 5px;
+}
+
+INPUT.eqslider-value {
+ position: relative;
+ top: -14px;
+ left: 210px;
+ width: 40px;
+}
Copied: trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.js (from rev 1114, trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.js)
===================================================================
--- trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.js (rev 0)
+++ trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/slider.js 2009-06-09 08:15:32 UTC (rev 1115)
@@ -0,0 +1,282 @@
+// script.aculo.us slider.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008
+
+// Copyright (c) 2005-2008 Marty Haught, Thomas Fuchs
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+// slightly modified from original to assure the increment is used and to allow the slider to be initially hidden
+// for this, two extra parameters "trackLength" and "handleLength" are introduced, which set the style of the elements.
+
+if (!Control) var Control = { };
+
+// options:
+// axis: 'vertical', or 'horizontal' (default)
+//
+// callbacks:
+// onChange(value)
+// onSlide(value)
+Control.eqSlider = Class.create({
+ initialize: function(handle, track, input, options) {
+ var slider = this;
+
+ if (Object.isArray(handle)) {
+ this.handles = handle.collect( function(e) { return $(e) });
+ } else {
+ this.handles = [$(handle)];
+ }
+
+ this.track = $(track);
+ this.input = $(input);
+ this.options = options || { };
+
+ this.axis = this.options.axis || 'horizontal';
+ this.increment = this.options.increment || 1;
+ this.step = parseInt(this.options.step || '1');
+ this.range = this.options.range || $R(0,1);
+
+ this.trackLength = parseInt(this.options.trackLength || '200');
+ this.handleLength = parseInt(this.options.handleLength || '5');
+
+ this.value = 0; // assure backwards compat
+ this.values = this.handles.map( function() { return 0 });
+ this.spans = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
+ this.options.startSpan = $(this.options.startSpan || null);
+ this.options.endSpan = $(this.options.endSpan || null);
+
+ this.restricted = this.options.restricted || false;
+
+ this.maximum = this.options.maximum || this.range.end;
+ this.minimum = this.options.minimum || this.range.start;
+
+ // Will be used to align the handle onto the track, if necessary
+ this.alignX = parseInt(this.options.alignX || '0');
+ this.alignY = parseInt(this.options.alignY || '0');
+
+ if ( this.isVertical() ) {
+ this.track.style.height=""+this.trackLength+"px";
+ this.handles[0].style.height=""+this.handleLength+"px";
+ } else {
+ this.track.style.width=""+this.trackLength+"px"
+ this.handles[0].style.width=""+this.handleLength+"px";
+ }
+
+ this.active = false;
+ this.dragging = false;
+ this.disabled = false;
+
+ if (this.options.disabled) this.setDisabled();
+
+ // Allowed values array
+ this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
+ if (this.allowedValues) {
+ this.minimum = this.allowedValues.min();
+ this.maximum = this.allowedValues.max();
+ }
+
+ this.eventMouseDown = this.startDrag.bindAsEventListener(this);
+ this.eventMouseUp = this.endDrag.bindAsEventListener(this);
+ this.eventMouseMove = this.update.bindAsEventListener(this);
+ this.eventValueChanged = this.valueTyped.bindAsEventListener(this);
+
+ // Initialize handles in reverse (make sure first handle is active)
+ this.handles.each( function(h,i) {
+ i = slider.handles.length-1-i;
+ slider.setValue(parseFloat(
+ (Object.isArray(slider.options.sliderValue) ?
+ slider.options.sliderValue[i] : slider.options.sliderValue) ||
+ slider.range.start), i);
+ h.makePositioned().observe("mousedown", slider.eventMouseDown);
+ });
+
+ this.track.observe("mousedown", this.eventMouseDown);
+ document.observe("mouseup", this.eventMouseUp);
+ document.observe("mousemove", this.eventMouseMove);
+ this.input.observe("change", this.eventValueChanged );
+
+ this.initialized = true;
+ },
+ dispose: function() {
+ var slider = this;
+ Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
+ Event.stopObserving(document, "mouseup", this.eventMouseUp);
+ Event.stopObserving(document, "mousemove", this.eventMouseMove);
+ this.handles.each( function(h) {
+ Event.stopObserving(h, "mousedown", slider.eventMouseDown);
+ });
+ },
+ setDisabled: function(){
+ this.disabled = true;
+ },
+ setEnabled: function(){
+ this.disabled = false;
+ },
+ getNearestValue: function(value){
+ value=Math.round(value/this.increment)*this.increment;
+ if (this.allowedValues){
+ if (value >= this.allowedValues.max()) return(this.allowedValues.max());
+ if (value <= this.allowedValues.min()) return(this.allowedValues.min());
+
+ var offset = Math.abs(this.allowedValues[0] - value);
+ var newValue = this.allowedValues[0];
+ this.allowedValues.each( function(v) {
+ var currentOffset = Math.abs(v - value);
+ if (currentOffset <= offset){
+ newValue = v;
+ offset = currentOffset;
+ }
+ });
+ return newValue;
+ }
+ if (value > this.range.end) return this.range.end;
+ if (value < this.range.start) return this.range.start;
+ return value;
+ },
+ valueTyped: function(event){
+ this.setValue( parseFloat( event.target.value ) );
+ },
+ setValue: function(sliderValue, handleIdx){
+ if (!this.active) {
+ this.activeHandleIdx = handleIdx || 0;
+ this.activeHandle = this.handles[this.activeHandleIdx];
+ this.updateStyles();
+ }
+ handleIdx = handleIdx || this.activeHandleIdx || 0;
+ if (this.initialized && this.restricted) {
+ if ((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
+ sliderValue = this.values[handleIdx-1];
+ if ((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
+ sliderValue = this.values[handleIdx+1];
+ }
+ sliderValue = this.getNearestValue(sliderValue);
+ this.values[handleIdx] = sliderValue;
+ this.value = this.values[0]; // assure backwards compat
+
+ this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
+ this.translateToPx(sliderValue);
+
+ this.drawSpans();
+ if (!this.dragging || !this.event) this.updateFinished();
+ },
+ setValueBy: function(delta, handleIdx) {
+ this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
+ handleIdx || this.activeHandleIdx || 0);
+ },
+ translateToPx: function(value) {
+ return Math.round(
+ ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
+ (value - this.range.start)) + "px";
+ },
+ translateToValue: function(offset) {
+ return ((offset/(this.trackLength-this.handleLength) *
+ (this.range.end-this.range.start)) + this.range.start);
+ },
+ getRange: function(range) {
+ var v = this.values.sortBy(Prototype.K);
+ range = range || 0;
+ return $R(v[range],v[range+1]);
+ },
+ isVertical: function(){
+ return (this.axis == 'vertical');
+ },
+ drawSpans: function() {
+ var slider = this;
+ if (this.spans)
+ $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
+ if (this.options.startSpan)
+ this.setSpan(this.options.startSpan,
+ $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
+ if (this.options.endSpan)
+ this.setSpan(this.options.endSpan,
+ $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
+ },
+ setSpan: function(span, range) {
+ if (this.isVertical()) {
+ span.style.top = this.translateToPx(range.start);
+ span.style.height = this.translateToPx(range.end - range.start + this.range.start);
+ } else {
+ span.style.left = this.translateToPx(range.start);
+ span.style.width = this.translateToPx(range.end - range.start + this.range.start);
+ }
+ },
+ updateStyles: function() {
+ this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
+ Element.addClassName(this.activeHandle, 'selected');
+ },
+ startDrag: function(event) {
+ if (Event.isLeftClick(event)) {
+ if (!this.disabled){
+ this.active = true;
+
+ var handle = Event.element(event);
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var track = handle;
+ if (track==this.track) {
+ var offsets = Position.cumulativeOffset(this.track);
+ this.event = event;
+ this.setValue(this.translateToValue(
+ (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
+ ));
+ var offsets = Position.cumulativeOffset(this.activeHandle);
+ this.offsetX = (pointer[0] - offsets[0]);
+ this.offsetY = (pointer[1] - offsets[1]);
+ } else {
+ // find the handle (prevents issues with Safari)
+ while((this.handles.indexOf(handle) == -1) && handle.parentNode)
+ handle = handle.parentNode;
+
+ if (this.handles.indexOf(handle)!=-1) {
+ this.activeHandle = handle;
+ this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
+ this.updateStyles();
+
+ var offsets = Position.cumulativeOffset(this.activeHandle);
+ this.offsetX = (pointer[0] - offsets[0]);
+ this.offsetY = (pointer[1] - offsets[1]);
+ }
+ }
+ }
+ Event.stop(event);
+ }
+ },
+ update: function(event) {
+ if (this.active) {
+ if (!this.dragging) this.dragging = true;
+ this.draw(event);
+ if (Prototype.Browser.WebKit) window.scrollBy(0,0);
+ Event.stop(event);
+ }
+ },
+ draw: function(event) {
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var offsets = Position.cumulativeOffset(this.track);
+ pointer[0] -= this.offsetX + offsets[0];
+ pointer[1] -= this.offsetY + offsets[1];
+ this.event = event;
+ this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
+ this.input.value = this.values.length>1 ? this.values : this.value, this;
+ if (this.initialized && this.options.onSlide)
+ this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
+ },
+ endDrag: function(event) {
+ if (this.active && this.dragging) {
+ this.finishDrag(event, true);
+ Event.stop(event);
+ }
+ this.active = false;
+ this.dragging = false;
+ },
+ finishDrag: function(event, success) {
+ this.active = false;
+ this.dragging = false;
+ this.updateFinished();
+ },
+ updateFinished: function() {
+ this.input.value = this.values.length>1 ? this.values : this.value, this;
+ if (this.initialized && this.options.onSlide)
+ this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
+ if (this.initialized && this.options.onChange)
+ this.options.onChange(this.values.length>1 ? this.values : this.value, this);
+ this.event = null;
+ }
+});
Modified: trunk/equanda-tapestry5/src/site/site.xml
===================================================================
--- trunk/equanda-tapestry5/src/site/site.xml 2009-06-08 10:34:11 UTC (rev 1114)
+++ trunk/equanda-tapestry5/src/site/site.xml 2009-06-09 08:15:32 UTC (rev 1115)
@@ -14,6 +14,7 @@
<item name="FormSupport" href="formsupport.html"/>
<item name="FormTraversal" href="formtraversal.html"/>
<item name="JSPagedLoop" href="jspagedloop.html"/>
+ <item name="Slider" href="slider.html"/>
<item name="Tabs / MemTabs" href="tabs.html"/>
<item name="TextAreaAutoExpander" href="textareaautoexpander.html"/>
<item name="TextField" href="textfield.html"/>
Modified: trunk/equanda-tapestry5/src/site/wiki/index.wiki
===================================================================
--- trunk/equanda-tapestry5/src/site/wiki/index.wiki 2009-06-08 10:34:11 UTC (rev 1114)
+++ trunk/equanda-tapestry5/src/site/wiki/index.wiki 2009-06-09 08:15:32 UTC (rev 1115)
@@ -7,15 +7,17 @@
The following components are provided
- [Accordion|accordion.html]
-- [Tabs|tabs.html]
-- [MemTabs|memtabs.html]
+- [FormActionLink|formactionlink.html]
+- [FormSupport|formsupport.html]
- [FormTraversal|formtraversal.html]
-- [Truncate|truncate.html]
-- [FormActionLink|formactionlink.html]
- [JSPagedLoop|jspagedloop.html]
+- [MemTabs|tabs.html]
+- [Slider|slider.html]
+- [Tabs|tabs.html]
- [TextAreaAutoExpander|textareaautoexpander.html]
- [TextField|textfield.html]
- [TreeTable|treetable.html]
+- [Truncate|truncate.html]
Useful services, translators and other
- DoubleTranslator : assures both dot or comma can be used as decimal seperator.
Added: trunk/equanda-tapestry5/src/site/wiki/slider.wiki
===================================================================
--- trunk/equanda-tapestry5/src/site/wiki/slider.wiki (rev 0)
+++ trunk/equanda-tapestry5/src/site/wiki/slider.wiki 2009-06-09 08:15:32 UTC (rev 1115)
@@ -0,0 +1,2 @@
+h1. Slider
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-08 10:36:40
|
Revision: 1114
http://equanda.svn.sourceforge.net/equanda/?rev=1114&view=rev
Author: triathlon98
Date: 2009-06-08 10:34:11 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
EQ-352 start of slider component
Added Paths:
-----------
trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Slider.java
trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/Slider.tml
trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.css
trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.js
Added: trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Slider.java
===================================================================
--- trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Slider.java (rev 0)
+++ trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Slider.java 2009-06-08 10:34:11 UTC (rev 1114)
@@ -0,0 +1,124 @@
+package org.equanda.tapestry5.components;
+
+import org.apache.tapestry5.*;
+import org.apache.tapestry5.annotations.*;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.services.Request;
+
+import java.util.Locale;
+
+/**
+ * Slider based on script.aculo.us slider, but works when initially hidden,
+ * has a textbox for direct value entry, allows click to position (instead of drag)
+ * and allows specifying a precision.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+@IncludeJavaScriptLibrary( value = { "${tapestry.scriptaculous}/controls.js", "/slider.js" } )
+@IncludeStylesheet( value = { "slider.css" } )
+public class Slider
+ implements ClientElement
+{
+ /**
+ * The id used to generate a page-unique client-side identifier for the component. If a component renders multiple
+ * times, a suffix will be appended to the to id to ensure uniqueness.
+ */
+ @Parameter( value = "prop:componentResources.id", defaultPrefix = BindingConstants.LITERAL )
+ private String clientId;
+
+ /** The value to read or update. */
+ @Parameter( required = true )
+ private Number value;
+
+ /** min. slide-able value. */
+ @Parameter( value = "0", required = false )
+ private Number min;
+
+ /** max. slide-able value. */
+ @Parameter( value = "100", required = false )
+ private Number max;
+
+ /** increments x on every step. */
+ @Parameter( value = "1", required = false )
+ private Number inc;
+
+ /**
+ * If true, then the field will render out with a disabled attribute (to turn off client-side behavior).
+ * Further, a disabled field ignores any value in the request when the form is submitted.
+ */
+ @Parameter( value = "false", required = false )
+ private boolean disabled;
+
+ @SuppressWarnings( "unused" )
+ @Component( parameters = { "value=inherit:value", "disabled=inherit:disabled" } )
+ private TextField formValue;
+
+ @Inject
+ private ComponentResources resources;
+
+ @Inject
+ private Request request;
+
+ @Environmental
+ private RenderSupport pageRenderSupport;
+
+ private String assignedClientId;
+
+ void setupRender()
+ {
+ assignedClientId = pageRenderSupport.allocateClientId( clientId );
+ }
+
+ String getTextFieldId() { return "tf_" + getClientId(); }
+
+ void afterRender( MarkupWriter writer )
+ {
+ String jsCommand =
+ "new Control.ckSlider('handle_%s','track_%s',{sliderValue:" + getNumberPattern( value ) + ",range:" +
+ "$R(" + getNumberPattern( min ) + "," + getNumberPattern( max ) + "),increment:" +
+ getNumberPattern( inc ) +
+ ",onSlide:function(v){ $('output_%s').innerHTML = v; $('%s').value=v; }";
+ jsCommand = String
+ .format( Locale.US, jsCommand, getClientId(), getClientId(), value, min, max, inc, getClientId(),
+ formValue.getClientId() );
+
+ if ( disabled )
+ {
+ jsCommand += ",disabled:true";
+ }
+ jsCommand += " });";
+ pageRenderSupport.addScript( jsCommand );
+ }
+
+ public Number getValue()
+ {
+ return value;
+ }
+
+ public void setValue( Number value )
+ {
+ this.value = value;
+ }
+
+ private String getNumberPattern( Number value )
+ {
+ String numberPattern = "%d";
+
+ if ( value instanceof Float || value instanceof Double )
+ {
+ numberPattern = "%f";
+ }
+
+ return numberPattern;
+ }
+
+ /**
+ * Returns a unique id for the element. This value will be unique for any given rendering of a
+ * page. This value is intended for use as the id attribute of the client-side element, and will
+ * be used with any DHTML/Ajax related JavaScript.
+ */
+ public String getClientId()
+ {
+ return assignedClientId;
+ }
+}
Added: trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/Slider.tml
===================================================================
--- trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/Slider.tml (rev 0)
+++ trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/Slider.tml 2009-06-08 10:34:11 UTC (rev 1114)
@@ -0,0 +1,8 @@
+<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+ <div id="track_${clientId}" class="eqslider-track">
+ <div id="handle_${clientId}" class="eqslider-handle">
+ </div>
+ </div>
+ <div id="output_${clientId}" class="eqslider-value">${value}</div>
+ <t:TextField t:id="formValue" style="display:none;"/>
+</t:container>
\ No newline at end of file
Added: trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.css
===================================================================
--- trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.css (rev 0)
+++ trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.css 2009-06-08 10:34:11 UTC (rev 1114)
@@ -0,0 +1,19 @@
+DIV.eqslider-handle {
+ /*width: 5px;*/
+ height: 15px;
+ top: -5px;
+ background-color: #f00;
+ cursor: move;
+}
+
+DIV.eqslider-track {
+ /*width: 200px;*/
+ background-color: #aaa;
+ height: 5px;
+}
+
+DIV.eqslider-value {
+ position: relative;
+ top: -10px;
+ left: 210px;
+}
Added: trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.js
===================================================================
--- trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.js (rev 0)
+++ trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/slider.js 2009-06-08 10:34:11 UTC (rev 1114)
@@ -0,0 +1,274 @@
+// script.aculo.us slider.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008
+
+// Copyright (c) 2005-2008 Marty Haught, Thomas Fuchs
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+// slightly modified from original to assure the increment is used and to allow the slider to be initially hidden
+// for this, two extra parameters "trackLength" and "handleLength" are introduced, which set the style of the elements.
+
+if (!Control) var Control = { };
+
+// options:
+// axis: 'vertical', or 'horizontal' (default)
+//
+// callbacks:
+// onChange(value)
+// onSlide(value)
+Control.ckSlider = Class.create({
+ initialize: function(handle, track, options) {
+ var slider = this;
+
+ if (Object.isArray(handle)) {
+ this.handles = handle.collect( function(e) { return $(e) });
+ } else {
+ this.handles = [$(handle)];
+ }
+
+ this.track = $(track);
+ this.options = options || { };
+
+ this.axis = this.options.axis || 'horizontal';
+ this.increment = this.options.increment || 1;
+ this.step = parseInt(this.options.step || '1');
+ this.range = this.options.range || $R(0,1);
+
+ this.trackLength = parseInt(this.options.trackLength || '200');
+ this.handleLength = parseInt(this.options.handleLength || '5');
+
+ this.value = 0; // assure backwards compat
+ this.values = this.handles.map( function() { return 0 });
+ this.spans = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
+ this.options.startSpan = $(this.options.startSpan || null);
+ this.options.endSpan = $(this.options.endSpan || null);
+
+ this.restricted = this.options.restricted || false;
+
+ this.maximum = this.options.maximum || this.range.end;
+ this.minimum = this.options.minimum || this.range.start;
+
+ // Will be used to align the handle onto the track, if necessary
+ this.alignX = parseInt(this.options.alignX || '0');
+ this.alignY = parseInt(this.options.alignY || '0');
+
+ if ( this.isVertical() ) {
+ this.track.style.height=""+this.trackLength+"px";
+ this.handles[0].style.height=""+this.handleLength+"px";
+ } else {
+ this.track.style.width=""+this.trackLength+"px"
+ this.handles[0].style.width=""+this.handleLength+"px";
+ }
+
+ this.active = false;
+ this.dragging = false;
+ this.disabled = false;
+
+ if (this.options.disabled) this.setDisabled();
+
+ // Allowed values array
+ this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
+ if (this.allowedValues) {
+ this.minimum = this.allowedValues.min();
+ this.maximum = this.allowedValues.max();
+ }
+
+ this.eventMouseDown = this.startDrag.bindAsEventListener(this);
+ this.eventMouseUp = this.endDrag.bindAsEventListener(this);
+ this.eventMouseMove = this.update.bindAsEventListener(this);
+
+ // Initialize handles in reverse (make sure first handle is active)
+ this.handles.each( function(h,i) {
+ i = slider.handles.length-1-i;
+ slider.setValue(parseFloat(
+ (Object.isArray(slider.options.sliderValue) ?
+ slider.options.sliderValue[i] : slider.options.sliderValue) ||
+ slider.range.start), i);
+ h.makePositioned().observe("mousedown", slider.eventMouseDown);
+ });
+
+ this.track.observe("mousedown", this.eventMouseDown);
+ document.observe("mouseup", this.eventMouseUp);
+ document.observe("mousemove", this.eventMouseMove);
+
+ this.initialized = true;
+ },
+ dispose: function() {
+ var slider = this;
+ Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
+ Event.stopObserving(document, "mouseup", this.eventMouseUp);
+ Event.stopObserving(document, "mousemove", this.eventMouseMove);
+ this.handles.each( function(h) {
+ Event.stopObserving(h, "mousedown", slider.eventMouseDown);
+ });
+ },
+ setDisabled: function(){
+ this.disabled = true;
+ },
+ setEnabled: function(){
+ this.disabled = false;
+ },
+ getNearestValue: function(value){
+ value=Math.round(value/this.increment)*this.increment;
+ if (this.allowedValues){
+ if (value >= this.allowedValues.max()) return(this.allowedValues.max());
+ if (value <= this.allowedValues.min()) return(this.allowedValues.min());
+
+ var offset = Math.abs(this.allowedValues[0] - value);
+ var newValue = this.allowedValues[0];
+ this.allowedValues.each( function(v) {
+ var currentOffset = Math.abs(v - value);
+ if (currentOffset <= offset){
+ newValue = v;
+ offset = currentOffset;
+ }
+ });
+ return newValue;
+ }
+ if (value > this.range.end) return this.range.end;
+ if (value < this.range.start) return this.range.start;
+ return value;
+ },
+ setValue: function(sliderValue, handleIdx){
+ if (!this.active) {
+ this.activeHandleIdx = handleIdx || 0;
+ this.activeHandle = this.handles[this.activeHandleIdx];
+ this.updateStyles();
+ }
+ handleIdx = handleIdx || this.activeHandleIdx || 0;
+ if (this.initialized && this.restricted) {
+ if ((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
+ sliderValue = this.values[handleIdx-1];
+ if ((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
+ sliderValue = this.values[handleIdx+1];
+ }
+ sliderValue = this.getNearestValue(sliderValue);
+ this.values[handleIdx] = sliderValue;
+ this.value = this.values[0]; // assure backwards compat
+
+ this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
+ this.translateToPx(sliderValue);
+
+ this.drawSpans();
+ if (!this.dragging || !this.event) this.updateFinished();
+ },
+ setValueBy: function(delta, handleIdx) {
+ this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
+ handleIdx || this.activeHandleIdx || 0);
+ },
+ translateToPx: function(value) {
+ return Math.round(
+ ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
+ (value - this.range.start)) + "px";
+ },
+ translateToValue: function(offset) {
+ return ((offset/(this.trackLength-this.handleLength) *
+ (this.range.end-this.range.start)) + this.range.start);
+ },
+ getRange: function(range) {
+ var v = this.values.sortBy(Prototype.K);
+ range = range || 0;
+ return $R(v[range],v[range+1]);
+ },
+ isVertical: function(){
+ return (this.axis == 'vertical');
+ },
+ drawSpans: function() {
+ var slider = this;
+ if (this.spans)
+ $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
+ if (this.options.startSpan)
+ this.setSpan(this.options.startSpan,
+ $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
+ if (this.options.endSpan)
+ this.setSpan(this.options.endSpan,
+ $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
+ },
+ setSpan: function(span, range) {
+ if (this.isVertical()) {
+ span.style.top = this.translateToPx(range.start);
+ span.style.height = this.translateToPx(range.end - range.start + this.range.start);
+ } else {
+ span.style.left = this.translateToPx(range.start);
+ span.style.width = this.translateToPx(range.end - range.start + this.range.start);
+ }
+ },
+ updateStyles: function() {
+ this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
+ Element.addClassName(this.activeHandle, 'selected');
+ },
+ startDrag: function(event) {
+ if (Event.isLeftClick(event)) {
+ if (!this.disabled){
+ this.active = true;
+
+ var handle = Event.element(event);
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var track = handle;
+ if (track==this.track) {
+ var offsets = Position.cumulativeOffset(this.track);
+ this.event = event;
+ this.setValue(this.translateToValue(
+ (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
+ ));
+ var offsets = Position.cumulativeOffset(this.activeHandle);
+ this.offsetX = (pointer[0] - offsets[0]);
+ this.offsetY = (pointer[1] - offsets[1]);
+ } else {
+ // find the handle (prevents issues with Safari)
+ while((this.handles.indexOf(handle) == -1) && handle.parentNode)
+ handle = handle.parentNode;
+
+ if (this.handles.indexOf(handle)!=-1) {
+ this.activeHandle = handle;
+ this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
+ this.updateStyles();
+
+ var offsets = Position.cumulativeOffset(this.activeHandle);
+ this.offsetX = (pointer[0] - offsets[0]);
+ this.offsetY = (pointer[1] - offsets[1]);
+ }
+ }
+ }
+ Event.stop(event);
+ }
+ },
+ update: function(event) {
+ if (this.active) {
+ if (!this.dragging) this.dragging = true;
+ this.draw(event);
+ if (Prototype.Browser.WebKit) window.scrollBy(0,0);
+ Event.stop(event);
+ }
+ },
+ draw: function(event) {
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var offsets = Position.cumulativeOffset(this.track);
+ pointer[0] -= this.offsetX + offsets[0];
+ pointer[1] -= this.offsetY + offsets[1];
+ this.event = event;
+ this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
+ if (this.initialized && this.options.onSlide)
+ this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
+ },
+ endDrag: function(event) {
+ if (this.active && this.dragging) {
+ this.finishDrag(event, true);
+ Event.stop(event);
+ }
+ this.active = false;
+ this.dragging = false;
+ },
+ finishDrag: function(event, success) {
+ this.active = false;
+ this.dragging = false;
+ this.updateFinished();
+ },
+ updateFinished: function() {
+ if (this.initialized && this.options.onSlide)
+ this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
+ if (this.initialized && this.options.onChange)
+ this.options.onChange(this.values.length>1 ? this.values : this.value, this);
+ this.event = null;
+ }
+});
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-08 08:34:56
|
Revision: 1113
http://equanda.svn.sourceforge.net/equanda/?rev=1113&view=rev
Author: triathlon98
Date: 2009-06-08 08:34:50 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
EQ-130 fix ProgrConstraintsTest and RequiredFieldsTest (includes integrating equandaCheckRules) (47 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HRObject.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectRoot.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/LinkableMediator.java
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-07 10:53:35 UTC (rev 1112)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-08 08:34:50 UTC (rev 1113)
@@ -437,13 +437,13 @@
#end
}
- //@PrePersist
- //@PreUpdate
- public void equandaCheckRules()
+ @PrePersist
+ @PreUpdate
+ public void onChange()
throws EquandaException
{
HT${table.Name} ht = new HT${table.Name}();
- ht.equandaCheckRules( this );
+ ht.equandaOnChange( this );
}
@PreRemove
@@ -451,6 +451,6 @@
throws EquandaException
{
HT${table.Name} ht = new HT${table.Name}();
- ht.equandaRemoveEntity( this );
+ ht.equandaOnRemove( this );
}
}
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HRObject.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HRObject.java.vm 2009-06-07 10:53:35 UTC (rev 1112)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HRObject.java.vm 2009-06-08 08:34:50 UTC (rev 1113)
@@ -54,6 +54,7 @@
import org.equanda.persistence.query.EquandaQueryImpl;
import org.equanda.util.StringUtil;
import ${package}.server.pm.*;
+import ${package}.server.*;
import javax.persistence.EntityManager;
import javax.persistence.Query;
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm 2009-06-07 10:53:35 UTC (rev 1112)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm 2009-06-08 08:34:50 UTC (rev 1113)
@@ -105,9 +105,7 @@
}
#end
#end
-#if( $table.isInherited() )
super.equandaCheckRules( entity );
-#end
}
}
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectRoot.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectRoot.java.vm 2009-06-07 10:53:35 UTC (rev 1112)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectRoot.java.vm 2009-06-08 08:34:50 UTC (rev 1113)
@@ -59,7 +59,15 @@
}
#end
- public void equandaRemoveEntity( DM${table.Name} entity )
+ public void equandaCheckRules( DM${table.Name} entity )
throws EquandaException
{/*nothing to do, please overwrite*/}
+
+ public void equandaOnChange( DM${table.Name} entity )
+ throws EquandaException
+ {/*nothing to do, please overwrite*/}
+
+ public void equandaOnRemove( DM${table.Name} entity )
+ throws EquandaException
+ {/*nothing to do, please overwrite*/}
}
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-07 10:53:35 UTC (rev 1112)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/ProxyObjectUpdater.java.vm 2009-06-08 08:34:50 UTC (rev 1113)
@@ -223,6 +223,7 @@
}
#end
#end
+ getTableHelper( entity ).equandaCheckRules( entity );
}
#if( $hasFields )
catch( EquandaException ee )
@@ -272,3 +273,12 @@
#end
throw new EquandaException( ECV_INVALID_TABLE_TYPE, cname, "table.${table.Name}" );
}
+
+ public static HT${table.Name}Root getTableHelper( DM${table.Name} entity )
+ {
+ HT${table.Name}Root helper = null;
+#foreach( $type in $table.TablesNotInternal )
+ if ( entity instanceof DM${type.Name} ) helper = new HT${type.Name}();
+#end
+ return helper;
+ }
Modified: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/LinkableMediator.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/LinkableMediator.java 2009-06-07 10:53:35 UTC (rev 1112)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/LinkableMediator.java 2009-06-08 08:34:50 UTC (rev 1113)
@@ -41,6 +41,8 @@
{
public static final String REMOVE2_NOT_ALOWED_STRING_TO_ADD = "REMOVE2_NOT_ALOWED_STRING_TO_ADD";
public static final String REMOVE2_NOT_ALOWED_STRING_TO_REMOVE = "REMOVE2_NOT_ALOWED_STRING_TO_REMOVE";
+
+ public void dummy() {}
/*
public void setEquandaLinkSingleBidirectional( Uoid value )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-07 10:53:41
|
Revision: 1112
http://equanda.svn.sourceforge.net/equanda/?rev=1112&view=rev
Author: triathlon98
Date: 2009-06-07 10:53:35 +0000 (Sun, 07 Jun 2009)
Log Message:
-----------
EQ-130 fix PriorityTest (49 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/FieldValidator.java
branches/EQ-130/equanda-test/src/main/dm/Priority.table
branches/EQ-130/equanda-test/src/main/dm/PriorityFields.table
branches/EQ-130/equanda-test/src/main/dm/Vehicle.table
Added Paths:
-----------
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/HTProgrConstraints.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator0.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator1.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator2.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator3.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator4.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator5.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator6.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator7.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator8.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator9.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/VehicleSpeedValidator.java
Removed Paths:
-------------
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/PriorityFieldsMediator.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/ProgrConstraintsMediator.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/VehicleWithWingsMediator.java
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-07 06:10:39 UTC (rev 1111)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-07 10:53:35 UTC (rev 1112)
@@ -105,7 +105,7 @@
#end## hasChoice
#set( $count = 0 )
#foreach( $fv in $field.Validators )
- FieldValidator<${field.WrappingFieldType},EquandaEntity> fv${field.Name}${count} = new $fv().setTableAndField( "${table.Name}", "${field.Name}}" );
+ FieldValidator fv${field.Name}${count} = new $fv().setTableAndField( "${table.Name}", "${field.Name}}" );
#set( $count = $count + 1 )
#end
#end## foreach field
@@ -395,7 +395,7 @@
}
#set( $count = 0 )
#foreach( $fv in $field.Validators )
- ${field.VarName} = fv${field.Name}${count}.validate( ${field.VarName}, this.${field.VarName}, this );
+ ${field.VarName} = (${field.WrappingFieldType}) fv${field.Name}${count}.validate( (${field.WrappingFieldType}) ${field.VarName}, this.${field.VarName}, this );
#set( $count = $count + 1 )
#end
this.${field.VarName} = ${field.VarName};
Modified: branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/FieldValidator.java
===================================================================
--- branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/FieldValidator.java 2009-06-07 06:10:39 UTC (rev 1111)
+++ branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/FieldValidator.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -24,6 +24,7 @@
package org.equanda.validation;
+import org.equanda.client.EquandaException;
import org.equanda.persistence.EquandaConstraintViolation;
import org.equanda.persistence.EquandaEntity;
@@ -48,7 +49,7 @@
* @throws EquandaConstraintViolation when validation failed
*/
TYPE validate( TYPE value, TYPE prevValue, ENTITY entity )
- throws EquandaConstraintViolation;
+ throws EquandaException;
/**
* Used to initialise the validator to know the table and field which it is applied to.
Modified: branches/EQ-130/equanda-test/src/main/dm/Priority.table
===================================================================
--- branches/EQ-130/equanda-test/src/main/dm/Priority.table 2009-06-07 06:10:39 UTC (rev 1111)
+++ branches/EQ-130/equanda-test/src/main/dm/Priority.table 2009-06-07 10:53:35 UTC (rev 1112)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-
+<!DOCTYPE table SYSTEM "equanda.dtd">
+
<table name="Priority">
<security-role-remove>LocalUser</security-role-remove>
Modified: branches/EQ-130/equanda-test/src/main/dm/PriorityFields.table
===================================================================
--- branches/EQ-130/equanda-test/src/main/dm/PriorityFields.table 2009-06-07 06:10:39 UTC (rev 1111)
+++ branches/EQ-130/equanda-test/src/main/dm/PriorityFields.table 2009-06-07 10:53:35 UTC (rev 1112)
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE table SYSTEM "equanda.dtd">
<table name="PriorityFields">
@@ -7,33 +8,63 @@
<page>
<field name="Field0" type="boolean" priority="0">
+ <constraints>
+ <validator>org.equanda.test.validator.PriorityValidator0</validator>
+ </constraints>
<display/>
</field>
<field name="Field7" type="boolean" priority="7">
+ <constraints>
+ <validator>org.equanda.test.validator.PriorityValidator7</validator>
+ </constraints>
<display/>
</field>
<field name="Field9" type="boolean" priority="9">
+ <constraints>
+ <validator>org.equanda.test.validator.PriorityValidator9</validator>
+ </constraints>
<display/>
</field>
<field name="Field3" type="boolean" priority="3">
+ <constraints>
+ <validator>org.equanda.test.validator.PriorityValidator3</validator>
+ </constraints>
<display/>
</field>
<field name="Field6" type="boolean" priority="6">
+ <constraints>
+ <validator>org.equanda.test.validator.PriorityValidator6</validator>
+ </constraints>
<display/>
</field>
<field name="Field1" type="boolean" priority="1">
+ <constraints>
+ <validator>org.equanda.test.validator.PriorityValidator1</validator>
+ </constraints>
<display/>
</field>
<field name="Field2" type="boolean" priority="2">
+ <constraints>
+ <validator>org.equanda.test.validator.PriorityValidator2</validator>
+ </constraints>
<display/>
</field>
<field name="Field5" type="boolean" priority="5">
+ <constraints>
+ <validator>org.equanda.test.validator.PriorityValidator5</validator>
+ </constraints>
<display/>
</field>
<field name="Field8" type="boolean" priority="8">
+ <constraints>
+ <validator>org.equanda.test.validator.PriorityValidator8</validator>
+ </constraints>
<display/>
</field>
<field name="Field4" type="boolean" priority="4">
+ <constraints>
+ <validator>org.equanda.test.validator.PriorityValidator4</validator>
+ </constraints>
<display/>
</field>
Modified: branches/EQ-130/equanda-test/src/main/dm/Vehicle.table
===================================================================
--- branches/EQ-130/equanda-test/src/main/dm/Vehicle.table 2009-06-07 06:10:39 UTC (rev 1111)
+++ branches/EQ-130/equanda-test/src/main/dm/Vehicle.table 2009-06-07 10:53:35 UTC (rev 1112)
@@ -16,7 +16,11 @@
<field name="ColourCode" type="int"/>
- <field name="Speed" type="int"/>
+ <field name="Speed" type="int">
+ <constraints>
+ <validator> org.equanda.test.validator.VehicleSpeedValidator</validator>
+ </constraints>
+ </field>
</page>
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/HTProgrConstraints.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/HTProgrConstraints.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/HTProgrConstraints.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -0,0 +1,45 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.dm.server;
+
+import org.equanda.test.dm.server.pm.DMProgrConstraints;
+import org.equanda.client.EquandaException;
+import org.equanda.persistence.EquandaConstraintViolation;
+
+/**
+ * equandaCheckRules for test for working of programmatic constraints
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class HTProgrConstraints
+ extends HTProgrConstraintsBase
+{
+ @Override
+ public void equandaCheckRules( DMProgrConstraints entity )
+ throws EquandaException
+ {
+ if ( entity.getMultipleOf100() == 3800 ) throw new EquandaConstraintViolation( 3800, "not allowed" );
+ }
+}
Deleted: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/PriorityFieldsMediator.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/PriorityFieldsMediator.java 2009-06-07 06:10:39 UTC (rev 1111)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/PriorityFieldsMediator.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -1,115 +0,0 @@
-/**
- * This file is part of the equanda project.
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
- * ANY KIND, either express or implied. See the License for the specific language governing rights and
- * limitations under the License.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- */
-
-package org.equanda.test.dm.server;
-
-import org.equanda.client.EquandaException;
-
-/**
- * Provisions for testing the order of setting fields in setEquandaProxy calls
- *
- * @author NetRom team
- */
-public class PriorityFieldsMediator
- //extends PriorityFieldsMediatorBase
-{
- /*
- private void add( char number )
- {
- String start = entity.getTest();
- if ( start == null ) start = "";
- entity.setTest( start + number );
- }
-
- public void setField0( boolean field0 )
- throws EquandaException
- {
- add( '0' );
- super.setField0( field0 );
- }
-
- public void setField1( boolean field0 )
- throws EquandaException
- {
- add( '1' );
- super.setField0( field0 );
- }
-
- public void setField2( boolean field0 )
- throws EquandaException
- {
- add( '2' );
- super.setField0( field0 );
- }
-
- public void setField3( boolean field0 )
- throws EquandaException
- {
- add( '3' );
- super.setField0( field0 );
- }
-
- public void setField4( boolean field0 )
- throws EquandaException
- {
- add( '4' );
- super.setField0( field0 );
- }
-
- public void setField5( boolean field0 )
- throws EquandaException
- {
- add( '5' );
- super.setField0( field0 );
- }
-
- public void setField6( boolean field0 )
- throws EquandaException
- {
- add( '6' );
- super.setField0( field0 );
- }
-
- public void setField7( boolean field0 )
- throws EquandaException
- {
- add( '7' );
- super.setField0( field0 );
- }
-
- public void setField8( boolean field0 )
- throws EquandaException
- {
- add( '8' );
- super.setField0( field0 );
- }
-
- public void setField9( boolean field0 )
- throws EquandaException
- {
- add( '9' );
- super.setField0( field0 );
- }
- */
-}
Deleted: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/ProgrConstraintsMediator.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/ProgrConstraintsMediator.java 2009-06-07 06:10:39 UTC (rev 1111)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/ProgrConstraintsMediator.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -1,47 +0,0 @@
-/**
- * This file is part of the equanda project.
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
- * ANY KIND, either express or implied. See the License for the specific language governing rights and
- * limitations under the License.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- */
-
-package org.equanda.test.dm.server;
-
-import org.equanda.client.EquandaException;
-import org.equanda.persistence.EquandaConstraintViolation;
-import org.equanda.test.TestExceptionCodes;
-
-/**
- * test for working of programmatic constraints
- *
- * @author NetRom team
- */
-public class ProgrConstraintsMediator
- //extends ProgrConstraintsMediatorBase
- implements TestExceptionCodes
-{
- /*
- public void equandaCheckRules()
- throws EquandaException
- {
- if ( entity.getMultipleOf100() == 3800 ) throw new EquandaConstraintViolation( 3800, "not allowed" );
- }
- */
-}
Deleted: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/VehicleWithWingsMediator.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/VehicleWithWingsMediator.java 2009-06-07 06:10:39 UTC (rev 1111)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/VehicleWithWingsMediator.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -1,58 +0,0 @@
-/**
- * This file is part of the equanda project.
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
- * ANY KIND, either express or implied. See the License for the specific language governing rights and
- * limitations under the License.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- */
-
-package org.equanda.test.dm.server;
-
-import org.equanda.persistence.EquandaConstraintViolation;
-import org.equanda.persistence.EquandaDowngradeException;
-import org.equanda.test.TestExceptionCodes;
-
-/**
- * Mediator for VehicleWithWings objects
- *
- * @author NetRom team
- */
-public class VehicleWithWingsMediator
- //extends VehicleWithWingsMediatorBase
- implements TestExceptionCodes
-{
- /*
- public void setSpeed( int speed )
- throws EquandaConstraintViolation
- {
- if ( speed < 100 )
- {
- throw new EquandaDowngradeException( EDE_TOO_SLOW_FOR_A_VEHICLE_WITH_WINGS, Integer.toString( speed ) );
- }
- try
- {
- super.setSpeed( speed );
- }
- catch ( Exception e )
- {
- throw new EquandaConstraintViolation( e );
- }
- }
- */
-}
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator0.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator0.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator0.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -0,0 +1,47 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.validator;
+
+import org.equanda.client.EquandaException;
+import org.equanda.test.dm.server.pm.DMPriorityFields;
+import org.equanda.validation.FieldValidatorAdapter;
+
+/**
+ * Validator for PriorityFields test.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class PriorityValidator0
+ extends FieldValidatorAdapter<Boolean, DMPriorityFields>
+{
+ public Boolean validate( Boolean value, Boolean prevValue, DMPriorityFields entity )
+ throws EquandaException
+ {
+ String start = entity.getTest();
+ if ( start == null ) start = "";
+ entity.setTest( start + "0" );
+ return value;
+ }
+}
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator1.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator1.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator1.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -0,0 +1,47 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.validator;
+
+import org.equanda.client.EquandaException;
+import org.equanda.test.dm.server.pm.DMPriorityFields;
+import org.equanda.validation.FieldValidatorAdapter;
+
+/**
+ * Validator for PriorityFields test.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class PriorityValidator1
+ extends FieldValidatorAdapter<Boolean, DMPriorityFields>
+{
+ public Boolean validate( Boolean value, Boolean prevValue, DMPriorityFields entity )
+ throws EquandaException
+ {
+ String start = entity.getTest();
+ if ( start == null ) start = "";
+ entity.setTest( start + "1" );
+ return value;
+ }
+}
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator2.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator2.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator2.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -0,0 +1,47 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.validator;
+
+import org.equanda.client.EquandaException;
+import org.equanda.test.dm.server.pm.DMPriorityFields;
+import org.equanda.validation.FieldValidatorAdapter;
+
+/**
+ * Validator for PriorityFields test.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class PriorityValidator2
+ extends FieldValidatorAdapter<Boolean, DMPriorityFields>
+{
+ public Boolean validate( Boolean value, Boolean prevValue, DMPriorityFields entity )
+ throws EquandaException
+ {
+ String start = entity.getTest();
+ if ( start == null ) start = "";
+ entity.setTest( start + "2" );
+ return value;
+ }
+}
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator3.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator3.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator3.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -0,0 +1,47 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.validator;
+
+import org.equanda.client.EquandaException;
+import org.equanda.test.dm.server.pm.DMPriorityFields;
+import org.equanda.validation.FieldValidatorAdapter;
+
+/**
+ * Validator for PriorityFields test.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class PriorityValidator3
+ extends FieldValidatorAdapter<Boolean, DMPriorityFields>
+{
+ public Boolean validate( Boolean value, Boolean prevValue, DMPriorityFields entity )
+ throws EquandaException
+ {
+ String start = entity.getTest();
+ if ( start == null ) start = "";
+ entity.setTest( start + "3" );
+ return value;
+ }
+}
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator4.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator4.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator4.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -0,0 +1,47 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.validator;
+
+import org.equanda.client.EquandaException;
+import org.equanda.test.dm.server.pm.DMPriorityFields;
+import org.equanda.validation.FieldValidatorAdapter;
+
+/**
+ * Validator for PriorityFields test.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class PriorityValidator4
+ extends FieldValidatorAdapter<Boolean, DMPriorityFields>
+{
+ public Boolean validate( Boolean value, Boolean prevValue, DMPriorityFields entity )
+ throws EquandaException
+ {
+ String start = entity.getTest();
+ if ( start == null ) start = "";
+ entity.setTest( start + "4" );
+ return value;
+ }
+}
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator5.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator5.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator5.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -0,0 +1,47 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.validator;
+
+import org.equanda.client.EquandaException;
+import org.equanda.test.dm.server.pm.DMPriorityFields;
+import org.equanda.validation.FieldValidatorAdapter;
+
+/**
+ * Validator for PriorityFields test.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class PriorityValidator5
+ extends FieldValidatorAdapter<Boolean, DMPriorityFields>
+{
+ public Boolean validate( Boolean value, Boolean prevValue, DMPriorityFields entity )
+ throws EquandaException
+ {
+ String start = entity.getTest();
+ if ( start == null ) start = "";
+ entity.setTest( start + "5" );
+ return value;
+ }
+}
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator6.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator6.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator6.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -0,0 +1,47 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.validator;
+
+import org.equanda.client.EquandaException;
+import org.equanda.test.dm.server.pm.DMPriorityFields;
+import org.equanda.validation.FieldValidatorAdapter;
+
+/**
+ * Validator for PriorityFields test.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class PriorityValidator6
+ extends FieldValidatorAdapter<Boolean, DMPriorityFields>
+{
+ public Boolean validate( Boolean value, Boolean prevValue, DMPriorityFields entity )
+ throws EquandaException
+ {
+ String start = entity.getTest();
+ if ( start == null ) start = "";
+ entity.setTest( start + "6" );
+ return value;
+ }
+}
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator7.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator7.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator7.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -0,0 +1,47 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.validator;
+
+import org.equanda.client.EquandaException;
+import org.equanda.test.dm.server.pm.DMPriorityFields;
+import org.equanda.validation.FieldValidatorAdapter;
+
+/**
+ * Validator for PriorityFields test.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class PriorityValidator7
+ extends FieldValidatorAdapter<Boolean, DMPriorityFields>
+{
+ public Boolean validate( Boolean value, Boolean prevValue, DMPriorityFields entity )
+ throws EquandaException
+ {
+ String start = entity.getTest();
+ if ( start == null ) start = "";
+ entity.setTest( start + "7" );
+ return value;
+ }
+}
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator8.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator8.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator8.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -0,0 +1,47 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.validator;
+
+import org.equanda.client.EquandaException;
+import org.equanda.test.dm.server.pm.DMPriorityFields;
+import org.equanda.validation.FieldValidatorAdapter;
+
+/**
+ * Validator for PriorityFields test.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class PriorityValidator8
+ extends FieldValidatorAdapter<Boolean, DMPriorityFields>
+{
+ public Boolean validate( Boolean value, Boolean prevValue, DMPriorityFields entity )
+ throws EquandaException
+ {
+ String start = entity.getTest();
+ if ( start == null ) start = "";
+ entity.setTest( start + "8" );
+ return value;
+ }
+}
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator9.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator9.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/PriorityValidator9.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -0,0 +1,47 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.validator;
+
+import org.equanda.client.EquandaException;
+import org.equanda.test.dm.server.pm.DMPriorityFields;
+import org.equanda.validation.FieldValidatorAdapter;
+
+/**
+ * Validator for PriorityFields test.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class PriorityValidator9
+ extends FieldValidatorAdapter<Boolean, DMPriorityFields>
+{
+ public Boolean validate( Boolean value, Boolean prevValue, DMPriorityFields entity )
+ throws EquandaException
+ {
+ String start = entity.getTest();
+ if ( start == null ) start = "";
+ entity.setTest( start + "9" );
+ return value;
+ }
+}
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/VehicleSpeedValidator.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/VehicleSpeedValidator.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/VehicleSpeedValidator.java 2009-06-07 10:53:35 UTC (rev 1112)
@@ -0,0 +1,52 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.validator;
+
+import org.equanda.persistence.EquandaConstraintViolation;
+import org.equanda.persistence.EquandaDowngradeException;
+import org.equanda.persistence.EquandaEntity;
+import org.equanda.validation.FieldValidatorAdapter;
+import org.equanda.test.TestExceptionCodes;
+import org.equanda.test.dm.server.pm.DMVehicleWithWings;
+
+/**
+ * Verify whether speed is possible for
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class VehicleSpeedValidator
+ extends FieldValidatorAdapter<Integer,EquandaEntity>
+{
+ public Integer validate( Integer speed, Integer prevValue, EquandaEntity equandaEntity )
+ throws EquandaConstraintViolation
+ {
+ if ( speed < 100 && equandaEntity instanceof DMVehicleWithWings )
+ {
+ throw new EquandaDowngradeException( TestExceptionCodes.EDE_TOO_SLOW_FOR_A_VEHICLE_WITH_WINGS,
+ Integer.toString( speed ) );
+ }
+ return speed;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-07 06:11:43
|
Revision: 1111
http://equanda.svn.sourceforge.net/equanda/?rev=1111&view=rev
Author: triathlon98
Date: 2009-06-07 06:10:39 +0000 (Sun, 07 Jun 2009)
Log Message:
-----------
EQ-130 provisions for equandaCheckRules and equandaRemoveEntity
Modified Paths:
--------------
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectRoot.java.vm
branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/StringLengthTest.java
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-05 10:15:01 UTC (rev 1110)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-07 06:10:39 UTC (rev 1111)
@@ -39,6 +39,7 @@
import ${package}.client.EquandaGlobal;
import ${package}.client.${table.getRoot().Name}SelectorEJB;
+import ${package}.server.HT${table.Name};
import org.equanda.client.EquandaException;
import org.equanda.client.ExceptionCodes;
import org.equanda.persistence.Uoid;
@@ -398,6 +399,7 @@
#set( $count = $count + 1 )
#end
this.${field.VarName} = ${field.VarName};
+
}
#else## field.isLink()
#set( $count = 0 )
@@ -434,4 +436,21 @@
#end
}
+
+ //@PrePersist
+ //@PreUpdate
+ public void equandaCheckRules()
+ throws EquandaException
+ {
+ HT${table.Name} ht = new HT${table.Name}();
+ ht.equandaCheckRules( this );
+ }
+
+ @PreRemove
+ protected void equandaRemoveEntity()
+ throws EquandaException
+ {
+ HT${table.Name} ht = new HT${table.Name}();
+ ht.equandaRemoveEntity( this );
+ }
}
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm 2009-06-05 10:15:01 UTC (rev 1110)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectBase.java.vm 2009-06-07 06:10:39 UTC (rev 1111)
@@ -35,18 +35,13 @@
package ${package}.server;
-import ${package}.client.*;
-import org.equanda.persistence.ObjectType;
-import org.equanda.persistence.query.EquandaQuery;
-import org.equanda.persistence.query.EquandaQueryImpl;
-import org.equanda.persistence.Uoid;
-import org.equanda.persistence.ObjectSelector;
-import org.equanda.persistence.SelectorsState;
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import ${package}.client.EquandaUser;
+import ${package}.server.pm.*;
+import org.equanda.client.EquandaException;
+import org.equanda.client.ExceptionCodes;
+import org.equanda.persistence.EquandaConstraintViolation;
+import org.apache.log4j.Logger;
+import java.util.Collection;
/**
* Base helper class for $table.Name
@@ -59,4 +54,60 @@
extends HT${table.Name}Root
#end
{
+ private static final Logger log = Logger.getLogger( HT${table.Name}Base.class );
+
+ /**
+ * utility routine to allow checking the integrity of the record
+ */
+ public void equandaCheckRules( DM${table.Name} entity )
+ throws EquandaException
+ {
+ #foreach( $field in $table.Fields )
+ #if( $field.isRequired() && !$field.isInherited() && ($field.isString() || $field.isDate() || $field.isTimestamp() || $field.isLink()))
+ #set( $fieldtype=$field.JavaFieldType )
+ #if ( $field.isLink() )#set( $fieldtype="DM${field.LinkTable.Name}" )
+ #elseif ( $field.isMultiple() ) #set( $fieldtype="DM${table.Name}_${field.Name}" )
+ #end
+ #if( $field.isMultiple() )#set( $fieldtype = "Collection<$fieldtype>" )#end
+
+ $fieldtype value${field.Name} = entity.get${field.Name}();
+
+ #if( !$field.isMultiple() )
+ if ( value${field.Name} == null )
+ {
+ throw new EquandaConstraintViolation( ExceptionCodes.ECV_FIELD_IS_REQUIRED, "field.${table.Name}.${field.Name}" );
+ }
+ #else
+ if ( value${field.Name}==null || value${field.Name}.isEmpty() )
+ {
+ throw new EquandaConstraintViolation( ExceptionCodes.ECV_FIELD_IS_REQUIRED, "field.${table.Name}.${field.Name}" );
+ }
+ #end
+
+ #end
+ #end
+#set( $loginPackage="" )
+#set( $loginPackage=$!{engine.getLoginConfig("package")} )
+#if( "x" != "$loginPackage" )
+ #if( "EquandaUser" == $table.Name )
+ ${loginPackage}.LoginCache.setUser( entity.getUserName() );
+ #end
+ #if( "EquandaRole" == $table.Name )
+ ${loginPackage}.LoginCache.setRoleAuths( entity.getRoleName(),
+ new org.equanda.auth.ParsedAuthAndConfigProvider( entity.getAuthAndConfig() ) );
+ for ( EquandaUser user : EquandaUser.selectRole( entity.getId() ) )
+ {
+ try
+ {
+ ${loginPackage}.LoginCache.setUser( user.getUserName() );
+ }
+ catch( Exception ex ) { log.error( ex, ex ); }
+ }
+ #end
+#end
+#if( $table.isInherited() )
+ super.equandaCheckRules( entity );
+#end
+ }
+
}
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectRoot.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectRoot.java.vm 2009-06-05 10:15:01 UTC (rev 1110)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/HTObjectRoot.java.vm 2009-06-07 06:10:39 UTC (rev 1111)
@@ -58,4 +58,8 @@
"$table.Name, ${action.Name}, "+ entity.getClass().getName() );
}
#end
+
+ public void equandaRemoveEntity( DM${table.Name} entity )
+ throws EquandaException
+ {/*nothing to do, please overwrite*/}
}
Modified: branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/StringLengthTest.java
===================================================================
--- branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/StringLengthTest.java 2009-06-05 10:15:01 UTC (rev 1110)
+++ branches/EQ-130/equanda-test/test-test/src/test/java/org/equanda/test/xejb/StringLengthTest.java 2009-06-07 06:10:39 UTC (rev 1111)
@@ -45,6 +45,7 @@
{
StringMaxLen obj = StringMaxLen.equandaCreate();
obj.setStrMax10Chars( "0123456789 + other things" );
+ obj.setStrMax10CharsImmutable( "imm" );
obj.equandaUpdate();
assertEquals( "0123456789", obj.getStrMax10Chars() );
}
@@ -54,6 +55,7 @@
{
StringMaxLen obj = StringMaxLen.equandaCreate();
obj.setStrMax10Chars( "shortstr" );
+ obj.setStrMax10CharsImmutable( "imm" );
obj.equandaUpdate();
assertEquals( "shortstr", obj.getStrMax10Chars() );
}
@@ -81,6 +83,7 @@
{
StringMaxLen obj = StringMaxLen.equandaCreate();
obj.getStrMax10CharsMultiple().add( "0123456789 + other things" );
+ obj.setStrMax10CharsImmutable( "imm" );
obj.equandaUpdate();
assertTrue( obj.getStrMax10CharsMultiple().contains( "0123456789" ) );
@@ -91,6 +94,7 @@
{
StringMaxLen obj = StringMaxLen.equandaCreate();
obj.getStrMax10CharsMultiple().add( "shortstr" );
+ obj.setStrMax10CharsImmutable( "imm" );
obj.equandaUpdate();
assertTrue( obj.getStrMax10CharsMultiple().contains( "shortstr" ) );
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tri...@us...> - 2009-06-05 10:15:06
|
Revision: 1110
http://equanda.svn.sourceforge.net/equanda/?rev=1110&view=rev
Author: triathlon98
Date: 2009-06-05 10:15:01 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
EQ-130 support for FieldValidator classes, first impl (still 50 tests to go)
Modified Paths:
--------------
branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Constraints.java
branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Field.java
branches/EQ-130/equanda-dm/src/main/resources/equanda.dtd
branches/EQ-130/equanda-dm/src/test/java/org/equanda/domain/xml/ConstraintsTest.java
branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
branches/EQ-130/equanda-test/src/main/dm/ProgrConstraints.table
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/ProgrConstraintsMediator.java
Added Paths:
-----------
branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/FieldValidator.java
branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/FieldValidatorAdapter.java
branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/MultipleOf100Validator.java
Removed Paths:
-------------
branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/SimpleValidator.java
branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/SimpleValidatorAdaptor.java
Modified: branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Constraints.java
===================================================================
--- branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Constraints.java 2009-06-04 13:38:37 UTC (rev 1109)
+++ branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Constraints.java 2009-06-05 10:15:01 UTC (rev 1110)
@@ -65,6 +65,9 @@
private ValueWhenNull valueWhenNull;
@XStreamAlias( "value-when-zero" )
private ValueWhenZero valueWhenZero;
+ @XStreamImplicit
+ @XStreamAlias( "validator" )
+ private List<String> validators;
@XStreamOmitField
private String uniqueConverter;
@@ -452,4 +455,10 @@
{
return uniqueConverter;
}
+
+ public List<String> getValidators()
+ {
+ if ( null == validators ) validators = new ArrayList<String>();
+ return validators;
+ }
}
Modified: branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Field.java
===================================================================
--- branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Field.java 2009-06-04 13:38:37 UTC (rev 1109)
+++ branches/EQ-130/equanda-dm/src/main/java/org/equanda/domain/xml/Field.java 2009-06-05 10:15:01 UTC (rev 1110)
@@ -1158,6 +1158,11 @@
return constraints != null && constraints.getValueWhenZero() != null;
}
+ public List<String> getValidators()
+ {
+ return constraints == null ? null : constraints.getValidators();
+ }
+
public boolean hasDelegatePath()
{
if ( constraints == null ) return false;
Modified: branches/EQ-130/equanda-dm/src/main/resources/equanda.dtd
===================================================================
--- branches/EQ-130/equanda-dm/src/main/resources/equanda.dtd 2009-06-04 13:38:37 UTC (rev 1109)
+++ branches/EQ-130/equanda-dm/src/main/resources/equanda.dtd 2009-06-05 10:15:01 UTC (rev 1110)
@@ -350,7 +350,7 @@
-->
<!ELEMENT default (#PCDATA)>
<!ATTLIST default
-type (value|auto|class) "value">
+type (value|auto|class-name) "value">
<!--
auto fields are calculated by the application and stored in the database. They have no setter.
@@ -416,7 +416,8 @@
(immutable)?,
(immutable-if|mutable-even-if|compare)*,
(value-when-null)?,
- (value-when-zero)?
+ (value-when-zero)?,
+ (validator)*
)>
<!--
@@ -487,7 +488,12 @@
path CDATA #IMPLIED
>
+<!--
+ Validator which can be used to check the constraints. Should be a fully qualified classname.
+-->
+<!ELEMENT validator (#PCDATA)>
+
<!--
define a selector method which selects records based on the selection criteria
A select can either define criteria (selection tags), or define a list of subselects.
Modified: branches/EQ-130/equanda-dm/src/test/java/org/equanda/domain/xml/ConstraintsTest.java
===================================================================
--- branches/EQ-130/equanda-dm/src/test/java/org/equanda/domain/xml/ConstraintsTest.java 2009-06-04 13:38:37 UTC (rev 1109)
+++ branches/EQ-130/equanda-dm/src/test/java/org/equanda/domain/xml/ConstraintsTest.java 2009-06-05 10:15:01 UTC (rev 1110)
@@ -52,6 +52,8 @@
" <compare test=\"!=\"/>" +
" <compare test=\">=\"/>" +
" <compare test=\"<=\"/>" +
+ " <validator>bla.bla.Something</validator>" +
+ " <validator>da.da.Else</validator>" +
"</constraints>";
XStream stream = getXStreamInstance();
Object res = stream.fromXML( test );
@@ -70,6 +72,9 @@
assertEquals( 3, constraints.getCompares().size() );
assertNull( constraints.getValueWhenNull() );
assertNull( constraints.getValueWhenZero() );
+ assertEquals( 2, constraints.getValidators().size() );
+ assertEquals( "bla.bla.Something", constraints.getValidators().get( 0 ) );
+ assertEquals( "da.da.Else", constraints.getValidators().get( 1 ) );
}
public void testParse2()
@@ -99,5 +104,6 @@
assertEquals( 0, constraints.getCompares().size() );
assertNotNull( constraints.getValueWhenNull() );
assertNotNull( constraints.getValueWhenZero() );
+ assertEquals( 0, constraints.getValidators().size() );
}
}
Modified: branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm
===================================================================
--- branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-04 13:38:37 UTC (rev 1109)
+++ branches/EQ-130/equanda-generate/src/main/velocity/ejb3/DMObject.java.vm 2009-06-05 10:15:01 UTC (rev 1110)
@@ -46,6 +46,7 @@
import org.equanda.persistence.EquandaConstraintViolation;
import org.equanda.persistence.EquandaEntity;
import org.equanda.util.StringUtil;
+import org.equanda.validation.FieldValidator;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.CacheConcurrencyStrategy;
@@ -93,7 +94,7 @@
#set( $constants=[] )
#foreach( $field in $table.Fields )
#if( $field.hasChoice() ) #set( $quote='' )
-#if( $field.isString() ) #set( $quote='"' ) #end
+ #if( $field.isString() ) #set( $quote='"' ) #end
#foreach( $choice in $field.ChoicesNotFromClass )
#if( !$constants.contains($choice.Name) )
#set( $discard=$constants.add($choice.Name) )
@@ -101,6 +102,11 @@
#end
#end##foreach choice
#end## hasChoice
+#set( $count = 0 )
+#foreach( $fv in $field.Validators )
+ FieldValidator<${field.WrappingFieldType},EquandaEntity> fv${field.Name}${count} = new $fv().setTableAndField( "${table.Name}", "${field.Name}}" );
+#set( $count = $count + 1 )
+#end
#end## foreach field
#foreach( $field in $table.FieldsNotCalculated )
@@ -386,10 +392,20 @@
}
#end
}
+#set( $count = 0 )
+#foreach( $fv in $field.Validators )
+ ${field.VarName} = fv${field.Name}${count}.validate( ${field.VarName}, this.${field.VarName}, this );
+#set( $count = $count + 1 )
+#end
this.${field.VarName} = ${field.VarName};
}
#else## field.isLink()
- this.${field.VarName} = ${field.VarName};
+#set( $count = 0 )
+#foreach( $fv in $field.Validators )
+ ${field.VarName} = fv${field.Name}${count}.validate( ${field.VarName}, this.${field.VarName}, this );
+#set( $count = $count + 1 )
+#end
+ this.${field.VarName} = ${field.VarName};
#end## field.isLink()
}
Added: branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/FieldValidator.java
===================================================================
--- branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/FieldValidator.java (rev 0)
+++ branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/FieldValidator.java 2009-06-05 10:15:01 UTC (rev 1110)
@@ -0,0 +1,62 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.validation;
+
+import org.equanda.persistence.EquandaConstraintViolation;
+import org.equanda.persistence.EquandaEntity;
+
+/**
+ * This interface needs to be implemented to handle the programmatic field level constraints.
+ * These constraints can both be used to validate but also to transform.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public interface FieldValidator<TYPE, ENTITY extends EquandaEntity>
+{
+ /**
+ * Perform the actual validation. The new and previous values are passed and also the actual entity (which
+ * allows cross-fields check if necessary).
+ * When validation succeeds, the value should be returned. This also allows transforming the value.
+ * When the validation fails, a EquandaConstraintViolation needs to be thrown (which will be propagated).
+ *
+ * @param value new value.
+ * @param prevValue previous value
+ * @param entity the actual entity instance
+ * @return the (possibly modified) value which will be set in the field
+ * @throws EquandaConstraintViolation when validation failed
+ */
+ TYPE validate( TYPE value, TYPE prevValue, ENTITY entity )
+ throws EquandaConstraintViolation;
+
+ /**
+ * Used to initialise the validator to know the table and field which it is applied to.
+ * This can then be used to determine what to do or to provide more meaningful error messages.
+ *
+ * @param table table name the field is part of
+ * @param field field on which the constraint is applied
+ * @return this
+ */
+ FieldValidator<TYPE, ENTITY> setTableAndField( String table, String field );
+}
Added: branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/FieldValidatorAdapter.java
===================================================================
--- branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/FieldValidatorAdapter.java (rev 0)
+++ branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/FieldValidatorAdapter.java 2009-06-05 10:15:01 UTC (rev 1110)
@@ -0,0 +1,45 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.validation;
+
+import org.equanda.persistence.EquandaEntity;
+
+/**
+ * Adapter for the FieldValidator interface
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public abstract class FieldValidatorAdapter<TYPE, ENTITY extends EquandaEntity>
+ implements FieldValidator<TYPE, ENTITY>
+{
+ protected String table, field;
+
+ public FieldValidator<TYPE, ENTITY> setTableAndField( String table, String field )
+ {
+ this.table = table;
+ this.field = field;
+ return this;
+ }
+}
Deleted: branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/SimpleValidator.java
===================================================================
--- branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/SimpleValidator.java 2009-06-04 13:38:37 UTC (rev 1109)
+++ branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/SimpleValidator.java 2009-06-05 10:15:01 UTC (rev 1110)
@@ -1,36 +0,0 @@
-/**
- * This file is part of the equanda project.
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
- * ANY KIND, either express or implied. See the License for the specific language governing rights and
- * limitations under the License.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- */
-
-package org.equanda.validation;
-
-/**
- * Used for validating rendering border items.
- * isValid will be implementing to test something, if needed.
- *
- * @author <a href="mailto:fl...@pa...">Florin</a>
- */
-public interface SimpleValidator
-{
- public boolean isValid();
-}
Deleted: branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/SimpleValidatorAdaptor.java
===================================================================
--- branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/SimpleValidatorAdaptor.java 2009-06-04 13:38:37 UTC (rev 1109)
+++ branches/EQ-130/equanda-server/src/main/java/org/equanda/validation/SimpleValidatorAdaptor.java 2009-06-05 10:15:01 UTC (rev 1110)
@@ -1,39 +0,0 @@
-/**
- * This file is part of the equanda project.
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
- * ANY KIND, either express or implied. See the License for the specific language governing rights and
- * limitations under the License.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- */
-
-package org.equanda.validation;
-
-/**
- * Just an implementation so we can test BorderItems with a border containing a validator...
- *
- * @author <a href="mailto:fl...@pa...">Florin</a>
- */
-public class SimpleValidatorAdaptor
- implements SimpleValidator
-{
- public boolean isValid()
- {
- return false;
- }
-}
Modified: branches/EQ-130/equanda-test/src/main/dm/ProgrConstraints.table
===================================================================
--- branches/EQ-130/equanda-test/src/main/dm/ProgrConstraints.table 2009-06-04 13:38:37 UTC (rev 1109)
+++ branches/EQ-130/equanda-test/src/main/dm/ProgrConstraints.table 2009-06-05 10:15:01 UTC (rev 1110)
@@ -5,6 +5,9 @@
<page>
<field name="MultipleOf100" type="int">
<display/>
+ <constraints>
+ <validator>org.equanda.test.validator.MultipleOf100Validator</validator>
+ </constraints>
</field>
</page>
</table>
Modified: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/ProgrConstraintsMediator.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/ProgrConstraintsMediator.java 2009-06-04 13:38:37 UTC (rev 1109)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/dm/server/ProgrConstraintsMediator.java 2009-06-05 10:15:01 UTC (rev 1110)
@@ -38,16 +38,6 @@
implements TestExceptionCodes
{
/*
- public void setMultipleOf100( int multipleOf100 )
- throws EquandaException
- {
- if ( multipleOf100 % 100 != 0 )
- {
- throw new EquandaConstraintViolation( ECV_NUMBER_NOT_MULTIPLE_OF_100, Integer.toString( multipleOf100 ) );
- }
- super.setMultipleOf100( multipleOf100 );
- }
-
public void equandaCheckRules()
throws EquandaException
{
Added: branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/MultipleOf100Validator.java
===================================================================
--- branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/MultipleOf100Validator.java (rev 0)
+++ branches/EQ-130/equanda-test/test-core/src/main/java/org/equanda/test/validator/MultipleOf100Validator.java 2009-06-05 10:15:01 UTC (rev 1110)
@@ -0,0 +1,50 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.test.validator;
+
+import org.equanda.persistence.EquandaConstraintViolation;
+import org.equanda.persistence.EquandaEntity;
+import org.equanda.test.TestExceptionCodes;
+import org.equanda.validation.FieldValidatorAdapter;
+
+/**
+ * Verify that the value to check is a multiple of 100.
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class MultipleOf100Validator
+ extends FieldValidatorAdapter<Integer, EquandaEntity>
+{
+ public Integer validate( Integer value, Integer prevValue, EquandaEntity equandaEntity )
+ throws EquandaConstraintViolation
+ {
+ if ( value % 100 != 0 )
+ {
+ throw new EquandaConstraintViolation( TestExceptionCodes.ECV_NUMBER_NOT_MULTIPLE_OF_100,
+ Integer.toString( value ) );
+ }
+ return value;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|