All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.hibernate.cfg.reveng.RevEngUtils Maven / Gradle / Ivy
package org.hibernate.cfg.reveng;
import java.util.List;
import java.util.Map;
import org.hibernate.mapping.MetaAttribute;
import org.hibernate.mapping.Table;
public class RevEngUtils {
public static List getPrimaryKeyInfoInRevengStrategy(
ReverseEngineeringStrategy revengStrat,
Table table,
String defaultCatalog,
String defaultSchema) {
List result = null;
TableIdentifier tableIdentifier = TableIdentifier.create(table);
result = revengStrat.getPrimaryKeyColumnNames(tableIdentifier);
if (result == null) {
String catalog = getCatalogForModel(table.getCatalog(), defaultCatalog);
String schema = getSchemaForModel(table.getSchema(), defaultSchema);
tableIdentifier = new TableIdentifier(catalog, schema, table.getName());
result = revengStrat.getPrimaryKeyColumnNames(tableIdentifier);
}
return result;
}
public static String getTableIdentifierStrategyNameInRevengStrategy(
ReverseEngineeringStrategy revengStrat,
Table table,
String defaultCatalog,
String defaultSchema) {
String result = null;
TableIdentifier tableIdentifier = TableIdentifier.create(table);
result = revengStrat.getTableIdentifierStrategyName(tableIdentifier);
if (result == null) {
String catalog = getCatalogForModel(table.getCatalog(), defaultCatalog);
String schema = getSchemaForModel(table.getSchema(), defaultSchema);
tableIdentifier = new TableIdentifier(catalog, schema, table.getName());
result = revengStrat.getTableIdentifierStrategyName(tableIdentifier);
}
return result;
}
public static Map getColumnToMetaAttributesInRevengStrategy(
ReverseEngineeringStrategy revengStrat,
Table table,
String defaultCatalog,
String defaultSchema,
String column) {
Map result = null;
TableIdentifier tableIdentifier = TableIdentifier.create(table);
result = revengStrat.columnToMetaAttributes(tableIdentifier, column);
if (result == null) {
String catalog = getCatalogForModel(table.getCatalog(), defaultCatalog);
String schema = getSchemaForModel(table.getSchema(), defaultSchema);
tableIdentifier = new TableIdentifier(catalog, schema, table.getName());
result = revengStrat.columnToMetaAttributes(tableIdentifier, column);
}
return result;
}
public static Map getTableToMetaAttributesInRevengStrategy(
ReverseEngineeringStrategy revengStrat,
Table table,
String defaultCatalog,
String defaultSchema) {
Map result = null;
TableIdentifier tableIdentifier = TableIdentifier.create(table);
result = revengStrat.tableToMetaAttributes(tableIdentifier);
if (result == null) {
String catalog = getCatalogForModel(table.getCatalog(), defaultCatalog);
String schema = getSchemaForModel(table.getSchema(), defaultSchema);
tableIdentifier = new TableIdentifier(catalog, schema, table.getName());
result = revengStrat.tableToMetaAttributes(tableIdentifier);
}
return result;
}
public static String getColumnToPropertyNameInRevengStrategy(
ReverseEngineeringStrategy revengStrat,
Table table,
String defaultCatalog,
String defaultSchema,
String columnName) {
String result = null;
TableIdentifier tableIdentifier = TableIdentifier.create(table);
result = revengStrat.columnToPropertyName(tableIdentifier, columnName);
if (result == null) {
String catalog = getCatalogForModel(table.getCatalog(), defaultCatalog);
String schema = getSchemaForModel(table.getSchema(), defaultSchema);
tableIdentifier = new TableIdentifier(catalog, schema, table.getName());
result = revengStrat.columnToPropertyName(tableIdentifier, columnName);
}
return result;
}
public static TableIdentifier createTableIdentifier(
Table table,
String defaultCatalog,
String defaultSchema) {
String tableName = table.getName();
String tableCatalog = getCatalogForModel(table.getCatalog(), defaultCatalog);
String tableSchema = getSchemaForModel(table.getSchema(), defaultSchema);
return new TableIdentifier(tableCatalog, tableSchema, tableName);
}
/** If catalog is equal to defaultCatalog then we return null so it will be null in the generated code. */
private static String getCatalogForModel(String catalog, String defaultCatalog) {
if(catalog==null) return null;
if(catalog.equals(defaultCatalog)) return null;
return catalog;
}
/** If catalog is equal to defaultSchema then we return null so it will be null in the generated code. */
private static String getSchemaForModel(String schema, String defaultSchema) {
if(schema==null) return null;
if(schema.equals(defaultSchema)) return null;
return schema;
}
}