Exemplo n.º 1
0
        protected override bool Retrieve(IPersistence persistence, ref ePersistence phase)
        {
            base.Retrieve(persistence, ref phase);
            switch (phase)
            {
            case ePersistence.Initial:
                _ShortName = persistence.GetFieldValue(Constants.Domain_Short_Name, "");

                string relativePath = persistence.GetFieldValue(Constants.Domain_Sub_Model, "");
                _Model = persistence.GetFullPath(relativePath);

                if (_Model != "")
                {
                    Tree.AddSubModel(this);
                }

                _Methods.Clear();
                _Methods.AddRange(persistence.GetFieldValues(Constants.Domain_Methods, ""));

                DataPersistence.Retrieve(persistence);

                break;
            }

            return(true);
        }
Exemplo n.º 2
0
        protected override bool Retrieve(IPersistence persistence, ref ePersistence phase)
        {
            base.Retrieve(persistence, ref phase);
            switch (phase)
            {
            case ePersistence.Initial:
                //Retrieve lVal
                string Reference = persistence.GetFieldValue(Constants.Domain_Reference, "");
                lVal.Domain = Tree.GetDomainObjectByReference(Reference) as IDomainObject;

                Reference = persistence.GetFieldValue(Constants.Variable_Reference, "");
                if (lVal.Domain != null)
                {
                    foreach (IBaseNode node in lVal.Domain.Nodes)
                    {
                        if (node.Reference == Reference)
                        {
                            lVal.Variable = node as IVariableDef;
                        }
                    }
                }
                else
                {
                    lVal.Variable = Tree.GetVariableByReference(Reference) as IVariableDef;
                }

                lVal.Value = persistence.GetFieldValue(Constants.Value, "");

                //Retrieve rVal
                Reference   = persistence.GetFieldValue(Constants.Domain_Reference + "-r", "");
                rVal.Domain = Tree.GetDomainObjectByReference(Reference) as IDomainObject;

                Reference = persistence.GetFieldValue(Constants.Variable_Reference + "-r", "");
                if (rVal.Domain != null)
                {
                    foreach (IBaseNode node in rVal.Domain.Nodes)
                    {
                        if (node.Reference == Reference)
                        {
                            rVal.Variable = node as IVariableDef;
                        }
                    }
                }
                else
                {
                    rVal.Variable = Tree.GetVariableByReference(Reference) as IVariableDef;
                }

                rVal.Value = persistence.GetFieldValue(Constants.Value + "-r", "");

                _BranchEvaluation = (BranchEvaluation)Enum.Parse(typeof(BranchEvaluation),
                                                                 persistence.GetFieldValue(Constants.Branch_Evaluation, BranchEvaluation.Once.ToString()));

                _Expression = persistence.GetFieldValue(Constants.Expression, "");
                break;
            }

            return(true);
        }
Exemplo n.º 3
0
        protected override bool Retrieve(IPersistence persistence, ref ePersistence phase)
        {
            base.Retrieve(persistence, ref phase);
            switch (phase)
            {
            case ePersistence.Initial:
                _Value    = persistence.GetFieldValue(Constants.IntVariable_Value, 0m);
                MinValue  = persistence.GetFieldValue(Constants.IntVariable_MinValue, 0m);
                MaxValue  = persistence.GetFieldValue(Constants.IntVariable_MaxValue, 0m);
                StepValue = persistence.GetFieldValue(Constants.IntVariable_StepValue, 1m);
                break;
            }

            return(true);
        }
Exemplo n.º 4
0
        protected override bool Retrieve(IPersistence persistence, ref ePersistence phase)
        {
            base.Retrieve(persistence, ref phase);
            switch (phase)
            {
            case ePersistence.Initial:
                DataPersistence.Retrieve(persistence);

                string json = persistence.GetFieldValue(Constants.ModelDatasource, "");
                if (json != "")
                {
                    Dictionary <string, List <string> > fromJson = JsonConvert.DeserializeObject <Dictionary <string, List <string> > >(json);
                    foreach (string key in fromJson.Keys)
                    {
                        IMapping mapping = new IMappingImpl();
                        mapping.DecisionModelNode = Tree.GetNodeByReference(key);
                        mapping.FromStringArray(fromJson[key]);

                        DecisionModelDataSources.Add(mapping);
                    }
                }

                break;
            }

            return(true);
        }
