Example #1
0
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="metaDataStore"></param>
        /// <param name="mainGenerator">Main generator, giving access to configuration and the basic mapper.</param>
        /// <param name="propertyValue">Value of the collection, as mapped by Hibernate.</param>
        /// <param name="currentMapper">Mapper, to which the appropriate {@link org.hibernate.envers.entities.mapper.PropertyMapper} will be added.</param>
        /// <param name="referencingEntityName">Name of the entity that owns this collection.</param>
        /// <param name="xmlMappingData">In case this collection requires a middle table, additional mapping documents will be created using this object.</param>
        /// <param name="propertyAuditingData">
        /// Property auditing (meta-)data. Among other things, holds the name of the
        /// property that references the collection in the referencing entity, the user data for middle (join)
        /// table and the value of the <code>@MapKey</code> annotation, if there was one.
        /// </param>
        public CollectionMetadataGenerator(IMetaDataStore metaDataStore,
                                           AuditMetadataGenerator mainGenerator,
                                           Mapping.Collection propertyValue,
                                           ICompositeMapperBuilder currentMapper,
                                           string referencingEntityName,
                                           EntityXmlMappingData xmlMappingData,
                                           PropertyAuditingData propertyAuditingData)
        {
            _metaDataStore         = metaDataStore;
            _mainGenerator         = mainGenerator;
            _propertyValue         = propertyValue;
            _currentMapper         = currentMapper;
            _referencingEntityName = referencingEntityName;
            _xmlMappingData        = xmlMappingData;
            _propertyAuditingData  = propertyAuditingData;

            _propertyName = propertyAuditingData.Name;

            _referencingEntityConfiguration = mainGenerator.EntitiesConfigurations[referencingEntityName];
            if (_referencingEntityConfiguration == null)
            {
                throw new MappingException("Unable to read auditing configuration for " + referencingEntityName + "!");
            }

            _referencedEntityName = MappingTools.ReferencedEntityName(propertyValue.Element);
        }
Example #2
0
 public ComponentAuditedPropertiesReader(IMetaDataStore metaDataStore,
                                         IPersistentPropertiesSource persistentPropertiesSource,
                                         IAuditedPropertiesHolder auditedPropertiesHolder,
                                         GlobalConfiguration globalCfg,
                                         string propertyNamePrefix)
     : base(metaDataStore, persistentPropertiesSource, auditedPropertiesHolder, globalCfg, propertyNamePrefix)
 {
     _metaDataStore = metaDataStore;
 }
Example #3
0
        public AnnotationsMetadataReader(IMetaDataStore metaDataStore,
                                         GlobalConfiguration globalCfg,
                                         PersistentClass pc)
        {
            _metaDataStore = metaDataStore;
            this.globalCfg = globalCfg;
            this.pc        = pc;

            _auditData = new ClassAuditingData();
        }
Example #4
0
        /// <summary>
        /// Configures the builder to use the provided <see cref="IMetaDataStore"/>
        /// </summary>
        /// <param name="metaDataStore"><see cref="IMetaDataStore"/> to use in the MLOps pipeline</param>
        /// <returns>The current builder for chaining</returns>
        public MLOpsBuilder UseMetaDataStore(IMetaDataStore metaDataStore)
        {
            if (this.metaDataStore != null)
            {
                throw new InvalidOperationException("MetaDataStore is already configured");
            }

            this.metaDataStore = metaDataStore ?? throw new ArgumentNullException(nameof(metaDataStore));
            return(this);
        }
 public RevisionInfoConfiguration(GlobalConfiguration globalCfg, IMetaDataStore metaDataStore)
 {
     _globalCfg                = globalCfg;
     _metaDataStore            = metaDataStore;
     revisionInfoEntityName    = "NHibernate.Envers.DefaultRevisionEntity";
     revisionInfoIdData        = new PropertyData("Id", "Id", "property");
     revisionInfoTimestampData = new PropertyData("RevisionDate", "RevisionDate", "property");
     modifiedEntityNamesData   = new PropertyData("ModifiedEntityNames", "ModifiedEntityNames", "property");
     revisionInfoTimestampType = new DateTimeType();
     revisionPropType          = typeof(int);
 }
 public AuditedPropertiesReader(IMetaDataStore metaDataStore,
                                IPersistentPropertiesSource persistentPropertiesSource,
                                IAuditedPropertiesHolder auditedPropertiesHolder,
                                GlobalConfiguration globalCfg,
                                string propertyNamePrefix)
 {
     _metaDataStore = metaDataStore;
     _persistentPropertiesSource = persistentPropertiesSource;
     _auditedPropertiesHolder    = auditedPropertiesHolder;
     _globalCfg                      = globalCfg;
     _propertyNamePrefix             = propertyNamePrefix;
     _overriddenAuditedProperties    = new HashSet <string>();
     _overriddenNotAuditedProperties = new HashSet <string>();
     _overriddenAuditedClasses       = new HashSet <System.Type>();
     _overriddenNotAuditedClasses    = new HashSet <System.Type>();
 }
