From jdo-commits-return-1882-apmail-db-jdo-commits-archive=www.apache.org@db.apache.org Tue Aug 14 17:17:06 2007 Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 60479 invoked from network); 14 Aug 2007 17:16:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Aug 2007 17:16:49 -0000 Received: (qmail 76117 invoked by uid 500); 14 Aug 2007 17:16:46 -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 76106 invoked by uid 99); 14 Aug 2007 17:16:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Aug 2007 10:16:45 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED 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; Tue, 14 Aug 2007 17:16:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8E5941A9823; Tue, 14 Aug 2007 10:16:19 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r565841 [4/4] - in /db/jdo/trunk/tck2: ./ src/conf/ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/ Date: Tue, 14 Aug 2007 17:16:10 -0000 To: jdo-commits@db.apache.org From: mcaisse@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070814171619.8E5941A9823@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java?view=auto&rev=565841 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java Tue Aug 14 10:16:06 2007 @@ -0,0 +1,311 @@ +/* + * 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.companyAnnotatedPC; + +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 + * PCDSEmployee. + */ +@PersistenceCapable(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")) +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") +public class PCDSInsurance + implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { + + @NotPersistent() + private long _insid; + @NotPersistent() + private String _carrier; + @NotPersistent() + private PCDSEmployee _employee; + + /** This is the JDO-required no-args constructor. */ + protected PCDSInsurance() {} + + /** + * Construct an PCDSInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + */ + protected PCDSInsurance(long insid, String carrier) { + this._insid = insid; + this._carrier = carrier; + } + + /** + * Construct an PCDSInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + */ + protected PCDSInsurance(long insid, String carrier, PCDSEmployee employee) { + this._insid = insid; + this._carrier = carrier; + this._employee = employee; + } + + /** + * Get the insurance ID. + * @return the insurance ID. + */ + + @Column(name="INSID") + 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. + */ + + @Column(name="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. + */ + + @Column(name="EMPLOYEE") + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + public IEmployee getEmployee() { + return _employee; + } + + /** + * Set the associated employee. + * @param employee The associated employee. + */ + public void setEmployee(IEmployee employee) { + this._employee = (PCDSEmployee)employee; + } + + /** + * Returns a String representation of a PCDSInsurance object. + * + * + * @return a String representation of a PCDSInsurance 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) { + PCDSInsurance otherIns = (PCDSInsurance)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((PCDSInsurance)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSInsurance)o1, (PCDSInsurance)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(PCDSInsurance 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(PCDSInsurance o1, PCDSInsurance 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 PCDSInsurance) { + return compareTo((PCDSInsurance)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/companyAnnotatedPC/PCDSInsurance.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java?view=auto&rev=565841 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java Tue Aug 14 10:16:06 2007 @@ -0,0 +1,132 @@ +/* + * 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.companyAnnotatedPC; + +import javax.jdo.annotations.*; +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 +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class PCDSMedicalInsurance extends PCDSInsurance + implements IMedicalInsurance { + + @NotPersistent() + 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 PCDSMedicalInsurance() {} + + /** + * Construct a PCDSMedicalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param planType The planType. + */ + public PCDSMedicalInsurance(long insid, String carrier, + String planType) + { + super(insid, carrier); + this._planType = planType; + } + + /** + * Construct a PCDSMedicalInsurance 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 PCDSMedicalInsurance(long insid, String carrier, + PCDSEmployee employee, String planType) + { + super(insid, carrier, employee); + this._planType = planType; + } + + /** + * Get the insurance planType. + * @return The insurance planType. + */ + + @Column(name="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 PCDSMedicalInsurance + * object. + * + * + * @return a String representation of a PCDSMedicalInsurance + * 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) { + PCDSMedicalInsurance otherIns = (PCDSMedicalInsurance)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/companyAnnotatedPC/PCDSMedicalInsurance.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java?view=auto&rev=565841 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java Tue Aug 14 10:16:06 2007 @@ -0,0 +1,139 @@ +/* + * 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.companyAnnotatedPC; + +import javax.jdo.annotations.*; + +import java.util.Date; +import org.apache.jdo.tck.pc.company.IAddress; +import org.apache.jdo.tck.pc.company.IPartTimeEmployee; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a part-time employee. + */ +@PersistenceCapable +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class PCDSPartTimeEmployee extends PCDSEmployee implements IPartTimeEmployee { + + @NotPersistent() + private double _wage; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSPartTimeEmployee() {} + + /** + * 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 PCDSPartTimeEmployee(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 PCDSPartTimeEmployee(long personid, String first, String last, + String middle, Date born, IAddress addr, + Date hired, double wage ) { + super(personid, first, last, middle, born, (PCDSAddress)addr, hired); + this._wage = wage; + } + + /** + * Get the wage of the part-time employee. + * @return The wage of the part-time employee. + */ + + @Column(name="WAGE") + 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 PCDSPartTimeEmployee object. + * + * + * @return a String representation of a PCDSPartTimeEmployee 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 + * PCDSPartTimeEmployee. + * + * + * @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) { + PCDSPartTimeEmployee otherEmp = (PCDSPartTimeEmployee)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/companyAnnotatedPC/PCDSPartTimeEmployee.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java?view=auto&rev=565841 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java Tue Aug 14 10:16:06 2007 @@ -0,0 +1,473 @@ +/* + * 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.companyAnnotatedPC; + +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(table="persons") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR", indexed="true") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") +public class PCDSPerson + implements IPerson, Serializable, Comparable, Comparator, DeepEquality { + + @NotPersistent() + private long _personid; + @NotPersistent() + private String _firstname; + @NotPersistent() + private String _lastname; + @NotPersistent() + private String _middlename; + @NotPersistent() + private Date _birthdate; + @NotPersistent() + private PCDSAddress _address; + @NotPersistent() + private Map _phoneNumbers = new HashMap(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. */ + protected PCDSPerson() {} + + /** + * Construct a PCDSPerson 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 PCDSPerson(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 PCDSPerson 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 PCDSPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address) { + this(personid, firstname, lastname, middlename, birthdate); + this._address = (PCDSAddress)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. + */ + + @Column(name="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. + */ + + @Column(name="LASTNAME") + 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. + */ + + @Column(name="FIRSTNAME") + 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. + */ + + @Persistent(defaultFetchGroup="false") + @Column(name="MIDDLENAME", allowsNull="true") + 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. + */ + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSAddress.class) + @Embedded(nullIndicatorColumn="COUNTRY", + members={ + @Persistent(name="addrid", columns=@Column(name="ADDRID")), + @Persistent(name="street", columns=@Column(name="STREET")), + @Persistent(name="city", columns=@Column(name="CITY")), + @Persistent(name="state", columns=@Column(name="STATE")), + @Persistent(name="zipcode", columns=@Column(name="ZIPCODE")), + @Persistent(name="country", columns=@Column(name="COUNTRY")) + }) + public IAddress getAddress() { + return _address; + } + + /** + * Set the address. + * @param address The address. + */ + public void setAddress(IAddress address) { + this._address = (PCDSAddress)address; + } + + /** + * Get the person's birthdate. + * @return The person's birthdate. + */ + @Column(name="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. + */ + // maps phone number types ("home", "work", "mobile", etc.) + // to phone numbers specified as String + @Persistent(table="employee_phoneno_type") + @Join(column="EMPID") + @Key(types=java.lang.String.class, column="TYPE") + @Value(types=java.lang.String.class, column="PHONENO") + public Map getPhoneNumbers() { + return _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 PCDSPerson object. + * + * + * @return a string representation of a PCDSPerson 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 PCDSPerson. + * + * + * @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) { + PCDSPerson otherPerson = (PCDSPerson)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((PCDSPerson)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSPerson)o1, (PCDSPerson)o2); + } + + /** + * + * Compares this object with the specified PCDSPerson 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 PCDSPerson 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 PCDSPerson + * object. + */ + public int compareTo(PCDSPerson 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(PCDSPerson o1, PCDSPerson 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 PCDSPerson) { + return compareTo((PCDSPerson)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/companyAnnotatedPC/PCDSPerson.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java?view=auto&rev=565841 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java Tue Aug 14 10:16:06 2007 @@ -0,0 +1,397 @@ +/* + * 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.companyAnnotatedPC; + +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(table="projects") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class PCDSProject + implements IProject, Serializable, Comparable, Comparator, DeepEquality { + + @NotPersistent() + private long _projid; + @NotPersistent() + private String _name; + @NotPersistent() + private BigDecimal _budget; + @NotPersistent() + private transient Set _reviewers = new HashSet(); + @NotPersistent() + 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 PCDSProject() {} + + /** + * Initialize a project. + * @param projid The project identifier. + * @param name The name of the project. + * @param budget The budget for the project. + */ + public PCDSProject(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. + */ + + @Column(name="PROJID") + public long getProjid() { + return _projid; + } + + /** + * Get the name of the project. + * @return The name of the project. + */ + + @Column(name="NAME") + 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. + */ + + @Column(name="BUDGET", jdbcType="DECIMAL", length=11, scale=2) + 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. + */ + + @Persistent(table="project_reviewer") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class, + column="REVIEWER", foreignKey="PR_REV_FK") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + public Set getReviewers() { + return _reviewers; + } + + /** + * Add a reviewer to the project. + * @param emp The employee to add as a reviewer. + */ + public void addReviewer(PCDSEmployee 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(PCDSEmployee 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 a + * set of PCDSEmployees. + */ + + @Persistent(table="project_member") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class, + column="MEMBER", foreignKey="PR_MEMB_FK") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + public Set getMembers() { + return _members; + } + + /** + * Add a new member to the project. + * @param emp The employee to add to the project. + */ + public void addMember(PCDSEmployee emp) { + _members.add(emp); + } + + /** + * Remove a member from the project. + * @param emp The employee to remove from the project. + */ + public void removeMember(PCDSEmployee 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 PCDSProject object. + * + * + * @return a String representation of a PCDSProject 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) { + PCDSProject otherProject = (PCDSProject)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((PCDSProject)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSProject)o1, (PCDSProject)o2); + } + + /** + * + * Compares this object with the specified PCDSProject 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 PCDSProject 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 PCDSProject object. + */ + public int compareTo(PCDSProject 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(PCDSProject o1, PCDSProject 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 PCDSProject) { + return compareTo((PCDSProject)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 PCDSProject class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the + * PCDSProject class. It must match a field in the + * PCDSProject 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/companyAnnotatedPC/PCDSProject.java ------------------------------------------------------------------------------ svn:eol-style = LF