예제 #1
0
 public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
 {
     if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
     {
         SymbolLogic <ModelConverterSymbol> .Start(sb, dqm, () => Converters.Keys);
     }
 }
예제 #2
0
 public static void Start(SchemaBuilder sb)
 {
     if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
     {
         SymbolLogic <TypeConditionSymbol> .Start(sb, () => infos.SelectMany(a => a.Value.Keys).ToHashSet());
     }
 }
예제 #3
0
        internal static void Start(SchemaBuilder sb)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                SymbolLogic <ChartScriptSymbol> .Start(sb, () => Scripts.Keys);

                ChartRequestModel.GetChartScriptFunc = s => Scripts.GetOrThrow(s);

                RegisterScript(new BarsChartScript());
                RegisterScript(new ColumnsChartScript());
                RegisterScript(new LineChartScript());

                RegisterScript(new MultiBarsChartScript());
                RegisterScript(new MultiColumnsChartScript());
                RegisterScript(new MultiLinesChartScript());

                RegisterScript(new StackedBarsChartScript());
                RegisterScript(new StackedColumnsChartScript());
                RegisterScript(new StackedLinesChartScript());

                RegisterScript(new PieChartScript());
                RegisterScript(new BubblePackChartScript());

                RegisterScript(new ScatterplotChartScript());
                RegisterScript(new BubbleplotChartScript());

                RegisterScript(new ParallelCoordiantesChartScript());
                RegisterScript(new PunchcardChartScript());
                RegisterScript(new CalendarStreamChartScript());
                RegisterScript(new TreeMapChartScript());

                RegisterScript(new HeatmapChartScript());
                RegisterScript(new MarkermapChartScript());
            }
        }
예제 #4
0
        public static void Start(SchemaBuilder sb)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                SymbolLogic <FileTypeSymbol> .Start(sb, () => FileTypes.Keys.ToHashSet());

                sb.Include <FileTypeSymbol>()
                .WithQuery(() => f => new
                {
                    Entity = f,
                    f.Key
                });
            }
        }
예제 #5
0
        public static void Start(SchemaBuilder sb)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                AuthLogic.AssertStarted(sb);

                sb.Include <PermissionSymbol>();

                SymbolLogic <PermissionSymbol> .Start(sb, () => RegisteredPermission.ToHashSet());

                sb.Include <RulePermissionEntity>()
                .WithUniqueIndex(rt => new { rt.Resource, rt.Role });

                cache = new AuthCache <RulePermissionEntity, PermissionAllowedRule, PermissionSymbol, PermissionSymbol, bool>(sb,
                                                                                                                              toKey: p => p,
                                                                                                                              toEntity: p => p,
                                                                                                                              isEquals: (p1, p2) => p1 == p2,
                                                                                                                              merger: new PermissionMerger(),
                                                                                                                              invalidateWithTypes: false);

                sb.Schema.EntityEvents <RoleEntity>().PreUnsafeDelete += query =>
                {
                    Database.Query <RulePermissionEntity>().Where(r => query.Contains(r.Role.Entity)).UnsafeDelete();
                    return(null);
                };

                RegisterPermissions(BasicPermission.AdminRules,
                                    BasicPermission.AutomaticUpgradeOfProperties,
                                    BasicPermission.AutomaticUpgradeOfOperations,
                                    BasicPermission.AutomaticUpgradeOfQueries);

                AuthLogic.ExportToXml += exportAll => cache.ExportXml("Permissions", "Permission", a => a.Key, b => b.ToString(),
                                                                      exportAll ? PermissionAuthLogic.RegisteredPermission.ToList() : null);
                AuthLogic.ImportFromXml += (x, roles, replacements) =>
                {
                    string replacementKey = "AuthRules:" + typeof(PermissionSymbol).Name;

                    replacements.AskForReplacements(
                        x.Element("Permissions").Elements("Role").SelectMany(r => r.Elements("Permission")).Select(p => p.Attribute("Resource").Value).ToHashSet(),
                        SymbolLogic <PermissionSymbol> .Symbols.Select(s => s.Key).ToHashSet(),
                        replacementKey);

                    return(cache.ImportXml(x, "Permissions", "Permission", roles,
                                           s => SymbolLogic <PermissionSymbol> .TryToSymbol(replacements.Apply(replacementKey, s)), bool.Parse));
                };

                sb.Schema.Table <PermissionSymbol>().PreDeleteSqlSync += new Func <Entity, SqlPreCommand>(AuthCache_PreDeleteSqlSync);
            }
        }
