Exemplo n.º 1
0
        public void MapToEntityFromMap(AuditConfiguration verCfg, Object obj, IDictionary<String, Object> data, Object primaryKey,
            IAuditReaderImplementor versionsReader, long revision)
        {
            if (obj == null)
            {
                return;
            }

            Object entityId = delegat.MapToIdFromMap(DictionaryWrapper<String, Object>.Wrap((IDictionary)data[propertyData.Name]));
            Object value;
            if (entityId == null)
            {
                value = null;
            }
            else
            {
                if (versionsReader.FirstLevelCache.Contains(referencedEntityName, revision, entityId))
                {
                    value = versionsReader.FirstLevelCache[referencedEntityName, revision, entityId];
                }
                else
                {
                    //java: Class<?> entityClass = ReflectionTools.loadClass(referencedEntityName);
                    value = versionsReader.SessionImplementor.Factory.GetEntityPersister(referencedEntityName).CreateProxy(
                        entityId, new ToOneDelegateSessionImplementor(versionsReader, Toolz.ResolveDotnetType(referencedEntityName), entityId, revision, verCfg));
                }
            }
            PropertyInfo propInfo = obj.GetType().GetProperty(propertyData.Name);
            propInfo.SetValue(obj, value, null);
        }
        public void MapToEntityFromMap(AuditConfiguration verCfg, Object obj, IDictionary<String, Object> data, Object primaryKey, IAuditReaderImplementor versionsReader, long revision)
        {
            //TODO in implementing second phase/////////////
            throw new NotImplementedException("Not Implemented!");

            //if (obj == null) {
            //    return;
            //}Not implememented

            //System.Type entityClass = ReflectionTools.loadClass(owningEntityName);

            //Object value;

            //try {
            //    value = versionsReader.CreateQuery().ForEntitiesAtRevision(entityClass, revision)
            //            //.Add( (AuditEntity.relatedId(owningReferencePropertyName).eq(primaryKey)).GetSingleResult();
            //} catch (NoResultException e) {
            //    value = null;
            //} catch (NonUniqueResultException e) {
            //    throw new AuditException("Many versions results for one-to-one relationship: (" + owningEntityName +
            //            ", " + owningReferencePropertyName + ")");
            //}

            //ISetter setter = ReflectionTools.getSetter(obj.getClass(), propertyData);
            //Catalina: la portare se foloseste PropertyInfo. Exemple in MultiPropertyMapper si SinglePropertyMapper
            //setter.set(obj, value, null);
        }
Exemplo n.º 3
0
        public void AddToQuery(AuditConfiguration auditCfg, IAuditReaderImplementor versionsReader, string entityName, QueryBuilder qb, Parameters parameters)
        {
            var propertyName = CriteriaTools.DeterminePropertyName(auditCfg, versionsReader, entityName, _propertyNameGetter);

            CriteriaTools.CheckPropertyNotARelation(auditCfg, entityName, propertyName);
            parameters.AddWhereWithFunction(propertyName, " lower ", " like ", _value.ToLower());
        }
Exemplo n.º 4
0
 public EntitiesAtRevisionQuery(AuditConfiguration verCfg,
                                IAuditReaderImplementor versionsReader, System.Type cls,
                                long revision)
     : base(verCfg, versionsReader, cls)
 {
     this.revision = revision;
 }
Exemplo n.º 5
0
        public void MapToEntityFromMap(AuditConfiguration verCfg, Object obj, IDictionary <String, Object> data, Object primaryKey,
                                       IAuditReaderImplementor versionsReader, long revision)
        {
            if (obj == null)
            {
                return;
            }

            Object entityId = delegat.MapToIdFromMap(DictionaryWrapper <String, Object> .Wrap((IDictionary)data[propertyData.Name]));
            Object value;

            if (entityId == null)
            {
                value = null;
            }
            else
            {
                if (versionsReader.FirstLevelCache.Contains(referencedEntityName, revision, entityId))
                {
                    value = versionsReader.FirstLevelCache[referencedEntityName, revision, entityId];
                }
                else
                {
                    //java: Class<?> entityClass = ReflectionTools.loadClass(referencedEntityName);
                    value = versionsReader.SessionImplementor.Factory.GetEntityPersister(referencedEntityName).CreateProxy(
                        entityId, new ToOneDelegateSessionImplementor(versionsReader, Toolz.ResolveDotnetType(referencedEntityName), entityId, revision, verCfg));
                }
            }
            PropertyInfo propInfo = obj.GetType().GetProperty(propertyData.Name);

            propInfo.SetValue(obj, value, null);
        }
Exemplo n.º 6
0
        public static string DeterminePropertyName(AuditConfiguration auditCfg, IAuditReaderImplementor versionsReader,
                                                   string entityName, string propertyName)
        {
            if (propertyName != null)
            {
                var sessionFactory = versionsReader.SessionImplementor.Factory;
                if (AuditId.IdentifierPlaceholder.Equals(propertyName))
                {
                    var identifierPropertyName = sessionFactory.GetEntityPersister(entityName).IdentifierPropertyName;
                    return(auditCfg.AuditEntCfg.OriginalIdPropName + "." + identifierPropertyName);
                }

                var idPropertyName = sessionFactory.GetEntityPersister(entityName).IdentifierPropertyName;
                if (propertyName.Equals(idPropertyName))
                {
                    return(auditCfg.AuditEntCfg.OriginalIdPropName + "." + propertyName);
                }
                if (propertyName.StartsWith(idPropertyName + MappingTools.RelationCharacter))
                {
                    propertyName = propertyName.Replace(MappingTools.RelationCharacter, ".");
                    return(auditCfg.AuditEntCfg.OriginalIdPropName + propertyName.Substring(idPropertyName.Length));
                }
            }

            return(propertyName);
        }
        public void MapToEntityFromMap(AuditConfiguration verCfg, object obj, IDictionary data,
									   object primaryKey, IAuditReaderImplementor versionsReader, long revision)
        {
            if (data == null || obj == null)
            {
                return;
            }

            var setter = ReflectionTools.GetSetter(obj.GetType(), _propertyData);

            // If all properties are null and single, then the component has to be null also.
            var allNullAndSingle = true;
            foreach (var property in _delegate.Properties)
            {
                if (data[property.Key.Name] != null || !(property.Value is SinglePropertyMapper))
                {
                    allNullAndSingle = false;
                    break;
                }
            }

            // And we don't have to set anything on the object - the default value is null
            if (!allNullAndSingle)
            {
                var subObj = new Dictionary<string, object>();
                foreach (var propertyData in _delegate.Properties.Keys)
                {
                    subObj[propertyData.BeanName] = data[propertyData.Name];
                }
                setter.Set(obj, subObj);
            }
        }
 public EntitiesAtRevisionQuery(AuditConfiguration verCfg,
     IAuditReaderImplementor versionsReader, System.Type cls,
     long revision)
     : base(verCfg, versionsReader, cls)
 {
     this.revision = revision;
 }
        protected AbstractRevisionsQuery(AuditConfiguration auditConfiguration,
                                         IAuditReaderImplementor versionsReader,
                                         bool includesDeletations,
                                         string entityName)
        {
            AuditConfiguration = auditConfiguration;
            _versionsReader    = versionsReader;

            _criterions        = new List <IAuditCriterion>();
            EntityInstantiator = new EntityInstantiator(auditConfiguration, versionsReader);

            EntityName = entityName;

            VersionsEntityName = auditConfiguration.AuditEntCfg.GetAuditEntityName(EntityName);

            QueryBuilder         = new QueryBuilder(VersionsEntityName, QueryConstants.ReferencedEntityAlias);
            _includesDeletations = includesDeletations;

            if (!auditConfiguration.EntCfg.IsVersioned(EntityName))
            {
                throw new NotAuditedException(EntityName, EntityName + " is not versioned!");
            }

            _associationQueries  = new List <AuditRevisionsAssociationQuery <TEntity> >();
            _associationQueryMap = new Dictionary <string, AuditRevisionsAssociationQuery <TEntity> >();
        }
        public void MapToEntityFromMap(AuditConfiguration verCfg, Object obj, IDictionary<String, Object> data, 
                                       Object primaryKey, IAuditReaderImplementor versionsReader, long revision)
        {
            if (data == null || obj == null) {
                return;
            }

            //ORIG: Setter setter = ReflectionTools.getSetter(obj.getClass(), propertyData);
            PropertyInfo propInfo = obj.GetType().GetProperty(propertyData.Name);

		    // If all properties are null and single, then the component has to be null also.
		    bool allNullAndSingle = true;
		    foreach (KeyValuePair<PropertyData, IPropertyMapper> property in _delegate.Properties) {
			    if (data[property.Key.Name] != null || !(property.Value is SinglePropertyMapper)) {
				    allNullAndSingle = false;
				    break;
			    }
		    }

		    // And we don't have to set anything on the object - the default value is null
		    if (!allNullAndSingle) {
			    try {
                    //ORIG: Object subObj = ReflectHelper.getDefaultConstructor(
                    //        Thread.currentThread().getContextClassLoader().loadClass(componentClassName)).newInstance();
                    //setter.set(obj, subObj, null);
                    object subObj = Activator.CreateInstance(Toolz.ResolveDotnetType(componentClassName));
                    propInfo.SetValue(obj, subObj, null);

				    _delegate.MapToEntityFromMap(verCfg, subObj, data, primaryKey, versionsReader, revision);
			    } catch (Exception e) {
				    throw new AuditException(e);
			    }
		    }
        }
        public AuditRevisionsAssociationQuery(AuditConfiguration auditConfiguration,
                                              IAuditReaderImplementor auditReader,
                                              IEntityAuditQuery <TEntity> parent,
                                              QueryBuilder queryBuilder,
                                              string ownerEntityName,
                                              string propertyName,
                                              JoinType joinType,
                                              string ownerAlias)
        {
            _auditConfiguration = auditConfiguration;
            _auditReader        = auditReader;
            _parent             = parent;
            _queryBuilder       = queryBuilder;
            _joinType           = joinType;
            _ownerAlias         = ownerAlias;

            var relationDescription = CriteriaTools.GetRelatedEntity(auditConfiguration, ownerEntityName, propertyName);

            if (relationDescription == null)
            {
                throw new ArgumentException("Property " + propertyName + " of entity " + ownerEntityName + " is not a valid association for queries");
            }
            _entityName = relationDescription.ToEntityName;
            _ownerAssociationIdMapper = relationDescription.IdMapper;
            _alias               = queryBuilder.GenerateAlias();
            _parameters          = queryBuilder.AddParameters(_alias);
            _criterions          = new List <IAuditCriterion>();
            _associationQueries  = new List <AuditRevisionsAssociationQuery <TEntity> >();
            _associationQueryMap = new Dictionary <string, AuditRevisionsAssociationQuery <TEntity> >();
        }
        public void AddToQuery(AuditConfiguration verCfg, IAuditReaderImplementor versionsReader, string entityName, QueryBuilder qb, Parameters parameters)
        {
            var opParameters = parameters.AddSubParameters(op);

            lhs.AddToQuery(verCfg, versionsReader, entityName, qb, opParameters.AddSubParameters("and"));
            rhs.AddToQuery(verCfg, versionsReader, entityName, qb, opParameters.AddSubParameters("and"));
        }
        public void AddToQuery(AuditConfiguration auditCfg, IAuditReaderImplementor versionsReader, string entityName, QueryBuilder qb, Parameters parameters)
        {
            var propertyName = CriteriaTools.DeterminePropertyName(auditCfg, versionsReader, entityName, propertyNameGetter);

            CriteriaTools.CheckPropertyNotARelation(auditCfg, entityName, propertyName);
            CriteriaTools.CheckPropertyNotARelation(auditCfg, entityName, otherPropertyName);
            parameters.AddWhere(propertyName, op, otherPropertyName);
        }
 public void MapToEntityFromMap(AuditConfiguration verCfg, object obj, IDictionary data,
                                object primaryKey, IAuditReaderImplementor versionsReader, long revision)
 {
     foreach (var mapper in Properties.Values)
     {
         mapper.MapToEntityFromMap(verCfg, obj, data, primaryKey, versionsReader, revision);
     }
 }
Exemplo n.º 15
0
        public EntitiesAtRevisionQuery(AuditConfiguration verCfg,
										IAuditReaderImplementor versionsReader,
										string entityName,
										long revision)
            : base(verCfg, versionsReader, entityName)
        {
            _revision = revision;
        }
Exemplo n.º 16
0
        public object CreateToOneProxy(AuditConfiguration verCfg, IAuditReaderImplementor versionsReader,
                                       string referencedEntityName, object entityId, long revision, bool removed)
        {
            var innerProxy = (ISessionImplementor)proxyFactory
                             .CreateProxy(typeof(ISessionImplementor), new SessionImplToOneInterceptor(versionsReader, entityId, revision, removed, verCfg));

            return(versionsReader.SessionImplementor.Factory.GetEntityPersister(referencedEntityName)
                   .CreateProxy(entityId, innerProxy));
        }
Exemplo n.º 17
0
 public SessionImplToOneInterceptor(IAuditReaderImplementor versionsReader, object entityId, long revision, bool removed, AuditConfiguration verCfg)
 {
     _versionsReader = versionsReader;
     _entityId       = entityId;
     _revision       = revision;
     _removed        = removed;
     _entCfg         = verCfg.EntCfg;
     _target         = _versionsReader.SessionImplementor;
 }
 public RevisionsOfEntityQuery(AuditConfiguration verCfg,
     IAuditReaderImplementor versionsReader,
     System.Type cls, bool selectEntitiesOnly,
     bool selectDeletedEntities)
     : base(verCfg, versionsReader, cls)
 {
     this.selectEntitiesOnly = selectEntitiesOnly;
     this.selectDeletedEntities = selectDeletedEntities;
 }
 public RevisionsOfEntityQuery(AuditConfiguration verCfg,
                               IAuditReaderImplementor versionsReader,
                               System.Type cls, bool selectEntitiesOnly,
                               bool selectDeletedEntities)
     : base(verCfg, versionsReader, cls)
 {
     this.selectEntitiesOnly    = selectEntitiesOnly;
     this.selectDeletedEntities = selectDeletedEntities;
 }
 public SetCollectionInitializor(AuditConfiguration verCfg,
                                 IAuditReaderImplementor versionsReader,
                                 IRelationQueryGenerator queryGenerator,
                                 object primaryKey, long revision, bool removed,
                                 MiddleComponentData elementComponentData)
     : base(verCfg, versionsReader, queryGenerator, primaryKey, revision, removed)
 {
     _elementComponentData = elementComponentData;
 }
Exemplo n.º 21
0
 public RevisionsOfEntityQuery(AuditConfiguration verCfg,
                               IAuditReaderImplementor versionsReader,
                               string entityName,
                               bool selectEntitiesOnly,
                               bool selectDeletedEntities)
     : base(verCfg, versionsReader, entityName)
 {
     _selectEntitiesOnly    = selectEntitiesOnly;
     _selectDeletedEntities = selectDeletedEntities;
 }
Exemplo n.º 22
0
        public void AddToQuery(AuditConfiguration auditCfg, IAuditReaderImplementor versionsReader, string entityName, QueryBuilder qb, Parameters parameters)
        {
            var propertyName = CriteriaTools.DeterminePropertyName(auditCfg, versionsReader, entityName, propertyNameGetter);

            CriteriaTools.CheckPropertyNotARelation(auditCfg, entityName, propertyName);
            var subParams = parameters.AddSubParameters(Parameters.AND);

            subParams.AddWhereWithParam(propertyName, ">=", lo);
            subParams.AddWhereWithParam(propertyName, "<=", hi);
        }
        public ToOneDelegateSessionImplementor(IAuditReaderImplementor versionsReader,
											   object entityId, long revision, 
											   AuditConfiguration verCfg)
            : base(versionsReader.SessionImplementor)
        {
            this.versionsReader = versionsReader;
            this.entityId = entityId;
            this.revision = revision;
            entCfg = verCfg.EntCfg;
        }
Exemplo n.º 24
0
 protected override IInitializor GetInitializor(AuditConfiguration verCfg, IAuditReaderImplementor versionsReader, object primaryKey, long revision, bool removed)
 {
     return(new SpecialInitializor(verCfg,
                                   versionsReader,
                                   CommonCollectionMapperData.QueryGenerator,
                                   primaryKey,
                                   revision,
                                   removed,
                                   _elementComponentData));
 }
        public IQuery GetQuery(IAuditReaderImplementor versionsReader, Object primaryKey, long revision) {
            IQuery query = versionsReader.Session.CreateQuery(queryString);
            query.SetParameter("revision", revision);
            query.SetParameter("delrevisiontype", RevisionType.DEL);
            foreach (QueryParameterData paramData in referencingIdData.PrefixedMapper.MapToQueryParametersFromId(primaryKey)) {
                paramData.SetParameterValue(query);
            }

            return query;
        }
Exemplo n.º 26
0
 protected override object QueryForReferencedEntity(IAuditReaderImplementor versionsReader, EntityInfo referencedEntity, object primaryKey, long revision, bool removed)
 {
     if (referencedEntity.IsAudited)
     {
         return(versionsReader.Find(referencedEntity.EntityName, primaryKey, revision, removed));
     }
     //Not audited revision
     return(createNotAuditedEntityReference(versionsReader, referencedEntity.EntityClass,
                                            referencedEntity.EntityName, primaryKey));
 }
Exemplo n.º 27
0
 public EntitiesAtRevisionQuery(AuditConfiguration verCfg,
                                IAuditReaderImplementor versionsReader,
                                string entityName,
                                long revision,
                                bool includeDeletions)
     : base(verCfg, versionsReader, entityName)
 {
     _revision         = revision;
     _includeDeletions = includeDeletions;
 }
Exemplo n.º 28
0
 public EntitiesAtRevisionQuery(AuditConfiguration verCfg,
                                IAuditReaderImplementor versionsReader,
                                System.Type cls,
                                long revision,
                                bool includeDeletions)
     : base(verCfg, versionsReader, cls)
 {
     _revision         = revision;
     _includeDeletions = includeDeletions;
 }
Exemplo n.º 29
0
        public RevisionsOfEntityQuery(AuditConfiguration verCfg,
							IAuditReaderImplementor versionsReader,
							string entityName,
							bool selectEntitiesOnly,
							bool selectDeletedEntities)
            : base(verCfg, versionsReader, entityName)
        {
            this.selectEntitiesOnly = selectEntitiesOnly;
            this.selectDeletedEntities = selectDeletedEntities;
        }
 public ToOneDelegateSessionImplementor(IAuditReaderImplementor versionsReader, string entityName,
                                        object entityId, long revision, bool removed, AuditConfiguration verCfg) : base(versionsReader.SessionImplementor)
 {
     _versionsReader = versionsReader;
     _entityName     = entityName;
     _entityId       = entityId;
     _revision       = revision;
     _removed        = removed;
     _verCfg         = verCfg;
 }
Exemplo n.º 31
0
 public static string DeterminePropertyName(AuditConfiguration auditCfg, IAuditReaderImplementor versionsReader,
                                            string entityName, string propertyName)
 {
     if (AuditId.IdentifierPlaceholder.Equals(propertyName))
     {
         var identifierPropertyName =
             versionsReader.SessionImplementor.Factory.GetEntityPersister(entityName).IdentifierPropertyName;
         propertyName = auditCfg.AuditEntCfg.OriginalIdPropName + "." + identifierPropertyName;
     }
     return(propertyName);
 }
Exemplo n.º 32
0
        private static object createNotAuditedEntityReference(IAuditReaderImplementor versionsReader, System.Type entityClass, string entityName, object primaryKey)
        {
            var entityPersister = versionsReader.SessionImplementor.Factory.GetEntityPersister(entityName);

            if (entityPersister.HasProxy)
            {
                // If possible create a proxy. Returning complete object may affect performance.
                return(versionsReader.Session.Load(entityClass, primaryKey));
            }
            // If proxy is not allowed (e.g. @Proxy(lazy=false)) construct the original object.
            return(versionsReader.Session.Get(entityClass, primaryKey));
        }
        public void AddToQuery(AuditConfiguration auditCfg, IAuditReaderImplementor versionsReader, string entityName, QueryBuilder qb, Parameters parameters)
        {
            var propertyName  = CriteriaTools.DeterminePropertyName(auditCfg, versionsReader, entityName, propertyNameGetter);
            var relatedEntity = CriteriaTools.GetRelatedEntity(auditCfg, entityName, propertyName);

            if (relatedEntity == null)
            {
                throw new AuditException("This criterion can only be used on a property that is " +
                                         "a relation to another property.");
            }
            relatedEntity.IdMapper.AddIdEqualsToQuery(parameters, id, null, equals);
        }
Exemplo n.º 34
0
        public AbstractCollectionInitializor(AuditConfiguration verCfg,
                                             IAuditReaderImplementor versionsReader,
                                             IRelationQueryGenerator queryGenerator,
                                             Object primaryKey, long revision)
        {
            this.versionsReader = versionsReader;
            this.queryGenerator = queryGenerator;
            this.primaryKey     = primaryKey;
            this.revision       = revision;

            entityInstantiator = new EntityInstantiator(verCfg, versionsReader);
        }
Exemplo n.º 35
0
        public static object CreateProxyOrLoadImmediate(IAuditReaderImplementor versionsReader, string entityName,
                                                        object entityId, long revision, bool removed, AuditConfiguration verCfg)
        {
            var persister = versionsReader.SessionImplementor.Factory.GetEntityPersister(entityName);

            if (persister.HasProxy)
            {
                return(persister.CreateProxy(entityId,
                                             new ToOneDelegateSessionImplementor(versionsReader, entityName, entityId, revision, removed, verCfg)));
            }

            return(LoadImmediate(versionsReader, entityName, entityId, revision, removed, verCfg));
        }
        public void MapToEntityFromMap(AuditConfiguration verCfg,
                                       object obj,
                                       IDictionary data,
                                       object primaryKey,
                                       IAuditReaderImplementor versionsReader,
                                       long revision)
        {
            var setter = ReflectionTools.GetSetter(obj.GetType(), CommonCollectionMapperData.CollectionReferencingPropertyData);
            var coll   = Activator.CreateInstance(_proxyType,
                                                  GetInitializor(verCfg, versionsReader, primaryKey, revision, data[verCfg.AuditEntCfg.RevisionTypePropName].Equals(RevisionType.Deleted)));

            setter.Set(obj, coll);
        }
 private static object loadImmediate(IAuditReaderImplementor versionsReader, string entityName,
                                     object entityId, long revision, bool removed, AuditConfiguration verCfg)
 {
     if (verCfg.EntCfg.GetNotVersionEntityConfiguration(entityName) == null)
     {
         // Audited relation, look up entity with Envers.
         // When user traverses removed entities graph, do not restrict revision type of referencing objects
         // to ADD or MOD (DEL possible). See HHH-5845.
         return(versionsReader.Find(entityName, entityId, revision, removed));
     }
     // Not audited relation, look up entity with Hibernate.
     return(versionsReader.SessionImplementor.ImmediateLoad(entityName, entityId));
 }
 public ToOneDelegateSessionImplementor(IAuditReaderImplementor versionsReader,
     System.Type entityClass,
     Object entityId, long revision,
     AuditConfiguration verCfg)
     : base(versionsReader.SessionImplementor)
 {
     this.versionsReader = versionsReader;
     this.entityClass = entityClass;
     this.entityId = entityId;
     this.revision = revision;
     EntitiesConfigurations entCfg = verCfg.EntCfg;
     notVersionedEntityConfiguration = entCfg.GetNotVersionEntityConfiguration(entityClass.FullName);
 }
        public IQuery GetQuery(IAuditReaderImplementor versionsReader, Object primaryKey, long revision)
        {
            IQuery query = versionsReader.Session.CreateQuery(_queryString);

            query.SetParameter("revision", revision);
            query.SetParameter("delrevisiontype", RevisionType.DEL);
            foreach (QueryParameterData paramData in _referencingIdData.PrefixedMapper.MapToQueryParametersFromId(primaryKey))
            {
                paramData.SetParameterValue(query);
            }

            return(query);
        }
 public SortedMapCollectionInitializor(AuditConfiguration verCfg,
                                       IAuditReaderImplementor versionsReader,
                                       IRelationQueryGenerator queryGenerator,
                                       object primaryKey,
                                       long revision,
                                       bool removed,
                                       MiddleComponentData elementComponentData,
                                       MiddleComponentData indexComponentData,
                                       IComparer <TKey> comparer)
     : base(verCfg, versionsReader, queryGenerator, primaryKey, revision, removed, elementComponentData, indexComponentData)
 {
     _comparer = comparer;
 }
        protected AbstractAuditQuery(AuditConfiguration verCfg, IAuditReaderImplementor versionsReader,
                                        System.Type cls) {
            this.verCfg = verCfg;
            this.versionsReader = versionsReader;

            criterions = new List<IAuditCriterion>();
            entityInstantiator = new EntityInstantiator(verCfg, versionsReader);

            entityName = cls.FullName;
            
            versionsEntityName = verCfg.AuditEntCfg.GetAuditEntityName(entityName);

            qb = new QueryBuilder(versionsEntityName, "e");
        }
 protected AbstractCollectionInitializor(AuditConfiguration verCfg,
                                         IAuditReaderImplementor versionsReader,
                                         IRelationQueryGenerator queryGenerator,
                                         object primaryKey,
                                         long revision,
                                         bool removed)
 {
     _versionsReader    = versionsReader;
     _queryGenerator    = queryGenerator;
     _primaryKey        = primaryKey;
     _removed           = removed;
     Revision           = revision;
     EntityInstantiator = new EntityInstantiator(verCfg, versionsReader);
 }
Exemplo n.º 43
0
        public void MapToEntityFromMap(AuditConfiguration verCfg, object obj, IDictionary data, object primaryKey,
									   IAuditReaderImplementor versionsReader, long revision)
        {
            if (data == null || obj == null)
            {
                return;
            }
            var objType = obj.GetType();
            var setter = ReflectionTools.GetSetter(objType, _propertyData);

            var value = data[_propertyData.Name];
            if (value != null)
            {
                setter.Set(obj, value);
            }
        }
        public void MapToEntityFromMap(AuditConfiguration verCfg, Object obj, IDictionary<string,object> data, Object primaryKey,
                                       IAuditReaderImplementor versionsReader, long revision) {
            if (data == null || obj == null) {
                return;
            }

            // ORIG: Setter setter = ReflectionTools.getSetter(obj.getClass(), propertyData);
            PropertyInfo propInfo = obj.GetType().GetProperty(propertyData.Name);

            Object value = data[propertyData.Name];
		    // We only set a null value if the field is not primitive. Otherwise, we leave it intact.
            //ORIG: if (value != null || !isPrimitive(setter, propertyData, obj.GetType())) {
            //    setter.Set(obj, value);
		    if (value != null || !isPrimitive(propInfo)) {
        	    propInfo.SetValue(obj, value, null);
		    }
        }
Exemplo n.º 45
0
        public void MapToEntityFromMap(AuditConfiguration verCfg, object obj, IDictionary data,
										object primaryKey, IAuditReaderImplementor versionsReader, long revision)
        {
            if (data == null || obj == null)
            {
                return;
            }

            if (propertyData.BeanName == null)
            {
                // If properties are not encapsulated in a component but placed directly in a class
                // (e.g. by applying <properties> tag).
                _delegate.MapToEntityFromMap(verCfg, obj, data, primaryKey, versionsReader, revision);
                return;
            }

            var setter = ReflectionTools.GetSetter(obj.GetType(), propertyData);

            // If all properties are null and single, then the component has to be null also.
            var allNullAndSingle = true;
            foreach (var property in _delegate.Properties)
            {
                if (data[property.Key.Name] != null || !(property.Value is SinglePropertyMapper))
                {
                    allNullAndSingle = false;
                    break;
                }
            }

            // And we don't have to set anything on the object - the default value is null
            if (!allNullAndSingle)
            {
                var componentType = Toolz.ResolveDotnetType(componentClassName);
                var subObj = ReflectionTools.CreateInstanceByDefaultConstructor(componentType);
                _delegate.MapToEntityFromMap(verCfg, subObj, data, primaryKey, versionsReader, revision);
                setter.Set(obj, subObj);
            }
        }
Exemplo n.º 46
0
        protected abstract object GetInitializor(AuditConfiguration verCfg,
														IAuditReaderImplementor versionsReader, 
														object primaryKey,
														long revision);
Exemplo n.º 47
0
        public void MapToEntityFromMap(AuditConfiguration verCfg, 
										object obj, 
										IDictionary data, 
										object primaryKey, 
										IAuditReaderImplementor versionsReader, 
										long revision)
        {
            var setter = ReflectionTools.GetSetter(obj.GetType(),
                                                   CommonCollectionMapperData.CollectionReferencingPropertyData);

            try
            {
                var coll = Activator.CreateInstance(_proxyType, new[]{GetInitializor(verCfg, versionsReader, primaryKey, revision)});
                setter.Set(obj, coll);
            }
            catch (InstantiationException e)
            {
                throw new AuditException(e.Message, e);
            }
            catch (SecurityException e)
            {
                throw new AuditException(e.Message, e);
            }
            catch (TargetInvocationException e)
            {
                throw new AuditException(e.Message, e);
            }
        }
Exemplo n.º 48
0
        public void MapToEntityFromMap(AuditConfiguration verCfg, object obj, IDictionary data,
									   object primaryKey, IAuditReaderImplementor versionsReader, long revision)
        {
            foreach (var mapper in Properties.Values)
            {
                mapper.MapToEntityFromMap(verCfg, obj, data, primaryKey, versionsReader, revision);
            }
        }
Exemplo n.º 49
0
 public AuditQueryCreator(AuditConfiguration auditCfg, IAuditReaderImplementor auditReaderImplementor)
 {
     this.auditCfg = auditCfg;
     this.auditReaderImplementor = auditReaderImplementor;
 }
 public CrossTypeRevisionChangesReader(IAuditReaderImplementor auditReaderImplementor, AuditConfiguration verCfg)
 {
     _auditReaderImplementor = auditReaderImplementor;
     _verCfg = verCfg;
 }
 public void MapToEntityFromMap(AuditConfiguration verCfg, Object obj, IDictionary<string,object> data, Object primaryKey, IAuditReaderImplementor versionsReader, long revision)
 {
     parentMapper.MapToEntityFromMap(verCfg, obj, data, primaryKey, versionsReader, revision);
     main.MapToEntityFromMap(verCfg, obj, data, primaryKey, versionsReader, revision);
 }
Exemplo n.º 52
0
 public EntityInstantiator(AuditConfiguration verCfg, IAuditReaderImplementor versionsReader)
 {
     this.verCfg = verCfg;
     this.versionsReader = versionsReader;
 }