-
Notifications
You must be signed in to change notification settings - Fork 60
/
MetadataImport_Perspectives.cs
61 lines (50 loc) · 1.82 KB
/
MetadataImport_Perspectives.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var folderName = @"C:\Users\mikova\Desktop\Metadata"; //Update this to the folder that contains the Metadata Export text files
var fileName = @"\Perspectives.txt";
var Metadata = ReadFile(folderName+fileName);
// Split the file into rows by CR and LF characters:
var tsvRows = Metadata.Split(new[] {'\r','\n'},StringSplitOptions.RemoveEmptyEntries);
// Set array for perspective names
var col = tsvRows[0].Split('\t');
int pCount = col.Count() - 3;
string[] p = new string[1000];
for (int i = 0; i < pCount; i++)
{
p[i] = col[i+3];
}
// Loop through all rows but skip the first one:
foreach(var row in tsvRows.Skip(1))
{
var tsvColumns = row.Split('\t'); // Assume file uses tabs as column separator
if (pCount > 0)
{
for (int i = 0; i < pCount; i++)
{
var tableName = tsvColumns[0];
var objectName = tsvColumns[1];
var objectType = tsvColumns[2];
var persp = p[i];
bool yesno = true;
if (tsvColumns[i+3] == "Yes")
{
yesno = true;
}
else if (tsvColumns[i+3] == "No")
{
yesno = false;
}
// Update perspective values for objects
if (objectType == "Column")
{
Model.Tables[tableName].Columns[objectName].InPerspective[persp] = yesno;
}
else if (objectType == "Measure")
{
Model.Tables[tableName].Measures[objectName].InPerspective[persp] = yesno;
}
else if (objectType == "Hierarchy")
{
Model.Tables[tableName].Hierarchies[objectName].InPerspective[persp] = yesno;
}
}
}
}