Skip to content

Commit c3d3e09

Browse files
committed
#2195 update to 4.2.0
2 parents d5941fe + c9badc1 commit c3d3e09

File tree

80 files changed

+1380
-1376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1380
-1376
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111

1212
steps:
1313
- name: Checkout repository
14+
1415
uses: actions/checkout@v4
1516

1617
- name: Install .NET SDK
@@ -26,7 +27,9 @@ jobs:
2627
upgrade-assistant analyze BExIS%2B%2B.sln --format json > upgrade-report.json
2728
2829
- name: Upload report artifact
29-
uses: actions/[email protected]
30+
31+
uses: actions/upload-artifact@v4
32+
3033
with:
3134
name: upgrade-report
3235
path: upgrade-report.json

Components/DLM/BExIS.Dlm.Entities/Curation/CurationEntry.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ public CurationEntry(string topic, CurationEntryType type, Dataset dataset, stri
6565
public virtual bool IsApproved { get; set; }
6666
public virtual DateTime LastChangeDatetime_User { get; set; }
6767
public virtual DateTime LastChangeDatetime_Curator { get; set; }
68-
public static CurationUserType GetCurationUserType(User user)
68+
69+
public static CurationUserType GetCurationUserType(User user, string curationGroupName)
6970
{
70-
if (user.Groups.Any(g => g.Name.Equals("curator", StringComparison.CurrentCultureIgnoreCase)))
71+
if (user.Groups.Any(g => g.Name.Equals(curationGroupName, StringComparison.CurrentCultureIgnoreCase)))
7172
{
7273
return CurationUserType.Curator;
7374
}

Components/DLM/BExIS.Dlm.Entities/Curation/CurationNote.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public CurationNote(int id, CurationUserType userType, DateTime creationDate, st
2929
User = user;
3030
}
3131

32-
public CurationNote(User user, string comment)
32+
public CurationNote(User user, string comment, CurationUserType userType)
3333
{
3434
Id = 0;
35-
UserType = CurationEntry.GetCurationUserType(user);
35+
UserType = userType;
3636
CreationDate = DateTime.Now;
3737
Comment = comment;
3838
User = user;

Components/DLM/BExIS.Dlm.Services/Curation/CurationManager.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private static void FixPositions(IEnumerable<CurationEntry> entries, CurationEnt
5353
}
5454
}
5555

56-
public CurationEntry Create(string topic, CurationEntryType type, long datasetId, string name, string description, string solution, int position, string source, IEnumerable<CurationNote> notes, bool userIsDone, bool isApproved, User user)
56+
public CurationEntry Create(string topic, CurationEntryType type, long datasetId, string name, string description, string solution, int position, string source, IEnumerable<CurationNote> notes, bool userIsDone, bool isApproved, User user, bool userIsCurator)
5757
{
5858
if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name), "name is empty but is required.");
5959
if (string.IsNullOrEmpty(source)) throw new ArgumentNullException(nameof(source), "source is empty but is required.");
@@ -72,7 +72,7 @@ public CurationEntry Create(string topic, CurationEntryType type, long datasetId
7272
var _ = loadedUser.Groups.Count;
7373

7474
// set last change date time
75-
if (CurationEntry.GetCurationUserType(loadedUser) != CurationUserType.Curator)
75+
if (!userIsCurator)
7676
throw new UnauthorizedAccessException("Only curators are allowed to create curation entries.");
7777

7878
var dataset = repoDataset.Get(datasetId);
@@ -113,8 +113,7 @@ public CurationEntry Create(string topic, CurationEntryType type, long datasetId
113113
return curationEntry;
114114
}
115115
}
116-
117-
public CurationEntry Update(long id, string topic, CurationEntryType type, string name, string description, string solution, int position, string source, IEnumerable<CurationNote> notes, bool userIsDone, bool isApproved, User user)
116+
public CurationEntry Update(long id, string topic, CurationEntryType type, string name, string description, string solution, int position, string source, IEnumerable<CurationNote> notes, bool userIsDone, bool isApproved, User user, bool userIsCurator)
118117
{
119118
if (id <= 0) throw new ArgumentException("id must be greater than 0.");
120119

@@ -132,15 +131,19 @@ public CurationEntry Update(long id, string topic, CurationEntryType type, strin
132131
// Force loading of Groups collection
133132
var _ = loadedUser.Groups.Count;
134133

135-
var isCurator = CurationEntry.GetCurationUserType(loadedUser) == CurationUserType.Curator;
136-
137134
var merged = repoEntries.Get(id);
138135

139136
var currentNotes = merged.Notes.ToList();
140137

141138
var incomingIds = new HashSet<long>(notes.Select(n => n.Id));
142139
incomingIds.Remove(0);
143140
var deletedNotes = merged.Notes.Where(n => !incomingIds.Contains(n.Id)).ToList();
141+
142+
var userType = CurationUserType.User;
143+
if (userIsCurator)
144+
userType = CurationUserType.Curator;
145+
146+
144147
foreach (var note in deletedNotes)
145148
{
146149
if (loadedUser.Id != note.User.Id) continue; // do not delete notes from other users
@@ -153,7 +156,7 @@ public CurationEntry Update(long id, string topic, CurationEntryType type, strin
153156
var existingNote = currentNotes.FirstOrDefault(n => n.Id == incomingNote.Id);
154157
if (incomingNote.Id == 0 || existingNote == null)
155158
{
156-
var newNote = new CurationNote(loadedUser, incomingNote.Comment);
159+
var newNote = new CurationNote(loadedUser, incomingNote.Comment, userType);
157160
currentNotes.Add(newNote);
158161
}
159162
else
@@ -167,7 +170,7 @@ public CurationEntry Update(long id, string topic, CurationEntryType type, strin
167170

168171
var changed = false;
169172

170-
if (isCurator)
173+
if (userIsCurator)
171174
{
172175
changed = topic != merged.Topic ||
173176
type != merged.Type ||

Components/DLM/BExIS.Dlm.Services/Data/DatasetManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@ public List<DatasetVersion> GetDatasetLatestVersions(List<Int64> datasetIds, boo
15101510
/// </summary>
15111511
/// <param name="datasetId">The identifiers of the dataset whose their latest versions is requested</param>
15121512
/// <returns>The list of the latest versions of the deleted datasets</returns>
1513-
private DatasetVersion getDeletedDatasetLatestVersion(long datasetId)
1513+
public DatasetVersion GetDeletedDatasetLatestVersion(long datasetId)
15141514
{
15151515
using (IUnitOfWork uow = this.GetUnitOfWork())
15161516
{

Components/DLM/BExIS.Dlm.Tests/Services/Curation/CurationEntryTests.cs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ public void OneTimeSetUp()
3030
helper = new TestSetupHelper(WebApiConfig.Register, false);
3131

3232
using (UserManager userManager = new UserManager())
33+
using (GroupManager groupManager = new GroupManager())
3334
{
35+
Group group = new Group();
36+
group.Name = "curator";
37+
group.Description = "curators group";
38+
groupManager.CreateAsync(group);
39+
40+
41+
3442
User admin = new User()
3543
{
3644
Name = "Admin",
@@ -39,6 +47,14 @@ public void OneTimeSetUp()
3947
};
4048

4149
userManager.CreateAsync(admin).Wait();
50+
51+
admin = userManager.FindByNameAsync("Admin").Result;
52+
group = groupManager.FindByNameAsync("curator").Result;
53+
54+
userManager.AddToRoleAsync(admin, group.Name).Wait();
55+
56+
57+
4258
}
4359
}
4460

@@ -69,6 +85,23 @@ public void OneTimeTearDown()
6985
repo.Delete(item);
7086
}
7187
uow.Commit();
88+
89+
var usersRepo = uow.GetRepository<User>();
90+
91+
var u = usersRepo.Query().ToList();
92+
foreach (var item in u)
93+
{
94+
usersRepo.Delete(item);
95+
}
96+
97+
var groupsRepo = uow.GetRepository<Group>();
98+
99+
var g = groupsRepo.Query().ToList();
100+
foreach (var item in g)
101+
{
102+
groupsRepo.Delete(item);
103+
}
104+
uow.Commit();
72105
}
73106

74107
var dsHelper = new DatasetHelper();
@@ -95,7 +128,7 @@ public void Create_valid_CurationEntry()
95128
var curationEntry = curationEntryManager.Create(
96129
"Test Topic",
97130
CurationEntryType.None,
98-
ds.Id, "Test Name", "Test Description", "Test Solution", 1, "Test Source", new List<CurationNote>(), false, false, user);
131+
ds.Id, "Test Name", "Test Description", "Test Solution", 1, "Test Source", new List<CurationNote>(), false, false, user, true);
99132

100133

101134
//Assert
@@ -133,7 +166,7 @@ public void Delete_valid_CurationEntry()
133166
var curationEntry = curationEntryManager.Create(
134167
"Test Topic",
135168
CurationEntryType.None,
136-
ds.Id, "Test Name", "Test Description", "Test Solution", 1, "Test Source", new List<CurationNote>(), false, false, user);
169+
ds.Id, "Test Name", "Test Description", "Test Solution", 1, "Test Source", new List<CurationNote>(), false, false, user, true);
137170

138171

139172
//Assert

Components/IO/BExIS.IO.Tests/Transform/Input/AsciiReaderTest.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,29 @@ public void rowToList_RowAsQuotesAndSeperatorInQuotes_ReturnExpectedListOfString
121121
Assert.That(values, Is.EquivalentTo(expectedOutcome));
122122
}
123123

124+
[Test]
125+
public void rowToList_RowAsOneVariablewithQuotesAndSeperatorInQuotes_ReturnExpectedListOfStrings()
126+
{
127+
//Arrange
128+
string row = "V1,V2,'V3,V4'";
129+
List<string> expectedOutcome = new List<string> { "V1", "V2", "V3,V4" };
130+
131+
AsciiFileReaderInfo info = new AsciiFileReaderInfo();
132+
info.Seperator = TextSeperator.comma;
133+
134+
AsciiReader reader = new AsciiReader(new StructuredDataStructure(), info);
135+
136+
//Act
137+
138+
List<string> values = reader.rowToList(row,
139+
AsciiFileReaderInfo.GetSeperator(TextSeperator.comma));
140+
141+
//Assert
142+
Assert.That(values.Count, Is.EqualTo(expectedOutcome.Count));
143+
Assert.That(values, Is.EquivalentTo(expectedOutcome));
144+
}
145+
146+
124147
[Test]
125148
public void ValidateRow_runNotValid_LimitErrors()
126149
{

Components/IO/BExIS.IO.Tests/Transform/Input/StructureAnalyzerTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public void SuggestSystemTypes_Valid_ResultWithCorrectTypes(int n)
249249
StructureAnalyser structureAnalyser = new StructureAnalyser();
250250

251251
//Act
252-
var result = structureAnalyser.SuggestSystemTypes(rows.GetRange(0, n), TextSeperator.semicolon, DecimalCharacter.comma, new List<string>());
252+
var result = structureAnalyser.SuggestSystemTypes(rows.GetRange(0, n),TextMarker.doubleQuotes, TextSeperator.semicolon, DecimalCharacter.comma, new List<string>());
253253

254254
//Assert
255255
Assert.NotNull(result);
@@ -294,7 +294,7 @@ public void SuggestSystemTypes_WithTestData_ResultWithCorrectTypes()
294294
StructureAnalyser structureAnalyser = new StructureAnalyser();
295295

296296
//Act
297-
var result = structureAnalyser.SuggestSystemTypes(rows, TextSeperator.semicolon, DecimalCharacter.comma, new List<string>());
297+
var result = structureAnalyser.SuggestSystemTypes(rows, TextMarker.doubleQuotes, TextSeperator.semicolon, DecimalCharacter.comma, new List<string>());
298298

299299
//Assert
300300
Assert.NotNull(result);
@@ -321,7 +321,7 @@ public void SuggestSystemTypes_ValidDateTypes_ResultWithCorrectTypes(int n)
321321
dateValues.Add("2022-12-24"); // yyyy-MM-dd
322322

323323
//Act
324-
var result = structureAnalyser.SuggestSystemTypes(rows.GetRange(0, n), TextSeperator.semicolon, DecimalCharacter.comma, new List<string>());
324+
var result = structureAnalyser.SuggestSystemTypes(rows.GetRange(0, n), TextMarker.doubleQuotes, TextSeperator.semicolon, DecimalCharacter.comma, new List<string>());
325325

326326
//Assert
327327
Assert.NotNull(result);
@@ -334,7 +334,7 @@ public void SuggestSystemTypes_ValidWithMissingValues_ResultWithCorrectTypes()
334334
StructureAnalyser structureAnalyser = new StructureAnalyser();
335335

336336
//Act
337-
var result = structureAnalyser.SuggestSystemTypes(rowWithMissingValues, TextSeperator.semicolon, DecimalCharacter.comma, missingValueList);
337+
var result = structureAnalyser.SuggestSystemTypes(rowWithMissingValues, TextMarker.doubleQuotes, TextSeperator.semicolon, DecimalCharacter.comma, missingValueList);
338338

339339
//Assert
340340
Assert.NotNull(result);

Components/IO/BExIS.IO.Tests/Transform/Input/StructureAnalyzer_SuggestUnitTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void SuggestUnit_AbbrOrNameAsInputDatatypeEmpty_ReturnUnit(string input,
5353
Assert.IsTrue(exist,"not exist");
5454
}
5555

56-
[TestCase("Floating Point Number", 1, 105)] // datatype, id, count
56+
[TestCase("Floating Point Number", 1, 104)] // datatype, id, count
5757
[TestCase("Text", 1, 1)] // datatype, id, count
5858
public void SuggestUnit_InputIsEmptyButDatatypeExist_ReturnUnit(string dataType, long firstId, int count)
5959
{

Components/IO/BExIS.IO.Transform.Input/AsciiReader.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,28 @@ public List<string> rowToList(string line, char seperator)
988988
return line.Split(seperator).ToList();
989989
}
990990

991+
/// <summary>
992+
/// Convert a row as a string to a list of strings based on offset,seperator and textmarker
993+
/// </summary>
994+
/// <remarks></remarks>
995+
/// <seealso cref=""/>
996+
/// <param name="line">Row as a string</param>
997+
/// <param name="seperator">Character used as TextSeparator</param>
998+
/// <param name="textMarker">Character used as TextMarker</param>
999+
/// <param name="offset">offset to skip values from begin</param>
1000+
/// <returns>List of values</returns>
1001+
public List<string> RowToList(string line, char seperator, char textMarker, int offset = 0)
1002+
{
1003+
List<string> tempRow = new List<string>();
1004+
1005+
tempRow = new List<string>();
1006+
tempRow = TextMarkerHandling(line, seperator,textMarker);
1007+
1008+
//if a offset is marked in the file reader information the offset needs to skip from the complete string array
1009+
return tempRow.Skip(offset).ToList();
1010+
//return line.Split(seperator).ToList();
1011+
}
1012+
9911013
private List<string> values;
9921014
private List<string> temp;
9931015

0 commit comments

Comments
 (0)