Skip to content

Commit

Permalink
Delete empty mnemonics (#2020)
Browse files Browse the repository at this point in the history
* delete empty mnemonics
  • Loading branch information
vaclavbasniar authored Aug 30, 2023
1 parent 0ea36c1 commit e1b7c1e
Show file tree
Hide file tree
Showing 12 changed files with 723 additions and 11 deletions.
79 changes: 79 additions & 0 deletions Src/WitsmlExplorer.Api/Jobs/DeleteEmptyMnemonicsJob.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Extensions.Primitives;
using Microsoft.IdentityModel.Tokens;

using WitsmlExplorer.Api.Jobs.Common;
using WitsmlExplorer.Api.Models;

namespace WitsmlExplorer.Api.Jobs
{
public record DeleteEmptyMnemonicsJob : Job
{

public IEnumerable<WellReference> Wells { get; init; }
public IEnumerable<WellboreReference> Wellbores { get; init; }
public double NullDepthValue { get; init; }
public DateTime NullTimeValue { get; init; }

public DeleteEmptyMnemonicsJob()
{
Wells = new List<WellReference>();
Wellbores = new List<WellboreReference>();
}

public override string Description()
{
return "DeleteEmptyMnemonicsJob"
+ $" - WellUids: {GetWellUid()};"
+ $" WellboreUids: {string.Join(", ", Wellbores.Select(w => w.WellboreUid))}";
}

public override string GetObjectName()
{
return null;
}

public override string GetWellboreName()
{
return Wellbores.IsNullOrEmpty() ? null : string.Join(", ", Wellbores.Select(w => w.WellboreName));
}

public override string GetWellName()
{
var wellNames = new List<string>();

if (!Wellbores.IsNullOrEmpty())
{
wellNames.AddRange(Wellbores.Select(w => w.WellName).Distinct());
}

if (!Wells.IsNullOrEmpty())
{
wellNames.AddRange(Wells.Select(w => w.WellName).Distinct());
}

return string.Join(", ", wellNames.Distinct());
}

private string GetWellUid()
{
var wellUids = new List<string>();

if (!Wellbores.IsNullOrEmpty())
{
wellUids.AddRange(Wellbores.Select(w => w.WellUid).Distinct());
}

if (!Wells.IsNullOrEmpty())
{
wellUids.AddRange(Wells.Select(w => w.WellUid).Distinct());
}

return string.Join(", ", wellUids.Distinct());
}
}
}
1 change: 1 addition & 0 deletions Src/WitsmlExplorer.Api/Models/JobType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public enum JobType
DeleteWell,
DeleteWellbore,
RenameMnemonic,
DeleteEmptyMnemonics,
ModifyBhaRun,
ModifyFormationMarker,
ModifyGeologyInterval,
Expand Down
22 changes: 11 additions & 11 deletions Src/WitsmlExplorer.Api/Models/LogCurveInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ namespace WitsmlExplorer.Api.Models
{
public class LogCurveInfo
{
public string Uid { get; internal set; }
public string Mnemonic { get; internal set; }
public string MinDateTimeIndex { get; internal set; }
public string MinDepthIndex { get; internal set; }
public string MaxDateTimeIndex { get; internal set; }
public string MaxDepthIndex { get; internal set; }
public string ClassWitsml { get; internal set; }
public string Unit { get; internal set; }
public LengthMeasure SensorOffset { get; internal set; }
public string MnemAlias { get; internal set; }
public List<AxisDefinition> AxisDefinitions { get; internal set; }
public string Uid { get; init; }
public string Mnemonic { get; init; }
public string MinDateTimeIndex { get; init; }
public string MinDepthIndex { get; init; }
public string MaxDateTimeIndex { get; init; }
public string MaxDepthIndex { get; init; }
public string ClassWitsml { get; init; }
public string Unit { get; init; }
public LengthMeasure SensorOffset { get; init; }
public string MnemAlias { get; init; }
public List<AxisDefinition> AxisDefinitions { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using WitsmlExplorer.Api.Jobs.Common;

namespace WitsmlExplorer.Api.Models.Reports
{
public class DeleteEmptyMnemonicsReport : BaseReport
{
}

public class DeleteEmptyMnemonicsReportItem
{
public string WellName { get; init; }
public string WellUid { get; init; }
public string WellboreName { get; init; }
public string WellboreUid { get; init; }
public string LogName { get; init; }
public string LogUid { get; init; }
public string LogIndexType { get; init; }
public string Mnemonic { get; init; }
}
}
29 changes: 29 additions & 0 deletions Src/WitsmlExplorer.Api/Services/MnemonicService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Threading.Tasks;

using Witsml;

using WitsmlExplorer.Api.Models;
using WitsmlExplorer.Api.Query;

namespace WitsmlExplorer.Api.Services
{
public interface IMnemonicService
{
Task<QueryResult> DeleteMnemonic(string wellUid, string wellboreUid, string logToCheckUid, LogCurveInfo mnemonicToDelete);
}

public class MnemonicService : WitsmlService, IMnemonicService
{
public MnemonicService(IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider)
{
}

public async Task<QueryResult> DeleteMnemonic(string wellUid, string wellboreUid, string logToCheckUid, LogCurveInfo mnemonicToDelete)
{
var query = LogQueries.DeleteMnemonics(wellUid, wellboreUid, logToCheckUid, new[] { mnemonicToDelete.Mnemonic });

return await _witsmlClient.DeleteFromStoreAsync(query);
}
}
}
Loading

0 comments on commit e1b7c1e

Please sign in to comment.