Skip to content

Commit

Permalink
Merge pull request #1699 from BEXIS2/rc
Browse files Browse the repository at this point in the history
Rc
  • Loading branch information
DavidBlaa authored Apr 23, 2024
2 parents 721e4a5 + 3f3c9b0 commit 636e6eb
Show file tree
Hide file tree
Showing 18 changed files with 159 additions and 129 deletions.
2 changes: 1 addition & 1 deletion Components/DLM/BExIS.Dlm.Services/Data/DatasetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2908,7 +2908,7 @@ private void updateMaterializedView(long datasetId, ViewCreationBehavior behavio
if (!IsDatasetCheckedIn(datasetId))
throw new Exception($"Dataset '{datasetId}' must be in the checked-in status.");

if (!(dataset.DataStructure.Self is StructuredDataStructure))
if (!(dataset.DataStructure != null))
{
if (throwExceptionOnUnstructured)
throw new Exception($"Dataset '{datasetId}' is not structured.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public void GenerateSeedData()

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

if (!versionManager.Exists("Shell", "3.2.0"))
if (!versionManager.Exists("Shell", "3.2.1"))
{
versionManager.Create("Shell", "3.2.0");
versionManager.Create("Shell", "3.2.1");
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions Components/XML/BExIS.Xml.Helpers/DatasetStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ public string GetTitleById(long id)

try
{
var dataset = dm.GetDataset(id);
if (dataset.Status == DatasetStatus.Deleted) return String.Empty;

var dsv = dm.GetDatasetLatestVersion(id);

return dsv.Title;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using BExIS.Security.Entities.Authorization;
using BExIS.Dlm.Services.Data;
using BExIS.Security.Entities.Authorization;
using BExIS.UI.Hooks;
using NHibernate.Engine;

namespace BExIS.Modules.Dcm.UI.Hooks
{
Expand Down Expand Up @@ -28,6 +30,12 @@ private void checkStatus(long id, string username)
// if one fail then access is denied
if (hasAccess == false || hasRights == false) Status = HookStatus.AccessDenied;
else Status = HookStatus.Open;

using (var datasetManager = new DatasetManager())
{
var dataset = datasetManager.GetDataset(id);
if (dataset.Status != Dlm.Entities.Data.DatasetStatus.CheckedIn) Status = HookStatus.Disabled;
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ private void checkDataStatus(long id, string username)
if (dataset == null && dataset.DataStructure == null) { Status = HookStatus.Disabled; return; }
else Status = HookStatus.Open;

if (dataset.Status != Dlm.Entities.Data.DatasetStatus.CheckedIn) Status = HookStatus.Disabled;

}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BExIS.Security.Entities.Authorization;
using BExIS.Dlm.Services.Data;
using BExIS.Security.Entities.Authorization;
using BExIS.UI.Hooks;

namespace BExIS.Modules.Dcm.UI.Hooks
Expand Down Expand Up @@ -28,6 +29,12 @@ private void checkStatus(long id, string username)
// if one fail then access is denied
if (hasAccess == false || hasRights == false) Status = HookStatus.AccessDenied;
else Status = HookStatus.Open;

// using (var datasetManager = new DatasetManager())
// {
// var dataset = datasetManager.GetDataset(id);
// if (dataset.Status != Dlm.Entities.Data.DatasetStatus.CheckedIn) Status = HookStatus.Disabled;
// }
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}


<script src="@Url.Content("~/Areas/DCM/" + debugPath + "Scripts/entity.reference.js")"
<script src="@Url.Content("~/Areas/DCM/" + debugPath + "Scripts/entity.reference.js")"/>
<div id="entity-reference-container" class="row text-left">
<div class="col-md-12">
Expand Down
150 changes: 76 additions & 74 deletions Console/BExIS.Web.Shell/Areas/DDM/Controllers/DataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
using BExIS.Security.Entities.Subjects;
using BExIS.Dlm.Services.MetadataStructure;
using System.Web.UI.WebControls;
using System.Security.Cryptography;

namespace BExIS.Modules.Ddm.UI.Controllers

Expand Down Expand Up @@ -619,66 +620,64 @@ public ActionResult ShowPrimaryData(long datasetID, int versionId)

try
{
if (dm.IsDatasetCheckedIn(datasetID))
var dataset = dm.GetDataset(datasetID);
Boolean latest = true;
string title = "";

if (dataset.Status != DatasetStatus.CheckedOut)
{
// get latest or other datasetversion
DatasetVersion dsv = dm.GetDatasetVersion(versionId);
bool latestVersion = versionId == dm.GetDatasetLatestVersionId(datasetID);
//TITLE
string title = dsv.Title;
DataTable table = null;
DatasetVersion dsv = null;
StructuredDataStructure sds = null;

if (dataset.Status == DatasetStatus.CheckedIn) // checi if version is latest
{
dsv = dm.GetDatasetVersion(versionId);
latest = versionId == dm.GetDatasetLatestVersionId(datasetID);
title = dsv.Title;
}

// TODO: refactor Download Right not existing, so i set it to read
bool downloadAccess = entityPermissionManager.HasEffectiveRight(HttpContext.User.Identity.Name, typeof(Dataset), datasetID, RightType.Read);

if (dsv.Dataset.DataStructure != null)
if (dataset.DataStructure != null)
{
StructuredDataStructure sds = dsm.StructuredDataStructureRepo.Get(dsv.Dataset.DataStructure.Id);
DataStructure ds = dsm.AllTypesDataStructureRepo.Get(dsv.Dataset.DataStructure.Id);
sds = dsm.StructuredDataStructureRepo.Get(dataset.DataStructure.Id);


if (ds.Self.GetType() == typeof(StructuredDataStructure))
// if deleted or latest show latest data,
if (dataset.Status == DatasetStatus.Deleted || (dataset.Status == DatasetStatus.CheckedIn && latest))
{
DataTable table = null;
// Count "Data" changes between current and latest version
int numberNewerDataVersions = dm.GetDatasetVersions(datasetID).Where(x => x.Id > versionId).Count(x => x.ModificationInfo.Comment.Contains("Data"));

// use MV for latest version and all older versions, if no data has been changed (only metadata)
if (latestVersion || numberNewerDataVersions == 0)
try
{
try
{
long count = dm.RowCount(datasetID, null);
if (count > 0) table = dm.GetLatestDatasetVersionTuples(datasetID, null, null, null,"", 0, 10);
else ModelState.AddModelError(string.Empty, "<span style=\"color: black;\"> There is no primary data available/uploaded. </span><br/><br/> <span style=\"font-weight: normal;color: black;\">Please note that the data may have been uploaded to another repository and is referenced here in the metadata.</span>");
}
catch
{
ModelState.AddModelError(string.Empty, "The data is not available, please ask the administrator for a synchronization.");
}

ViewData["gridTotal"] = dm.RowCount(dsv.Dataset.Id, null);
long count = dm.RowCount(datasetID, null);
if (count > 0) table = dm.GetLatestDatasetVersionTuples(datasetID, null, null, null, "", 0, 10);
else ModelState.AddModelError(string.Empty, "<span style=\"color: black;\"> There is no primary data available/uploaded. </span><br/><br/> <span style=\"font-weight: normal;color: black;\">Please note that the data may have been uploaded to another repository and is referenced here in the metadata.</span>");
}
else
catch
{
table = dm.GetDatasetVersionTuples(versionId, 0, 10);
ViewData["gridTotal"] = dm.GetDatasetVersionEffectiveTuples(dsv).Count;
ModelState.AddModelError(string.Empty, "The data is not available, please ask the administrator for a synchronization.");
}

sds.Variables = sds.Variables.OrderBy(v => v.OrderNo).ToList();

return PartialView(ShowPrimaryDataModel.Convert(
datasetID,
versionId,
title,
sds,
table,
downloadAccess,
iOUtility.GetSupportedAsciiFiles(),
latestVersion,
hasUserRights(datasetID, RightType.Write)
));
}
else
{
table = dm.GetDatasetVersionTuples(versionId, 0, 10);
ViewData["gridTotal"] = dm.GetDatasetVersionEffectiveTuples(dsv).Count;
}

ViewData["gridTotal"] = dm.RowCount(dataset.Id, null);

sds.Variables = sds.Variables.OrderBy(v => v.OrderNo).ToList();

return PartialView(ShowPrimaryDataModel.Convert(
datasetID,
versionId,
title,
sds,
table,
downloadAccess,
iOUtility.GetSupportedAsciiFiles(),
latest,
hasUserRights(datasetID, RightType.Write)
));
}
else
{
Expand All @@ -693,15 +692,11 @@ public ActionResult ShowPrimaryData(long datasetID, int versionId)
SearchUIHelper.GetContantDescriptorFromKey(dsv, "unstructuredData"),
downloadAccess,
iOUtility.GetSupportedAsciiFiles(),
latestVersion,
latest,
hasUserRights(datasetID, RightType.Write)
));
}
}
else
{
ModelState.AddModelError(string.Empty, "The dataset is currently being processed and is therefore locked.");
}

return PartialView(null);
}
Expand All @@ -728,31 +723,42 @@ public ActionResult _CustomPrimaryDataBinding(GridCommand command, string column

try
{
if (dm.IsDatasetCheckedIn(datasetId))
{
DatasetVersion dsv = dm.GetDatasetVersion(versionId);
long latestDatasetVersionId = dm.GetDatasetLatestVersionId(datasetId);
var dataset = dm.GetDataset(datasetId);
Boolean latest = true;

if (dataset.Status != DatasetStatus.CheckedOut)
{
DataTable table = null;
DatasetVersion dsv = null;
if (dataset.Status == DatasetStatus.CheckedIn) // checi if version is latest
{
dsv = dm.GetDatasetVersion(versionId);
long latestDatasetVersionId = dm.GetDatasetLatestVersionId(datasetId);
if (versionId == latestDatasetVersionId) latest = true;
}

// get primarydata from latest version with table
if (versionId == latestDatasetVersionId)
// if deleted or latest show latest data,
if (dataset.Status == DatasetStatus.Deleted || (dataset.Status == DatasetStatus.CheckedIn && latest))
{
// get primarydata from latest version with table

FilterExpression filter = TelerikGridHelper.Convert(command.FilterDescriptors.ToList());
OrderByExpression orderBy = TelerikGridHelper.Convert(command.SortDescriptors.ToList());

table = dm.GetLatestDatasetVersionTuples(datasetId, filter, orderBy, null,"", command.Page - 1, command.PageSize);
table = dm.GetLatestDatasetVersionTuples(datasetId, filter, orderBy, null, "", command.Page - 1, command.PageSize);
ViewData["gridTotal"] = dm.RowCount(datasetId, filter);
}
// get primarydata from other version with tuples
else
{
table = dm.GetDatasetVersionTuples(versionId, command.Page - 1, command.PageSize);
ViewData["gridTotal"] = dm.GetDatasetVersionEffectiveTuples(dsv).Count;
}
if (!latest)
{
table = dm.GetDatasetVersionTuples(versionId, command.Page - 1, command.PageSize);
ViewData["gridTotal"] = dm.GetDatasetVersionEffectiveTuples(dsv).Count;
}

model = new GridModel(table);
model.Total = Convert.ToInt32(ViewData["gridTotal"]); // (int)Session["gridTotal"];
model = new GridModel(table);
model.Total = Convert.ToInt32(ViewData["gridTotal"]); // (int)Session["gridTotal"];
}
}
else
{
Expand Down Expand Up @@ -1455,13 +1461,13 @@ public ActionResult _CustomDataStructureBinding(GridCommand command, long datase

try
{
long id = datasetID;
if (dm.IsDatasetCheckedIn(id))
using (var uow = this.GetUnitOfWork())
{
DatasetVersion ds = dm.GetDatasetLatestVersion(id);
if (ds != null)
Dataset dataset = dm.GetDataset(datasetID);

if (dataset != null)
{
StructuredDataStructure sds = dsm.StructuredDataStructureRepo.Get(ds.Dataset.DataStructure.Id);
StructuredDataStructure sds = dsm.StructuredDataStructureRepo.Get(dataset.DataStructure.Id);
dsm.StructuredDataStructureRepo.LoadIfNot(sds.Variables);
//StructuredDataStructure sds = (StructuredDataStructure)(ds.Dataset.DataStructure.Self);
SearchUIHelper suh = new SearchUIHelper();
Expand All @@ -1470,10 +1476,6 @@ public ActionResult _CustomDataStructureBinding(GridCommand command, long datase
return View(new GridModel(table));
}
}
else
{
ModelState.AddModelError(String.Empty, "Dataset is just in processing.");
}
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
<h1>@Model.Title </h1>
</div>

@if (Model.HasEditRight)
@if (Model.HasEditRight && ViewData["state"].ToString() != "hidden")
{
<div class="datasetview_header-toggle" onclick="toogleToEdit()">
<div class="switch">
Expand Down
8 changes: 6 additions & 2 deletions Console/BExIS.Web.Shell/Areas/DIM/Helpers/MappingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,8 +1194,12 @@ public static bool UpdateSimpleMappings(long sourceId, long targetId, List<Simpl
simplemapping.TransformationRule = transformationRule;
mappingManager.UpdateMapping(simplemapping);

simplemappingReverse.TransformationRule = transformationRule;
mappingManager.UpdateMapping(simplemappingReverse);
if (bothDirections)
{
simplemappingReverse.TransformationRule = transformationRule;
mappingManager.UpdateMapping(simplemappingReverse);
}

}

sm.Id = simplemapping.Id;
Expand Down
14 changes: 12 additions & 2 deletions Console/BExIS.Web.Shell/Areas/DIM/Hooks/PublishHook.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BExIS.Security.Entities.Authorization;
using BExIS.Dlm.Services.Data;
using BExIS.Security.Entities.Authorization;
using BExIS.UI.Hooks;
using System;
using System.Collections.Generic;
Expand All @@ -23,6 +24,9 @@ public override void Check(long id, string username)

private void checkStatus(long id, string username)
{

Status = HookStatus.Open;

// check if the user has access rights to the entrypoint - set in Start
bool hasAccess = hasUserAccessRights(username);

Expand All @@ -32,7 +36,13 @@ private void checkStatus(long id, string username)
// if one fail then access is denied
if(hasAccess == false || hasRights == false) Status = HookStatus.AccessDenied;

Status = HookStatus.Open;
using (var datasetManager = new DatasetManager())
{
var dataset = datasetManager.GetDataset(id);
if (dataset.Status != Dlm.Entities.Data.DatasetStatus.CheckedIn) Status = HookStatus.Disabled;
}


}

}
Expand Down
6 changes: 4 additions & 2 deletions Console/BExIS.Web.Shell/Controllers/TokensController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BExIS.App.Bootstrap.Attributes;
using BExIS.App.Bootstrap.Helpers;
using BExIS.Security.Entities.Subjects;
using BExIS.Security.Services.Subjects;
using BExIS.Utils.Config;
Expand Down Expand Up @@ -86,7 +87,8 @@ public async Task<ActionResult> GetToken()

using (var userManager = new UserManager())
{
var user = await userManager.FindByNameAsync(HttpContext.User.Identity.Name);
var user = BExISAuthorizeHelper.GetUserFromAuthorizationAsync(HttpContext).Result;

if (user != null)
{
var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtConfiguration.IssuerSigningKey));
Expand Down Expand Up @@ -134,7 +136,7 @@ public async Task<ActionResult> Get()

using (var userManager = new UserManager())
{
var user = await userManager.FindByNameAsync(HttpContext.User.Identity.Name);
var user = BExISAuthorizeHelper.GetUserFromAuthorizationAsync(HttpContext).Result;
if (user != null)
{
var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtConfiguration.IssuerSigningKey));
Expand Down
Loading

0 comments on commit 636e6eb

Please sign in to comment.