2002-11-15 22:57:05 +00:00
|
|
|
/**
|
|
|
|
EOJoin.m <title>EOJoin Class</title>
|
|
|
|
|
2005-08-17 08:07:57 +00:00
|
|
|
Copyright (C) 2000-2002,2003,2004,2005 Free Software Foundation, Inc.
|
2002-11-15 22:57:05 +00:00
|
|
|
|
2006-09-14 16:06:21 +00:00
|
|
|
Author: Mirko Viviani <mirko.viviani@gmail.com>
|
2002-11-15 22:57:05 +00:00
|
|
|
Date: February 2000
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
$Date$
|
|
|
|
|
|
|
|
<abstract></abstract>
|
|
|
|
|
|
|
|
This file is part of the GNUstep Database Library.
|
|
|
|
|
|
|
|
<license>
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, write to the Free Software Foundation,
|
2005-08-17 08:07:57 +00:00
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-11-15 22:57:05 +00:00
|
|
|
</license>
|
|
|
|
**/
|
|
|
|
|
2002-12-31 16:25:21 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
RCS_ID("$Id$")
|
2002-11-15 22:57:05 +00:00
|
|
|
|
2004-03-19 16:41:21 +00:00
|
|
|
#ifdef GNUSTEP
|
2003-03-31 00:24:15 +00:00
|
|
|
#include <Foundation/NSString.h>
|
|
|
|
#include <Foundation/NSUtilities.h>
|
|
|
|
#include <Foundation/NSDebug.h>
|
|
|
|
#else
|
|
|
|
#include <Foundation/Foundation.h>
|
|
|
|
#endif
|
|
|
|
|
2003-07-11 19:04:05 +00:00
|
|
|
#ifndef GNUSTEP
|
2003-08-25 20:01:59 +00:00
|
|
|
#include <GNUstepBase/GNUstep.h>
|
2004-01-31 13:57:38 +00:00
|
|
|
#include <GNUstepBase/GSObjCRuntime.h>
|
|
|
|
#include <GNUstepBase/GSCategories.h>
|
2003-07-11 19:04:05 +00:00
|
|
|
#endif
|
|
|
|
|
2003-03-31 00:24:15 +00:00
|
|
|
#include <EOControl/EODebug.h>
|
|
|
|
|
|
|
|
#include <EOAccess/EOModel.h>
|
|
|
|
#include <EOAccess/EOEntity.h>
|
|
|
|
#include <EOAccess/EOAttribute.h>
|
|
|
|
#include <EOAccess/EORelationship.h>
|
|
|
|
#include <EOAccess/EOJoin.h>
|
2002-12-30 23:00:10 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
@implementation EOJoin
|
|
|
|
|
|
|
|
+ (EOJoin *) joinWithSourceAttribute: (EOAttribute *)source
|
|
|
|
destinationAttribute: (EOAttribute *)destination
|
|
|
|
{
|
|
|
|
return [[[self alloc] initWithSourceAttribute: source
|
|
|
|
destinationAttribute: destination] autorelease];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithSourceAttribute: (EOAttribute *)source
|
|
|
|
destinationAttribute: (EOAttribute *)destination
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2006-10-15 12:23:42 +00:00
|
|
|
NSAssert((source && destination),
|
|
|
|
@"Source and destination attributes cannot be nil");
|
2002-11-15 22:57:05 +00:00
|
|
|
ASSIGN(_sourceAttribute, source);
|
|
|
|
ASSIGN(_destinationAttribute, destination);
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (unsigned)hash
|
|
|
|
{
|
|
|
|
return [_sourceAttribute hash];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)description
|
|
|
|
{
|
|
|
|
NSString *dscr = nil;
|
|
|
|
/*NSString *joinOperatorDescr = nil;
|
|
|
|
NSString *joinSemanticDescr = nil;
|
|
|
|
|
|
|
|
switch(joinOperator)
|
|
|
|
{
|
|
|
|
case EOJoinEqualTo:
|
|
|
|
joinOperatorDescr=@"EOJoinEqualTo";
|
|
|
|
break;
|
|
|
|
case EOJoinNotEqualTo:
|
|
|
|
joinOperatorDescr=@"EOJoinNotEqualTo";
|
|
|
|
break;
|
|
|
|
case EOJoinGreaterThan:
|
|
|
|
joinOperatorDescr=@"EOJoinGreaterThan";
|
|
|
|
break;
|
|
|
|
case EOJoinGreaterThanOrEqualTo:
|
|
|
|
joinOperatorDescr=@"EOJoinGreaterThanOrEqualTo";
|
|
|
|
break;
|
|
|
|
case EOJoinLessThan:
|
|
|
|
joinOperatorDescr=@"EOJoinLessThan";
|
|
|
|
break;
|
|
|
|
case EOJoinLessThanOrEqualTo:
|
|
|
|
joinOperatorDescr=@"EOJoinLessThanOrEqualTo";
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
switch(joinSemantic)
|
|
|
|
{
|
|
|
|
case EOInnerJoin:
|
|
|
|
joinSemanticDescr=@"EOInnerJoin";
|
|
|
|
break;
|
|
|
|
case EOFullOuterJoin:
|
|
|
|
joinSemanticDescr=@"EOFullOuterJoin";
|
|
|
|
break;
|
|
|
|
case EOLeftOuterJoin:
|
|
|
|
joinSemanticDescr=@"EOLeftOuterJoin";
|
|
|
|
break;
|
|
|
|
case EORightOuterJoin:
|
|
|
|
joinSemanticDescr=@"EORightOuterJoin";
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
|
|
|
dscr = [NSString stringWithFormat: @"<%s %p -",
|
|
|
|
object_get_class_name(self),
|
|
|
|
(void*)self];
|
|
|
|
dscr = [dscr stringByAppendingFormat: @" sourceAttribute=%@",
|
|
|
|
[_sourceAttribute name]];
|
|
|
|
dscr = [dscr stringByAppendingFormat: @" destinationAttribute=%@",
|
|
|
|
[_destinationAttribute name]];
|
|
|
|
|
|
|
|
/* dscr=[dscr stringByAppendingFormat:@" relationship name=%@",
|
|
|
|
[relationship name]];
|
|
|
|
dscr=[dscr stringByAppendingFormat:@" joinOperator=%@ joinSemantic=%@>",
|
|
|
|
joinOperatorDescr,
|
|
|
|
joinSemanticDescr];*/
|
|
|
|
|
|
|
|
return dscr;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (EOAttribute *)destinationAttribute
|
|
|
|
{
|
|
|
|
return _destinationAttribute;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (EOAttribute *)sourceAttribute
|
|
|
|
{
|
|
|
|
return _sourceAttribute;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isReciprocalToJoin: (EOJoin *)otherJoin
|
|
|
|
{
|
|
|
|
//OK
|
|
|
|
NSDebugMLLog(@"gsdb", @"_sourceAttribute name=%@",
|
|
|
|
[_sourceAttribute name]);
|
|
|
|
NSDebugMLLog(@"gsdb", @"[[otherJoin destinationAttribute] name]=%@",
|
|
|
|
[[otherJoin destinationAttribute] name]);
|
|
|
|
NSDebugMLLog(@"gsdb", @"_destinationAttribute name=%@",
|
|
|
|
[_destinationAttribute name]);
|
|
|
|
NSDebugMLLog(@"gsdb", @"[[otherJoin sourceAttribute] name]=%@",
|
|
|
|
[[otherJoin sourceAttribute] name]);
|
|
|
|
|
|
|
|
if ([[_sourceAttribute name]
|
|
|
|
isEqual: [[otherJoin destinationAttribute] name]]
|
|
|
|
&& [[_destinationAttribute name]
|
|
|
|
isEqual: [[otherJoin sourceAttribute] name]])
|
|
|
|
return YES;
|
|
|
|
else
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|