예제 #6
0
        public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                SymbolLogic <FileTypeSymbol> .Start(sb, dqm, () => FileTypes.Keys.ToHashSet());

                sb.Include <FileTypeSymbol>()
                .WithQuery(dqm, () => f => new
                {
                    Entity = f,
                    f.Key
                });

                sb.Schema.SchemaCompleted += Schema_SchemaCompleted;
            }
        }
예제 #7
0
        public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                sb.Include <OperationLogEntity>();

                SymbolLogic <OperationSymbol> .Start(sb, () => RegisteredOperations);

                dqm.RegisterQuery(typeof(OperationSymbol), () =>
                                  from os in Database.Query <OperationSymbol>()
                                  select new
                {
                    Entity = os,
                    os.Id,
                    os.Key
                });

                dqm.RegisterQuery(typeof(OperationLogEntity), () =>
                                  from lo in Database.Query <OperationLogEntity>()
                                  select new
                {
                    Entity = lo,
                    lo.Id,
                    lo.Target,
                    lo.Operation,
                    lo.User,
                    lo.Start,
                    lo.End,
                    lo.Exception
                });

                dqm.RegisterExpression((OperationSymbol o) => o.Logs(), () => OperationMessage.Logs.NiceToString());
                dqm.RegisterExpression((Entity o) => o.OperationLogs(), () => typeof(OperationLogEntity).NicePluralName());

                sb.Schema.EntityEventsGlobal.Saving += EntityEventsGlobal_Saving;

                sb.Schema.Table <OperationSymbol>().PreDeleteSqlSync += new Func <Entity, SqlPreCommand>(Operation_PreDeleteSqlSync);
                sb.Schema.Table <TypeEntity>().PreDeleteSqlSync      += new Func <Entity, SqlPreCommand>(Type_PreDeleteSqlSync);

                sb.Schema.SchemaCompleted += OperationLogic_Initializing;

                ExceptionLogic.DeleteLogs += ExceptionLogic_DeleteLogs;
            }
        }
예제 #8
0
        public static void Start(SchemaBuilder sb)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                sb.Include <OperationLogEntity>()
                .WithQuery(() => lo => new
                {
                    Entity = lo,
                    lo.Id,
                    lo.Target,
                    lo.Operation,
                    lo.User,
                    lo.Start,
                    lo.End,
                    lo.Exception
                });

                SymbolLogic <OperationSymbol> .Start(sb, () => RegisteredOperations);

                sb.Include <OperationSymbol>()
                .WithQuery(() => os => new
                {
                    Entity = os,
                    os.Id,
                    os.Key
                });

                QueryLogic.Expressions.Register((OperationSymbol o) => o.Logs(), () => OperationMessage.Logs.NiceToString());
                QueryLogic.Expressions.Register((Entity o) => o.OperationLogs(), () => typeof(OperationLogEntity).NicePluralName());


                sb.Schema.EntityEventsGlobal.Saving += EntityEventsGlobal_Saving;

                sb.Schema.Table <OperationSymbol>().PreDeleteSqlSync += new Func <Entity, SqlPreCommand>(Operation_PreDeleteSqlSync);
                sb.Schema.Table <TypeEntity>().PreDeleteSqlSync      += new Func <Entity, SqlPreCommand>(Type_PreDeleteSqlSync);

                sb.Schema.SchemaCompleted += OperationLogic_Initializing;
                sb.Schema.SchemaCompleted += () => RegisterCurrentLogs(sb.Schema);

                ExceptionLogic.DeleteLogs += ExceptionLogic_DeleteLogs;
            }
        }
예제 #9
0
        internal static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                SymbolLogic <SimpleTaskSymbol> .Start(sb, dqm, () => tasks.Keys.ToHashSet());

                SchedulerLogic.ExecuteTask.Register((SimpleTaskSymbol st, ScheduledTaskContext ctx) =>
                {
                    Func <ScheduledTaskContext, Lite <IEntity> > func = tasks.GetOrThrow(st);
                    return(func(ctx));
                });

                sb.Include <SimpleTaskSymbol>()
                .WithQuery(dqm, () => ct => new
                {
                    Entity = ct,
                    ct.Id,
                    ct.Key,
                });
            }
        }
