Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 15372 invoked from network); 19 Jul 2007 20:53:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Jul 2007 20:53:41 -0000 Received: (qmail 9619 invoked by uid 500); 19 Jul 2007 20:53:15 -0000 Mailing-List: contact jdo-commits-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-commits@db.apache.org Received: (qmail 9522 invoked by uid 99); 19 Jul 2007 20:53:14 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jul 2007 13:53:14 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jul 2007 13:53:07 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 211D31A981D; Thu, 19 Jul 2007 13:52:47 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r557767 [2/4] - in /db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc: company/ companyAnnotatedApp/ companyAnnotatedDS/ companyAnnotatedFC/ companyAnnotatedPI/ Date: Thu, 19 Jul 2007 20:52:33 -0000 To: jdo-commits@db.apache.org From: mcaisse@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070719205247.211D31A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppInsurance.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppInsurance.java?view=auto&rev=557767 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppInsurance.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppInsurance.java Thu Jul 19 13:52:29 2007 @@ -0,0 +1,300 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.tck.pc.companyAnnotatedFC; + +import javax.jdo.annotations.*; + +import java.io.Serializable; + +import java.util.Comparator; +import org.apache.jdo.tck.pc.company.IEmployee; + +import org.apache.jdo.tck.pc.company.IInsurance; +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents an insurance carrier selection for a particular + * FCAppEmployee. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION,table="insuranceplans" ) +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR", indexed="true") +@Index(name="INS_DISCRIMINATOR_INDEX", unique="false", + columns=@Column(name="DISCRIMINATOR")) +public class FCAppInsurance + implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { + + @Field(primaryKey="true") + @Column(name="INSID") + private long insid; + @Column(name="CARRIER") + private String carrier; + @Column(name="EMPLOYEE") + private FCAppEmployee employee; + + /** This is the JDO-required no-args constructor. */ + protected FCAppInsurance() {} + + /** + * Construct an FCAppInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + */ + protected FCAppInsurance(long insid, String carrier) { + this.insid = insid; + this.carrier = carrier; + } + + /** + * Construct an FCAppInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + */ + protected FCAppInsurance(long insid, String carrier, IEmployee employee) { + this.insid = insid; + this.carrier = carrier; + this.employee = (FCAppEmployee)employee; + } + + /** + * Get the insurance ID. + * @return the insurance ID. + */ + public long getInsid() { + return insid; + } + + /** + * Set the insurance ID. + * @param id The insurance ID value. + */ + public void setInsid(long id) { + if (this.insid != 0) + throw new IllegalStateException("Id is already set."); + this.insid = id; + } + + /** + * Get the insurance carrier. + * @return The insurance carrier. + */ + public String getCarrier() { + return carrier; + } + + /** + * Set the insurance carrier. + * @param carrier The insurance carrier. + */ + public void setCarrier(String carrier) { + this.carrier = carrier; + } + + /** + * Get the associated employee. + * @return The employee for this insurance. + */ + public IEmployee getEmployee() { + return employee; + } + + /** + * Set the associated employee. + * @param employee The associated employee. + */ + public void setEmployee(IEmployee employee) { + this.employee = (FCAppEmployee)employee; + } + + /** + * Returns a String representation of a FCAppInsurance object. + * + * @return a String representation of a FCAppInsurance object. + */ + public String toString() { + return "FCInsurance(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(insid); + rc.append(", carrier ").append(carrier); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppInsurance otherIns = (FCAppInsurance)other; + String where = "FCInsurance<" + insid + ">"; + return + helper.equals(insid, otherIns.getInsid(), where + ".insid") & + helper.equals(carrier, otherIns.getCarrier(), where + ".carrier") & + helper.deepEquals(employee, otherIns.getEmployee(), where + ".employee"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCAppInsurance)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCAppInsurance)o1, (FCAppInsurance)o2); + } + + /** + * Compares this object with the specified Insurance object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Insurance object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Insurance object. + */ + public int compareTo(FCAppInsurance other) { + return compare(this, other); + } + + /** + * Compares its two IInsurance arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IInsurance object to be compared. + * @param o2 the second IInsurance object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCAppInsurance o1, FCAppInsurance o2) { + return EqualityHelper.compare(o1.getInsid(), o2.getInsid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCAppInsurance) { + return compareTo((FCAppInsurance)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)insid; + } + + /** + * This class is used to represent the application + * identifier for the Insurance class. + */ + public static class Oid implements Serializable, Comparable + { + /** + * This field represents the application identifier for the + * Insurance class. It must match the field in the + * Insurance class in both name and type. + */ + public long insid; + + /** + * The required public no-args constructor. + */ + public Oid() { } + + /** + * Initialize with an insurance identifier. + * @param insid the insurance ID. + */ + public Oid(long insid) { + this.insid = insid; + } + + public Oid(String s) { insid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + insid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o=(Oid) obj; + if( this.insid!=o.insid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) insid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( insid < other.insid ) return -1; + if( insid > other.insid ) return 1; + return 0; + } + + } + +} + Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppInsurance.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMedicalInsurance.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMedicalInsurance.java?view=auto&rev=557767 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMedicalInsurance.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMedicalInsurance.java Thu Jul 19 13:52:29 2007 @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.tck.pc.companyAnnotatedFC; + +import javax.jdo.annotations.*; +import org.apache.jdo.tck.pc.company.IEmployee; + +import org.apache.jdo.tck.pc.company.IMedicalInsurance; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a dental insurance carrier selection for a + * particular Employee. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION) +public class FCAppMedicalInsurance extends FCAppInsurance implements IMedicalInsurance { + + @Column(name="PLANTYPE") + private String planType; // possible values: "PPO", "EPO", "NPO" + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCAppMedicalInsurance() {} + + /** + * Construct a FCAppMedicalInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param planType The planType. + */ + public FCAppMedicalInsurance(long insid, String carrier, + String planType) + { + super(insid, carrier); + this.planType = planType; + } + + /** + * Construct a FCAppMedicalInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param planType The planType. + */ + public FCAppMedicalInsurance(long insid, String carrier, + IEmployee employee, String planType) + { + super(insid, carrier, (FCAppEmployee)employee); + this.planType = planType; + } + + /** + * Get the insurance planType. + * @return The insurance planType. + */ + public String getPlanType() { + return planType; + } + + /** + * Set the insurance planType. + * @param planType The insurance planType. + */ + public void setPlanType(String planType) { + this.planType = planType; + } + + /** + * Returns a String representation of a FCAppMedicalInsurance + * object. + * + * @return a String representation of a FCAppMedicalInsurance + * object. + */ + public String toString() { + return "FCMedicalInsurance(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", planType ").append(planType); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppMedicalInsurance otherIns = (FCAppMedicalInsurance)other; + String where = "FCMedicalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(planType, otherIns.getPlanType(), where + ".planType"); + } +} + Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMedicalInsurance.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPartTimeEmployee.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPartTimeEmployee.java?view=auto&rev=557767 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPartTimeEmployee.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPartTimeEmployee.java Thu Jul 19 13:52:29 2007 @@ -0,0 +1,136 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.tck.pc.companyAnnotatedFC; + +import javax.jdo.annotations.*; + +import java.util.Date; + +import org.apache.jdo.tck.pc.company.IPartTimeEmployee; +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a part-time employee. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +public class FCAppPartTimeEmployee extends FCAppEmployee + implements IPartTimeEmployee { + + @Column(name="WAGE") + private double wage; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCAppPartTimeEmployee() {} + + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public FCAppPartTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double wage ) { + super(personid, first, last, middle, born, hired); + this.wage = wage; + } + + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param addr The person's address. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public FCAppPartTimeEmployee(long personid, String first, String last, + String middle, Date born, FCAppAddress addr, + Date hired, double wage ) { + super(personid, first, last, middle, born, addr, hired); + this.wage = wage; + } + + /** + * Get the wage of the part-time employee. + * @return The wage of the part-time employee. + */ + public double getWage() { + return wage; + } + + /** + * Set the wage of the part-time employee. + * @param wage The wage of the part-time employee. + */ + public void setWage(double wage) { + this.wage = wage; + } + + /** + * Returns a String representation of a FCAppPartTimeEmployee object. + * + * @return a String representation of a FCAppPartTimeEmployee object. + */ + public String toString() { + return "FCPartTimeEmployee(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $" + wage); + return rc.toString(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * FCAppPartTimeEmployee. + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppPartTimeEmployee otherEmp = (FCAppPartTimeEmployee)other; + String where = "FCPartTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(wage, otherEmp.getWage(), where + ".wage"); + } +} Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPartTimeEmployee.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPerson.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPerson.java?view=auto&rev=557767 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPerson.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPerson.java Thu Jul 19 13:52:29 2007 @@ -0,0 +1,455 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.jdo.tck.pc.companyAnnotatedFC; + +import javax.jdo.annotations.*; + +import java.io.Serializable; + +import java.text.SimpleDateFormat; + +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import org.apache.jdo.tck.pc.company.IAddress; + +import org.apache.jdo.tck.pc.company.IPerson; +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a person. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION,table="persons") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR", indexed="true") +public class FCAppPerson + implements IPerson, Serializable, Comparable, Comparator, DeepEquality { + + @Field(primaryKey="true") + @Column(name="PERSONID") + private long personid; + @Column(name="FIRSTNAME") + private String firstname; + @Column(name="LASTNAME") + private String lastname; + @Field(defaultFetchGroup="false") + @Column(name="MIDDLENAME", allowsNull="true") + private String middlename; + private Date birthdate; + @Field(persistenceModifier=FieldPersistenceModifier.PERSISTENT) + @Embedded(nullIndicatorColumn="COUNTRY", + fields={ + @Field(name="addrid", columns=@Column(name="ADDRID")), + @Field(name="street", columns=@Column(name="STREET")), + @Field(name="city", columns=@Column(name="CITY")), + @Field(name="state", columns=@Column(name="STATE")), + @Field(name="zipcode", columns=@Column(name="ZIPCODE")), + @Field(name="country", columns=@Column(name="COUNTRY")) + }) + private FCAppAddress address; + + // maps phone number types ("home", "work", "mobile", etc.) + // to phone numbers specified as String + @Field(persistenceModifier=FieldPersistenceModifier.PERSISTENT, table="employee_phoneno_type") + @Join(column="EMPID") + @Key(types=java.lang.String.class, column="TYPE") + @Value(types=java.lang.String.class, column="PHONENO") + private Map phoneNumbers = new HashMap(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. */ + protected FCAppPerson() {} + + /** + * Construct a FCAppPerson instance. + * + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + */ + public FCAppPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate) { + this.personid = personid; + this.firstname = firstname; + this.lastname = lastname; + this.middlename = middlename; + this.birthdate = birthdate; + } + + /** + * Construct a FCAppPerson instance. + * + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + * @param address The person's address. + */ + public FCAppPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address) { + this(personid, firstname, lastname, middlename, birthdate); + this.address = (FCAppAddress)address; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setPersonid(long id) { + if (this.personid != 0) + throw new IllegalStateException("Id is already set."); + this.personid = id; + } + + /** + * Get the person's id. + * @return The personid. + */ + public long getPersonid() { + return personid; + } + + /** + * Set the person's id. + * @param personid The personid. + */ + public void setLastname(long personid) { + this.personid = personid; + } + + /** + * Get the person's last name. + * @return The last name. + */ + public String getLastname() { + return lastname; + } + + /** + * Set the person's last name. + * @param lastname The last name. + */ + public void setLastname(String lastname) { + this.lastname = lastname; + } + + /** + * Get the person's first name. + * @return The first name. + */ + public String getFirstname() { + return firstname; + } + + /** + * Set the person's first name. + * @param firstname The first name. + */ + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + /** + * Get the person's middle name. + * @return The middle name. + */ + public String getMiddlename() { + return middlename; + } + + /** + * Set the person's middle name. + * @param middlename The middle name. + */ + public void setMiddlename(String middlename) { + this.middlename = middlename; + } + + /** + * Get the address. + * @return The address. + */ + public IAddress getAddress() { + return address; + } + + /** + * Set the address. + * @param address The address. + */ + public void setAddress(IAddress address) { + this.address = (FCAppAddress)address; + } + + /** + * Get the person's birthdate. + * @return The person's birthdate. + */ + public Date getBirthdate() { + return birthdate; + } + + /** + * Set the person's birthdate. + * @param birthdate The person's birthdate. + */ + public void setBirthdate(Date birthdate) { + this. birthdate = birthdate; + } + + /** + * Get the map of phone numbers as an unmodifiable map. + * @return The map of phone numbers, as an unmodifiable map. + */ + public Map getPhoneNumbers() { + return Collections.unmodifiableMap(phoneNumbers); + } + + /** + * Get the phone number for the specified phone number type. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String getPhoneNumber(String type) { + return (String)phoneNumbers.get(type); + } + + /** + * Associates the specified phone number with the specified type in the + * map of phone numbers of this person. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @param phoneNumber The phone number + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String putPhoneNumber(String type, String phoneNumber) { + return (String)phoneNumbers.put(type, phoneNumber); + } + + /** + * Remove a phoneNumber from the map of phone numbers. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String removePhoneNumber(String type) { + return (String)phoneNumbers.remove(type); + } + + /** + * Set the phoneNumber map to be in this person. + * @param phoneNumbers The map of phoneNumbers for this person. + */ + public void setPhoneNumbers(Map phoneNumbers) { + // workaround: create a new HashMap, because fostore does not + // support LinkedHashMap + this.phoneNumbers = + (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; + } + + /** + * Returns a String representation of a FCAppPerson object. + * + * @return a string representation of a FCAppPerson object. + */ + public String toString() { + return "FCPerson(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(personid); + rc.append(", ").append(lastname); + rc.append(", ").append(firstname); + rc.append(", born ").append(formatter.format(birthdate)); + rc.append(", phone ").append(phoneNumbers); + return rc.toString(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified FCAppPerson. + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppPerson otherPerson = (FCAppPerson)other; + String where = "FCPerson<" + personid + ">"; + return + helper.equals(personid, otherPerson.getPersonid(), where + ".personid") & + helper.equals(firstname, otherPerson.getFirstname(), where + ".firstname") & + helper.equals(lastname, otherPerson.getLastname(), where + ".lastname") & + helper.equals(middlename, otherPerson.getMiddlename(), where + ".middlename") & + helper.equals(birthdate, otherPerson.getBirthdate(), where + ".birthdate") & + helper.deepEquals(address, otherPerson.getAddress(), where + ".address") & + helper.deepEquals(phoneNumbers, otherPerson.getPhoneNumbers(), where + ".phoneNumbers"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCAppPerson)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCAppPerson)o1, (FCAppPerson)o2); + } + + /** + * + * Compares this object with the specified FCAppPerson object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * + * @param other The FCAppPerson object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified FFCAppPerson + * object. + */ + public int compareTo(FCAppPerson other) { + return compare(this, other); + } + + /** + * Compares its two IPerson arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IPerson object to be compared. + * @param o2 the second IPerson object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCAppPerson o1, FCAppPerson o2) { + return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCAppPerson) { + return compareTo((FCAppPerson)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)personid; + } + /** + * This class is used to represent the application identifier + * for the Person class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the Person + * class. It must match a field in the Person class in + * both name and type. + */ + public long personid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the identifier. + * @param personid The person identifier. + */ + public Oid(long personid) { + this.personid = personid; + } + + public Oid(String s) { personid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + personid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o = (Oid) obj; + if( this.personid != o.personid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) personid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( personid < other.personid ) return -1; + if( personid > other.personid ) return 1; + return 0; + } + + } + +} Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPerson.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppProject.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppProject.java?view=auto&rev=557767 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppProject.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppProject.java Thu Jul 19 13:52:29 2007 @@ -0,0 +1,389 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.tck.pc.companyAnnotatedFC; + +import javax.jdo.annotations.*; + +import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + +import java.util.Collections; +import java.util.Comparator; +import java.util.Set; +import java.util.HashSet; +import java.math.BigDecimal; + +import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a project, a budgeted task with one or more + * employees working on it. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION, table="projects") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +public class FCAppProject + implements IProject, Serializable, Comparable, Comparator, DeepEquality { + + @Field(primaryKey="true") + @Column(name="PROJID") + private long projid; + @Column(name="NAME") + private String name; + @Column(name="BUDGET", jdbcType="DECIMAL", length=11, scale=2) + private BigDecimal budget; + @Field(persistenceModifier=FieldPersistenceModifier.PERSISTENT, + table="project_reviewer") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class, + column="REVIEWER") + @Join(column="PROJID") + //@Join(column="PROJID", foreignKey=@ForeignKey(name="PR_PROJ_FK")) + private transient Set reviewers = new HashSet(); + @Field(persistenceModifier=FieldPersistenceModifier.PERSISTENT, + table="project_member") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class, + column="MEMBER") + //@Element(types=org.apache.jdo.tck.pc.companyAnnotatedApp.FCAppEmployee.class, + // foreignKey=@ForeignKey(name="PR_REV_FK")) + @Join(column="PROJID") + private transient Set members = new HashSet(); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCAppProject() {} + + /** + * Initialize a project. + * @param projid The project identifier. + * @param name The name of the project. + * @param budget The budget for the project. + */ + public FCAppProject(long projid, String name, BigDecimal budget) { + this.projid = projid; + this.name = name; + this.budget = budget; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setProjid(long id) { + if (this.projid != 0) + throw new IllegalStateException("Id is already set."); + this.projid = id; + } + + /** + * Get the project ID. + * @return The project ID. + */ + public long getProjid() { + return projid; + } + + /** + * Get the name of the project. + * @return The name of the project. + */ + public String getName() { + return name; + } + + /** + * Set the name of the project. + * @param name The name of the project. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the project's budget. + * @return The project's budget. + */ + public BigDecimal getBudget() { + return budget; + } + + /** + * Set the project's budget. + * @param budget The project's budget. + */ + public void setBudget(BigDecimal budget) { + this.budget = budget; + } + + /** + * Get the reviewers associated with this project. + */ + public Set getReviewers() { + return Collections.unmodifiableSet(reviewers); + } + + /** + * Add a reviewer to the project. + * @param emp The employee to add as a reviewer. + */ + public void addReviewer(FCAppEmployee emp) { + reviewers.add(emp); + } + + /** + * Remove a reviewer from the project. + * @param emp The employee to remove as a reviewer of this project. + */ + public void removeReviewer(FCAppEmployee emp) { + reviewers.remove(emp); + } + + /** + * Set the reviewers associated with this project. + * @param reviewers The set of reviewers to associate with this project. + */ + public void setReviewers(Set reviewers) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.reviewers = (reviewers != null) ? new HashSet(reviewers) : null; + } + + /** + * Get the project members. + * + * @return The members of the project is returned as an unmodifiable + * set of FCAppEmployees. + */ + public Set getMembers() { + return Collections.unmodifiableSet(members); + } + + /** + * Add a new member to the project. + * @param emp The employee to add to the project. + */ + public void addMember(FCAppEmployee emp) { + members.add(emp); + } + + /** + * Remove a member from the project. + * @param emp The employee to remove from the project. + */ + public void removeMember(FCAppEmployee emp) { + members.remove(emp); + } + + /** + * Set the members of the project. + * @param employees The set of employees to be the members of this + * project. + */ + public void setMembers(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.members = (members != null) ? new HashSet(employees) : null; + } + + /** Serialization support: initialize transient fields. */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + reviewers = new HashSet(); + members = new HashSet(); + } + + /** + * Returns a String representation of a FCAppProject object. + * + * @return a String representation of a FCAppProject object. + */ + public String toString() { + return "FCProject(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(projid); + rc.append(", name ").append(name); + rc.append(", budget ").append(budget); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppProject otherProject = (FCAppProject)other; + String where = "FCProject<" + projid + ">"; + return + helper.equals(projid, otherProject.getProjid(), where + ".projid") & + helper.equals(name, otherProject.getName(), where + ".name") & + helper.equals(budget, otherProject.getBudget(), where + ".budget") & + helper.deepEquals(reviewers, otherProject.getReviewers(), where + ".reviewers") & + helper.deepEquals(members, otherProject.getMembers(), where + ".members"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCAppProject)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCAppProject)o1, (FCAppProject)o2); + } + + /** + * + * Compares this object with the specified FCAppProject object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * + * @param other The FCAppProject object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified FFCAppProject object. + */ + public int compareTo(FCAppProject other) { + return compare(this, other); + } + + /** + * Compares its two IProject arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IProject object to be compared. + * @param o2 the second IProject object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCAppProject o1, FCAppProject o2) { + return EqualityHelper.compare(o1.getProjid(), o2.getProjid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCAppProject) { + return compareTo((FCAppProject)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)projid; + } + + /** + * This class is used to represent the application identity + * for the FCAppProject class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the + * FCAppProject class. It must match a field in the + * FCAppProject class in both name and type. + */ + public long projid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the application identifier with a project ID. + * @param projid The id of the project. + */ + public Oid(long projid) { + this.projid = projid; + } + + public Oid(String s) { projid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + projid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.projid != o.projid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) projid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( projid < other.projid ) return -1; + if( projid > other.projid ) return 1; + return 0; + } + + } + +} + Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppProject.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSAddress.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSAddress.java?view=auto&rev=557767 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSAddress.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSAddress.java Thu Jul 19 13:52:29 2007 @@ -0,0 +1,345 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.tck.pc.companyAnnotatedFC; + +import java.io.Serializable; +import java.util.Comparator; + +import javax.jdo.annotations.*; +import org.apache.jdo.tck.pc.company.IAddress; + +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a postal address. + */ +@PersistenceCapable(embeddedOnly="true", requiresExtent="false") +public class FCDSAddress + implements IAddress, Serializable, Comparable, Comparator, DeepEquality { + + private long addrid; + private String street; + private String city; + private String state; + private String zipcode; + private String country; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCDSAddress() {} + + /** + * This constructor initializes the FCDSAddress components. + * + * @param addrid The address ID. + * @param street The street address. + * @param city The city. + * @param state The state. + * @param zipcode The zip code. + * @param country The zip country. + */ + public FCDSAddress(long addrid, String street, String city, + String state, String zipcode, String country) + { + this.addrid = addrid; + this.street = street; + this.city = city; + this.state = state; + this.zipcode = zipcode; + this.country = country; + } + + /** + * Get the addrid associated with this object. + * @return the addrid. + */ + public long getAddrid() { + return addrid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setAddrid(long id) { + if (this.addrid != 0) + throw new IllegalStateException("Id is already set."); + this.addrid = id; + } + + /** + * Get the street component of the address. + * @return The street component of the address. + */ + public String getStreet() { + return street; + } + + /** + * Set the street component of the address. + * @param street The street component. + */ + public void setStreet(String street) { + this.street = street; + } + + /** + * Get the city. + * @return The city component of the address. + */ + public String getCity() { + return city; + } + + /** + * Set the city component of the address. + * @param city The city. + */ + public void setCity(String city) { + this.city = city; + } + + /** + * Get the state component of the address. + * @return The state. + */ + public String getState() { + return state; + } + + /** + * Set the state component of the address. + * @param state The state. + */ + public void setState(String state) { + this.state = state; + } + + /** + * Get the zipcode component of the address. + * @return The zipcode. + */ + public String getZipcode() { + return zipcode; + } + + /** + * Set the zip code component of the address. + * @param zipcode The zipcode. + */ + public void setZipcode(String zipcode) { + this.zipcode = zipcode; + } + + /** + * Get the country component of the address. + * @return The country. + */ + public String getCountry() { + return country; + } + + /** + * Set the country component of the address. + * @param country The country. + */ + public void setCountry(String country) { + this.country = country; + } + + /** + * Returns a String representation of a Address object. + * @return a String representation of a Address object. + */ + public String toString() { + return "Address(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(addrid); + rc.append(", street ").append(street); + rc.append(", city ").append(city); + rc.append(", state ").append(state); + rc.append(", zipcode ").append(zipcode); + rc.append(", country ").append(country); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSAddress otherAddress = (FCDSAddress)other; + String where = "Address<" + addrid + ">"; + return + helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & + helper.equals(street, otherAddress.getStreet(), where + ".street") & + helper.equals(city, otherAddress.getCity(), where + ".city") & + helper.equals(state, otherAddress.getState(), where + ".state") & + helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & + helper.equals(country, otherAddress.getCountry(), where + ".country"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCDSAddress)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCDSAddress)o1, (FCDSAddress)o2); + } + + /** + * Compares this object with the specified Address object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Address object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Address + * object. + */ + public int compareTo(FCDSAddress other) { + return compare(this, other); + } + + /** + * Compares its two FCDSAddress arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * + * @param o1 the first FCDSAddress object to be compared. + * @param o2 the second FFCDSAddressobject to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCDSAddress o1, FCDSAddress o2) { + return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCDSAddress) { + return compareTo((FCDSAddress)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)addrid; + } + + /** + * This class is used to represent the application identifier + * for the Address class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for Address and must + * correspond in type and name to the field in + * Address. + */ + public long addrid; + + /** The required public, no-arg constructor. */ + public Oid() + { + addrid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param addrid the id of the Address. + */ + public Oid(long addrid) { + this.addrid = addrid; + } + + public Oid(String s) { addrid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + addrid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.addrid != o.addrid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) addrid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( addrid < other.addrid ) return -1; + if( addrid > other.addrid ) return 1; + return 0; + } + + } + +} Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSAddress.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSCompany.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSCompany.java?view=auto&rev=557767 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSCompany.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSCompany.java Thu Jul 19 13:52:29 2007 @@ -0,0 +1,394 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.tck.pc.companyAnnotatedFC; + +import javax.jdo.annotations.*; + +import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + +import java.text.SimpleDateFormat; + +import java.util.Collections; +import java.util.Comparator; +import java.util.Set; +import java.util.HashSet; +import java.util.Date; +import org.apache.jdo.tck.pc.company.IAddress; +import org.apache.jdo.tck.pc.company.ICompany; + +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents information about a company. + */ +@PersistenceCapable(table="companies") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") +public class FCDSCompany + implements ICompany, Serializable, Comparable, Comparator, DeepEquality { + + @Column(name="ID") + private long companyid; + @Column(name="NAME", jdbcType="VARCHAR") + private String name; + @Column(name="FOUNDEDDATE") + private Date founded; + @Field(persistenceModifier=FieldPersistenceModifier.PERSISTENT) + @Embedded(nullIndicatorColumn="COUNTRY", + fields={ + @Field(name="addrid", columns=@Column(name="ADDRID")), + @Field(name="street", columns=@Column(name="STREET")), + @Field(name="city", columns=@Column(name="CITY")), + @Field(name="state", columns=@Column(name="STATE")), + @Field(name="zipcode", columns=@Column(name="ZIPCODE")), + @Field(name="country", columns=@Column(name="COUNTRY")) + }) + private FCDSAddress address; + @Field(persistenceModifier=FieldPersistenceModifier.PERSISTENT, + mappedBy="company") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSDepartment.class) + private transient Set departments = new HashSet(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCDSCompany() {} + + /** + * + * Initialize the FCDSCompany instance. + * + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + */ + public FCDSCompany(long companyid, String name, Date founded) { + this.companyid = companyid; + this.name = name; + this.founded = founded; + } + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + * @param addr The company's address. + */ + public FCDSCompany(long companyid, String name, Date founded, IAddress addr) { + this(companyid, name, founded); + this.address = (FCDSAddress)addr; + } + + /** + * Get the company id. + * @return The company id. + */ + public long getCompanyid() { + return companyid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setCompanyid(long id) { + if (this.companyid != 0) + throw new IllegalStateException("Id is already set."); + this.companyid = id; + } + + /** + * Get the name of the company. + * @return The name of the company. + */ + public String getName() { + return name; + } + + /** + * Set the name of the company. + * @param name The value to use for the name of the company. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the date that the company was founded. + * @return The date the company was founded. + */ + public Date getFounded() { + return founded; + } + + /** + * Set the date that the company was founded. + * @param founded The date to set that the company was founded. + */ + public void setFounded(Date founded) { + this.founded = founded; + } + + /** + * Get the address of the company. + * @return The primary address of the company. + */ + public IAddress getAddress() { + return address; + } + + /** + * Set the primary address for the company. + * @param address The address to set for the company. + */ + public void setAddress(IAddress address) { + this.address = (FCDSAddress)address; + } + + /** + * Get the departments contained in the company. + * + * @return An unmodifiable Set that contains all the + * FCDSDepartments of the company. + */ + public Set getDepartments() { + return Collections.unmodifiableSet(departments); + } + + /** + * Add a FCDSDepartment instance to the company. + * + * @param dept The FCDSDepartment instance to add. + */ + public void addDepartment(FCDSDepartment dept) { + departments.add(dept); + } + + /** + * Remove a FCDSDepartment instance from the company. + * + * @param dept The FCDSDepartment instance to remove. + */ + public void removeDepartment(FCDSDepartment dept) { + departments.remove(dept); + } + + /** + * Initialize the set of FCDSDepartments in the company to the + * parameter. + * + * @param departments The set of FCDSDepartments for the + * company. + */ + public void setDepartments(Set departments) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.departments = + (departments != null) ? new HashSet(departments) : null; + } + + /** Serialization support: initialize transient fields. */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + departments = new HashSet(); + } + + /** + * Returns a String representation of a Company object. + * @return a String representation of a Company object. + */ + public String toString() { + return "Company(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(companyid); + rc.append(", name ").append(name); + rc.append(", founded ").append(formatter.format(founded)); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSCompany otherCompany = (FCDSCompany)other; + String where = "Company<" + companyid + ">"; + return + helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") & + helper.equals(name, otherCompany.getName(), where + ".name") & + helper.equals(founded, otherCompany.getFounded(), where + ".founded") & + helper.deepEquals(address, otherCompany.getAddress(), where + ".address") & + helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCDSCompany)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCDSCompany)o1, (FCDSCompany)o2); + } + + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(FCDSCompany other) { + return compare(this, other); + } + + /** + * Compares its two ICompany arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first ICompany object to be compared. + * @param o2 the second ICompany object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCDSCompany o1, FCDSCompany o2) { + return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCDSCompany) { + return compareTo((FCDSCompany)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)companyid; + } + + /** + * The class to be used as the application identifier + * for the Company class. It consists of both the company + * name and the date that the company was founded. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the Company class. + */ + public long companyid; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param companyid The id of the company. + */ + public Oid(long companyid) { + this.companyid = companyid; + } + + public Oid(String s) { companyid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + companyid;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.companyid != o.companyid) + return false; + return true; + } + + /** */ + public int hashCode() { + return (int)companyid; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( companyid < other.companyid ) return -1; + if( companyid > other.companyid ) return 1; + return 0; + } + + } + +} + Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSCompany.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSDentalInsurance.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSDentalInsurance.java?view=auto&rev=557767 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSDentalInsurance.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSDentalInsurance.java Thu Jul 19 13:52:29 2007 @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.tck.pc.companyAnnotatedFC; + +import javax.jdo.annotations.*; + +import java.math.BigDecimal; +import org.apache.jdo.tck.pc.company.IDentalInsurance; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a dental insurance carrier selection for a + * particular Employee. + */ +@PersistenceCapable +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class FCDSDentalInsurance extends FCDSInsurance + implements IDentalInsurance { + + @Column(name="LIFETIME_ORTHO_BENEFIT") + private BigDecimal lifetimeOrthoBenefit; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCDSDentalInsurance() {} + + /** + * Construct a DentalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public FCDSDentalInsurance(long insid, String carrier, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Construct a FCDSDentalInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public FCDSDentalInsurance(long insid, String carrier, FCDSEmployee employee, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier, employee); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Get the insurance lifetimeOrthoBenefit. + * @return The insurance lifetimeOrthoBenefit. + */ + public BigDecimal getLifetimeOrthoBenefit() { + return lifetimeOrthoBenefit; + } + + /** + * Set the insurance lifetimeOrthoBenefit. + * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. + */ + public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Returns a String representation of a FCDSDentalInsurance + * object. + * + * @return a String representation of a FCDSDentalInsurance + * object. + */ + public String toString() { + return "FCDentalInsurance(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", lifetimeOrthoBenefit ").append(lifetimeOrthoBenefit); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSDentalInsurance otherIns = (FCDSDentalInsurance)other; + String where = "FCDentalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(lifetimeOrthoBenefit, + otherIns.getLifetimeOrthoBenefit(), where + ".lifetimeOrthoBenefit"); + } + +} + Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSDentalInsurance.java ------------------------------------------------------------------------------ svn:eol-style = LF