|
| 1 | +. "$global:rootDir\Helpers\EndpointsClass.ps1" |
| 2 | +. "$global:rootDir\Helpers\WriteInformationClass.ps1" |
| 3 | +. "$global:rootDir\Helpers\BaseExportService.ps1" |
| 4 | + |
| 5 | +# Your workspace ID: this is where we point to the workspace where we want to export from |
| 6 | +[int]$workspaceId = 1022188 |
| 7 | + |
| 8 | +# Export settings parameters |
| 9 | +# Your view ID: view will provide us with available data to export, requires folder to be visible there. |
| 10 | +# Your folder ID: our targetted folder. If you want to export from the workspace root, the ID is different from the workspace ID. |
| 11 | +# ExportSourceType: ExportFolder or ExportFolderWithSubfolders |
| 12 | +[int]$viewId = 1003684 |
| 13 | +[int]$folderID = 1003697 |
| 14 | +[bool]$withSubfolders = $true |
| 15 | + |
| 16 | +# ArtifactIds: Example: 1003668 - Extracted Text, 1003677 - Folder Name, 1003676 - Artifact ID, 1003667 - Control Number |
| 17 | +$fulltextPrecedenceFieldsArtifactIds = '[1003668,1003677]' |
| 18 | + |
| 19 | +# Aliases can use only artifact IDs that are in the fieldArtifactIDs list |
| 20 | +# Key is the artifact ID of the field, value is the alias |
| 21 | +$fieldArtifactIds = '[1003676,1003667]' |
| 22 | +$aliases = '{ |
| 23 | + "1003676": "Artifact ID - Field1", |
| 24 | + "1003667": "Control Number - Field2" |
| 25 | +}' |
| 26 | + |
| 27 | +# Job related data |
| 28 | +$jobId = New-Guid |
| 29 | +[string]$applicationName = "Export-Service-Sample-Powershell" |
| 30 | +[string]$applicationId = "Sample-Job-" + $MyInvocation.MyCommand.Name.Replace(".ps1", "") |
| 31 | +[int]$exportSourceType = if ($withSubfolders) { 3 } else { 2 } |
| 32 | + |
| 33 | +# Export job settings |
| 34 | +[string]$exportJobSettings = |
| 35 | +'{ |
| 36 | + "settings": { |
| 37 | + "ExportSourceSettings": { |
| 38 | + "ArtifactTypeID":10, |
| 39 | + "ExportSourceType":' + $exportSourceType + ', |
| 40 | + "ExportSourceArtifactID":' + $folderID + ', |
| 41 | + "ViewID":' + $viewId + ', |
| 42 | + "StartAtDocumentNumber":1 |
| 43 | + }, |
| 44 | + "ExportArtifactSettings": { |
| 45 | + "FileNamePattern":"{identifier}", |
| 46 | + "ExportNative":true, |
| 47 | + "ExportPdf":true, |
| 48 | + "ExportImages":true, |
| 49 | + "ExportFullText":true, |
| 50 | + "ExportMultiChoicesAsNested":false, |
| 51 | + "ImageExportSettings": { |
| 52 | + "ImagePrecedenceArtifactIDs":[-1], |
| 53 | + "TypeOfImage":2, |
| 54 | + }, |
| 55 | + "FullTextExportSettings": { |
| 56 | + "ExportFullTextAsFile":true, |
| 57 | + "TextFileEncoding":"utf-8", |
| 58 | + "PrecedenceFieldsArtifactIDs":' + $fulltextPrecedenceFieldsArtifactIds + ' |
| 59 | + }, |
| 60 | + "NativeFilesExportSettings": { |
| 61 | + "NativePrecedenceArtifactIDs":[-1] |
| 62 | + }, |
| 63 | + "FieldArtifactIDs":' + $fieldArtifactIds + ', |
| 64 | + "FieldAliases":' + $aliases + ', |
| 65 | + "ApplyFileNamePatternToImages":false |
| 66 | + }, |
| 67 | + "ExportOutputSettings": { |
| 68 | + "LoadFileSettings": { |
| 69 | + "LoadFileFormat":"CSV", |
| 70 | + "ImageLoadFileFormat":"IPRO", |
| 71 | + "PdfLoadFileFormat":"IPRO", |
| 72 | + "Encoding":"utf-8", |
| 73 | + "DelimitersSettings": { |
| 74 | + "NestedValueDelimiter":"B", |
| 75 | + "RecordDelimiter":"E", |
| 76 | + "QuoteDelimiter":"D", |
| 77 | + "NewlineDelimiter":"C", |
| 78 | + "MultiRecordDelimiter":"A" |
| 79 | + }, |
| 80 | + "ExportMsAccess": false |
| 81 | + }, |
| 82 | + "VolumeSettings": { |
| 83 | + "VolumePrefix":"VOL_FOLDER", |
| 84 | + "VolumeStartNumber":"1", |
| 85 | + "VolumeMaxSizeInMegabytes":100, |
| 86 | + "VolumeDigitPadding":5 |
| 87 | + }, |
| 88 | + "SubdirectorySettings": { |
| 89 | + "SubdirectoryStartNumber":1, |
| 90 | + "MaxNumberOfFilesInDirectory":100, |
| 91 | + "ImageSubdirectoryPrefix":"IMAGE_", |
| 92 | + "NativeSubdirectoryPrefix":"NATIVE_", |
| 93 | + "FullTextSubdirectoryPrefix":"FULLTEXT_", |
| 94 | + "PdfSubdirectoryPrefix":"PDFS_", |
| 95 | + "SubdirectoryDigitPadding":5 |
| 96 | + }, |
| 97 | + "CreateArchive":false, |
| 98 | + "FolderStructure":0 |
| 99 | + } |
| 100 | + }, |
| 101 | + "applicationName":"' + $applicationName + '", |
| 102 | + "correlationID":"' + $applicationId + '" |
| 103 | +}' |
| 104 | + |
| 105 | +# Create, run export job and display export job result |
| 106 | +$global:Endpoints = [Endpoints]::new($workspaceId) |
| 107 | +$global:WriteInformation = [WriteInformation]::new() |
| 108 | +$global:BaseExportService = [BaseExportService]::new() |
| 109 | + |
| 110 | +Context "Exports native, fulltext, images and PDF files from folder" { |
| 111 | + Describe "Create export job" { |
| 112 | + $global:BaseExportService.createExportJob($jobId, $exportJobSettings) |
| 113 | + } |
| 114 | + |
| 115 | + Describe "Start export job" { |
| 116 | + $global:BaseExportService.startExportJob($jobId) |
| 117 | + } |
| 118 | + |
| 119 | + Describe "Wait for export job to be completed" { |
| 120 | + $global:BaseExportService.waitForExportJobToBeCompleted($jobId) |
| 121 | + } |
| 122 | + |
| 123 | + Describe "Export job summary" { |
| 124 | + $global:BaseExportService.exportJobResult($jobId) |
| 125 | + } |
| 126 | +} |
| 127 | + |
0 commit comments