From 7bccb46fd37f91ace4d73afddf9fd998b7686dca Mon Sep 17 00:00:00 2001 From: Magzhan Abdibayev Date: Tue, 16 Apr 2024 17:36:43 +0200 Subject: [PATCH] [DV-5681] Remove analysis push and pull --- src/commands/analysis.command.ts | 18 ----- src/content-cli-pull.ts | 17 ---- src/content-cli-push.ts | 16 ---- .../factory/analysis-manager.factory.ts | 25 ------ src/content/manager/analysis.manager.ts | 81 ------------------- 5 files changed, 157 deletions(-) delete mode 100644 src/commands/analysis.command.ts delete mode 100644 src/content/factory/analysis-manager.factory.ts delete mode 100644 src/content/manager/analysis.manager.ts diff --git a/src/commands/analysis.command.ts b/src/commands/analysis.command.ts deleted file mode 100644 index 35529bc..0000000 --- a/src/commands/analysis.command.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { ContentService } from "../services/content.service"; -import { AnalysisManagerFactory } from "../content/factory/analysis-manager.factory"; - -export class AnalysisCommand { - private contentService = new ContentService(); - private analysisManagerFactory = new AnalysisManagerFactory(); - - public async pullAnalysis(profile: string, id: string, packageManager: boolean): Promise { - await this.contentService.pull( - profile, - this.analysisManagerFactory.createManager(id, null, null, packageManager) - ); - } - - public async pushAnalysis(profile: string, workspaceId: string, filename: string): Promise { - await this.contentService.push(profile, this.analysisManagerFactory.createManager(null, workspaceId, filename)); - } -} diff --git a/src/content-cli-pull.ts b/src/content-cli-pull.ts index 6c24289..13b6556 100644 --- a/src/content-cli-pull.ts +++ b/src/content-cli-pull.ts @@ -1,4 +1,3 @@ -import { AnalysisCommand } from "./commands/analysis.command"; import { SkillCommand } from "./commands/skill.command"; import { ObjectiveCommand } from "./commands/objective.command"; import { DataPoolCommand } from "./commands/data-pool.command"; @@ -10,21 +9,6 @@ import commander = require("commander"); type CommanderStatic = commander.CommanderStatic; class Pull { - public static analysis(program: CommanderStatic): CommanderStatic { - program - .command("analysis") - .description("Command to pull an analysis") - .option("-p, --profile ", "Profile which you want to use to pull the analysis") - .requiredOption("--id ", "Id of the analysis you want to pull") - .option("--asset", "Pull workflow as an asset") - .action(async cmd => { - await new AnalysisCommand().pullAnalysis(cmd.profile, cmd.id, !!cmd.asset); - process.exit(); - }); - - return program; - } - public static analysisBookmarks(program: CommanderStatic): CommanderStatic { program .command("bookmarks") @@ -115,7 +99,6 @@ class Pull { } } -Pull.analysis(commander); Pull.analysisBookmarks(commander); Pull.skill(commander); Pull.objective(commander); diff --git a/src/content-cli-push.ts b/src/content-cli-push.ts index 80a0b6c..a6b3ef5 100644 --- a/src/content-cli-push.ts +++ b/src/content-cli-push.ts @@ -2,7 +2,6 @@ import * as commander from "commander"; import * as fs from "fs"; import * as path from "path"; -import { AnalysisCommand } from "./commands/analysis.command"; import { SkillCommand } from "./commands/skill.command"; import { WidgetCommand } from "./commands/widget.command"; import { DataPoolCommand } from "./commands/data-pool.command"; @@ -17,20 +16,6 @@ import { GracefulError, logger } from "./util/logger"; type CommanderStatic = commander.CommanderStatic; class Push { - public static analysis(program: CommanderStatic): CommanderStatic { - program - .command("analysis") - .description("Command to push an analysis to a workspace") - .option("-p, --profile ", "Profile which you want to use to push the analysis") - .requiredOption("--workspaceId ", "Id of the workspace to which you want to push the analysis") - .requiredOption("-f, --file ", "The file you want to push") - .action(async cmd => { - await new AnalysisCommand().pushAnalysis(cmd.profile, cmd.workspaceId, cmd.file); - process.exit(); - }); - - return program; - } public static analysisBookmarks(program: CommanderStatic): CommanderStatic { program @@ -233,7 +218,6 @@ class Push { } } -Push.analysis(commander); Push.analysisBookmarks(commander); Push.ctp(commander); Push.skill(commander); diff --git a/src/content/factory/analysis-manager.factory.ts b/src/content/factory/analysis-manager.factory.ts deleted file mode 100644 index 2a14f36..0000000 --- a/src/content/factory/analysis-manager.factory.ts +++ /dev/null @@ -1,25 +0,0 @@ -import * as fs from "fs"; -import * as path from "path"; -import { FatalError, logger } from "../../util/logger"; -import { AnalysisManager } from "../manager/analysis.manager"; - -export class AnalysisManagerFactory { - public createManager(id: string, processId: string, filename: string, packageManager?: boolean): AnalysisManager { - const analysisManager = new AnalysisManager(); - analysisManager.id = id; - analysisManager.processId = processId; - if (filename !== null) { - analysisManager.fileName = this.resolvePackageFilePath(filename); - } - analysisManager.packageManager = packageManager; - - return analysisManager; - } - - private resolvePackageFilePath(fileName: string): string { - if (!fs.existsSync(path.resolve(process.cwd(), fileName))) { - logger.error(new FatalError("The provided file does not exist")); - } - return path.resolve(process.cwd(), fileName); - } -} diff --git a/src/content/manager/analysis.manager.ts b/src/content/manager/analysis.manager.ts deleted file mode 100644 index 3869415..0000000 --- a/src/content/manager/analysis.manager.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { BaseManager } from "./base.manager"; -import { ManagerConfig } from "../../interfaces/manager-config.interface"; -import { AssetManager } from "./asset.manager"; -import * as fs from "fs"; -import {stringify} from "../../util/yaml"; -import * as FormData from "form-data"; - -export class AnalysisManager extends BaseManager { - private static BASE_URL = "/process-mining/api/analysis/"; - private static PULL_URL = `${AnalysisManager.BASE_URL}/export?id=`; - private static ANALYSIS_FILE_PREFIX = "analysis_"; - - private _id: string; - private _processId: string; - private _fileName: string; - private _packageManager: boolean; - - public get fileName(): string { - return this._fileName; - } - - public set fileName(value: string) { - this._fileName = value; - } - - public get id(): string { - return this._id; - } - - public set id(value: string) { - this._id = value; - } - - public get processId(): string { - return this._processId; - } - - public set processId(value: string) { - this._processId = value; - } - - public get packageManager(): boolean { - return this._packageManager; - } - - public set packageManager(value: boolean) { - this._packageManager = value; - } - - public getConfig(): ManagerConfig { - const pullUrl = this.packageManager - ? `${AnalysisManager.BASE_URL}${this.id}/package/export` - : `${AnalysisManager.PULL_URL}${this.id}`; - return { - pushUrl: this.profile.team.replace( - /\/?$/, - `${AnalysisManager.BASE_URL}/import?processId=${this.processId}` - ), - pullUrl: this.profile.team.replace(/\/?$/, pullUrl), - exportFileName: `${ - this.packageManager ? AssetManager.ASSET_FILE_PREFIX : AnalysisManager.ANALYSIS_FILE_PREFIX - }${this.id}${this.packageManager ? ".yaml" : ".json"}`, - onPushSuccessMessage: (data: any): string => { - return "Analysis was pushed successfully. New ID: " + data.id; - }, - }; - } - - public getBody(): any { - const formData = new FormData(); - formData.append("file", fs.createReadStream(this.fileName)); - return formData; - } - - protected getSerializedFileContent(data: any): string { - if (this.packageManager) { - return stringify(data); - } - return JSON.stringify(data); - } -}