This commit is contained in:
@@ -58,8 +58,8 @@ namespace AyaNova.Api.Controllers
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
if (selectedRequest.IsEmpty)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelection is required"));
|
||||
if (selectedRequest == null)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelectedRequest is required"));
|
||||
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, selectedRequest.ObjectType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
@@ -70,9 +70,16 @@ namespace AyaNova.Api.Controllers
|
||||
if (format != "csv" && format != "json")
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "format not valid, must be 'csv' or 'json'"));
|
||||
|
||||
await selectedRequest.RehydrateIdList(ct, UserRolesFromContext.Roles(HttpContext.Items), log, UserIdFromContext.Id(HttpContext.Items));
|
||||
|
||||
//Rehydrate id list if necessary
|
||||
if (selectedRequest.SelectedRowIds.Length == 0)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids"));
|
||||
selectedRequest.SelectedRowIds = await DataListSelectedProcessingOptions.RehydrateIdList(
|
||||
selectedRequest,
|
||||
ct,
|
||||
UserRolesFromContext.Roles(HttpContext.Items),
|
||||
log,
|
||||
UserIdFromContext.Id(HttpContext.Items),
|
||||
UserTranslationIdFromContext.Id(HttpContext.Items));
|
||||
|
||||
|
||||
log.LogDebug($"Instantiating biz object handler for {selectedRequest.ObjectType}");
|
||||
|
||||
@@ -203,17 +203,22 @@ namespace AyaNova.Api.Controllers
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
if (selectedRequest.IsEmpty)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelection is required"));
|
||||
if (selectedRequest == null)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelectedRequest is required"));
|
||||
|
||||
|
||||
if (!Authorized.HasDeleteRole(HttpContext.Items, selectedRequest.ObjectType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
|
||||
await selectedRequest.RehydrateIdList(ct, UserRolesFromContext.Roles(HttpContext.Items), log, UserIdFromContext.Id(HttpContext.Items));
|
||||
//Rehydrate id list if necessary
|
||||
if (selectedRequest.SelectedRowIds.Length == 0)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids"));
|
||||
selectedRequest.SelectedRowIds = await DataListSelectedProcessingOptions.RehydrateIdList(
|
||||
selectedRequest,
|
||||
ct,
|
||||
UserRolesFromContext.Roles(HttpContext.Items),
|
||||
log,
|
||||
UserIdFromContext.Id(HttpContext.Items),
|
||||
UserTranslationIdFromContext.Id(HttpContext.Items));
|
||||
|
||||
var JobName = $"LT:BatchDeleteJob - LT:{selectedRequest.ObjectType} ({selectedRequest.SelectedRowIds.LongLength}) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
JObject o = JObject.FromObject(new
|
||||
|
||||
@@ -196,32 +196,7 @@ namespace AyaNova.Api.Controllers
|
||||
ReportBiz biz = ReportBiz.GetBiz(ct, HttpContext);
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
|
||||
// //-------------------------------
|
||||
// var UserRoles = UserRolesFromContext.Roles(HttpContext.Items);
|
||||
// var UserId = UserIdFromContext.Id(HttpContext.Items);
|
||||
// DataListSavedColumnViewBiz viewbiz = DataListSavedColumnViewBiz.GetBiz(ct, HttpContext);
|
||||
// var SavedView = await viewbiz.GetAsync(UserId, selectedRequest.DataListKey, true);
|
||||
|
||||
// DataListSavedFilter SavedFilter = null;
|
||||
// if (selectedRequest.FilterId != 0)
|
||||
// {
|
||||
// DataListSavedFilterBiz filterbiz = DataListSavedFilterBiz.GetBiz(ct, HttpContext);
|
||||
// SavedFilter = await filterbiz.GetAsync(selectedRequest.FilterId, false);
|
||||
// }
|
||||
// var DataList = DataListFactory.GetAyaDataList(selectedRequest.DataListKey);
|
||||
// if (DataList == null)
|
||||
// return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, "DataListKey", $"DataList \"{selectedRequest.DataListKey}\" specified does not exist"));
|
||||
|
||||
// //check rights
|
||||
// if (!UserRoles.HasAnyFlags(DataList.AllowedRoles))
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
// //hydrate the saved view and filter
|
||||
// DataListSelectedProcessingOptions dataListSelectedOptions = new DataListSelectedProcessingOptions(selectedRequest, DataList, SavedView, SavedFilter, UserId, UserRoles);
|
||||
// //------------------------
|
||||
|
||||
|
||||
|
||||
var reportData = await biz.GetReportData(selectedRequest);
|
||||
if (reportData == null)
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace AyaNova.Api.Controllers
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
if (selectedRequest.IsEmpty)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelection is required"));
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelectedRequest is required"));
|
||||
|
||||
if (!selectedRequest.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type"));
|
||||
@@ -103,9 +103,15 @@ namespace AyaNova.Api.Controllers
|
||||
if (string.IsNullOrWhiteSpace(tag))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "tag required"));
|
||||
|
||||
await selectedRequest.RehydrateIdList(ct, UserRolesFromContext.Roles(HttpContext.Items), log, UserIdFromContext.Id(HttpContext.Items));
|
||||
//Rehydrate id list if necessary
|
||||
if (selectedRequest.SelectedRowIds.Length == 0)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids"));
|
||||
selectedRequest.SelectedRowIds = await DataListSelectedProcessingOptions.RehydrateIdList(
|
||||
selectedRequest,
|
||||
ct,
|
||||
UserRolesFromContext.Roles(HttpContext.Items),
|
||||
log,
|
||||
UserIdFromContext.Id(HttpContext.Items),
|
||||
UserTranslationIdFromContext.Id(HttpContext.Items));
|
||||
|
||||
var JobName = $"LT:BatchJob LT:Add LT:Tag \"{tag}\" LT:{selectedRequest.ObjectType} ({selectedRequest.SelectedRowIds.LongLength}) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
JObject o = JObject.FromObject(new
|
||||
@@ -181,7 +187,7 @@ namespace AyaNova.Api.Controllers
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
if (selectedRequest.IsEmpty)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelection is required"));
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelectedRequest is required"));
|
||||
|
||||
if (!selectedRequest.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type"));
|
||||
@@ -192,10 +198,15 @@ namespace AyaNova.Api.Controllers
|
||||
if (string.IsNullOrWhiteSpace(tag))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "tag"));
|
||||
|
||||
await selectedRequest.RehydrateIdList(ct, UserRolesFromContext.Roles(HttpContext.Items), log, UserIdFromContext.Id(HttpContext.Items));
|
||||
//Rehydrate id list if necessary
|
||||
if (selectedRequest.SelectedRowIds.Length == 0)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids"));
|
||||
|
||||
selectedRequest.SelectedRowIds = await DataListSelectedProcessingOptions.RehydrateIdList(
|
||||
selectedRequest,
|
||||
ct,
|
||||
UserRolesFromContext.Roles(HttpContext.Items),
|
||||
log,
|
||||
UserIdFromContext.Id(HttpContext.Items),
|
||||
UserTranslationIdFromContext.Id(HttpContext.Items));
|
||||
|
||||
var JobName = $"LT:BatchJob LT:Remove LT:Tag \"{tag}\" LT:{selectedRequest.ObjectType} ({selectedRequest.SelectedRowIds.LongLength}) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
JObject o = JObject.FromObject(new
|
||||
@@ -263,20 +274,20 @@ namespace AyaNova.Api.Controllers
|
||||
/// </summary>
|
||||
/// <param name="fromTag"></param>
|
||||
/// <param name="toTag"></param>
|
||||
/// <param name="dataListSelection"></param>
|
||||
/// <param name="selectedRequest"></param>
|
||||
/// <returns>Job Id</returns>
|
||||
[HttpPost("batch-replace/{fromTag}")]
|
||||
public async Task<IActionResult> BatchReplace([FromRoute] string fromTag, [FromQuery] string toTag, [FromBody] DataListSelectedRequest dataListSelection)
|
||||
public async Task<IActionResult> BatchReplace([FromRoute] string fromTag, [FromQuery] string toTag, [FromBody] DataListSelectedRequest selectedRequest)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
if (dataListSelection.IsEmpty)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelection is required"));
|
||||
if (!dataListSelection.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
if (selectedRequest.IsEmpty)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelectedRequest is required"));
|
||||
if (!selectedRequest.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type"));
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, dataListSelection.ObjectType))
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, selectedRequest.ObjectType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
fromTag = TagBiz.NormalizeTag(fromTag);
|
||||
if (string.IsNullOrWhiteSpace(fromTag))
|
||||
@@ -284,20 +295,27 @@ namespace AyaNova.Api.Controllers
|
||||
toTag = TagBiz.NormalizeTag(toTag);
|
||||
if (string.IsNullOrWhiteSpace(toTag))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "toTag"));
|
||||
await dataListSelection.RehydrateIdList(ct, UserRolesFromContext.Roles(HttpContext.Items), log, UserIdFromContext.Id(HttpContext.Items));
|
||||
if (dataListSelection.SelectedRowIds.Length == 0)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids"));
|
||||
|
||||
//Rehydrate id list if necessary
|
||||
if (selectedRequest.SelectedRowIds.Length == 0)
|
||||
selectedRequest.SelectedRowIds = await DataListSelectedProcessingOptions.RehydrateIdList(
|
||||
selectedRequest,
|
||||
ct,
|
||||
UserRolesFromContext.Roles(HttpContext.Items),
|
||||
log,
|
||||
UserIdFromContext.Id(HttpContext.Items),
|
||||
UserTranslationIdFromContext.Id(HttpContext.Items));
|
||||
|
||||
var JobName = $"LT:BatchJob LT:Replace LT:Tag \"{fromTag}\" -> LT:Tag \"{toTag}\" LT:{dataListSelection.ObjectType} ({dataListSelection.SelectedRowIds.LongLength}) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
var JobName = $"LT:BatchJob LT:Replace LT:Tag \"{fromTag}\" -> LT:Tag \"{toTag}\" LT:{selectedRequest.ObjectType} ({selectedRequest.SelectedRowIds.LongLength}) LT:User {UserNameFromContext.Name(HttpContext.Items)}";
|
||||
JObject o = JObject.FromObject(new
|
||||
{
|
||||
idList = dataListSelection.SelectedRowIds,
|
||||
idList = selectedRequest.SelectedRowIds,
|
||||
tag = fromTag,
|
||||
toTag = toTag
|
||||
});
|
||||
|
||||
OpsJob j = new OpsJob();
|
||||
j.ObjectType = dataListSelection.ObjectType;
|
||||
j.ObjectType = selectedRequest.ObjectType;
|
||||
j.Name = JobName;
|
||||
j.JobType = JobType.BatchCoreObjectOperation;
|
||||
j.SubType = JobSubType.TagReplace;
|
||||
|
||||
Reference in New Issue
Block a user