private/AdfObject.class.ps1

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
class AdfObject {
    [string] $Name
    [string] $Type
    [string] $FileName
    [System.Collections.Hashtable] $DependsOn = @{}
    [Boolean] $Deployed = $false
    [Boolean] $ToBeDeployed = $true
    [Adf] $Adf
    [PSCustomObject] $Body

    [Boolean] AddDependant ([string]$name, [string]$type)
    {
        $type2 = $type.Replace('Reference', '')
        if (!$this.DependsOn.ContainsKey($name)) {
            $this.DependsOn.Add( $name, $type2 ) | Out-Null
        }
        return $true
    }

    [String] FullName ([boolean] $quoted)
    {
        $simtype = Get-SimplifiedType -Type $this.Type
        if ($quoted) {
            return "[$simtype].[$($this.Name)]"
        } else {
            return "$simtype.$($this.Name)"
        }
    }

    [String] FullName ()
    {
        return $this.FullName($false)
    }

    [String] FullNameQuoted ()
    {
        return $this.FullName($true)
    }

    [String] GetFolderName()
    {
        $ofn = $null
        if ($this.Body.PSObject.Properties.Name -contains "properties")
        {
            $o = $this.Body.properties
            if ($o.PSobject.Properties.Name -contains "folder")
            {
                $ofn = $_.Body.properties.folder.name
            }
        }
        return $ofn
    }


}

if (!(Get-Variable ADF_FOLDERS -ErrorAction:SilentlyContinue)) {
    Set-Variable ADF_FOLDERS -option ReadOnly -value ('integrationRuntime', 'pipeline', 'dataset', 'dataflow', 'linkedService', 'trigger', 'factory')
}