Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#193 The cmdlet Add-IshBackgroundTask is extended with InputDataTempl… #195

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright (c) 2014 All Rights Reserved by the SDL Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -239,10 +239,10 @@ protected override void EndProcessing()
// remove duplicates from annotationIds list
annotationIds = annotationIds.Distinct().ToList();
WriteDebug($"Retrieving AnnotationId.length[{annotationIds.Count}] MetadataFilter.length[{metadataFilter.ToXml().Length}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}]");
// Devides the list of Annotation Ids in different lists that all have maximally MetadataBatchSize elements
List<List<string>> devidedAnnotationIdsList = DevideListInBatches<string>(annotationIds, IshSession.MetadataBatchSize);
// Divides the list of Annotation Ids in different lists that all have maximally MetadataBatchSize elements
List<List<string>> dividedAnnotationIdsList = DivideListInBatches<string>(annotationIds, IshSession.MetadataBatchSize);
int currentAnnotationIdCount = 0;
foreach (List<string> annotationIdBatch in devidedAnnotationIdsList)
foreach (List<string> annotationIdBatch in dividedAnnotationIdsList)
{
string xmlIshObjectsRetrieved = IshSession.Annotation25.RetrieveMetadata(annotationIdBatch.ToArray(), metadataFilter.ToXml(), requestedMetadata.ToXml());
IshObjects ishObjectsRetrieved = new IshObjects(ISHType, xmlIshObjectsRetrieved);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright (c) 2014 All Rights Reserved by the SDL Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -189,11 +189,11 @@ protected override void EndProcessing()

//2. Retrieve set annotations
WriteDebug($"Retrieving AnnotationId.length[{annotationIdsToRetrieve.Count}]");
// Devides the list of Annotation Ids in different lists that all have maximally MetadataBatchSize elements
List<List<string>> devidedAnnotationIdsList = DevideListInBatches<string>(annotationIdsToRetrieve, IshSession.MetadataBatchSize);
// Divides the list of Annotation Ids in different lists that all have maximally MetadataBatchSize elements
List<List<string>> dividedAnnotationIdsList = DivideListInBatches<string>(annotationIdsToRetrieve, IshSession.MetadataBatchSize);
IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, returnFields, Enumerations.ActionMode.Read);
int currentAnnotationIdCount = 0;
foreach (List<string> annotationIdBatch in devidedAnnotationIdsList)
foreach (List<string> annotationIdBatch in dividedAnnotationIdsList)
{
string xmlIshObjectsRetrieved = IshSession.Annotation25.RetrieveMetadata(annotationIdBatch.ToArray(), "", requestedMetadata.ToXml());
IshObjects ishObjectsRetrieved = new IshObjects(ISHType, xmlIshObjectsRetrieved);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,79 @@ Describe "Add-IshBackgroundTask" -Tags "Create" {
$ishSession.MetadataBatchSize = $savedMetadataBatchSize
}
}


Context "Add-IshBackgroundTask IshObjectsGroup Pipeline IshObject with InputDataTemplate" {
BeforeAll {
$requestedMetadata = Set-IshRequestedMetadataField -IshSession $ishSession -Level Task -Name INPUTDATAID
}
It "Pipeline IshObject with LogicalId IshObjectsWithLngRef" {
if(([Version]$ishSession.ServerVersion).Major -ge 15 -or (([Version]$ishSession.ServerVersion).Major -ge 14 -and ([Version]$ishSession.ServerVersion).Revision -ge 4)) {
# Get-IshBackgroundTask is called to get the system field 'INPUTDATAID'
$backgroundTask = $ishObjects | Add-IshBackgroundTask -IshSession $ishSession -EventType "TESTBACKGROUNDTASK" -InputDataTemplate IshObjectsWithLngRef |
Get-IshBackgroundTask -IshSession $ishSession -RequestedMetadata $requestedMetadata

$inputData = $ishSession.BackgroundTask25.RetrieveDataObjectByIshDataRefs($backgroundTask.INPUTDATAID)
$xml = [xml]$inputData
$cdataNode = $xml.ishbackgroundtaskdataobjects.ishbackgroundtaskdataobject.'#cdata-section'
$rawCdataContent = $cdataNode
$decodedContent = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($rawCdataContent))
$ishObjectsFromInputData = [xml]$decodedContent

$ishObjectsFromInputData.ishObjects -ne $null | Should -Be $true
$ishObjectsFromInputData.ishObjects.ishObject.Count -ge 0 | Should -Be $true
$ishObjectsFromInputData.ishObjects.ishObject[0].ishtype -ne $null | Should -Be $true
$ishObjectsFromInputData.ishObjects.ishObject[0].ishref -ne $null | Should -Be $true
$ishObjectsFromInputData.ishObjects.ishObject[0].ishlogicalref -ne $null | Should -Be $true
$ishObjectsFromInputData.ishObjects.ishObject[0].ishversionref -ne $null | Should -Be $true
$ishObjectsFromInputData.ishObjects.ishObject[0].ishlngref -ne $null | Should -Be $true
}
}

