示例#1
0
        public static void Serialize(TransformationTree transformationTree, string targetFile)
        {
            //Generate the Serializer:
            var nodeSerializer = new NodeSerializer();

            //Combine the JSON:
            dynamic json = new ExpandoObject();

            json.nodes       = transformationTree.Nodes.Select(nodeSerializer.serializeNode);
            json.connections = transformationTree.Connections.Select(nodeSerializer.serializeNodeConnection);


            //Create the Json settings:
            var jsonSettings = new JsonSerializerSettings()
            {
                ConstructorHandling   = ConstructorHandling.AllowNonPublicDefaultConstructor,
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                Formatting            = Formatting.Indented
            };

            //Generate a string and write it to the file:
            string text = JsonConvert.SerializeObject(json, jsonSettings);

            File.WriteAllText(targetFile, text);
        }
        /// <summary>
        /// Définit la valeur du TargetItem en cour d'édition
        /// et affiche cette valeur dans le TextBox
        /// </summary>
        /// <param name="value">La valeur du TargetItem en cour d'édition</param>
        public void SetValue(TransformationTree tree)
        {
            bool added = false;

            if (this.CombinedTransformationTreeItem == null)
            {
                this.CombinedTransformationTreeItem = new CombinedTransformationTreeItem(Index - 1);
                added = true;
            }

            int position = this.CombinedTransformationTreeItem.position;

            this.CombinedTransformationTreeItem.tree     = tree;
            this.CombinedTransformationTreeItem.position = position;
            String name = tree.name;

            this.TextBox.Text = tree != null ? tree.name : "";
            if (Added != null && added)
            {
                Added(this);
            }
            if (Updated != null && !added)
            {
                Updated(this);
            }
        }
示例#3
0
 public void AddTransformationTreeIfNatExist(TransformationTree tree)
 {
     if (getTransformationTreeByName(tree.name) != null)
     {
         return;
     }
     AddTransformationTree(tree);
 }
 public void displayTransformationTree(TransformationTree transformationTree)
 {
     if (transformationTree == null)
     {
         return;
     }
     nameTextBox.Text = transformationTree.name;
     groupField.Group = transformationTree.group;
     visibleInShortcutCheckBox.IsChecked = transformationTree.visibleInShortcut;
 }
示例#5
0
 /// <summary>
 /// Methode de selection du treeview qui renvoit l'élément selectionné
 /// et cet élément un design est transmis au InputTableTreeview
 /// par l'évènement OnClick
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnTreeNodeClick(object sender, MouseButtonEventArgs e)
 {
     if (TransformationTreeTreeView.SelectedItem != null && TransformationTreeTreeView.SelectedItem is BrowserData && SelectionChanged != null)
     {
         TransformationTree treeLoop = new TransformationTree();
         treeLoop.name = ((BrowserData)TransformationTreeTreeView.SelectedItem).name;
         treeLoop.oid  = ((BrowserData)TransformationTreeTreeView.SelectedItem).oid;
         SelectionChanged(treeLoop);
         e.Handled = true;
     }
 }
示例#6
0
 /// <summary>
 /// Retire un Design de la liste
 /// </summary>
 /// <param name="inputTable">L'Design à modifier</param>
 public void RemoveTransformationTree(TransformationTree transformationTree)
 {
     foreach (BrowserData data in this.liste)
     {
         if (data.name == transformationTree.name)
         {
             this.liste.Remove(data);
             this.cvs.DeferRefresh();
             return;
         }
     }
 }
 public void fillTransformationTree(TransformationTree transformationTree)
 {
     if (transformationTree == null)
     {
         return;
     }
     transformationTree.name = nameTextBox.Text;
     if (groupField.Group != null)
     {
         groupField.Group.subjectType = Kernel.Domain.SubjectType.TRANSFORMATION_TREE.label;
         transformationTree.group     = groupField.Group;
     }
     transformationTree.visibleInShortcut = visibleInShortcutCheckBox.IsChecked.Value;
 }
示例#8
0
        /// <summary>
        /// Retourne un Design à partir de son nom
        /// </summary>
        /// <param name="designName">Le nom de l'Design</param>
        /// <returns>L'Design renvoyé</returns>
        public TransformationTree getTreeLoopByName(string treeLoopName)
        {
            TransformationTree transformationTree = new TransformationTree();

            foreach (BrowserData obj in this.liste)
            {
                transformationTree.name = ((BrowserData)obj).name;
                transformationTree.oid  = ((BrowserData)obj).oid;
                if (transformationTree.name.ToUpper() == treeLoopName.ToUpper())
                {
                    return(transformationTree);
                }
            }
            return(null);
        }