Exemplo n.º 5
0
        protected override bool Retrieve(IPersistence persistence, ref ePersistence phase)
        {
            Persistence = persistence;

            while (persistence.NextRecord())
            {
                string type = persistence.GetFieldValue(Constants.BaseNode_ClassType, Constants.BaseNode_Type);
                if (type == "sakwa.IBaseNodeImpl")
                {
                    type = "sakwa.IRootNodeImpl";
                }

                RootNode        = IDecisionTreeInterface.CreateNewNode(type);
                RootNode.Parent = this;
                RootNode.Tree   = this;

                phase = ePersistence.Final;

                RootNode.NodeLoaded += RootNode_NodeLoaded;

                return(RootNode.Retrieve(persistence));
            }

            return(false);
        }
Exemplo n.º 6
0
        bool IDataPersistence.Retrieve(IPersistence persistence)
        {
            InitializeMode = (eInitializeMode)Enum.Parse(
                typeof(eInitializeMode),
                persistence.GetFieldValue(Constants.IDataPesistence_InitializeMode,
                                          eInitializeMode.None.ToString()));

            PersistMode = (ePersistMode)Enum.Parse(
                typeof(ePersistMode),
                persistence.GetFieldValue(Constants.IDataPesistence_PersistMode,
                                          ePersistMode.Never.ToString()));

            string[] connections = persistence.GetFieldValues(Constants.IDataPesistence_DataConnections, "");
            DataConnections.Clear();
            DataConnections.AddRange(connections);

            return(true);
        }
Exemplo n.º 7
0
        protected override bool Retrieve(IPersistence persistence, ref ePersistence phase)
        {
            base.Retrieve(persistence, ref phase);
            switch (phase)
            {
            case ePersistence.Initial:
                //Retrieve lVal
                string Reference = persistence.GetFieldValue(Constants.Domain_Reference, "");
                lVal.Domain = Tree.GetDomainObjectByReference(Reference) as IDomainObject;

                Reference = persistence.GetFieldValue(Constants.Variable_Reference, "");
                if (lVal.Domain != null)
                {
                    foreach (IBaseNode node in lVal.Domain.Nodes)
                    {
                        if (node.Reference == Reference)
                        {
                            lVal.Variable = node as IVariableDef;
                        }
                    }
                }
                else
                {
                    lVal.Variable = Tree.GetVariableByReference(Reference) as IVariableDef;
                }

                lVal.Value = persistence.HasField(Constants.Value)
                        ? persistence.GetFieldValue(Constants.Value, "")
                        : _Name;

                //Retieve rValue
                Reference   = persistence.GetFieldValue(Constants.Domain_Reference + "-r", "");
                rVal.Domain = Tree.GetDomainObjectByReference(Reference) as IDomainObject;

                Reference = persistence.GetFieldValue(Constants.Variable_Reference + "-r", "");
                if (rVal.Domain != null)
                {
                    foreach (IBaseNode node in rVal.Domain.Nodes)
                    {
                        if (node.Reference == Reference)
                        {
                            rVal.Variable = node as IVariableDef;
                        }
                    }
                }
                else
                {
                    rVal.Variable = Tree.GetVariableByReference(Reference) as IVariableDef;
                }

                rVal.Value = persistence.GetFieldValue(Constants.Value + "-r", "");

                _Expression = persistence.GetFieldValue(Constants.Expression, "");
                break;
            }

            return(true);
        }
