Skip to content

Commit

Permalink
basic implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
hoeppner-dataport committed Nov 20, 2023
1 parent 84c267d commit 5308c8b
Showing 1 changed file with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { FileRecordParentType } from '@infra/rabbitmq';
import { CopyElementType, CopyStatus, CopyStatusEnum } from '@modules/copy-helper';
import {
AnyBoardDo,
BoardCompositeVisitorAsync,
Expand All @@ -12,8 +14,6 @@ import {
SubmissionItem,
} from '@shared/domain';
import { LinkElement } from '@shared/domain/domainobject/board/link-element.do';
import { FileRecordParentType } from '@infra/rabbitmq';
import { CopyElementType, CopyStatus, CopyStatusEnum } from '@modules/copy-helper';
import { ObjectId } from 'bson';
import { SchoolSpecificFileCopyService } from './school-specific-file-copy.interface';

Expand Down Expand Up @@ -133,11 +133,38 @@ export class RecursiveCopyVisitor implements BoardCompositeVisitorAsync {
createdAt: new Date(),
updatedAt: new Date(),
});
this.resultMap.set(original.id, {

const result: CopyStatus = {
copyEntity: copy,
type: CopyElementType.LINK_ELEMENT,
status: CopyStatusEnum.SUCCESS,
});
};

if (original.imageUrl) {
const fileCopy = await this.fileCopyService.copyFilesOfParent({
sourceParentId: original.id,
targetParentId: copy.id,
parentType: FileRecordParentType.BoardNode,
});
fileCopy.forEach((copyFileDto) => {
if (copyFileDto.id) {
if (copy.imageUrl.includes(copyFileDto.sourceId)) {
copy.imageUrl = copy.imageUrl.replace(copyFileDto.sourceId, copyFileDto.id);
} else {
copy.imageUrl = '';
}
}
});
const fileCopyStatus = fileCopy.map((copyFileDto) => {
return {
type: CopyElementType.FILE,
status: copyFileDto.id ? CopyStatusEnum.SUCCESS : CopyStatusEnum.FAIL,
title: copyFileDto.name ?? `(old fileid: ${copyFileDto.sourceId})`,
};
});
result.elements = fileCopyStatus;
}
this.resultMap.set(original.id, result);
this.copyMap.set(original.id, copy);

return Promise.resolve();
Expand Down

0 comments on commit 5308c8b

Please sign in to comment.