diff --git a/Cognite.Extensions/CogniteResult.cs b/Cognite.Extensions/CogniteResult.cs index ce2844fa..087b457a 100644 --- a/Cognite.Extensions/CogniteResult.cs +++ b/Cognite.Extensions/CogniteResult.cs @@ -241,7 +241,7 @@ public static bool ContainsIdentity(this HashSet set, long? idt) /// Set of identities /// IntanceId to test /// True if instance id is non-null and set contains it, false otherwise - public static bool ContainsIdentity(this HashSet set, InstanceIdentifier? idt) + public static bool ContainsIdentity(this HashSet set, InstanceIdentifier idt) { if (idt == null) return false; return set.Contains(IdentityWithInstanceId.Create(idt)); diff --git a/Cognite.Extensions/DataModels/CogniteExtractorExtensions/ExtractorTimeSeriesResultHandlers.cs b/Cognite.Extensions/DataModels/CogniteExtractorExtensions/ExtractorTimeSeriesResultHandlers.cs index ba2d1e9a..879cfc11 100644 --- a/Cognite.Extensions/DataModels/CogniteExtractorExtensions/ExtractorTimeSeriesResultHandlers.cs +++ b/Cognite.Extensions/DataModels/CogniteExtractorExtensions/ExtractorTimeSeriesResultHandlers.cs @@ -1,6 +1,8 @@ using CogniteSdk; +using CogniteSdk.Alpha; using CogniteSdk.Beta.DataModels; using System.Collections.Generic; +using System.Linq; namespace Cognite.Extensions { @@ -10,24 +12,23 @@ private static bool IsAffected(SourcedNodeWrite ts, HashSet bad { return error.Resource switch { - ResourceType.SpaceId => badValues.ContainsIdentity(ts.Space), - ResourceType.ExternalId => badValues.ContainsIdentity(ts.ExternalId), + ResourceType.InstanceId => new HashSet(badValues.Where(x => x is IdentityWithInstanceId).Select(x => (IdentityWithInstanceId)x)).ContainsIdentity(new InstanceIdentifier(ts.Space, ts.ExternalId)), _ => false, }; } /// - /// Clean list of TimeSeriesCreate objects based on CogniteError + /// Clean list of SourceNodeWrite objects based on CogniteError /// /// Error that occured with a previous push - /// Timeseries to clean - /// TimeSeries that are not affected by the error + /// Nodes to clean + /// Nodes that are not affected by the error public static IEnumerable> CleanFromError( CogniteError> error, IEnumerable> timeseries) { return CleanFromErrorCommon(error, timeseries, IsAffected, - ts => ts.ExternalId == null ? null : Identity.Create(ts.ExternalId), + ts => ts.ExternalId == null || ts.Space == null ? null : IdentityWithInstanceId.Create(new InstanceIdentifier(ts.Space, ts.ExternalId)), CdfMetrics.TimeSeriesSkipped); } } diff --git a/ExtractorUtils/Cognite/Beta/CogniteDestinationWithIDM.cs b/ExtractorUtils/Cognite/Beta/CogniteDestinationWithIDM.cs index 8f630a28..c2f8cc5f 100644 --- a/ExtractorUtils/Cognite/Beta/CogniteDestinationWithIDM.cs +++ b/ExtractorUtils/Cognite/Beta/CogniteDestinationWithIDM.cs @@ -8,7 +8,6 @@ using CogniteSdk; using CogniteSdk.Beta.DataModels; using Microsoft.Extensions.Logging; -using Cognite.Extractor.Common; using CogniteSdk.Beta.DataModels.Core; using CogniteSdk.Alpha; @@ -61,11 +60,11 @@ public CogniteDestinationWithIDM(Client client, ILogger logg /// /// /// Instance Ids - /// Function that builds CogniteSdk TimeSeriesCreate objects + /// Function that builds CogniteSdk TimeSeries objects /// How to handle failed requests - /// The type of sanitation to apply to timeseries before creating + /// The type of sanitation to apply to TimeSeries before creating /// Cancellation token - /// A containing errors that occurred and a list of the created and found timeseries + /// A containing errors that occurred and a list of the created and found TimeSeries public async Task, SourcedNodeWrite>> GetOrCreateTimeSeriesAsync( IEnumerable instanceIds, Func, IEnumerable>> buildTimeSeries, @@ -96,11 +95,11 @@ public async Task, SourcedNodeWrite>> GetOrCreat /// /// /// Instance Ids - /// Async function that builds CogniteSdk TimeSeriesCreate objects + /// Async function that builds CogniteSdk TimeSeries objects /// How to handle failed requests - /// The type of sanitation to apply to timeseries before creating + /// The type of sanitation to apply to TimeSeries before creating /// Cancellation token - /// A containing errors that occured and a list of the created and found timeseries + /// A containing errors that occured and a list of the created and found TimeSeries public async Task, SourcedNodeWrite>> GetOrCreateTimeSeriesAsync( IEnumerable instanceIds, Func, Task>>> buildTimeSeries, @@ -125,11 +124,11 @@ public async Task, SourcedNodeWrite>> GetOrCreat /// by setting . /// TimeSeries will be returned in the same order as given. /// - /// List of CogniteSdk TimeSeriesUpdateItem objects + /// List of CogniteSdk TimeSeries objects /// How to do retries. Keeping duplicates is not valid for this method. /// The type of sanitation to apply to assets before updating /// Cancellation token - /// A containing errors that occured and a list of the updated timeseries + /// A containing errors that occured and a list of the updated TimeSeries public async Task>> UpdateTimeSeriesAsync( IEnumerable> updates, RetryMode retryMode, @@ -255,7 +254,6 @@ public async Task DeleteDataPointsIgnoreErrorsAsync( #endregion #region ranges - /// /// Fetches the range of datapoints present in CDF. Limited by given ranges for each id. /// Note that end limits closer to actual endpoints in CDF is considerably faster. @@ -283,7 +281,6 @@ public async Task DeleteDataPointsIgnoreErrorsAsync( token); } - /// /// Fetches the range of datapoints present in CDF. Limited by given ranges for each id. /// Note that end limits closer to actual endpoints in CDF is considerably faster. @@ -310,8 +307,6 @@ public async Task DeleteDataPointsIgnoreErrorsAsync( earliest, token); } - - #endregion } } \ No newline at end of file diff --git a/ExtractorUtils/Cognite/CogniteDestination.cs b/ExtractorUtils/Cognite/CogniteDestination.cs index ab6e086d..6299c99d 100644 --- a/ExtractorUtils/Cognite/CogniteDestination.cs +++ b/ExtractorUtils/Cognite/CogniteDestination.cs @@ -8,7 +8,6 @@ using Cognite.Extensions.DataModels.CogniteExtractorExtensions; using Cognite.Extractor.StateStorage; using CogniteSdk; -using CogniteSdk.Beta.DataModels; using Microsoft.Extensions.Logging; using TimeRange = Cognite.Extractor.Common.TimeRange;