mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-19 17:50:47 +00:00
* EOAccess/EORelationship.m (-referencesProperty:): Check if property
is the relationships destination entity. * EOModeler/EOModelerDocument (-delete:): Call referencesToProperty: on all model objects. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@28011 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
500785be3b
commit
ad8dedbf6c
3 changed files with 47 additions and 29 deletions
|
@ -1,3 +1,10 @@
|
|||
2009-03-01 Matt Rice <ratmice@gmail.com>
|
||||
|
||||
* EOAccess/EORelationship.m (-referencesProperty:): Check if property
|
||||
is the relationships destination entity.
|
||||
* EOModeler/EOModelerDocument (-delete:): Call referencesToProperty:
|
||||
on all model objects.
|
||||
|
||||
2009-02-27 Matt Rice <ratmice@gmail.com>
|
||||
|
||||
* DBModeler/MainModelEditor.m: Implement -viewSelectedObject
|
||||
|
|
|
@ -760,21 +760,27 @@ to know what to-many mean :-) **/
|
|||
- (BOOL)referencesProperty: (id)property
|
||||
{
|
||||
BOOL referencesProperty = NO;
|
||||
NSArray *srcAttribs = [self sourceAttributes];
|
||||
NSArray *destAttribs = [self destinationAttributes];
|
||||
NSArray *compRels = [self componentRelationships];
|
||||
NSArray *srcAttribs;
|
||||
NSArray *destAttribs;
|
||||
NSArray *compRels;
|
||||
|
||||
if (property == nil)
|
||||
return NO;
|
||||
|
||||
destAttribs = [self destinationAttributes];
|
||||
srcAttribs = [self sourceAttributes];
|
||||
compRels = [self componentRelationships];
|
||||
|
||||
NSEmitTODO(); //TODO
|
||||
EOFLOGObjectLevelArgs(@"EORelationship", @"in referencesProperty:%@",
|
||||
property);
|
||||
|
||||
referencesProperty =
|
||||
((srcAttribs
|
||||
&& [srcAttribs indexOfObject: property] != NSNotFound)
|
||||
|| (destAttribs
|
||||
&& [destAttribs indexOfObject: property] != NSNotFound)
|
||||
&& [destAttribs indexOfObject: property] != NSNotFound)
|
||||
|| (compRels
|
||||
&& [compRels indexOfObject: property] != NSNotFound));
|
||||
&& [compRels indexOfObject: property] != NSNotFound)
|
||||
|| (_destination == property));
|
||||
|
||||
return referencesProperty;
|
||||
}
|
||||
|
|
|
@ -536,30 +536,34 @@ NSString *EOMConsistencyModelObjectKey = @"EOMConsistencyModelObjectKey";
|
|||
for (i = 0, c = [objects count]; i < c; i++)
|
||||
{
|
||||
id object = [objects objectAtIndex:i];
|
||||
|
||||
if ([object isKindOfClass:[EOAttribute class]])
|
||||
{
|
||||
NSArray *refs;
|
||||
|
||||
refs = [[[object entity] model] referencesToProperty:object];
|
||||
if (![refs count])
|
||||
[[object entity] removeAttribute:object];
|
||||
else
|
||||
NSArray *refs;
|
||||
if ([object isKindOfClass:[EOAttribute class]]
|
||||
|| [object isKindOfClass:[EORelationship class]])
|
||||
refs = [[[object entity] model] referencesToProperty:object];
|
||||
else if ([object isKindOfClass:[EOEntity class]])
|
||||
refs = [[object model] referencesToProperty:object];
|
||||
|
||||
if ([refs count])
|
||||
{
|
||||
NSMutableString *str;
|
||||
unsigned i,c;
|
||||
str = [NSMutableString stringWithFormat:@"object(%@) is referenced by other properties\n", [object name]];
|
||||
for (i = 0, c = [refs count]; i < c; i++)
|
||||
{
|
||||
NSMutableString *str;
|
||||
unsigned i,c;
|
||||
str = [NSMutableString stringWithFormat:@"attribute is referenced by properties\n"];
|
||||
for (i = 0, c = [refs count]; i < c; i++)
|
||||
{
|
||||
id prop = [refs objectAtIndex:i];
|
||||
NSString *tmp;
|
||||
tmp=[NSString stringWithFormat:@"%@ in %@\n",[prop name],
|
||||
[[prop entity] name]];
|
||||
[str appendString:tmp];
|
||||
}
|
||||
|
||||
NSRunAlertPanel(@"unable to remove attribute", str, @"ok", nil, nil);
|
||||
id prop = [refs objectAtIndex:i];
|
||||
NSString *tmp;
|
||||
tmp=[NSString stringWithFormat:@"%@ of type %@\n",
|
||||
[prop name],
|
||||
[prop class]];
|
||||
[str appendString:tmp];
|
||||
}
|
||||
|
||||
NSRunAlertPanel(@"unable to remove property", str, @"ok", nil, nil);
|
||||
return;
|
||||
}
|
||||
else if ([object isKindOfClass:[EOAttribute class]])
|
||||
{
|
||||
[[object entity] removeAttribute:object];
|
||||
}
|
||||
else if ([object isKindOfClass:[EOEntity class]])
|
||||
{
|
||||
|
@ -573,6 +577,7 @@ NSString *EOMConsistencyModelObjectKey = @"EOMConsistencyModelObjectKey";
|
|||
[[EOMApp currentEditor] setSelectionWithinViewedObject:[NSArray array]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addFetchSpecification:(id)sender
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in a new issue