Produced by Araxis Merge on 11/9/2018 12:16:35 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | RAMS-2.3.0.zip\RAMS-2.3.0\ps | MigrateDataSharingRepository.ps1 | Sun Aug 19 22:22:30 2018 UTC |
2 | RAMS-2.3.0.zip\RAMS-2.3.0\ps | MigrateDataSharingRepository.ps1 | Fri Nov 9 14:50:12 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 518 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | <# | |
2 | ||
3 | .SYNOPSIS | |
4 | Builds a new Dat a Sharing Repository Agreement s (DSRA) L ist and mi grates the data from the old l ist. | |
5 | ||
6 | .DESCRIPTI ON | |
7 | Create s Faciliti es Lookup for the DS RA list | |
8 | Adds t he site co lumns to t he DSRA Co ntent Type | |
9 | Rename s the DSRA list to O ldDataShar ingReposit oryAgreeme nts | |
10 | Create s a new DS RA list | |
11 | NOT US ED - Migra tes the da ta from th e old DSRA to the ne w DSRA - T his kept g etting err ors in dev elopment s o, since t he data in productio n is only test data, this step is commen ted out. | |
12 | Create d the DSRA Standard View | |
13 | ||
14 | .EXAMPLE | |
15 | #when run from d eploymentD river.ps1 | |
16 | Run-Sc ript 340 M igrateData SharingRep ository.ps 1 | |
17 | ||
18 | .EXAMPLE | |
19 | #when run from c ommand lin e | |
20 | .\Migr ateDataSha ringReposi tory.ps1 | |
21 | #> | |
22 | Add-PSSnap in Microso ft.SharePo int.Powers hell | |
23 | ||
24 | function C reateDataS haringRepo sitoryFaci lityLookup s () { | |
25 | try { | |
26 | #C REATE SITE COLUMNS | |
27 | wr ite-log -m essage "CR EATING SIT E COLUMNS for 'Site Shared Wit h'" -conso leForegrou nd Gray | |
28 | ||
29 | # GET THE LI STS | |
30 | $m yList = $w .Lists["Fa cilities"] ; | |
31 | ||
32 | #W here the S ource List for Looku p Exists | |
33 | ||
34 | $P arentWebUR L=$siteURL | |
35 | $P arentListN ame="Facil ities" | |
36 | $P arentLooku pColumnNam e="Title" | |
37 | ||
38 | #W here the L ookup Site column Go ing to get created | |
39 | $C hildWebURL =$siteURL | |
40 | $C hildLookup ColumnName ="SiteShar edWith" | |
41 | ||
42 | #G et the Par ent and Ch ild Webs a nd List | |
43 | ||
44 | $P arentWeb = $w | |
45 | $P arentList = $w.Lists [$ParentLi stName] | |
46 | $C hildWeb = $w | |
47 | ||
48 | if (!$ChildWe b.Fields.C ontainsFie ld($ChildL ookupColum nName)) { | |
49 | #Add Loo kup Field | |
50 | $ChildLo okupColumn = $ChildW eb.Fields. AddLookup( $ChildLook upColumnNa me,$Parent List.id,$F alse) | |
51 | $ChildLo okupColumn = $ChildW eb.Fields[ $ChildLook upColumnNa me] | |
52 | ||
53 | #Setup l ookup Fiel d property | |
54 | $ChildLo okupColumn .LookupWeb Id = $Pare ntWeb.ID | |
55 | $ChildLo okupColumn .LookupFie ld = $Pare ntList.Fie lds[$Paren tLookupCol umnName].I nternalNam e | |
56 | ||
57 | #$ChildL ookupColum n.AllowMul tipleValue s=$true | |
58 | $ChildLo okupColumn .Group="RA MS IRB" | |
59 | $ChildLo okupColumn .Title="Si te Shared With" | |
60 | ||
61 | $ChildLo okupColumn .update() | |
62 | write-lo g -message "Lookup f ield $($Ch ildLookupC olumn.Inte rnalName) added succ essfully!" -consoleF oreground green | |
63 | } else { | |
64 | write-lo g -message "Field $C hildLookup ColumnName exists al ready!" -c onsoleFore ground red | |
65 | } | |
66 | } catc h { | |
67 | wr ite-log -m essage "Ex ception Oc curred:" - consoleFor eground Re d | |
68 | wr ite-log -m essage "$( $_.Excepti on.Message )" -consol eForegroun d Red | |
69 | if ($($_.Exc eption.Err orRecord)) { write-l og -messag e "$($_.Ex ception.Er rorRecord) " -console Foreground Red } | |
70 | if ($($_.Exc eption.sta cktrace)) { write-lo g -message "$($_.Exc eption.sta cktrace)" -consoleFo reground R ed } | |
71 | if ($($_.Scr iptStackTr ace)) { wr ite-log -m essage "$( $_.ScriptS tackTrace) " -console Foreground Red } | |
72 | } | |
73 | } | |
74 | ||
75 | function C reatDSRACo ntentType( $subweb) { | |
76 | $dsraC T = New-Ob ject Micro soft.Share Point.SPCo ntentType( $w.Availab leContentT ypes["Item "],$w.Cont entTypes," DSRA CT") | |
77 | $dsraC T.Group = "RAMS IRB" | |
78 | $w.Con tentTypes. Add($dsraC T) | write -log -cons oleForegro und White | |
79 | $w.Upd ate() | |
80 | } | |
81 | ||
82 | function A ddSiteColu mnsToConte ntType() { | |
83 | write- log -messa ge "AddSit eColumnsTo ContentTyp e DSRA CT" -consoleF oreground Cyan | |
84 | Add-Si teColumnTo CT -web (G et-SiteWeb ) -ctName "DSRA CT" -sFieldInt ernalName "DSTypeOfA greement" -sFieldSta ticName "D STypeOfAgr eement" | |
85 | Add-Si teColumnTo CT -web (G et-SiteWeb ) -ctName "DSRA CT" -sFieldInt ernalName "SiteShare dWith" -sF ieldStatic Name "Site SharedWith " | |
86 | Add-Si teColumnTo CT -web (G et-SiteWeb ) -ctName "DSRA CT" -sFieldInt ernalName "StudyTitl e" -sField StaticName "StudyTit le" | |
87 | Add-Si teColumnTo CT -web (G et-SiteWeb ) -ctName "DSRA CT" -sFieldInt ernalName "DSIRBAppr oval" -sFi eldStaticN ame "DSIRB Approval" | |
88 | Add-Si teColumnTo CT -web (G et-SiteWeb ) -ctName "DSRA CT" -sFieldInt ernalName "StartDate " -sFieldS taticName "StartDate " | |
89 | Add-Si teColumnTo CT -web (G et-SiteWeb ) -ctName "DSRA CT" -sFieldInt ernalName "RenewalDa te" -sFiel dStaticNam e "Renewal Date" | |
90 | Add-Si teColumnTo CT -web (G et-SiteWeb ) -ctName "DSRA CT" -sFieldInt ernalName "DSPIName" -sFieldSt aticName " DSPIName" | |
91 | } | |
92 | ||
93 | function A djustConte ntType () { | |
94 | #ADJUS T CONTENT TYPE ON LI ST | |
95 | write- log -messa ge "ADJUST CONTENT T YPE 'DSRA' " -console Foreground Cyan | |
96 | $ct = $w.Content Types["DSR A CT"] | |
97 | $fldLi st = @( | |
98 | "T itle", | |
99 | "D STypeOfAgr eement", | |
100 | "S iteSharedW ith", | |
101 | 'S tudyTitle' , | |
102 | "D SIRBApprov al", | |
103 | "S tartDate", | |
104 | "R enewalDate ", | |
105 | "D SPIName" | |
106 | ) | |
107 | $ct.Fi eldLinks.R eorder($fl dList) | |
108 | $ct.Up date($true ) | |
109 | } | |
110 | ||
111 | function R ecreateLis t ($subweb ) { | |
112 | #renam e current facility l ist to old list | |
113 | $agree mentslist =$subweb.L ists["Data SharingRep ositoryAgr eements"] | |
114 | $agree mentslist. Title = "O ld DataSha ringReposi toryAgreem ents" | |
115 | $oldag reementsli st = $subw eb.Lists.T ryGetList( "OldDataSh aringRepos itoryAgree ments") | |
116 | if($ol dagreement slist){ | |
117 | $o ldagreemen tslist.All owDeletion = $true | |
118 | $o ldagreemen tslist.Upd ate() | |
119 | $o ldagreemen tslist.Del ete() | |
120 | wr ite-log -m essage "Re moved an O ldDataShar ingReposit oryAgreeme nts List" -consoleFo reground Y ellow | |
121 | } | |
122 | $agree mentslist. RootFolder .MoveTo("O ldDataShar ingReposit oryAgreeme nts") | |
123 | #$agre ementslist .Update() | |
124 | write- log -messa ge "Rename d the Data SharingRep ositoryAgr eements li st to OldD ataSharing Repository Agreements " -console Foreground Yellow | |
125 | ||
126 | #creat e new faci lity list | |
127 | $listT emplate = $w.ListTem plates | ? {$_.Inter nalName -m atch "cust list"} | |
128 | $subwe b.Lists.Ad d("DataSha ringReposi toryAgreem ents","Dat aSharingRe positoryAg reements", $listTemp late) | |
129 | write- log -messa ge "Create d New Data SharingRep ositoryAgr eements Li st on $($s ubweb.URL) " -console Foreground Gray | |
130 | } | |
131 | ||
132 | function A ddContentT ypeToList( $subweb) { | |
133 | $agree mentslist = $subweb. Lists["Dat aSharingRe positoryAg reements"] | |
134 | $dsraC T = $w.Con tentTypes[ "DSRA CT"] | |
135 | ||
136 | $ctOnL ist=$agree mentslist. ContentTyp es["DSRA C T"] | |
137 | if($ct OnList -eq $null) { | |
138 | $a greementsl ist.Conten tTypes.Add ($dsraCT) | write-lo g -console Foreground white | |
139 | $a greementsl ist.Conten tTypes["It em"].Delet e() | |
140 | #$ agreements list.Conte ntTypes["F older"].De lete() | |
141 | $a greementsl ist.Update () | |
142 | } | |
143 | } | |
144 | ||
145 | function M igrateData SharingRep ositoryIte ms($subweb ) { | |
146 | try { | |
147 | wr ite-log -m essage "$( [String]:: Format("Pr ocesing we b {0}",$su bweb.Url)) " -console Foreground White | |
148 | wr ite-log -m essage "MO VING DataS haringRepo sitoryAgre ements OLD FIELDS TO DataShari ngReposito ryAgreemen ts LIST" - consoleFor eground Gr een | |
149 | #R ead needed items fro m the old facilit | |
150 | $o ldAgreemen tsList = $ subweb.Lis ts.TryGetL ist("OldDa taSharingR epositoryA greements" ) | |
151 | $a greementsL ist =$subw eb.Lists[" DataSharin gRepositor yAgreement s"] | |
152 | ||
153 | wr ite-log -m essage "Mi grating $( $oldAgreem entsList.I temCount) $($agreeme ntsList.Ti tle) recor ds" -conso leForegrou nd White | |
154 | ||
155 | fo reach($old Item in $o ldAgreemen tsList.Ite ms) { | |
156 | Write-lo g -message "Migratin g old reco rd: $oldIt em" -conso leForegrou nd Gray | |
157 | $newItem = $agreem entsList.A ddItem() | |
158 | ||
159 | if ($old Item["Titl e"] -ne $n ull) { | |
160 | $new Item["Titl e"] = $old Item["Titl e"] | |
161 | } | |
162 | ||
163 | if ($old Item["Type Of Agreem ent"] -ne $null) { | |
164 | $new Item["Type Of Agreem ent"] = $o ldItem["Ty pe Of Agre ement"] | |
165 | } | |
166 | ||
167 | $agreeme ntsFacilit ySharedLoo kup = $old Item["Faci lity Share d With"] | |
168 | ||
169 | if ($agr eementsFac ilityShare dLookup -n e $null) { | |
170 | $agr eementsFac ilityShare dLookupInd ex = $agre ementsFaci lityShared Lookup.Ind exOf("#") + 1 | |
171 | $agr eementsFac ilityShare dLookupTit le = $agre ementsFaci lityShared Lookup.sub string($ag reementsFa cilityShar edLookupIn dex) | |
172 | $agr eementsFac ilityShare dLookupIte m =GetFaci litiesItem ($agreemen tsFacility SharedLook upTitle) | |
173 | } | |
174 | ||
175 | if ($old Item["Stud y Title"] -ne $null) { | |
176 | $new Item["Site Shared Wi th"] = $ag reementsFa cilityShar edLookupIt em.Id | |
177 | } | |
178 | ||
179 | if ($old Item["Stud y Title"] -ne $null) { | |
180 | $new Item["Stud y Title"] = $oldItem ["Study Ti tle"] | |
181 | } | |
182 | ||
183 | if ($old Item["IRB Approval"] -ne $null ) { | |
184 | $new Item["IRB Approval"] = $oldIte m["IRB App roval"] | |
185 | } | |
186 | ||
187 | if ($old Item["Star t Date"] - ne $null) { | |
188 | $new Item["Star t Date"] = $oldItem[ "Start Dat e"] | |
189 | } | |
190 | ||
191 | if ($old Item["Rene wal Date"] -ne $null ) { | |
192 | $new Item["Rene wal Date"] = $oldIte m["Renewal Date"] | |
193 | } | |
194 | ||
195 | if ($old Item["PI N ame"] -ne $null) { | |
196 | $new Item["PI N ame"] = $o ldItem["PI Name"] | |
197 | } | |
198 | ||
199 | $newItem .Update() | |
200 | write-lo g -message "New item has been added to D araSharing Repository Agreements ." -consol eForegroun d Green | |
201 | } | |
202 | } catc h { | |
203 | wr ite-log -m essage "$( [String]:: Format("Er ror proces sing web a t {0}, wit h Exceptio n: {1}", $ subweb.Url , $_.Excep tion.Messa ge))" -con soleForegr ound Red | |
204 | } | |
205 | } | |
206 | ||
207 | function G etFaciliti esItem ($t itle) { | |
208 | $facil itiesList = (Get-Sit eWeb).List s.TryGetLi st("Facili ties") | |
209 | $spLis tItem = $ facilities List.Items | ? {$_[" Title"] -m atch $titl e} | |
210 | return $spListIt em; | |
211 | } | |
212 | ||
213 | function M odifyAllIt emsView ($ subweb) { | |
214 | $list = $subweb. Lists.TryG etList("Da taSharingR epositoryA greements" ) | |
215 | $fldLi st = @( | |
216 | 'L inkTitle'; | |
217 | 'D STypeOfAgr eement'; | |
218 | 'S iteSharedW ith'; | |
219 | 'S tudyTitle' ; | |
220 | 'D SIRBApprov al'; | |
221 | 'S tartDate'; | |
222 | 'R enewalDate '; | |
223 | 'D SPIName' | |
224 | ) | |
225 | $viewQ uery = "<W here></Whe re>" | |
226 | New-Sp FacilityLi stView -we b $subweb -fldList $ fldList -v iewTitle ' Agreements View' -lis tName $lis t.Title -v iewQuery $ viewQuery -viewRowLi mit '50' | |
227 | $view= $list.View s["Agreeme ntsView"] | |
228 | $view. DefaultVie w = $true | |
229 | $view. MobileView = $true | |
230 | $view. MobileDefa ultView = $true | |
231 | $view. Update() | |
232 | } | |
233 | ||
234 | function D eleteAllIt emsView ($ list) { | |
235 | $view= $list.View s["All Ite ms"] | |
236 | if ($v iew -ne $n ull) { | |
237 | $l ist.Views. Delete($vi ew.Id) | |
238 | $l ist.Update () | |
239 | } | |
240 | } | |
241 | ||
242 | #This is t o test the driver co ntains a $ siteUrl | |
243 | #$siteUrl= "https:// DNS . URL /sites/IRB Applicatio ns/"; | |
244 | $w = Get-S iteWeb | |
245 | write-log -message " Updating a nd Migrati ng Data Sh aring Repo sitory Agr eements" - consoleFor eground Ma genta | |
246 | CreateData SharingRep ositoryFac ilityLooku ps | |
247 | CreatDSRAC ontentType | |
248 | AddSiteCol umnsToCont entType | |
249 | AdjustCont entType | |
250 | $siteUrl = Get-SiteU RL | |
251 | ||
252 | (Get-SiteW eb).Webs | % { | |
253 | $facil itySite = $_ | |
254 | #Recre ate DataSh aringRepos itoryAgree ments | |
255 | Recrea teList $fa cilitySite | |
256 | AddCon tentTypeTo List $faci litySite | |
257 | ||
258 | #Migra teDataShar ingReposit oryItems $facilityS ite | |
259 | Modify AllItemsVi ew $facili tySite | |
260 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.