diff --git a/.vscode/launch.json b/.vscode/launch.json index d0c5b057..3390857f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -52,7 +52,7 @@ "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", - "AYANOVA_SERVER_TEST_MODE": "true", + "AYANOVA_SERVER_TEST_MODE": "false", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\" diff --git a/server/AyaNova/Controllers/TagController.cs b/server/AyaNova/Controllers/TagController.cs index 94359d25..623bf4d0 100644 --- a/server/AyaNova/Controllers/TagController.cs +++ b/server/AyaNova/Controllers/TagController.cs @@ -103,7 +103,7 @@ namespace AyaNova.Api.Controllers tag = TagBiz.NormalizeTag(tag); if (string.IsNullOrWhiteSpace(tag)) return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "tag required")); - + await dataListSelection.RehydrateIdList(ct, UserRolesFromContext.Roles(HttpContext.Items), log); if (dataListSelection.SelectedRowIds.Length == 0) return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids")); @@ -169,38 +169,45 @@ namespace AyaNova.Api.Controllers /// /// Bulk remove tags to list of object id's specified - /// - /// + /// /// - /// + /// /// Job Id - [HttpPost("bulk-remove/{ayaType}/{tag}")] - public async Task BulkRemove([FromRoute] AyaType ayaType, [FromRoute] string tag, [FromBody] List idList) + [HttpPost("bulk-remove/{tag}")] + public async Task BulkRemove([FromRoute] string tag, [FromBody] DataListSelection dataListSelection) { if (!serverState.IsOpen) return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); - if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) + + if (dataListSelection.IsEmpty) + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelection is required")); + + if (!dataListSelection.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute))) return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type")); - if (!Authorized.HasModifyRole(HttpContext.Items, ayaType)) + if (!Authorized.HasModifyRole(HttpContext.Items, dataListSelection.ObjectType)) return StatusCode(403, new ApiNotAuthorizedResponse()); - if (idList.Count == 0) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids")); + tag = TagBiz.NormalizeTag(tag); if (string.IsNullOrWhiteSpace(tag)) return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "tag")); - var JobName = $"Bulk operation: Remove tag \"{tag}\" from {ayaType} ({idList.Count} specified)"; + await dataListSelection.RehydrateIdList(ct, UserRolesFromContext.Roles(HttpContext.Items), log); + if (dataListSelection.SelectedRowIds.Length == 0) + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids")); + + + var JobName = $"Bulk operation: Remove tag \"{tag}\" from {dataListSelection.ObjectType} ({dataListSelection.SelectedRowIds.LongLength} specified)"; JObject o = JObject.FromObject(new { - idList = idList, + idList = dataListSelection.SelectedRowIds, tag = tag }); OpsJob j = new OpsJob(); j.Name = JobName; - j.ObjectType = ayaType; + j.ObjectType = dataListSelection.ObjectType; j.JobType = JobType.BulkCoreBizObjectOperation; j.SubType = JobSubType.TagRemove; j.Exclusive = false; @@ -254,41 +261,44 @@ namespace AyaNova.Api.Controllers /// /// Bulk replace tags to list of object id's specified - /// - /// + /// /// /// - /// + /// /// Job Id - [HttpPost("bulk-replace/{ayaType}/{fromTag}")] - public async Task BulkReplace([FromRoute] AyaType ayaType, [FromRoute] string fromTag, [FromQuery] string toTag, [FromBody] List idList) + [HttpPost("bulk-replace/{fromTag}")] + public async Task BulkReplace([FromRoute] string fromTag, [FromQuery] string toTag, [FromBody] DataListSelection dataListSelection) { if (!serverState.IsOpen) return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); - if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) + if (dataListSelection.IsEmpty) + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelection is required")); + if (!dataListSelection.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute))) return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type")); - if (!Authorized.HasModifyRole(HttpContext.Items, ayaType)) + if (!Authorized.HasModifyRole(HttpContext.Items, dataListSelection.ObjectType)) return StatusCode(403, new ApiNotAuthorizedResponse()); - if (idList.Count == 0) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids")); fromTag = TagBiz.NormalizeTag(fromTag); if (string.IsNullOrWhiteSpace(fromTag)) return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "fromTag")); toTag = TagBiz.NormalizeTag(toTag); if (string.IsNullOrWhiteSpace(toTag)) return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "toTag")); - var JobName = $"Bulk operation: Replace tag \"{fromTag}\" with tag \"{toTag}\" on {ayaType} ({idList.Count} specified)"; + await dataListSelection.RehydrateIdList(ct, UserRolesFromContext.Roles(HttpContext.Items), log); + if (dataListSelection.SelectedRowIds.Length == 0) + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids")); + + var JobName = $"Bulk operation: Replace tag \"{fromTag}\" with tag \"{toTag}\" on {dataListSelection.ObjectType} ({dataListSelection.SelectedRowIds.LongLength} specified)"; JObject o = JObject.FromObject(new { - idList = idList, + idList = dataListSelection.SelectedRowIds, tag = fromTag, toTag = toTag }); OpsJob j = new OpsJob(); - j.ObjectType = ayaType; + j.ObjectType = dataListSelection.ObjectType; j.Name = JobName; j.JobType = JobType.BulkCoreBizObjectOperation; j.SubType = JobSubType.TagReplace;