예제 #10
0
        public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                AuthLogic.AssertStarted(sb);

                sb.Include <PermissionSymbol>();

                SymbolLogic <PermissionSymbol> .Start(sb, dqm, () => RegisteredPermission.ToHashSet());

                cache = new AuthCache <RulePermissionEntity, PermissionAllowedRule, PermissionSymbol, PermissionSymbol, bool>(sb,
                                                                                                                              s => s,
                                                                                                                              s => s,
                                                                                                                              merger: new PermissionMerger(),
                                                                                                                              invalidateWithTypes: false);

                RegisterPermissions(BasicPermission.AdminRules,
                                    BasicPermission.AutomaticUpgradeOfProperties,
                                    BasicPermission.AutomaticUpgradeOfOperations,
                                    BasicPermission.AutomaticUpgradeOfQueries);

                AuthLogic.ExportToXml += exportAll => cache.ExportXml("Permissions", "Permission", a => a.Key, b => b.ToString(),
                                                                      exportAll ? PermissionAuthLogic.RegisteredPermission.ToList() : null);
                AuthLogic.ImportFromXml += (x, roles, replacements) =>
                {
                    string replacementKey = "AuthRules:" + typeof(PermissionSymbol).Name;

                    replacements.AskForReplacements(
                        x.Element("Permissions").Elements("Role").SelectMany(r => r.Elements("Permission")).Select(p => p.Attribute("Resource").Value).ToHashSet(),
                        SymbolLogic <PermissionSymbol> .Symbols.Select(s => s.Key).ToHashSet(),
                        replacementKey);

                    return(cache.ImportXml(x, "Permissions", "Permission", roles,
                                           s => SymbolLogic <PermissionSymbol> .TryToSymbol(replacements.Apply(replacementKey, s)), bool.Parse));
                };
            }
        }
예제 #11
0
        public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                sb.Include <ProcessAlgorithmSymbol>()
                .WithQuery(dqm, () => pa => new
                {
                    Entity = pa,
                    pa.Id,
                    pa.Key
                });

                sb.Include <ProcessEntity>()
                .WithQuery(dqm, () => p => new
                {
                    Entity = p,
                    p.Id,
                    p.Algorithm,
                    p.Data,
                    p.State,
                    p.MachineName,
                    p.ApplicationName,
                    p.CreationDate,
                    p.PlannedDate,
                    p.CancelationDate,
                    p.QueuedDate,
                    p.ExecutionStart,
                    p.ExecutionEnd,
                    p.SuspendDate,
                    p.ExceptionDate,
                });

                sb.Include <ProcessExceptionLineEntity>()
                .WithQuery(dqm, () => p => new
                {
                    Entity = p,
                    p.Line,
                    p.Process,
                    p.Exception,
                });

                PermissionAuthLogic.RegisterPermissions(ProcessPermission.ViewProcessPanel);

                SymbolLogic <ProcessAlgorithmSymbol> .Start(sb, dqm, () => registeredProcesses.Keys.ToHashSet());

                OperationLogic.AssertStarted(sb);

                ProcessGraph.Register();

                dqm.RegisterExpression((ProcessAlgorithmSymbol p) => p.Processes(), () => typeof(ProcessEntity).NicePluralName());
                dqm.RegisterExpression((ProcessAlgorithmSymbol p) => p.LastProcess(), () => ProcessMessage.LastProcess.NiceToString());

                dqm.RegisterExpression((IProcessDataEntity p) => p.Processes(), () => typeof(ProcessEntity).NicePluralName());
                dqm.RegisterExpression((IProcessDataEntity p) => p.LastProcess(), () => ProcessMessage.LastProcess.NiceToString());

                dqm.RegisterExpression((IProcessLineDataEntity p) => p.ExceptionLines(), () => ProcessMessage.ExceptionLines.NiceToString());

                PropertyAuthLogic.AvoidAutomaticUpgradeCollection.Add(PropertyRoute.Construct((ProcessEntity p) => p.User));

                ExceptionLogic.DeleteLogs += ExceptionLogic_DeleteLogs;
            }
        }
