HHH-5276 - Refactoring
This commit is contained in:
parent
ac49a906e8
commit
86c15fd212
|
@ -83,10 +83,10 @@ public class AuditConfiguration {
|
||||||
Properties properties = cfg.getProperties();
|
Properties properties = cfg.getProperties();
|
||||||
|
|
||||||
ReflectionManager reflectionManager = cfg.getReflectionManager();
|
ReflectionManager reflectionManager = cfg.getReflectionManager();
|
||||||
RevisionInfoConfiguration revInfoCfg = new RevisionInfoConfiguration();
|
globalCfg = new GlobalConfiguration(properties);
|
||||||
|
RevisionInfoConfiguration revInfoCfg = new RevisionInfoConfiguration(globalCfg);
|
||||||
RevisionInfoConfigurationResult revInfoCfgResult = revInfoCfg.configure(cfg, reflectionManager);
|
RevisionInfoConfigurationResult revInfoCfgResult = revInfoCfg.configure(cfg, reflectionManager);
|
||||||
auditEntCfg = new AuditEntitiesConfiguration(properties, revInfoCfgResult.getRevisionInfoEntityName());
|
auditEntCfg = new AuditEntitiesConfiguration(properties, revInfoCfgResult.getRevisionInfoEntityName());
|
||||||
globalCfg = new GlobalConfiguration(properties);
|
|
||||||
auditProcessManager = new AuditProcessManager(revInfoCfgResult.getRevisionInfoGenerator());
|
auditProcessManager = new AuditProcessManager(revInfoCfgResult.getRevisionInfoGenerator());
|
||||||
revisionInfoQueryCreator = revInfoCfgResult.getRevisionInfoQueryCreator();
|
revisionInfoQueryCreator = revInfoCfgResult.getRevisionInfoQueryCreator();
|
||||||
revisionInfoNumberReader = revInfoCfgResult.getRevisionInfoNumberReader();
|
revisionInfoNumberReader = revInfoCfgResult.getRevisionInfoNumberReader();
|
||||||
|
|
|
@ -59,11 +59,13 @@ public class RevisionInfoConfiguration {
|
||||||
private PropertyData revisionInfoIdData;
|
private PropertyData revisionInfoIdData;
|
||||||
private PropertyData revisionInfoTimestampData;
|
private PropertyData revisionInfoTimestampData;
|
||||||
private Type revisionInfoTimestampType;
|
private Type revisionInfoTimestampType;
|
||||||
|
private GlobalConfiguration globalCfg;
|
||||||
|
|
||||||
private String revisionPropType;
|
private String revisionPropType;
|
||||||
private String revisionPropSqlType;
|
private String revisionPropSqlType;
|
||||||
|
|
||||||
public RevisionInfoConfiguration() {
|
public RevisionInfoConfiguration(GlobalConfiguration globalCfg) {
|
||||||
|
this.globalCfg = globalCfg;
|
||||||
revisionInfoEntityName = "org.hibernate.envers.DefaultRevisionEntity";
|
revisionInfoEntityName = "org.hibernate.envers.DefaultRevisionEntity";
|
||||||
revisionInfoIdData = new PropertyData("id", "id", "field", null);
|
revisionInfoIdData = new PropertyData("id", "id", "field", null);
|
||||||
revisionInfoTimestampData = new PropertyData("timestamp", "timestamp", "field", null);
|
revisionInfoTimestampData = new PropertyData("timestamp", "timestamp", "field", null);
|
||||||
|
@ -72,10 +74,10 @@ public class RevisionInfoConfiguration {
|
||||||
revisionPropType = "integer";
|
revisionPropType = "integer";
|
||||||
}
|
}
|
||||||
|
|
||||||
private Document generateDefaultRevisionInfoXmlMapping(Configuration cfg) {
|
private Document generateDefaultRevisionInfoXmlMapping() {
|
||||||
Document document = DocumentHelper.createDocument();
|
Document document = DocumentHelper.createDocument();
|
||||||
|
|
||||||
Element class_mapping = MetadataTools.createEntity(document, new AuditTableData(null, null, cfg.getProperty("org.hibernate.envers.default_schema"), cfg.getProperty("org.hibernate.envers.default_catalog")), null);
|
Element class_mapping = MetadataTools.createEntity(document, new AuditTableData(null, null, globalCfg.getDefaultSchemaName(), globalCfg.getDefaultCatalogName()), null);
|
||||||
|
|
||||||
class_mapping.addAttribute("name", revisionInfoEntityName);
|
class_mapping.addAttribute("name", revisionInfoEntityName);
|
||||||
class_mapping.addAttribute("table", "REVINFO");
|
class_mapping.addAttribute("table", "REVINFO");
|
||||||
|
@ -236,7 +238,7 @@ public class RevisionInfoConfiguration {
|
||||||
revisionInfoClass = DefaultRevisionEntity.class;
|
revisionInfoClass = DefaultRevisionEntity.class;
|
||||||
revisionInfoGenerator = new DefaultRevisionInfoGenerator(revisionInfoEntityName, revisionInfoClass,
|
revisionInfoGenerator = new DefaultRevisionInfoGenerator(revisionInfoEntityName, revisionInfoClass,
|
||||||
RevisionListener.class, revisionInfoTimestampData, isTimestampAsDate());
|
RevisionListener.class, revisionInfoTimestampData, isTimestampAsDate());
|
||||||
revisionInfoXmlMapping = generateDefaultRevisionInfoXmlMapping(cfg);
|
revisionInfoXmlMapping = generateDefaultRevisionInfoXmlMapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RevisionInfoConfigurationResult(
|
return new RevisionInfoConfigurationResult(
|
||||||
|
|
Loading…
Reference in New Issue