Exemplo n.º 8
0
        protected override bool Retrieve(IPersistence persistence, ref ePersistence phase)
        {
            base.Retrieve(persistence, ref phase);
            switch (phase)
            {
            case ePersistence.Initial:
                string dataSourceFactory = persistence.GetFieldValue(Constants.DataNode_DataSourceFactory, "");
                if (dataSourceFactory != "" && _DataSourceManager != null)
                {
                    _DataSourceFactory = _DataSourceManager.GetDataSourceFactory(dataSourceFactory);
                    if (_DataSourceFactory != null)
                    {
                        _ConnectionProperties = _DataSourceFactory.ConnectionProperties;
                    }
                }

                string json = persistence.GetFieldValue(Constants.DataNode_DataSourceProperties, "");
                if (json != "")
                {
                    try
                    {
                        Dictionary <string, string> props = JsonConvert.DeserializeObject <Dictionary <string, string> >(json);
                        foreach (string name in props.Keys)
                        {
                            IProperty prop = getProperty(name);
                            if (prop != null)
                            {
                                prop.Value = props[name];
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Debug(ex.ToString());
                    }
                }

                break;
            }

            return(true);
        }
Exemplo n.º 9
0
        protected override bool Retrieve(IPersistence persistence, ref ePersistence phase)
        {
            base.Retrieve(persistence, ref phase);
            switch (phase)
            {
            case ePersistence.Initial:
                _VariableType = (eVariableType)Enum.Parse(typeof(eVariableType), persistence.GetFieldValue(Constants.Variable_Type, eVariableType.character.ToString()), true);
                break;
            }

            return(true);
        }
Exemplo n.º 10
0
        protected override bool Retrieve(IPersistence persistence, ref ePersistence phase)
        {
            base.Retrieve(persistence, ref phase);
            switch (phase)
            {
            case ePersistence.Initial:
                _Value = persistence.GetFieldValue(Constants.CharVariable_Value, "");
                break;
            }

            return(true);
        }
Exemplo n.º 11
0
        IBaseNode IDecisionTree.LoadVariables(IPersistence persistence)
        {
            if (persistence.NextRecord())
            {
                string    type = persistence.GetFieldValue(Constants.BaseNode_ClassType, Constants.BaseNode_ClassType);
                IBaseNode node = IDecisionTreeInterface.CreateNewNode(type);

                node.Reference = persistence.GetFieldValue(Constants.BaseNode_Reference, new Guid().ToString());
                int count = persistence.GetFieldValue(Constants.BaseNode_NodeCount, 0);
                node.NodeType = (eNodeType)Enum.Parse(typeof(eNodeType), persistence.GetFieldValue(Constants.BaseNode_Type, eNodeType.unknown.ToString()), true);
                node.Name     = persistence.GetFieldValue(Constants.BaseNode_Name, "");

                node.Parent = this;
                node.Tree   = this;

                if (persistence.NextRecord())
                {
                    type = persistence.GetFieldValue(Constants.BaseNode_ClassType, Constants.BaseNode_ClassType);
                    IBaseNode variables = IDecisionTreeInterface.CreateNewNode(type);

                    variables.Parent = node;
                    variables.Tree   = this;
                    variables.Retrieve(persistence);

                    return(variables);
                }
            }

            return(null);
        }
Exemplo n.º 12
0
        protected override bool Retrieve(IPersistence persistence, ref ePersistence phase)
        {
            base.Retrieve(persistence, ref phase);
            switch (phase)
            {
            case ePersistence.Initial:
                _Value = persistence.GetFieldValue(Constants.EnumVariable_Value, "");
                _Elements.Clear();
                _Elements.AddRange(persistence.GetFieldValues(Constants.EnumVariable_Choices, ""));
                break;
            }

            return(true);
        }
Exemplo n.º 13
0
        protected override bool Retrieve(IPersistence persistence, ref ePersistence phase)
        {
            base.Retrieve(persistence, ref phase);
            switch (phase)
            {
            case ePersistence.Initial:
                string relativePath = persistence.GetFieldValue(Constants.Root_Template, "");
                _DomainTemplate = persistence.GetFullPath(relativePath);

                break;
            }

            return(true);
        }
Exemplo n.º 14
0
        protected virtual bool Retrieve(IPersistence persistence, ref ePersistence phase)
        {
            switch (phase)
            {
            case ePersistence.Initial:
                Reference = persistence.GetFieldValue(Constants.BaseNode_Reference, new Guid().ToString());
                count     = persistence.GetFieldValue(Constants.BaseNode_NodeCount, 0);
                if (NodeType == eNodeType.unknown)
                {
                    NodeType = (eNodeType)Enum.Parse(typeof(eNodeType), persistence.GetFieldValue(Constants.BaseNode_Type, eNodeType.unknown.ToString()), true);
                }
                _Name        = persistence.GetFieldValue(Constants.BaseNode_Name, "");
                _Description = persistence.GetFieldValue(Constants.BaseNode_Description, "");
                break;

            case ePersistence.Final:
                if (!IsReadOnly())
                {
                    for (int i = 0; i < count; i++)
                    {
                        if (persistence.NextRecord())
                        {
                            string type = persistence.GetFieldValue(Constants.BaseNode_ClassType, Constants.BaseNode_ClassType);

                            IBaseNode node = Tree.CreateNewNode(type);
                            node.NodeLoaded += NodeLoaded;
                            node.Parent      = this;

                            Nodes.Add(node);

                            node.Retrieve(persistence);
                        }
                    }

                    OnNodeLoaded();
                }
                break;
            }

            return(true);
        }