/* EOAccessAdditions.h created by lindberg on Mon 20-Dec-1999 */

#import <EOAccess/EOModel.h>
#import <EOAccess/EOEntity.h>
#import <EOAccess/EOAttribute.h>
#import <EOAccess/EORelationship.h>
#import <EOControl/EOFetchSpecification.h>
#import "SystemType.h"

/* EOAccess extension methods for use by templates */

@interface EOModel (EOAccessAdditions)

// Tries to find the framework name. First looks to see if a value for
// "EOGeneratorFrameworkName" exists in the model's -userInfo dictionary, and if
// not, looks at the model's -path to find the framework the .eomodeld is in.
// Both PB.project files and path components ending in ".framework" are looked
// for, so it should work for .eomodels insided installed frameworks or in a
// development tree. If the framework name could not be found, returns nil.
- (NSString *)frameworkName;

// Uses isLike: to do the comparisons
- (NSArray *)entityNamesMatchingWildcard:(NSString *)wildcard;


@interface EOEntity (EOAccessAdditions)

- (BOOL)hasParentEntity;
- (NSString *)frameworkName;

- (NSString *)objcImportString;
- (NSString *)objcImportStringInRelationToEntity:(EOEntity *)sourceEntity;
- (NSString *)parentObjCImportString;

//uniqued array of relationships' -objcImportString
- (NSArray *)referencedObjCImportStrings;
- (NSArray *)arrayWithParentObjCImportStringIfNeeded;

#ifdef EOF2_ONLY
// Define for use by EOF2 systems
- (NSString *)classNameWithoutPackage;
- (NSArray *)fetchSpecificationNames;
- (EOFetchSpecification *)fetchSpecificationNamed:(NSString *)name;

// Getting the Java package as a string
- (NSString *)classPackageName;

#ifndef EOF2_ONLY
- (NSString *)clientClassPackageName;
- (NSString *)javaParentClientClassName;

// JavaClient methods... reimplementation of ones in EOJavaClientExtensions.EOMBundle
- (NSArray *)clientClassAttributes;
- (NSArray *)clientClassToOneRelationships;
- (NSArray *)clientClassToManyRelationships;
- (NSArray *)clientClassScalarAttributes;
- (NSArray *)clientClassNonScalarAttributes;

- (NSArray *)fetchSpecifications;
- (NSArray *)beautifiedFetchSpecificationDictionaries;
- (NSArray *)javaBeautifiedFetchSpecificationDictionaries;


#ifndef EOF2_ONLY
// <EOJavaClient/EOAccessAdditions.h> isn't always there (the ObjC framework
// does not come with WO 4.5.1 on OS X or with WO 5), so just declare the
// methods here.  Except with WO 4.0, the methods are actually implemented
// in the EOAccess framework, so this is OK.
@interface EOEntity (JavaClientExtensions)
- (NSString *)clientClassName;
- (NSString *)clientClassNameWithoutPackage;
- (NSString *)referenceClientClassName;
- (NSArray *)clientClassProperties;
- (NSArray *)clientClassPropertyAttributeNames;
- (NSArray *)clientClassPropertyToOneRelationshipNames;
- (NSArray *)clientClassPropertyToManyRelationshipNames;

@interface EORelationship (EOAccessAdditions)

// If the destination entity is in an external framework, returns
// <Framework/ClassName.h>, otherwise returns "ClassName.h".
- (NSString *)objcImportString;


@interface EOAttribute (EOAccessAdditions)

- (NSString *)javaValueTypeClassName;
- (NSString *)javaScalarValueTypeClassName;


@interface EOFetchSpecification (EOAccessAdditions)

- (NSArray *)bindingParametersIsJava:(BOOL)isJava;
- (NSArray *)bindingParameters;
- (NSArray *)javaBindingParameters;


@interface NSString (ModelStringManipulations)

- (NSString *)uppercaseUnderbarString;
- (NSString *)lowercaseNonUnderbarString;


@interface EOGeneratorAttributePoser : EOAttribute