Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 60487 invoked from network); 14 Aug 2007 17:16:51 -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:51 -0000 Received: (qmail 76206 invoked by uid 500); 14 Aug 2007 17:16:49 -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 76195 invoked by uid 99); 14 Aug 2007 17:16:49 -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:49 -0700 X-ASF-Spam-Status: No, hits=-98.9 required=10.0 tests=ALL_TRUSTED,FB_GET_MEDS 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:57 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 76E5E1A981D; 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 [2/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.76E5E1A981D@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/PCAppDepartment.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java?view=auto&rev=565841 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java Tue Aug 14 10:16:06 2007 @@ -0,0 +1,443 @@ +/* + * 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.HashSet; +import java.util.Set; +import org.apache.jdo.tck.pc.company.ICompany; + +import org.apache.jdo.tck.pc.company.IDepartment; +import org.apache.jdo.tck.pc.company.IEmployee; +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a department within a company. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION, table="departments") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +public class PCAppDepartment + implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { + + public static final int RECOMMENDED_NO_OF_EMPS = 2; + + @NotPersistent() + private long _deptid; + @NotPersistent() + private String _name; + @NotPersistent() + private PCAppCompany _company; + @NotPersistent() + private PCAppEmployee _employeeOfTheMonth; + @NotPersistent() + private transient Set _employees = new HashSet(); + @NotPersistent() + private transient Set _fundedEmps = new HashSet(); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppDepartment() {} + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + */ + public PCAppDepartment(long deptid, String name) { + this._deptid = deptid; + this._name = name; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + */ + public PCAppDepartment(long deptid, String name, ICompany company) { + this._deptid = deptid; + this._name = name; + this._company = (PCAppCompany)company; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + * @param employeeOfTheMonth The employee of the month the + * department is associated with. + */ + public PCAppDepartment(long deptid, String name, ICompany company, + IEmployee employeeOfTheMonth) { + this._deptid = deptid; + this._name = name; + this._company = (PCAppCompany)company; + this._employeeOfTheMonth = (PCAppEmployee)employeeOfTheMonth; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setDeptid(long id) { + if (this._deptid != 0) + throw new IllegalStateException("Id is already set."); + this._deptid = id; + } + + /** + * Get the department id. + * @return The department id. + */ + + @PrimaryKey + @Column(name="ID") + public long getDeptid() { + return _deptid; + } + + /** + * Get the name of the department. + * @return The name of the department. + */ + @Column(name="NAME") + public String getName() { + return _name; + } + + /** + * Set the name of the department. + * @param name The name to set for the department. + */ + public void setName(String name) { + this._name = name; + } + + /** + * Get the company associated with the department. + * @return The company. + */ + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppCompany.class) + @Column(name="COMPANYID") + public ICompany getCompany() { + return _company; + } + + /** + * Set the company for the department. + * @param company The company to associate with the department. + */ + public void setCompany(ICompany company) { + this._company = (PCAppCompany)company; + } + + /** + * Get the employee of the month associated with the department. + * @return The employee of the month. + */ + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Column(name="EMP_OF_THE_MONTH") + public IEmployee getEmployeeOfTheMonth() { + return _employeeOfTheMonth; + } + + /** + * Set the employee of the month for the department. + * @param employeeOfTheMonth The employee of the month to + * associate with the department. + */ + public void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth) { + this._employeeOfTheMonth = (PCAppEmployee)employeeOfTheMonth; + } + + /** + * Get the employees in the department. + * @return The set of employees in the department. + */ + + @Persistent(mappedBy="department") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + public Set getEmployees() { + return _employees; + } + + /** + * Add an employee to the department. + * @param emp The employee to add to the department. + */ + public void addEmployee(PCAppEmployee emp) { + _employees.add(emp); + } + + /** + * Remove an employee from the department. + * @param emp The employee to remove from the department. + */ + public void removeEmployee(PCAppEmployee emp) { + _employees.remove(emp); + } + + /** + * Set the employees to be in this department. + * @param employees The set of employees for this department. + */ + public void setEmployees(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._employees = (employees != null) ? new HashSet(employees) : null; + } + + /** + * Get the funded employees in the department. + * @return The set of funded employees in the department. + */ + + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Persistent(mappedBy="fundingDept") + public Set getFundedEmps() { + return _fundedEmps; + } + + /** + * Add an employee to the collection of funded employees of this + * department. + * @param emp The employee to add to the department. + */ + public void addFundedEmp(PCAppEmployee emp) { + _fundedEmps.add(emp); + } + + /** + * Remove an employee from collection of funded employees of this + * department. + * @param emp The employee to remove from the department. + */ + public void removeFundedEmp(PCAppEmployee emp) { + _fundedEmps.remove(emp); + } + + /** + * Set the funded employees to be in this department. + * @param employees The set of funded employees for this department. + */ + public void setFundedEmps(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._fundedEmps = (_fundedEmps != null) ? new HashSet(employees) : null; + } + + /** Serialization support: initialize transient fields. */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + _employees = new HashSet(); + _fundedEmps = new HashSet(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other PCAppDepartment. + * + * + * @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) { + PCAppDepartment otherDept = (PCAppDepartment)other; + String where = "FCDepartment<" + _deptid + ">"; + return + helper.equals(_deptid, otherDept.getDeptid(), where + ".deptid") & + helper.equals(_name, otherDept.getName(), where + ".name") & + helper.deepEquals(_company, otherDept.getCompany(), where + ".company") & + helper.deepEquals(_employeeOfTheMonth, otherDept.getEmployeeOfTheMonth(), where + ".employeeOfTheMonth") & + helper.deepEquals(_employees, otherDept.getEmployees(), where + ".employees") & + helper.deepEquals(_fundedEmps, otherDept.getFundedEmps(), where + ".fundedEmps"); + } + + /** + * Returns a String representation of a PCAppDepartment object. + * + * + * @return a String representation of a PCAppDepartment object. + */ + public String toString() { + return "FCDepartment(" + 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(_deptid); + rc.append(", name ").append(_name); + return rc.toString(); + } + + /** + * 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((PCAppDepartment)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppDepartment)o1, (PCAppDepartment)o2); + } + + /** + * Compares this object with the specified Department 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 Department 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 + * Department object. + */ + public int compareTo(PCAppDepartment other) { + return compare(this, other); + } + + /** + * Compares its two IDepartment 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 IDepartment object to be compared. + * @param o2 the second IDepartment 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(PCAppDepartment o1, PCAppDepartment o2) { + return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); + } + + /** + * 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 PCAppDepartment) { + return compareTo((PCAppDepartment)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)_deptid; + } + + /** + * The application identity class associated with the + * Department class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the application identifier field + * for the Department class. + * It must match in name and type with the field in the + * Department class. + */ + public long deptid; + + /** + * The required public, no-arg constructor. + */ + public Oid() { } + + /** + * A constructor to initialize the identifier field. + * @param deptid the deptid of the Department. + */ + public Oid(long deptid) { + this.deptid = deptid; + } + + public Oid(String s) { deptid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + deptid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.deptid != o.deptid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) deptid ); + } + + 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( deptid < other.deptid ) return -1; + if( deptid > other.deptid ) return 1; + return 0; + } + + } + +} + Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java?view=auto&rev=565841 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java Tue Aug 14 10:16:06 2007 @@ -0,0 +1,539 @@ +/* + * 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.ObjectInputStream; +import java.io.IOException; + +import java.util.Collections; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; +import org.apache.jdo.tck.pc.company.IAddress; +import org.apache.jdo.tck.pc.company.IDentalInsurance; +import org.apache.jdo.tck.pc.company.IDepartment; + +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 an employee. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +public abstract class PCAppEmployee extends PCAppPerson implements IEmployee { + + @NotPersistent() + private Date _hiredate; + @NotPersistent() + private double _weeklyhours; + @NotPersistent() + private PCAppDentalInsurance _dentalInsurance; + @NotPersistent() + private PCAppMedicalInsurance _medicalInsurance; + @NotPersistent() + private PCAppDepartment _department; + @NotPersistent() + private PCAppDepartment _fundingDept; + @NotPersistent() + private PCAppEmployee _manager; + @NotPersistent() + private PCAppEmployee _mentor; + @NotPersistent() + private PCAppEmployee _protege; + @NotPersistent() + private PCAppEmployee _hradvisor; + @NotPersistent() + private transient Set _reviewedProjects = new HashSet(); + @NotPersistent() + private transient Set _projects = new HashSet(); + @NotPersistent() + private transient Set _team = new HashSet(); + @NotPersistent() + private transient Set _hradvisees = new HashSet(); + + /** This is the JDO-required no-args constructor */ + protected PCAppEmployee() {} + + /** + * Construct an PCAppEmployee instance. + * + * + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param hiredate The date that the employee was hired. + */ + public PCAppEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate); + this._hiredate = hiredate; + } + + /** + * Construct an PCAppEmployee instance. + * + * + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param address The address of the employee. + * @param hiredate The date that the employee was hired. + */ + public PCAppEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate, + (PCAppAddress)address); + this._hiredate = hiredate; + } + + /** + * Get the date that the employee was hired. + * @return The date the employee was hired. + */ + @Column(name="HIREDATE") + public Date getHiredate() { + return _hiredate; + } + + /** + * Set the date that the employee was hired. + * @param hiredate The date the employee was hired. + */ + public void setHiredate(Date hiredate) { + this._hiredate = _hiredate; + } + + /** + * Get the weekly hours of the employee. + * @return The number of hours per week that the employee works. + */ + @Column(name="WEEKLYHOURS") + public double getWeeklyhours() { + return _weeklyhours; + } + + /** + * Set the number of hours per week that the employee works. + * @param weeklyhours The number of hours per week that the employee + * works. + */ + public void setWeeklyhours(double weeklyhours) { + this._weeklyhours = weeklyhours; + } + + /** + * Get the reviewed projects. + * @return The reviewed projects. + */ + @Persistent(mappedBy="reviewers") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppProject.class) + public Set getReviewedProjects() { + return _reviewedProjects; + } + + /** + * Add a reviewed project. + * @param project A reviewed project. + */ + public void addReviewedProjects(PCAppProject project) { + _reviewedProjects.add(project); + } + + /** + * Remove a reviewed project. + * @param project A reviewed project. + */ + public void removeReviewedProject(PCAppProject project) { + _reviewedProjects.remove(project); + } + + /** + * Set the reviewed projects for the employee. + * @param reviewedProjects The set of reviewed projects. + */ + public void setReviewedProjects(Set reviewedProjects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._reviewedProjects = + (reviewedProjects != null) ? new HashSet(reviewedProjects) : null; + } + + /** + * Get the employee's projects. + * @return The employee's projects + * set. + */ + @Persistent(mappedBy="members") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppProject.class) + public Set getProjects() { + return _projects; + } + + /** + * Add a project for the employee. + * @param project The project. + */ + public void addProject(PCAppProject project) { + _projects.add(project); + } + + /** + * Remove a project from an employee's set of projects. + * @param project The project. + */ + public void removeProject(PCAppProject project) { + _projects.remove(project); + } + + /** + * Set the projects for the employee. + * @param projects The set of projects of the employee. + */ + public void setProjects(Set projects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._projects = (projects != null) ? new HashSet(projects) : null; + } + + /** + * Get the dental insurance of the employee. + * @return The employee's dental insurance. + */ + + @Persistent(mappedBy="employee", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDentalInsurance.class) + public IDentalInsurance getDentalInsurance() { + return _dentalInsurance; + } + + /** + * Set the dental insurance object for the employee. + * @param dentalInsurance The dental insurance object to associate with + * the employee. + */ + public void setDentalInsurance(IDentalInsurance dentalInsurance) { + this._dentalInsurance = (PCAppDentalInsurance)dentalInsurance; + } + /** + * Get the medical insurance of the employee. + * @return The employee's medical insurance. + */ + @Persistent(mappedBy="employee", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppMedicalInsurance.class) + public IMedicalInsurance getMedicalInsurance() { + return _medicalInsurance; + } + + /** + * Set the medical insurance object for the employee. + * @param medicalInsurance The medical insurance object to associate + * with the employee. + */ + public void setMedicalInsurance(IMedicalInsurance medicalInsurance) { + this._medicalInsurance = (PCAppMedicalInsurance)medicalInsurance; + } + + /** + * Get the employee's department. + * @return The department associated with the employee. + */ + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) + @Column(name="DEPARTMENT") + public IDepartment getDepartment() { + return _department; + } + + /** + * Set the employee's department. + * @param department The department. + */ + public void setDepartment(IDepartment department) { + this._department = (PCAppDepartment)department; + } + + /** + * Get the employee's funding department. + * @return The funding department associated with the employee. + */ + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) + @Column(name="FUNDINGDEPT") + public IDepartment getFundingDept() { + return _fundingDept; + } + + /** + * Set the employee's funding department. + * @param department The funding department. + */ + public void setFundingDept(IDepartment department) { + this._fundingDept = (PCAppDepartment)department; + } + + /** + * Get the employee's manager. + * @return The employee's manager. + */ + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Column(name="MANAGER") + public IEmployee getManager() { + return _manager; + } + + /** + * Set the employee's manager. + * @param manager The employee's manager. + */ + public void setManager(IEmployee manager) { + this._manager = (PCAppEmployee)manager; + } + + /** + * Get the employee's team. + * + * + * @return The set of PCAppEmployees on this employee's team. + */ + @Persistent(mappedBy="manager") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + public Set getTeam() { + return _team; + } + + /** + * Add an PCAppEmployee to this employee's team. + * This method sets both sides of the relationship, modifying + * this employees team to include parameter emp and modifying + * emp to set its manager attribute to this object. + * + * + * @param emp The PCAppEmployee to add to the team. + */ + public void addToTeam(PCAppEmployee emp) { + _team.add(emp); + emp._manager = this; + } + + /** + * Remove an PCAppEmployee from this employee's team. + * This method will also set the emp manager to null. + * + * + * @param emp The PCAppEmployee to remove from the team. + */ + public void removeFromTeam(PCAppEmployee emp) { + _team.remove(emp); + emp._manager = null; + } + + /** + * Set the employee's team. + * + * + * @param team The set of PCAppEmployees. + */ + public void setTeam(Set team) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._team = (team != null) ? new HashSet(team) : null; + } + + /** + * Set the mentor for this employee. + * @param mentor The mentor for this employee. + */ + public void setMentor(IEmployee mentor) { + this._mentor = (PCAppEmployee)mentor; + } + + /** + * Get the mentor for this employee. + * @return The mentor. + */ + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Column(name="MENTOR") + public IEmployee getMentor() { + return _mentor; + } + + /** + * Set the protege for this employee. + * @param protege The protege for this employee. + */ + public void setProtege(IEmployee protege) { + this._protege = (PCAppEmployee)protege; + } + + /** + * Get the protege of this employee. + * @return The protege of this employee. + */ + @Persistent(mappedBy="mentor", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + public IEmployee getProtege() { + return _protege; + } + + /** + * Set the HR advisor for this employee. + * @param hradvisor The hradvisor for this employee. + */ + public void setHradvisor(IEmployee hradvisor) { + this._hradvisor = (PCAppEmployee)hradvisor; + } + + /** + * Get the HR advisor for the employee. + * @return The HR advisor. + */ + @Column(name="HRADVISOR") + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + public IEmployee getHradvisor() { + return _hradvisor; + } + + /** + * Get the HR advisees of this HR advisor. + * + * + * @return HR advisees of this employee. + */ + @Persistent(mappedBy="hradvisor") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + public Set getHradvisees() { + return _hradvisees; + } + + /** + * Add an PCAppEmployee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to reference + * this object. In other words, both sides of the relationship are + * set. + * + * + * @param emp The employee to add as an advisee. + */ + public void addAdvisee(PCAppEmployee emp) { + _hradvisees.add(emp); + emp._hradvisor = this; + } + + /** + * Remove an PCAppEmployee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to null. + * In other words, both sides of the relationship are set. + * + * + * @param emp The employee to add as an HR advisee. + */ + public void removeAdvisee(PCAppEmployee emp) { + _hradvisees.remove(emp); + emp._hradvisor = null; + } + + /** + * Set the HR advisees of this HR advisor. + * + * + * @param hradvisees The PCAppEmployees that are HR advisees of + * this employee. + */ + public void setHradvisees(Set hradvisees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; + } + + /** Serialization support: initialize transient fields. */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + _reviewedProjects = new HashSet(); + _projects = new HashSet(); + _team = new HashSet(); + _hradvisees = new HashSet(); + } + + /** + * Return a String representation of a PCAppEmployee object. + * + * + * @return a String representation of a PCAppEmployee object. + */ + public String toString() { + return "FCEmployee(" + 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(", hired ").append(formatter.format(_hiredate)); + rc.append(", weeklyhours ").append(_weeklyhours); + return rc.toString(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the corresponding fields of the specified PCAppEmployee. + * + * + * @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) { + PCAppEmployee otherEmp = (PCAppEmployee)other; + String where = "Employee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.equals(_hiredate, otherEmp.getHiredate(), where + ".hiredate") & + helper.closeEnough(_weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") & + helper.deepEquals(_dentalInsurance, otherEmp.getDentalInsurance(), where + ".dentalInsurance") & + helper.deepEquals(_medicalInsurance, otherEmp.getMedicalInsurance(), where + ".medicalInsurance") & + helper.deepEquals(_department, otherEmp.getDepartment(), where + ".department") & + helper.deepEquals(_fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") & + helper.deepEquals(_manager, otherEmp.getManager(), where + ".manager") & + helper.deepEquals(_mentor, otherEmp.getMentor(), where + ".mentor") & + helper.deepEquals(_protege, otherEmp.getProtege(), where + ".protege") & + helper.deepEquals(_hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") & + helper.deepEquals(_reviewedProjects, otherEmp.getReviewedProjects(), where + ".reviewedProjects") & + helper.deepEquals(_projects, otherEmp.getProjects(), where + ".projects") & + helper.deepEquals(_team, otherEmp.getTeam(), where + ".team") & + helper.deepEquals(_hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); + } + +} + Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java?view=auto&rev=565841 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java Tue Aug 14 10:16:06 2007 @@ -0,0 +1,140 @@ +/* + * 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.IFullTimeEmployee; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a full-time employee. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +public class PCAppFullTimeEmployee extends PCAppEmployee + implements IFullTimeEmployee { + + @NotPersistent() + private double _salary; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppFullTimeEmployee() {} + + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @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 that the person was hired. + * @param sal The salary of the full-time employee. + */ + public PCAppFullTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double sal) { + super(personid, first, last, middle, born, hired); + _salary = sal; + } + + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @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 that the person was hired. + * @param sal The salary of the full-time employee. + */ + public PCAppFullTimeEmployee(long personid, String first, String last, + String middle, Date born, IAddress addr, + Date hired, double sal) { + super(personid, first, last, middle, born, (PCAppAddress)addr, hired); + _salary = sal; + } + + /** + * Get the salary of the full time employee. + * @return The salary of the full time employee. + */ + @Column(name="SALARY") + public double getSalary() { + return _salary; + } + + /** + * Set the salary for the full-time employee. + * @param salary The salary to set for the full-time employee. + */ + public void setSalary(double salary) { + this._salary = salary; + } + + /** + * Return a String representation of a PCAppFullTimeEmployee object. + * + * + * @return a String representation of a PCAppFullTimeEmployee object. + */ + public String toString() { + return "FCFullTimeEmployee(" + 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(", $").append(_salary); + return rc.toString(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * PCAppFullTimeEmployee. + * + * + * @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) { + PCAppFullTimeEmployee otherEmp = (PCAppFullTimeEmployee)other; + String where = "FCFullTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(_salary, otherEmp.getSalary(), where + ".salary"); + } + +} Propchange: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java?view=auto&rev=565841 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java Tue Aug 14 10:16:06 2007 @@ -0,0 +1,310 @@ +/* + * 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 + * PCAppEmployee. + */ +@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 PCAppInsurance + implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { + + @NotPersistent() + private long _insid; + @NotPersistent() + private String _carrier; + @NotPersistent() + private PCAppEmployee _employee; + + /** This is the JDO-required no-args constructor. */ + protected PCAppInsurance() {} + + /** + * Construct an PCAppInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + */ + protected PCAppInsurance(long insid, String carrier) { + this._insid = insid; + this._carrier = carrier; + } + + /** + * Construct an PCAppInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + */ + protected PCAppInsurance(long insid, String carrier, IEmployee employee) { + this._insid = insid; + this._carrier = carrier; + this._employee = (PCAppEmployee)employee; + } + + /** + * Get the insurance ID. + * @return the insurance ID. + */ + + @PrimaryKey + @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. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Column(name="EMPLOYEE") + public IEmployee getEmployee() { + return _employee; + } + + /** + * Set the associated employee. + * @param employee The associated employee. + */ + public void setEmployee(IEmployee employee) { + this._employee = (PCAppEmployee)employee; + } + + /** + * Returns a String representation of a PCAppInsurance object. + * + * + * @return a String representation of a PCAppInsurance 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) { + PCAppInsurance otherIns = (PCAppInsurance)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((PCAppInsurance)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppInsurance)o1, (PCAppInsurance)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(PCAppInsurance 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(PCAppInsurance o1, PCAppInsurance 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 PCAppInsurance) { + return compareTo((PCAppInsurance)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/PCAppInsurance.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java?view=auto&rev=565841 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.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.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 PCAppMedicalInsurance extends PCAppInsurance 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 PCAppMedicalInsurance() {} + + /** + * Construct a PCAppMedicalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param planType The planType. + */ + public PCAppMedicalInsurance(long insid, String carrier, + String planType) + { + super(insid, carrier); + this._planType = planType; + } + + /** + * Construct a PCAppMedicalInsurance 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 PCAppMedicalInsurance(long insid, String carrier, + IEmployee employee, String planType) + { + super(insid, carrier, (PCAppEmployee)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 PCAppMedicalInsurance + * object. + * + * + * @return a String representation of a PCAppMedicalInsurance + * 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) { + PCAppMedicalInsurance otherIns = (PCAppMedicalInsurance)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/PCAppMedicalInsurance.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java?view=auto&rev=565841 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java Tue Aug 14 10:16:06 2007 @@ -0,0 +1,140 @@ +/* + * 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.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 PCAppPartTimeEmployee extends PCAppEmployee + 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 PCAppPartTimeEmployee() {} + + /** + * 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 PCAppPartTimeEmployee(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 PCAppPartTimeEmployee(long personid, String first, String last, + String middle, Date born, PCAppAddress 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. + */ + + @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 PCAppPartTimeEmployee object. + * + * + * @return a String representation of a PCAppPartTimeEmployee 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 + * PCAppPartTimeEmployee. + * + * + * @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) { + PCAppPartTimeEmployee otherEmp = (PCAppPartTimeEmployee)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/PCAppPartTimeEmployee.java ------------------------------------------------------------------------------ svn:eol-style = LF Added: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java?view=auto&rev=565841 ============================================================================== --- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java (added) +++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.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(identityType=IdentityType.APPLICATION,table="persons") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR", indexed="true") +public class PCAppPerson + 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 PCAppAddress _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 PCAppPerson() {} + + /** + * Construct a PCAppPerson 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 PCAppPerson(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 PCAppPerson 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 PCAppPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address) { + this(personid, firstname, lastname, middlename, birthdate); + this._address = (PCAppAddress)_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. + */ + + @PrimaryKey + @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.PCAppAddress.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 = (PCAppAddress)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 + * @return The map of phone numbers. + */ + // 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 PCAppPerson object. + * + * + * @return a string representation of a PCAppPerson 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 PCAppPerson. + * + * + * @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) { + PCAppPerson otherPerson = (PCAppPerson)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((PCAppPerson)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppPerson)o1, (PCAppPerson)o2); + } + + /** + * + * Compares this object with the specified PCAppPerson 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 PCAppPerson 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 PFCAppPerson + * object. + */ + public int compareTo(PCAppPerson 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(PCAppPerson o1, PCAppPerson 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 PCAppPerson) { + return compareTo((PCAppPerson)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/PCAppPerson.java ------------------------------------------------------------------------------ svn:eol-style = LF