Commits

tbrugz committed 8841a75

dbmodel: Index: added getters/setters

Comments (0)

Files changed (7)

src/tbrugz/sqldump/JDBCSchemaGrabber.java

 				idx = new Index();
 				idx.setName(idxName);
 				boolean bNonUnique = indexesrs.getBoolean("NON_UNIQUE");
-				idx.unique = !bNonUnique;
+				idx.setUnique(!bNonUnique);
 				
 				idx.setSchemaName( indexesrs.getString("TABLE_SCHEM") );
-				idx.tableName = indexesrs.getString("TABLE_NAME");
+				idx.setTableName( indexesrs.getString("TABLE_NAME") );
 				String catName = indexesrs.getString("TABLE_CAT");
 
 				//for MySQL
 				if(idx.getSchemaName()==null && catName!=null) { idx.setSchemaName( catName ); }
 				if(idx.getName().equals("PRIMARY")) {
-					idx.setName( SQLUtils.newNameFromTableName(idx.tableName, SQLUtils.pkiNamePattern) );
+					idx.setName( SQLUtils.newNameFromTableName(idx.getTableName(), SQLUtils.pkiNamePattern) );
 				}
 				
 			}
-			idx.columns.add(indexesrs.getString("COLUMN_NAME"));
+			idx.getColumns().add(indexesrs.getString("COLUMN_NAME"));
 		}
 		if(idx!=null) {
 			indexes.add(idx);

src/tbrugz/sqldump/SchemaModelScriptDumper.java

 						log.warn("index null? table: "+table);
 						continue;
 					}
-					if(table.getName().equals(idx.tableName)) {
-						categorizedOut(idx.getSchemaName(), idx.tableName, DBObjectType.TABLE, idx.getDefinition(dumpWithSchemaName)+";\n");
+					if(table.getName().equals(idx.getTableName())) {
+						categorizedOut(idx.getSchemaName(), idx.getTableName(), DBObjectType.TABLE, idx.getDefinition(dumpWithSchemaName)+";\n");
 					}
 				}
 			}

src/tbrugz/sqldump/dbmodel/Index.java

 		}
 	}
 	
-	public boolean unique;
-	public String type;
-	public Boolean reverse;
-	public String tableName; //XXX: Table instead of tableName?
-	public final List<String> columns = new ArrayList<String>();
-	public String comment;
-	public Boolean local;
+	boolean unique;
+	String type;
+	Boolean reverse;
+	String tableName; //XXX: Table instead of tableName?
+	final List<String> columns = new ArrayList<String>();
+	String comment;
+	Boolean local;
 	
 	@Override
 	public String getDefinition(boolean dumpSchemaName) {
 		return comp;
 	}
 
+	public boolean isUnique() {
+		return unique;
+	}
+
+	public void setUnique(boolean unique) {
+		this.unique = unique;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public Boolean getReverse() {
+		return reverse;
+	}
+
+	public void setReverse(Boolean reverse) {
+		this.reverse = reverse;
+	}
+
+	public String getTableName() {
+		return tableName;
+	}
+
+	public void setTableName(String tableName) {
+		this.tableName = tableName;
+	}
+
+	public String getComment() {
+		return comment;
+	}
+
+	public void setComment(String comment) {
+		this.comment = comment;
+	}
+
+	public Boolean getLocal() {
+		return local;
+	}
+
+	public void setLocal(Boolean local) {
+		this.local = local;
+	}
+
+	public List<String> getColumns() {
+		return columns;
+	}
+
 }

src/tbrugz/sqldump/dbmsfeatures/OracleFeatures.java

 				//new object
 				idx = new Index();
 				idx.setName( idxName );
-				idx.unique = rs.getString(3).equals("UNIQUE");
+				idx.setUnique(rs.getString(3).equals("UNIQUE"));
 				idx.setSchemaName(rs.getString(1));
 				setIndexType(idx, rs.getString(4));
-				idx.tableName = rs.getString(5);
+				idx.setTableName(rs.getString(5));
 				if("LOCAL".equals(rs.getString("LOCALITY"))) {
-					idx.local = true;
+					idx.setLocal(true);
 				}
 			}