It "Pipeline IshObject with LogicalId IshObjectWithLngRef" {
if(([Version]$ishSession.ServerVersion).Major -ge 15 -or (([Version]$ishSession.ServerVersion).Major -ge 14 -and ([Version]$ishSession.ServerVersion).Revision -ge 4)) {
# Get-IshBackgroundTask is called to get the system field 'INPUTDATAID'
$backgroundTask = Add-IshBackgroundTask -IshSession $ishSession -EventType "TESTBACKGROUNDTASK" -InputDataTemplate IshObjectWithLngRef -IshObject $ishObjectTopic1_1 |
Get-IshBackgroundTask -IshSession $ishSession -RequestedMetadata $requestedMetadata

$inputData = $ishSession.BackgroundTask25.RetrieveDataObjectByIshDataRefs($backgroundTask.INPUTDATAID)
$xml = [xml]$inputData
$cdataNode = $xml.ishbackgroundtaskdataobjects.ishbackgroundtaskdataobject.'#cdata-section'
$rawCdataContent = $cdataNode
$decodedContent = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($rawCdataContent))
$ishObjectFromInputData = [xml]$decodedContent

$ishObjectFromInputData.ishObject -ne $null | Should -Be $true
$ishObjectFromInputData.ishObject.ishtype -ne $null | Should -Be $true
$ishObjectFromInputData.ishObject.ishref -ne $null | Should -Be $true
$ishObjectFromInputData.ishObject.ishlogicalref -ne $null | Should -Be $true
$ishObjectFromInputData.ishObject.ishversionref -ne $null | Should -Be $true
$ishObjectFromInputData.ishObject.ishlngref -ne $null | Should -Be $true
}
}

It "Pipeline IshObject with LogicalId IshObjectsWithIshRef" {
if(([Version]$ishSession.ServerVersion).Major -ge 15 -or (([Version]$ishSession.ServerVersion).Major -ge 14 -and ([Version]$ishSession.ServerVersion).Revision -ge 4)) {
# Get-IshBackgroundTask is called to get the system field 'INPUTDATAID'
$backgroundTask = $ishObjects | Add-IshBackgroundTask -IshSession $ishSession -EventType "TESTBACKGROUNDTASK" -InputDataTemplate IshObjectsWithIshRef |
Get-IshBackgroundTask -IshSession $ishSession -RequestedMetadata $requestedMetadata

$inputData = $ishSession.BackgroundTask25.RetrieveDataObjectByIshDataRefs($backgroundTask.INPUTDATAID)
$xml = [xml]$inputData
$cdataNode = $xml.ishbackgroundtaskdataobjects.ishbackgroundtaskdataobject.'#cdata-section'
$rawCdataContent = $cdataNode
$decodedContent = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($rawCdataContent))
$ishObjectsFromInputData = [xml]$decodedContent

$ishObjectsFromInputData.ishObjects -ne $null | Should -Be $true
$ishObjectsFromInputData.ishObjects.ishObject.Count -ge 0 | Should -Be $true
$ishObjectsFromInputData.ishObjects.ishObject[0].ishtype -ne $null | Should -Be $true
$ishObjectsFromInputData.ishObjects.ishObject[0].ishref -ne $null | Should -Be $true
$ishObjectsFromInputData.ishObjects.ishObject[0].ishlogicalref -eq $null | Should -Be $true
$ishObjectsFromInputData.ishObjects.ishObject[0].ishversionref -eq $null | Should -Be $true
$ishObjectsFromInputData.ishObjects.ishObject[0].ishlngref -eq $null | Should -Be $true
}
}
}
Context "Add-IshBackgroundTask ParameterGroup" {
BeforeAll {
# If you get the below error, it means you configured default purge operation $ishEventTypetoPurge (defaults to PUSHTRANSLATIONS in ISHRemote.PesterSetup.ps1) away
Expand Down
Loading
Loading