1 19 20 package org.apache.cayenne.map; 21 22 import java.io.PrintWriter ; 23 import java.io.Serializable ; 24 import java.util.ArrayList ; 25 import java.util.Collection ; 26 import java.util.Collections ; 27 import java.util.Iterator ; 28 import java.util.List ; 29 import java.util.Map ; 30 import java.util.SortedMap ; 31 import java.util.TreeMap ; 32 33 import org.apache.cayenne.map.event.AttributeEvent; 34 import org.apache.cayenne.map.event.DbAttributeListener; 35 import org.apache.cayenne.map.event.DbEntityListener; 36 import org.apache.cayenne.map.event.DbRelationshipListener; 37 import org.apache.cayenne.map.event.EntityEvent; 38 import org.apache.cayenne.map.event.ObjAttributeListener; 39 import org.apache.cayenne.map.event.ObjEntityListener; 40 import org.apache.cayenne.map.event.ObjRelationshipListener; 41 import org.apache.cayenne.map.event.RelationshipEvent; 42 import org.apache.cayenne.project.Project; 43 import org.apache.cayenne.query.NamedQuery; 44 import org.apache.cayenne.query.Query; 45 import org.apache.cayenne.util.Util; 46 import org.apache.cayenne.util.XMLEncoder; 47 import org.apache.cayenne.util.XMLSerializable; 48 import org.apache.commons.lang.builder.ToStringBuilder; 49 50 59 public class DataMap implements Serializable , XMLSerializable, MappingNamespace, 60 DbEntityListener, DbAttributeListener, DbRelationshipListener, ObjEntityListener, 61 ObjAttributeListener, ObjRelationshipListener { 62 63 68 public static final String CLIENT_SUPPORTED_PROPERTY = "clientSupported"; 69 70 75 public static final String DEFAULT_CLIENT_PACKAGE_PROPERTY = "defaultClientPackage"; 76 77 82 public static final String DEFAULT_SCHEMA_PROPERTY = "defaultSchema"; 83 84 89 public static final String DEFAULT_PACKAGE_PROPERTY = "defaultPackage"; 90 91 96 public static final String DEFAULT_SUPERCLASS_PROPERTY = "defaultSuperclass"; 97 98 103 public static final String DEFAULT_LOCK_TYPE_PROPERTY = "defaultLockType"; 104 105 protected String name; 106 protected String location; 107 protected MappingNamespace namespace; 108 109 protected String defaultSchema; 110 protected String defaultPackage; 111 protected String defaultSuperclass; 112 protected int defaultLockType; 113 114 protected boolean clientSupported; 115 protected String defaultClientPackage; 116 117 private SortedMap embeddablesMap; 118 private SortedMap entityListenersMap; 119 private SortedMap objEntityMap; 120 private SortedMap dbEntityMap; 121 private SortedMap procedureMap; 122 private SortedMap queryMap; 123 124 private List defaultEntityListeners; 125 126 129 public DataMap() { 130 this(null); 131 } 132 133 136 public DataMap(String mapName) { 137 this(mapName, Collections.EMPTY_MAP); 138 } 139 140 public DataMap(String mapName, Map properties) { 141 embeddablesMap = new TreeMap (); 142 entityListenersMap = new TreeMap (); 143 objEntityMap = new TreeMap (); 144 dbEntityMap = new TreeMap (); 145 procedureMap = new TreeMap (); 146 queryMap = new TreeMap (); 147 defaultEntityListeners = new ArrayList (3); 148 149 setName(mapName); 150 initWithProperties(properties); 151 } 152 153 159 public void initWithProperties(Map properties) { 160 if (properties == null) { 162 properties = Collections.EMPTY_MAP; 163 } 164 165 Object lockType = properties.get(DEFAULT_LOCK_TYPE_PROPERTY); 166 Object packageName = properties.get(DEFAULT_PACKAGE_PROPERTY); 167 Object schema = properties.get(DEFAULT_SCHEMA_PROPERTY); 168 Object superclass = properties.get(DEFAULT_SUPERCLASS_PROPERTY); 169 Object clientEntities = properties.get(CLIENT_SUPPORTED_PROPERTY); 170 Object clientPackageName = properties.get(DEFAULT_CLIENT_PACKAGE_PROPERTY); 171 172 this.defaultLockType = "optimistic".equals(lockType) 173 ? ObjEntity.LOCK_TYPE_OPTIMISTIC 174 : ObjEntity.LOCK_TYPE_NONE; 175 176 this.defaultPackage = (packageName != null) ? packageName.toString() : null; 177 this.defaultSchema = (schema != null) ? schema.toString() : null; 178 this.defaultSuperclass = (superclass != null) ? superclass.toString() : null; 179 this.clientSupported = (clientEntities != null) ? "true" 180 .equalsIgnoreCase(clientEntities.toString()) : false; 181 this.defaultClientPackage = (clientPackageName != null) ? clientPackageName 182 .toString() : null; 183 } 184 185 192 public DataMap getClientDataMap(EntityResolver serverResolver) { 193 if (!isClientSupported()) { 194 return null; 195 } 196 197 DataMap clientMap = new DataMap(getName()); 198 199 Iterator entities = getObjEntities().iterator(); 201 while (entities.hasNext()) { 202 ObjEntity entity = (ObjEntity) entities.next(); 203 if (entity.isClientAllowed()) { 204 clientMap.addObjEntity(entity.getClientEntity()); 205 } 206 } 207 208 Iterator queries = getQueries().iterator(); 210 while (queries.hasNext()) { 211 Query q = (Query) queries.next(); 212 NamedQuery proxy = new NamedQuery(q.getName()); 213 proxy.setName(q.getName()); 214 215 proxy.initMetadata(q.getMetaData(serverResolver)); 218 clientMap.addQuery(proxy); 219 } 220 221 return clientMap; 222 } 223 224 231 public void encodeAsXML(PrintWriter pw) { 232 XMLEncoder encoder = new XMLEncoder(pw, "\t"); 233 encoder.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); 234 encodeAsXML(encoder); 235 } 236 237 242 public void encodeAsXML(XMLEncoder encoder) { 243 encoder.print("<data-map project-version=\""); 244 encoder.print(String.valueOf(Project.CURRENT_PROJECT_VERSION)); 245 encoder.println("\">"); 246 247 encoder.indent(1); 248 249 if (defaultLockType == ObjEntity.LOCK_TYPE_OPTIMISTIC) { 251 encoder.printProperty(DEFAULT_LOCK_TYPE_PROPERTY, "optimistic"); 252 } 253 254 if (!Util.isEmptyString(defaultPackage)) { 255 encoder.printProperty(DEFAULT_PACKAGE_PROPERTY, defaultPackage); 256 } 257 258 if (!Util.isEmptyString(defaultSchema)) { 259 encoder.printProperty(DEFAULT_SCHEMA_PROPERTY, defaultSchema); 260 } 261 262 if (!Util.isEmptyString(defaultSuperclass)) { 263 encoder.printProperty(DEFAULT_SUPERCLASS_PROPERTY, defaultSuperclass); 264 } 265 266 if (clientSupported) { 267 encoder.printProperty(CLIENT_SUPPORTED_PROPERTY, "true"); 268 } 269 270 if (!Util.isEmptyString(defaultClientPackage)) { 271 encoder.printProperty(DEFAULT_CLIENT_PACKAGE_PROPERTY, defaultClientPackage); 272 } 273 274 encoder.print(getEmbeddableMap()); 276 277 encoder.print(getProcedureMap()); 279 280 boolean hasDerived = false; 282 Iterator dbEntities = getDbEntityMap().entrySet().iterator(); 283 while (dbEntities.hasNext()) { 284 Map.Entry entry = (Map.Entry ) dbEntities.next(); 285 DbEntity dbe = (DbEntity) entry.getValue(); 286 287 if (dbe instanceof DerivedDbEntity) { 289 hasDerived = true; 290 } 291 else { 292 dbe.encodeAsXML(encoder); 293 } 294 } 295 296 if (hasDerived) { 298 Iterator derivedDbEntities = getDbEntityMap().entrySet().iterator(); 299 while (derivedDbEntities.hasNext()) { 300 Map.Entry entry = (Map.Entry ) derivedDbEntities.next(); 301 DbEntity dbe = (DbEntity) entry.getValue(); 302 303 if (dbe instanceof DerivedDbEntity) { 305 dbe.encodeAsXML(encoder); 306 } 307 } 308 } 309 310 encoder.print(getObjEntityMap()); 312 encodeDBRelationshipsAsXML(getDbEntityMap(), encoder); 313 encodeOBJRelationshipsAsXML(getObjEntityMap(), encoder); 314 encoder.print(getQueryMap()); 315 316 encoder.indent(-1); 317 encoder.println("</data-map>"); 318 } 319 320 private final void encodeDBRelationshipsAsXML(Map entityMap, XMLEncoder encoder) { 322 Iterator it = entityMap.entrySet().iterator(); 323 while (it.hasNext()) { 324 Map.Entry entry = (Map.Entry ) it.next(); 325 Entity entity = (Entity) entry.getValue(); 326 encoder.print(entity.getRelationships()); 327 } 328 } 329 330 private final void encodeOBJRelationshipsAsXML(Map entityMap, XMLEncoder encoder) { 332 Iterator it = entityMap.entrySet().iterator(); 333 while (it.hasNext()) { 334 Map.Entry entry = (Map.Entry ) it.next(); 335 ObjEntity entity = (ObjEntity) entry.getValue(); 336 encoder.print(entity.getDeclaredRelationships()); 337 } 338 } 339 340 public String toString() { 341 return new ToStringBuilder(this).append("name", getName()).toString(); 342 } 343 344 347 public String getName() { 348 return name; 349 } 350 351 public void setName(String name) { 352 this.name = name; 353 } 354 355 363 public void mergeWithDataMap(DataMap map) { 364 Iterator dbs = new ArrayList (map.getDbEntities()).iterator(); 365 while (dbs.hasNext()) { 366 DbEntity ent = (DbEntity) dbs.next(); 367 this.removeDbEntity(ent.getName()); 368 this.addDbEntity(ent); 369 } 370 371 Iterator objs = new ArrayList (map.getObjEntities()).iterator(); 372 while (objs.hasNext()) { 373 ObjEntity ent = (ObjEntity) objs.next(); 374 this.removeObjEntity(ent.getName()); 375 this.addObjEntity(ent); 376 } 377 378 Iterator queries = new ArrayList (map.getQueries()).iterator(); 379 while (queries.hasNext()) { 380 Query query = (Query) queries.next(); 381 this.removeQuery(query.getName()); 382 this.addQuery(query); 383 } 384 } 385 386 391 public String getLocation() { 392 return location; 393 } 394 395 398 public void setLocation(String location) { 399 this.location = location; 400 } 401 402 406 public SortedMap getObjEntityMap() { 407 return Collections.unmodifiableSortedMap(objEntityMap); 408 } 409 410 414 public SortedMap getDbEntityMap() { 415 return Collections.unmodifiableSortedMap(dbEntityMap); 416 } 417 418 423 public Query getQuery(String queryName) { 424 Query query = (Query) queryMap.get(queryName); 425 if (query != null) { 426 return query; 427 } 428 429 return namespace != null ? namespace.getQuery(queryName) : null; 430 } 431 432 437 public void addQuery(Query query) { 438 if (query == null) { 439 throw new NullPointerException ("Can't add null query."); 440 } 441 442 if (query.getName() == null) { 443 throw new NullPointerException ("Query name can't be null."); 444 } 445 446 Object existingQuery = queryMap.get(query.getName()); 449 if (existingQuery != null) { 450 if (existingQuery == query) { 451 return; 452 } 453 else { 454 throw new IllegalArgumentException ("An attempt to override entity '" 455 + query.getName()); 456 } 457 } 458 459 queryMap.put(query.getName(), query); 460 } 461 462 467 public void removeQuery(String queryName) { 468 queryMap.remove(queryName); 469 } 470 471 476 public void clearEmbeddables() { 477 embeddablesMap.clear(); 478 } 479 480 485 public void clearEntityListeners() { 486 entityListenersMap.clear(); 487 } 488 489 492 public void clearQueries() { 493 queryMap.clear(); 494 } 495 496 499 public void clearObjEntities() { 500 objEntityMap.clear(); 501 } 502 503 506 public void clearDbEntities() { 507 dbEntityMap.clear(); 508 } 509 510 513 public void clearProcedures() { 514 procedureMap.clear(); 515 } 516 517 520 public SortedMap getQueryMap() { 521 return Collections.unmodifiableSortedMap(queryMap); 522 } 523 524 529 public Collection getQueries() { 530 return Collections.unmodifiableCollection(queryMap.values()); 531 } 532 533 537 public void addEntityListener(EntityListener listener) { 538 if (listener == null) { 539 throw new NullPointerException ("Null EntityListener"); 540 } 541 542 if (listener.getClassName() == null) { 543 throw new NullPointerException ( 544 "Attempt to add EntityListener with no class name."); 545 } 546 547 Object existing = embeddablesMap.get(listener.getClassName()); 550 if (existing != null) { 551 if (existing == listener) { 552 return; 553 } 554 else { 555 throw new IllegalArgumentException ("An attempt to override listener '" 556 + listener.getClassName()); 557 } 558 } 559 560 entityListenersMap.put(listener.getClassName(), listener); 561 } 562 563 569 public void removeEntityListener(String className) { 570 if (entityListenersMap.remove(className) != null) { 571 removeDefaultEntityListener(className); 572 } 573 } 574 575 580 public void addEmbeddable(Embeddable embeddable) { 581 if (embeddable == null) { 582 throw new NullPointerException ("Null embeddable"); 583 } 584 585 if (embeddable.getClassName() == null) { 586 throw new NullPointerException ( 587 "Attempt to add Embeddable with no class name."); 588 } 589 590 Object existing = embeddablesMap.get(embeddable.getClassName()); 593 if (existing != null) { 594 if (existing == embeddable) { 595 return; 596 } 597 else { 598 throw new IllegalArgumentException ("An attempt to override embeddable '" 599 + embeddable.getClassName()); 600 } 601 } 602 603 embeddablesMap.put(embeddable.getClassName(), embeddable); 604 } 605 606 609 public void addObjEntity(ObjEntity entity) { 610 if (entity.getName() == null) { 611 throw new NullPointerException ("Attempt to add ObjEntity with no name."); 612 } 613 614 Object existingEntity = objEntityMap.get(entity.getName()); 617 if (existingEntity != null) { 618 if (existingEntity == entity) { 619 return; 620 } 621 else { 622 throw new IllegalArgumentException ("An attempt to override entity '" 623 + entity.getName()); 624 } 625 } 626 627 objEntityMap.put(entity.getName(), entity); 628 entity.setDataMap(this); 629 } 630 631 634 public void addDbEntity(DbEntity entity) { 635 if (entity.getName() == null) { 636 throw new NullPointerException ("Attempt to add DbEntity with no name."); 637 } 638 639 Object existingEntity = dbEntityMap.get(entity.getName()); 642 if (existingEntity != null) { 643 if (existingEntity == entity) { 644 return; 645 } 646 else { 647 throw new IllegalArgumentException ("An attempt to override entity '" 648 + entity.getName()); 649 } 650 } 651 652 dbEntityMap.put(entity.getName(), entity); 653 entity.setDataMap(this); 654 } 655 656 659 public Collection getObjEntities() { 660 return Collections.unmodifiableCollection(objEntityMap.values()); 661 } 662 663 666 public Map getEmbeddableMap() { 667 return Collections.unmodifiableMap(embeddablesMap); 668 } 669 670 675 public Collection getEmbeddables() { 676 return Collections.unmodifiableCollection(embeddablesMap.values()); 677 } 678 679 682 public Embeddable getEmbeddable(String className) { 683 Embeddable e = (Embeddable) embeddablesMap.get(className); 684 if (e != null) { 685 return e; 686 } 687 688 return namespace != null ? namespace.getEmbeddable(className) : null; 689 } 690 691 694 public Map getEntityListenersMap() { 695 return Collections.unmodifiableMap(entityListenersMap); 696 } 697 698 703 public Collection getEntityListeners() { 704 return Collections.unmodifiableCollection(entityListenersMap.values()); 705 } 706 707 710 public EntityListener getEntityListener(String className) { 711 EntityListener e = (EntityListener) entityListenersMap.get(className); 712 if (e != null) { 713 return e; 714 } 715 716 return namespace != null ? namespace.getEntityListener(className) : null; 717 } 718 719 726 public List getDefaultEntityListeners() { 727 return Collections.unmodifiableList(defaultEntityListeners); 728 } 729 730 737 public void addDefaultEntityListener(EntityListener listener) { 738 Iterator it = defaultEntityListeners.iterator(); 739 while (it.hasNext()) { 740 EntityListener next = (EntityListener) it.next(); 741 if (listener.getClassName().equals(next.getClassName())) { 742 throw new IllegalArgumentException ("Duplicate default listener for " 743 + next.getClassName()); 744 } 745 } 746 747 defaultEntityListeners.add(listener); 748 } 749 750 755 public void removeDefaultEntityListener(String className) { 756 Iterator it = defaultEntityListeners.iterator(); 757 while (it.hasNext()) { 758 EntityListener next = (EntityListener) it.next(); 759 if (className.equals(next.getClassName())) { 760 it.remove(); 761 break; 762 } 763 } 764 } 765 766 769 public EntityListener getDefaultEntityListener(String className) { 770 Iterator it = defaultEntityListeners.iterator(); 771 while (it.hasNext()) { 772 EntityListener next = (EntityListener) it.next(); 773 if (className.equals(next.getClassName())) { 774 return next; 775 } 776 } 777 778 return null; 779 } 780 781 784 public Collection getDbEntities() { 785 return Collections.unmodifiableCollection(dbEntityMap.values()); 786 } 787 788 792 public DbEntity getDbEntity(String dbEntityName) { 793 DbEntity entity = (DbEntity) dbEntityMap.get(dbEntityName); 794 795 if (entity != null) { 796 return entity; 797 } 798 799 return namespace != null ? namespace.getDbEntity(dbEntityName) : null; 800 } 801 802 807 public ObjEntity getObjEntityForJavaClass(String javaClassName) { 808 if (javaClassName == null) { 809 return null; 810 } 811 812 Iterator it = getObjEntityMap().entrySet().iterator(); 813 while (it.hasNext()) { 814 Map.Entry entry = (Map.Entry ) it.next(); 815 ObjEntity entity = (ObjEntity) entry.getValue(); 816 if (javaClassName.equals(entity.getClassName())) { 817 return entity; 818 } 819 } 820 821 return null; 822 } 823 824 828 public ObjEntity getObjEntity(String objEntityName) { 829 ObjEntity entity = (ObjEntity) objEntityMap.get(objEntityName); 830 if (entity != null) { 831 return entity; 832 } 833 834 return namespace != null ? namespace.getObjEntity(objEntityName) : null; 835 } 836 837 840 public Collection getMappedEntities(DbEntity dbEntity) { 841 if (dbEntity == null) { 842 return Collections.EMPTY_LIST; 843 } 844 845 Collection allEntities = (namespace != null) 846 ? namespace.getObjEntities() 847 : getObjEntities(); 848 849 if (allEntities.isEmpty()) { 850 return Collections.EMPTY_LIST; 851 } 852 853 Collection result = new ArrayList (); 854 Iterator iter = allEntities.iterator(); 855 while (iter.hasNext()) { 856 ObjEntity objEnt = (ObjEntity) iter.next(); 857 if (objEnt.getDbEntity() == dbEntity) { 858 result.add(objEnt); 859 } 860 } 861 862 return result; 863 } 864 865 870 public void removeEmbeddable(String className) { 871 embeddablesMap.remove(className); 873 } 874 875 878 public void removeDbEntity(String dbEntityName) { 879 removeDbEntity(dbEntityName, false); 880 } 881 882 889 public void removeDbEntity(String dbEntityName, boolean clearDependencies) { 890 DbEntity dbEntityToDelete = (DbEntity) dbEntityMap.remove(dbEntityName); 891 892 if (dbEntityToDelete != null && clearDependencies) { 893 Iterator dbEnts = this.getDbEntities().iterator(); 894 while (dbEnts.hasNext()) { 895 DbEntity dbEnt = (DbEntity) dbEnts.next(); 896 Iterator rels = new ArrayList (dbEnt.getRelationships()).iterator(); 898 while (rels.hasNext()) { 899 DbRelationship rel = (DbRelationship) rels.next(); 900 if (dbEntityName.equals(rel.getTargetEntityName())) { 901 dbEnt.removeRelationship(rel.getName()); 902 } 903 } 904 } 905 906 Iterator objEnts = this.getObjEntities().iterator(); 908 while (objEnts.hasNext()) { 909 ObjEntity objEnt = (ObjEntity) objEnts.next(); 910 if (objEnt.getDbEntity() == dbEntityToDelete) { 911 objEnt.clearDbMapping(); 912 } 913 else { 914 Iterator iter = objEnt.getRelationships().iterator(); 915 while (iter.hasNext()) { 916 ObjRelationship rel = (ObjRelationship) iter.next(); 917 Iterator dbRels = rel.getDbRelationships().iterator(); 918 while (dbRels.hasNext()) { 919 DbRelationship dbRel = (DbRelationship) dbRels.next(); 920 if (dbRel.getTargetEntity() == dbEntityToDelete) { 921 rel.clearDbRelationships(); 922 break; 923 } 924 } 925 } 926 } 927 } 928 } 929 } 930 931 934 public void removeObjEntity(String objEntityName) { 935 removeObjEntity(objEntityName, false); 936 } 937 938 944 public void removeObjEntity(String objEntityName, boolean clearDependencies) { 945 ObjEntity entity = (ObjEntity) objEntityMap.remove(objEntityName); 946 947 if (entity != null && clearDependencies) { 948 949 Iterator entities = getObjEntities().iterator(); 951 while (entities.hasNext()) { 952 ObjEntity ent = (ObjEntity) entities.next(); 953 Iterator rels = new ArrayList (ent.getRelationships()).iterator(); 955 while (rels.hasNext()) { 956 ObjRelationship rel = (ObjRelationship) rels.next(); 957 if (objEntityName.equals(rel.getTargetEntityName()) 958 || objEntityName.equals(rel.getTargetEntityName())) { 959 ent.removeRelationship(rel.getName()); 960 } 961 } 962 } 963 } 964 } 965 966 969 public Collection getProcedures() { 970 return Collections.unmodifiableCollection(procedureMap.values()); 971 } 972 973 977 public Procedure getProcedure(String procedureName) { 978 Procedure procedure = (Procedure) procedureMap.get(procedureName); 979 if (procedure != null) { 980 return procedure; 981 } 982 983 return namespace != null ? namespace.getProcedure(procedureName) : null; 984 } 985 986 990 public void addProcedure(Procedure procedure) { 991 if (procedure.getName() == null) { 992 throw new NullPointerException ("Attempt to add procedure with no name."); 993 } 994 995 Object existingProcedure = procedureMap.get(procedure.getName()); 998 if (existingProcedure != null) { 999 if (existingProcedure == procedure) { 1000 return; 1001 } 1002 else { 1003 throw new IllegalArgumentException ("An attempt to override procedure '" 1004 + procedure.getName()); 1005 } 1006 } 1007 1008 procedureMap.put(procedure.getName(), procedure); 1009 procedure.setDataMap(this); 1010 } 1011 1012 public void removeProcedure(String name) { 1013 procedureMap.remove(name); 1014 } 1015 1016 1019 public SortedMap getProcedureMap() { 1020 return Collections.unmodifiableSortedMap(procedureMap); 1021 } 1022 1023 1029 public MappingNamespace getNamespace() { 1030 return namespace; 1031 } 1032 1033 1039 public void setNamespace(MappingNamespace namespace) { 1040 this.namespace = namespace; 1041 } 1042 1043 1046 public int getDefaultLockType() { 1047 return defaultLockType; 1048 } 1049 1050 1053 public void setDefaultLockType(int defaultLockType) { 1054 this.defaultLockType = defaultLockType; 1055 } 1056 1057 1060 public boolean isClientSupported() { 1061 return clientSupported; 1062 } 1063 1064 1067 public void setClientSupported(boolean clientSupport) { 1068 this.clientSupported = clientSupport; 1069 } 1070 1071 1076 public String getDefaultClientPackage() { 1077 return defaultClientPackage; 1078 } 1079 1080 1083 public void setDefaultClientPackage(String defaultClientPackage) { 1084 this.defaultClientPackage = defaultClientPackage; 1085 } 1086 1087 1090 public String getDefaultPackage() { 1091 return defaultPackage; 1092 } 1093 1094 1097 public void setDefaultPackage(String defaultPackage) { 1098 this.defaultPackage = defaultPackage; 1099 } 1100 1101 1104 public String getDefaultSchema() { 1105 return defaultSchema; 1106 } 1107 1108 1111 public void setDefaultSchema(String defaultSchema) { 1112 this.defaultSchema = defaultSchema; 1113 } 1114 1115 1118 public String getDefaultSuperclass() { 1119 return defaultSuperclass; 1120 } 1121 1122 1125 public void setDefaultSuperclass(String defaultSuperclass) { 1126 this.defaultSuperclass = defaultSuperclass; 1127 } 1128 1129 1136 public void dbEntityChanged(EntityEvent e) { 1137 Entity entity = e.getEntity(); 1138 if (entity instanceof DbEntity) { 1139 ((DbEntity) entity).dbEntityChanged(e); 1140 1141 if (e.isNameChange()) { 1144 dbEntityMap.remove(e.getOldName()); 1146 1147 dbEntityMap.put(e.getNewName(), entity); 1149 1150 MappingNamespace ns = getNamespace(); 1152 if (ns instanceof EntityResolver) { 1153 ((EntityResolver) ns).clearCache(); 1154 } 1155 } 1156 } 1157 } 1158 1159 1160 public void dbEntityAdded(EntityEvent e) { 1161 } 1163 1164 1165 public void dbEntityRemoved(EntityEvent e) { 1166 } 1168 1169 1170 public void dbAttributeChanged(AttributeEvent e) { 1171 Entity entity = e.getEntity(); 1172 if (entity instanceof DbEntity) { 1173 ((DbEntity) entity).dbAttributeChanged(e); 1174 } 1175 } 1176 1177 1178 public void dbAttributeAdded(AttributeEvent e) { 1179 } 1181 1182 1183 public void dbAttributeRemoved(AttributeEvent e) { 1184 } 1186 1187 1188 public void dbRelationshipChanged(RelationshipEvent e) { 1189 Entity entity = e.getEntity(); 1190 if (entity instanceof DbEntity) { 1191 ((DbEntity) entity).dbRelationshipChanged(e); 1192 } 1193 } 1194 1195 1196 public void dbRelationshipAdded(RelationshipEvent e) { 1197 } 1199 1200 1201 public void dbRelationshipRemoved(RelationshipEvent e) { 1202 } 1204 1205 1212 public void objEntityChanged(EntityEvent e) { 1213 Entity entity = e.getEntity(); 1214 if (entity instanceof ObjEntity) { 1215 ((ObjEntity) entity).objEntityChanged(e); 1216 1217 if (e.isNameChange()) { 1220 objEntityMap.remove(e.getOldName()); 1222 1223 objEntityMap.put(e.getNewName(), entity); 1225 1226 MappingNamespace ns = getNamespace(); 1228 if (ns instanceof EntityResolver) { 1229 ((EntityResolver) ns).clearCache(); 1230 } 1231 } 1232 } 1233 } 1234 1235 1236 public void objEntityAdded(EntityEvent e) { 1237 } 1239 1240 1241 public void objEntityRemoved(EntityEvent e) { 1242 } 1244 1245 1246 public void objAttributeChanged(AttributeEvent e) { 1247 } 1249 1250 1251 public void objAttributeAdded(AttributeEvent e) { 1252 } 1254 1255 1256 public void objAttributeRemoved(AttributeEvent e) { 1257 } 1259 1260 1261 public void objRelationshipChanged(RelationshipEvent e) { 1262 } 1264 1265 1266 public void objRelationshipAdded(RelationshipEvent e) { 1267 } 1269 1270 1271 public void objRelationshipRemoved(RelationshipEvent e) { 1272 } 1274} 1275 | Popular Tags |