Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions Relativity.Export.Samples.RelConsole/Helpers/OutputHelper.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System.Reflection;
using System.Text.Json;
using Relativity.Export.Samples.RelConsole.SampleCollection;
using Relativity.Export.V1.Model;
using Relativity.Export.V1.Model.ExportJobSettings;
using Spectre.Console;
using Spectre.Console.Json;
using Spectre.Console.Rendering;

namespace Relativity.Export.Samples.RelConsole.Helpers;
Expand Down Expand Up @@ -35,11 +31,11 @@ public static async Task StartAsync(string[] args, string relativityUrl, string
var samplesPanel = GetSamplesPanel(samples);
var metadataPanel = GetSampleMetadataPanel(samples.FirstOrDefault(s => s.ID == selectedSampleId));

Columns[] dataColumns = new Columns[]
{
Columns[] dataColumns =
[
new Columns(samplesPanel),
new Columns(metadataPanel)
};
];

PrintRelativityLogo();
AnsiConsole.Write(new Columns(dataColumns));
Expand Down Expand Up @@ -139,16 +135,28 @@ private static List<SampleMetadata> GetSamples(int selectedSampleId)
.Where(method => method.GetCustomAttributes(typeof(SampleMetadataAttribute), false).Length > 0)
.ToArray();

foreach (var method in sampleMethods)
var samplesMetadataAttribute = sampleMethods.Select(m => m.GetCustomAttribute<SampleMetadataAttribute>())
.OrderBy(x => x?.Name)
.ToArray();

for (int i = 0; i < samplesMetadataAttribute.Length; i++)
{
var typeMeta = method.GetCustomAttribute<SampleMetadataAttribute>();
var data = samplesMetadataAttribute[i];

// Sample ID is 1-based
// Automatically assigned to the sample based on alphabetical order of samples names
var sampleID = i + 1;

if (typeMeta is null)
if (data is null)
continue;

samples.Add(new SampleMetadata(typeMeta.ID, typeMeta.Name, typeMeta.Description ?? "No description", typeMeta.ID == selectedSampleId));
var sampleMetadata = new SampleMetadata(ID: sampleID,
data.Name,
!string.IsNullOrEmpty(data.Description) ? data.Description : "No description",
sampleID == selectedSampleId); // is sample currently selected

_sampleRunner.Add(typeMeta.ID, method);
samples.Add(sampleMetadata);
_sampleRunner.Add(i + 1, sampleMethods[i]);
}

return samples;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
[System.AttributeUsage(System.AttributeTargets.Method)]
public class SampleMetadataAttribute : System.Attribute
{
public int ID { get; set; }
public string Name { get; set; } = default!;
public string? Description { get; set; } = default!;

public SampleMetadataAttribute(int id, string name, string description)
public SampleMetadataAttribute(string name, string description)
{
ID = id;
Name = name;
Description = description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(5, nameof(Export_FromFolder_All), "Exports native, fulltext, images and PDF files from folder")]
[SampleMetadata(nameof(Export_FromFolder_All), "Exports native, fulltext, images and PDF files from folder")]
public async Task Export_FromFolder_All()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(21, nameof(Export_Folder_All_With_DataSource_Name_In_Loadfile), "Exports native, fulltext, images and PDF files from folder. Exported laodfiles names contians DataSource name and date.")]
public async Task Export_Folder_All_With_DataSource_Name_In_Loadfile()
[SampleMetadata(nameof(Export_FromFolder_All_With_DataSource_Name_In_Loadfile), "Exports native, fulltext, images and PDF files from folder. Exported laodfiles names contians DataSource name and date.")]
public async Task Export_FromFolder_All_With_DataSource_Name_In_Loadfile()
{
// Your workspace ID.
// This is where we point to the workspace where we want to export from.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(4, nameof(Export_FromFolder_FullText), "Exports Fulltext from folder")]
[SampleMetadata(nameof(Export_FromFolder_FullText), "Exports Fulltext from folder")]
public async Task Export_FromFolder_FullText()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(2, nameof(Export_FromFolder_Images), "Exports images from folder")]
[SampleMetadata(nameof(Export_FromFolder_Images), "Exports images from folder")]
public async Task Export_FromFolder_Images()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using Relativity.Export.Samples.RelConsole.Helpers;
using Relativity.Export.V1.Builders.ExportSettings;
using Relativity.Export.V1.Model.ExportJobSettings;
Expand All @@ -7,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(1, nameof(Export_FromFolder_NativeFiles), "Exports native files from folder")]
[SampleMetadata(nameof(Export_FromFolder_NativeFiles), "Exports native files from folder")]
public async Task Export_FromFolder_NativeFiles()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(3, nameof(Export_FromFolder_PDF), "Exports PDF files from folder")]
[SampleMetadata(nameof(Export_FromFolder_PDF), "Exports PDF files from folder")]
public async Task Export_FromFolder_PDF()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(15, nameof(Export_FromProduction_All), "Exports native, fulltext, images and PDF files from production set")]
[SampleMetadata(nameof(Export_FromProduction_All), "Exports native, fulltext, images and PDF files from production set")]
public async Task Export_FromProduction_All()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(14, nameof(Export_FromProduction_Fulltext), "Exports fulltext from production")]
[SampleMetadata(nameof(Export_FromProduction_Fulltext), "Exports fulltext from production")]
public async Task Export_FromProduction_Fulltext()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(12, nameof(Export_FromProduction_Images), "Exports images from folder")]
[SampleMetadata(nameof(Export_FromProduction_Images), "Exports images from folder")]
public async Task Export_FromProduction_Images()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(11, nameof(Export_FromProduction_NativeFiles), "Exports native files from production")]
[SampleMetadata(nameof(Export_FromProduction_NativeFiles), "Exports native files from production")]
public async Task Export_FromProduction_NativeFiles()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(13, nameof(Export_FromProduction_PDF), "Exports PDF files from a production")]
[SampleMetadata(nameof(Export_FromProduction_PDF), "Exports PDF files from a production")]
public async Task Export_FromProduction_PDF()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(16, nameof(Export_RDO), "Exports RDO objects")]
[SampleMetadata(nameof(Export_RDO), "Exports RDO objects")]
public async Task Export_RDO()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(10, nameof(Export_FromSavedSearch_All), "Exports native, fulltext, images and PDF files from saved search")]
[SampleMetadata(nameof(Export_FromSavedSearch_All), "Exports native, fulltext, images and PDF files from saved search")]
public async Task Export_FromSavedSearch_All()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(9, nameof(Export_FromSavedSearch_FullText), "Exports fulltext from saved search")]
[SampleMetadata(nameof(Export_FromSavedSearch_FullText), "Exports fulltext from saved search")]
public async Task Export_FromSavedSearch_FullText()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(7, nameof(Export_FromSavedSearch_Images), "Exports images from saved search")]
[SampleMetadata(nameof(Export_FromSavedSearch_Images), "Exports images from saved search")]
public async Task Export_FromSavedSearch_Images()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(6, nameof(Export_FromSavedSearch_NativeFiles), "Exports native files from saved search")]
[SampleMetadata(nameof(Export_FromSavedSearch_NativeFiles), "Exports native files from saved search")]
public async Task Export_FromSavedSearch_NativeFiles()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(8, nameof(Export_FromSavedSearch_PDF), "Exports PDF files from saved search")]
[SampleMetadata(nameof(Export_FromSavedSearch_PDF), "Exports PDF files from saved search")]
public async Task Export_FromSavedSearch_PDF()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(20, nameof(Job_Cancel), "Cancels running export job")]
[SampleMetadata(nameof(Job_Cancel), "Cancels running export job")]
public async Task Job_Cancel()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(22, nameof(Job_Delete_Files), "Deletes exported files of specified export job")]
[SampleMetadata(nameof(Job_Delete_Files), "Deletes exported files of specified export job")]
public async Task Job_Delete_Files()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using System.Collections.Concurrent;
using Relativity.Export.Samples.RelConsole.Helpers;
using Relativity.Export.V1.Builders.ExportSettings;
using Relativity.Export.V1.Model;
using Relativity.Export.V1.Model.ExportJobSettings;

namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(19, nameof(Job_GetSettings), "Gets settings of a selected job")]
[SampleMetadata(nameof(Job_GetSettings), "Gets settings of a selected job")]
public async Task Job_GetSettings()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Concurrent;
using Relativity.Export.Samples.RelConsole.Helpers;
using Relativity.Export.V1.Builders.ExportSettings;
using Relativity.Export.V1.Model;
Expand All @@ -8,7 +7,7 @@ namespace Relativity.Export.Samples.RelConsole.SampleCollection;

public partial class BaseExportService
{
[SampleMetadata(17, nameof(Job_ListExportJobs), "Lists export jobs")]
[SampleMetadata(nameof(Job_ListExportJobs), "Lists export jobs")]
public async Task Job_ListExportJobs()
{
// Your workspace ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public record class RunnableJobResult(string ResultMessage, ExportStatus? Result

public partial class BaseExportService
{
[SampleMetadata(18, nameof(Job_StartAllRunnableJobs), "Starts all runnable export jobs")]
[SampleMetadata(nameof(Job_StartAllRunnableJobs), "Starts all runnable export jobs")]
public async Task Job_StartAllRunnableJobs()
{
// Your workspace ID.
Expand Down