1 23 package org.objectweb.jorm.mapper.rdb.generator; 24 25 import org.objectweb.jorm.api.PException; 26 import org.objectweb.jorm.mapper.rdb.metainfo.RdbJoin; 27 28 import java.util.ArrayList ; 29 import java.util.List ; 30 31 35 public class RdbGenJoin { 36 37 public RdbGenTable mainTable = null; 38 public RdbGenTable table = null; 39 public int joinIdx = 0; 40 41 46 public List joinColumnsInMain = null; 47 48 52 public List joinColumnsInExt = null; 53 54 public int getJoinIdx() { 55 return joinIdx; 56 } 57 58 public List getJoinColumnsInMain() { 59 return joinColumnsInMain; 60 } 61 62 public List getJoinColumnsInExt() { 63 return joinColumnsInExt; 64 } 65 66 public RdbGenTable getMainTable() { 67 return mainTable; 68 } 69 70 public RdbGenTable getTable() { 71 return table; 72 } 73 74 public RdbGenJoin(RdbGenTable mainTable, 75 RdbGenTable extTable, 76 RdbJoin j, 77 int idx) throws PException { 78 this.joinIdx = idx; 79 this.table = extTable; 81 this.mainTable = mainTable; 82 List pcns = j.getPTJoinColumnNames(); 84 List ecns = j.getETJoinColumnNames(); 85 joinColumnsInMain = new ArrayList (pcns.size()); 86 joinColumnsInExt = new ArrayList (pcns.size()); 87 for (int i = 0; i < pcns.size(); i++) { 88 String pcn = (String ) pcns.get(i); 89 String ecn = (String ) ecns.get(i); 90 RdbGenColumn pjcol = mainTable.getColumn(pcn); 92 if (pjcol == null) { 93 throw new PException("In the join between tables " 94 + mainTable.tableName + " and " + extTable.tableName + ", " + 95 "the column '" + pcn + "' was not found in extTable " 96 + mainTable.tableName); 97 } 98 joinColumnsInMain.add(pjcol); 99 RdbGenColumn ejcol = extTable.getColumn(ecn); 100 if (ejcol == null) { 101 ejcol = new RdbGenColumn(); 102 ejcol.columnName = ecn; 103 ejcol.joinCol = pjcol; 104 ejcol.columnType = pjcol.columnType; 105 ejcol.columnSqlType = pjcol.columnSqlType; 106 ejcol.table = extTable; 107 ejcol.fieldName = pjcol.fieldName; 108 ejcol.columnNotNull = pjcol.columnNotNull; 109 ejcol.joins = null; 110 ejcol.pes = null; 111 } 112 joinColumnsInExt.add(ejcol); 113 extTable.columns.add(ejcol); 114 } 115 } 116 117 } 118 | Popular Tags |