예제 #12
0
        public static void Start(SchemaBuilder sb, DynamicQueryManager dqm)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                sb.Include <WordTemplateEntity>()
                .WithSave(WordTemplateOperation.Save)
                .WithDelete(WordTemplateOperation.Delete)
                .WithQuery(dqm, () => e => new
                {
                    Entity = e,
                    e.Id,
                    e.Name,
                    e.Query,
                    e.Culture,
                    e.Template.Entity.FileName
                });

                PermissionAuthLogic.RegisterPermissions(WordTemplatePermission.GenerateReport);

                SystemWordTemplateLogic.Start(sb, dqm);

                SymbolLogic <WordTransformerSymbol> .Start(sb, dqm, () => Transformers.Keys.ToHashSet());

                SymbolLogic <WordConverterSymbol> .Start(sb, dqm, () => Converters.Keys.ToHashSet());

                sb.Include <WordTransformerSymbol>()
                .WithQuery(dqm, () => f => new
                {
                    Entity = f,
                    f.Key
                });

                sb.Include <WordConverterSymbol>()
                .WithQuery(dqm, () => f => new
                {
                    Entity = f,
                    f.Key
                });


                ToDataTableProviders.Add("Model", new ModelDataTableProvider());
                ToDataTableProviders.Add("UserQuery", new UserQueryDataTableProvider());
                ToDataTableProviders.Add("UserChart", new UserChartDataTableProvider());

                dqm.RegisterExpression((SystemWordTemplateEntity e) => e.WordTemplates(), () => typeof(WordTemplateEntity).NiceName());


                new Graph <WordTemplateEntity> .Execute(WordTemplateOperation.CreateWordReport)
                {
                    CanExecute = et =>
                    {
                        if (et.SystemWordTemplate != null && SystemWordTemplateLogic.RequiresExtraParameters(et.SystemWordTemplate))
                        {
                            return(WordTemplateMessage._01RequiresExtraParameters.NiceToString(typeof(SystemWordTemplateEntity).NiceName(), et.SystemWordTemplate));
                        }

                        return(null);
                    },
                    Execute = (et, args) =>
                    {
                        throw new InvalidOperationException("UI-only operation");
                    }
                }

                .Register();

                WordTemplatesLazy = sb.GlobalLazy(() => Database.Query <WordTemplateEntity>()
                                                  .ToDictionary(et => et.ToLite()), new InvalidateWith(typeof(WordTemplateEntity)));

                TemplatesByQueryName = sb.GlobalLazy(() =>
                {
                    return(WordTemplatesLazy.Value.Values.GroupToDictionary(a => a.Query.ToQueryName()));
                }, new InvalidateWith(typeof(WordTemplateEntity)));

                TemplatesByEntityType = sb.GlobalLazy(() =>
                {
                    return((from wr in WordTemplatesLazy.Value.Values
                            let imp = DynamicQueryManager.Current.GetEntityImplementations(wr.Query.ToQueryName())
                                      where !imp.IsByAll
                                      from t in imp.Types
                                      select KVP.Create(t, wr))
                           .GroupToDictionary(a => a.Key, a => a.Value));
                }, new InvalidateWith(typeof(WordTemplateEntity)));

                Schema.Current.Synchronizing += Schema_Synchronize_Tokens;

                Validator.PropertyValidator((WordTemplateEntity e) => e.Template).StaticPropertyValidation += ValidateTemplate;
            }
        }