示例#9
0
        /// <summary>
        /// Rajoute une inputTable
        /// </summary>
        /// <param name="inputTable">L'inputTable à modifier</param>
        public void AddTransformationTree(TransformationTree transformationTree)
        {
            BrowserData data = new BrowserData();

            if (transformationTree.oid.HasValue)
            {
                data.oid = transformationTree.oid.Value;
            }
            data.name = transformationTree.name;
            if (transformationTree.group != null)
            {
                data.group = transformationTree.group.name;
            }
            this.liste.Add(data);
            this.cvs.DeferRefresh();
        }
示例#10
0
 public TransformationTree deserializeTransformationTree(String json)
 {
     try
     {
         System.Web.Script.Serialization.JavaScriptSerializer Serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
         Serializer.MaxJsonLength = int.MaxValue;
         TransformationTree transformationTree = Serializer.Deserialize <TransformationTree>(json);
         if (transformationTree == null || transformationTree.oid == null || !transformationTree.oid.HasValue)
         {
             return(null);
         }
         return(transformationTree);
     }
     catch (Exception e)
     {
         logger.Debug("Fail to deserialize InputTable!", e);
     }
     return(null);
 }
示例#11
0
        /// <summary>
        /// Retourne un inputTable à partir de son nom
        /// </summary>
        /// <param name="inputTableName">Le nom de l'inputTable</param>
        /// <returns>L'inputTable renvoyé</returns>
        public TransformationTree getTransformationTreeByName(string inputTableName)
        {
            TransformationTree table = new TransformationTree();

            foreach (object obj in this.liste)
            {
                if (obj is TransformationTree)
                {
                    table.name = ((TransformationTree)obj).name;
                    table.oid  = ((TransformationTree)obj).oid;
                }
                else if (obj is BrowserData)
                {
                    table.name = ((BrowserData)obj).name;
                    table.oid  = ((BrowserData)obj).oid;
                }
                if (table.name.ToUpper() == inputTableName.ToUpper())
                {
                    return(table);
                }
            }
            return(null);
        }
示例#12
0
        public static void Deserialize(TransformationTree transformationTree, string targetFile)
        {
            //Read the singleton ClassManager.
            var classManager = Singleton <ClassManager> .Instance;

            //First clear old tree:
            foreach (var node in new List <Node>(transformationTree.Nodes))
            {
                if (!(node is OutputNode))
                {
                    transformationTree.DesignTree.RemoveNode(node);
                }
            }
            foreach (var connection in new List <Connection>(transformationTree.Connections))
            {
                transformationTree.DesignTree.RemoveConnection(connection);
            }

            //Generate the Serializer + lists:
            var nodeSerializer = new NodeSerializer();
            var treeDesigner   = transformationTree.DesignTree;

            var newNodes       = new List <Node>();
            var newConnections = new List <Connection>();

            var json = JObject.Parse(File.ReadAllText(targetFile));

            //Seems like this is the only way this is synthactically correct....
            //Read Nodes:
            foreach (dynamic obj in json["nodes"])
            {
                Node node = nodeSerializer.deserializeNode(obj, classManager);
                if (node != null)
                {
                    newNodes.Add(node);
                }
            }

            //Read connections:
            foreach (dynamic obj in json["connections"])
            {
                Connection?connection = nodeSerializer.deserializeConnection(obj, newNodes);
                if (connection.HasValue)
                {
                    //Apply the connection:
                    newConnections.Add(connection.Value);
                }
            }

            //Then add new ones. FIRST THE NODES!
            foreach (var node in newNodes)
            {
                if (node is OutputNode)
                {
                    transformationTree.OutputNode.PosX = node.PosX;
                    transformationTree.OutputNode.PosY = node.PosY;
                    transformationTree.OutputNode.Name = node.Name;
                }
                else
                {
                    treeDesigner.AddNode(node);
                }
            }

            //Apply the Connections at last.
            newConnections.ForEach(treeDesigner.AddConnection);
        }
示例#13
0
 /// <summary>
 /// Creates a new Generator.
 /// </summary>
 /// <param name="tree">To generate with.</param>
 public NewJavaGenerator(TransformationTree tree)
 {
     this._tree = tree;
 }