Commit 1bb85fb3 authored by Alicia.DeDiosFuente's avatar Alicia.DeDiosFuente Committed by Florent Poittevin
Browse files

feat: [DLCM-2059] Adapt preservation job for order purge job

parent 1ff715d0
......@@ -1056,10 +1056,6 @@ export namespace Enums {
value: MARK_AS_TRANSLATABLE("order.enum.status.ready"),
backgroundColorHexa: ColorHexaEnum.green,
},
{
key: StatusEnum.COMPLETED,
value: MARK_AS_TRANSLATABLE("order.enum.status.completed"),
},
{
key: StatusEnum.IN_DISSEMINATION_PREPARATION,
value: MARK_AS_TRANSLATABLE("order.enum.status.inDisseminationPreparation"),
......@@ -1266,6 +1262,10 @@ export namespace Enums {
key: TypeEnum.PURGE_SUBMISSION_TEMP_FILES,
value: MARK_AS_TRANSLATABLE("preservation.job.jobTypeEnum.purgeSubmissionTempFiles"),
},
{
key: TypeEnum.PURGE_ORDER,
value: MARK_AS_TRANSLATABLE("preservation.job.jobTypeEnum.purgeOrder"),
},
{
key: TypeEnum.REBUILD_REGISTRY,
value: MARK_AS_TRANSLATABLE("preservation.job.jobTypeEnum.rebuildRegistry"),
......@@ -1278,6 +1278,7 @@ export namespace Enums {
key: TypeEnum.RELOAD,
value: MARK_AS_TRANSLATABLE("preservation.job.jobTypeEnum.reload"),
},
{
key: TypeEnum.REPLICATION,
value: MARK_AS_TRANSLATABLE("preservation.job.jobTypeEnum.replication"),
......
......@@ -242,6 +242,7 @@ export namespace OrderAllOrderAction {
export class ResumeFail extends BaseSubActionFail<Resume> {
static readonly type: string = `[${state}] Resume Fail`;
}
}
export const orderAllOrderActionNameSpace: ResourceNameSpace = OrderAllOrderAction;
......@@ -300,4 +300,5 @@ export class OrderAllOrderState extends ResourceState<OrderAllOrderStateModel, O
isLoadingCounter: ctx.getState().isLoadingCounter - 1,
});
}
}
......@@ -213,6 +213,13 @@ export namespace PreservationPlanningDipAction {
export class PutInErrorFail extends BaseSubActionFail<PutInError> {
static readonly type: string = `[${state}] Put In Error Fail`;
}
export class GoToDip {
static readonly type: string = `[${state}] Go To DIP`;
constructor(public dipId: string) {
}
}
}
export const preservationPlanningDipActionNameSpace: ResourceNameSpace = PreservationPlanningDipAction;
......@@ -34,6 +34,7 @@ import {
StateContext,
Store,
} from "@ngxs/store";
import {OrderAllOrderStateModel} from "@order/features/all-order/stores/order-all-order.state";
import {
PreservationPlanningDipAipState,
PreservationPlanningDipAipStateModel,
......@@ -52,8 +53,11 @@ import {
PreservationPlanningDipStatusHistoryStateModel,
} from "@preservation-planning/dip/stores/status-history/preservation-planning-dip-status-history.state";
import {
AppRoutesEnum,
DepositRoutesEnum,
PreservationPlanningRoutesEnum,
RoutesEnum,
urlSeparator,
} from "@shared/enums/routes.enum";
import {StateEnum} from "@shared/enums/state.enum";
import {defaultStatusHistoryInitValue} from "@shared/stores/status-history/status-history.state";
......@@ -245,4 +249,11 @@ export class PreservationPlanningDipState extends ResourceState<PreservationPlan
});
this.notificationService.showError(MARK_AS_TRANSLATABLE("notification.dip.action.put-in-error.fail"));
}
@Action(PreservationPlanningDipAction.GoToDip)
goToDip(ctx: StateContext<OrderAllOrderStateModel>, action: PreservationPlanningDipAction.GoToDip): void {
const pathOrderDetail = RoutesEnum.preservationPlanningDip + urlSeparator + PreservationPlanningRoutesEnum.dipDetail + AppRoutesEnum.separator;
const path = [pathOrderDetail, action.dipId];
ctx.dispatch(new Navigate(path));
}
}
......@@ -37,18 +37,28 @@ import {
import {PreservationPlanningDepositStatusHistoryState} from "@app/features/preservation-planning/deposit/stores/status-history/preservation-planning-deposit-status-history.state";
import {Enums} from "@enums";
import {environment} from "@environments/environment";
import {Navigate} from "@ngxs/router-plugin";
import {Store} from "@ngxs/store";
import {PreservationPlanningDepositStatusHistoryAction} from "@preservation-planning/deposit/stores/status-history/preservation-planning-deposit-status-history.action";
import {PreservationPlanningDipAction} from "@preservation-planning/dip/stores/preservation-planning-dip.action";
import {PreservationPlanningDipStatusHistoryAction} from "@preservation-planning/dip/stores/status-history/preservation-planning-dip-status-history.action";
import {PreservationPlanningDipStatusHistoryState} from "@preservation-planning/dip/stores/status-history/preservation-planning-dip-status-history.state";
import {PreservationPlanningJobReportDetailErrorMessageDialog} from "@preservation-planning/job/components/dialogs/job-report-detail-error-message/preservation-planning-job-report-detail-error-message.dialog";
import {PreservationPlanningJobExecutionReportAction} from "@preservation-planning/job/stores/job-execution/job-execution-report/preservation-planning-job-execution-report.action";
import {PreservationPlanningJobExecutionReportState} from "@preservation-planning/job/stores/job-execution/job-execution-report/preservation-planning-job-execution-report.state";
import {PreservationPlanningSipStatusHistoryAction} from "@preservation-planning/sip/stores/status-history/preservation-planning-sip-status-history.action";
import {PreservationPlanningSipStatusHistoryState} from "@preservation-planning/sip/stores/status-history/preservation-planning-sip-status-history.state";
import {PreservationPlanningOrderAction} from "@preservation-planning/stores/order/preservation-planning-order.action";
import {PreservationPlanningOrderStatusHistoryAction} from "@preservation-planning/stores/order/status-history/preservation-planning-order-status-history.action";
import {PreservationPlanningOrderStatusHistoryState} from "@preservation-planning/stores/order/status-history/preservation-planning-order-status-history.state";
import {SharedAbstractDialog} from "@shared/components/dialogs/shared-abstract/shared-abstract.dialog";
import {ApiEnum} from "@shared/enums/api.enum";
import {DataTableComponentEnum} from "@shared/enums/data-table-component.enum";
import {IconNameEnum} from "@shared/enums/icon-name.enum";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {
RoutesEnum,
} from "@shared/enums/routes.enum";
import {StateEnum} from "@shared/enums/state.enum";
import {SharedAipStatusHistoryAction} from "@shared/features/aip/stores/status-history/shared-aip-status-history.action";
import {SharedAipStatusHistoryState} from "@shared/features/aip/stores/status-history/shared-aip-status-history.state";
......@@ -94,6 +104,14 @@ export class PreservationPlanningJobReportDetailDialog extends SharedAbstractDia
isLoadingHistoryDepositObs: Observable<boolean> = MemoizedUtil.isLoading(this._store, PreservationPlanningDepositStatusHistoryState);
queryParametersHistoryDepositObs: Observable<QueryParameters> = MemoizedUtil.select(this._store, PreservationPlanningDepositStatusHistoryState, state => state.queryParameters);
historyOrderObs: Observable<StatusHistory[]> = MemoizedUtil.select(this._store, PreservationPlanningOrderStatusHistoryState, state => state.history);
isLoadingHistoryOrderObs: Observable<boolean> = MemoizedUtil.isLoading(this._store, PreservationPlanningOrderStatusHistoryState);
queryParametersHistoryOrderObs: Observable<QueryParameters> = MemoizedUtil.select(this._store, PreservationPlanningOrderStatusHistoryState, state => state.queryParameters);
historyDipObs: Observable<StatusHistory[]> = MemoizedUtil.select(this._store, PreservationPlanningDipStatusHistoryState, state => state.history);
isLoadingHistoryDipObs: Observable<boolean> = MemoizedUtil.isLoading(this._store, PreservationPlanningDipStatusHistoryState);
queryParametersHistoryDipObs: Observable<QueryParameters> = MemoizedUtil.select(this._store, PreservationPlanningDipStatusHistoryState, state => state.queryParameters);
paramMessage: { resId: string } = {resId: StringUtil.stringEmpty};
columns: DataTableColumns<JobExecutionReportLine>[];
......@@ -108,7 +126,8 @@ export class PreservationPlanningJobReportDetailDialog extends SharedAbstractDia
logo: IconNameEnum.history,
callback: (jobExecutionReportLine: JobExecutionReportLine) => this.historyAip(jobExecutionReportLine),
placeholder: current => LabelTranslateEnum.showHistoryStatus,
displayOnCondition: (jobExecutionReportLine: JobExecutionReportLine) => jobExecutionReportLine.status !== Enums.PreservationJob.JobExecutionReportStatusEnum.ERROR,
displayOnCondition: (jobExecutionReportLine: JobExecutionReportLine) => jobExecutionReportLine.status !== Enums.PreservationJob.JobExecutionReportStatusEnum.ERROR
&& isNotNullNorUndefined(jobExecutionReportLine.url),
},
];
......@@ -172,6 +191,15 @@ export class PreservationPlanningJobReportDetailDialog extends SharedAbstractDia
} else if (jobExecutionReportLine.url.indexOf(ApiEnum.preIngestDeposits) !== -1) {
this._store.dispatch(new PreservationPlanningJobExecutionReportAction.GoToDeposit(jobExecutionReportLine.resId));
this.close();
} else if (jobExecutionReportLine.url.indexOf(ApiEnum.accessOrders) !== -1) {
this._store.dispatch(new PreservationPlanningOrderAction.GoToOrder(jobExecutionReportLine.resId));
this.close();
} else if (jobExecutionReportLine.url.indexOf(ApiEnum.accessDip) !== -1) {
this._store.dispatch(new PreservationPlanningDipAction.GoToDip(jobExecutionReportLine.resId));
this.close();
} else if (jobExecutionReportLine.url.indexOf(ApiEnum.accessAipDownloaded) !== -1) {
this._store.dispatch(new Navigate([RoutesEnum.preservationPlanningAipDownloadedDetail, jobExecutionReportLine.resId]));
this.close();
} else {
for (const storage of ApiEnum.archivalStorageAipStorages) {
if (jobExecutionReportLine.url.indexOf(storage.url) !== -1 || jobExecutionReportLine.url === ApiEnum.archivalStorage) {
......@@ -216,6 +244,8 @@ export class PreservationPlanningJobReportDetailDialog extends SharedAbstractDia
state: PreservationPlanningDepositStatusHistoryAction,
statusEnums: Enums.Package.StatusEnumTranslate,
};
} else if (this.data.jobType === Enums.PreservationJob.TypeEnum.PURGE_ORDER) {
dataForDialog = this.getDataHistoryForPurgeOrder(jobExecutionReportLine);
} else {
dataForDialog = {
parentId: null,
......@@ -232,6 +262,45 @@ export class PreservationPlanningJobReportDetailDialog extends SharedAbstractDia
width: environment.modalWidth,
});
}
private getDataHistoryForPurgeOrder(jobExecutionReportLine: JobExecutionReportLine): StatusHistoryDialogData {
let dataForDialog: StatusHistoryDialogData;
if (jobExecutionReportLine.url.indexOf(ApiEnum.accessOrders) !== -1) {
dataForDialog = {
parentId: null,
resourceResId: jobExecutionReportLine.resId,
name: StateEnum.preservationPlanning_order,
statusHistory: this.historyOrderObs,
isLoading: this.isLoadingHistoryOrderObs,
queryParametersObs: this.queryParametersHistoryOrderObs,
state: PreservationPlanningOrderStatusHistoryAction,
statusEnums: Enums.Package.StatusEnumTranslate,
};
} else if (jobExecutionReportLine.url.indexOf(ApiEnum.accessAipDownloaded) !== -1) {
dataForDialog = {
parentId: null,
resourceResId: jobExecutionReportLine.resId,
name: StateEnum.shared_aip,
statusHistory: this.historyAipObs,
isLoading: this.isLoadingHistoryAipObs,
queryParametersObs: this.queryParametersHistoryAipObs,
state: SharedAipStatusHistoryAction,
statusEnums: Enums.Package.StatusEnumTranslate,
};
} else if (jobExecutionReportLine.url.indexOf(ApiEnum.accessDip) !== -1) {
dataForDialog = {
parentId: null,
resourceResId: jobExecutionReportLine.resId,
name: StateEnum.preservationPlanning_dip,
statusHistory: this.historyAipObs,
isLoading: this.isLoadingHistoryDipObs,
queryParametersObs: this.queryParametersHistoryDipObs,
state: PreservationPlanningDipStatusHistoryAction,
statusEnums: Enums.Package.StatusEnumTranslate,
};
}
return dataForDialog;
}
}
export interface PreservationPlanningJobReportDetailDialogData {
......
......@@ -45,6 +45,8 @@ import {PreservationPlanningSipDataFileState} from "@preservation-planning/sip/s
import {PreservationPlanningSipDataFileStatusHistoryState} from "@preservation-planning/sip/stores/data-file/status-history/preservation-planning-sip-data-file-status-history.state";
import {PreservationPlanningSipState} from "@preservation-planning/sip/stores/preservation-planning-sip.state";
import {PreservationPlanningSipStatusHistoryState} from "@preservation-planning/sip/stores/status-history/preservation-planning-sip-status-history.state";
import {PreservationPlanningOrderState} from "@preservation-planning/stores/order/preservation-planning-order.state";
import {PreservationPlanningOrderStatusHistoryState} from "@preservation-planning/stores/order/status-history/preservation-planning-order-status-history.state";
import {PreservationPlanningState} from "@preservation-planning/stores/preservation-planning.state";
import {ModuleLoadedEnum} from "@shared/enums/module-loaded.enum";
import {PreservationPlanningDepositStatusHistoryState} from "@preservation-planning/deposit/stores/status-history/preservation-planning-deposit-status-history.state";
......@@ -88,6 +90,8 @@ const presentationals = [];
PreservationPlanningDipAipState,
PreservationPlanningDepositState,
PreservationPlanningDepositStatusHistoryState,
PreservationPlanningOrderState,
PreservationPlanningOrderStatusHistoryState,
]),
],
exports: [
......
/*-
* %%----------------------------------------------------------------------------------------------
* DLCM Technology - DLCM Portal - preservation-planning-order.action.ts
* SPDX-License-Identifier: GPL-2.0-or-later
* %----------------------------------------------------------------------------------------------%
* Copyright (C) 2017 - 2022 University of Geneva
* %----------------------------------------------------------------------------------------------%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* ----------------------------------------------------------------------------------------------%%
*/
import {Order} from "@models";
import {StateEnum} from "@shared/enums/state.enum";
import {
ResourceAction,
ResourceNameSpace,
TypeDefaultAction,
} from "solidify-frontend";
const state = StateEnum.preservationPlanning_order;
export namespace PreservationPlanningOrderAction {
@TypeDefaultAction(state)
export class LoadResource extends ResourceAction.LoadResource {
}
@TypeDefaultAction(state)
export class LoadResourceSuccess extends ResourceAction.LoadResourceSuccess {
}
@TypeDefaultAction(state)
export class LoadResourceFail extends ResourceAction.LoadResourceFail {
}
@TypeDefaultAction(state)
export class ChangeQueryParameters extends ResourceAction.ChangeQueryParameters {
}
@TypeDefaultAction(state)
export class GetAll extends ResourceAction.GetAll {
}
@TypeDefaultAction(state)
export class GetAllSuccess extends ResourceAction.GetAllSuccess<Order> {
}
@TypeDefaultAction(state)
export class GetAllFail extends ResourceAction.GetAllFail<Order> {
}
@TypeDefaultAction(state)
export class GetByListId extends ResourceAction.GetByListId {
}
@TypeDefaultAction(state)
export class GetByListIdSuccess extends ResourceAction.GetByListIdSuccess {
}
@TypeDefaultAction(state)
export class GetByListIdFail extends ResourceAction.GetByListIdFail {
}
@TypeDefaultAction(state)
export class GetById extends ResourceAction.GetById {
}
@TypeDefaultAction(state)
export class GetByIdSuccess extends ResourceAction.GetByIdSuccess<Order> {
}
@TypeDefaultAction(state)
export class GetByIdFail extends ResourceAction.GetByIdFail<Order> {
}
@TypeDefaultAction(state)
export class Create extends ResourceAction.Create<Order> {
}
@TypeDefaultAction(state)
export class CreateSuccess extends ResourceAction.CreateSuccess<Order> {
}
@TypeDefaultAction(state)
export class CreateFail extends ResourceAction.CreateFail<Order> {
}
@TypeDefaultAction(state)
export class Update extends ResourceAction.Update<Order> {
}
@TypeDefaultAction(state)
export class UpdateSuccess extends ResourceAction.UpdateSuccess<Order> {
}
@TypeDefaultAction(state)
export class UpdateFail extends ResourceAction.UpdateFail<Order> {
}
@TypeDefaultAction(state)
export class Delete extends ResourceAction.Delete {
}
@TypeDefaultAction(state)
export class DeleteSuccess extends ResourceAction.DeleteSuccess {
}
@TypeDefaultAction(state)
export class DeleteFail extends ResourceAction.DeleteFail {
}
@TypeDefaultAction(state)
export class DeleteList extends ResourceAction.DeleteList {
}
@TypeDefaultAction(state)
export class DeleteListSuccess extends ResourceAction.DeleteListSuccess {
}
@TypeDefaultAction(state)
export class DeleteListFail extends ResourceAction.DeleteListFail {
}
@TypeDefaultAction(state)
export class AddInList extends ResourceAction.AddInList<Order> {
}
@TypeDefaultAction(state)
export class AddInListById extends ResourceAction.AddInListById {
}
@TypeDefaultAction(state)
export class AddInListByIdSuccess extends ResourceAction.AddInListByIdSuccess<Order> {
}
@TypeDefaultAction(state)
export class AddInListByIdFail extends ResourceAction.AddInListByIdFail<Order> {
}
@TypeDefaultAction(state)
export class RemoveInListById extends ResourceAction.RemoveInListById {
}
@TypeDefaultAction(state)
export class RemoveInListByListId extends ResourceAction.RemoveInListByListId {
}
@TypeDefaultAction(state)
export class LoadNextChunkList extends ResourceAction.LoadNextChunkList {
}
@TypeDefaultAction(state)
export class LoadNextChunkListSuccess extends ResourceAction.LoadNextChunkListSuccess<Order> {
}
@TypeDefaultAction(state)
export class LoadNextChunkListFail extends ResourceAction.LoadNextChunkListFail {
}
@TypeDefaultAction(state)
export class Clean extends ResourceAction.Clean {
}
export class GoToOrder {
static readonly type: string = `[${state}] Go To Order`;
constructor(public orderId: string) {
}
}
}
export const preservationPlanningOrderNamespace: ResourceNameSpace = PreservationPlanningOrderAction;
/*-
* %%----------------------------------------------------------------------------------------------
* DLCM Technology - DLCM Portal - preservation-planning-order.state.ts
* SPDX-License-Identifier: GPL-2.0-or-later
* %----------------------------------------------------------------------------------------------%
* Copyright (C) 2017 - 2022 University of Geneva
* %----------------------------------------------------------------------------------------------%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* ----------------------------------------------------------------------------------------------%%
*/
import {Injectable} from "@angular/core";
import {environment} from "@environments/environment";
import {Order} from "@models";
import {Navigate} from "@ngxs/router-plugin";
import {
Action,
Actions,
State,
StateContext,
Store,
} from "@ngxs/store";
import {
PreservationPlanningOrderAction,
preservationPlanningOrderNamespace,
} from "@preservation-planning/stores/order/preservation-planning-order.action";
import {
PreservationPlanningOrderStatusHistoryState,
PreservationPlanningOrderStatusHistoryStateModel,
} from "@preservation-planning/stores/order/status-history/preservation-planning-order-status-history.state";
import {ApiEnum} from "@shared/enums/api.enum";
import {
AppRoutesEnum,
OrderRoutesEnum,
RoutesEnum,
urlSeparator,
} from "@shared/enums/routes.enum";
import {StateEnum} from "@shared/enums/state.enum";
import {defaultStatusHistoryInitValue} from "@shared/stores/status-history/status-history.state";
import {
ApiService,
defaultResourceStateInitValue,
NotificationService,
OrderEnum,
QueryParameters,
ResourceState,
ResourceStateModel,
Sort,
} from "solidify-frontend";
export interface PreservationPlanningOrderStateModel extends ResourceStateModel<Order> {
[StateEnum.preservationPlanning_order_statusHistory]: PreservationPlanningOrderStatusHistoryStateModel;
}
@Injectable()
@State<PreservationPlanningOrderStateModel>({
name: StateEnum.preservationPlanning_order,
defaults: {
...defaultResourceStateInitValue(),
[StateEnum.preservationPlanning_order_statusHistory]: {...defaultStatusHistoryInitValue()},
queryParameters: new QueryParameters(environment.defaultEnumValuePageSizeOption, {field: "name", order: OrderEnum.ascending} as Sort),
},
children: [
PreservationPlanningOrderStatusHistoryState,
],
})
export class PreservationPlanningOrderState extends ResourceState<PreservationPlanningOrderStateModel, Order> {
constructor(protected apiService: ApiService,
protected store: Store,
protected notificationService: NotificationService,
protected actions$: Actions) {
super(apiService, store, notificationService, actions$, {
nameSpace: preservationPlanningOrderNamespace,
});
}
protected get _urlResource(): string {
return ApiEnum.accessOrders;
}
@Action(PreservationPlanningOrderAction.GoToOrder)
goToOrder(ctx: StateContext<PreservationPlanningOrderStateModel>, action: PreservationPlanningOrderAction.GoToOrder): void {
ctx.dispatch(new Navigate([RoutesEnum.orderAllOrder + urlSeparator + OrderRoutesEnum.allOrderDetail + AppRoutesEnum.separator, action.orderId]));
}
}
/*-
* %%----------------------------------------------------------------------------------------------
* DLCM Technology - DLCM Portal - preservation-planning-order-status-history.action.ts
* SPDX-License-Identifier: GPL-2.0-or-later
* %----------------------------------------------------------------------------------------------%
* Copyright (C) 2017 - 2022 University of Geneva
* %----------------------------------------------------------------------------------------------%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* ----------------------------------------------------------------------------------------------%%
*/
import {StateEnum} from "@shared/enums/state.enum";
import {StatusHistoryNamespace} from "@shared/stores/status-history/status-history-namespace.model";
import {StatusHistoryAction} from "@shared/stores/status-history/status-history.action";
import {TypeDefaultAction} from "solidify-frontend";
const state = StateEnum.preservationPlanning_order_statusHistory;
export namespace PreservationPlanningOrderStatusHistoryAction {
@TypeDefaultAction(state)
export class History extends StatusHistoryAction.History {
}