예제 #13
0
    public static void Start(SchemaBuilder sb, IFileTypeAlgorithm predictorFileAlgorithm)
    {
        if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
        {
            sb.Settings.AssertIgnored((PredictorEntity p) => p.MainQuery.Filters.Single().Pinned, "use PredictorLogic", "by calling PredictorLogic.IgnorePinned in Starter.OverrideAttributes");
            sb.Settings.AssertIgnored((PredictorSubQueryEntity p) => p.Filters.Single().Pinned, "use PredictorLogic", "by calling PredictorLogic.IgnorePinned in Starter.OverrideAttributes");

            sb.Include <PredictorEntity>()
            .WithVirtualMList(p => p.SubQueries, mc => mc.Predictor)
            .WithQuery(() => e => new
            {
                Entity = e,
                e.Id,
                e.Name,
                e.MainQuery.Query,
                e.Algorithm,
                e.State,
                e.TrainingException,
            });

            PredictorGraph.Register();

            sb.Include <PredictorSubQueryEntity>()
            .WithQuery(() => e => new
            {
                Entity = e,
                e.Id,
                e.Name,
                e.Query,
                e.Predictor
            });

            sb.Include <PredictorCodificationEntity>()
            .WithUniqueIndex(pc => new { pc.Predictor, pc.Index, pc.Usage })
            .WithExpressionFrom((PredictorEntity e) => e.Codifications())
            .WithQuery(() => e => new
            {
                Entity = e,
                e.Id,
                e.Predictor,
                e.Index,
                e.Usage,
                e.OriginalColumnIndex,
                e.SubQueryIndex,
                e.SplitKey0,
                e.SplitKey1,
                e.SplitKey2,
                e.IsValue,
                e.Min,
                e.Max,
                e.Average,
                e.StdDev,
            });

            sb.Include <PredictorEpochProgressEntity>()
            .WithExpressionFrom((PredictorEntity e) => e.EpochProgresses())
            .WithQuery(() => e => new
            {
                Entity = e,
                e.Predictor,
                e.Id,
                e.Epoch,
                e.Ellapsed,
                e.LossTraining,
                e.AccuracyTraining,
                e.LossValidation,
                e.AccuracyValidation,
            });

            FileTypeLogic.Register(PredictorFileType.PredictorFile, predictorFileAlgorithm);

            SymbolLogic <PredictorAlgorithmSymbol> .Start(sb, () => Algorithms.Keys);

            SymbolLogic <PredictorColumnEncodingSymbol> .Start(sb, () => Algorithms.Values.SelectMany(a => a.GetRegisteredEncodingSymbols()).Distinct());

            SymbolLogic <PredictorResultSaverSymbol> .Start(sb, () => ResultSavers.Keys);

            SymbolLogic <PredictorPublicationSymbol> .Start(sb, () => Publications.Keys);

            sb.Schema.EntityEvents <PredictorEntity>().Retrieved         += PredictorEntity_Retrieved;
            sb.Schema.EntityEvents <PredictorSubQueryEntity>().Retrieved += PredictorMultiColumnEntity_Retrieved;

            Validator.PropertyValidator((PredictorColumnEmbedded c) => c.Encoding).StaticPropertyValidation      += Column_StaticPropertyValidation;
            Validator.PropertyValidator((PredictorSubQueryColumnEmbedded c) => c.Token).StaticPropertyValidation += GroupKey_StaticPropertyValidation;
            Validator.PropertyValidator((PredictorSubQueryEntity c) => c.Columns).StaticPropertyValidation       += SubQueryColumns_StaticPropertyValidation;

            sb.Include <PredictSimpleResultEntity>()
            .WithQuery(() => e => new
            {
                Entity = e,
                e.Id,
                e.Predictor,
                e.Target,
                e.Type,
                e.OriginalValue,
                e.PredictedValue,
                e.OriginalCategory,
                e.PredictedCategory,
            });

            RegisterResultSaver(PredictorSimpleResultSaver.StatisticsOnly, new PredictorSimpleSaver {
                SaveAllResults = false
            });
            RegisterResultSaver(PredictorSimpleResultSaver.Full, new PredictorSimpleSaver {
                SaveAllResults = true
            });

            sb.Schema.EntityEvents <PredictorEntity>().PreUnsafeDelete += query =>
            {
                Database.Query <PredictSimpleResultEntity>().Where(a => query.Contains(a.Predictor.Entity)).UnsafeDelete();
                return(null);
            };

            sb.Schema.WhenIncluded <ProcessEntity>(() =>
            {
                sb.Schema.Settings.AssertImplementedBy((ProcessEntity p) => p.Data, typeof(PredictorEntity));
                sb.Schema.Settings.AssertImplementedBy((ProcessEntity p) => p.Data, typeof(AutoconfigureNeuralNetworkEntity));
                ProcessLogic.Register(PredictorProcessAlgorithm.AutoconfigureNeuralNetwork, new AutoconfigureNeuralNetworkAlgorithm());

                new Graph <ProcessEntity> .ConstructFrom <PredictorEntity>(PredictorOperation.AutoconfigureNetwork)
                {
                    CanConstruct = p => p.AlgorithmSettings is NeuralNetworkSettingsEntity ? null : ValidationMessage._0ShouldBeOfType1.NiceToString(p.NicePropertyName(_ => _.AlgorithmSettings), typeof(NeuralNetworkSettingsEntity).NiceName()),
                    Construct    = (p, _) =>
                    {
                        return(ProcessLogic.Create(PredictorProcessAlgorithm.AutoconfigureNeuralNetwork, new AutoconfigureNeuralNetworkEntity
                        {
                            InitialPredictor = p.ToLite()
                        }));
                    }
                }.Register();
            });
        }
    }