Skip to content

Commit 07c6453

Browse files
committed
Merge branch 'rc' of https://github.com/bexis2/core into rc
2 parents 5cacda6 + c207b5d commit 07c6453

File tree

58 files changed

+1382
-590
lines changed

Some content is hidden

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

58 files changed

+1382
-590
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
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
30+
2931
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/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/JSON/BEXIS.JSON.Helpers/MetadataStructureConverter.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,21 @@ private JSchema addMetadataAttrUsage(BaseUsage usage, JSchema schema, out bool r
179179
// set json schema type based on datatype input
180180
currentText.Type = convertToJSchemaType(type.DataType);
181181

182-
//if Datatype is datetime, jsosn schema use type string
183-
// but need to set a format
184-
if (type.DataType.SystemType == "datetime")
182+
////if Datatype is datetime, jsosn schema use type string
183+
//// but need to set a format
184+
//if (type.DataType.SystemType.ToLower() == "datetime")
185+
//{
186+
// currentText.Format = "date";
187+
//}
188+
189+
if (type.DataType.SystemType.ToLower() == "datetime")
185190
{
186-
currentText.Format = "date";
191+
currentText.Format = type.DataType.Name.ToLower(); // set datetime, date or time in format
192+
}
193+
194+
if (type.DataType.SystemType.ToLower() == "string" && type.DataType.Name.ToLower() == "text")
195+
{
196+
currentText.Format = type.DataType.Name.ToLower();
187197
}
188198

189199
//Contraints
@@ -378,7 +388,10 @@ private bool IsChoice(XmlNode xmlNode)
378388

379389
private JSchemaType GetJSchemaType(BaseUsage usage)
380390
{
381-
if(IsChoice(usage.Extra))
391+
// if choice and max cardinality >1 then array
392+
if (IsChoice(usage.Extra) && getMaxCardinality(usage) > 1)
393+
return JSchemaType.Array;
394+
else if (IsChoice(usage.Extra))
382395
return JSchemaType.Object;
383396
else if (getMaxCardinality(usage) > 1)
384397
return JSchemaType.Array;

Components/Utils/BExIS.Utils.Data/Helpers/ShellSeedDataGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public void GenerateSeedData()
4040

4141
var o12 = operationManager.Find("Shell", "Settings", "*") ?? operationManager.Create("Shell", "Settings", "*", settings);
4242

43-
if (!versionManager.Exists("Shell", "4.1.0"))
43+
if (!versionManager.Exists("Shell", "4.2.0"))
4444
{
45-
versionManager.Create("Shell", "4.1.0");
45+
versionManager.Create("Shell", "4.2.0");
4646
}
4747
}
4848
}

Components/XML/BExIS.Xml.Helpers/Mapping/XmlSchemaManager.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,14 +2135,27 @@ private DataType GetDataType(string dataTypeAsString, string typeCodeName)
21352135
{
21362136
if (!dataTypeAsString.ToLower().Equals("Object"))
21372137
{
2138+
21382139
TypeCode typeCode = ConvertStringToSystemType(dataTypeAsString);
21392140
DataType dataType = null;
21402141
// if datatime - need to check typeCodeName for date, time , datetime
21412142

2142-
2143+
21432144
TypeCode c = DataTypeHelper.GetMaxTypeCode(typeCode);
21442145
string label = DataTypeHelper.GetLabel(typeCode);
21452146

2147+
// in case of time or date, there is no system type for it so we need to set it
2148+
if (typeCodeName.ToLower().Equals("time"))
2149+
{
2150+
c = TypeCode.DateTime;
2151+
label = "Time";
2152+
}
2153+
else if(typeCodeName.ToLower().Equals("date"))
2154+
{
2155+
c = TypeCode.DateTime;
2156+
label = "Date";
2157+
}
2158+
21462159
if (dataTypeAsString.Equals(TypeCode.DateTime.ToString()))
21472160
{
21482161

@@ -2158,7 +2171,7 @@ private DataType GetDataType(string dataTypeAsString, string typeCodeName)
21582171
dataType =
21592172
dataTypeManager.Repo.Query()
21602173
.Where(
2161-
d =>
2174+
d =>
21622175
d.Name.ToLower().Equals(label.ToString().ToLower()))
21632176
.FirstOrDefault();
21642177

0 commit comments

Comments
 (0)