mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-21 10:30:58 +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>
|
2009-02-27 Matt Rice <ratmice@gmail.com>
|
||||||
|
|
||||||
* DBModeler/MainModelEditor.m: Implement -viewSelectedObject
|
* DBModeler/MainModelEditor.m: Implement -viewSelectedObject
|
||||||
|
|
|
@ -760,21 +760,27 @@ to know what to-many mean :-) **/
|
||||||
- (BOOL)referencesProperty: (id)property
|
- (BOOL)referencesProperty: (id)property
|
||||||
{
|
{
|
||||||
BOOL referencesProperty = NO;
|
BOOL referencesProperty = NO;
|
||||||
NSArray *srcAttribs = [self sourceAttributes];
|
NSArray *srcAttribs;
|
||||||
NSArray *destAttribs = [self destinationAttributes];
|
NSArray *destAttribs;
|
||||||
NSArray *compRels = [self componentRelationships];
|
NSArray *compRels;
|
||||||
|
|
||||||
|
if (property == nil)
|
||||||
|
return NO;
|
||||||
|
|
||||||
|
destAttribs = [self destinationAttributes];
|
||||||
|
srcAttribs = [self sourceAttributes];
|
||||||
|
compRels = [self componentRelationships];
|
||||||
|
|
||||||
NSEmitTODO(); //TODO
|
|
||||||
EOFLOGObjectLevelArgs(@"EORelationship", @"in referencesProperty:%@",
|
EOFLOGObjectLevelArgs(@"EORelationship", @"in referencesProperty:%@",
|
||||||
property);
|
property);
|
||||||
|
|
||||||
referencesProperty =
|
referencesProperty =
|
||||||
((srcAttribs
|
((srcAttribs
|
||||||
&& [srcAttribs indexOfObject: property] != NSNotFound)
|
&& [srcAttribs indexOfObject: property] != NSNotFound)
|
||||||
|| (destAttribs
|
|| (destAttribs
|
||||||
&& [destAttribs indexOfObject: property] != NSNotFound)
|
&& [destAttribs indexOfObject: property] != NSNotFound)
|
||||||
|| (compRels
|
|| (compRels
|
||||||
&& [compRels indexOfObject: property] != NSNotFound));
|
&& [compRels indexOfObject: property] != NSNotFound)
|
||||||
|
|| (_destination == property));
|
||||||
|
|
||||||
return referencesProperty;
|
return referencesProperty;
|
||||||
}
|
}
|
||||||
|
|
|
@ -536,30 +536,34 @@ NSString *EOMConsistencyModelObjectKey = @"EOMConsistencyModelObjectKey";
|
||||||
for (i = 0, c = [objects count]; i < c; i++)
|
for (i = 0, c = [objects count]; i < c; i++)
|
||||||
{
|
{
|
||||||
id object = [objects objectAtIndex:i];
|
id object = [objects objectAtIndex:i];
|
||||||
|
NSArray *refs;
|
||||||
if ([object isKindOfClass:[EOAttribute class]])
|
if ([object isKindOfClass:[EOAttribute class]]
|
||||||
{
|
|| [object isKindOfClass:[EORelationship class]])
|
||||||
NSArray *refs;
|
refs = [[[object entity] model] referencesToProperty:object];
|
||||||
|
else if ([object isKindOfClass:[EOEntity class]])
|
||||||
refs = [[[object entity] model] referencesToProperty:object];
|
refs = [[object model] referencesToProperty:object];
|
||||||
if (![refs count])
|
|
||||||
[[object entity] removeAttribute:object];
|
if ([refs count])
|
||||||
else
|
{
|
||||||
|
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;
|
id prop = [refs objectAtIndex:i];
|
||||||
unsigned i,c;
|
NSString *tmp;
|
||||||
str = [NSMutableString stringWithFormat:@"attribute is referenced by properties\n"];
|
tmp=[NSString stringWithFormat:@"%@ of type %@\n",
|
||||||
for (i = 0, c = [refs count]; i < c; i++)
|
[prop name],
|
||||||
{
|
[prop class]];
|
||||||
id prop = [refs objectAtIndex:i];
|
[str appendString:tmp];
|
||||||
NSString *tmp;
|
|
||||||
tmp=[NSString stringWithFormat:@"%@ in %@\n",[prop name],
|
|
||||||
[[prop entity] name]];
|
|
||||||
[str appendString:tmp];
|
|
||||||
}
|
|
||||||
|
|
||||||
NSRunAlertPanel(@"unable to remove attribute", str, @"ok", nil, nil);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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]])
|
else if ([object isKindOfClass:[EOEntity class]])
|
||||||
{
|
{
|
||||||
|
@ -573,6 +577,7 @@ NSString *EOMConsistencyModelObjectKey = @"EOMConsistencyModelObjectKey";
|
||||||
[[EOMApp currentEditor] setSelectionWithinViewedObject:[NSArray array]];
|
[[EOMApp currentEditor] setSelectionWithinViewedObject:[NSArray array]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)addFetchSpecification:(id)sender
|
- (void)addFetchSpecification:(id)sender
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue