Rebel.Cms.Web.Packaging.PackageInstallation.CheckImportableEntities C# (CSharp) Method

CheckImportableEntities() private method

Check Entities can be imported. Updates 'IsImportable' property on DeseriazliedDataResult
private CheckImportableEntities ( SerializedDataImport dataImport ) : void
dataImport SerializedDataImport
return void
        private void CheckImportableEntities(SerializedDataImport dataImport)
        {
            using (var uow = _context.Application.Hive.OpenReader<IContentStore>())
            {
                foreach (var attributeType in dataImport.AttributeTypes)
                {
                    var attributeTypeObj = attributeType.DeserializedObject as AttributeType;
                    if(attributeTypeObj == null) continue;

                    if (!uow.Repositories.Schemas.Exists<AttributeType>(attributeTypeObj.Id))
                    {
                        attributeType.IsImportable = true;
                        attributeType.IsUpdatingEntity = false;
                        attributeType.ObjectId = attributeTypeObj.Id;
                    }
                }

                foreach (var entity in dataImport.Entities)
                {
                    var typedEntity = entity.DeserializedObject as TypedEntity;
                    if (typedEntity == null) continue;

                    entity.IsImportable = true;
                    entity.IsUpdatingEntity = uow.Repositories.Exists<TypedEntity>(typedEntity.Id);
                    entity.ObjectId = typedEntity.Id;
                    //Note this might be a dirty hack - removing Ids from source AttributeGroups to avoid conflicts
                    foreach (var attributeGroup in typedEntity.EntitySchema.AttributeGroups)
                    {
                        attributeGroup.Id = HiveId.Empty;
                    }
                }

                foreach (var schema in dataImport.Schemas)
                {
                    var entitySchema = schema.DeserializedObject as EntitySchema;
                    if(entitySchema == null) continue;

                    schema.IsImportable = true;
                    schema.IsUpdatingEntity = uow.Repositories.Schemas.Exists<EntitySchema>(entitySchema.Id);
                    schema.ObjectId = entitySchema.Id;
                    //Note this might be a dirty hack - removing Ids from source AttributeGroups to avoid conflicts
                    foreach (var attributeGroup in entitySchema.AttributeGroups)
                    {
                        attributeGroup.Id = HiveId.Empty;
                    }
                }
            }
        }