| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
package net.wotonomy.access; |
| 19 |
|
|
| 20 |
|
import net.wotonomy.control.EOClassDescription; |
| 21 |
|
import net.wotonomy.control.EOEditingContext; |
| 22 |
|
import net.wotonomy.control.EOFetchSpecification; |
| 23 |
|
import net.wotonomy.control.EOGenericRecord; |
| 24 |
|
import net.wotonomy.control.EOGlobalID; |
| 25 |
|
import net.wotonomy.foundation.NSArray; |
| 26 |
|
import net.wotonomy.foundation.NSMutableArray; |
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
public class EOEntityClassDescription extends EOClassDescription { |
| 34 |
|
|
| 35 |
|
protected EOEntity _entity; |
| 36 |
|
|
| 37 |
|
public EOEntityClassDescription() { |
| 38 |
0 |
super(); |
| 39 |
0 |
} |
| 40 |
|
|
| 41 |
|
public EOEntityClassDescription(EOEntity entity) { |
| 42 |
0 |
this(); |
| 43 |
0 |
_entity = entity; |
| 44 |
0 |
} |
| 45 |
|
|
| 46 |
|
public NSArray allAttributeKeys() { |
| 47 |
0 |
NSArray arr = entity().attributes(); |
| 48 |
0 |
NSMutableArray a = new NSMutableArray(arr.count()); |
| 49 |
0 |
for (int i = 0; i < arr.count(); i++) { |
| 50 |
0 |
EOAttribute atrib = (EOAttribute)arr.objectAtIndex(i); |
| 51 |
0 |
a.addObject(atrib); |
| 52 |
|
} |
| 53 |
0 |
return a; |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
public NSArray allPropertyKeys() { |
| 57 |
0 |
return entity().classPropertyNames(); |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
public NSArray allToManyRelationshipKeys() { |
| 61 |
0 |
NSArray arr = entity().relationships(); |
| 62 |
0 |
NSMutableArray a = new NSMutableArray(arr.count()); |
| 63 |
0 |
for (int i = 0; i < arr.count(); i++) { |
| 64 |
0 |
EORelationship r = (EORelationship)arr.objectAtIndex(i); |
| 65 |
0 |
if (r.isToMany()) |
| 66 |
0 |
a.addObject(r); |
| 67 |
|
} |
| 68 |
0 |
return a; |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
public NSArray allToOneRelationshipKeys() { |
| 72 |
0 |
NSArray arr = entity().relationships(); |
| 73 |
0 |
NSMutableArray a = new NSMutableArray(arr.count()); |
| 74 |
0 |
for (int i = 0; i < arr.count(); i++) { |
| 75 |
0 |
EORelationship r = (EORelationship)arr.objectAtIndex(i); |
| 76 |
0 |
if (!r.isToMany()) |
| 77 |
0 |
a.addObject(r); |
| 78 |
|
} |
| 79 |
0 |
return a; |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
public NSArray attributeKeys() { |
| 86 |
0 |
NSArray arr = entity().attributes(); |
| 87 |
0 |
NSMutableArray a = new NSMutableArray(arr.count()); |
| 88 |
0 |
for (int i = 0; i < arr.count(); i++) { |
| 89 |
0 |
EOAttribute atrib = (EOAttribute)arr.objectAtIndex(i); |
| 90 |
0 |
if (!atrib.isDerived()) |
| 91 |
0 |
a.addObject(atrib); |
| 92 |
|
} |
| 93 |
0 |
return a; |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
public EOClassDescription classDescriptionForDestinationKey(String key) { |
| 97 |
0 |
EORelationship r = entity().relationshipNamed(key); |
| 98 |
0 |
if (r == null) |
| 99 |
0 |
return null; |
| 100 |
0 |
return r.destinationEntity().classDescriptionForInstances(); |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
public NSArray clientAttributeKeys() { |
| 104 |
0 |
return null; |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
public NSArray clientToManyRelationshipKeys() { |
| 108 |
0 |
return null; |
| 109 |
|
} |
| 110 |
|
|
| 111 |
|
public NSArray clientToOneRelationshipKeys() { |
| 112 |
0 |
return null; |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
public EOEntity entity() { |
| 116 |
0 |
return _entity; |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
public String entityName() { |
| 120 |
0 |
return _entity.name(); |
| 121 |
|
} |
| 122 |
|
|
| 123 |
|
public EOFetchSpecification fetchSpecificationNamed(String name) { |
| 124 |
0 |
return entity().fetchSpecificationNamed(name); |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
public NSArray toManyRelationshipKeys() { |
| 128 |
0 |
NSArray arr = entity().relationships(); |
| 129 |
0 |
NSMutableArray a = new NSMutableArray(arr.count()); |
| 130 |
0 |
for (int i = 0; i < arr.count(); i++) { |
| 131 |
0 |
EORelationship r = (EORelationship)arr.objectAtIndex(i); |
| 132 |
0 |
if (r.isToMany() && !r.isFlattened()) |
| 133 |
0 |
a.addObject(r); |
| 134 |
|
} |
| 135 |
0 |
return a; |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
public NSArray toOneRelationshipKeys() { |
| 139 |
0 |
NSArray arr = entity().relationships(); |
| 140 |
0 |
NSMutableArray a = new NSMutableArray(arr.count()); |
| 141 |
0 |
for (int i = 0; i < arr.count(); i++) { |
| 142 |
0 |
EORelationship r = (EORelationship)arr.objectAtIndex(i); |
| 143 |
0 |
if (!r.isToMany() && !r.isFlattened()) |
| 144 |
0 |
a.addObject(r); |
| 145 |
|
} |
| 146 |
0 |
return a; |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
public Object createInstanceWithEditingContext(EOEditingContext ec, EOGlobalID gid) { |
| 150 |
0 |
if (theClass == null) { |
| 151 |
|
try { |
| 152 |
0 |
theClass = Class.forName(entity().className()); |
| 153 |
0 |
} catch (ClassNotFoundException ex) { |
| 154 |
0 |
if (entity().className().equals("net.wotonomy.control.EOGenericRecord")) |
| 155 |
0 |
throw new IllegalArgumentException("Cannot find class " + entity().className()); |
| 156 |
0 |
theClass = EOGenericRecord.class; |
| 157 |
0 |
} |
| 158 |
|
} |
| 159 |
0 |
return super.createInstanceWithEditingContext(ec, gid); |
| 160 |
|
} |
| 161 |
|
|
| 162 |
|
} |
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
|
|
| 183 |
|
|
| 184 |
|
|
| 185 |
|
|