summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2008-08-18 09:11:38 (EDT)
committerCarsten Drossel2008-08-18 09:11:38 (EDT)
commitb19bb4f7164a3c566119c9af38196af7c1b6ba62 (patch)
tree1f330706b878181f2cdd1b97377e4e0598184123
parent30bd5abf5e674ad9cbc5f0763cbf557b26d84dae (diff)
downloadorg.eclipse.riena-b19bb4f7164a3c566119c9af38196af7c1b6ba62.zip
org.eclipse.riena-b19bb4f7164a3c566119c9af38196af7c1b6ba62.tar.gz
org.eclipse.riena-b19bb4f7164a3c566119c9af38196af7c1b6ba62.tar.bz2
fixed a test by changing implementation from Set to List to guarantee order
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/objecttransaction/list/value/Kunde.java126
1 files changed, 71 insertions, 55 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/objecttransaction/list/value/Kunde.java b/org.eclipse.riena.tests/src/org/eclipse/riena/objecttransaction/list/value/Kunde.java
index 2b8b892..36a526b 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/objecttransaction/list/value/Kunde.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/objecttransaction/list/value/Kunde.java
@@ -1,7 +1,7 @@
package org.eclipse.riena.objecttransaction.list.value;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.riena.objecttransaction.AbstractTransactedObject;
import org.eclipse.riena.objecttransaction.ITransactedObject;
@@ -10,7 +10,7 @@ import org.eclipse.riena.objecttransaction.ObjectTransactionManagerAccessor;
/**
* Sample class for "Kunde"
- *
+ *
* @author Christian Campo
*/
public class Kunde extends AbstractTransactedObject implements ITransactedObject {
@@ -19,52 +19,55 @@ public class Kunde extends AbstractTransactedObject implements ITransactedObject
private String nachname;
private String kundennr;
private Addresse addresse;
- private HashSet<Vertrag> vertraege;
+ private List<Vertrag> vertraege;
/** constructor called by webservices only for clean objects * */
@SuppressWarnings("unused")
private Kunde() {
super();
- if ( ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus() ) {
- ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().register( this );
+ if (ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus()) {
+ ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().register(this);
} else {
- throw new InvalidTransactionFailure( "cannot instantiate Kunde with private method if not in clean state" );
+ throw new InvalidTransactionFailure("cannot instantiate Kunde with private method if not in clean state");
}
}
/**
* @param kundennr
*/
- public Kunde( String kundennr ) {
- super( new GenericOID( "kunde", "kundennrpk", kundennr ), "1" );
- if ( ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus() ) {
- ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().register( this );
+ public Kunde(String kundennr) {
+ super(new GenericOID("kunde", "kundennrpk", kundennr), "1");
+ if (ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus()) {
+ ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().register(this);
} else {
- ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().registerNew( this );
+ ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().registerNew(this);
}
- setKundennr( kundennr );
- vertraege = new HashSet<Vertrag>();
+ setKundennr(kundennr);
+ vertraege = new ArrayList<Vertrag>();
}
/**
* @return Returns the kundennr.
*/
public String getKundennr() {
- return (String) ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().getReference( this, "kundennr", kundennr );
+ return (String) ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().getReference(
+ this, "kundennr", kundennr);
}
/**
- * @param kundennr The kundennr to set.
+ * @param kundennr
+ * The kundennr to set.
*/
- public void setKundennr( String kundennr ) {
- if ( ( (GenericOID) getObjectId() ).getProperties().get( "primkey" ) != null ) {
- throw new UnsupportedOperationException( "cannot change kundennr (once it is set)" );
+ public void setKundennr(String kundennr) {
+ if (((GenericOID) getObjectId()).getProperties().get("primkey") != null) {
+ throw new UnsupportedOperationException("cannot change kundennr (once it is set)");
}
// changeEvent
- if ( ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus() ) {
+ if (ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus()) {
this.kundennr = kundennr;
} else {
- ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().setReference( this, "kundennr", kundennr );
+ ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().setReference(this,
+ "kundennr", kundennr);
}
}
@@ -72,18 +75,21 @@ public class Kunde extends AbstractTransactedObject implements ITransactedObject
* @return Returns the nachname.
*/
public String getNachname() {
- return (String) ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().getReference( this, "nachname", nachname );
+ return (String) ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().getReference(
+ this, "nachname", nachname);
}
/**
- * @param nachname The nachname to set.
+ * @param nachname
+ * The nachname to set.
*/
- public void setNachname( String nachname ) {
+ public void setNachname(String nachname) {
// changeEvent
- if ( ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus() ) {
+ if (ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus()) {
this.nachname = nachname;
} else {
- ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().setReference( this, "nachname", nachname );
+ ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().setReference(this,
+ "nachname", nachname);
}
}
@@ -91,18 +97,21 @@ public class Kunde extends AbstractTransactedObject implements ITransactedObject
* @return Returns the vorname.
*/
public String getVorname() {
- return (String) ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().getReference( this, "vorname", vorname );
+ return (String) ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().getReference(
+ this, "vorname", vorname);
}
/**
- * @param vorname The vorname to set.
+ * @param vorname
+ * The vorname to set.
*/
- public void setVorname( String vorname ) {
+ public void setVorname(String vorname) {
// changeEvent
- if ( ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus() ) {
+ if (ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus()) {
this.vorname = vorname;
} else {
- ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().setReference( this, "vorname", vorname );
+ ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().setReference(this, "vorname",
+ vorname);
}
}
@@ -110,54 +119,60 @@ public class Kunde extends AbstractTransactedObject implements ITransactedObject
* @return Returns the addresse.
*/
public Addresse getAddresse() {
- return (Addresse) ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().getReference( this, "addresse", addresse );
+ return (Addresse) ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().getReference(
+ this, "addresse", addresse);
}
/**
- * @param addresse The addresse to set.
+ * @param addresse
+ * The addresse to set.
*/
- public void setAddresse( Addresse addresse ) {
+ public void setAddresse(Addresse addresse) {
// changeEvent
- if ( ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus() ) {
+ if (ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus()) {
this.addresse = addresse;
} else {
- ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().setReference( this, "addresse", addresse );
+ ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().setReference(this,
+ "addresse", addresse);
}
}
/**
* @param vertrag
*/
- public void addVertrag( Vertrag vertrag ) {
- if ( ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus() ) {
- vertraege.add( vertrag );
+ public void addVertrag(Vertrag vertrag) {
+ if (ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus()) {
+ vertraege.add(vertrag);
} else {
- ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().addReference( this, "vertrag", vertrag );
+ ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().addReference(this, "vertrag",
+ vertrag);
}
}
/**
* @param vertragsNummer
*/
- public void removeVertrag( String vertragsNummer ) {
- Vertrag tempVertrag = getVertrag( vertragsNummer );
+ public void removeVertrag(String vertragsNummer) {
+ Vertrag tempVertrag = getVertrag(vertragsNummer);
// changeEvent
- if ( ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus() ) {
- vertraege.remove( getVertrag( vertragsNummer ) );
+ if (ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus()) {
+ vertraege.remove(getVertrag(vertragsNummer));
} else {
- ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().removeReference( this, "vertrag", tempVertrag );
+ ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().removeReference(this,
+ "vertrag", tempVertrag);
}
}
/**
* @param vertrag
*/
- public void removeVertrag( Vertrag vertrag ) {
+ public void removeVertrag(Vertrag vertrag) {
// changeEvent
- if ( ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus() ) {
- vertraege.remove( vertrag );
+ if (ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().isCleanModus()) {
+ vertraege.remove(vertrag);
} else {
- ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().removeReference( this, "vertrag", vertrag );
+ ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().removeReference(this,
+ "vertrag", vertrag);
}
}
@@ -165,10 +180,10 @@ public class Kunde extends AbstractTransactedObject implements ITransactedObject
* @param vertragsNummer
* @return
*/
- public Vertrag getVertrag( String vertragsNummer ) {
+ public Vertrag getVertrag(String vertragsNummer) {
Vertrag[] tempVertraege = listVertrag();
- for ( int i = 0; i < tempVertraege.length; i++ ) {
- if ( tempVertraege[i].getVertragsNummer().equals( vertragsNummer ) ) {
+ for (int i = 0; i < tempVertraege.length; i++) {
+ if (tempVertraege[i].getVertragsNummer().equals(vertragsNummer)) {
return tempVertraege[i];
}
}
@@ -179,10 +194,11 @@ public class Kunde extends AbstractTransactedObject implements ITransactedObject
* @return
*/
public Vertrag[] listVertrag() {
- Set<Vertrag> vertraegeSet = ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent().listReference( this, "vertrag", vertraege );
- if ( vertraegeSet.size() == 0 ) {
+ List<Vertrag> vertraegeSet = ObjectTransactionManagerAccessor.fetchObjectTransactionManager().getCurrent()
+ .listReference(this, "vertrag", vertraege);
+ if (vertraegeSet.size() == 0) {
return new Vertrag[0];
}
- return vertraegeSet.toArray( new Vertrag[vertraegeSet.size()] );
+ return vertraegeSet.toArray(new Vertrag[vertraegeSet.size()]);
}
} \ No newline at end of file