-			idx.columns.add(rs.getString(6));
+			idx.getColumns().add(rs.getString(6));
 			colCount++;
 		}
 		if(idx!=null) {
 	boolean grabIndexesFromUnkownTables = false;
 	boolean addIndexToModel(SchemaModel model, Index idx) {
 		if(!grabIndexesFromUnkownTables) {
-			Table t = DBIdentifiable.getDBIdentifiableByTypeSchemaAndName(model.getTables(), DBObjectType.TABLE, idx.getSchemaName(), idx.tableName);
+			Table t = DBIdentifiable.getDBIdentifiableByTypeSchemaAndName(model.getTables(), DBObjectType.TABLE, idx.getSchemaName(), idx.getTableName());
 			if(t==null) {
-				log.debug("table '"+idx.getSchemaName()+"."+idx.tableName+"' not found in model, index "+idx.getName()+" won't be grabbed");
+				log.debug("table '"+idx.getSchemaName()+"."+idx.getTableName()+"' not found in model, index "+idx.getName()+" won't be grabbed");
 				return false;
 			}
 		}
 	static void setIndexType(Index idx, String typeStr) {
 		if(typeStr==null) { return; }
 		if(typeStr.equals("NORMAL")) { return; }
-		if(typeStr.equals("BITMAP")) { idx.type = typeStr; return; }
-		if(typeStr.equals("NORMAL/REV")) { idx.reverse = true; return; }
+		if(typeStr.equals("BITMAP")) { idx.setType(typeStr); return; }
+		if(typeStr.equals("NORMAL/REV")) { idx.setReverse(true); return; }
 		//XXX: 'unknown' index types: DOMAIN, FUNCTION-BASED NORMAL, FUNCTION-BASED DOMAIN, IOT - TOP
-		idx.comment = "unknown index type: '"+typeStr+"'";
+		idx.setComment("unknown index type: '"+typeStr+"'");
 	}
 
 	String grabDBSequencesQuery(String schemaPattern) {

src_graphml/tbrugz/sqldump/graph/Schema2GraphML.java

 			StringBuffer sbIndexes = new StringBuffer();
 			for(Index idx: schemaModel.getIndexes()) {
 				//log.debug("idx: "+idx+" / t: "+t.name);
-				if(idx.tableName.equals(t.getName())) {
+				if(idx.getTableName().equals(t.getName())) {
 					sbIndexes.append(idx.getDefinition(false)+"\n");
 					indexCount++;
 				}

src_xtra/tbrugz/sqldump/xtradumpers/AlterSchemaSuggester.java

 				
 				//Index
 				for(Index idx: schemaModel.getIndexes()) {
-					if(! (idx.tableName.equals(fk.getPkTable()) || idx.tableName.equals(fk.getFkTable()))) { continue; }
+					if(! (idx.getTableName().equals(fk.getPkTable()) || idx.getTableName().equals(fk.getFkTable()))) { continue; }
 
 					Set<String> cols = new HashSet<String>();
-					cols.addAll(idx.columns);
-					if(idx.tableName.equals(fk.getPkTable())) {
+					cols.addAll(idx.getColumns());
+					if(idx.getTableName().equals(fk.getPkTable())) {
 						if(stringCollectionEquals(cols,fk.getPkColumns())) { pkTableHasIndex = true; }
 						//if(cols.equals(fk.pkColumns)) { pkTableHasIndex = true; }
 						//log.info("cols["+idx.tableName+"/pkt]: "+cols+" fk.pkCols: "+fk.pkColumns+"; hasI: "+pkTableHasIndex+"/"+stringCollectionEquals(cols, fk.pkColumns));
 					}
-					if(idx.tableName.equals(fk.getFkTable())) { 
+					if(idx.getTableName().equals(fk.getFkTable())) { 
 						if(stringCollectionEquals(cols,fk.getFkColumns())) { fkTableHasIndex = true; }
 						//if(cols.equals(fk.fkColumns)) { fkTableHasIndex = true; }
 						//log.info("cols["+idx.tableName+"/fkt]: "+cols+" fk.fkCols: "+fk.fkColumns+"; hasI: "+fkTableHasIndex+"/"+stringCollectionEquals(cols, fk.fkColumns));
 			
 			if(!pkTableHasIndex && !dumpFKIndexesOnly) {
 				Index idx = new Index();
-				idx.tableName = fk.getPkTable();
+				idx.setTableName(fk.getPkTable());
 				idx.setSchemaName(fk.getPkTableSchemaName());
-				idx.unique = false;
-				idx.columns.addAll(fk.getPkColumns());
-				idx.setName(fk.getPkTable() + "_" + suggestAcronym(idx.columns) + "_UKI"); //_" + (indexes.size()+1);
+				idx.setUnique(false);
+				idx.getColumns().addAll(fk.getPkColumns());
+				idx.setName(fk.getPkTable() + "_" + suggestAcronym(idx.getColumns()) + "_UKI"); //_" + (indexes.size()+1);
 				addIndex(indexes, idx);
 			}
 
 			if(!fkTableHasIndex) {
 				Index idx = new Index();
-				idx.tableName = fk.getFkTable();
+				idx.setTableName(fk.getFkTable());
 				idx.setSchemaName(fk.getFkTableSchemaName());
-				idx.unique = false;
-				idx.columns.addAll(fk.getFkColumns());
-				idx.setName(fk.getFkTable() + "_" + suggestAcronym(idx.columns) + "_FKI");
+				idx.setUnique(false);
+				idx.getColumns().addAll(fk.getFkColumns());
+				idx.setName(fk.getFkTable() + "_" + suggestAcronym(idx.getColumns()) + "_FKI");
 				//idx.name = fk.fkTable + "_FKI";
 				//idx.name = fk.fkTable + "_FKI_" + idx.hashCode();
 				//idx.name = fk.fkTable + "_FKI_" + (++fkIndexCounter);

src_xtra/tbrugz/sqldump/xtraproc/ModelSQLIdTransformer.java

 		}
 		for(Index i: model.getIndexes()) {
 			i.setName( identifierDecorator.get(i.getName()) );
-			i.tableName = identifierDecorator.get( i.tableName );
-			procList(i.columns, identifierDecorator);
+			i.setTableName(identifierDecorator.get( i.getTableName() ));
+			procList(i.getColumns(), identifierDecorator);
 		}
 		log.info("model transformer end: ok");
 	}