-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
…ate and HashId.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
End of Friday review to attempt an unblock. Chose this issue over the older one ;-) as I think this one is more important.
Remember, ISHRemote works across all, so should remain backward compatible.
@@ -18,6 +18,8 @@ Describe "Add-IshBackgroundTask" -Tags "Create" { | |||
$global:ishBackgroundTaskCmdlet = Add-IshFolder -IShSession $ishSession -ParentFolderId $folderIdTestRootOriginal -FolderType $folderTypeTestRootOriginal -FolderName $cmdletName -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal | |||
$ishFolderTopic = Add-IshFolder -IshSession $ishSession -ParentFolderId($global:ishBackgroundTaskCmdlet.IshFolderRef) -FolderType ISHModule -FolderName "Topic" -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal | |||
|
|||
$inputMetadataField = Set-IshRequestedMetadataField -IshSession $ishSession -Level Task -Name INPUTDATAID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move variable down to a new BeforeAll block in section Context "Add-IshBackgroundTask IshObjectsGroup Pipeline IshObject with InputDataTemplate" {
... please also rename $inputMetadataField
to $requestedMetadata
@@ -128,6 +130,69 @@ Describe "Add-IshBackgroundTask" -Tags "Create" { | |||
$ishSession.MetadataBatchSize = $savedMetadataBatchSize | |||
} | |||
} | |||
|
|||
Context "Add-IshBackgroundTask IshObjectsGroup Pipeline IshObject with InputDataTemplate" { | |||
if(([Version]$ishSession.ServerVersion).Major -ge 15 -or (([Version]$ishSession.ServerVersion).Major -ge 14 -and ([Version]$ishSession.ServerVersion).Revision -ge 4)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just like in #175 ...
Pesters tests need to have if clauses WITHIN the Pester It scope, not around.... see https://pester.dev/docs/usage/discovery-and-run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I corrected it :-) I mistakenly thought that this condition could cover the test context
if(([Version]$ishSession.ServerVersion).Major -ge 15 -or (([Version]$ishSession.ServerVersion).Major -ge 14 -and ([Version]$ishSession.ServerVersion).Revision -ge 4)) { | ||
It "Pipeline IshObject with LogicalId IshObjectsWithLngRef" { | ||
$backgroundTask = $ishObjects | Add-IshBackgroundTask -IshSession $ishSession -EventType "TESTBACKGROUNDTASK" -InputDataTemplate IshObjectsWithLngRef | | ||
Get-IshBackgroundTask -IshSession $ishSession -RequestedMetadata $inputMetadataField |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purpose of a superfluous Get-IshBackgroundTask ... as the Add-IshBackgroundTask should already return a good value to the pipeline.... At least add a comment for that you want to retrieve system metadata which typically is not returned
using Trisoft.ISHRemote.BackgroundTask25ServiceReference; | ||
using Trisoft.ISHRemote.EventMonitor25ServiceReference; | ||
using System.Text; | ||
using System.Xml.Linq; | ||
using Microsoft.IdentityModel.Tokens; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purpose of this reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's for IsNullOrEmpty. -> EventDescription.IsNullOrEmpty()
@@ -46,13 +50,30 @@ namespace Trisoft.ISHRemote.Cmdlets.BackgroundTask | |||
/// New-IshSession -WsBaseUrl "https://example.com/ISHWS/" -PSCredential "Admin" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New sample should not write
New-IshSession -WsBaseUrl "https://example.com/ISHWS/" -PSCredential "Admin"
but
New-IshSession -WsBaseUrl "https://example.com/ISHWS/"
Same for other samples in this file. Refactoring other files is a separate story, at least make the new samples good
// Create BackgroundTask | ||
WriteDebug($"Create BackgroundTask EventType[{EventType}] RawInputData.length[{RawInputData.Length}] StartAfter[{StartAfter}]"); | ||
WriteDebug($"Create BackgroundTask EventType[{EventType}] RawInputData.length[{inputData}] StartAfter[{StartAfter}]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RawInputData.Length[{inputData}
- should be backgroundTaskInputData given line 314
- should be with .Length as we don't want to print 10000 bytes of text here
The before readWriteDebug($"Create BackgroundTask EventType[{EventType}] RawInputData.length[{RawInputData.Length}] StartAfter[{StartAfter}]");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved with the following
WriteDebug(ParameterSetName == "IshObjectsGroup" ?
$"Create BackgroundTask EventType[{EventType}] InputData.length[{inputData.Length}] StartAfter[{StartAfter}]" :
$"Create BackgroundTask EventType[{EventType}] RawInputData.length[{RawInputData.Length}] StartAfter[{StartAfter}]");
// Create BackgroundTask | ||
WriteDebug($"Create BackgroundTask EventType[{EventType}] RawInputData.length[{RawInputData.Length}]"); | ||
// Create BackgroundTask | ||
WriteDebug($"Create BackgroundTask EventType[{EventType}] RawInputData.length[{inputData}] StartAfter[{StartAfter}]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why print StartAfter value, when two lines up you checked it does not have a value... please do similar correction as higher.
Orginal was WriteDebug($"Create BackgroundTask EventType[{EventType}] RawInputData.length[{RawInputData.Length}]");
using Trisoft.ISHRemote.Folder25ServiceReference; | ||
using System.Runtime.InteropServices; | ||
using Trisoft.ISHRemote.Interfaces; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprised why removing a function, which I assume was not used (DevideListInBatchesByLogicalId
) results in 3 extra using statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not extra, the using section is ordered
#region Private fields | ||
private readonly List<IshObject> _retrievedIshObjects = new List<IshObject>(); | ||
private readonly DateTime _modifiedSince = DateTime.Today.AddDays(-1); | ||
private readonly BackgroundTask25ServiceReference.eUserFilter _userFilter = EnumConverter.ToUserFilter<BackgroundTask25ServiceReference.eUserFilter>(Enumerations.UserFilter.Current); | ||
private readonly eUserFilter _userFilter = EnumConverter.ToUserFilter<eUserFilter>(Enumerations.UserFilter.Current); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expected an _inputDataTemplate
here, like this EnumConverter.ToUserFi...
line. Because you made InputDataTemplate
a non-mandatory parameter, so if not specified it defaults to...?
Add a default for IshObjectsWithLngRef
because any customer that already has a script that reads Add-IshBackgroundTask -EventType "SMARTTAG"
should not break
@@ -46,13 +50,30 @@ namespace Trisoft.ISHRemote.Cmdlets.BackgroundTask | |||
/// New-IshSession -WsBaseUrl "https://example.com/ISHWS/" -PSCredential "Admin" | |||
/// $ishBackgroundTask = Get-IshFolder -FolderPath "General\Myfolder" -FolderTypeFilter @("ISHModule", "ISHMasterDoc", "ISHLibrary") -Recurse | | |||
/// Get-IshFolderContent -VersionFilter Latest -LanguagesFilter en | | |||
/// Add-IshBackgroundTask -EventType "SMARTTAG" | |||
/// Add-IshBackgroundTask -EventType "SMARTTAG" -InputDataTemplate IshObjectsWithLngRef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the explicit added -InputDataTemplate IshObjectsWithLngRef
. And enrich the help and this sample description to indicate that the default value of this parameter is `IshObjectsWithLngRef .
/// <para type="description">The InputDataTemplate (e.g. IshObjectWithLngRef) indicates whether a list of ishObjects or one ishObject is submitted as input data to the background task.</para> | ||
/// </summary> | ||
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = false, ParameterSetName = "IshObjectsGroup")] | ||
public InputDataTemplate InputDataTemplate { get; set; } = InputDataTemplate.IshObjectsWithIshRef; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default should be "IshObjectsWithLngRef"
var createBackgroundTaskResponse = IshSession.BackgroundTask25.CreateBackgroundTask(newBackgroundTaskRequest); | ||
var progressId = createBackgroundTaskResponse.progressId; | ||
var createBackgroundTaskStartAfterResponse = IshSession.BackgroundTask25.CreateBackgroundTask(newBackgroundTaskRequest); | ||
var progressId = createBackgroundTaskStartAfterResponse.progressId; | ||
progressIds.Add(progressId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why we add this single value progressId to a list. Event with the DocumenObj25 call we are returning 1 taskId and 1 progressId. So can we remove this list and the code "if (progressIds.Count > 1)"
and for the following part an "FilterOperator.equal" and "valuetype.value" are slightly better:
"new IshMetadataFilterField(FieldElements.BackgroundTaskProgressId,
Enumerations.Level.Task, Enumerations.FilterOperator.In, progressIds.First().ToString(),
Enumerations.ValueType.Element)"
metadataFilter.AddField(new IshMetadataFilterField(FieldElements.BackgroundTaskProgressId, | ||
Level.Task, FilterOperator.In, progressId.ToString(), | ||
Enumerations.ValueType.Value)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant new line (2 in a row)
@@ -35,32 +39,49 @@ namespace Trisoft.ISHRemote.Cmdlets.BackgroundTask | |||
/// </summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need to mention DocumentObj25.RaiseEventByIshLngRefs in the description?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it and corrected the whole description.
/// $ishBackgroundTask = Get-IshDocumentObj -LogicalId "GUID-ABCD-1234" | | ||
/// Add-IshBackgroundTask -EventType "SYNCHRONIZEMETRICS" -InputDataTemplate IshObjectWithIshRef | ||
/// </code> | ||
/// <para>Add BackgroundTask with event type "SYNCHRONIZEMETRICS" for the latest-version of a single content object of type topic; located under the "General\MyFolder\Topics" path. Trigger an event of synchronizing a topic from CM to the metrics.</para> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not use folder path "General\MyFolder\Topics" in the example
…ate and HashId.