private readonly Cfg.Configuration _configuration; //for serialization private AuditConfiguration(Cfg.Configuration cfg, IMetaDataProvider metaDataProvider) { //this might be over kill - move back into MetaDataStore later if not needed for other stuff... var metaDataAdders = new List <IMetaDataAdder> { new AuditMappedByMetaDataAdder(cfg) }; var mds = new MetaDataStore(cfg, metaDataProvider, metaDataAdders); var properties = cfg.Properties; GlobalCfg = new GlobalConfiguration(this, properties); var revInfoCfg = new RevisionInfoConfiguration(GlobalCfg, mds); var revInfoCfgResult = revInfoCfg.Configure(cfg); AuditEntCfg = new AuditEntitiesConfiguration(properties, revInfoCfgResult.RevisionInfoEntityName); AuditProcessManager = new AuditProcessManager(revInfoCfgResult.RevisionInfoGenerator); RevisionTimestampGetter = ReflectionTools.GetGetter(revInfoCfgResult.RevisionInfoClass, revInfoCfgResult.RevisionInfoTimestampData); RevisionInfoQueryCreator = revInfoCfgResult.RevisionInfoQueryCreator; RevisionInfoNumberReader = revInfoCfgResult.RevisionInfoNumberReader; ModifiedEntityNamesReader = revInfoCfgResult.ModifiedEntityNamesReader; EntCfg = new EntitiesConfigurator() .Configure(cfg, mds, GlobalCfg, AuditEntCfg, revInfoCfgResult.RevisionInfoXmlMapping, revInfoCfgResult.RevisionInfoRelationMapping); _configuration = cfg; }
public TwoEntityOneAuditedQueryGenerator(AuditEntitiesConfiguration verEntCfg, IAuditStrategy auditStrategy, string versionsMiddleEntityName, MiddleIdData referencingIdData, MiddleIdData referencedIdData, IEnumerable<MiddleComponentData> componentDatas) { this.referencingIdData = referencingIdData; /* * The query that we need to create: * SELECT new list(ee, e) FROM referencedEntity e, middleEntity ee * WHERE * (entities referenced by the middle table; id_ref_ed = id of the referenced entity) * ee.id_ref_ed = e.id_ref_ed AND * (only entities referenced by the association; id_ref_ing = id of the referencing entity) * ee.id_ref_ing = :id_ref_ing AND * * (the association at revision :revision) * --> For DefaultAuditStrategy: * ee.revision = (SELECT max(ee2.revision) FROM middleEntity ee2 * WHERE ee2.revision <= :revision AND ee2.originalId.* = ee.originalId.*) * --> for ValidityAuditStrategy: * ee.revision <= :revision and (ee.endRevision > :revision or ee.endRevision is null) * * AND * * (only non-deleted entities and associations) * ee.revision_type != DEL */ var revisionPropertyPath = verEntCfg.RevisionNumberPath; var originalIdPropertyName = verEntCfg.OriginalIdPropName; var eeOriginalIdPropertyPath = "ee." + originalIdPropertyName; // SELECT new list(ee) FROM middleEntity ee var qb = new QueryBuilder(versionsMiddleEntityName, "ee"); qb.AddFrom(referencedIdData.EntityName, "e"); qb.AddProjection("new list", "ee, e", false, false); // WHERE var rootParameters = qb.RootParameters; // ee.id_ref_ed = e.id_ref_ed referencedIdData.PrefixedMapper.AddIdsEqualToQuery(rootParameters, eeOriginalIdPropertyPath, referencedIdData.OriginalMapper, "e"); // ee.originalId.id_ref_ing = :id_ref_ing referencingIdData.PrefixedMapper.AddNamedIdEqualsToQuery(rootParameters, originalIdPropertyName, true); // (with ee association at revision :revision) // --> based on auditStrategy (see above) auditStrategy.AddAssociationAtRevisionRestriction(qb, revisionPropertyPath, verEntCfg.RevisionEndFieldName, true, referencingIdData, versionsMiddleEntityName, eeOriginalIdPropertyPath, revisionPropertyPath, originalIdPropertyName, componentDatas.ToArray()); // ee.revision_type != DEL rootParameters.AddWhereWithNamedParam(verEntCfg.RevisionTypePropName, "!=", "delrevisiontype"); var sb = new StringBuilder(); qb.Build(sb, null); queryString = sb.ToString(); }
public MiddleIdData(AuditEntitiesConfiguration verEntCfg, IdMappingData mappingData, String prefix, String entityName, bool audited) { this.OriginalMapper = mappingData.IdMapper; this.PrefixedMapper = mappingData.IdMapper.PrefixMappedProperties(prefix); this.EntityName = entityName; this.AuditEntityName = audited ? verEntCfg.GetAuditEntityName(entityName) : null; }
public CommonCollectionMapperData(AuditEntitiesConfiguration verEntCfg, String versionsMiddleEntityName, PropertyData collectionReferencingPropertyData, MiddleIdData referencingIdData, IRelationQueryGenerator queryGenerator) { this._verEntCfg = verEntCfg; this._versionsMiddleEntityName = versionsMiddleEntityName; this._collectionReferencingPropertyData = collectionReferencingPropertyData; this._referencingIdData = referencingIdData; this._queryGenerator = queryGenerator; }
public OneAuditEntityQueryGenerator(GlobalConfiguration globalCfg, AuditEntitiesConfiguration verEntCfg, MiddleIdData referencingIdData, String referencedEntityName, IIdMapper referencedIdMapper) { this.referencingIdData = referencingIdData; /* * The query that we need to create: * SELECT new list(e) FROM versionsReferencedEntity e * WHERE * (only entities referenced by the association; id_ref_ing = id of the referencing entity) * e.id_ref_ing = :id_ref_ing AND * (selecting e entities at revision :revision) * e.revision = (SELECT max(e2.revision) FROM versionsReferencedEntity e2 * WHERE e2.revision <= :revision AND e2.id = e.id) AND * (only non-deleted entities) * e.revision_type != DEL */ String revisionPropertyPath = verEntCfg.RevisionNumberPath; String originalIdPropertyName = verEntCfg.OriginalIdPropName; String versionsReferencedEntityName = verEntCfg.GetAuditEntityName(referencedEntityName); // SELECT new list(e) FROM versionsEntity e QueryBuilder qb = new QueryBuilder(versionsReferencedEntityName, "e"); qb.AddProjection("new list", "e", false, false); // WHERE Parameters rootParameters = qb.RootParameters; // e.id_ref_ed = :id_ref_ed referencingIdData.PrefixedMapper.AddNamedIdEqualsToQuery(rootParameters, null, true); // SELECT max(e.revision) FROM versionsReferencedEntity e2 QueryBuilder maxERevQb = qb.NewSubQueryBuilder(versionsReferencedEntityName, "e2"); maxERevQb.AddProjection("max", revisionPropertyPath, false); // WHERE Parameters maxERevQbParameters = maxERevQb.RootParameters; // e2.revision <= :revision maxERevQbParameters.AddWhereWithNamedParam(revisionPropertyPath, "<=", "revision"); // e2.id = e.id referencedIdMapper.AddIdsEqualToQuery(maxERevQbParameters, "e." + originalIdPropertyName, "e2." + originalIdPropertyName); // e.revision = (SELECT max(...) ...) rootParameters.AddWhere(revisionPropertyPath, false, globalCfg.getCorrelatedSubqueryOperator(), maxERevQb); // e.revision_type != DEL rootParameters.AddWhereWithNamedParam(verEntCfg.RevisionTypePropName, false, "!=", "delrevisiontype"); StringBuilder sb = new StringBuilder(); qb.Build(sb, EmptyDictionary<String, object>.Instance); queryString = sb.ToString(); }
public OneEntityQueryGenerator(AuditEntitiesConfiguration verEntCfg, String versionsMiddleEntityName, MiddleIdData referencingIdData, IEnumerable<MiddleComponentData> componentDatas) { this._referencingIdData = referencingIdData; /* * The query that we need to create: * SELECT new list(ee) FROM middleEntity ee WHERE * (only entities referenced by the association; id_ref_ing = id of the referencing entity) * ee.originalId.id_ref_ing = :id_ref_ing AND * (the association at revision :revision) * ee.revision = (SELECT max(ee2.revision) FROM middleEntity ee2 * WHERE ee2.revision <= :revision AND ee2.originalId.* = ee.originalId.*) AND * (only non-deleted entities and associations) * ee.revision_type != DEL */ String revisionPropertyPath = verEntCfg.RevisionNumberPath; String originalIdPropertyName = verEntCfg.OriginalIdPropName; // SELECT new list(ee) FROM middleEntity ee QueryBuilder qb = new QueryBuilder(versionsMiddleEntityName, "ee"); qb.AddProjection("new list", "ee", false, false); // WHERE Parameters rootParameters = qb.RootParameters; // ee.originalId.id_ref_ing = :id_ref_ing referencingIdData.PrefixedMapper.AddNamedIdEqualsToQuery(rootParameters, originalIdPropertyName, true); // SELECT max(ee2.revision) FROM middleEntity ee2 QueryBuilder maxRevQb = qb.NewSubQueryBuilder(versionsMiddleEntityName, "ee2"); maxRevQb.AddProjection("max", revisionPropertyPath, false); // WHERE Parameters maxRevQbParameters = maxRevQb.RootParameters; // ee2.revision <= :revision maxRevQbParameters.AddWhereWithNamedParam(revisionPropertyPath, "<=", "revision"); // ee2.originalId.* = ee.originalId.* String eeOriginalIdPropertyPath = "ee." + originalIdPropertyName; String ee2OriginalIdPropertyPath = "ee2." + originalIdPropertyName; referencingIdData.PrefixedMapper.AddIdsEqualToQuery(maxRevQbParameters, eeOriginalIdPropertyPath, ee2OriginalIdPropertyPath); foreach (MiddleComponentData componentData in componentDatas) { componentData.ComponentMapper.AddMiddleEqualToQuery(maxRevQbParameters, eeOriginalIdPropertyPath, ee2OriginalIdPropertyPath); } // ee.revision = (SELECT max(...) ...) rootParameters.AddWhere(revisionPropertyPath, "=", maxRevQb); // ee.revision_type != DEL rootParameters.AddWhereWithNamedParam(verEntCfg.RevisionTypePropName, "!=", "delrevisiontype"); StringBuilder sb = new StringBuilder(); qb.Build(sb, EmptyDictionary<String, object>.Instance); _queryString = sb.ToString(); }
public TwoEntityOneAuditedQueryGenerator( AuditEntitiesConfiguration verEntCfg, String versionsMiddleEntityName, MiddleIdData referencingIdData, MiddleIdData referencedIdData, IEnumerable<MiddleComponentData> componentDatas) { this.referencingIdData = referencingIdData; /* * The query that we need to create: * SELECT new list(ee, e) FROM referencedEntity e, middleEntity ee * WHERE * (entities referenced by the middle table; id_ref_ed = id of the referenced entity) * ee.id_ref_ed = e.id_ref_ed AND * (only entities referenced by the association; id_ref_ing = id of the referencing entity) * ee.id_ref_ing = :id_ref_ing AND * (the association at revision :revision) * ee.revision = (SELECT max(ee2.revision) FROM middleEntity ee2 * WHERE ee2.revision <= :revision AND ee2.originalId.* = ee.originalId.*) AND * (only non-deleted entities and associations) * ee.revision_type != DEL */ String revisionPropertyPath = verEntCfg.RevisionNumberPath; String originalIdPropertyName = verEntCfg.OriginalIdPropName; String eeOriginalIdPropertyPath = "ee." + originalIdPropertyName; // SELECT new list(ee) FROM middleEntity ee QueryBuilder qb = new QueryBuilder(versionsMiddleEntityName, "ee"); qb.AddFrom(referencedIdData.EntityName, "e"); qb.AddProjection("new list", "ee, e", false, false); // WHERE Parameters rootParameters = qb.RootParameters; // ee.id_ref_ed = e.id_ref_ed referencedIdData.PrefixedMapper.AddIdsEqualToQuery(rootParameters, eeOriginalIdPropertyPath, referencedIdData.OriginalMapper, "e"); // ee.originalId.id_ref_ing = :id_ref_ing referencingIdData.PrefixedMapper.AddNamedIdEqualsToQuery(rootParameters, originalIdPropertyName, true); // ee.revision = (SELECT max(...) ...) QueryGeneratorTools.AddAssociationAtRevision(qb, rootParameters, referencingIdData, versionsMiddleEntityName, eeOriginalIdPropertyPath, revisionPropertyPath, originalIdPropertyName, componentDatas); // ee.revision_type != DEL rootParameters.AddWhereWithNamedParam(verEntCfg.RevisionTypePropName, "!=", "delrevisiontype"); StringBuilder sb = new StringBuilder(); qb.Build(sb, EmptyDictionary<String, Object>.Instance); queryString = sb.ToString(); }
//public AuditEntitiesConfiguration getAuditEntCfg() { // return auditEntCfg; //} //public AuditSyncManager getSyncManager() { // return auditSyncManager; //} //public GlobalConfiguration getGlobalCfg() { // return globalCfg; //} //public EntitiesConfigurations getEntCfg() { // return entCfg; //} //public RevisionInfoQueryCreator getRevisionInfoQueryCreator() { // return revisionInfoQueryCreator; //} //public RevisionInfoNumberReader getRevisionInfoNumberReader() { // return revisionInfoNumberReader; //} //TODO Simon @SuppressWarnings({"unchecked"}) public AuditConfiguration(NHibernate.Cfg.Configuration cfg) { IDictionary<string,string> properties = cfg.Properties; //ReflectionManager reflectionManager = ((AnnotationConfiguration) cfg).getReflectionManager(); RevisionInfoConfiguration revInfoCfg = new RevisionInfoConfiguration(); RevisionInfoConfigurationResult revInfoCfgResult = revInfoCfg.configure(cfg); AuditEntCfg = new AuditEntitiesConfiguration(properties, revInfoCfgResult.RevisionInfoEntityName); GlobalCfg = new GlobalConfiguration(properties); AuditSyncManager = new AuditSyncManager(revInfoCfgResult.RevisionInfoGenerator); RevisionInfoQueryCreator = revInfoCfgResult.RevisionInfoQueryCreator; RevisionInfoNumberReader = revInfoCfgResult.RevisionInfoNumberReader; EntCfg = new EntitiesConfigurator().Configure(cfg, GlobalCfg, AuditEntCfg, revInfoCfgResult.RevisionInfoXmlMapping, revInfoCfgResult.RevisionInfoRelationMapping); }
//public AuditEntitiesConfiguration getAuditEntCfg() { // return auditEntCfg; //} //public AuditSyncManager getSyncManager() { // return auditSyncManager; //} //public GlobalConfiguration getGlobalCfg() { // return globalCfg; //} //public EntitiesConfigurations getEntCfg() { // return entCfg; //} //public RevisionInfoQueryCreator getRevisionInfoQueryCreator() { // return revisionInfoQueryCreator; //} //public RevisionInfoNumberReader getRevisionInfoNumberReader() { // return revisionInfoNumberReader; //} //TODO Simon @SuppressWarnings({"unchecked"}) public AuditConfiguration(NHibernate.Cfg.Configuration cfg) { IDictionary <string, string> properties = cfg.Properties; //ReflectionManager reflectionManager = ((AnnotationConfiguration) cfg).getReflectionManager(); RevisionInfoConfiguration revInfoCfg = new RevisionInfoConfiguration(); RevisionInfoConfigurationResult revInfoCfgResult = revInfoCfg.configure(cfg); AuditEntCfg = new AuditEntitiesConfiguration(properties, revInfoCfgResult.RevisionInfoEntityName); GlobalCfg = new GlobalConfiguration(properties); AuditSyncManager = new AuditSyncManager(revInfoCfgResult.RevisionInfoGenerator); RevisionInfoQueryCreator = revInfoCfgResult.RevisionInfoQueryCreator; RevisionInfoNumberReader = revInfoCfgResult.RevisionInfoNumberReader; EntCfg = new EntitiesConfigurator().Configure(cfg, GlobalCfg, AuditEntCfg, revInfoCfgResult.RevisionInfoXmlMapping, revInfoCfgResult.RevisionInfoRelationMapping); }
public MiddleMapKeyIdComponentMapper(AuditEntitiesConfiguration verEntCfg, IIdMapper relatedIdMapper) { this.verEntCfg = verEntCfg; this.relatedIdMapper = relatedIdMapper; }
public EntitiesConfigurations Configure(Cfg.Configuration cfg, IMetaDataStore metaDataStore, GlobalConfiguration globalCfg, AuditEntitiesConfiguration verEntCfg, XDocument revisionInfoXmlMapping, XElement revisionInfoRelationMapping) { // Creating a name register to capture all audit entity names created. var auditEntityNameRegister = new AuditEntityNameRegister(); // Sorting the persistent class topologically - superclass always before subclass var classes = GraphTopologicalSort.Sort(new PersistentClassGraphDefiner(cfg)); var classesAuditingData = new ClassesAuditingData(); var xmlMappings = new Dictionary <PersistentClass, EntityXmlMappingData>(); // Reading metadata from annotations foreach (var pc in classes) { // Collecting information from annotations on the persistent class pc var annotationsMetadataReader = new AnnotationsMetadataReader(metaDataStore, globalCfg, pc); var auditData = annotationsMetadataReader.GetAuditData(); classesAuditingData.AddClassAuditingData(pc, auditData); } // Now that all information is read we can update the calculated fields. classesAuditingData.UpdateCalculatedFields(); var auditMetaGen = new AuditMetadataGenerator(metaDataStore, cfg, globalCfg, verEntCfg, revisionInfoRelationMapping, auditEntityNameRegister); // First pass foreach (var pcDatasEntry in classesAuditingData.AllClassAuditedData) { var pc = pcDatasEntry.Key; var auditData = pcDatasEntry.Value; var xmlMappingData = new EntityXmlMappingData(); if (auditData.IsAudited()) { if (!string.IsNullOrEmpty(auditData.AuditTable.Value)) { verEntCfg.AddCustomAuditTableName(pc.EntityName, auditData.AuditTable.Value); } auditMetaGen.GenerateFirstPass(pc, auditData, xmlMappingData, true); } else { auditMetaGen.GenerateFirstPass(pc, auditData, xmlMappingData, false); } xmlMappings.Add(pc, xmlMappingData); } // Second pass foreach (var pcDatasEntry in classesAuditingData.AllClassAuditedData) { var xmlMappingData = xmlMappings[pcDatasEntry.Key]; if (pcDatasEntry.Value.IsAudited()) { auditMetaGen.GenerateSecondPass(pcDatasEntry.Key, pcDatasEntry.Value, xmlMappingData); cfg.AddXml(xmlMappingData.MainXmlMapping.ToString()); foreach (var additionalMapping in xmlMappingData.AdditionalXmlMappings) { cfg.AddXml(additionalMapping.ToString()); } } } // Only if there are any versioned classes if (auditMetaGen.EntitiesConfigurations.Count > 0) { if (revisionInfoXmlMapping != null) { cfg.AddXml(revisionInfoXmlMapping.ToString()); } } return(new EntitiesConfigurations(auditMetaGen.EntitiesConfigurations, auditMetaGen.NotAuditedEntitiesConfigurations)); }
public EntitiesConfigurations Configure(NHibernate.Cfg.Configuration cfg, GlobalConfiguration globalCfg, AuditEntitiesConfiguration verEntCfg, XmlDocument revisionInfoXmlMapping, XmlElement revisionInfoRelationMapping) { // Creating a name register to capture all audit entity names created. AuditEntityNameRegister auditEntityNameRegister = new AuditEntityNameRegister(); //XmlWriter writer = new XmlTextWriter(.. // Sorting the persistent class topologically - superclass always before subclass IEnumerator<PersistentClass> classes = GraphTopologicalSort.Sort<PersistentClass, String>(new PersistentClassGraphDefiner(cfg)).GetEnumerator(); ClassesAuditingData classesAuditingData = new ClassesAuditingData(); IDictionary<PersistentClass, EntityXmlMappingData> xmlMappings = new Dictionary<PersistentClass, EntityXmlMappingData>(); // Reading metadata from annotations while (classes.MoveNext()) { PersistentClass pc = classes.Current; // Collecting information from annotations on the persistent class pc AnnotationsMetadataReader annotationsMetadataReader = new AnnotationsMetadataReader(globalCfg, pc); ClassAuditingData auditData = annotationsMetadataReader.AuditData; classesAuditingData.AddClassAuditingData(pc, auditData); } // Now that all information is read we can update the calculated fields. classesAuditingData.UpdateCalculatedFields(); AuditMetadataGenerator auditMetaGen = new AuditMetadataGenerator(cfg, globalCfg, verEntCfg, revisionInfoRelationMapping, auditEntityNameRegister, classesAuditingData); // First pass foreach (KeyValuePair<PersistentClass, ClassAuditingData> pcDatasEntry in classesAuditingData.GetAllClassAuditedData()) { PersistentClass pc = pcDatasEntry.Key; ClassAuditingData auditData = pcDatasEntry.Value; EntityXmlMappingData xmlMappingData = new EntityXmlMappingData(); if (auditData.IsAudited()) { if (!String.IsNullOrEmpty(auditData.AuditTable.value)){ // .getAuditTable().value())) { verEntCfg.AddCustomAuditTableName(pc.EntityName, auditData.AuditTable.value); } auditMetaGen.GenerateFirstPass(pc, auditData, xmlMappingData, true); } else { auditMetaGen.GenerateFirstPass(pc, auditData, xmlMappingData, false); } xmlMappings.Add(pc, xmlMappingData); } // Second pass foreach (KeyValuePair<PersistentClass, ClassAuditingData> pcDatasEntry in classesAuditingData.GetAllClassAuditedData()) { EntityXmlMappingData xmlMappingData = xmlMappings[pcDatasEntry.Key]; if (pcDatasEntry.Value.IsAudited()) { auditMetaGen.GenerateSecondPass(pcDatasEntry.Key, pcDatasEntry.Value, xmlMappingData); try { //cfg.AddDocument(writer.write(xmlMappingData.MainXmlMapping)); cfg.AddDocument(xmlMappingData.MainXmlMapping); //WriteDocument(xmlMappingData.getMainXmlMapping()); foreach (XmlDocument additionalMapping in xmlMappingData.AdditionalXmlMappings) { //cfg.AddDocument(writer.write(additionalMapping)); cfg.AddDocument(additionalMapping); //WriteDocument(additionalMapping); } } catch (MappingException e) { //catch (DocumentException e) { //?Catalina DocumentException NOT IMPLEMENTED throw new MappingException(e); } } } // Only if there are any versioned classes if (classesAuditingData.GetAllClassAuditedData().Count > 0) { try { if (revisionInfoXmlMapping != null) { //WriteDocument(revisionInfoXmlMapping); //cfg.addDocument(writer.write(revisionInfoXmlMapping)); cfg.AddDocument((revisionInfoXmlMapping)); } } catch (MappingException e) { //catch (DocumentException e) { //?Catalina throw new MappingException(e); } } return new EntitiesConfigurations(auditMetaGen.EntitiesConfigurations, auditMetaGen.NotAuditedEntitiesConfigurations); }
public EntitiesConfigurations Configure(NHibernate.Cfg.Configuration cfg, GlobalConfiguration globalCfg, AuditEntitiesConfiguration verEntCfg, XmlDocument revisionInfoXmlMapping, XmlElement revisionInfoRelationMapping) { // Creating a name register to capture all audit entity names created. AuditEntityNameRegister auditEntityNameRegister = new AuditEntityNameRegister(); //XmlWriter writer = new XmlTextWriter(.. // Sorting the persistent class topologically - superclass always before subclass IEnumerator <PersistentClass> classes = GraphTopologicalSort.Sort <PersistentClass, String>(new PersistentClassGraphDefiner(cfg)).GetEnumerator(); ClassesAuditingData classesAuditingData = new ClassesAuditingData(); IDictionary <PersistentClass, EntityXmlMappingData> xmlMappings = new Dictionary <PersistentClass, EntityXmlMappingData>(); // Reading metadata from annotations while (classes.MoveNext()) { PersistentClass pc = classes.Current; // Collecting information from annotations on the persistent class pc AnnotationsMetadataReader annotationsMetadataReader = new AnnotationsMetadataReader(globalCfg, pc); ClassAuditingData auditData = annotationsMetadataReader.AuditData; classesAuditingData.AddClassAuditingData(pc, auditData); } // Now that all information is read we can update the calculated fields. classesAuditingData.UpdateCalculatedFields(); AuditMetadataGenerator auditMetaGen = new AuditMetadataGenerator(cfg, globalCfg, verEntCfg, revisionInfoRelationMapping, auditEntityNameRegister, classesAuditingData); // First pass foreach (KeyValuePair <PersistentClass, ClassAuditingData> pcDatasEntry in classesAuditingData.GetAllClassAuditedData()) { PersistentClass pc = pcDatasEntry.Key; ClassAuditingData auditData = pcDatasEntry.Value; EntityXmlMappingData xmlMappingData = new EntityXmlMappingData(); if (auditData.IsAudited()) { if (!String.IsNullOrEmpty(auditData.AuditTable.value)) // .getAuditTable().value())) { { verEntCfg.AddCustomAuditTableName(pc.EntityName, auditData.AuditTable.value); } auditMetaGen.GenerateFirstPass(pc, auditData, xmlMappingData, true); } else { auditMetaGen.GenerateFirstPass(pc, auditData, xmlMappingData, false); } xmlMappings.Add(pc, xmlMappingData); } // Second pass foreach (KeyValuePair <PersistentClass, ClassAuditingData> pcDatasEntry in classesAuditingData.GetAllClassAuditedData()) { EntityXmlMappingData xmlMappingData = xmlMappings[pcDatasEntry.Key]; if (pcDatasEntry.Value.IsAudited()) { auditMetaGen.GenerateSecondPass(pcDatasEntry.Key, pcDatasEntry.Value, xmlMappingData); try { //cfg.AddDocument(writer.write(xmlMappingData.MainXmlMapping)); cfg.AddDocument(xmlMappingData.MainXmlMapping); //WriteDocument(xmlMappingData.getMainXmlMapping()); foreach (XmlDocument additionalMapping in xmlMappingData.AdditionalXmlMappings) { //cfg.AddDocument(writer.write(additionalMapping)); cfg.AddDocument(additionalMapping); //WriteDocument(additionalMapping); } } catch (MappingException e) { //catch (DocumentException e) { //?Catalina DocumentException NOT IMPLEMENTED throw new MappingException(e); } } } // Only if there are any versioned classes if (classesAuditingData.GetAllClassAuditedData().Count > 0) { try { if (revisionInfoXmlMapping != null) { //WriteDocument(revisionInfoXmlMapping); //cfg.addDocument(writer.write(revisionInfoXmlMapping)); cfg.AddDocument((revisionInfoXmlMapping)); } } catch (MappingException e) { //catch (DocumentException e) { //?Catalina throw new MappingException(e); } } return(new EntitiesConfigurations(auditMetaGen.EntitiesConfigurations, auditMetaGen.NotAuditedEntitiesConfigurations)); }
public MiddleSimpleComponentMapper(AuditEntitiesConfiguration verEntCfg, String propertyName) { this.propertyName = propertyName; this.verEntCfg = verEntCfg; }