Example #7
0
        internal MLOpsContext(IMetaDataStore metaDataStore, IModelRepository modelRepository)
        {
            if (metaDataStore == null)
            {
                throw new ArgumentNullException(nameof(metaDataStore));
            }
            if (modelRepository == null)
            {
                throw new ArgumentNullException(nameof(modelRepository));
            }

            this.LifeCycle  = new LifeCycleCatalog(metaDataStore);
            this.Evaluation = new EvaluationCatalog(metaDataStore);
            this.Model      = new ModelCatalog(modelRepository);
            this.Training   = new TrainingCatalog(metaDataStore);
        }
Example #8
0
 public AuditMetadataGenerator(IMetaDataStore metaDataStore,
                               Cfg.Configuration cfg,
                               GlobalConfiguration globalCfg,
                               AuditEntitiesConfiguration verEntCfg,
                               XElement revisionInfoRelationMapping,
                               AuditEntityNameRegister auditEntityNameRegister)
 {
     Cfg            = cfg;
     GlobalCfg      = globalCfg;
     VerEntCfg      = verEntCfg;
     _metaDataStore = metaDataStore;
     this.revisionInfoRelationMapping = revisionInfoRelationMapping;
     BasicMetadataGenerator           = new BasicMetadataGenerator();
     componentMetadataGenerator       = new ComponentMetadataGenerator(this);
     idMetadataGenerator              = new IdMetadataGenerator(this);
     toOneRelationMetadataGenerator   = new ToOneRelationMetadataGenerator(this);
     AuditEntityNameRegister          = auditEntityNameRegister;
     EntitiesConfigurations           = new Dictionary <string, EntityConfiguration>();
     NotAuditedEntitiesConfigurations = new Dictionary <string, EntityConfiguration>();
     entitiesJoins = new Dictionary <string, IDictionary <Join, XElement> >();
 }
        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));
        }
Example #10
0
        /// <summary>
        /// Get the file contract batch from the parse store
        /// </summary>
        /// <param name="parseStorePath">Location for reading the parsed content</param>
        /// <param name="metaDataStoresPath">MetaDataStore data location</param>
        /// <param name="skip">Number of files to skip from parse store</param>
        /// <param name="take">Number of files to pick in this batch from parse store. Set it to -1 to create batch based on size</param>
        /// <param name="size">Size of files in this batch. Set it to -1 to prepare batch based on file count</param>
        public IEnumerable <IFileContract> GetFileContractBatch(IObjectStore parseStore, IMetaDataStore metaDataStore, int skip, int take, long size = -1)
        {
            if (null == parseStore)
            {
                throw new ArgumentNullException("GetFileContractBatch", "parsestore");
            }

            if (null == metaDataStore)
            {
                throw new ArgumentNullException("GetFileContractBatch", "metaDataStore");
            }

            return(m_fileContracter.GetFileContractBatch(parseStore, metaDataStore, skip, take, size));
        }
Example #11
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="metaDataStore"></param>
 /// <param name="clock">Abstraction of DateTime</param>
 public LifeCycleCatalog(IMetaDataStore metaDataStore, IClock clock)
 {
     this.metaDataStore = metaDataStore;
     this.clock         = clock;
 }
Example #12
0
 public MLLifeCycleManager(string connectionString)
 {
     this.metaDataStore = new StorageAccountMetaDataStore(connectionString);
 }
Example #13
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="metaDataStore"></param>
 public EvaluationCatalog(IMetaDataStore metaDataStore)
 {
     this.metaDataStore = metaDataStore;
 }
Example #14
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="metaDataStore"></param>
 public LifeCycleCatalog(IMetaDataStore metaDataStore)
 {
     this.metaDataStore = metaDataStore;
 }
Example #15
0
 internal MLOpsContext(IMetaDataStore metaDataStore, IModelRepository modelRepository)
 {
     this.metaDataStore   = metaDataStore ?? throw new ArgumentNullException(nameof(metaDataStore));
     this.modelRepository = modelRepository ?? throw new ArgumentNullException(nameof(modelRepository));
 }
Example #16
0
 /// <summary>
 /// ctor
 /// </summary>
 public TrainingCatalog(IMetaDataStore metaDataStore)
 {
     this.metaDataStore = metaDataStore;
 }