3 #include <NGObjWeb/SoComponent.h>
5 @class EOAdaptorChannel;
7 @interface DTable : SoComponent
9 EOAdaptorChannel *channel;
20 @implementation DTable
23 if ([self->channel isOpen])
24 [self->channel closeChannel];
25 [self->channel release];
27 [self->attributes release];
28 [self->columnNames release];
36 if ([self->channel isOpen])
37 [self->channel closeChannel];
44 - (EOAdaptor *)adaptor {
45 return [(DSoTable *)[self clientObject] adaptorInContext:[self context]];
48 - (EOAdaptorChannel *)channel {
49 EOAdaptorContext *ctx;
54 ctx = [[self adaptor] createAdaptorContext];
55 self->channel = [[ctx createAdaptorChannel] retain];
56 if (![self->channel openChannel]) {
57 [self->channel release];
64 - (EOModel *)_describeModel {
67 tableNames = [NSArray arrayWithObject:[[self clientObject] tableName]];
68 return [[self channel] describeModelWithTableNames:tableNames];
73 - (void)setItem:(id)_item {
74 ASSIGN(self->item, _item);
80 - (NSArray *)attributes {
84 return self->attributes;
86 model = [self _describeModel];
87 self->attributes = [[[[model entities] lastObject] attributes] retain];
88 return self->attributes;
90 - (NSArray *)columnNames {
91 if (self->columnNames)
92 return self->columnNames;
94 self->columnNames = [[[self attributes] valueForKey:@"columnName"] copy];
95 return self->columnNames;
98 - (NSString *)columnLink {
99 return [[[self item] columnName] stringByAppendingString:@"/"];
101 - (NSString *)itemSlashLink {
102 // this suxx, a) we need to write code, b) we need to attach the / manually
103 return [[self item] stringByAppendingString:@"/"];