From 87b880dbe308d0ed8437014ca81c658b2253b941 Mon Sep 17 00:00:00 2001 From: Fabian Peters Date: Sun, 15 Nov 2015 12:34:39 +0100 Subject: [PATCH] Include Rentals EOModel in eogen configuration. Refactor EOs from the Rentals model to use superclass methods where possible. Add ERCoreUserInterface implementation to User entity and use this instead of the newly added AppUser entity. Remove AppUser entity from the Movies model and delete the related migration. --- .../ERMoviesLogic/Resources/Movies.eogen | 2 +- .../Resources/Movies.eomodeld/AppUser.plist | 25 -- .../Resources/Movies.eomodeld/index.eomodeld | 4 - .../movies/migrations/Movies4.java | 29 -- .../rentals/common/CreditCard.java | 33 +- .../rentals/common/Customer.java | 96 ++--- .../businesslogic/rentals/common/Fee.java | 54 +-- .../businesslogic/rentals/common/FeeType.java | 62 +--- .../businesslogic/rentals/common/Rental.java | 48 +-- .../rentals/common/RentalTerms.java | 93 +---- .../businesslogic/rentals/common/Unit.java | 36 +- .../businesslogic/rentals/common/User.java | 44 ++- .../businesslogic/rentals/common/Video.java | 10 +- .../rentals/common/_CreditCard.java | 201 +++++++++++ .../rentals/common/_Customer.java | 330 ++++++++++++++++++ .../businesslogic/rentals/common/_Fee.java | 182 ++++++++++ .../rentals/common/_FeeType.java | 143 ++++++++ .../businesslogic/rentals/common/_Rental.java | 277 +++++++++++++++ .../rentals/common/_RentalTerms.java | 158 +++++++++ .../businesslogic/rentals/common/_Unit.java | 277 +++++++++++++++ .../businesslogic/rentals/common/_User.java | 188 ++++++++++ .../businesslogic/rentals/common/_Video.java | 250 +++++++++++++ .../er/modern/movies/test/Application.java | 4 +- .../er/modern/movies/test/DirectAction.java | 6 +- 24 files changed, 2111 insertions(+), 441 deletions(-) delete mode 100644 Frameworks/BusinessLogic/ERMoviesLogic/Resources/Movies.eomodeld/AppUser.plist delete mode 100644 Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/movies/migrations/Movies4.java create mode 100644 Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_CreditCard.java create mode 100644 Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Customer.java create mode 100644 Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Fee.java create mode 100644 Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_FeeType.java create mode 100644 Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Rental.java create mode 100644 Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_RentalTerms.java create mode 100644 Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Unit.java create mode 100644 Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_User.java create mode 100644 Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Video.java diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Resources/Movies.eogen b/Frameworks/BusinessLogic/ERMoviesLogic/Resources/Movies.eogen index 4ace1aa714e..97dca8d2bc8 100644 --- a/Frameworks/BusinessLogic/ERMoviesLogic/Resources/Movies.eogen +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Resources/Movies.eogen @@ -1 +1 @@ - -destination Sources -extension java -java -javaTemplate _WonderEntity.java -model Resources/Movies.eomodeld -packagedirs -subclassDestination Sources -subclassJavaTemplate WonderEntity.java -templatedir EOTemplates -verbose -loadModelGroup -define-EOGenericRecord er.extensions.eof.ERXGenericRecord \ No newline at end of file + -destination Sources -extension java -java -javaTemplate _WonderEntity.java -model Resources/Movies.eomodeld -model Resources/Rentals.eomodeld -packagedirs -subclassDestination Sources -subclassJavaTemplate WonderEntity.java -templatedir EOTemplates -verbose -loadModelGroup -define-EOGenericRecord er.extensions.eof.ERXGenericRecord \ No newline at end of file diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Resources/Movies.eomodeld/AppUser.plist b/Frameworks/BusinessLogic/ERMoviesLogic/Resources/Movies.eomodeld/AppUser.plist deleted file mode 100644 index ae29741f534..00000000000 --- a/Frameworks/BusinessLogic/ERMoviesLogic/Resources/Movies.eomodeld/AppUser.plist +++ /dev/null @@ -1,25 +0,0 @@ -{ - attributes = ( - { - allowsNull = N; - columnName = "APP_USER_ID"; - externalType = integer; - name = appUserID; - precision = 9; - prototypeName = id; - }, - {columnName = "USER_NAME"; name = userName; prototypeName = varchar50; } - ); - attributesUsedForLocking = (appUserID, userName); - className = "webobjectsexamples.businesslogic.movies.common.AppUser"; - classProperties = (userName); - externalName = "app_user"; - fetchSpecificationDictionary = {}; - internalInfo = { - "_clientClassPropertyNames" = (userName); - "_javaClientClassName" = "webobjectsexamples.businesslogic.movies.common.AppUser"; - }; - maxNumberOfInstancesToBatchFetch = 10; - name = AppUser; - primaryKeyAttributes = (appUserID); -} diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Resources/Movies.eomodeld/index.eomodeld b/Frameworks/BusinessLogic/ERMoviesLogic/Resources/Movies.eomodeld/index.eomodeld index ee7a5b1318f..8dd76d52167 100644 --- a/Frameworks/BusinessLogic/ERMoviesLogic/Resources/Movies.eomodeld/index.eomodeld +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Resources/Movies.eomodeld/index.eomodeld @@ -2,10 +2,6 @@ EOModelVersion = "2.1"; adaptorName = JDBC; entities = ( - { - className = "webobjectsexamples.businesslogic.movies.common.AppUser"; - name = AppUser; - }, {className = EOGenericRecord; name = Director; }, { className = "webobjectsexamples.businesslogic.movies.common.Movie"; diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/movies/migrations/Movies4.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/movies/migrations/Movies4.java deleted file mode 100644 index 5164644f58f..00000000000 --- a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/movies/migrations/Movies4.java +++ /dev/null @@ -1,29 +0,0 @@ -package webobjectsexamples.businesslogic.movies.migrations; - -import com.webobjects.eocontrol.EOEditingContext; -import com.webobjects.foundation.NSArray; - -import er.extensions.migration.ERXMigrationDatabase; -import er.extensions.migration.ERXMigrationTable; -import er.extensions.migration.ERXModelVersion; - -public class Movies4 extends ERXMigrationDatabase.Migration { - @Override - public NSArray modelDependencies() { - return null; - } - - @Override - public void downgrade(EOEditingContext editingContext, ERXMigrationDatabase database) throws Throwable { - // DO NOTHING - } - - @Override - public void upgrade(EOEditingContext editingContext, ERXMigrationDatabase database) throws Throwable { - ERXMigrationTable appUserTable = database.newTableNamed("app_user"); - appUserTable.newIntegerColumn("APP_USER_ID", 9, NOT_NULL); - appUserTable.newStringColumn("USER_NAME", 50, NOT_NULL); - appUserTable.create(); - appUserTable.setPrimaryKey("APP_USER_ID"); - } -} \ No newline at end of file diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/CreditCard.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/CreditCard.java index 1d2fa89b4d6..0f2c47fac83 100644 --- a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/CreditCard.java +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/CreditCard.java @@ -15,25 +15,13 @@ import java.math.BigDecimal; import com.webobjects.eocontrol.EOEditingContext; -import com.webobjects.eocontrol.EOGenericRecord; import com.webobjects.foundation.NSTimestamp; -public class CreditCard extends EOGenericRecord { - private static final long serialVersionUID = 8148546767562117626L; +public class CreditCard extends _CreditCard { - public static final String AuthorizationDateKey = "authorizationDate"; + private static final long serialVersionUID = 1L; - public static final String AuthorizationNumKey = "authorizationNum"; - - public static final String CardNumberKey = "cardNumber"; - - public static final String CustomerKey = "customer"; - - public static final String ExpirationDateKey = "expirationDate"; - - public static final String LimitKey = "limit"; - - public static final BigDecimal DefaultLimit = new BigDecimal(150); + public static final BigDecimal DefaultLimit = new BigDecimal(150); public CreditCard() { super(); @@ -50,19 +38,4 @@ public void awakeFromInsertion(EOEditingContext editingContext) { } } - public NSTimestamp authorizationDate() { - return (NSTimestamp) (storedValueForKey(AuthorizationDateKey)); - } - - public void setAuthorizationDate(NSTimestamp value) { - takeStoredValueForKey(value, AuthorizationDateKey); - } - - public BigDecimal limit() { - return (BigDecimal) (storedValueForKey(LimitKey)); - } - - public void setLimit(BigDecimal value) { - takeStoredValueForKey(value, LimitKey); - } } diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Customer.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Customer.java index 42963a8a6a2..f815c663df7 100644 --- a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Customer.java +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Customer.java @@ -15,8 +15,6 @@ import java.math.BigDecimal; import com.webobjects.eocontrol.EOEditingContext; -import com.webobjects.eocontrol.EOEnterpriseObject; -import com.webobjects.eocontrol.EOGenericRecord; import com.webobjects.eocontrol.EOKeyValueQualifier; import com.webobjects.eocontrol.EOQualifier; import com.webobjects.foundation.NSArray; @@ -25,30 +23,11 @@ import com.webobjects.foundation.NSTimestamp; import com.webobjects.foundation.NSValidation; -public class Customer extends EOGenericRecord { - private static final long serialVersionUID = -1996155567059278076L; +public class Customer extends _Customer { - public static final String CityKey = "city"; + private static final long serialVersionUID = 1L; - public static final String CreditCardKey = "creditCard"; - - public static final String FirstNameKey = "firstName"; - - public static final String LastNameKey = "lastName"; - - public static final String MemberSinceKey = "memberSince"; - - public static final String PhoneKey = "phone"; - - public static final String RentalsKey = "rentals"; - - public static final String StateKey = "state"; - - public static final String StreetAddressKey = "streetAddress"; - - public static final String ZipKey = "zip"; - - private static final String _DepositAmountKeyPath = "unit.video.rentalTerms.depositAmount"; + private static final String _DepositAmountKeyPath = "unit.video.rentalTerms.depositAmount"; public static final BigDecimal DefaultCostRestriction = new BigDecimal(50); @@ -57,8 +36,8 @@ public Customer() { } @Override - public void awakeFromInsertion(EOEditingContext editingContext) { - super.awakeFromInsertion(editingContext); + public void init(EOEditingContext editingContext) { + super.init(editingContext); if (memberSince() == null) { setMemberSince(new NSTimestamp()); } @@ -68,10 +47,10 @@ public void awakeFromInsertion(EOEditingContext editingContext) { public void validateForSave() throws NSValidation.ValidationException { // calculate deposit BigDecimal deposit = new BigDecimal(0); - NSArray outRentals = outRentals(); + NSArray outRentals = outRentals(); int count = outRentals.count(); for (int i = 0; i < count; i++) { - BigDecimal amount = (BigDecimal) (((EOEnterpriseObject) (outRentals.objectAtIndex(i))).valueForKeyPath(_DepositAmountKeyPath)); + BigDecimal amount = (BigDecimal) ((outRentals.objectAtIndex(i)).valueForKeyPath(_DepositAmountKeyPath)); if (amount != null) { deposit = deposit.add(amount); } @@ -85,38 +64,6 @@ public void validateForSave() throws NSValidation.ValidationException { super.validateForSave(); } - public CreditCard creditCard() { - return (CreditCard) (storedValueForKey(CreditCardKey)); - } - - public String firstName() { - return (String) (storedValueForKey(FirstNameKey)); - } - - public void setFirstName(String value) { - takeStoredValueForKey(value, FirstNameKey); - } - - public String lastName() { - return (String) (storedValueForKey(LastNameKey)); - } - - public void setLastName(String value) { - takeStoredValueForKey(value, LastNameKey); - } - - public NSTimestamp memberSince() { - return (NSTimestamp) (storedValueForKey(MemberSinceKey)); - } - - public void setMemberSince(NSTimestamp value) { - takeStoredValueForKey(value, MemberSinceKey); - } - - public NSArray rentals() { - return (NSArray) (storedValueForKey(RentalsKey)); - } - public BigDecimal costRestriction() { CreditCard creditCard = creditCard(); return (creditCard != null) ? creditCard.limit() : DefaultCostRestriction; @@ -130,14 +77,13 @@ public String fullName() { return buffer.toString(); } - @SuppressWarnings("unchecked") - public NSArray allFees() { - NSMutableArray allFees = new NSMutableArray(); - NSArray rentals = rentals(); + public NSArray allFees() { + NSMutableArray allFees = new NSMutableArray(); + NSArray rentals = rentals(); if (rentals != null) { int count = rentals.count(); for (int i = 0; i < count; i++) { - NSArray fees = ((Rental) (rentals.objectAtIndex(i))).fees(); + NSArray fees = rentals.objectAtIndex(i).fees(); if (fees != null) { allFees.addObjectsFromArray(fees); } @@ -150,8 +96,8 @@ public Number numberOfAllFees() { return Integer.valueOf(allFees().count()); } - public NSArray unpaidFees() { - EOQualifier qualifier = new EOKeyValueQualifier(Fee.DatePaidKey, EOQualifier.QualifierOperatorEqual, NSKeyValueCoding.NullValue); + public NSArray unpaidFees() { + EOQualifier qualifier = new EOKeyValueQualifier(Fee.DATE_PAID_KEY, EOQualifier.QualifierOperatorEqual, NSKeyValueCoding.NullValue); return EOQualifier.filteredArrayWithQualifier(allFees(), qualifier); } @@ -163,16 +109,16 @@ public boolean hasUnpaidFees() { return (unpaidFees().count() > 0); } - public NSArray allRentals() { - NSArray rentals = rentals(); - return (rentals != null) ? rentals : new NSArray(); + public NSArray allRentals() { + NSArray rentals = rentals(); + return (rentals != null) ? rentals : new NSArray(); } public Number numberOfAllRentals() { return Integer.valueOf(allRentals().count()); } - public NSArray outRentals() { + public NSArray outRentals() { EOQualifier qualifier = new EOKeyValueQualifier(Rental.IsOutKey, EOQualifier.QualifierOperatorEqual, Boolean.TRUE); return EOQualifier.filteredArrayWithQualifier(allRentals(), qualifier); } @@ -185,7 +131,7 @@ public boolean hasOutRentals() { return (outRentals().count() > 0); } - public NSArray overdueRentals() { + public NSArray overdueRentals() { EOQualifier qualifier = new EOKeyValueQualifier(Rental.IsOverdueKey, EOQualifier.QualifierOperatorEqual, Boolean.TRUE); return EOQualifier.filteredArrayWithQualifier(allRentals(), qualifier); } @@ -211,8 +157,8 @@ public void rentUnit(Unit unit) { editingContext.insertObject(fee); editingContext.insertObject(rental); // manipulate relationships after inserting objects - rental.addObjectToBothSidesOfRelationshipWithKey(unit, Rental.UnitKey); - rental.addObjectToBothSidesOfRelationshipWithKey(fee, Rental.FeesKey); - addObjectToBothSidesOfRelationshipWithKey(rental, RentalsKey); + rental.addObjectToBothSidesOfRelationshipWithKey(unit, Rental.UNIT_KEY); + rental.addObjectToBothSidesOfRelationshipWithKey(fee, Rental.FEES_KEY); + addObjectToBothSidesOfRelationshipWithKey(rental, RENTALS_KEY); } } diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Fee.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Fee.java index 242cfeb50e7..2a4daff710e 100644 --- a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Fee.java +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Fee.java @@ -14,24 +14,16 @@ import java.math.BigDecimal; import com.webobjects.eocontrol.EOEditingContext; -import com.webobjects.eocontrol.EOGenericRecord; import com.webobjects.foundation.NSTimestamp; import com.webobjects.foundation.NSValidation; -public class Fee extends EOGenericRecord { - private static final long serialVersionUID = -6593943328561415279L; +public class Fee extends _Fee { + + private static final long serialVersionUID = 1L; - public static final String AmountKey = "amount"; - - public static final String DatePaidKey = "datePaid"; - - public static final String FeeTypeKey = "feeType"; - - public static final String RentalKey = "rental"; - - private static final String _CostKeyPath = "rental.unit.video.rentalTerms.cost"; - - public static final int LateFeeAmountPerDay = 3; + private static final String _CostKeyPath = "rental.unit.video.rentalTerms.cost"; + + public static final int LateFeeAmountPerDay = 3; public Fee() { super(); @@ -48,8 +40,8 @@ public Fee(NSTimestamp date, EOEditingContext editingContext) { } @Override - public void awakeFromInsertion(EOEditingContext editingContext) { - super.awakeFromInsertion(editingContext); + public void init(EOEditingContext editingContext) { + super.init(editingContext); if (amount() == null) { setAmount((BigDecimal) (valueForKeyPath(_CostKeyPath))); } @@ -66,36 +58,8 @@ public void validateForDelete() throws NSValidation.ValidationException { super.validateForDelete(); } - public BigDecimal amount() { - return (BigDecimal) (storedValueForKey(AmountKey)); - } - - public void setAmount(BigDecimal value) { - takeStoredValueForKey(value, AmountKey); - } - - public NSTimestamp datePaid() { - return (NSTimestamp) (storedValueForKey(DatePaidKey)); - } - - public void setDatePaid(NSTimestamp value) { - takeStoredValueForKey(value, DatePaidKey); - } - - public FeeType feeType() { - return (FeeType) (storedValueForKey(FeeTypeKey)); - } - - public void setFeeType(FeeType value) { - takeStoredValueForKey(value, FeeTypeKey); - } - - public Rental rental() { - return (Rental) (storedValueForKey(RentalKey)); - } - public void setRental(Rental value) { - takeStoredValueForKey(value, RentalKey); + super.setRental(value); if (amount() == null) { setAmount((BigDecimal) (valueForKeyPath(_CostKeyPath))); } diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/FeeType.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/FeeType.java index 2e912f909c3..591a530e9e9 100644 --- a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/FeeType.java +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/FeeType.java @@ -12,55 +12,25 @@ package webobjectsexamples.businesslogic.rentals.common; +import com.webobjects.eoaccess.EOUtilities; import com.webobjects.eocontrol.EOEditingContext; -import com.webobjects.eocontrol.EOEnterpriseObject; -import com.webobjects.eocontrol.EOFetchSpecification; -import com.webobjects.eocontrol.EOGenericRecord; -import com.webobjects.eocontrol.EOGlobalID; -import com.webobjects.eocontrol.EOKeyValueQualifier; -import com.webobjects.eocontrol.EOQualifier; -import com.webobjects.foundation.NSArray; -public class FeeType extends EOGenericRecord { - private static final long serialVersionUID = -3924679005498502385L; +public class FeeType extends _FeeType { + private static final long serialVersionUID = 1L; - public static final String EnabledKey = "enabled"; + public FeeType() { + super(); + } - public static final String FeeTypeKey = "feeType"; + public static FeeType defaultFeeType(EOEditingContext editingContext) { + // default fee type is the object with primary key = 1 + return (FeeType) EOUtilities.objectWithPrimaryKeyValue(editingContext, + ENTITY_NAME, 1); + } - public static final String OrderByKey = "orderBy"; - - public static final String FeeTypeEntityName = "FeeType"; - - public static final String FeeTypeIDKey = "feeTypeID"; - - private static EOGlobalID _defaultFeeTypeGlobalID = null; - - private static EOGlobalID _lateFeeTypeGlobalID = null; - - public FeeType() { - super(); - } - - private static EOGlobalID _globalIDForPrimaryKey(int primaryKey, EOEditingContext editingContext) { - EOFetchSpecification fetchSpecification = new EOFetchSpecification(FeeTypeEntityName, new EOKeyValueQualifier(FeeTypeIDKey, EOQualifier.QualifierOperatorEqual, Integer.valueOf(primaryKey)), null); - NSArray objects = editingContext.objectsWithFetchSpecification(fetchSpecification); - return (objects.count() > 0) ? editingContext.globalIDForObject((EOEnterpriseObject) (objects.objectAtIndex(0))) : null; - } - - public static FeeType defaultFeeType(EOEditingContext editingContext) { - if (_defaultFeeTypeGlobalID == null) { - // default fee type is the object with primary key = 1 - _defaultFeeTypeGlobalID = _globalIDForPrimaryKey(1, editingContext); - } - return (_defaultFeeTypeGlobalID != null) ? (FeeType) (editingContext.faultForGlobalID(_defaultFeeTypeGlobalID, editingContext)) : null; - } - - public static FeeType lateFeeType(EOEditingContext editingContext) { - if (_lateFeeTypeGlobalID == null) { - // late fee type is the object with primary key = 2 - _lateFeeTypeGlobalID = _globalIDForPrimaryKey(2, editingContext); - } - return (_lateFeeTypeGlobalID != null) ? (FeeType) (editingContext.faultForGlobalID(_lateFeeTypeGlobalID, editingContext)) : null; - } + public static FeeType lateFeeType(EOEditingContext editingContext) { + // late fee type is the object with primary key = 2 + return (FeeType) EOUtilities.objectWithPrimaryKeyValue(editingContext, + ENTITY_NAME, 1); + } } diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Rental.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Rental.java index 128d1099407..8badffaba3d 100644 --- a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Rental.java +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Rental.java @@ -13,29 +13,19 @@ package webobjectsexamples.businesslogic.rentals.common; import com.webobjects.eocontrol.EOEditingContext; -import com.webobjects.eocontrol.EOGenericRecord; import com.webobjects.foundation.NSArray; import com.webobjects.foundation.NSTimestamp; import com.webobjects.foundation.NSValidation; -public class Rental extends EOGenericRecord { - private static final long serialVersionUID = -6572273760378405850L; +public class Rental extends _Rental { - public static final String CustomerKey = "customer"; + private static final long serialVersionUID = 1L; - public static final String DateOutKey = "dateOut"; + public static final String IsOutKey = "isOut"; - public static final String DateReturnedKey = "dateReturned"; + public static final String IsOverdueKey = "isOverdue"; - public static final String FeesKey = "fees"; - - public static final String UnitKey = "unit"; - - public static final String IsOutKey = "isOut"; - - public static final String IsOverdueKey = "isOverdue"; - - private static final String _CheckOutLengthKeyPath = "unit.video.rentalTerms.checkOutLength"; + private static final String _CheckOutLengthKeyPath = "unit.video.rentalTerms.checkOutLength"; public Rental() { super(); @@ -58,30 +48,6 @@ public void validateForSave() throws NSValidation.ValidationException { super.validateForSave(); } - public Customer customer() { - return (Customer) (storedValueForKey(CustomerKey)); - } - - public NSTimestamp dateOut() { - return (NSTimestamp) (storedValueForKey(DateOutKey)); - } - - public void setDateOut(NSTimestamp value) { - takeStoredValueForKey(value, DateOutKey); - } - - public NSTimestamp dateReturned() { - return (NSTimestamp) (storedValueForKey(DateReturnedKey)); - } - - public void setDateReturned(NSTimestamp value) { - takeStoredValueForKey(value, DateReturnedKey); - } - - public NSArray fees() { - return (NSArray) (storedValueForKey(FeesKey)); - } - public NSTimestamp dateDue() { NSTimestamp dateOut = dateOut(); if (dateOut != null) { @@ -113,7 +79,7 @@ public String isOverdueString() { public void feePaid() { if (dateReturned() != null) { - NSArray fees = fees(); + NSArray fees = fees(); if (fees != null) { int count = fees.count(); for (int i = 0; i < count; i++) { @@ -137,7 +103,7 @@ public void returnVideo() { Fee fee = new Fee(dateDue(), editingContext); editingContext.insertObject(fee); // manipulate relationship after inserting object - addObjectToBothSidesOfRelationshipWithKey(fee, FeesKey); + addObjectToBothSidesOfRelationshipWithKey(fee, FEES_KEY); } } } diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/RentalTerms.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/RentalTerms.java index 33cd5100a9c..47ace343d07 100644 --- a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/RentalTerms.java +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/RentalTerms.java @@ -12,91 +12,20 @@ package webobjectsexamples.businesslogic.rentals.common; -import java.math.BigDecimal; - -import com.webobjects.eocontrol.EOCustomObject; +import com.webobjects.eoaccess.EOUtilities; import com.webobjects.eocontrol.EOEditingContext; -import com.webobjects.eocontrol.EOEnterpriseObject; -import com.webobjects.eocontrol.EOFetchSpecification; -import com.webobjects.eocontrol.EOGlobalID; -import com.webobjects.eocontrol.EOKeyValueQualifier; -import com.webobjects.eocontrol.EOQualifier; -import com.webobjects.foundation.NSArray; - -// RentalTerms inherits from EOCustomObject as an example of not inheriting from EOGenericRecord -public class RentalTerms extends EOCustomObject { - private static final long serialVersionUID = 4273410078165804242L; - - public static final String RentalTermsEntityName = "RentalTerms"; - - public static final String RentalTermsIDKey = "rentalTermsID"; - - private transient Number _checkOutLength; - - private transient BigDecimal _cost; - - private transient BigDecimal _depositAmount; - - private transient String _name; - - private static EOGlobalID _defaultRentalTermsGlobalID = null; - - private static EOGlobalID _globalIDForPrimaryKey(int primaryKey, EOEditingContext editingContext) { - EOFetchSpecification fetchSpecification = new EOFetchSpecification(RentalTermsEntityName, - new EOKeyValueQualifier(RentalTermsIDKey, EOQualifier.QualifierOperatorEqual, Integer.valueOf(primaryKey)), null); - NSArray objects = editingContext.objectsWithFetchSpecification(fetchSpecification); - return (objects.count() > 0) ? editingContext.globalIDForObject((EOEnterpriseObject) (objects.objectAtIndex(0))) : null; - } - - public static RentalTerms defaultRentalTerms(EOEditingContext editingContext) { - if (_defaultRentalTermsGlobalID == null) { - // default rental terms are the object with primary key = 1 - _defaultRentalTermsGlobalID = _globalIDForPrimaryKey(1, editingContext); - } - return (_defaultRentalTermsGlobalID != null) ? (RentalTerms) (editingContext.faultForGlobalID(_defaultRentalTermsGlobalID, editingContext)) : null; - } - - public RentalTerms() { - super(); - } - - public Number checkOutLength() { - willRead(); - return _checkOutLength; - } - - public void setCheckOutLength(Number value) { - willChange(); - _checkOutLength = value; - } - - public BigDecimal cost() { - willRead(); - return _cost; - } - - public void setCost(BigDecimal value) { - willChange(); - _cost = value; - } - public BigDecimal depositAmount() { - willRead(); - return _depositAmount; - } +public class RentalTerms extends _RentalTerms { - public void setDepositAmount(BigDecimal value) { - willChange(); - _depositAmount = value; - } + private static final long serialVersionUID = 1L; - public String name() { - willRead(); - return _name; - } + public static RentalTerms defaultRentalTerms(EOEditingContext editingContext) { + // default rental terms are the object with primary key = 1 + return (RentalTerms) EOUtilities.objectWithPrimaryKeyValue(editingContext, + ENTITY_NAME, 1); + } - public void setName(String value) { - willChange(); - _name = value; - } + public RentalTerms() { + super(); + } } diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Unit.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Unit.java index dc23cf87fec..3f62685f0b8 100644 --- a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Unit.java +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Unit.java @@ -13,25 +13,15 @@ package webobjectsexamples.businesslogic.rentals.common; import com.webobjects.eocontrol.EOEditingContext; -import com.webobjects.eocontrol.EOGenericRecord; import com.webobjects.foundation.NSArray; import com.webobjects.foundation.NSTimestamp; import com.webobjects.foundation.NSValidation; -public class Unit extends EOGenericRecord { - private static final long serialVersionUID = -1282298842109267336L; +public class Unit extends _Unit { - public static final String DateAcquiredKey = "dateAcquired"; + private static final long serialVersionUID = 1L; - public static final String NotesKey = "notes"; - - public static final String RentalsKey = "rentals"; - - public static final String UnitIDKey = "unitID"; - - public static final String VideoKey = "video"; - - public Unit() { + public Unit() { super(); } @@ -46,7 +36,7 @@ public void awakeFromInsertion(EOEditingContext editingContext) { @Override public void validateForSave() throws NSValidation.ValidationException { int rentalsOut = 0; - NSArray rentals = rentals(); + NSArray rentals = rentals(); if (rentals != null) { int count = rentals.count(); for (int i = 0; i < count; i++) { @@ -62,24 +52,8 @@ public void validateForSave() throws NSValidation.ValidationException { super.validateForSave(); } - public Number unitID() { - return (Number) (storedValueForKey(UnitIDKey)); - } - - public NSTimestamp dateAcquired() { - return (NSTimestamp) (storedValueForKey(DateAcquiredKey)); - } - - public void setDateAcquired(NSTimestamp value) { - takeStoredValueForKey(value, DateAcquiredKey); - } - - public NSArray rentals() { - return (NSArray) (storedValueForKey(RentalsKey)); - } - public boolean isAvailableForRent() { - NSArray rentals = rentals(); + NSArray rentals = rentals(); if (rentals != null) { int count = rentals.count(); for (int i = 0; i < count; i++) { diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/User.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/User.java index abe6e2890dc..f88cb9cb3b2 100644 --- a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/User.java +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/User.java @@ -13,20 +13,16 @@ package webobjectsexamples.businesslogic.rentals.common; import com.webobjects.eocontrol.EOEditingContext; -import com.webobjects.eocontrol.EOGenericRecord; +import com.webobjects.eocontrol.EOEnterpriseObject; +import com.webobjects.foundation.NSArray; -public class User extends EOGenericRecord { - private static final long serialVersionUID = -4880721435398743375L; +import er.corebusinesslogic.ERCoreUserInterface; - public static final String AccessLevelKey = "accessLevel"; +public class User extends _User implements ERCoreUserInterface { - public static final String CustomerKey = "customer"; + private static final long serialVersionUID = 1L; - public static final String PasswordKey = "password"; - - public static final String UsernameKey = "username"; - - public static final int NoAccessLevel = 4; + public static final int NoAccessLevel = 4; public static final int CustomerAccessLevel = 3; @@ -46,14 +42,6 @@ public void awakeFromInsertion(EOEditingContext editingContext) { } } - public Number accessLevel() { - return (Number) (storedValueForKey(AccessLevelKey)); - } - - public void setAccessLevel(Number value) { - takeStoredValueForKey(value, AccessLevelKey); - } - private boolean _hasAccessLevel(int level) { Number accessLevel = accessLevel(); return ((accessLevel != null) && (accessLevel.intValue() <= level)); @@ -70,4 +58,24 @@ public boolean hasEmployeeAccessLevel() { public boolean hasCustomerAccessLevel() { return _hasAccessLevel(CustomerAccessLevel); } + + /* + * ERCore user interface implementation + */ + + @Override + public void newPreference(EOEnterpriseObject pref) { + addObjectToBothSidesOfRelationshipWithKey(pref, "preferences"); + } + + @Override + public void setPreferences(NSArray array) { + takeStoredValueForKey(array.mutableClone(), "preferences"); + } + + @Override + public NSArray preferences() { + return (NSArray) storedValueForKey("preferences"); + } + } diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Video.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Video.java index 1b026823cf2..49da95de993 100644 --- a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Video.java +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/Video.java @@ -13,9 +13,8 @@ package webobjectsexamples.businesslogic.rentals.common; import com.webobjects.eocontrol.EOEditingContext; -import com.webobjects.eocontrol.EOGenericRecord; -public class Video extends EOGenericRecord { +public class Video extends _Video { private static final long serialVersionUID = -729666207038859697L; public static final String MovieKey = "movie"; @@ -36,11 +35,4 @@ public void awakeFromInsertion(EOEditingContext editingContext) { } } - public RentalTerms rentalTerms() { - return (RentalTerms) (storedValueForKey(RentalTermsKey)); - } - - public void setRentalTerms(RentalTerms value) { - takeStoredValueForKey(value, RentalTermsKey); - } } diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_CreditCard.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_CreditCard.java new file mode 100644 index 00000000000..f2e7fcbeaf3 --- /dev/null +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_CreditCard.java @@ -0,0 +1,201 @@ +// DO NOT EDIT. Make changes to CreditCard.java instead. +package webobjectsexamples.businesslogic.rentals.common; + +import com.webobjects.eoaccess.*; +import com.webobjects.eocontrol.*; +import com.webobjects.foundation.*; +import java.math.*; +import java.util.*; +import org.apache.log4j.Logger; + +import er.extensions.eof.*; +import er.extensions.foundation.*; + +@SuppressWarnings("all") +public abstract class _CreditCard extends er.extensions.eof.ERXGenericRecord { + public static final String ENTITY_NAME = "CreditCard"; + + // Attribute Keys + public static final ERXKey AUTHORIZATION_DATE = new ERXKey("authorizationDate"); + public static final ERXKey AUTHORIZATION_NUM = new ERXKey("authorizationNum"); + public static final ERXKey CARD_NUMBER = new ERXKey("cardNumber"); + public static final ERXKey EXPIRATION_DATE = new ERXKey("expirationDate"); + public static final ERXKey LIMIT = new ERXKey("limit"); + // Relationship Keys + public static final ERXKey CUSTOMER = new ERXKey("customer"); + + // Attributes + public static final String AUTHORIZATION_DATE_KEY = AUTHORIZATION_DATE.key(); + public static final String AUTHORIZATION_NUM_KEY = AUTHORIZATION_NUM.key(); + public static final String CARD_NUMBER_KEY = CARD_NUMBER.key(); + public static final String EXPIRATION_DATE_KEY = EXPIRATION_DATE.key(); + public static final String LIMIT_KEY = LIMIT.key(); + // Relationships + public static final String CUSTOMER_KEY = CUSTOMER.key(); + + private static Logger LOG = Logger.getLogger(_CreditCard.class); + + public CreditCard localInstanceIn(EOEditingContext editingContext) { + CreditCard localInstance = (CreditCard)EOUtilities.localInstanceOfObject(editingContext, this); + if (localInstance == null) { + throw new IllegalStateException("You attempted to localInstance " + this + ", which has not yet committed."); + } + return localInstance; + } + + public NSTimestamp authorizationDate() { + return (NSTimestamp) storedValueForKey(_CreditCard.AUTHORIZATION_DATE_KEY); + } + + public void setAuthorizationDate(NSTimestamp value) { + if (_CreditCard.LOG.isDebugEnabled()) { + _CreditCard.LOG.debug( "updating authorizationDate from " + authorizationDate() + " to " + value); + } + takeStoredValueForKey(value, _CreditCard.AUTHORIZATION_DATE_KEY); + } + + public String authorizationNum() { + return (String) storedValueForKey(_CreditCard.AUTHORIZATION_NUM_KEY); + } + + public void setAuthorizationNum(String value) { + if (_CreditCard.LOG.isDebugEnabled()) { + _CreditCard.LOG.debug( "updating authorizationNum from " + authorizationNum() + " to " + value); + } + takeStoredValueForKey(value, _CreditCard.AUTHORIZATION_NUM_KEY); + } + + public String cardNumber() { + return (String) storedValueForKey(_CreditCard.CARD_NUMBER_KEY); + } + + public void setCardNumber(String value) { + if (_CreditCard.LOG.isDebugEnabled()) { + _CreditCard.LOG.debug( "updating cardNumber from " + cardNumber() + " to " + value); + } + takeStoredValueForKey(value, _CreditCard.CARD_NUMBER_KEY); + } + + public NSTimestamp expirationDate() { + return (NSTimestamp) storedValueForKey(_CreditCard.EXPIRATION_DATE_KEY); + } + + public void setExpirationDate(NSTimestamp value) { + if (_CreditCard.LOG.isDebugEnabled()) { + _CreditCard.LOG.debug( "updating expirationDate from " + expirationDate() + " to " + value); + } + takeStoredValueForKey(value, _CreditCard.EXPIRATION_DATE_KEY); + } + + public java.math.BigDecimal limit() { + return (java.math.BigDecimal) storedValueForKey(_CreditCard.LIMIT_KEY); + } + + public void setLimit(java.math.BigDecimal value) { + if (_CreditCard.LOG.isDebugEnabled()) { + _CreditCard.LOG.debug( "updating limit from " + limit() + " to " + value); + } + takeStoredValueForKey(value, _CreditCard.LIMIT_KEY); + } + + public webobjectsexamples.businesslogic.rentals.common.Customer customer() { + return (webobjectsexamples.businesslogic.rentals.common.Customer)storedValueForKey(_CreditCard.CUSTOMER_KEY); + } + + public void setCustomer(webobjectsexamples.businesslogic.rentals.common.Customer value) { + takeStoredValueForKey(value, _CreditCard.CUSTOMER_KEY); + } + + public void setCustomerRelationship(webobjectsexamples.businesslogic.rentals.common.Customer value) { + if (_CreditCard.LOG.isDebugEnabled()) { + _CreditCard.LOG.debug("updating customer from " + customer() + " to " + value); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + setCustomer(value); + } + else if (value == null) { + webobjectsexamples.businesslogic.rentals.common.Customer oldValue = customer(); + if (oldValue != null) { + removeObjectFromBothSidesOfRelationshipWithKey(oldValue, _CreditCard.CUSTOMER_KEY); + } + } else { + addObjectToBothSidesOfRelationshipWithKey(value, _CreditCard.CUSTOMER_KEY); + } + } + + + public static CreditCard createCreditCard(EOEditingContext editingContext, NSTimestamp authorizationDate +, String authorizationNum +, String cardNumber +, NSTimestamp expirationDate +, java.math.BigDecimal limit +, webobjectsexamples.businesslogic.rentals.common.Customer customer) { + CreditCard eo = (CreditCard) EOUtilities.createAndInsertInstance(editingContext, _CreditCard.ENTITY_NAME); + eo.setAuthorizationDate(authorizationDate); + eo.setAuthorizationNum(authorizationNum); + eo.setCardNumber(cardNumber); + eo.setExpirationDate(expirationDate); + eo.setLimit(limit); + eo.setCustomerRelationship(customer); + return eo; + } + + public static ERXFetchSpecification fetchSpec() { + return new ERXFetchSpecification(_CreditCard.ENTITY_NAME, null, null, false, true, null); + } + + public static NSArray fetchAllCreditCards(EOEditingContext editingContext) { + return _CreditCard.fetchAllCreditCards(editingContext, null); + } + + public static NSArray fetchAllCreditCards(EOEditingContext editingContext, NSArray sortOrderings) { + return _CreditCard.fetchCreditCards(editingContext, null, sortOrderings); + } + + public static NSArray fetchCreditCards(EOEditingContext editingContext, EOQualifier qualifier, NSArray sortOrderings) { + ERXFetchSpecification fetchSpec = new ERXFetchSpecification(_CreditCard.ENTITY_NAME, qualifier, sortOrderings); + fetchSpec.setIsDeep(true); + NSArray eoObjects = fetchSpec.fetchObjects(editingContext); + return eoObjects; + } + + public static CreditCard fetchCreditCard(EOEditingContext editingContext, String keyName, Object value) { + return _CreditCard.fetchCreditCard(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static CreditCard fetchCreditCard(EOEditingContext editingContext, EOQualifier qualifier) { + NSArray eoObjects = _CreditCard.fetchCreditCards(editingContext, qualifier, null); + CreditCard eoObject; + int count = eoObjects.count(); + if (count == 0) { + eoObject = null; + } + else if (count == 1) { + eoObject = eoObjects.objectAtIndex(0); + } + else { + throw new IllegalStateException("There was more than one CreditCard that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static CreditCard fetchRequiredCreditCard(EOEditingContext editingContext, String keyName, Object value) { + return _CreditCard.fetchRequiredCreditCard(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static CreditCard fetchRequiredCreditCard(EOEditingContext editingContext, EOQualifier qualifier) { + CreditCard eoObject = _CreditCard.fetchCreditCard(editingContext, qualifier); + if (eoObject == null) { + throw new NoSuchElementException("There was no CreditCard that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static CreditCard localInstanceIn(EOEditingContext editingContext, CreditCard eo) { + CreditCard localInstance = (eo == null) ? null : ERXEOControlUtilities.localInstanceOfObject(editingContext, eo); + if (localInstance == null && eo != null) { + throw new IllegalStateException("You attempted to localInstance " + eo + ", which has not yet committed."); + } + return localInstance; + } +} diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Customer.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Customer.java new file mode 100644 index 00000000000..ea37114e744 --- /dev/null +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Customer.java @@ -0,0 +1,330 @@ +// DO NOT EDIT. Make changes to Customer.java instead. +package webobjectsexamples.businesslogic.rentals.common; + +import com.webobjects.eoaccess.*; +import com.webobjects.eocontrol.*; +import com.webobjects.foundation.*; +import java.math.*; +import java.util.*; +import org.apache.log4j.Logger; + +import er.extensions.eof.*; +import er.extensions.foundation.*; + +@SuppressWarnings("all") +public abstract class _Customer extends er.extensions.eof.ERXGenericRecord { + public static final String ENTITY_NAME = "Customer"; + + // Attribute Keys + public static final ERXKey CITY = new ERXKey("city"); + public static final ERXKey FIRST_NAME = new ERXKey("firstName"); + public static final ERXKey LAST_NAME = new ERXKey("lastName"); + public static final ERXKey MEMBER_SINCE = new ERXKey("memberSince"); + public static final ERXKey PHONE = new ERXKey("phone"); + public static final ERXKey STATE = new ERXKey("state"); + public static final ERXKey STREET_ADDRESS = new ERXKey("streetAddress"); + public static final ERXKey ZIP = new ERXKey("zip"); + // Relationship Keys + public static final ERXKey CREDIT_CARD = new ERXKey("creditCard"); + public static final ERXKey RENTALS = new ERXKey("rentals"); + + // Attributes + public static final String CITY_KEY = CITY.key(); + public static final String FIRST_NAME_KEY = FIRST_NAME.key(); + public static final String LAST_NAME_KEY = LAST_NAME.key(); + public static final String MEMBER_SINCE_KEY = MEMBER_SINCE.key(); + public static final String PHONE_KEY = PHONE.key(); + public static final String STATE_KEY = STATE.key(); + public static final String STREET_ADDRESS_KEY = STREET_ADDRESS.key(); + public static final String ZIP_KEY = ZIP.key(); + // Relationships + public static final String CREDIT_CARD_KEY = CREDIT_CARD.key(); + public static final String RENTALS_KEY = RENTALS.key(); + + private static Logger LOG = Logger.getLogger(_Customer.class); + + public Customer localInstanceIn(EOEditingContext editingContext) { + Customer localInstance = (Customer)EOUtilities.localInstanceOfObject(editingContext, this); + if (localInstance == null) { + throw new IllegalStateException("You attempted to localInstance " + this + ", which has not yet committed."); + } + return localInstance; + } + + public String city() { + return (String) storedValueForKey(_Customer.CITY_KEY); + } + + public void setCity(String value) { + if (_Customer.LOG.isDebugEnabled()) { + _Customer.LOG.debug( "updating city from " + city() + " to " + value); + } + takeStoredValueForKey(value, _Customer.CITY_KEY); + } + + public String firstName() { + return (String) storedValueForKey(_Customer.FIRST_NAME_KEY); + } + + public void setFirstName(String value) { + if (_Customer.LOG.isDebugEnabled()) { + _Customer.LOG.debug( "updating firstName from " + firstName() + " to " + value); + } + takeStoredValueForKey(value, _Customer.FIRST_NAME_KEY); + } + + public String lastName() { + return (String) storedValueForKey(_Customer.LAST_NAME_KEY); + } + + public void setLastName(String value) { + if (_Customer.LOG.isDebugEnabled()) { + _Customer.LOG.debug( "updating lastName from " + lastName() + " to " + value); + } + takeStoredValueForKey(value, _Customer.LAST_NAME_KEY); + } + + public NSTimestamp memberSince() { + return (NSTimestamp) storedValueForKey(_Customer.MEMBER_SINCE_KEY); + } + + public void setMemberSince(NSTimestamp value) { + if (_Customer.LOG.isDebugEnabled()) { + _Customer.LOG.debug( "updating memberSince from " + memberSince() + " to " + value); + } + takeStoredValueForKey(value, _Customer.MEMBER_SINCE_KEY); + } + + public String phone() { + return (String) storedValueForKey(_Customer.PHONE_KEY); + } + + public void setPhone(String value) { + if (_Customer.LOG.isDebugEnabled()) { + _Customer.LOG.debug( "updating phone from " + phone() + " to " + value); + } + takeStoredValueForKey(value, _Customer.PHONE_KEY); + } + + public String state() { + return (String) storedValueForKey(_Customer.STATE_KEY); + } + + public void setState(String value) { + if (_Customer.LOG.isDebugEnabled()) { + _Customer.LOG.debug( "updating state from " + state() + " to " + value); + } + takeStoredValueForKey(value, _Customer.STATE_KEY); + } + + public String streetAddress() { + return (String) storedValueForKey(_Customer.STREET_ADDRESS_KEY); + } + + public void setStreetAddress(String value) { + if (_Customer.LOG.isDebugEnabled()) { + _Customer.LOG.debug( "updating streetAddress from " + streetAddress() + " to " + value); + } + takeStoredValueForKey(value, _Customer.STREET_ADDRESS_KEY); + } + + public String zip() { + return (String) storedValueForKey(_Customer.ZIP_KEY); + } + + public void setZip(String value) { + if (_Customer.LOG.isDebugEnabled()) { + _Customer.LOG.debug( "updating zip from " + zip() + " to " + value); + } + takeStoredValueForKey(value, _Customer.ZIP_KEY); + } + + public webobjectsexamples.businesslogic.rentals.common.CreditCard creditCard() { + return (webobjectsexamples.businesslogic.rentals.common.CreditCard)storedValueForKey(_Customer.CREDIT_CARD_KEY); + } + + public void setCreditCard(webobjectsexamples.businesslogic.rentals.common.CreditCard value) { + takeStoredValueForKey(value, _Customer.CREDIT_CARD_KEY); + } + + public void setCreditCardRelationship(webobjectsexamples.businesslogic.rentals.common.CreditCard value) { + if (_Customer.LOG.isDebugEnabled()) { + _Customer.LOG.debug("updating creditCard from " + creditCard() + " to " + value); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + setCreditCard(value); + } + else if (value == null) { + webobjectsexamples.businesslogic.rentals.common.CreditCard oldValue = creditCard(); + if (oldValue != null) { + removeObjectFromBothSidesOfRelationshipWithKey(oldValue, _Customer.CREDIT_CARD_KEY); + } + } else { + addObjectToBothSidesOfRelationshipWithKey(value, _Customer.CREDIT_CARD_KEY); + } + } + + public NSArray rentals() { + return (NSArray)storedValueForKey(_Customer.RENTALS_KEY); + } + + public NSArray rentals(EOQualifier qualifier) { + return rentals(qualifier, null, false); + } + + public NSArray rentals(EOQualifier qualifier, boolean fetch) { + return rentals(qualifier, null, fetch); + } + + public NSArray rentals(EOQualifier qualifier, NSArray sortOrderings, boolean fetch) { + NSArray results; + if (fetch) { + EOQualifier fullQualifier; + EOQualifier inverseQualifier = new EOKeyValueQualifier(webobjectsexamples.businesslogic.rentals.common.Rental.CUSTOMER_KEY, EOQualifier.QualifierOperatorEqual, this); + + if (qualifier == null) { + fullQualifier = inverseQualifier; + } + else { + NSMutableArray qualifiers = new NSMutableArray(); + qualifiers.addObject(qualifier); + qualifiers.addObject(inverseQualifier); + fullQualifier = new EOAndQualifier(qualifiers); + } + + results = webobjectsexamples.businesslogic.rentals.common.Rental.fetchRentals(editingContext(), fullQualifier, sortOrderings); + } + else { + results = rentals(); + if (qualifier != null) { + results = (NSArray)EOQualifier.filteredArrayWithQualifier(results, qualifier); + } + if (sortOrderings != null) { + results = (NSArray)EOSortOrdering.sortedArrayUsingKeyOrderArray(results, sortOrderings); + } + } + return results; + } + + public void addToRentals(webobjectsexamples.businesslogic.rentals.common.Rental object) { + includeObjectIntoPropertyWithKey(object, _Customer.RENTALS_KEY); + } + + public void removeFromRentals(webobjectsexamples.businesslogic.rentals.common.Rental object) { + excludeObjectFromPropertyWithKey(object, _Customer.RENTALS_KEY); + } + + public void addToRentalsRelationship(webobjectsexamples.businesslogic.rentals.common.Rental object) { + if (_Customer.LOG.isDebugEnabled()) { + _Customer.LOG.debug("adding " + object + " to rentals relationship"); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + addToRentals(object); + } + else { + addObjectToBothSidesOfRelationshipWithKey(object, _Customer.RENTALS_KEY); + } + } + + public void removeFromRentalsRelationship(webobjectsexamples.businesslogic.rentals.common.Rental object) { + if (_Customer.LOG.isDebugEnabled()) { + _Customer.LOG.debug("removing " + object + " from rentals relationship"); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + removeFromRentals(object); + } + else { + removeObjectFromBothSidesOfRelationshipWithKey(object, _Customer.RENTALS_KEY); + } + } + + public webobjectsexamples.businesslogic.rentals.common.Rental createRentalsRelationship() { + EOClassDescription eoClassDesc = EOClassDescription.classDescriptionForEntityName( webobjectsexamples.businesslogic.rentals.common.Rental.ENTITY_NAME ); + EOEnterpriseObject eo = eoClassDesc.createInstanceWithEditingContext(editingContext(), null); + editingContext().insertObject(eo); + addObjectToBothSidesOfRelationshipWithKey(eo, _Customer.RENTALS_KEY); + return (webobjectsexamples.businesslogic.rentals.common.Rental) eo; + } + + public void deleteRentalsRelationship(webobjectsexamples.businesslogic.rentals.common.Rental object) { + removeObjectFromBothSidesOfRelationshipWithKey(object, _Customer.RENTALS_KEY); + } + + public void deleteAllRentalsRelationships() { + Enumeration objects = rentals().immutableClone().objectEnumerator(); + while (objects.hasMoreElements()) { + deleteRentalsRelationship(objects.nextElement()); + } + } + + + public static Customer createCustomer(EOEditingContext editingContext, String city +, String firstName +, String lastName +) { + Customer eo = (Customer) EOUtilities.createAndInsertInstance(editingContext, _Customer.ENTITY_NAME); + eo.setCity(city); + eo.setFirstName(firstName); + eo.setLastName(lastName); + return eo; + } + + public static ERXFetchSpecification fetchSpec() { + return new ERXFetchSpecification(_Customer.ENTITY_NAME, null, null, false, true, null); + } + + public static NSArray fetchAllCustomers(EOEditingContext editingContext) { + return _Customer.fetchAllCustomers(editingContext, null); + } + + public static NSArray fetchAllCustomers(EOEditingContext editingContext, NSArray sortOrderings) { + return _Customer.fetchCustomers(editingContext, null, sortOrderings); + } + + public static NSArray fetchCustomers(EOEditingContext editingContext, EOQualifier qualifier, NSArray sortOrderings) { + ERXFetchSpecification fetchSpec = new ERXFetchSpecification(_Customer.ENTITY_NAME, qualifier, sortOrderings); + fetchSpec.setIsDeep(true); + NSArray eoObjects = fetchSpec.fetchObjects(editingContext); + return eoObjects; + } + + public static Customer fetchCustomer(EOEditingContext editingContext, String keyName, Object value) { + return _Customer.fetchCustomer(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static Customer fetchCustomer(EOEditingContext editingContext, EOQualifier qualifier) { + NSArray eoObjects = _Customer.fetchCustomers(editingContext, qualifier, null); + Customer eoObject; + int count = eoObjects.count(); + if (count == 0) { + eoObject = null; + } + else if (count == 1) { + eoObject = eoObjects.objectAtIndex(0); + } + else { + throw new IllegalStateException("There was more than one Customer that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static Customer fetchRequiredCustomer(EOEditingContext editingContext, String keyName, Object value) { + return _Customer.fetchRequiredCustomer(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static Customer fetchRequiredCustomer(EOEditingContext editingContext, EOQualifier qualifier) { + Customer eoObject = _Customer.fetchCustomer(editingContext, qualifier); + if (eoObject == null) { + throw new NoSuchElementException("There was no Customer that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static Customer localInstanceIn(EOEditingContext editingContext, Customer eo) { + Customer localInstance = (eo == null) ? null : ERXEOControlUtilities.localInstanceOfObject(editingContext, eo); + if (localInstance == null && eo != null) { + throw new IllegalStateException("You attempted to localInstance " + eo + ", which has not yet committed."); + } + return localInstance; + } +} diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Fee.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Fee.java new file mode 100644 index 00000000000..fd5c0189281 --- /dev/null +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Fee.java @@ -0,0 +1,182 @@ +// DO NOT EDIT. Make changes to Fee.java instead. +package webobjectsexamples.businesslogic.rentals.common; + +import com.webobjects.eoaccess.*; +import com.webobjects.eocontrol.*; +import com.webobjects.foundation.*; +import java.math.*; +import java.util.*; +import org.apache.log4j.Logger; + +import er.extensions.eof.*; +import er.extensions.foundation.*; + +@SuppressWarnings("all") +public abstract class _Fee extends er.extensions.eof.ERXGenericRecord { + public static final String ENTITY_NAME = "Fee"; + + // Attribute Keys + public static final ERXKey AMOUNT = new ERXKey("amount"); + public static final ERXKey DATE_PAID = new ERXKey("datePaid"); + // Relationship Keys + public static final ERXKey FEE_TYPE = new ERXKey("feeType"); + public static final ERXKey RENTAL = new ERXKey("rental"); + + // Attributes + public static final String AMOUNT_KEY = AMOUNT.key(); + public static final String DATE_PAID_KEY = DATE_PAID.key(); + // Relationships + public static final String FEE_TYPE_KEY = FEE_TYPE.key(); + public static final String RENTAL_KEY = RENTAL.key(); + + private static Logger LOG = Logger.getLogger(_Fee.class); + + public Fee localInstanceIn(EOEditingContext editingContext) { + Fee localInstance = (Fee)EOUtilities.localInstanceOfObject(editingContext, this); + if (localInstance == null) { + throw new IllegalStateException("You attempted to localInstance " + this + ", which has not yet committed."); + } + return localInstance; + } + + public java.math.BigDecimal amount() { + return (java.math.BigDecimal) storedValueForKey(_Fee.AMOUNT_KEY); + } + + public void setAmount(java.math.BigDecimal value) { + if (_Fee.LOG.isDebugEnabled()) { + _Fee.LOG.debug( "updating amount from " + amount() + " to " + value); + } + takeStoredValueForKey(value, _Fee.AMOUNT_KEY); + } + + public NSTimestamp datePaid() { + return (NSTimestamp) storedValueForKey(_Fee.DATE_PAID_KEY); + } + + public void setDatePaid(NSTimestamp value) { + if (_Fee.LOG.isDebugEnabled()) { + _Fee.LOG.debug( "updating datePaid from " + datePaid() + " to " + value); + } + takeStoredValueForKey(value, _Fee.DATE_PAID_KEY); + } + + public webobjectsexamples.businesslogic.rentals.common.FeeType feeType() { + return (webobjectsexamples.businesslogic.rentals.common.FeeType)storedValueForKey(_Fee.FEE_TYPE_KEY); + } + + public void setFeeType(webobjectsexamples.businesslogic.rentals.common.FeeType value) { + takeStoredValueForKey(value, _Fee.FEE_TYPE_KEY); + } + + public void setFeeTypeRelationship(webobjectsexamples.businesslogic.rentals.common.FeeType value) { + if (_Fee.LOG.isDebugEnabled()) { + _Fee.LOG.debug("updating feeType from " + feeType() + " to " + value); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + setFeeType(value); + } + else if (value == null) { + webobjectsexamples.businesslogic.rentals.common.FeeType oldValue = feeType(); + if (oldValue != null) { + removeObjectFromBothSidesOfRelationshipWithKey(oldValue, _Fee.FEE_TYPE_KEY); + } + } else { + addObjectToBothSidesOfRelationshipWithKey(value, _Fee.FEE_TYPE_KEY); + } + } + + public webobjectsexamples.businesslogic.rentals.common.Rental rental() { + return (webobjectsexamples.businesslogic.rentals.common.Rental)storedValueForKey(_Fee.RENTAL_KEY); + } + + public void setRental(webobjectsexamples.businesslogic.rentals.common.Rental value) { + takeStoredValueForKey(value, _Fee.RENTAL_KEY); + } + + public void setRentalRelationship(webobjectsexamples.businesslogic.rentals.common.Rental value) { + if (_Fee.LOG.isDebugEnabled()) { + _Fee.LOG.debug("updating rental from " + rental() + " to " + value); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + setRental(value); + } + else if (value == null) { + webobjectsexamples.businesslogic.rentals.common.Rental oldValue = rental(); + if (oldValue != null) { + removeObjectFromBothSidesOfRelationshipWithKey(oldValue, _Fee.RENTAL_KEY); + } + } else { + addObjectToBothSidesOfRelationshipWithKey(value, _Fee.RENTAL_KEY); + } + } + + + public static Fee createFee(EOEditingContext editingContext, java.math.BigDecimal amount +, webobjectsexamples.businesslogic.rentals.common.FeeType feeType, webobjectsexamples.businesslogic.rentals.common.Rental rental) { + Fee eo = (Fee) EOUtilities.createAndInsertInstance(editingContext, _Fee.ENTITY_NAME); + eo.setAmount(amount); + eo.setFeeTypeRelationship(feeType); + eo.setRentalRelationship(rental); + return eo; + } + + public static ERXFetchSpecification fetchSpec() { + return new ERXFetchSpecification(_Fee.ENTITY_NAME, null, null, false, true, null); + } + + public static NSArray fetchAllFees(EOEditingContext editingContext) { + return _Fee.fetchAllFees(editingContext, null); + } + + public static NSArray fetchAllFees(EOEditingContext editingContext, NSArray sortOrderings) { + return _Fee.fetchFees(editingContext, null, sortOrderings); + } + + public static NSArray fetchFees(EOEditingContext editingContext, EOQualifier qualifier, NSArray sortOrderings) { + ERXFetchSpecification fetchSpec = new ERXFetchSpecification(_Fee.ENTITY_NAME, qualifier, sortOrderings); + fetchSpec.setIsDeep(true); + NSArray eoObjects = fetchSpec.fetchObjects(editingContext); + return eoObjects; + } + + public static Fee fetchFee(EOEditingContext editingContext, String keyName, Object value) { + return _Fee.fetchFee(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static Fee fetchFee(EOEditingContext editingContext, EOQualifier qualifier) { + NSArray eoObjects = _Fee.fetchFees(editingContext, qualifier, null); + Fee eoObject; + int count = eoObjects.count(); + if (count == 0) { + eoObject = null; + } + else if (count == 1) { + eoObject = eoObjects.objectAtIndex(0); + } + else { + throw new IllegalStateException("There was more than one Fee that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static Fee fetchRequiredFee(EOEditingContext editingContext, String keyName, Object value) { + return _Fee.fetchRequiredFee(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static Fee fetchRequiredFee(EOEditingContext editingContext, EOQualifier qualifier) { + Fee eoObject = _Fee.fetchFee(editingContext, qualifier); + if (eoObject == null) { + throw new NoSuchElementException("There was no Fee that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static Fee localInstanceIn(EOEditingContext editingContext, Fee eo) { + Fee localInstance = (eo == null) ? null : ERXEOControlUtilities.localInstanceOfObject(editingContext, eo); + if (localInstance == null && eo != null) { + throw new IllegalStateException("You attempted to localInstance " + eo + ", which has not yet committed."); + } + return localInstance; + } +} diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_FeeType.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_FeeType.java new file mode 100644 index 00000000000..1244ede51de --- /dev/null +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_FeeType.java @@ -0,0 +1,143 @@ +// DO NOT EDIT. Make changes to FeeType.java instead. +package webobjectsexamples.businesslogic.rentals.common; + +import com.webobjects.eoaccess.*; +import com.webobjects.eocontrol.*; +import com.webobjects.foundation.*; +import java.math.*; +import java.util.*; +import org.apache.log4j.Logger; + +import er.extensions.eof.*; +import er.extensions.foundation.*; + +@SuppressWarnings("all") +public abstract class _FeeType extends er.extensions.eof.ERXGenericRecord { + public static final String ENTITY_NAME = "FeeType"; + + // Attribute Keys + public static final ERXKey ENABLED = new ERXKey("enabled"); + public static final ERXKey FEE_TYPE = new ERXKey("feeType"); + public static final ERXKey ORDER_BY = new ERXKey("orderBy"); + // Relationship Keys + + // Attributes + public static final String ENABLED_KEY = ENABLED.key(); + public static final String FEE_TYPE_KEY = FEE_TYPE.key(); + public static final String ORDER_BY_KEY = ORDER_BY.key(); + // Relationships + + private static Logger LOG = Logger.getLogger(_FeeType.class); + + public FeeType localInstanceIn(EOEditingContext editingContext) { + FeeType localInstance = (FeeType)EOUtilities.localInstanceOfObject(editingContext, this); + if (localInstance == null) { + throw new IllegalStateException("You attempted to localInstance " + this + ", which has not yet committed."); + } + return localInstance; + } + + public Integer enabled() { + return (Integer) storedValueForKey(_FeeType.ENABLED_KEY); + } + + public void setEnabled(Integer value) { + if (_FeeType.LOG.isDebugEnabled()) { + _FeeType.LOG.debug( "updating enabled from " + enabled() + " to " + value); + } + takeStoredValueForKey(value, _FeeType.ENABLED_KEY); + } + + public String feeType() { + return (String) storedValueForKey(_FeeType.FEE_TYPE_KEY); + } + + public void setFeeType(String value) { + if (_FeeType.LOG.isDebugEnabled()) { + _FeeType.LOG.debug( "updating feeType from " + feeType() + " to " + value); + } + takeStoredValueForKey(value, _FeeType.FEE_TYPE_KEY); + } + + public Integer orderBy() { + return (Integer) storedValueForKey(_FeeType.ORDER_BY_KEY); + } + + public void setOrderBy(Integer value) { + if (_FeeType.LOG.isDebugEnabled()) { + _FeeType.LOG.debug( "updating orderBy from " + orderBy() + " to " + value); + } + takeStoredValueForKey(value, _FeeType.ORDER_BY_KEY); + } + + + public static FeeType createFeeType(EOEditingContext editingContext, Integer enabled +, String feeType +, Integer orderBy +) { + FeeType eo = (FeeType) EOUtilities.createAndInsertInstance(editingContext, _FeeType.ENTITY_NAME); + eo.setEnabled(enabled); + eo.setFeeType(feeType); + eo.setOrderBy(orderBy); + return eo; + } + + public static ERXFetchSpecification fetchSpec() { + return new ERXFetchSpecification(_FeeType.ENTITY_NAME, null, null, false, true, null); + } + + public static NSArray fetchAllFeeTypes(EOEditingContext editingContext) { + return _FeeType.fetchAllFeeTypes(editingContext, null); + } + + public static NSArray fetchAllFeeTypes(EOEditingContext editingContext, NSArray sortOrderings) { + return _FeeType.fetchFeeTypes(editingContext, null, sortOrderings); + } + + public static NSArray fetchFeeTypes(EOEditingContext editingContext, EOQualifier qualifier, NSArray sortOrderings) { + ERXFetchSpecification fetchSpec = new ERXFetchSpecification(_FeeType.ENTITY_NAME, qualifier, sortOrderings); + fetchSpec.setIsDeep(true); + NSArray eoObjects = fetchSpec.fetchObjects(editingContext); + return eoObjects; + } + + public static FeeType fetchFeeType(EOEditingContext editingContext, String keyName, Object value) { + return _FeeType.fetchFeeType(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static FeeType fetchFeeType(EOEditingContext editingContext, EOQualifier qualifier) { + NSArray eoObjects = _FeeType.fetchFeeTypes(editingContext, qualifier, null); + FeeType eoObject; + int count = eoObjects.count(); + if (count == 0) { + eoObject = null; + } + else if (count == 1) { + eoObject = eoObjects.objectAtIndex(0); + } + else { + throw new IllegalStateException("There was more than one FeeType that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static FeeType fetchRequiredFeeType(EOEditingContext editingContext, String keyName, Object value) { + return _FeeType.fetchRequiredFeeType(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static FeeType fetchRequiredFeeType(EOEditingContext editingContext, EOQualifier qualifier) { + FeeType eoObject = _FeeType.fetchFeeType(editingContext, qualifier); + if (eoObject == null) { + throw new NoSuchElementException("There was no FeeType that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static FeeType localInstanceIn(EOEditingContext editingContext, FeeType eo) { + FeeType localInstance = (eo == null) ? null : ERXEOControlUtilities.localInstanceOfObject(editingContext, eo); + if (localInstance == null && eo != null) { + throw new IllegalStateException("You attempted to localInstance " + eo + ", which has not yet committed."); + } + return localInstance; + } +} diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Rental.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Rental.java new file mode 100644 index 00000000000..3ba7076e463 --- /dev/null +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Rental.java @@ -0,0 +1,277 @@ +// DO NOT EDIT. Make changes to Rental.java instead. +package webobjectsexamples.businesslogic.rentals.common; + +import com.webobjects.eoaccess.*; +import com.webobjects.eocontrol.*; +import com.webobjects.foundation.*; +import java.math.*; +import java.util.*; +import org.apache.log4j.Logger; + +import er.extensions.eof.*; +import er.extensions.foundation.*; + +@SuppressWarnings("all") +public abstract class _Rental extends er.extensions.eof.ERXGenericRecord { + public static final String ENTITY_NAME = "Rental"; + + // Attribute Keys + public static final ERXKey DATE_OUT = new ERXKey("dateOut"); + public static final ERXKey DATE_RETURNED = new ERXKey("dateReturned"); + // Relationship Keys + public static final ERXKey CUSTOMER = new ERXKey("customer"); + public static final ERXKey FEES = new ERXKey("fees"); + public static final ERXKey UNIT = new ERXKey("unit"); + + // Attributes + public static final String DATE_OUT_KEY = DATE_OUT.key(); + public static final String DATE_RETURNED_KEY = DATE_RETURNED.key(); + // Relationships + public static final String CUSTOMER_KEY = CUSTOMER.key(); + public static final String FEES_KEY = FEES.key(); + public static final String UNIT_KEY = UNIT.key(); + + private static Logger LOG = Logger.getLogger(_Rental.class); + + public Rental localInstanceIn(EOEditingContext editingContext) { + Rental localInstance = (Rental)EOUtilities.localInstanceOfObject(editingContext, this); + if (localInstance == null) { + throw new IllegalStateException("You attempted to localInstance " + this + ", which has not yet committed."); + } + return localInstance; + } + + public NSTimestamp dateOut() { + return (NSTimestamp) storedValueForKey(_Rental.DATE_OUT_KEY); + } + + public void setDateOut(NSTimestamp value) { + if (_Rental.LOG.isDebugEnabled()) { + _Rental.LOG.debug( "updating dateOut from " + dateOut() + " to " + value); + } + takeStoredValueForKey(value, _Rental.DATE_OUT_KEY); + } + + public NSTimestamp dateReturned() { + return (NSTimestamp) storedValueForKey(_Rental.DATE_RETURNED_KEY); + } + + public void setDateReturned(NSTimestamp value) { + if (_Rental.LOG.isDebugEnabled()) { + _Rental.LOG.debug( "updating dateReturned from " + dateReturned() + " to " + value); + } + takeStoredValueForKey(value, _Rental.DATE_RETURNED_KEY); + } + + public webobjectsexamples.businesslogic.rentals.common.Customer customer() { + return (webobjectsexamples.businesslogic.rentals.common.Customer)storedValueForKey(_Rental.CUSTOMER_KEY); + } + + public void setCustomer(webobjectsexamples.businesslogic.rentals.common.Customer value) { + takeStoredValueForKey(value, _Rental.CUSTOMER_KEY); + } + + public void setCustomerRelationship(webobjectsexamples.businesslogic.rentals.common.Customer value) { + if (_Rental.LOG.isDebugEnabled()) { + _Rental.LOG.debug("updating customer from " + customer() + " to " + value); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + setCustomer(value); + } + else if (value == null) { + webobjectsexamples.businesslogic.rentals.common.Customer oldValue = customer(); + if (oldValue != null) { + removeObjectFromBothSidesOfRelationshipWithKey(oldValue, _Rental.CUSTOMER_KEY); + } + } else { + addObjectToBothSidesOfRelationshipWithKey(value, _Rental.CUSTOMER_KEY); + } + } + + public webobjectsexamples.businesslogic.rentals.common.Unit unit() { + return (webobjectsexamples.businesslogic.rentals.common.Unit)storedValueForKey(_Rental.UNIT_KEY); + } + + public void setUnit(webobjectsexamples.businesslogic.rentals.common.Unit value) { + takeStoredValueForKey(value, _Rental.UNIT_KEY); + } + + public void setUnitRelationship(webobjectsexamples.businesslogic.rentals.common.Unit value) { + if (_Rental.LOG.isDebugEnabled()) { + _Rental.LOG.debug("updating unit from " + unit() + " to " + value); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + setUnit(value); + } + else if (value == null) { + webobjectsexamples.businesslogic.rentals.common.Unit oldValue = unit(); + if (oldValue != null) { + removeObjectFromBothSidesOfRelationshipWithKey(oldValue, _Rental.UNIT_KEY); + } + } else { + addObjectToBothSidesOfRelationshipWithKey(value, _Rental.UNIT_KEY); + } + } + + public NSArray fees() { + return (NSArray)storedValueForKey(_Rental.FEES_KEY); + } + + public NSArray fees(EOQualifier qualifier) { + return fees(qualifier, null, false); + } + + public NSArray fees(EOQualifier qualifier, boolean fetch) { + return fees(qualifier, null, fetch); + } + + public NSArray fees(EOQualifier qualifier, NSArray sortOrderings, boolean fetch) { + NSArray results; + if (fetch) { + EOQualifier fullQualifier; + EOQualifier inverseQualifier = new EOKeyValueQualifier(webobjectsexamples.businesslogic.rentals.common.Fee.RENTAL_KEY, EOQualifier.QualifierOperatorEqual, this); + + if (qualifier == null) { + fullQualifier = inverseQualifier; + } + else { + NSMutableArray qualifiers = new NSMutableArray(); + qualifiers.addObject(qualifier); + qualifiers.addObject(inverseQualifier); + fullQualifier = new EOAndQualifier(qualifiers); + } + + results = webobjectsexamples.businesslogic.rentals.common.Fee.fetchFees(editingContext(), fullQualifier, sortOrderings); + } + else { + results = fees(); + if (qualifier != null) { + results = (NSArray)EOQualifier.filteredArrayWithQualifier(results, qualifier); + } + if (sortOrderings != null) { + results = (NSArray)EOSortOrdering.sortedArrayUsingKeyOrderArray(results, sortOrderings); + } + } + return results; + } + + public void addToFees(webobjectsexamples.businesslogic.rentals.common.Fee object) { + includeObjectIntoPropertyWithKey(object, _Rental.FEES_KEY); + } + + public void removeFromFees(webobjectsexamples.businesslogic.rentals.common.Fee object) { + excludeObjectFromPropertyWithKey(object, _Rental.FEES_KEY); + } + + public void addToFeesRelationship(webobjectsexamples.businesslogic.rentals.common.Fee object) { + if (_Rental.LOG.isDebugEnabled()) { + _Rental.LOG.debug("adding " + object + " to fees relationship"); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + addToFees(object); + } + else { + addObjectToBothSidesOfRelationshipWithKey(object, _Rental.FEES_KEY); + } + } + + public void removeFromFeesRelationship(webobjectsexamples.businesslogic.rentals.common.Fee object) { + if (_Rental.LOG.isDebugEnabled()) { + _Rental.LOG.debug("removing " + object + " from fees relationship"); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + removeFromFees(object); + } + else { + removeObjectFromBothSidesOfRelationshipWithKey(object, _Rental.FEES_KEY); + } + } + + public webobjectsexamples.businesslogic.rentals.common.Fee createFeesRelationship() { + EOClassDescription eoClassDesc = EOClassDescription.classDescriptionForEntityName( webobjectsexamples.businesslogic.rentals.common.Fee.ENTITY_NAME ); + EOEnterpriseObject eo = eoClassDesc.createInstanceWithEditingContext(editingContext(), null); + editingContext().insertObject(eo); + addObjectToBothSidesOfRelationshipWithKey(eo, _Rental.FEES_KEY); + return (webobjectsexamples.businesslogic.rentals.common.Fee) eo; + } + + public void deleteFeesRelationship(webobjectsexamples.businesslogic.rentals.common.Fee object) { + removeObjectFromBothSidesOfRelationshipWithKey(object, _Rental.FEES_KEY); + } + + public void deleteAllFeesRelationships() { + Enumeration objects = fees().immutableClone().objectEnumerator(); + while (objects.hasMoreElements()) { + deleteFeesRelationship(objects.nextElement()); + } + } + + + public static Rental createRental(EOEditingContext editingContext, NSTimestamp dateOut +, webobjectsexamples.businesslogic.rentals.common.Customer customer, webobjectsexamples.businesslogic.rentals.common.Unit unit) { + Rental eo = (Rental) EOUtilities.createAndInsertInstance(editingContext, _Rental.ENTITY_NAME); + eo.setDateOut(dateOut); + eo.setCustomerRelationship(customer); + eo.setUnitRelationship(unit); + return eo; + } + + public static ERXFetchSpecification fetchSpec() { + return new ERXFetchSpecification(_Rental.ENTITY_NAME, null, null, false, true, null); + } + + public static NSArray fetchAllRentals(EOEditingContext editingContext) { + return _Rental.fetchAllRentals(editingContext, null); + } + + public static NSArray fetchAllRentals(EOEditingContext editingContext, NSArray sortOrderings) { + return _Rental.fetchRentals(editingContext, null, sortOrderings); + } + + public static NSArray fetchRentals(EOEditingContext editingContext, EOQualifier qualifier, NSArray sortOrderings) { + ERXFetchSpecification fetchSpec = new ERXFetchSpecification(_Rental.ENTITY_NAME, qualifier, sortOrderings); + fetchSpec.setIsDeep(true); + NSArray eoObjects = fetchSpec.fetchObjects(editingContext); + return eoObjects; + } + + public static Rental fetchRental(EOEditingContext editingContext, String keyName, Object value) { + return _Rental.fetchRental(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static Rental fetchRental(EOEditingContext editingContext, EOQualifier qualifier) { + NSArray eoObjects = _Rental.fetchRentals(editingContext, qualifier, null); + Rental eoObject; + int count = eoObjects.count(); + if (count == 0) { + eoObject = null; + } + else if (count == 1) { + eoObject = eoObjects.objectAtIndex(0); + } + else { + throw new IllegalStateException("There was more than one Rental that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static Rental fetchRequiredRental(EOEditingContext editingContext, String keyName, Object value) { + return _Rental.fetchRequiredRental(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static Rental fetchRequiredRental(EOEditingContext editingContext, EOQualifier qualifier) { + Rental eoObject = _Rental.fetchRental(editingContext, qualifier); + if (eoObject == null) { + throw new NoSuchElementException("There was no Rental that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static Rental localInstanceIn(EOEditingContext editingContext, Rental eo) { + Rental localInstance = (eo == null) ? null : ERXEOControlUtilities.localInstanceOfObject(editingContext, eo); + if (localInstance == null && eo != null) { + throw new IllegalStateException("You attempted to localInstance " + eo + ", which has not yet committed."); + } + return localInstance; + } +} diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_RentalTerms.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_RentalTerms.java new file mode 100644 index 00000000000..78e66bb781a --- /dev/null +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_RentalTerms.java @@ -0,0 +1,158 @@ +// DO NOT EDIT. Make changes to RentalTerms.java instead. +package webobjectsexamples.businesslogic.rentals.common; + +import com.webobjects.eoaccess.*; +import com.webobjects.eocontrol.*; +import com.webobjects.foundation.*; +import java.math.*; +import java.util.*; +import org.apache.log4j.Logger; + +import er.extensions.eof.*; +import er.extensions.foundation.*; + +@SuppressWarnings("all") +public abstract class _RentalTerms extends er.extensions.eof.ERXGenericRecord { + public static final String ENTITY_NAME = "RentalTerms"; + + // Attribute Keys + public static final ERXKey CHECK_OUT_LENGTH = new ERXKey("checkOutLength"); + public static final ERXKey COST = new ERXKey("cost"); + public static final ERXKey DEPOSIT_AMOUNT = new ERXKey("depositAmount"); + public static final ERXKey NAME = new ERXKey("name"); + // Relationship Keys + + // Attributes + public static final String CHECK_OUT_LENGTH_KEY = CHECK_OUT_LENGTH.key(); + public static final String COST_KEY = COST.key(); + public static final String DEPOSIT_AMOUNT_KEY = DEPOSIT_AMOUNT.key(); + public static final String NAME_KEY = NAME.key(); + // Relationships + + private static Logger LOG = Logger.getLogger(_RentalTerms.class); + + public RentalTerms localInstanceIn(EOEditingContext editingContext) { + RentalTerms localInstance = (RentalTerms)EOUtilities.localInstanceOfObject(editingContext, this); + if (localInstance == null) { + throw new IllegalStateException("You attempted to localInstance " + this + ", which has not yet committed."); + } + return localInstance; + } + + public Integer checkOutLength() { + return (Integer) storedValueForKey(_RentalTerms.CHECK_OUT_LENGTH_KEY); + } + + public void setCheckOutLength(Integer value) { + if (_RentalTerms.LOG.isDebugEnabled()) { + _RentalTerms.LOG.debug( "updating checkOutLength from " + checkOutLength() + " to " + value); + } + takeStoredValueForKey(value, _RentalTerms.CHECK_OUT_LENGTH_KEY); + } + + public java.math.BigDecimal cost() { + return (java.math.BigDecimal) storedValueForKey(_RentalTerms.COST_KEY); + } + + public void setCost(java.math.BigDecimal value) { + if (_RentalTerms.LOG.isDebugEnabled()) { + _RentalTerms.LOG.debug( "updating cost from " + cost() + " to " + value); + } + takeStoredValueForKey(value, _RentalTerms.COST_KEY); + } + + public java.math.BigDecimal depositAmount() { + return (java.math.BigDecimal) storedValueForKey(_RentalTerms.DEPOSIT_AMOUNT_KEY); + } + + public void setDepositAmount(java.math.BigDecimal value) { + if (_RentalTerms.LOG.isDebugEnabled()) { + _RentalTerms.LOG.debug( "updating depositAmount from " + depositAmount() + " to " + value); + } + takeStoredValueForKey(value, _RentalTerms.DEPOSIT_AMOUNT_KEY); + } + + public String name() { + return (String) storedValueForKey(_RentalTerms.NAME_KEY); + } + + public void setName(String value) { + if (_RentalTerms.LOG.isDebugEnabled()) { + _RentalTerms.LOG.debug( "updating name from " + name() + " to " + value); + } + takeStoredValueForKey(value, _RentalTerms.NAME_KEY); + } + + + public static RentalTerms createRentalTerms(EOEditingContext editingContext, Integer checkOutLength +, java.math.BigDecimal cost +, java.math.BigDecimal depositAmount +, String name +) { + RentalTerms eo = (RentalTerms) EOUtilities.createAndInsertInstance(editingContext, _RentalTerms.ENTITY_NAME); + eo.setCheckOutLength(checkOutLength); + eo.setCost(cost); + eo.setDepositAmount(depositAmount); + eo.setName(name); + return eo; + } + + public static ERXFetchSpecification fetchSpec() { + return new ERXFetchSpecification(_RentalTerms.ENTITY_NAME, null, null, false, true, null); + } + + public static NSArray fetchAllRentalTermses(EOEditingContext editingContext) { + return _RentalTerms.fetchAllRentalTermses(editingContext, null); + } + + public static NSArray fetchAllRentalTermses(EOEditingContext editingContext, NSArray sortOrderings) { + return _RentalTerms.fetchRentalTermses(editingContext, null, sortOrderings); + } + + public static NSArray fetchRentalTermses(EOEditingContext editingContext, EOQualifier qualifier, NSArray sortOrderings) { + ERXFetchSpecification fetchSpec = new ERXFetchSpecification(_RentalTerms.ENTITY_NAME, qualifier, sortOrderings); + fetchSpec.setIsDeep(true); + NSArray eoObjects = fetchSpec.fetchObjects(editingContext); + return eoObjects; + } + + public static RentalTerms fetchRentalTerms(EOEditingContext editingContext, String keyName, Object value) { + return _RentalTerms.fetchRentalTerms(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static RentalTerms fetchRentalTerms(EOEditingContext editingContext, EOQualifier qualifier) { + NSArray eoObjects = _RentalTerms.fetchRentalTermses(editingContext, qualifier, null); + RentalTerms eoObject; + int count = eoObjects.count(); + if (count == 0) { + eoObject = null; + } + else if (count == 1) { + eoObject = eoObjects.objectAtIndex(0); + } + else { + throw new IllegalStateException("There was more than one RentalTerms that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static RentalTerms fetchRequiredRentalTerms(EOEditingContext editingContext, String keyName, Object value) { + return _RentalTerms.fetchRequiredRentalTerms(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static RentalTerms fetchRequiredRentalTerms(EOEditingContext editingContext, EOQualifier qualifier) { + RentalTerms eoObject = _RentalTerms.fetchRentalTerms(editingContext, qualifier); + if (eoObject == null) { + throw new NoSuchElementException("There was no RentalTerms that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static RentalTerms localInstanceIn(EOEditingContext editingContext, RentalTerms eo) { + RentalTerms localInstance = (eo == null) ? null : ERXEOControlUtilities.localInstanceOfObject(editingContext, eo); + if (localInstance == null && eo != null) { + throw new IllegalStateException("You attempted to localInstance " + eo + ", which has not yet committed."); + } + return localInstance; + } +} diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Unit.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Unit.java new file mode 100644 index 00000000000..c19ded27f47 --- /dev/null +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Unit.java @@ -0,0 +1,277 @@ +// DO NOT EDIT. Make changes to Unit.java instead. +package webobjectsexamples.businesslogic.rentals.common; + +import com.webobjects.eoaccess.*; +import com.webobjects.eocontrol.*; +import com.webobjects.foundation.*; +import java.math.*; +import java.util.*; +import org.apache.log4j.Logger; + +import er.extensions.eof.*; +import er.extensions.foundation.*; + +@SuppressWarnings("all") +public abstract class _Unit extends er.extensions.eof.ERXGenericRecord { + public static final String ENTITY_NAME = "Unit"; + + // Attribute Keys + public static final ERXKey DATE_ACQUIRED = new ERXKey("dateAcquired"); + public static final ERXKey NOTES = new ERXKey("notes"); + public static final ERXKey UNIT_ID = new ERXKey("unitID"); + // Relationship Keys + public static final ERXKey RENTALS = new ERXKey("rentals"); + public static final ERXKey VIDEO = new ERXKey("video"); + + // Attributes + public static final String DATE_ACQUIRED_KEY = DATE_ACQUIRED.key(); + public static final String NOTES_KEY = NOTES.key(); + public static final String UNIT_ID_KEY = UNIT_ID.key(); + // Relationships + public static final String RENTALS_KEY = RENTALS.key(); + public static final String VIDEO_KEY = VIDEO.key(); + + private static Logger LOG = Logger.getLogger(_Unit.class); + + public Unit localInstanceIn(EOEditingContext editingContext) { + Unit localInstance = (Unit)EOUtilities.localInstanceOfObject(editingContext, this); + if (localInstance == null) { + throw new IllegalStateException("You attempted to localInstance " + this + ", which has not yet committed."); + } + return localInstance; + } + + public NSTimestamp dateAcquired() { + return (NSTimestamp) storedValueForKey(_Unit.DATE_ACQUIRED_KEY); + } + + public void setDateAcquired(NSTimestamp value) { + if (_Unit.LOG.isDebugEnabled()) { + _Unit.LOG.debug( "updating dateAcquired from " + dateAcquired() + " to " + value); + } + takeStoredValueForKey(value, _Unit.DATE_ACQUIRED_KEY); + } + + public String notes() { + return (String) storedValueForKey(_Unit.NOTES_KEY); + } + + public void setNotes(String value) { + if (_Unit.LOG.isDebugEnabled()) { + _Unit.LOG.debug( "updating notes from " + notes() + " to " + value); + } + takeStoredValueForKey(value, _Unit.NOTES_KEY); + } + + public Integer unitID() { + return (Integer) storedValueForKey(_Unit.UNIT_ID_KEY); + } + + public void setUnitID(Integer value) { + if (_Unit.LOG.isDebugEnabled()) { + _Unit.LOG.debug( "updating unitID from " + unitID() + " to " + value); + } + takeStoredValueForKey(value, _Unit.UNIT_ID_KEY); + } + + public webobjectsexamples.businesslogic.rentals.common.Video video() { + return (webobjectsexamples.businesslogic.rentals.common.Video)storedValueForKey(_Unit.VIDEO_KEY); + } + + public void setVideo(webobjectsexamples.businesslogic.rentals.common.Video value) { + takeStoredValueForKey(value, _Unit.VIDEO_KEY); + } + + public void setVideoRelationship(webobjectsexamples.businesslogic.rentals.common.Video value) { + if (_Unit.LOG.isDebugEnabled()) { + _Unit.LOG.debug("updating video from " + video() + " to " + value); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + setVideo(value); + } + else if (value == null) { + webobjectsexamples.businesslogic.rentals.common.Video oldValue = video(); + if (oldValue != null) { + removeObjectFromBothSidesOfRelationshipWithKey(oldValue, _Unit.VIDEO_KEY); + } + } else { + addObjectToBothSidesOfRelationshipWithKey(value, _Unit.VIDEO_KEY); + } + } + + public NSArray rentals() { + return (NSArray)storedValueForKey(_Unit.RENTALS_KEY); + } + + public NSArray rentals(EOQualifier qualifier) { + return rentals(qualifier, null, false); + } + + public NSArray rentals(EOQualifier qualifier, boolean fetch) { + return rentals(qualifier, null, fetch); + } + + public NSArray rentals(EOQualifier qualifier, NSArray sortOrderings, boolean fetch) { + NSArray results; + if (fetch) { + EOQualifier fullQualifier; + EOQualifier inverseQualifier = new EOKeyValueQualifier(webobjectsexamples.businesslogic.rentals.common.Rental.UNIT_KEY, EOQualifier.QualifierOperatorEqual, this); + + if (qualifier == null) { + fullQualifier = inverseQualifier; + } + else { + NSMutableArray qualifiers = new NSMutableArray(); + qualifiers.addObject(qualifier); + qualifiers.addObject(inverseQualifier); + fullQualifier = new EOAndQualifier(qualifiers); + } + + results = webobjectsexamples.businesslogic.rentals.common.Rental.fetchRentals(editingContext(), fullQualifier, sortOrderings); + } + else { + results = rentals(); + if (qualifier != null) { + results = (NSArray)EOQualifier.filteredArrayWithQualifier(results, qualifier); + } + if (sortOrderings != null) { + results = (NSArray)EOSortOrdering.sortedArrayUsingKeyOrderArray(results, sortOrderings); + } + } + return results; + } + + public void addToRentals(webobjectsexamples.businesslogic.rentals.common.Rental object) { + includeObjectIntoPropertyWithKey(object, _Unit.RENTALS_KEY); + } + + public void removeFromRentals(webobjectsexamples.businesslogic.rentals.common.Rental object) { + excludeObjectFromPropertyWithKey(object, _Unit.RENTALS_KEY); + } + + public void addToRentalsRelationship(webobjectsexamples.businesslogic.rentals.common.Rental object) { + if (_Unit.LOG.isDebugEnabled()) { + _Unit.LOG.debug("adding " + object + " to rentals relationship"); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + addToRentals(object); + } + else { + addObjectToBothSidesOfRelationshipWithKey(object, _Unit.RENTALS_KEY); + } + } + + public void removeFromRentalsRelationship(webobjectsexamples.businesslogic.rentals.common.Rental object) { + if (_Unit.LOG.isDebugEnabled()) { + _Unit.LOG.debug("removing " + object + " from rentals relationship"); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + removeFromRentals(object); + } + else { + removeObjectFromBothSidesOfRelationshipWithKey(object, _Unit.RENTALS_KEY); + } + } + + public webobjectsexamples.businesslogic.rentals.common.Rental createRentalsRelationship() { + EOClassDescription eoClassDesc = EOClassDescription.classDescriptionForEntityName( webobjectsexamples.businesslogic.rentals.common.Rental.ENTITY_NAME ); + EOEnterpriseObject eo = eoClassDesc.createInstanceWithEditingContext(editingContext(), null); + editingContext().insertObject(eo); + addObjectToBothSidesOfRelationshipWithKey(eo, _Unit.RENTALS_KEY); + return (webobjectsexamples.businesslogic.rentals.common.Rental) eo; + } + + public void deleteRentalsRelationship(webobjectsexamples.businesslogic.rentals.common.Rental object) { + removeObjectFromBothSidesOfRelationshipWithKey(object, _Unit.RENTALS_KEY); + editingContext().deleteObject(object); + } + + public void deleteAllRentalsRelationships() { + Enumeration objects = rentals().immutableClone().objectEnumerator(); + while (objects.hasMoreElements()) { + deleteRentalsRelationship(objects.nextElement()); + } + } + + + public static Unit createUnit(EOEditingContext editingContext, NSTimestamp dateAcquired +, Integer unitID +, webobjectsexamples.businesslogic.rentals.common.Video video) { + Unit eo = (Unit) EOUtilities.createAndInsertInstance(editingContext, _Unit.ENTITY_NAME); + eo.setDateAcquired(dateAcquired); + eo.setUnitID(unitID); + eo.setVideoRelationship(video); + return eo; + } + + public static ERXFetchSpecification fetchSpec() { + return new ERXFetchSpecification(_Unit.ENTITY_NAME, null, null, false, true, null); + } + + public static NSArray fetchAllUnits(EOEditingContext editingContext) { + return _Unit.fetchAllUnits(editingContext, null); + } + + public static NSArray fetchAllUnits(EOEditingContext editingContext, NSArray sortOrderings) { + return _Unit.fetchUnits(editingContext, null, sortOrderings); + } + + public static NSArray fetchUnits(EOEditingContext editingContext, EOQualifier qualifier, NSArray sortOrderings) { + ERXFetchSpecification fetchSpec = new ERXFetchSpecification(_Unit.ENTITY_NAME, qualifier, sortOrderings); + fetchSpec.setIsDeep(true); + NSArray eoObjects = fetchSpec.fetchObjects(editingContext); + return eoObjects; + } + + public static Unit fetchUnit(EOEditingContext editingContext, String keyName, Object value) { + return _Unit.fetchUnit(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static Unit fetchUnit(EOEditingContext editingContext, EOQualifier qualifier) { + NSArray eoObjects = _Unit.fetchUnits(editingContext, qualifier, null); + Unit eoObject; + int count = eoObjects.count(); + if (count == 0) { + eoObject = null; + } + else if (count == 1) { + eoObject = eoObjects.objectAtIndex(0); + } + else { + throw new IllegalStateException("There was more than one Unit that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static Unit fetchRequiredUnit(EOEditingContext editingContext, String keyName, Object value) { + return _Unit.fetchRequiredUnit(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static Unit fetchRequiredUnit(EOEditingContext editingContext, EOQualifier qualifier) { + Unit eoObject = _Unit.fetchUnit(editingContext, qualifier); + if (eoObject == null) { + throw new NoSuchElementException("There was no Unit that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static Unit localInstanceIn(EOEditingContext editingContext, Unit eo) { + Unit localInstance = (eo == null) ? null : ERXEOControlUtilities.localInstanceOfObject(editingContext, eo); + if (localInstance == null && eo != null) { + throw new IllegalStateException("You attempted to localInstance " + eo + ", which has not yet committed."); + } + return localInstance; + } + public static NSArray fetchPrefetchVideoMovie(EOEditingContext editingContext, NSDictionary bindings) { + EOFetchSpecification fetchSpec = EOFetchSpecification.fetchSpecificationNamed("prefetchVideoMovie", _Unit.ENTITY_NAME); + fetchSpec = fetchSpec.fetchSpecificationWithQualifierBindings(bindings); + return (NSArray)editingContext.objectsWithFetchSpecification(fetchSpec); + } + + public static NSArray fetchPrefetchVideoMovie(EOEditingContext editingContext) + { + EOFetchSpecification fetchSpec = EOFetchSpecification.fetchSpecificationNamed("prefetchVideoMovie", _Unit.ENTITY_NAME); + return (NSArray)editingContext.objectsWithFetchSpecification(fetchSpec); + } + +} diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_User.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_User.java new file mode 100644 index 00000000000..8b2c2fdd674 --- /dev/null +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_User.java @@ -0,0 +1,188 @@ +// DO NOT EDIT. Make changes to User.java instead. +package webobjectsexamples.businesslogic.rentals.common; + +import com.webobjects.eoaccess.*; +import com.webobjects.eocontrol.*; +import com.webobjects.foundation.*; +import java.math.*; +import java.util.*; +import org.apache.log4j.Logger; + +import er.extensions.eof.*; +import er.extensions.foundation.*; + +@SuppressWarnings("all") +public abstract class _User extends er.extensions.eof.ERXGenericRecord { + public static final String ENTITY_NAME = "User"; + + // Attribute Keys + public static final ERXKey ACCESS_LEVEL = new ERXKey("accessLevel"); + public static final ERXKey PASSWORD = new ERXKey("password"); + public static final ERXKey USERNAME = new ERXKey("username"); + // Relationship Keys + public static final ERXKey CUSTOMER = new ERXKey("customer"); + + // Attributes + public static final String ACCESS_LEVEL_KEY = ACCESS_LEVEL.key(); + public static final String PASSWORD_KEY = PASSWORD.key(); + public static final String USERNAME_KEY = USERNAME.key(); + // Relationships + public static final String CUSTOMER_KEY = CUSTOMER.key(); + + private static Logger LOG = Logger.getLogger(_User.class); + + public User localInstanceIn(EOEditingContext editingContext) { + User localInstance = (User)EOUtilities.localInstanceOfObject(editingContext, this); + if (localInstance == null) { + throw new IllegalStateException("You attempted to localInstance " + this + ", which has not yet committed."); + } + return localInstance; + } + + public Integer accessLevel() { + return (Integer) storedValueForKey(_User.ACCESS_LEVEL_KEY); + } + + public void setAccessLevel(Integer value) { + if (_User.LOG.isDebugEnabled()) { + _User.LOG.debug( "updating accessLevel from " + accessLevel() + " to " + value); + } + takeStoredValueForKey(value, _User.ACCESS_LEVEL_KEY); + } + + public String password() { + return (String) storedValueForKey(_User.PASSWORD_KEY); + } + + public void setPassword(String value) { + if (_User.LOG.isDebugEnabled()) { + _User.LOG.debug( "updating password from " + password() + " to " + value); + } + takeStoredValueForKey(value, _User.PASSWORD_KEY); + } + + public String username() { + return (String) storedValueForKey(_User.USERNAME_KEY); + } + + public void setUsername(String value) { + if (_User.LOG.isDebugEnabled()) { + _User.LOG.debug( "updating username from " + username() + " to " + value); + } + takeStoredValueForKey(value, _User.USERNAME_KEY); + } + + public webobjectsexamples.businesslogic.rentals.common.Customer customer() { + return (webobjectsexamples.businesslogic.rentals.common.Customer)storedValueForKey(_User.CUSTOMER_KEY); + } + + public void setCustomer(webobjectsexamples.businesslogic.rentals.common.Customer value) { + takeStoredValueForKey(value, _User.CUSTOMER_KEY); + } + + public void setCustomerRelationship(webobjectsexamples.businesslogic.rentals.common.Customer value) { + if (_User.LOG.isDebugEnabled()) { + _User.LOG.debug("updating customer from " + customer() + " to " + value); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + setCustomer(value); + } + else if (value == null) { + webobjectsexamples.businesslogic.rentals.common.Customer oldValue = customer(); + if (oldValue != null) { + removeObjectFromBothSidesOfRelationshipWithKey(oldValue, _User.CUSTOMER_KEY); + } + } else { + addObjectToBothSidesOfRelationshipWithKey(value, _User.CUSTOMER_KEY); + } + } + + + public static User createUser(EOEditingContext editingContext, Integer accessLevel +, String password +, String username +) { + User eo = (User) EOUtilities.createAndInsertInstance(editingContext, _User.ENTITY_NAME); + eo.setAccessLevel(accessLevel); + eo.setPassword(password); + eo.setUsername(username); + return eo; + } + + public static ERXFetchSpecification fetchSpec() { + return new ERXFetchSpecification(_User.ENTITY_NAME, null, null, false, true, null); + } + + public static NSArray fetchAllUsers(EOEditingContext editingContext) { + return _User.fetchAllUsers(editingContext, null); + } + + public static NSArray fetchAllUsers(EOEditingContext editingContext, NSArray sortOrderings) { + return _User.fetchUsers(editingContext, null, sortOrderings); + } + + public static NSArray fetchUsers(EOEditingContext editingContext, EOQualifier qualifier, NSArray sortOrderings) { + ERXFetchSpecification fetchSpec = new ERXFetchSpecification(_User.ENTITY_NAME, qualifier, sortOrderings); + fetchSpec.setIsDeep(true); + NSArray eoObjects = fetchSpec.fetchObjects(editingContext); + return eoObjects; + } + + public static User fetchUser(EOEditingContext editingContext, String keyName, Object value) { + return _User.fetchUser(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static User fetchUser(EOEditingContext editingContext, EOQualifier qualifier) { + NSArray eoObjects = _User.fetchUsers(editingContext, qualifier, null); + User eoObject; + int count = eoObjects.count(); + if (count == 0) { + eoObject = null; + } + else if (count == 1) { + eoObject = eoObjects.objectAtIndex(0); + } + else { + throw new IllegalStateException("There was more than one User that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static User fetchRequiredUser(EOEditingContext editingContext, String keyName, Object value) { + return _User.fetchRequiredUser(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value)); + } + + public static User fetchRequiredUser(EOEditingContext editingContext, EOQualifier qualifier) { + User eoObject = _User.fetchUser(editingContext, qualifier); + if (eoObject == null) { + throw new NoSuchElementException("There was no User that matched the qualifier '" + qualifier + "'."); + } + return eoObject; + } + + public static User localInstanceIn(EOEditingContext editingContext, User eo) { + User localInstance = (eo == null) ? null : ERXEOControlUtilities.localInstanceOfObject(editingContext, eo); + if (localInstance == null && eo != null) { + throw new IllegalStateException("You attempted to localInstance " + eo + ", which has not yet committed."); + } + return localInstance; + } + public static NSArray fetchLogin(EOEditingContext editingContext, NSDictionary bindings) { + EOFetchSpecification fetchSpec = EOFetchSpecification.fetchSpecificationNamed("login", _User.ENTITY_NAME); + fetchSpec = fetchSpec.fetchSpecificationWithQualifierBindings(bindings); + return (NSArray)editingContext.objectsWithFetchSpecification(fetchSpec); + } + + public static NSArray fetchLogin(EOEditingContext editingContext, + String passwordBinding, + String userBinding) + { + EOFetchSpecification fetchSpec = EOFetchSpecification.fetchSpecificationNamed("login", _User.ENTITY_NAME); + NSMutableDictionary bindings = new NSMutableDictionary(); + bindings.takeValueForKey(passwordBinding, "password"); + bindings.takeValueForKey(userBinding, "user"); + fetchSpec = fetchSpec.fetchSpecificationWithQualifierBindings(bindings); + return (NSArray)editingContext.objectsWithFetchSpecification(fetchSpec); + } + +} diff --git a/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Video.java b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Video.java new file mode 100644 index 00000000000..36108c011b1 --- /dev/null +++ b/Frameworks/BusinessLogic/ERMoviesLogic/Sources/webobjectsexamples/businesslogic/rentals/common/_Video.java @@ -0,0 +1,250 @@ +// DO NOT EDIT. Make changes to Video.java instead. +package webobjectsexamples.businesslogic.rentals.common; + +import com.webobjects.eoaccess.*; +import com.webobjects.eocontrol.*; +import com.webobjects.foundation.*; +import java.math.*; +import java.util.*; +import org.apache.log4j.Logger; + +import er.extensions.eof.*; +import er.extensions.foundation.*; + +@SuppressWarnings("all") +public abstract class _Video extends er.extensions.eof.ERXGenericRecord { + public static final String ENTITY_NAME = "Video"; + + // Attribute Keys + // Relationship Keys + public static final ERXKey MOVIE = new ERXKey("movie"); + public static final ERXKey RENTAL_TERMS = new ERXKey("rentalTerms"); + public static final ERXKey UNITS = new ERXKey("units"); + + // Attributes + // Relationships + public static final String MOVIE_KEY = MOVIE.key(); + public static final String RENTAL_TERMS_KEY = RENTAL_TERMS.key(); + public static final String UNITS_KEY = UNITS.key(); + + private static Logger LOG = Logger.getLogger(_Video.class); + + public Video localInstanceIn(EOEditingContext editingContext) { + Video localInstance = (Video)EOUtilities.localInstanceOfObject(editingContext, this); + if (localInstance == null) { + throw new IllegalStateException("You attempted to localInstance " + this + ", which has not yet committed."); + } + return localInstance; + } + + public webobjectsexamples.businesslogic.movies.common.Movie movie() { + return (webobjectsexamples.businesslogic.movies.common.Movie)storedValueForKey(_Video.MOVIE_KEY); + } + + public void setMovie(webobjectsexamples.businesslogic.movies.common.Movie value) { + takeStoredValueForKey(value, _Video.MOVIE_KEY); + } + + public void setMovieRelationship(webobjectsexamples.businesslogic.movies.common.Movie value) { + if (_Video.LOG.isDebugEnabled()) { + _Video.LOG.debug("updating movie from " + movie() + " to " + value); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + setMovie(value); + } + else if (value == null) { + webobjectsexamples.businesslogic.movies.common.Movie oldValue = movie(); + if (oldValue != null) { + removeObjectFromBothSidesOfRelationshipWithKey(oldValue, _Video.MOVIE_KEY); + } + } else { + addObjectToBothSidesOfRelationshipWithKey(value, _Video.MOVIE_KEY); + } + } + + public webobjectsexamples.businesslogic.rentals.common.RentalTerms rentalTerms() { + return (webobjectsexamples.businesslogic.rentals.common.RentalTerms)storedValueForKey(_Video.RENTAL_TERMS_KEY); + } + + public void setRentalTerms(webobjectsexamples.businesslogic.rentals.common.RentalTerms value) { + takeStoredValueForKey(value, _Video.RENTAL_TERMS_KEY); + } + + public void setRentalTermsRelationship(webobjectsexamples.businesslogic.rentals.common.RentalTerms value) { + if (_Video.LOG.isDebugEnabled()) { + _Video.LOG.debug("updating rentalTerms from " + rentalTerms() + " to " + value); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + setRentalTerms(value); + } + else if (value == null) { + webobjectsexamples.businesslogic.rentals.common.RentalTerms oldValue = rentalTerms(); + if (oldValue != null) { + removeObjectFromBothSidesOfRelationshipWithKey(oldValue, _Video.RENTAL_TERMS_KEY); + } + } else { + addObjectToBothSidesOfRelationshipWithKey(value, _Video.RENTAL_TERMS_KEY); + } + } + + public NSArray units() { + return (NSArray)storedValueForKey(_Video.UNITS_KEY); + } + + public NSArray units(EOQualifier qualifier) { + return units(qualifier, null, false); + } + + public NSArray units(EOQualifier qualifier, boolean fetch) { + return units(qualifier, null, fetch); + } + + public NSArray units(EOQualifier qualifier, NSArray sortOrderings, boolean fetch) { + NSArray results; + if (fetch) { + EOQualifier fullQualifier; + EOQualifier inverseQualifier = new EOKeyValueQualifier(webobjectsexamples.businesslogic.rentals.common.Unit.VIDEO_KEY, EOQualifier.QualifierOperatorEqual, this); + + if (qualifier == null) { + fullQualifier = inverseQualifier; + } + else { + NSMutableArray qualifiers = new NSMutableArray(); + qualifiers.addObject(qualifier); + qualifiers.addObject(inverseQualifier); + fullQualifier = new EOAndQualifier(qualifiers); + } + + results = webobjectsexamples.businesslogic.rentals.common.Unit.fetchUnits(editingContext(), fullQualifier, sortOrderings); + } + else { + results = units(); + if (qualifier != null) { + results = (NSArray)EOQualifier.filteredArrayWithQualifier(results, qualifier); + } + if (sortOrderings != null) { + results = (NSArray)EOSortOrdering.sortedArrayUsingKeyOrderArray(results, sortOrderings); + } + } + return results; + } + + public void addToUnits(webobjectsexamples.businesslogic.rentals.common.Unit object) { + includeObjectIntoPropertyWithKey(object, _Video.UNITS_KEY); + } + + public void removeFromUnits(webobjectsexamples.businesslogic.rentals.common.Unit object) { + excludeObjectFromPropertyWithKey(object, _Video.UNITS_KEY); + } + + public void addToUnitsRelationship(webobjectsexamples.businesslogic.rentals.common.Unit object) { + if (_Video.LOG.isDebugEnabled()) { + _Video.LOG.debug("adding " + object + " to units relationship"); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + addToUnits(object); + } + else { + addObjectToBothSidesOfRelationshipWithKey(object, _Video.UNITS_KEY); + } + } + + public void removeFromUnitsRelationship(webobjectsexamples.businesslogic.rentals.common.Unit object) { + if (_Video.LOG.isDebugEnabled()) { + _Video.LOG.debug("removing " + object + " from units relationship"); + } + if (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) { + removeFromUnits(object); + } + else { + removeObjectFromBothSidesOfRelationshipWithKey(object, _Video.UNITS_KEY); + } + } + + public webobjectsexamples.businesslogic.rentals.common.Unit createUnitsRelationship() { + EOClassDescription eoClassDesc = EOClassDescription.classDescriptionForEntityName( webobjectsexamples.businesslogic.rentals.common.Unit.ENTITY_NAME ); + EOEnterpriseObject eo = eoClassDesc.createInstanceWithEditingContext(editingContext(), null); + editingContext().insertObject(eo); + addObjectToBothSidesOfRelationshipWithKey(eo, _Video.UNITS_KEY); + return (webobjectsexamples.businesslogic.rentals.common.Unit) eo; + } + + public void deleteUnitsRelationship(webobjectsexamples.businesslogic.rentals.common.Unit object) { + removeObjectFromBothSidesOfRelationshipWithKey(object, _Video.UNITS_KEY); + editingContext().deleteObject(object); + } + + public void deleteAllUnitsRelationships() { + Enumeration objects = units().immutableClone().objectEnumerator(); + while (objects.hasMoreElements()) { + deleteUnitsRelationship(objects.nextElement()); + } + } + + + public static Video createVideo(EOEditingContext editingContext, webobjectsexamples.businesslogic.movies.common.Movie movie, webobjectsexamples.businesslogic.rentals.common.RentalTerms rentalTerms) { + Video eo = (Video) EOUtilities.createAndInsertInstance(editingContext, _Video.ENTITY_NAME); + eo.setMovieRelationship(movie); + eo.setRentalTermsRelationship(rentalTerms); + return eo; + } + + public static ERXFetchSpecification