Index: project.properties =================================================================== --- project.properties (revision 562617) +++ project.properties (working copy) @@ -131,6 +131,17 @@ org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMedicalInsurance.java \ org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPartTimeEmployee.java \ org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppProject.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppAddress.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppCompany.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDentalInsurance.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppProject.java \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppAddress.java \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppCompany.java \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppDepartment.java \ @@ -153,6 +164,17 @@ org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSMedicalInsurance.java \ org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSPartTimeEmployee.java \ org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSProject.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSAddress.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSCompany.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDepartment.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSEmployee.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSFullTimeEmployee.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDentalInsurance.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSAddress.java \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSCompany.java \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSDepartment.java \ @@ -324,6 +346,17 @@ org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMedicalInsurance.class \ org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPartTimeEmployee.class \ org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppProject.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppAddress.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppCompany.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDentalInsurance.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppProject.class \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppAddress.class \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppCompany.class \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppDepartment.class \ @@ -346,6 +379,17 @@ org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSMedicalInsurance.class \ org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSPartTimeEmployee.class \ org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSProject.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSAddress.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSCompany.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDepartment.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSEmployee.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSFullTimeEmployee.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDentalInsurance.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.class \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSAddress.class \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSCompany.class \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSDepartment.class \ @@ -591,9 +635,28 @@ org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSMedicalInsurance.class \ org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSPartTimeEmployee.class \ org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSProject.class \ - -#Add these when jpox support is ready: - org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppAddress.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppAddress.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppCompany.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDentalInsurance.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppProject.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSAddress.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSCompany.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDepartment.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSEmployee.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSFullTimeEmployee.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDentalInsurance.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.class \ + org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.class \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppCompany.class \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppDepartment.class \ org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppPerson.class \ Index: src/conf/configurations.list =================================================================== --- src/conf/configurations.list (revision 562617) +++ src/conf/configurations.list (working copy) @@ -38,13 +38,20 @@ companyListWithoutJoin.conf \ companyPMClass.conf \ companyPMInterface.conf \ - companyAnnotatedNoRelationshipsFCPM.conf \ companyAnnotated1-1RelationshipsFCPM.conf \ companyAnnotated1-MRelationshipsFCPM.conf \ - companyAnnotatedM-MRelationshipsFCPM.conf \ + companyAnnotatedAllRelationshipsFCConcrete.conf \ companyAnnotatedAllRelationshipsFCPM.conf \ + companyAnnotatedAllRelationshipsPCConcrete.conf \ + companyAnnotatedAllRelationshipsPCPM.conf \ + companyAnnotatedAllRelationshipsPIPM.conf \ companyAnnotatedEmbeddedFCPM.conf \ companyAnnotatedM-MRelationshipsFCConcrete.conf \ + companyAnnotatedM-MRelationshipsFCPM.conf \ + companyAnnotatedNoRelationshipsFCConcrete.conf \ + companyAnnotatedNoRelationshipsFCPM.conf \ + companyAnnotatedNoRelationshipsPCConcrete.conf \ + companyAnnotatedNoRelationshipsPCPM.conf \ companyAnnotatedNoRelationshipsPIPM.conf \ inheritance1.conf \ inheritance2.conf \ Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java (revision 0) @@ -0,0 +1,138 @@ +/* + * 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 { + + 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"); + } +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSPartTimeEmployee.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSAddress.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSAddress.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSAddress.java (revision 0) @@ -0,0 +1,347 @@ +/* + * 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 java.io.Serializable; +import java.util.Comparator; + +import javax.jdo.annotations.*; +import org.apache.jdo.tck.pc.company.IAddress; + +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a postal address. + */ +@PersistenceCapable(embeddedOnly="true", requiresExtent="false") +public class PCDSAddress + implements IAddress, Serializable, Comparable, Comparator, DeepEquality { + + private long addrid; + private String street; + private String city; + private String state; + private String zipcode; + private String country; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSAddress() {} + + /** + * This constructor initializes the PCDSAddress components. + * + * + * @param addrid The address ID. + * @param street The street address. + * @param city The city. + * @param state The state. + * @param zipcode The zip code. + * @param country The zip country. + */ + public PCDSAddress(long addrid, String street, String city, + String state, String zipcode, String country) + { + this.addrid = addrid; + this.street = street; + this.city = city; + this.state = state; + this.zipcode = zipcode; + this.country = country; + } + + /** + * Get the addrid associated with this object. + * @return the addrid. + */ + public long getAddrid() { + return addrid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setAddrid(long id) { + if (this.addrid != 0) + throw new IllegalStateException("Id is already set."); + this.addrid = id; + } + + /** + * Get the street component of the address. + * @return The street component of the address. + */ + public String getStreet() { + return street; + } + + /** + * Set the street component of the address. + * @param street The street component. + */ + public void setStreet(String street) { + this.street = street; + } + + /** + * Get the city. + * @return The city component of the address. + */ + public String getCity() { + return city; + } + + /** + * Set the city component of the address. + * @param city The city. + */ + public void setCity(String city) { + this.city = city; + } + + /** + * Get the state component of the address. + * @return The state. + */ + public String getState() { + return state; + } + + /** + * Set the state component of the address. + * @param state The state. + */ + public void setState(String state) { + this.state = state; + } + + /** + * Get the zipcode component of the address. + * @return The zipcode. + */ + public String getZipcode() { + return zipcode; + } + + /** + * Set the zip code component of the address. + * @param zipcode The zipcode. + */ + public void setZipcode(String zipcode) { + this.zipcode = zipcode; + } + + /** + * Get the country component of the address. + * @return The country. + */ + public String getCountry() { + return country; + } + + /** + * Set the country component of the address. + * @param country The country. + */ + public void setCountry(String country) { + this.country = country; + } + + /** + * Returns a String representation of a Address object. + * @return a String representation of a Address object. + */ + public String toString() { + return "Address(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(addrid); + rc.append(", street ").append(street); + rc.append(", city ").append(city); + rc.append(", state ").append(state); + rc.append(", zipcode ").append(zipcode); + rc.append(", country ").append(country); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSAddress otherAddress = (PCDSAddress)other; + String where = "Address<" + addrid + ">"; + return + helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & + helper.equals(street, otherAddress.getStreet(), where + ".street") & + helper.equals(city, otherAddress.getCity(), where + ".city") & + helper.equals(state, otherAddress.getState(), where + ".state") & + helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & + helper.equals(country, otherAddress.getCountry(), where + ".country"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCDSAddress)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSAddress)o1, (PCDSAddress)o2); + } + + /** + * Compares this object with the specified Address object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Address object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Address + * object. + */ + public int compareTo(PCDSAddress other) { + return compare(this, other); + } + + /** + * Compares its two PCDSAddress 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 PCDSAddress object to be compared. + * @param o2 the second PCDSAddressobject 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(PCDSAddress o1, PCDSAddress o2) { + return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCDSAddress) { + return compareTo((PCDSAddress)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)addrid; + } + + /** + * This class is used to represent the application identifier + * for the Address class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for Address and must + * correspond in type and name to the field in + * Address. + */ + public long addrid; + + /** The required public, no-arg constructor. */ + public Oid() + { + addrid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param addrid the id of the Address. + */ + public Oid(long addrid) { + this.addrid = addrid; + } + + public Oid(String s) { addrid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + addrid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.addrid != o.addrid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) addrid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( addrid < other.addrid ) return -1; + if( addrid > other.addrid ) return 1; + return 0; + } + + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSAddress.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java (revision 0) @@ -0,0 +1,308 @@ +/* + * 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 { + + private long insid; + private String carrier; + 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; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSInsurance.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java (revision 0) @@ -0,0 +1,525 @@ +/* + * 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 { + + @Column(name="HIREDATE") + private Date hiredate; + @Column(name="WEEKLYHOURS") + private double weeklyhours; + @Persistent(mappedBy="employee", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDentalInsurance.class) + private PCAppDentalInsurance dentalInsurance; + @Persistent(mappedBy="employee") + private PCAppMedicalInsurance medicalInsurance; + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) + @Column(name="DEPARTMENT") + private PCAppDepartment department; + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) + @Column(name="FUNDINGDEPT") + private PCAppDepartment fundingDept; + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Column(name="MANAGER") + private PCAppEmployee manager; + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Column(name="MENTOR") + private PCAppEmployee mentor; + @Persistent(mappedBy="mentor", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + private PCAppEmployee protege; + @Column(name="HRADVISOR") + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + private PCAppEmployee hradvisor; + @Persistent(mappedBy="reviewers") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppProject.class) + private transient Set reviewedProjects = new HashSet(); + @Persistent(mappedBy="members") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppProject.class) + private transient Set projects = new HashSet(); + @Persistent(mappedBy="manager") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + private transient Set team = new HashSet(); + @Persistent(mappedBy="hradvisor") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + 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. + */ + 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. + */ + 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 as an unmodifiable set. + */ + public Set getReviewedProjects() { + return Collections.unmodifiableSet(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 are returned as an unmodifiable + * set. + */ + public Set getProjects() { + return Collections.unmodifiableSet(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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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, + * returned as an unmodifiable set. + */ + public Set getTeam() { + return Collections.unmodifiableSet(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. + */ + 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. + */ + 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. + */ + public IEmployee getHradvisor() { + return hradvisor; + } + + /** + * Get the HR advisees of this HR advisor. + * + * + * @return An unmodifiable Set containing the + * PCAppEmployees that are HR advisees of this employee. + */ + public Set getHradvisees() { + return Collections.unmodifiableSet(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"); + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppEmployee.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDentalInsurance.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDentalInsurance.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDentalInsurance.java (revision 0) @@ -0,0 +1,130 @@ +/* + * 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.math.BigDecimal; + +import org.apache.jdo.tck.pc.company.IDentalInsurance; +import org.apache.jdo.tck.pc.company.IEmployee; +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 PCAppDentalInsurance extends PCAppInsurance implements IDentalInsurance { + + private BigDecimal lifetimeOrthoBenefit; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppDentalInsurance() {} + + /** + * Construct a DentalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public PCAppDentalInsurance(long insid, String carrier, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Construct a PCAppDentalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public PCAppDentalInsurance(long insid, String carrier, IEmployee employee, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier, employee); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Get the insurance lifetimeOrthoBenefit. + * @return The insurance lifetimeOrthoBenefit. + */ + @Column(name="LIFETIME_ORTHO_BENEFIT") + public BigDecimal getLifetimeOrthoBenefit() { + return lifetimeOrthoBenefit; + } + + /** + * Set the insurance lifetimeOrthoBenefit. + * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. + */ + public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Returns a String representation of a PCAppDentalInsurance + * object. + * + * + * @return a String representation of a PCAppDentalInsurance + * object. + */ + public String toString() { + return "FCDentalInsurance(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", lifetimeOrthoBenefit ").append(lifetimeOrthoBenefit); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppDentalInsurance otherIns = (PCAppDentalInsurance)other; + String where = "FCDentalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(lifetimeOrthoBenefit, + otherIns.getLifetimeOrthoBenefit(), where + ".lifetimeOrthoBenefit"); + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppDentalInsurance.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCPMDelegator.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCPMDelegator.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCPMDelegator.java (revision 0) @@ -0,0 +1,44 @@ +/* + * 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.PersistenceManager; +import org.apache.jdo.tck.pc.company.CompanyFactoryAnnotatedAbstractDelegator; + +/* + * CompanyFactoryAnnotatedPMFieldClass.java + * + * This class uses the PersistenceManager.newInstance method with the concrete + * class as a parameter. + */ +public class CompanyFactoryAnnotatedPCPMDelegator + extends CompanyFactoryAnnotatedAbstractDelegator { + + /** + * Creates a new instance of CompanyFactory + */ + public CompanyFactoryAnnotatedPCPMDelegator(PersistenceManager pm) { + super(pm); + if (isAppIdentity){ + delegate = new CompanyFactoryAnnotatedPCAppPM(pm); + } else { //datastoreidentity + delegate = new CompanyFactoryAnnotatedPCDSPM(pm); + } + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\CompanyFactoryAnnotatedPCPMDelegator.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSPM.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSPM.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSPM.java (revision 0) @@ -0,0 +1,85 @@ +/* + * 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.PersistenceManager; +import org.apache.jdo.tck.pc.company.*; + +/* + * CompanyFactoryAnnotatedPCDSPM.java + * + * This class uses the PersistenceManager.newInstance method with the concrete + * class as a parameter. + */ +public class CompanyFactoryAnnotatedPCDSPM + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; + + /** + * Creates a new instance of CompanyFactoryAnnotatedPMFieldClass + */ + public CompanyFactoryAnnotatedPCDSPM(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PCDSDentalInsurance.class, + PCDSMedicalInsurance.class, + PCDSPartTimeEmployee.class, + PCDSFullTimeEmployee.class, + PCDSProject.class, + PCDSDepartment.class, + PCDSCompany.class, + PCDSAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(PCDSAddress.class); + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(PCDSCompany.class); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(PCDSDentalInsurance.class); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(PCDSDepartment.class); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(PCDSFullTimeEmployee.class); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(PCDSMedicalInsurance.class); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(PCDSPartTimeEmployee.class); + } + + public IProject newProject() { + return (IProject)pm.newInstance(PCDSProject.class); + } +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\CompanyFactoryAnnotatedPCDSPM.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppConcrete.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppConcrete.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppConcrete.java (revision 0) @@ -0,0 +1,85 @@ +/* + * 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.PersistenceManager; +import org.apache.jdo.tck.pc.company.*; + +/* + * CompanyFactoryAnnotatedPMFieldClass.java + * + * This class uses the PersistenceManager.newInstance method with the concrete + * class as a parameter. + */ +public class CompanyFactoryAnnotatedPCAppConcrete + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; + + /** + * Creates a new instance of CompanyFactoryAnnotatedPMFieldClass + */ + public CompanyFactoryAnnotatedPCAppConcrete(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PCAppDentalInsurance.class, + PCAppMedicalInsurance.class, + PCAppPartTimeEmployee.class, + PCAppFullTimeEmployee.class, + PCAppProject.class, + PCAppDepartment.class, + PCAppCompany.class, + PCAppAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress) new PCAppAddress(); + } + + public ICompany newCompany() { + return (ICompany) new PCAppCompany(); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance) new PCAppDentalInsurance(); + } + + public IDepartment newDepartment() { + return (IDepartment) new PCAppDepartment(); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee) new PCAppFullTimeEmployee(); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance) new PCAppMedicalInsurance(); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee) new PCAppPartTimeEmployee(); + } + + public IProject newProject() { + return (IProject) new PCAppProject(); + } +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\CompanyFactoryAnnotatedPCAppConcrete.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java (revision 0) @@ -0,0 +1,138 @@ +/* + * 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 { + + 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"); + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppFullTimeEmployee.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java (revision 0) @@ -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.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 { + + 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"); + } +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppPartTimeEmployee.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppAddress.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppAddress.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppAddress.java (revision 0) @@ -0,0 +1,349 @@ +/* + * 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 java.io.Serializable; +import java.util.Comparator; + +import javax.jdo.annotations.*; + +import org.apache.jdo.tck.pc.company.IAddress; +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a postal address. + */ +@PersistenceCapable(embeddedOnly="true", requiresExtent="false") +public class PCAppAddress + implements IAddress, Serializable, Comparable, Comparator, DeepEquality { + + private long addrid; + private String street; + private String city; + private String state; + private String zipcode; + private String country; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppAddress() {} + + /** + * This constructor initializes the PCAppAddress components. + * + * + * + * @param addrid The address ID. + * @param street The street address. + * @param city The city. + * @param state The state. + * @param zipcode The zip code. + * @param country The zip country. + */ + public PCAppAddress(long addrid, String street, String city, + String state, String zipcode, String country) + { + this.addrid = addrid; + this.street = street; + this.city = city; + this.state = state; + this.zipcode = zipcode; + this.country = country; + } + + /** + * Get the addrid associated with this object. + * @return the addrid. + */ + public long getAddrid() { + return addrid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setAddrid(long id) { + if (this.addrid != 0) + throw new IllegalStateException("Id is already set."); + this.addrid = id; + } + + /** + * Get the street component of the address. + * @return The street component of the address. + */ + public String getStreet() { + return street; + } + + /** + * Set the street component of the address. + * @param street The street component. + */ + public void setStreet(String street) { + this.street = street; + } + + /** + * Get the city. + * @return The city component of the address. + */ + public String getCity() { + return city; + } + + /** + * Set the city component of the address. + * @param city The city. + */ + public void setCity(String city) { + this.city = city; + } + + /** + * Get the state component of the address. + * @return The state. + */ + public String getState() { + return state; + } + + /** + * Set the state component of the address. + * @param state The state. + */ + public void setState(String state) { + this.state = state; + } + + /** + * Get the zipcode component of the address. + * @return The zipcode. + */ + public String getZipcode() { + return zipcode; + } + + /** + * Set the zip code component of the address. + * @param zipcode The zipcode. + */ + public void setZipcode(String zipcode) { + this.zipcode = zipcode; + } + + /** + * Get the country component of the address. + * @return The country. + */ + public String getCountry() { + return country; + } + + /** + * Set the country component of the address. + * @param country The country. + */ + public void setCountry(String country) { + this.country = country; + } + + /** + * Returns a String representation of a Address object. + * @return a String representation of a Address object. + */ + public String toString() { + return "Address(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(addrid); + rc.append(", street ").append(street); + rc.append(", city ").append(city); + rc.append(", state ").append(state); + rc.append(", zipcode ").append(zipcode); + rc.append(", country ").append(country); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppAddress otherAddress = (PCAppAddress)other; + String where = "Address<" + addrid + ">"; + return + helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & + helper.equals(street, otherAddress.getStreet(), where + ".street") & + helper.equals(city, otherAddress.getCity(), where + ".city") & + helper.equals(state, otherAddress.getState(), where + ".state") & + helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & + helper.equals(country, otherAddress.getCountry(), where + ".country"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCAppAddress)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppAddress)o1, (PCAppAddress)o2); + } + + /** + * Compares this object with the specified Address object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Address object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Address + * object. + */ + public int compareTo(PCAppAddress other) { + return compare(this, other); + } + + /** + * Compares its two PCAppAddress 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 PCAppAddresss object to be compared. + * @param o2 the second FFCPIAddressobject 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(PCAppAddress o1, PCAppAddress o2) { + return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCAppAddress) { + return compareTo((PCAppAddress)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)addrid; + } + + /** + * This class is used to represent the application identifier + * for the Address class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for Address and must + * correspond in type and name to the field in + * Address. + */ + public long addrid; + + /** The required public, no-arg constructor. */ + public Oid() + { + addrid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param addrid the id of the Address. + */ + public Oid(long addrid) { + this.addrid = addrid; + } + + public Oid(String s) { addrid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + addrid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.addrid != o.addrid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) addrid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( addrid < other.addrid ) return -1; + if( addrid > other.addrid ) return 1; + return 0; + } + + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppAddress.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java (revision 0) @@ -0,0 +1,307 @@ +/* + * 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 { + + private long insid; + private String carrier; + 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; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppInsurance.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppPM.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppPM.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppPM.java (revision 0) @@ -0,0 +1,85 @@ +/* + * 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.PersistenceManager; +import org.apache.jdo.tck.pc.company.*; + +/* + * CompanyFactoryAnnotatedPMFieldClass.java + * + * This class uses the PersistenceManager.newInstance method with the concrete + * class as a parameter. + */ +public class CompanyFactoryAnnotatedPCAppPM + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; + + /** + * Creates a new instance of CompanyFactoryAnnotatedPMFieldClass + */ + public CompanyFactoryAnnotatedPCAppPM(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PCAppDentalInsurance.class, + PCAppMedicalInsurance.class, + PCAppPartTimeEmployee.class, + PCAppFullTimeEmployee.class, + PCAppProject.class, + PCAppDepartment.class, + PCAppCompany.class, + PCAppAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(PCAppAddress.class); + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(PCAppCompany.class); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(PCAppDentalInsurance.class); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(PCAppDepartment.class); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(PCAppFullTimeEmployee.class); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(PCAppMedicalInsurance.class); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(PCAppPartTimeEmployee.class); + } + + public IProject newProject() { + return (IProject)pm.newInstance(PCAppProject.class); + } +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\CompanyFactoryAnnotatedPCAppPM.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDepartment.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDepartment.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDepartment.java (revision 0) @@ -0,0 +1,441 @@ +/* + * 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(table="departments") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") +public class PCDSDepartment + implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { + + public static final int RECOMMENDED_NO_OF_EMPS = 2; + + private long deptid; + private String name; + private PCDSCompany company; + private PCDSEmployee employeeOfTheMonth; + private transient Set employees = new HashSet(); + 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 PCDSDepartment() {} + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + */ + public PCDSDepartment(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 PCDSDepartment(long deptid, String name, ICompany company) { + this.deptid = deptid; + this.name = name; + this.company = (PCDSCompany)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 PCDSDepartment(long deptid, String name, ICompany company, + IEmployee employeeOfTheMonth) { + this.deptid = deptid; + this.name = name; + this.company = (PCDSCompany)company; + this.employeeOfTheMonth = (PCDSEmployee)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. + */ + @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.PCDSCompany.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 = (PCDSCompany)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.PCDSEmployee.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 = (PCDSEmployee)employeeOfTheMonth; + } + + /** + * Get the employees in the department as an unmodifiable set. + * @return The set of employees in the department, as an unmodifiable + * set. + */ + + @Persistent(mappedBy="department") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + public Set getEmployees() { + return Collections.unmodifiableSet(employees); + } + + /** + * Add an employee to the department. + * @param emp The employee to add to the department. + */ + public void addEmployee(PCDSEmployee emp) { + employees.add(emp); + } + + /** + * Remove an employee from the department. + * @param emp The employee to remove from the department. + */ + public void removeEmployee(PCDSEmployee 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 as an unmodifiable set. + * @return The set of funded employees in the department, as an + * unmodifiable set. + */ + + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + @Persistent(mappedBy="fundingDept") + public Set getFundedEmps() { + return Collections.unmodifiableSet(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(PCDSEmployee 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(PCDSEmployee 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 PCDSDepartment. + * + * + * @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) { + PCDSDepartment otherDept = (PCDSDepartment)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 PCDSDepartment object. + * + * + * @return a String representation of a PCDSDepartment 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((PCDSDepartment)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSDepartment)o1, (PCDSDepartment)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(PCDSDepartment 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(PCDSDepartment o1, PCDSDepartment 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 PCDSDepartment) { + return compareTo((PCDSDepartment)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; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSDepartment.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java (revision 0) @@ -0,0 +1,133 @@ +/* + * 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 { + + @Column(name="PLANTYPE") + private String planType; // possible values: "PPO", "EPO", "NPO" + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public 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="EMPLOYEE") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + 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"); + } +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSMedicalInsurance.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSCompany.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSCompany.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSCompany.java (revision 0) @@ -0,0 +1,405 @@ +/* + * 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.text.SimpleDateFormat; + +import java.util.Collections; +import java.util.Comparator; +import java.util.Set; +import java.util.HashSet; +import java.util.Date; +import org.apache.jdo.tck.pc.company.IAddress; +import org.apache.jdo.tck.pc.company.ICompany; + +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents information about a company. + */ +@PersistenceCapable(table="companies") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") +public class PCDSCompany + implements ICompany, Serializable, Comparable, Comparator, DeepEquality { + + private long companyid; + private String name; + private Date founded; + private PCDSAddress address; + private transient Set departments = new HashSet(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSCompany() {} + + /** + * + * Initialize the PCDSCompany instance. + * + * + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + */ + public PCDSCompany(long companyid, String name, Date founded) { + this.companyid = companyid; + this.name = name; + this.founded = founded; + } + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + * @param addr The company's address. + */ + public PCDSCompany(long companyid, String name, Date founded, IAddress addr) { + this(companyid, name, founded); + this.address = (PCDSAddress)addr; + } + + /** + * Get the company id. + * @return The company id. + */ + + @Column(name="ID") + public long getCompanyid() { + return companyid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setCompanyid(long id) { + if (this.companyid != 0) + throw new IllegalStateException("Id is already set."); + this.companyid = id; + } + + /** + * Get the name of the company. + * @return The name of the company. + */ + + @Column(name="NAME", jdbcType="VARCHAR") + public String getName() { + return name; + } + + /** + * Set the name of the company. + * @param name The value to use for the name of the company. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the date that the company was founded. + * @return The date the company was founded. + */ + + @Column(name="FOUNDEDDATE") + public Date getFounded() { + return founded; + } + + /** + * Set the date that the company was founded. + * @param founded The date to set that the company was founded. + */ + public void setFounded(Date founded) { + this.founded = founded; + } + + /** + * Get the address of the company. + * @return The primary address of the company. + */ + + @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 primary address for the company. + * @param address The address to set for the company. + */ + public void setAddress(IAddress address) { + this.address = (PCDSAddress)address; + } + + /** + * Get the departments contained in the company. + * + * + * @return An unmodifiable Set that contains all the + * PCDSDepartments of the company. + */ + + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + mappedBy="company") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDepartment.class) + public Set getDepartments() { + return Collections.unmodifiableSet(departments); + } + + /** + * Add a PCDSDepartment instance to the company. + * + * + * @param dept The PCDSDepartment instance to add. + */ + public void addDepartment(PCDSDepartment dept) { + departments.add(dept); + } + + /** + * Remove a PCDSDepartment instance from the company. + * + * + * @param dept The PCDSDepartment instance to remove. + */ + public void removeDepartment(PCDSDepartment dept) { + departments.remove(dept); + } + + /** + * Initialize the set of PCDSDepartments in the company to the + * parameter. + * + * + * @param departments The set of PCDSDepartments for the + * company. + */ + public void setDepartments(Set departments) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.departments = + (departments != null) ? new HashSet(departments) : null; + } + + /** Serialization support: initialize transient fields. */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + departments = new HashSet(); + } + + /** + * Returns a String representation of a Company object. + * @return a String representation of a Company object. + */ + public String toString() { + return "Company(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(companyid); + rc.append(", name ").append(name); + rc.append(", founded ").append(formatter.format(founded)); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSCompany otherCompany = (PCDSCompany)other; + String where = "Company<" + companyid + ">"; + return + helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") & + helper.equals(name, otherCompany.getName(), where + ".name") & + helper.equals(founded, otherCompany.getFounded(), where + ".founded") & + helper.deepEquals(address, otherCompany.getAddress(), where + ".address") & + helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCDSCompany)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSCompany)o1, (PCDSCompany)o2); + } + + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(PCDSCompany other) { + return compare(this, other); + } + + /** + * Compares its two ICompany arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first ICompany object to be compared. + * @param o2 the second ICompany object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCDSCompany o1, PCDSCompany o2) { + return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCDSCompany) { + return compareTo((PCDSCompany)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)companyid; + } + + /** + * The class to be used as the application identifier + * for the Company class. It consists of both the company + * name and the date that the company was founded. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the Company class. + */ + public long companyid; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param companyid The id of the company. + */ + public Oid(long companyid) { + this.companyid = companyid; + } + + public Oid(String s) { companyid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + companyid;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.companyid != o.companyid) + return false; + return true; + } + + /** */ + public int hashCode() { + return (int)companyid; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( companyid < other.companyid ) return -1; + if( companyid > other.companyid ) return 1; + return 0; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSCompany.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java (revision 0) @@ -0,0 +1,465 @@ +/* + * 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 { + + private long personid; + private String firstname; + private String lastname; + private String middlename; + private Date birthdate; + private PCDSAddress address; + 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. + */ + 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 Collections.unmodifiableMap(phoneNumbers); + } + + /** + * Get the phone number for the specified phone number type. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String getPhoneNumber(String type) { + return (String)phoneNumbers.get(type); + } + + /** + * Associates the specified phone number with the specified type in the + * map of phone numbers of this person. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @param phoneNumber The phone number + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String putPhoneNumber(String type, String phoneNumber) { + return (String)phoneNumbers.put(type, phoneNumber); + } + + /** + * Remove a phoneNumber from the map of phone numbers. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String removePhoneNumber(String type) { + return (String)phoneNumbers.remove(type); + } + + /** + * Set the phoneNumber map to be in this person. + * @param phoneNumbers The map of phoneNumbers for this person. + */ + public void setPhoneNumbers(Map phoneNumbers) { + // workaround: create a new HashMap, because fostore does not + // support LinkedHashMap + this.phoneNumbers = + (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; + } + + /** + * Returns a String representation of a 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; + } + + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSPerson.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java (revision 0) @@ -0,0 +1,392 @@ +/* + * 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 { + + private long projid; + private String name; + private BigDecimal budget; + private transient Set reviewers = new HashSet(); + 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 Collections.unmodifiableSet(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 an unmodifiable + * 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 Collections.unmodifiableSet(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; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSProject.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java (revision 0) @@ -0,0 +1,439 @@ +/* + * 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; + + private long deptid; + private String name; + private PCAppCompany company; + private PCAppEmployee employeeOfTheMonth; + private transient Set employees = new HashSet(); + 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 as an unmodifiable set. + * @return The set of employees in the department, as an unmodifiable + * set. + */ + + @Persistent(mappedBy="department") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + public Set getEmployees() { + return Collections.unmodifiableSet(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 as an unmodifiable set. + * @return The set of funded employees in the department, as an + * unmodifiable set. + */ + + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Persistent(mappedBy="fundingDept") + public Set getFundedEmps() { + return Collections.unmodifiableSet(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; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppDepartment.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSConcrete.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSConcrete.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSConcrete.java (revision 0) @@ -0,0 +1,85 @@ +/* + * 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.PersistenceManager; +import org.apache.jdo.tck.pc.company.*; + +/* + * CompanyFactoryAnnotatedFCDSPM.java + * + * This class uses the PersistenceManager.newInstance method with the concrete + * class as a parameter. + */ +public class CompanyFactoryAnnotatedPCDSConcrete + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; + + /** + * Creates a new instance of CompanyFactoryAnnotatedPMFieldClass + */ + public CompanyFactoryAnnotatedPCDSConcrete(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PCDSDentalInsurance.class, + PCDSMedicalInsurance.class, + PCDSPartTimeEmployee.class, + PCDSFullTimeEmployee.class, + PCDSProject.class, + PCDSDepartment.class, + PCDSCompany.class, + PCDSAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress) new PCDSAddress(); + } + + public ICompany newCompany() { + return (ICompany) new PCDSCompany(); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance) new PCDSDentalInsurance(); + } + + public IDepartment newDepartment() { + return (IDepartment) new PCDSDepartment(); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee) new PCDSFullTimeEmployee(); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance) new PCDSMedicalInsurance(); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee) new PCDSPartTimeEmployee(); + } + + public IProject newProject() { + return (IProject) new PCDSProject(); + } +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\CompanyFactoryAnnotatedPCDSConcrete.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCConcreteDelegator.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCConcreteDelegator.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCConcreteDelegator.java (revision 0) @@ -0,0 +1,44 @@ +/* + * 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.PersistenceManager; +import org.apache.jdo.tck.pc.company.CompanyFactoryAnnotatedAbstractDelegator; + +/* + * CompanyFactoryAnnotatedPMFieldClass.java + * + * This class uses the PersistenceManager.newInstance method with the concrete + * class as a parameter. + */ +public class CompanyFactoryAnnotatedPCConcreteDelegator + extends CompanyFactoryAnnotatedAbstractDelegator { + + /** + * Creates a new instance of CompanyFactory + */ + public CompanyFactoryAnnotatedPCConcreteDelegator(PersistenceManager pm) { + super(pm); + if (isAppIdentity){ + delegate = new CompanyFactoryAnnotatedPCAppConcrete(pm); + } else { //datastoreidentity + delegate = new CompanyFactoryAnnotatedPCDSConcrete(pm); + } + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\CompanyFactoryAnnotatedPCConcreteDelegator.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDentalInsurance.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDentalInsurance.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDentalInsurance.java (revision 0) @@ -0,0 +1,131 @@ +/* + * 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.math.BigDecimal; +import org.apache.jdo.tck.pc.company.IDentalInsurance; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a dental insurance carrier selection for a + * particular Employee. + */ +@PersistenceCapable +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class PCDSDentalInsurance extends PCDSInsurance + implements IDentalInsurance { + + private BigDecimal lifetimeOrthoBenefit; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSDentalInsurance() {} + + /** + * Construct a DentalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public PCDSDentalInsurance(long insid, String carrier, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Construct a PCDSDentalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public PCDSDentalInsurance(long insid, String carrier, PCDSEmployee employee, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier, employee); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Get the insurance lifetimeOrthoBenefit. + * @return The insurance lifetimeOrthoBenefit. + */ + + @Column(name="LIFETIME_ORTHO_BENEFIT") + public BigDecimal getLifetimeOrthoBenefit() { + return lifetimeOrthoBenefit; + } + + /** + * Set the insurance lifetimeOrthoBenefit. + * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. + */ + public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Returns a String representation of a PCDSDentalInsurance + * object. + * + * + * @return a String representation of a PCDSDentalInsurance + * object. + */ + public String toString() { + return "FCDentalInsurance(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", lifetimeOrthoBenefit ").append(lifetimeOrthoBenefit); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSDentalInsurance otherIns = (PCDSDentalInsurance)other; + String where = "FCDentalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(lifetimeOrthoBenefit, + otherIns.getLifetimeOrthoBenefit(), where + ".lifetimeOrthoBenefit"); + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSDentalInsurance.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSEmployee.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSEmployee.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSEmployee.java (revision 0) @@ -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.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 +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public abstract class PCDSEmployee extends PCDSPerson implements IEmployee { + + private Date hiredate; + private double weeklyhours; + private PCDSDentalInsurance dentalInsurance; + private PCDSMedicalInsurance medicalInsurance; + private PCDSDepartment department; + private PCDSDepartment fundingDept; + private PCDSEmployee manager; + private PCDSEmployee mentor; + private PCDSEmployee protege; + private PCDSEmployee hradvisor; + private transient Set reviewedProjects = new HashSet(); + private transient Set projects = new HashSet(); + private transient Set team = new HashSet(); + private transient Set hradvisees = new HashSet(); + + + /** This is the JDO-required no-args constructor */ + protected PCDSEmployee() {} + + /** + * Construct an PCDSEmployee 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 PCDSEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate); + this.hiredate = hiredate; + } + + /** + * Construct an PCDSEmployee 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 PCDSEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, PCDSAddress address, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate, 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 as an unmodifiable set. + */ + + @Persistent(mappedBy="reviewers") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSProject.class) + public Set getReviewedProjects() { + return Collections.unmodifiableSet(reviewedProjects); + } + + /** + * Add a reviewed project. + * @param project A reviewed project. + */ + public void addReviewedProjects(PCDSProject project) { + reviewedProjects.add(project); + } + + /** + * Remove a reviewed project. + * @param project A reviewed project. + */ + public void removeReviewedProject(PCDSProject 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 are returned as an unmodifiable + * set. + */ + + @Persistent(mappedBy="members") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSProject.class) + public Set getProjects() { + return Collections.unmodifiableSet(projects); + } + + /** + * Add a project for the employee. + * @param project The project. + */ + public void addProject(PCDSProject project) { + projects.add(project); + } + + /** + * Remove a project from an employee's set of projects. + * @param project The project. + */ + public void removeProject(PCDSProject 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 = (PCDSDentalInsurance)dentalInsurance; + } + + /** + * Get the medical insurance of the employee. + * @return The employee's medical insurance. + */ + @Persistent(mappedBy="employee", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSMedicalInsurance.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 = (PCDSMedicalInsurance)medicalInsurance; + } + + /** + * Get the employee's department. + * @return The department associated with the employee. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDepartment.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 = (PCDSDepartment)department; + } + + /** + * Get the employee's funding department. + * @return The funding department associated with the employee. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDepartment.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 = (PCDSDepartment)department; + } + + /** + * Get the employee's manager. + * @return The employee's manager. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.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 = (PCDSEmployee)manager; + } + + /** + * Get the employee's team. + * + * + * @return The set of PCDSEmployees on this employee's team, + * returned as an unmodifiable set. + */ + + @Persistent(mappedBy="manager") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + public Set getTeam() { + return Collections.unmodifiableSet(team); + } + + /** + * Add an PCDSEmployee 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 PCDSEmployee to add to the team. + */ + public void addToTeam(PCDSEmployee emp) { + team.add(emp); + emp.manager = this; + } + + /** + * Remove an PCDSEmployee from this employee's team. + * This method will also set the emp manager to null. + * + * + * @param emp The PCDSEmployee to remove from the team. + */ + public void removeFromTeam(PCDSEmployee emp) { + team.remove(emp); + emp.manager = null; + } + + /** + * Set the employee's team. + * + * + * @param team The set of PCDSEmployees. + */ + 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 = (PCDSEmployee)mentor; + } + + /** + * Get the mentor for this employee. + * @return The mentor. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.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 = (PCDSEmployee)protege; + } + + /** + * Get the protege of this employee. + * @return The protege of this employee. + */ + + @Persistent(mappedBy="mentor", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.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 = (PCDSEmployee)hradvisor; + } + + /** + * Get the HR advisor for the employee. + * @return The HR advisor. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + @Column(name="HRADVISOR") + public IEmployee getHradvisor() { + return hradvisor; + } + + /** + * Get the HR advisees of this HR advisor. + * + * + * @return An unmodifiable Set containing the + * PCDSEmployees that are HR advisees of this employee. + */ + + @Persistent(mappedBy="hradvisor") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + public Set getHradvisees() { + return Collections.unmodifiableSet(hradvisees); + } + + /** + * Add an PCDSEmployee 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(PCDSEmployee emp) { + hradvisees.add(emp); + emp.hradvisor = this; + } + + /** + * Remove an PCDSEmployee 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(PCDSEmployee emp) { + hradvisees.remove(emp); + emp.hradvisor = null; + } + + /** + * Set the HR advisees of this HR advisor. + * + * + * @param hradvisees The PCDSEmployees 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 PCDSEmployee object. + * + * + * @return a String representation of a PCDSEmployee 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 PCDSEmployee. + * + * + * @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) { + PCDSEmployee otherEmp = (PCDSEmployee)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"); + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSEmployee.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppCompany.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppCompany.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppCompany.java (revision 0) @@ -0,0 +1,400 @@ +/* + * 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.text.SimpleDateFormat; + +import java.util.Collections; +import java.util.Comparator; +import java.util.Set; +import java.util.HashSet; +import java.util.Date; +import org.apache.jdo.tck.pc.company.IAddress; + +import org.apache.jdo.tck.pc.company.ICompany; +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents information about a company. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION,table="companies") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") + public class PCAppCompany + implements ICompany, Serializable, Comparable, Comparator, DeepEquality { + + private long companyid; + private String name; + private Date founded; + private PCAppAddress address; + private transient Set departments = new HashSet(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppCompany() {} + + /** + * + * Initialize the PCAppCompany instance. + * + * + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + */ + public PCAppCompany(long companyid, String name, Date founded) { + this.companyid = companyid; + this.name = name; + this.founded = founded; + } + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + * @param addr The company's address. + */ + public PCAppCompany(long companyid, String name, Date founded, IAddress addr) { + this(companyid, name, founded); + this.address = (PCAppAddress)addr; + } + + /** + * Get the company id. + * @return The company id. + */ + @Persistent(primaryKey="true") + @Column(name="ID") + public long getCompanyid() { + return companyid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setCompanyid(long id) { + if (this.companyid != 0) + throw new IllegalStateException("Id is already set."); + this.companyid = id; + } + + /** + * Get the name of the company. + * @return The name of the company. + */ + @Column(name="NAME", jdbcType="VARCHAR") + public String getName() { + return name; + } + + /** + * Set the name of the company. + * @param name The value to use for the name of the company. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the date that the company was founded. + * @return The date the company was founded. + */ + @Column(name="FOUNDEDDATE") + public Date getFounded() { + return founded; + } + + /** + * Set the date that the company was founded. + * @param founded The date to set that the company was founded. + */ + public void setFounded(Date founded) { + this.founded = founded; + } + + /** + * Get the address of the company. + * @return The primary address of the company. + */ + @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 primary address for the company. + * @param address The address to set for the company. + */ + public void setAddress(IAddress address) { + this.address = (PCAppAddress)address; + } + + /** + * Get the departments contained in the company. + * + * + * @return An unmodifiable Set that contains all the + * PCAppDepartments of the company. + */ + + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + mappedBy="company") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) + public Set getDepartments() { + return Collections.unmodifiableSet(departments); + } + + /** + * Add a PCAppDepartment instance to the company. + * + * + * @param dept The PCAppDepartment instance to add. + */ + public void addDepartment(PCAppDepartment dept) { + departments.add(dept); + } + + /** + * Remove a PCAppDepartment instance from the company. + * + * + * @param dept The PCAppDepartment instance to remove. + */ + public void removeDepartment(PCAppDepartment dept) { + departments.remove(dept); + } + + /** + * Initialize the set of PCAppDepartments in the company to the + * parameter. + * + * + * @param departments The set of PCAppDepartments for the + * company. + */ + public void setDepartments(Set departments) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.departments = + (departments != null) ? new HashSet(departments) : null; + } + + /** Serialization support: initialize transient fields. */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + departments = new HashSet(); + } + + /** + * Returns a String representation of a Company object. + * @return a String representation of a Company object. + */ + public String toString() { + return "Company(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(companyid); + rc.append(", name ").append(name); + rc.append(", founded ").append(formatter.format(founded)); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppCompany otherCompany = (PCAppCompany)other; + String where = "Company<" + companyid + ">"; + return + helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") & + helper.equals(name, otherCompany.getName(), where + ".name") & + helper.equals(founded, otherCompany.getFounded(), where + ".founded") & + helper.deepEquals(address, otherCompany.getAddress(), where + ".address") & + helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCAppCompany)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppCompany)o1, (PCAppCompany)o2); + } + + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(PCAppCompany other) { + return compare(this, other); + } + + /** + * Compares its two ICompany arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first ICompany object to be compared. + * @param o2 the second ICompany object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCAppCompany o1, PCAppCompany o2) { + return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCAppCompany) { + return compareTo((PCAppCompany)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)companyid; + } + + /** + * The class to be used as the application identifier + * for the Company class. It consists of both the company + * name and the date that the company was founded. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the Company class. + */ + public long companyid; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param companyid The id of the company. + */ + public Oid(long companyid) { + this.companyid = companyid; + } + + public Oid(String s) { companyid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + companyid;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.companyid != o.companyid) + return false; + return true; + } + + /** */ + public int hashCode() { + return (int)companyid; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( companyid < other.companyid ) return -1; + if( companyid > other.companyid ) return 1; + return 0; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppCompany.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java (revision 0) @@ -0,0 +1,131 @@ +/* + * 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 { + + 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"); + } +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppMedicalInsurance.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java (revision 0) @@ -0,0 +1,465 @@ +/* + * 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 { + + private long personid; + private String firstname; + private String lastname; + private String middlename; + private Date birthdate; + private PCAppAddress address; + 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. + */ + 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 Collections.unmodifiableMap(phoneNumbers); + } + + /** + * Get the phone number for the specified phone number type. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String getPhoneNumber(String type) { + return (String)phoneNumbers.get(type); + } + + /** + * Associates the specified phone number with the specified type in the + * map of phone numbers of this person. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @param phoneNumber The phone number + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String putPhoneNumber(String type, String phoneNumber) { + return (String)phoneNumbers.put(type, phoneNumber); + } + + /** + * Remove a phoneNumber from the map of phone numbers. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String removePhoneNumber(String type) { + return (String)phoneNumbers.remove(type); + } + + /** + * Set the phoneNumber map to be in this person. + * @param phoneNumbers The map of phoneNumbers for this person. + */ + public void setPhoneNumbers(Map phoneNumbers) { + // workaround: create a new HashMap, because fostore does not + // support LinkedHashMap + this.phoneNumbers = + (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; + } + + /** + * Returns a String representation of a 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; + } + + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppPerson.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppProject.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppProject.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppProject.java (revision 0) @@ -0,0 +1,392 @@ +/* + * 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(identityType=IdentityType.APPLICATION, table="projects") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +public class PCAppProject + implements IProject, Serializable, Comparable, Comparator, DeepEquality { + + private long projid; + private String name; + private BigDecimal budget; + private transient Set reviewers = new HashSet(); + 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 PCAppProject() {} + + /** + * Initialize a project. + * @param projid The project identifier. + * @param name The name of the project. + * @param budget The budget for the project. + */ + public PCAppProject(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. + */ + + @PrimaryKey + @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.PCAppEmployee.class, + column="REVIEWER") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + public Set getReviewers() { + return Collections.unmodifiableSet(reviewers); + } + + /** + * Add a reviewer to the project. + * @param emp The employee to add as a reviewer. + */ + public void addReviewer(PCAppEmployee 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(PCAppEmployee emp) { + reviewers.remove(emp); + } + + /** + * Set the reviewers associated with this project. + * @param reviewers The set of reviewers to associate with this project. + */ + public void setReviewers(Set reviewers) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.reviewers = (reviewers != null) ? new HashSet(reviewers) : null; + } + + /** + * Get the project members. + * + * + * @return The members of the project is returned as an unmodifiable + * set of PCAppEmployees. + */ + + @Persistent(table="project_member") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class, + column="MEMBER", foreignKey="PR_MEMB_FK") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + public Set getMembers() { + return Collections.unmodifiableSet(members); + } + + /** + * Add a new member to the project. + * @param emp The employee to add to the project. + */ + public void addMember(PCAppEmployee emp) { + members.add(emp); + } + + /** + * Remove a member from the project. + * @param emp The employee to remove from the project. + */ + public void removeMember(PCAppEmployee 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 PCAppProject object. + * + * + * @return a String representation of a PCAppProject 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) { + PCAppProject otherProject = (PCAppProject)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((PCAppProject)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppProject)o1, (PCAppProject)o2); + } + + /** + * + * Compares this object with the specified PCAppProject 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 PCAppProject 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 F\PFCAppProject object. + */ + public int compareTo(PCAppProject 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(PCAppProject o1, PCAppProject 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 PCAppProject) { + return compareTo((PCAppProject)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 PCAppProject class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the + * PCAppProject class. It must match a field in the + * PCAppProject 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; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppProject.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSFullTimeEmployee.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSFullTimeEmployee.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSFullTimeEmployee.java (revision 0) @@ -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 +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class PCDSFullTimeEmployee extends PCDSEmployee + implements IFullTimeEmployee { + + private double salary; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSFullTimeEmployee() {} + + /** + * 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 PCDSFullTimeEmployee(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 PCDSFullTimeEmployee(long personid, String first, String last, + String middle, Date born, IAddress addr, + Date hired, double sal) { + super(personid, first, last, middle, born, (PCDSAddress)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 PCDSFullTimeEmployee object. + * + * + * @return a String representation of a PCDSFullTimeEmployee 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 + * PCDSFullTimeEmployee. + * + * + * @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) { + PCDSFullTimeEmployee otherEmp = (PCDSFullTimeEmployee)other; + String where = "FCFullTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSFullTimeEmployee.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppConcrete.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppConcrete.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppConcrete.java (revision 0) @@ -0,0 +1,85 @@ +/* + * 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.PersistenceManager; +import org.apache.jdo.tck.pc.company.*; + +/* + * CompanyFactoryAnnotatedPMFieldClass.java + * + * This class uses the PersistenceManager.newInstance method with the concrete + * class as a parameter. + */ +public class CompanyFactoryAnnotatedPCAppConcrete + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; + + /** + * Creates a new instance of CompanyFactoryAnnotatedPMFieldClass + */ + public CompanyFactoryAnnotatedPCAppConcrete(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PCAppDentalInsurance.class, + PCAppMedicalInsurance.class, + PCAppPartTimeEmployee.class, + PCAppFullTimeEmployee.class, + PCAppProject.class, + PCAppDepartment.class, + PCAppCompany.class, + PCAppAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress) new PCAppAddress(); + } + + public ICompany newCompany() { + return (ICompany) new PCAppCompany(); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance) new PCAppDentalInsurance(); + } + + public IDepartment newDepartment() { + return (IDepartment) new PCAppDepartment(); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee) new PCAppFullTimeEmployee(); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance) new PCAppMedicalInsurance(); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee) new PCAppPartTimeEmployee(); + } + + public IProject newProject() { + return (IProject) new PCAppProject(); + } +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\CompanyFactoryAnnotatedPCAppConcrete.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppPM.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppPM.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppPM.java (revision 0) @@ -0,0 +1,85 @@ +/* + * 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.PersistenceManager; +import org.apache.jdo.tck.pc.company.*; + +/* + * CompanyFactoryAnnotatedPMFieldClass.java + * + * This class uses the PersistenceManager.newInstance method with the concrete + * class as a parameter. + */ +public class CompanyFactoryAnnotatedPCAppPM + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; + + /** + * Creates a new instance of CompanyFactoryAnnotatedPMFieldClass + */ + public CompanyFactoryAnnotatedPCAppPM(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PCAppDentalInsurance.class, + PCAppMedicalInsurance.class, + PCAppPartTimeEmployee.class, + PCAppFullTimeEmployee.class, + PCAppProject.class, + PCAppDepartment.class, + PCAppCompany.class, + PCAppAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(PCAppAddress.class); + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(PCAppCompany.class); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(PCAppDentalInsurance.class); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(PCAppDepartment.class); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(PCAppFullTimeEmployee.class); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(PCAppMedicalInsurance.class); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(PCAppPartTimeEmployee.class); + } + + public IProject newProject() { + return (IProject)pm.newInstance(PCAppProject.class); + } +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\CompanyFactoryAnnotatedPCAppPM.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCConcreteDelegator.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCConcreteDelegator.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCConcreteDelegator.java (revision 0) @@ -0,0 +1,44 @@ +/* + * 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.PersistenceManager; +import org.apache.jdo.tck.pc.company.CompanyFactoryAnnotatedAbstractDelegator; + +/* + * CompanyFactoryAnnotatedPMFieldClass.java + * + * This class uses the PersistenceManager.newInstance method with the concrete + * class as a parameter. + */ +public class CompanyFactoryAnnotatedPCConcreteDelegator + extends CompanyFactoryAnnotatedAbstractDelegator { + + /** + * Creates a new instance of CompanyFactory + */ + public CompanyFactoryAnnotatedPCConcreteDelegator(PersistenceManager pm) { + super(pm); + if (isAppIdentity){ + delegate = new CompanyFactoryAnnotatedPCAppConcrete(pm); + } else { //datastoreidentity + delegate = new CompanyFactoryAnnotatedPCDSConcrete(pm); + } + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\CompanyFactoryAnnotatedPCConcreteDelegator.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSConcrete.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSConcrete.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSConcrete.java (revision 0) @@ -0,0 +1,85 @@ +/* + * 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.PersistenceManager; +import org.apache.jdo.tck.pc.company.*; + +/* + * CompanyFactoryAnnotatedFCDSPM.java + * + * This class uses the PersistenceManager.newInstance method with the concrete + * class as a parameter. + */ +public class CompanyFactoryAnnotatedPCDSConcrete + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; + + /** + * Creates a new instance of CompanyFactoryAnnotatedPMFieldClass + */ + public CompanyFactoryAnnotatedPCDSConcrete(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PCDSDentalInsurance.class, + PCDSMedicalInsurance.class, + PCDSPartTimeEmployee.class, + PCDSFullTimeEmployee.class, + PCDSProject.class, + PCDSDepartment.class, + PCDSCompany.class, + PCDSAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress) new PCDSAddress(); + } + + public ICompany newCompany() { + return (ICompany) new PCDSCompany(); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance) new PCDSDentalInsurance(); + } + + public IDepartment newDepartment() { + return (IDepartment) new PCDSDepartment(); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee) new PCDSFullTimeEmployee(); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance) new PCDSMedicalInsurance(); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee) new PCDSPartTimeEmployee(); + } + + public IProject newProject() { + return (IProject) new PCDSProject(); + } +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\CompanyFactoryAnnotatedPCDSConcrete.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSPM.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSPM.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSPM.java (revision 0) @@ -0,0 +1,85 @@ +/* + * 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.PersistenceManager; +import org.apache.jdo.tck.pc.company.*; + +/* + * CompanyFactoryAnnotatedPCDSPM.java + * + * This class uses the PersistenceManager.newInstance method with the concrete + * class as a parameter. + */ +public class CompanyFactoryAnnotatedPCDSPM + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; + + /** + * Creates a new instance of CompanyFactoryAnnotatedPMFieldClass + */ + public CompanyFactoryAnnotatedPCDSPM(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PCDSDentalInsurance.class, + PCDSMedicalInsurance.class, + PCDSPartTimeEmployee.class, + PCDSFullTimeEmployee.class, + PCDSProject.class, + PCDSDepartment.class, + PCDSCompany.class, + PCDSAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(PCDSAddress.class); + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(PCDSCompany.class); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(PCDSDentalInsurance.class); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(PCDSDepartment.class); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(PCDSFullTimeEmployee.class); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(PCDSMedicalInsurance.class); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(PCDSPartTimeEmployee.class); + } + + public IProject newProject() { + return (IProject)pm.newInstance(PCDSProject.class); + } +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\CompanyFactoryAnnotatedPCDSPM.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCPMDelegator.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCPMDelegator.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCPMDelegator.java (revision 0) @@ -0,0 +1,44 @@ +/* + * 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.PersistenceManager; +import org.apache.jdo.tck.pc.company.CompanyFactoryAnnotatedAbstractDelegator; + +/* + * CompanyFactoryAnnotatedPMFieldClass.java + * + * This class uses the PersistenceManager.newInstance method with the concrete + * class as a parameter. + */ +public class CompanyFactoryAnnotatedPCPMDelegator + extends CompanyFactoryAnnotatedAbstractDelegator { + + /** + * Creates a new instance of CompanyFactory + */ + public CompanyFactoryAnnotatedPCPMDelegator(PersistenceManager pm) { + super(pm); + if (isAppIdentity){ + delegate = new CompanyFactoryAnnotatedPCAppPM(pm); + } else { //datastoreidentity + delegate = new CompanyFactoryAnnotatedPCDSPM(pm); + } + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\CompanyFactoryAnnotatedPCPMDelegator.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppAddress.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppAddress.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppAddress.java (revision 0) @@ -0,0 +1,349 @@ +/* + * 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 java.io.Serializable; +import java.util.Comparator; + +import javax.jdo.annotations.*; + +import org.apache.jdo.tck.pc.company.IAddress; +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a postal address. + */ +@PersistenceCapable(embeddedOnly="true", requiresExtent="false") +public class PCAppAddress + implements IAddress, Serializable, Comparable, Comparator, DeepEquality { + + private long addrid; + private String street; + private String city; + private String state; + private String zipcode; + private String country; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppAddress() {} + + /** + * This constructor initializes the PCAppAddress components. + * + * + * + * @param addrid The address ID. + * @param street The street address. + * @param city The city. + * @param state The state. + * @param zipcode The zip code. + * @param country The zip country. + */ + public PCAppAddress(long addrid, String street, String city, + String state, String zipcode, String country) + { + this.addrid = addrid; + this.street = street; + this.city = city; + this.state = state; + this.zipcode = zipcode; + this.country = country; + } + + /** + * Get the addrid associated with this object. + * @return the addrid. + */ + public long getAddrid() { + return addrid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setAddrid(long id) { + if (this.addrid != 0) + throw new IllegalStateException("Id is already set."); + this.addrid = id; + } + + /** + * Get the street component of the address. + * @return The street component of the address. + */ + public String getStreet() { + return street; + } + + /** + * Set the street component of the address. + * @param street The street component. + */ + public void setStreet(String street) { + this.street = street; + } + + /** + * Get the city. + * @return The city component of the address. + */ + public String getCity() { + return city; + } + + /** + * Set the city component of the address. + * @param city The city. + */ + public void setCity(String city) { + this.city = city; + } + + /** + * Get the state component of the address. + * @return The state. + */ + public String getState() { + return state; + } + + /** + * Set the state component of the address. + * @param state The state. + */ + public void setState(String state) { + this.state = state; + } + + /** + * Get the zipcode component of the address. + * @return The zipcode. + */ + public String getZipcode() { + return zipcode; + } + + /** + * Set the zip code component of the address. + * @param zipcode The zipcode. + */ + public void setZipcode(String zipcode) { + this.zipcode = zipcode; + } + + /** + * Get the country component of the address. + * @return The country. + */ + public String getCountry() { + return country; + } + + /** + * Set the country component of the address. + * @param country The country. + */ + public void setCountry(String country) { + this.country = country; + } + + /** + * Returns a String representation of a Address object. + * @return a String representation of a Address object. + */ + public String toString() { + return "Address(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(addrid); + rc.append(", street ").append(street); + rc.append(", city ").append(city); + rc.append(", state ").append(state); + rc.append(", zipcode ").append(zipcode); + rc.append(", country ").append(country); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppAddress otherAddress = (PCAppAddress)other; + String where = "Address<" + addrid + ">"; + return + helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & + helper.equals(street, otherAddress.getStreet(), where + ".street") & + helper.equals(city, otherAddress.getCity(), where + ".city") & + helper.equals(state, otherAddress.getState(), where + ".state") & + helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & + helper.equals(country, otherAddress.getCountry(), where + ".country"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCAppAddress)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppAddress)o1, (PCAppAddress)o2); + } + + /** + * Compares this object with the specified Address object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Address object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Address + * object. + */ + public int compareTo(PCAppAddress other) { + return compare(this, other); + } + + /** + * Compares its two PCAppAddress 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 PCAppAddresss object to be compared. + * @param o2 the second FFCPIAddressobject 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(PCAppAddress o1, PCAppAddress o2) { + return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCAppAddress) { + return compareTo((PCAppAddress)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)addrid; + } + + /** + * This class is used to represent the application identifier + * for the Address class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for Address and must + * correspond in type and name to the field in + * Address. + */ + public long addrid; + + /** The required public, no-arg constructor. */ + public Oid() + { + addrid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param addrid the id of the Address. + */ + public Oid(long addrid) { + this.addrid = addrid; + } + + public Oid(String s) { addrid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + addrid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.addrid != o.addrid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) addrid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( addrid < other.addrid ) return -1; + if( addrid > other.addrid ) return 1; + return 0; + } + + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppAddress.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppCompany.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppCompany.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppCompany.java (revision 0) @@ -0,0 +1,400 @@ +/* + * 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.text.SimpleDateFormat; + +import java.util.Collections; +import java.util.Comparator; +import java.util.Set; +import java.util.HashSet; +import java.util.Date; +import org.apache.jdo.tck.pc.company.IAddress; + +import org.apache.jdo.tck.pc.company.ICompany; +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents information about a company. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION,table="companies") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") + public class PCAppCompany + implements ICompany, Serializable, Comparable, Comparator, DeepEquality { + + private long companyid; + private String name; + private Date founded; + private PCAppAddress address; + private transient Set departments = new HashSet(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppCompany() {} + + /** + * + * Initialize the PCAppCompany instance. + * + * + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + */ + public PCAppCompany(long companyid, String name, Date founded) { + this.companyid = companyid; + this.name = name; + this.founded = founded; + } + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + * @param addr The company's address. + */ + public PCAppCompany(long companyid, String name, Date founded, IAddress addr) { + this(companyid, name, founded); + this.address = (PCAppAddress)addr; + } + + /** + * Get the company id. + * @return The company id. + */ + @Persistent(primaryKey="true") + @Column(name="ID") + public long getCompanyid() { + return companyid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setCompanyid(long id) { + if (this.companyid != 0) + throw new IllegalStateException("Id is already set."); + this.companyid = id; + } + + /** + * Get the name of the company. + * @return The name of the company. + */ + @Column(name="NAME", jdbcType="VARCHAR") + public String getName() { + return name; + } + + /** + * Set the name of the company. + * @param name The value to use for the name of the company. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the date that the company was founded. + * @return The date the company was founded. + */ + @Column(name="FOUNDEDDATE") + public Date getFounded() { + return founded; + } + + /** + * Set the date that the company was founded. + * @param founded The date to set that the company was founded. + */ + public void setFounded(Date founded) { + this.founded = founded; + } + + /** + * Get the address of the company. + * @return The primary address of the company. + */ + @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 primary address for the company. + * @param address The address to set for the company. + */ + public void setAddress(IAddress address) { + this.address = (PCAppAddress)address; + } + + /** + * Get the departments contained in the company. + * + * + * @return An unmodifiable Set that contains all the + * PCAppDepartments of the company. + */ + + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + mappedBy="company") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) + public Set getDepartments() { + return Collections.unmodifiableSet(departments); + } + + /** + * Add a PCAppDepartment instance to the company. + * + * + * @param dept The PCAppDepartment instance to add. + */ + public void addDepartment(PCAppDepartment dept) { + departments.add(dept); + } + + /** + * Remove a PCAppDepartment instance from the company. + * + * + * @param dept The PCAppDepartment instance to remove. + */ + public void removeDepartment(PCAppDepartment dept) { + departments.remove(dept); + } + + /** + * Initialize the set of PCAppDepartments in the company to the + * parameter. + * + * + * @param departments The set of PCAppDepartments for the + * company. + */ + public void setDepartments(Set departments) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.departments = + (departments != null) ? new HashSet(departments) : null; + } + + /** Serialization support: initialize transient fields. */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + departments = new HashSet(); + } + + /** + * Returns a String representation of a Company object. + * @return a String representation of a Company object. + */ + public String toString() { + return "Company(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(companyid); + rc.append(", name ").append(name); + rc.append(", founded ").append(formatter.format(founded)); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppCompany otherCompany = (PCAppCompany)other; + String where = "Company<" + companyid + ">"; + return + helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") & + helper.equals(name, otherCompany.getName(), where + ".name") & + helper.equals(founded, otherCompany.getFounded(), where + ".founded") & + helper.deepEquals(address, otherCompany.getAddress(), where + ".address") & + helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCAppCompany)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppCompany)o1, (PCAppCompany)o2); + } + + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(PCAppCompany other) { + return compare(this, other); + } + + /** + * Compares its two ICompany arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first ICompany object to be compared. + * @param o2 the second ICompany object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCAppCompany o1, PCAppCompany o2) { + return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCAppCompany) { + return compareTo((PCAppCompany)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)companyid; + } + + /** + * The class to be used as the application identifier + * for the Company class. It consists of both the company + * name and the date that the company was founded. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the Company class. + */ + public long companyid; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param companyid The id of the company. + */ + public Oid(long companyid) { + this.companyid = companyid; + } + + public Oid(String s) { companyid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + companyid;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.companyid != o.companyid) + return false; + return true; + } + + /** */ + public int hashCode() { + return (int)companyid; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( companyid < other.companyid ) return -1; + if( companyid > other.companyid ) return 1; + return 0; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppCompany.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDentalInsurance.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDentalInsurance.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDentalInsurance.java (revision 0) @@ -0,0 +1,130 @@ +/* + * 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.math.BigDecimal; + +import org.apache.jdo.tck.pc.company.IDentalInsurance; +import org.apache.jdo.tck.pc.company.IEmployee; +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 PCAppDentalInsurance extends PCAppInsurance implements IDentalInsurance { + + private BigDecimal lifetimeOrthoBenefit; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppDentalInsurance() {} + + /** + * Construct a DentalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public PCAppDentalInsurance(long insid, String carrier, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Construct a PCAppDentalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public PCAppDentalInsurance(long insid, String carrier, IEmployee employee, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier, employee); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Get the insurance lifetimeOrthoBenefit. + * @return The insurance lifetimeOrthoBenefit. + */ + @Column(name="LIFETIME_ORTHO_BENEFIT") + public BigDecimal getLifetimeOrthoBenefit() { + return lifetimeOrthoBenefit; + } + + /** + * Set the insurance lifetimeOrthoBenefit. + * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. + */ + public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Returns a String representation of a PCAppDentalInsurance + * object. + * + * + * @return a String representation of a PCAppDentalInsurance + * object. + */ + public String toString() { + return "FCDentalInsurance(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", lifetimeOrthoBenefit ").append(lifetimeOrthoBenefit); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppDentalInsurance otherIns = (PCAppDentalInsurance)other; + String where = "FCDentalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(lifetimeOrthoBenefit, + otherIns.getLifetimeOrthoBenefit(), where + ".lifetimeOrthoBenefit"); + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppDentalInsurance.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java (revision 0) @@ -0,0 +1,439 @@ +/* + * 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; + + private long deptid; + private String name; + private PCAppCompany company; + private PCAppEmployee employeeOfTheMonth; + private transient Set employees = new HashSet(); + 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 as an unmodifiable set. + * @return The set of employees in the department, as an unmodifiable + * set. + */ + + @Persistent(mappedBy="department") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + public Set getEmployees() { + return Collections.unmodifiableSet(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 as an unmodifiable set. + * @return The set of funded employees in the department, as an + * unmodifiable set. + */ + + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Persistent(mappedBy="fundingDept") + public Set getFundedEmps() { + return Collections.unmodifiableSet(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; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppDepartment.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java (revision 0) @@ -0,0 +1,525 @@ +/* + * 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 { + + @Column(name="HIREDATE") + private Date hiredate; + @Column(name="WEEKLYHOURS") + private double weeklyhours; + @Persistent(mappedBy="employee", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDentalInsurance.class) + private PCAppDentalInsurance dentalInsurance; + @Persistent(mappedBy="employee") + private PCAppMedicalInsurance medicalInsurance; + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) + @Column(name="DEPARTMENT") + private PCAppDepartment department; + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) + @Column(name="FUNDINGDEPT") + private PCAppDepartment fundingDept; + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Column(name="MANAGER") + private PCAppEmployee manager; + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Column(name="MENTOR") + private PCAppEmployee mentor; + @Persistent(mappedBy="mentor", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + private PCAppEmployee protege; + @Column(name="HRADVISOR") + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + private PCAppEmployee hradvisor; + @Persistent(mappedBy="reviewers") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppProject.class) + private transient Set reviewedProjects = new HashSet(); + @Persistent(mappedBy="members") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppProject.class) + private transient Set projects = new HashSet(); + @Persistent(mappedBy="manager") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + private transient Set team = new HashSet(); + @Persistent(mappedBy="hradvisor") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + 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. + */ + 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. + */ + 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 as an unmodifiable set. + */ + public Set getReviewedProjects() { + return Collections.unmodifiableSet(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 are returned as an unmodifiable + * set. + */ + public Set getProjects() { + return Collections.unmodifiableSet(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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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, + * returned as an unmodifiable set. + */ + public Set getTeam() { + return Collections.unmodifiableSet(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. + */ + 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. + */ + 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. + */ + public IEmployee getHradvisor() { + return hradvisor; + } + + /** + * Get the HR advisees of this HR advisor. + * + * + * @return An unmodifiable Set containing the + * PCAppEmployees that are HR advisees of this employee. + */ + public Set getHradvisees() { + return Collections.unmodifiableSet(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"); + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppEmployee.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java (revision 0) @@ -0,0 +1,138 @@ +/* + * 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 { + + 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"); + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppFullTimeEmployee.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java (revision 0) @@ -0,0 +1,307 @@ +/* + * 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 { + + private long insid; + private String carrier; + 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; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppInsurance.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java (revision 0) @@ -0,0 +1,131 @@ +/* + * 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 { + + 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"); + } +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppMedicalInsurance.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java (revision 0) @@ -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.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 { + + 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"); + } +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppPartTimeEmployee.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java (revision 0) @@ -0,0 +1,465 @@ +/* + * 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 { + + private long personid; + private String firstname; + private String lastname; + private String middlename; + private Date birthdate; + private PCAppAddress address; + 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. + */ + 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 Collections.unmodifiableMap(phoneNumbers); + } + + /** + * Get the phone number for the specified phone number type. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String getPhoneNumber(String type) { + return (String)phoneNumbers.get(type); + } + + /** + * Associates the specified phone number with the specified type in the + * map of phone numbers of this person. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @param phoneNumber The phone number + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String putPhoneNumber(String type, String phoneNumber) { + return (String)phoneNumbers.put(type, phoneNumber); + } + + /** + * Remove a phoneNumber from the map of phone numbers. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String removePhoneNumber(String type) { + return (String)phoneNumbers.remove(type); + } + + /** + * Set the phoneNumber map to be in this person. + * @param phoneNumbers The map of phoneNumbers for this person. + */ + public void setPhoneNumbers(Map phoneNumbers) { + // workaround: create a new HashMap, because fostore does not + // support LinkedHashMap + this.phoneNumbers = + (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; + } + + /** + * Returns a String representation of a 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; + } + + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppPerson.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppProject.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppProject.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppProject.java (revision 0) @@ -0,0 +1,392 @@ +/* + * 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(identityType=IdentityType.APPLICATION, table="projects") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +public class PCAppProject + implements IProject, Serializable, Comparable, Comparator, DeepEquality { + + private long projid; + private String name; + private BigDecimal budget; + private transient Set reviewers = new HashSet(); + 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 PCAppProject() {} + + /** + * Initialize a project. + * @param projid The project identifier. + * @param name The name of the project. + * @param budget The budget for the project. + */ + public PCAppProject(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. + */ + + @PrimaryKey + @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.PCAppEmployee.class, + column="REVIEWER") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + public Set getReviewers() { + return Collections.unmodifiableSet(reviewers); + } + + /** + * Add a reviewer to the project. + * @param emp The employee to add as a reviewer. + */ + public void addReviewer(PCAppEmployee 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(PCAppEmployee emp) { + reviewers.remove(emp); + } + + /** + * Set the reviewers associated with this project. + * @param reviewers The set of reviewers to associate with this project. + */ + public void setReviewers(Set reviewers) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.reviewers = (reviewers != null) ? new HashSet(reviewers) : null; + } + + /** + * Get the project members. + * + * + * @return The members of the project is returned as an unmodifiable + * set of PCAppEmployees. + */ + + @Persistent(table="project_member") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class, + column="MEMBER", foreignKey="PR_MEMB_FK") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + public Set getMembers() { + return Collections.unmodifiableSet(members); + } + + /** + * Add a new member to the project. + * @param emp The employee to add to the project. + */ + public void addMember(PCAppEmployee emp) { + members.add(emp); + } + + /** + * Remove a member from the project. + * @param emp The employee to remove from the project. + */ + public void removeMember(PCAppEmployee 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 PCAppProject object. + * + * + * @return a String representation of a PCAppProject 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) { + PCAppProject otherProject = (PCAppProject)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((PCAppProject)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppProject)o1, (PCAppProject)o2); + } + + /** + * + * Compares this object with the specified PCAppProject 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 PCAppProject 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 F\PFCAppProject object. + */ + public int compareTo(PCAppProject 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(PCAppProject o1, PCAppProject 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 PCAppProject) { + return compareTo((PCAppProject)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 PCAppProject class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the + * PCAppProject class. It must match a field in the + * PCAppProject 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; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCAppProject.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSAddress.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSAddress.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSAddress.java (revision 0) @@ -0,0 +1,347 @@ +/* + * 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 java.io.Serializable; +import java.util.Comparator; + +import javax.jdo.annotations.*; +import org.apache.jdo.tck.pc.company.IAddress; + +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a postal address. + */ +@PersistenceCapable(embeddedOnly="true", requiresExtent="false") +public class PCDSAddress + implements IAddress, Serializable, Comparable, Comparator, DeepEquality { + + private long addrid; + private String street; + private String city; + private String state; + private String zipcode; + private String country; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSAddress() {} + + /** + * This constructor initializes the PCDSAddress components. + * + * + * @param addrid The address ID. + * @param street The street address. + * @param city The city. + * @param state The state. + * @param zipcode The zip code. + * @param country The zip country. + */ + public PCDSAddress(long addrid, String street, String city, + String state, String zipcode, String country) + { + this.addrid = addrid; + this.street = street; + this.city = city; + this.state = state; + this.zipcode = zipcode; + this.country = country; + } + + /** + * Get the addrid associated with this object. + * @return the addrid. + */ + public long getAddrid() { + return addrid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setAddrid(long id) { + if (this.addrid != 0) + throw new IllegalStateException("Id is already set."); + this.addrid = id; + } + + /** + * Get the street component of the address. + * @return The street component of the address. + */ + public String getStreet() { + return street; + } + + /** + * Set the street component of the address. + * @param street The street component. + */ + public void setStreet(String street) { + this.street = street; + } + + /** + * Get the city. + * @return The city component of the address. + */ + public String getCity() { + return city; + } + + /** + * Set the city component of the address. + * @param city The city. + */ + public void setCity(String city) { + this.city = city; + } + + /** + * Get the state component of the address. + * @return The state. + */ + public String getState() { + return state; + } + + /** + * Set the state component of the address. + * @param state The state. + */ + public void setState(String state) { + this.state = state; + } + + /** + * Get the zipcode component of the address. + * @return The zipcode. + */ + public String getZipcode() { + return zipcode; + } + + /** + * Set the zip code component of the address. + * @param zipcode The zipcode. + */ + public void setZipcode(String zipcode) { + this.zipcode = zipcode; + } + + /** + * Get the country component of the address. + * @return The country. + */ + public String getCountry() { + return country; + } + + /** + * Set the country component of the address. + * @param country The country. + */ + public void setCountry(String country) { + this.country = country; + } + + /** + * Returns a String representation of a Address object. + * @return a String representation of a Address object. + */ + public String toString() { + return "Address(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(addrid); + rc.append(", street ").append(street); + rc.append(", city ").append(city); + rc.append(", state ").append(state); + rc.append(", zipcode ").append(zipcode); + rc.append(", country ").append(country); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSAddress otherAddress = (PCDSAddress)other; + String where = "Address<" + addrid + ">"; + return + helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & + helper.equals(street, otherAddress.getStreet(), where + ".street") & + helper.equals(city, otherAddress.getCity(), where + ".city") & + helper.equals(state, otherAddress.getState(), where + ".state") & + helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & + helper.equals(country, otherAddress.getCountry(), where + ".country"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCDSAddress)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSAddress)o1, (PCDSAddress)o2); + } + + /** + * Compares this object with the specified Address object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Address object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Address + * object. + */ + public int compareTo(PCDSAddress other) { + return compare(this, other); + } + + /** + * Compares its two PCDSAddress 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 PCDSAddress object to be compared. + * @param o2 the second PCDSAddressobject 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(PCDSAddress o1, PCDSAddress o2) { + return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCDSAddress) { + return compareTo((PCDSAddress)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)addrid; + } + + /** + * This class is used to represent the application identifier + * for the Address class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for Address and must + * correspond in type and name to the field in + * Address. + */ + public long addrid; + + /** The required public, no-arg constructor. */ + public Oid() + { + addrid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param addrid the id of the Address. + */ + public Oid(long addrid) { + this.addrid = addrid; + } + + public Oid(String s) { addrid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + addrid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.addrid != o.addrid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) addrid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( addrid < other.addrid ) return -1; + if( addrid > other.addrid ) return 1; + return 0; + } + + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSAddress.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSCompany.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSCompany.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSCompany.java (revision 0) @@ -0,0 +1,405 @@ +/* + * 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.text.SimpleDateFormat; + +import java.util.Collections; +import java.util.Comparator; +import java.util.Set; +import java.util.HashSet; +import java.util.Date; +import org.apache.jdo.tck.pc.company.IAddress; +import org.apache.jdo.tck.pc.company.ICompany; + +import org.apache.jdo.tck.util.DeepEquality; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents information about a company. + */ +@PersistenceCapable(table="companies") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") +public class PCDSCompany + implements ICompany, Serializable, Comparable, Comparator, DeepEquality { + + private long companyid; + private String name; + private Date founded; + private PCDSAddress address; + private transient Set departments = new HashSet(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSCompany() {} + + /** + * + * Initialize the PCDSCompany instance. + * + * + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + */ + public PCDSCompany(long companyid, String name, Date founded) { + this.companyid = companyid; + this.name = name; + this.founded = founded; + } + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + * @param addr The company's address. + */ + public PCDSCompany(long companyid, String name, Date founded, IAddress addr) { + this(companyid, name, founded); + this.address = (PCDSAddress)addr; + } + + /** + * Get the company id. + * @return The company id. + */ + + @Column(name="ID") + public long getCompanyid() { + return companyid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setCompanyid(long id) { + if (this.companyid != 0) + throw new IllegalStateException("Id is already set."); + this.companyid = id; + } + + /** + * Get the name of the company. + * @return The name of the company. + */ + + @Column(name="NAME", jdbcType="VARCHAR") + public String getName() { + return name; + } + + /** + * Set the name of the company. + * @param name The value to use for the name of the company. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the date that the company was founded. + * @return The date the company was founded. + */ + + @Column(name="FOUNDEDDATE") + public Date getFounded() { + return founded; + } + + /** + * Set the date that the company was founded. + * @param founded The date to set that the company was founded. + */ + public void setFounded(Date founded) { + this.founded = founded; + } + + /** + * Get the address of the company. + * @return The primary address of the company. + */ + + @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 primary address for the company. + * @param address The address to set for the company. + */ + public void setAddress(IAddress address) { + this.address = (PCDSAddress)address; + } + + /** + * Get the departments contained in the company. + * + * + * @return An unmodifiable Set that contains all the + * PCDSDepartments of the company. + */ + + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + mappedBy="company") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDepartment.class) + public Set getDepartments() { + return Collections.unmodifiableSet(departments); + } + + /** + * Add a PCDSDepartment instance to the company. + * + * + * @param dept The PCDSDepartment instance to add. + */ + public void addDepartment(PCDSDepartment dept) { + departments.add(dept); + } + + /** + * Remove a PCDSDepartment instance from the company. + * + * + * @param dept The PCDSDepartment instance to remove. + */ + public void removeDepartment(PCDSDepartment dept) { + departments.remove(dept); + } + + /** + * Initialize the set of PCDSDepartments in the company to the + * parameter. + * + * + * @param departments The set of PCDSDepartments for the + * company. + */ + public void setDepartments(Set departments) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.departments = + (departments != null) ? new HashSet(departments) : null; + } + + /** Serialization support: initialize transient fields. */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + departments = new HashSet(); + } + + /** + * Returns a String representation of a Company object. + * @return a String representation of a Company object. + */ + public String toString() { + return "Company(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(companyid); + rc.append(", name ").append(name); + rc.append(", founded ").append(formatter.format(founded)); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSCompany otherCompany = (PCDSCompany)other; + String where = "Company<" + companyid + ">"; + return + helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") & + helper.equals(name, otherCompany.getName(), where + ".name") & + helper.equals(founded, otherCompany.getFounded(), where + ".founded") & + helper.deepEquals(address, otherCompany.getAddress(), where + ".address") & + helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCDSCompany)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSCompany)o1, (PCDSCompany)o2); + } + + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(PCDSCompany other) { + return compare(this, other); + } + + /** + * Compares its two ICompany arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first ICompany object to be compared. + * @param o2 the second ICompany object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCDSCompany o1, PCDSCompany o2) { + return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCDSCompany) { + return compareTo((PCDSCompany)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)companyid; + } + + /** + * The class to be used as the application identifier + * for the Company class. It consists of both the company + * name and the date that the company was founded. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the Company class. + */ + public long companyid; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param companyid The id of the company. + */ + public Oid(long companyid) { + this.companyid = companyid; + } + + public Oid(String s) { companyid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + companyid;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.companyid != o.companyid) + return false; + return true; + } + + /** */ + public int hashCode() { + return (int)companyid; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( companyid < other.companyid ) return -1; + if( companyid > other.companyid ) return 1; + return 0; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSCompany.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDentalInsurance.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDentalInsurance.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDentalInsurance.java (revision 0) @@ -0,0 +1,131 @@ +/* + * 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.math.BigDecimal; +import org.apache.jdo.tck.pc.company.IDentalInsurance; +import org.apache.jdo.tck.util.EqualityHelper; + +/** + * This class represents a dental insurance carrier selection for a + * particular Employee. + */ +@PersistenceCapable +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class PCDSDentalInsurance extends PCDSInsurance + implements IDentalInsurance { + + private BigDecimal lifetimeOrthoBenefit; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSDentalInsurance() {} + + /** + * Construct a DentalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public PCDSDentalInsurance(long insid, String carrier, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Construct a PCDSDentalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public PCDSDentalInsurance(long insid, String carrier, PCDSEmployee employee, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier, employee); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Get the insurance lifetimeOrthoBenefit. + * @return The insurance lifetimeOrthoBenefit. + */ + + @Column(name="LIFETIME_ORTHO_BENEFIT") + public BigDecimal getLifetimeOrthoBenefit() { + return lifetimeOrthoBenefit; + } + + /** + * Set the insurance lifetimeOrthoBenefit. + * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. + */ + public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } + + /** + * Returns a String representation of a PCDSDentalInsurance + * object. + * + * + * @return a String representation of a PCDSDentalInsurance + * object. + */ + public String toString() { + return "FCDentalInsurance(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", lifetimeOrthoBenefit ").append(lifetimeOrthoBenefit); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSDentalInsurance otherIns = (PCDSDentalInsurance)other; + String where = "FCDentalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(lifetimeOrthoBenefit, + otherIns.getLifetimeOrthoBenefit(), where + ".lifetimeOrthoBenefit"); + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSDentalInsurance.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDepartment.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDepartment.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDepartment.java (revision 0) @@ -0,0 +1,441 @@ +/* + * 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(table="departments") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") +public class PCDSDepartment + implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { + + public static final int RECOMMENDED_NO_OF_EMPS = 2; + + private long deptid; + private String name; + private PCDSCompany company; + private PCDSEmployee employeeOfTheMonth; + private transient Set employees = new HashSet(); + 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 PCDSDepartment() {} + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + */ + public PCDSDepartment(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 PCDSDepartment(long deptid, String name, ICompany company) { + this.deptid = deptid; + this.name = name; + this.company = (PCDSCompany)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 PCDSDepartment(long deptid, String name, ICompany company, + IEmployee employeeOfTheMonth) { + this.deptid = deptid; + this.name = name; + this.company = (PCDSCompany)company; + this.employeeOfTheMonth = (PCDSEmployee)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. + */ + @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.PCDSCompany.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 = (PCDSCompany)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.PCDSEmployee.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 = (PCDSEmployee)employeeOfTheMonth; + } + + /** + * Get the employees in the department as an unmodifiable set. + * @return The set of employees in the department, as an unmodifiable + * set. + */ + + @Persistent(mappedBy="department") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + public Set getEmployees() { + return Collections.unmodifiableSet(employees); + } + + /** + * Add an employee to the department. + * @param emp The employee to add to the department. + */ + public void addEmployee(PCDSEmployee emp) { + employees.add(emp); + } + + /** + * Remove an employee from the department. + * @param emp The employee to remove from the department. + */ + public void removeEmployee(PCDSEmployee 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 as an unmodifiable set. + * @return The set of funded employees in the department, as an + * unmodifiable set. + */ + + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + @Persistent(mappedBy="fundingDept") + public Set getFundedEmps() { + return Collections.unmodifiableSet(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(PCDSEmployee 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(PCDSEmployee 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 PCDSDepartment. + * + * + * @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) { + PCDSDepartment otherDept = (PCDSDepartment)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 PCDSDepartment object. + * + * + * @return a String representation of a PCDSDepartment 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((PCDSDepartment)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSDepartment)o1, (PCDSDepartment)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(PCDSDepartment 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(PCDSDepartment o1, PCDSDepartment 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 PCDSDepartment) { + return compareTo((PCDSDepartment)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; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSDepartment.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSEmployee.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSEmployee.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSEmployee.java (revision 0) @@ -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.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 +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public abstract class PCDSEmployee extends PCDSPerson implements IEmployee { + + private Date hiredate; + private double weeklyhours; + private PCDSDentalInsurance dentalInsurance; + private PCDSMedicalInsurance medicalInsurance; + private PCDSDepartment department; + private PCDSDepartment fundingDept; + private PCDSEmployee manager; + private PCDSEmployee mentor; + private PCDSEmployee protege; + private PCDSEmployee hradvisor; + private transient Set reviewedProjects = new HashSet(); + private transient Set projects = new HashSet(); + private transient Set team = new HashSet(); + private transient Set hradvisees = new HashSet(); + + + /** This is the JDO-required no-args constructor */ + protected PCDSEmployee() {} + + /** + * Construct an PCDSEmployee 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 PCDSEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate); + this.hiredate = hiredate; + } + + /** + * Construct an PCDSEmployee 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 PCDSEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, PCDSAddress address, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate, 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 as an unmodifiable set. + */ + + @Persistent(mappedBy="reviewers") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSProject.class) + public Set getReviewedProjects() { + return Collections.unmodifiableSet(reviewedProjects); + } + + /** + * Add a reviewed project. + * @param project A reviewed project. + */ + public void addReviewedProjects(PCDSProject project) { + reviewedProjects.add(project); + } + + /** + * Remove a reviewed project. + * @param project A reviewed project. + */ + public void removeReviewedProject(PCDSProject 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 are returned as an unmodifiable + * set. + */ + + @Persistent(mappedBy="members") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSProject.class) + public Set getProjects() { + return Collections.unmodifiableSet(projects); + } + + /** + * Add a project for the employee. + * @param project The project. + */ + public void addProject(PCDSProject project) { + projects.add(project); + } + + /** + * Remove a project from an employee's set of projects. + * @param project The project. + */ + public void removeProject(PCDSProject 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 = (PCDSDentalInsurance)dentalInsurance; + } + + /** + * Get the medical insurance of the employee. + * @return The employee's medical insurance. + */ + @Persistent(mappedBy="employee", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSMedicalInsurance.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 = (PCDSMedicalInsurance)medicalInsurance; + } + + /** + * Get the employee's department. + * @return The department associated with the employee. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDepartment.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 = (PCDSDepartment)department; + } + + /** + * Get the employee's funding department. + * @return The funding department associated with the employee. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDepartment.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 = (PCDSDepartment)department; + } + + /** + * Get the employee's manager. + * @return The employee's manager. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.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 = (PCDSEmployee)manager; + } + + /** + * Get the employee's team. + * + * + * @return The set of PCDSEmployees on this employee's team, + * returned as an unmodifiable set. + */ + + @Persistent(mappedBy="manager") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + public Set getTeam() { + return Collections.unmodifiableSet(team); + } + + /** + * Add an PCDSEmployee 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 PCDSEmployee to add to the team. + */ + public void addToTeam(PCDSEmployee emp) { + team.add(emp); + emp.manager = this; + } + + /** + * Remove an PCDSEmployee from this employee's team. + * This method will also set the emp manager to null. + * + * + * @param emp The PCDSEmployee to remove from the team. + */ + public void removeFromTeam(PCDSEmployee emp) { + team.remove(emp); + emp.manager = null; + } + + /** + * Set the employee's team. + * + * + * @param team The set of PCDSEmployees. + */ + 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 = (PCDSEmployee)mentor; + } + + /** + * Get the mentor for this employee. + * @return The mentor. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.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 = (PCDSEmployee)protege; + } + + /** + * Get the protege of this employee. + * @return The protege of this employee. + */ + + @Persistent(mappedBy="mentor", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.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 = (PCDSEmployee)hradvisor; + } + + /** + * Get the HR advisor for the employee. + * @return The HR advisor. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + @Column(name="HRADVISOR") + public IEmployee getHradvisor() { + return hradvisor; + } + + /** + * Get the HR advisees of this HR advisor. + * + * + * @return An unmodifiable Set containing the + * PCDSEmployees that are HR advisees of this employee. + */ + + @Persistent(mappedBy="hradvisor") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + public Set getHradvisees() { + return Collections.unmodifiableSet(hradvisees); + } + + /** + * Add an PCDSEmployee 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(PCDSEmployee emp) { + hradvisees.add(emp); + emp.hradvisor = this; + } + + /** + * Remove an PCDSEmployee 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(PCDSEmployee emp) { + hradvisees.remove(emp); + emp.hradvisor = null; + } + + /** + * Set the HR advisees of this HR advisor. + * + * + * @param hradvisees The PCDSEmployees 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 PCDSEmployee object. + * + * + * @return a String representation of a PCDSEmployee 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 PCDSEmployee. + * + * + * @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) { + PCDSEmployee otherEmp = (PCDSEmployee)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"); + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSEmployee.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSFullTimeEmployee.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSFullTimeEmployee.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSFullTimeEmployee.java (revision 0) @@ -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 +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class PCDSFullTimeEmployee extends PCDSEmployee + implements IFullTimeEmployee { + + private double salary; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSFullTimeEmployee() {} + + /** + * 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 PCDSFullTimeEmployee(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 PCDSFullTimeEmployee(long personid, String first, String last, + String middle, Date born, IAddress addr, + Date hired, double sal) { + super(personid, first, last, middle, born, (PCDSAddress)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 PCDSFullTimeEmployee object. + * + * + * @return a String representation of a PCDSFullTimeEmployee 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 + * PCDSFullTimeEmployee. + * + * + * @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) { + PCDSFullTimeEmployee otherEmp = (PCDSFullTimeEmployee)other; + String where = "FCFullTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSFullTimeEmployee.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java (revision 0) @@ -0,0 +1,308 @@ +/* + * 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 { + + private long insid; + private String carrier; + 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; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSInsurance.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java (revision 0) @@ -0,0 +1,133 @@ +/* + * 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 { + + @Column(name="PLANTYPE") + private String planType; // possible values: "PPO", "EPO", "NPO" + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public 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="EMPLOYEE") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + 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"); + } +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSMedicalInsurance.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java (revision 0) @@ -0,0 +1,138 @@ +/* + * 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 { + + 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"); + } +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSPartTimeEmployee.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java (revision 0) @@ -0,0 +1,465 @@ +/* + * 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 { + + private long personid; + private String firstname; + private String lastname; + private String middlename; + private Date birthdate; + private PCDSAddress address; + 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. + */ + 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 Collections.unmodifiableMap(phoneNumbers); + } + + /** + * Get the phone number for the specified phone number type. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String getPhoneNumber(String type) { + return (String)phoneNumbers.get(type); + } + + /** + * Associates the specified phone number with the specified type in the + * map of phone numbers of this person. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @param phoneNumber The phone number + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String putPhoneNumber(String type, String phoneNumber) { + return (String)phoneNumbers.put(type, phoneNumber); + } + + /** + * Remove a phoneNumber from the map of phone numbers. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String removePhoneNumber(String type) { + return (String)phoneNumbers.remove(type); + } + + /** + * Set the phoneNumber map to be in this person. + * @param phoneNumbers The map of phoneNumbers for this person. + */ + public void setPhoneNumbers(Map phoneNumbers) { + // workaround: create a new HashMap, because fostore does not + // support LinkedHashMap + this.phoneNumbers = + (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; + } + + /** + * Returns a String representation of a 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; + } + + } + +} Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSPerson.java ___________________________________________________________________ Name: svn:eol-style + LF Index: src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java =================================================================== --- src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java (revision 0) +++ src/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java (revision 0) @@ -0,0 +1,392 @@ +/* + * 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 { + + private long projid; + private String name; + private BigDecimal budget; + private transient Set reviewers = new HashSet(); + 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 Collections.unmodifiableSet(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 an unmodifiable + * 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 Collections.unmodifiableSet(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; + } + + } + +} + Property changes on: src\java\org\apache\jdo\tck\pc\companyAnnotatedPC\PCDSProject.java ___________________________________________________________________ Name: svn:eol-style + LF