public PersistentClassPropertiesSource(System.Type typ, AnnotationsMetadataReader parent) { this.typ = typ; this.parent = parent; }
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 PersistentClassPropertiesSource(System.Type typ, AnnotationsMetadataReader parent) { this.parent = parent; DeclaredPersistentProperties = PropertyAndMemberInfo.PersistentInfo(typ, parent.pc.PropertyIterator, true); Class = typ; }