Skip to content

Commit

Permalink
Implemented algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
m-luketin committed May 27, 2019
1 parent 5bc3560 commit a2182c0
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Backend/Normalization.Maps/Algorithm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Normalization.ViewModel;

namespace Normalization.Maps.Algorithm
{
public class Algorithm
{
public NormalizedViewModel NormalizeTable(TableViewModel table)
{
var normalizedTable = new NormalizedViewModel();
var decompositionElement = new List<string>();

foreach (var dependencyViewModel in table.Dependencies)
{
decompositionElement.AddRange(dependencyViewModel.From);
decompositionElement.Add(dependencyViewModel.To);
normalizedTable.TableAttributes.Add(decompositionElement);
decompositionElement.Clear();
}

decompositionElement.AddRange(table.Keys.First());
normalizedTable.TableAttributes.Add(decompositionElement);
decompositionElement.Clear();

normalizedTable.TableAttributes = normalizedTable.TableAttributes.Distinct().ToList();


return normalizedTable;
}
}
}
35 changes: 35 additions & 0 deletions Backend/Normalization.Maps/Algorithm/Algorithm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Normalization.ViewModel;

namespace Normalization.Maps.Algorithm
{
public class Algorithm
{
public NormalizedViewModel NormalizeTable(TableViewModel table)
{
var normalizedTable = new NormalizedViewModel();
var decompositionElement = new List<string>();

foreach (var dependencyViewModel in table.Dependencies)
{
decompositionElement.AddRange(dependencyViewModel.From);
decompositionElement.Add(dependencyViewModel.To);
normalizedTable.TableAttributes.Add(decompositionElement);
decompositionElement.Clear();
}

decompositionElement.AddRange(table.Keys.First());
normalizedTable.TableAttributes.Add(decompositionElement);
decompositionElement.Clear();

normalizedTable.TableAttributes = normalizedTable.TableAttributes.Distinct().ToList();


return normalizedTable;
}
}
}

0 comments on commit a2182c0

Please sign in to comment.