// $LastChangedRevision: 5773 $ DO NOT EDIT. Make changes to Person.java instead. package er.rest.model; import java.util.NoSuchElementException; import org.apache.log4j.Logger; import com.webobjects.eoaccess.EOUtilities; import com.webobjects.eocontrol.EOEditingContext; import com.webobjects.eocontrol.EOFetchSpecification; import com.webobjects.eocontrol.EOGenericRecord; import com.webobjects.eocontrol.EOKeyValueQualifier; import com.webobjects.eocontrol.EOQualifier; import com.webobjects.eocontrol.EOSortOrdering; import com.webobjects.foundation.NSArray; @SuppressWarnings("all") public abstract class _Person extends EOGenericRecord { public static final String ENTITY_NAME = "Person"; // Attributes public static final String AGE_KEY = "age"; public static final String NAME_KEY = "name"; public static final String SALARY_KEY = "salary"; // Relationships public static final String COMPANY_KEY = "company"; private static Logger LOG = Logger.getLogger(_Person.class); public Person localInstanceIn(EOEditingContext editingContext) { Person localInstance = (Person)EOUtilities.localInstanceOfObject(editingContext, this); if (localInstance == null) { throw new IllegalStateException("You attempted to localInstance " + this + ", which has not yet committed."); } return localInstance; } public Integer age() { return (Integer) storedValueForKey("age"); } public void setAge(Integer value) { if (_Person.LOG.isDebugEnabled()) { _Person.LOG.debug( "updating age from " + age() + " to " + value); } takeStoredValueForKey(value, "age"); } public String name() { return (String) storedValueForKey("name"); } public void setName(String value) { if (_Person.LOG.isDebugEnabled()) { _Person.LOG.debug( "updating name from " + name() + " to " + value); } takeStoredValueForKey(value, "name"); } public Double salary() { return (Double) storedValueForKey("salary"); } public void setSalary(Double value) { if (_Person.LOG.isDebugEnabled()) { _Person.LOG.debug( "updating salary from " + salary() + " to " + value); } takeStoredValueForKey(value, "salary"); } public er.rest.model.Company company() { return (er.rest.model.Company)storedValueForKey("company"); } public void setCompanyRelationship(er.rest.model.Company value) { if (_Person.LOG.isDebugEnabled()) { _Person.LOG.debug("updating company from " + company() + " to " + value); } if (value == null) { er.rest.model.Company oldValue = company(); if (oldValue != null) { removeObjectFromBothSidesOfRelationshipWithKey(oldValue, "company"); } } else { addObjectToBothSidesOfRelationshipWithKey(value, "company"); } } public static Person createPerson(EOEditingContext editingContext, String name ) { Person eo = (Person) EOUtilities.createAndInsertInstance(editingContext, _Person.ENTITY_NAME); eo.setName(name); return eo; } public static NSArray<Person> fetchAllPersons(EOEditingContext editingContext) { return _Person.fetchAllPersons(editingContext, null); } public static NSArray<Person> fetchAllPersons(EOEditingContext editingContext, NSArray<EOSortOrdering> sortOrderings) { return _Person.fetchPersons(editingContext, null, sortOrderings); } public static NSArray<Person> fetchPersons(EOEditingContext editingContext, EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) { EOFetchSpecification fetchSpec = new EOFetchSpecification(_Person.ENTITY_NAME, qualifier, sortOrderings); fetchSpec.setIsDeep(true); NSArray<Person> eoObjects = (NSArray<Person>)editingContext.objectsWithFetchSpecification(fetchSpec); return eoObjects; } public static Person fetchPerson(EOEditingContext editingContext, String keyName, Object value) { return _Person.fetchPerson(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); } public static Person fetchPerson(EOEditingContext editingContext, EOQualifier qualifier) { NSArray<Person> eoObjects = _Person.fetchPersons(editingContext, qualifier, null); Person eoObject; int count = eoObjects.count(); if (count == 0) { eoObject = null; } else if (count == 1) { eoObject = (Person)eoObjects.objectAtIndex(0); } else { throw new IllegalStateException("There was more than one Person that matched the qualifier '" + qualifier + "'."); } return eoObject; } public static Person fetchRequiredPerson(EOEditingContext editingContext, String keyName, Object value) { return _Person.fetchRequiredPerson(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); } public static Person fetchRequiredPerson(EOEditingContext editingContext, EOQualifier qualifier) { Person eoObject = _Person.fetchPerson(editingContext, qualifier); if (eoObject == null) { throw new NoSuchElementException("There was no Person that matched the qualifier '" + qualifier + "'."); } return eoObject; } public static Person localInstanceIn(EOEditingContext editingContext, Person eo) { Person localInstance = (eo == null) ? null : (Person)EOUtilities.localInstanceOfObject(editingContext, eo); if (localInstance == null && eo != null) { throw new IllegalStateException("You attempted to localInstance " + eo + ", which has not yet committed."); } return localInstance; } }