home *** CD-ROM | disk | FTP | other *** search
- /* QualifiedAssociation.m:
- * You may freely copy, distribute, and reuse the code in this example.
- * NeXT disclaims any warranty of any kind, expressed or implied, as to its
- * fitness for any particular use.
- *
- * Written by Mai Nguyen, NeXT Developer Support
- *
- */
-
- #import "QualifiedAssociation.h"
-
- @implementation QualifiedAssociation
-
- - setValue:value
- {
- [[self destination] fetchContentsOf:value usingQualifier:dbQualifier];
- return self;
- }
-
- - setQualifier: qualifier
- {
- dbQualifier = (DBQualifier *)qualifier;
- return self;
- }
-
- - qualifier
- {
- return dbQualifier;
- }
-
-
- /* C function to set up a custom association between the master fetchgroup
- * and the detail fetchgroup.
- */
-
- QualifiedAssociation * setUpAssociation(DBFetchGroup * dbFetchGroup)
- {
- DBModule * dbModule;
- DBAssociation * dbAssociation;
- DBExpression * dbExpression;
- DBFetchGroup * masterFetchGroup;
- QualifiedAssociation * qualifiedAssociation;
-
-
- /* Get a hold of the association from master fetchgroup to detail
- * fetchgroup
- */
- dbModule = [dbFetchGroup module];
- dbAssociation = [dbModule associationForObject:dbFetchGroup];
- dbExpression = [dbAssociation expression];
- masterFetchGroup = [dbAssociation fetchGroup];
- /* Remove the association from the master fetchgroup
- */
- [masterFetchGroup removeAssociation:dbAssociation];
- qualifiedAssociation = [[QualifiedAssociation alloc]
- initFetchGroup:masterFetchGroup
- expression: dbExpression
- destination: dbFetchGroup ];
-
- [masterFetchGroup addAssociation:qualifiedAssociation];
-
- /* Free old association */
- [dbAssociation free];
- return qualifiedAssociation;
- }
-
- @end
-