1 19 20 package org.netbeans.modules.j2ee.persistence.entitygenerator; 21 22 import java.util.Arrays ; 23 import java.util.HashMap ; 24 import java.util.Iterator ; 25 import java.util.List ; 26 import java.util.Map ; 27 28 33 public class CMPMappingModel { 34 private Map cmpFieldMapping; 35 private Map cmrFieldMapping; 36 private String tableName; 37 private Map cmrJoinMapping; 38 private Map <String , JoinTableColumnMapping> joinTableColumnMappings; 39 40 public CMPMappingModel() { 41 cmpFieldMapping = new HashMap (); 42 cmrFieldMapping = new HashMap (); 43 cmrJoinMapping = new HashMap (); 44 joinTableColumnMappings = new HashMap (); 45 } 46 47 public void setTableName(String tableName) { 48 this.tableName = tableName; 49 } 50 51 public String getTableName() { 52 return tableName; 53 } 54 55 public Map getCMPFieldMapping() { 56 return cmpFieldMapping; 57 } 58 59 public void setCMPFieldMapping(Map m) { 60 cmpFieldMapping = m; 61 } 62 63 public Map getCmrFieldMapping() { 64 return cmrFieldMapping; 65 } 66 67 public void setCmrFieldMapping(Map m) { 68 cmrFieldMapping = m; 69 } 70 71 public Map getJoinTableMapping() { 72 return cmrJoinMapping; 73 } 74 75 public void setJoinTableMapping(Map m) { 76 cmrJoinMapping = m; 77 } 78 79 public static class JoinTableColumnMapping { 80 private String [] columns; 81 private String [] referencedColumns; 82 private String [] inverseColumns; 83 private String [] referencedInverseColumns; 84 85 public String [] getColumns() { 86 return columns; 87 } 88 89 public void setColumns(String [] columns) { 90 this.columns = columns; 91 } 92 93 public String [] getReferencedColumns() { 94 return referencedColumns; 95 } 96 97 public void setReferencedColumns(String [] referencedColumns) { 98 this.referencedColumns = referencedColumns; 99 } 100 101 public String [] getInverseColumns() { 102 return inverseColumns; 103 } 104 105 public void setInverseColumns(String [] inverseColumns) { 106 this.inverseColumns = inverseColumns; 107 } 108 109 public String [] getReferencedInverseColumns() { 110 return referencedInverseColumns; 111 } 112 113 public void setReferencedInverseColumns(String [] referencedInverseColumns) { 114 this.referencedInverseColumns = referencedInverseColumns; 115 } 116 } 117 118 public Map <String , JoinTableColumnMapping> getJoinTableColumnMppings() { 119 return joinTableColumnMappings; 120 } 121 122 public void setJoiTableColumnMppings(Map <String , JoinTableColumnMapping> joinTableColumnMppings) { 123 this.joinTableColumnMappings = joinTableColumnMppings; 124 } 125 126 public int hashCode() { 127 return tableName.hashCode(); 128 } 129 130 public boolean equals(Object o) { 131 if (! (o instanceof CMPMappingModel)) { 132 return false; 133 } 134 135 CMPMappingModel other = (CMPMappingModel)o; 136 137 if (cmrFieldMapping.size() != other.cmrFieldMapping.size()) { 138 return false; 139 } 140 141 Iterator keyIt = cmrFieldMapping.keySet().iterator(); 142 while (keyIt.hasNext()) { 143 String key = (String ) keyIt.next(); 144 String [] value = (String []) cmrFieldMapping.get(key); 145 List l = Arrays.asList(value); 146 Object otherValue = other.cmrFieldMapping.get(key); 147 if (otherValue == null || 148 !l.equals(Arrays.asList((String [])other.cmrFieldMapping.get(key)))) { 149 return false; 150 } 151 } 152 153 return tableName.equals(other.tableName) && 154 cmrJoinMapping.equals(other.cmrJoinMapping) && 155 cmpFieldMapping.equals(other.cmpFieldMapping); 156 } 157 158 } 159 | Popular Tags |