mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 09:35:36 -05:00
Move project entry classes to separate file (#17629)
* moving ProjectEntry stuff to another file * cleanup
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SystemDatabase } from './project';
|
||||
import { Uri } from 'vscode';
|
||||
import { SystemDatabase } from './projectEntry';
|
||||
|
||||
export interface IDatabaseReferenceSettings {
|
||||
databaseName?: string;
|
||||
|
||||
@@ -12,11 +12,12 @@ import * as os from 'os';
|
||||
import * as templates from '../templates/templates';
|
||||
|
||||
import { Uri, window } from 'vscode';
|
||||
import { IFileProjectEntry, ISqlProject, SqlTargetPlatform } from 'sqldbproj';
|
||||
import { ISqlProject, SqlTargetPlatform } from 'sqldbproj';
|
||||
import { promises as fs } from 'fs';
|
||||
import { DataSource } from './dataSources/dataSources';
|
||||
import { ISystemDatabaseReferenceSettings, IDacpacReferenceSettings, IProjectReferenceSettings } from './IDatabaseReferenceSettings';
|
||||
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
||||
import { DacpacReferenceProjectEntry, EntryType, FileProjectEntry, IDatabaseReferenceProjectEntry, ProjectEntry, SqlCmdVariableProjectEntry, SqlProjectReferenceProjectEntry, SystemDatabase, SystemDatabaseReferenceProjectEntry } from './projectEntry';
|
||||
|
||||
/**
|
||||
* Class representing a Project, and providing functions for operating on it
|
||||
@@ -1293,155 +1294,4 @@ export class Project implements ISqlProject {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an entry in a project file
|
||||
*/
|
||||
export abstract class ProjectEntry {
|
||||
type: EntryType;
|
||||
|
||||
constructor(type: EntryType) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
export class FileProjectEntry extends ProjectEntry implements IFileProjectEntry {
|
||||
/**
|
||||
* Absolute file system URI
|
||||
*/
|
||||
fsUri: Uri;
|
||||
relativePath: string;
|
||||
sqlObjectType: string | undefined;
|
||||
|
||||
constructor(uri: Uri, relativePath: string, entryType: EntryType, sqlObjectType?: string) {
|
||||
super(entryType);
|
||||
this.fsUri = uri;
|
||||
this.relativePath = relativePath;
|
||||
this.sqlObjectType = sqlObjectType;
|
||||
}
|
||||
|
||||
public override toString(): string {
|
||||
return this.fsUri.path;
|
||||
}
|
||||
|
||||
public pathForSqlProj(): string {
|
||||
return utils.convertSlashesForSqlProj(this.fsUri.fsPath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a database reference entry in a project file
|
||||
*/
|
||||
|
||||
export interface IDatabaseReferenceProjectEntry extends FileProjectEntry {
|
||||
databaseName: string;
|
||||
databaseVariableLiteralValue?: string;
|
||||
suppressMissingDependenciesErrors: boolean;
|
||||
}
|
||||
|
||||
export class DacpacReferenceProjectEntry extends FileProjectEntry implements IDatabaseReferenceProjectEntry {
|
||||
databaseVariableLiteralValue?: string;
|
||||
databaseSqlCmdVariable?: string;
|
||||
serverName?: string;
|
||||
serverSqlCmdVariable?: string;
|
||||
suppressMissingDependenciesErrors: boolean;
|
||||
|
||||
constructor(settings: IDacpacReferenceSettings) {
|
||||
super(settings.dacpacFileLocation, '', EntryType.DatabaseReference);
|
||||
this.databaseSqlCmdVariable = settings.databaseVariable;
|
||||
this.databaseVariableLiteralValue = settings.databaseName;
|
||||
this.serverName = settings.serverName;
|
||||
this.serverSqlCmdVariable = settings.serverVariable;
|
||||
this.suppressMissingDependenciesErrors = settings.suppressMissingDependenciesErrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* File name that gets displayed in the project tree
|
||||
*/
|
||||
public get databaseName(): string {
|
||||
return path.parse(utils.getPlatformSafeFileEntryPath(this.fsUri.fsPath)).name;
|
||||
}
|
||||
|
||||
public override pathForSqlProj(): string {
|
||||
// need to remove the leading slash from path for build to work
|
||||
return utils.convertSlashesForSqlProj(this.fsUri.path.substring(1));
|
||||
}
|
||||
}
|
||||
|
||||
export class SystemDatabaseReferenceProjectEntry extends FileProjectEntry implements IDatabaseReferenceProjectEntry {
|
||||
constructor(uri: Uri, public ssdtUri: Uri, public databaseVariableLiteralValue: string | undefined, public suppressMissingDependenciesErrors: boolean) {
|
||||
super(uri, '', EntryType.DatabaseReference);
|
||||
}
|
||||
|
||||
/**
|
||||
* File name that gets displayed in the project tree
|
||||
*/
|
||||
public get databaseName(): string {
|
||||
return path.parse(utils.getPlatformSafeFileEntryPath(this.fsUri.fsPath)).name;
|
||||
}
|
||||
|
||||
public override pathForSqlProj(): string {
|
||||
// need to remove the leading slash for system database path for build to work on Windows
|
||||
return utils.convertSlashesForSqlProj(this.fsUri.path.substring(1));
|
||||
}
|
||||
|
||||
public ssdtPathForSqlProj(): string {
|
||||
// need to remove the leading slash for system database path for build to work on Windows
|
||||
return utils.convertSlashesForSqlProj(this.ssdtUri.path.substring(1));
|
||||
}
|
||||
}
|
||||
|
||||
export class SqlProjectReferenceProjectEntry extends FileProjectEntry implements IDatabaseReferenceProjectEntry {
|
||||
projectName: string;
|
||||
projectGuid: string;
|
||||
databaseVariableLiteralValue?: string;
|
||||
databaseSqlCmdVariable?: string;
|
||||
serverName?: string;
|
||||
serverSqlCmdVariable?: string;
|
||||
suppressMissingDependenciesErrors: boolean;
|
||||
|
||||
constructor(settings: IProjectReferenceSettings) {
|
||||
super(settings.projectRelativePath!, '', EntryType.DatabaseReference);
|
||||
this.projectName = settings.projectName;
|
||||
this.projectGuid = settings.projectGuid;
|
||||
this.databaseSqlCmdVariable = settings.databaseVariable;
|
||||
this.databaseVariableLiteralValue = settings.databaseName;
|
||||
this.serverName = settings.serverName;
|
||||
this.serverSqlCmdVariable = settings.serverVariable;
|
||||
this.suppressMissingDependenciesErrors = settings.suppressMissingDependenciesErrors;
|
||||
}
|
||||
|
||||
public get databaseName(): string {
|
||||
return this.projectName;
|
||||
}
|
||||
|
||||
public override pathForSqlProj(): string {
|
||||
// need to remove the leading slash from path for build to work on Windows
|
||||
return utils.convertSlashesForSqlProj(this.fsUri.path.substring(1));
|
||||
}
|
||||
}
|
||||
|
||||
export class SqlCmdVariableProjectEntry extends ProjectEntry {
|
||||
constructor(public variableName: string, public defaultValue: string) {
|
||||
super(EntryType.SqlCmdVariable);
|
||||
}
|
||||
}
|
||||
|
||||
export enum EntryType {
|
||||
File,
|
||||
Folder,
|
||||
DatabaseReference,
|
||||
SqlCmdVariable
|
||||
}
|
||||
|
||||
export enum DatabaseReferenceLocation {
|
||||
sameDatabase,
|
||||
differentDatabaseSameServer,
|
||||
differentDatabaseDifferentServer
|
||||
}
|
||||
|
||||
export enum SystemDatabase {
|
||||
master,
|
||||
msdb
|
||||
}
|
||||
|
||||
export const reservedProjectFolders = ['Properties', 'Data Sources', 'Database References'];
|
||||
|
||||
161
extensions/sql-database-projects/src/models/projectEntry.ts
Normal file
161
extensions/sql-database-projects/src/models/projectEntry.ts
Normal file
@@ -0,0 +1,161 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as path from 'path';
|
||||
import * as utils from '../common/utils';
|
||||
import { IDacpacReferenceSettings, IProjectReferenceSettings } from './IDatabaseReferenceSettings';
|
||||
import { IFileProjectEntry } from 'sqldbproj';
|
||||
import { Uri } from 'vscode';
|
||||
|
||||
/**
|
||||
* Represents an entry in a project file
|
||||
*/
|
||||
export abstract class ProjectEntry {
|
||||
type: EntryType;
|
||||
|
||||
constructor(type: EntryType) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
export class FileProjectEntry extends ProjectEntry implements IFileProjectEntry {
|
||||
/**
|
||||
* Absolute file system URI
|
||||
*/
|
||||
fsUri: Uri;
|
||||
relativePath: string;
|
||||
sqlObjectType: string | undefined;
|
||||
|
||||
constructor(uri: Uri, relativePath: string, entryType: EntryType, sqlObjectType?: string) {
|
||||
super(entryType);
|
||||
this.fsUri = uri;
|
||||
this.relativePath = relativePath;
|
||||
this.sqlObjectType = sqlObjectType;
|
||||
}
|
||||
|
||||
public override toString(): string {
|
||||
return this.fsUri.path;
|
||||
}
|
||||
|
||||
public pathForSqlProj(): string {
|
||||
return utils.convertSlashesForSqlProj(this.fsUri.fsPath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a database reference entry in a project file
|
||||
*/
|
||||
|
||||
export interface IDatabaseReferenceProjectEntry extends FileProjectEntry {
|
||||
databaseName: string;
|
||||
databaseVariableLiteralValue?: string;
|
||||
suppressMissingDependenciesErrors: boolean;
|
||||
}
|
||||
|
||||
export class DacpacReferenceProjectEntry extends FileProjectEntry implements IDatabaseReferenceProjectEntry {
|
||||
databaseVariableLiteralValue?: string;
|
||||
databaseSqlCmdVariable?: string;
|
||||
serverName?: string;
|
||||
serverSqlCmdVariable?: string;
|
||||
suppressMissingDependenciesErrors: boolean;
|
||||
|
||||
constructor(settings: IDacpacReferenceSettings) {
|
||||
super(settings.dacpacFileLocation, '', EntryType.DatabaseReference);
|
||||
this.databaseSqlCmdVariable = settings.databaseVariable;
|
||||
this.databaseVariableLiteralValue = settings.databaseName;
|
||||
this.serverName = settings.serverName;
|
||||
this.serverSqlCmdVariable = settings.serverVariable;
|
||||
this.suppressMissingDependenciesErrors = settings.suppressMissingDependenciesErrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* File name that gets displayed in the project tree
|
||||
*/
|
||||
public get databaseName(): string {
|
||||
return path.parse(utils.getPlatformSafeFileEntryPath(this.fsUri.fsPath)).name;
|
||||
}
|
||||
|
||||
public override pathForSqlProj(): string {
|
||||
// need to remove the leading slash from path for build to work
|
||||
return utils.convertSlashesForSqlProj(this.fsUri.path.substring(1));
|
||||
}
|
||||
}
|
||||
|
||||
export class SystemDatabaseReferenceProjectEntry extends FileProjectEntry implements IDatabaseReferenceProjectEntry {
|
||||
constructor(uri: Uri, public ssdtUri: Uri, public databaseVariableLiteralValue: string | undefined, public suppressMissingDependenciesErrors: boolean) {
|
||||
super(uri, '', EntryType.DatabaseReference);
|
||||
}
|
||||
|
||||
/**
|
||||
* File name that gets displayed in the project tree
|
||||
*/
|
||||
public get databaseName(): string {
|
||||
return path.parse(utils.getPlatformSafeFileEntryPath(this.fsUri.fsPath)).name;
|
||||
}
|
||||
|
||||
public override pathForSqlProj(): string {
|
||||
// need to remove the leading slash for system database path for build to work on Windows
|
||||
return utils.convertSlashesForSqlProj(this.fsUri.path.substring(1));
|
||||
}
|
||||
|
||||
public ssdtPathForSqlProj(): string {
|
||||
// need to remove the leading slash for system database path for build to work on Windows
|
||||
return utils.convertSlashesForSqlProj(this.ssdtUri.path.substring(1));
|
||||
}
|
||||
}
|
||||
|
||||
export class SqlProjectReferenceProjectEntry extends FileProjectEntry implements IDatabaseReferenceProjectEntry {
|
||||
projectName: string;
|
||||
projectGuid: string;
|
||||
databaseVariableLiteralValue?: string;
|
||||
databaseSqlCmdVariable?: string;
|
||||
serverName?: string;
|
||||
serverSqlCmdVariable?: string;
|
||||
suppressMissingDependenciesErrors: boolean;
|
||||
|
||||
constructor(settings: IProjectReferenceSettings) {
|
||||
super(settings.projectRelativePath!, '', EntryType.DatabaseReference);
|
||||
this.projectName = settings.projectName;
|
||||
this.projectGuid = settings.projectGuid;
|
||||
this.databaseSqlCmdVariable = settings.databaseVariable;
|
||||
this.databaseVariableLiteralValue = settings.databaseName;
|
||||
this.serverName = settings.serverName;
|
||||
this.serverSqlCmdVariable = settings.serverVariable;
|
||||
this.suppressMissingDependenciesErrors = settings.suppressMissingDependenciesErrors;
|
||||
}
|
||||
|
||||
public get databaseName(): string {
|
||||
return this.projectName;
|
||||
}
|
||||
|
||||
public override pathForSqlProj(): string {
|
||||
// need to remove the leading slash from path for build to work on Windows
|
||||
return utils.convertSlashesForSqlProj(this.fsUri.path.substring(1));
|
||||
}
|
||||
}
|
||||
|
||||
export class SqlCmdVariableProjectEntry extends ProjectEntry {
|
||||
constructor(public variableName: string, public defaultValue: string) {
|
||||
super(EntryType.SqlCmdVariable);
|
||||
}
|
||||
}
|
||||
|
||||
export enum EntryType {
|
||||
File,
|
||||
Folder,
|
||||
DatabaseReference,
|
||||
SqlCmdVariable
|
||||
}
|
||||
|
||||
export enum DatabaseReferenceLocation {
|
||||
sameDatabase,
|
||||
differentDatabaseSameServer,
|
||||
differentDatabaseDifferentServer
|
||||
}
|
||||
|
||||
export enum SystemDatabase {
|
||||
master,
|
||||
msdb
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import * as constants from '../../common/constants';
|
||||
import { BaseProjectTreeItem } from './baseTreeItem';
|
||||
import { ProjectRootTreeItem } from './projectTreeItem';
|
||||
import { IconPathHelper } from '../../common/iconHelper';
|
||||
import { IDatabaseReferenceProjectEntry } from '../../models/project';
|
||||
import { IDatabaseReferenceProjectEntry } from '../projectEntry';
|
||||
|
||||
/**
|
||||
* Folder for containing references nodes in the tree
|
||||
|
||||
@@ -8,11 +8,12 @@ import * as path from 'path';
|
||||
import { DataSourcesTreeItem } from './dataSourceTreeItem';
|
||||
import { BaseProjectTreeItem } from './baseTreeItem';
|
||||
import * as fileTree from './fileFolderTreeItem';
|
||||
import { Project, EntryType, FileProjectEntry } from '../project';
|
||||
import { Project } from '../project';
|
||||
import * as utils from '../../common/utils';
|
||||
import { DatabaseReferencesTreeItem } from './databaseReferencesTreeItem';
|
||||
import { DatabaseProjectItemType, RelativeOuterPath, ExternalStreamingJob, sqlprojExtension } from '../../common/constants';
|
||||
import { IconPathHelper } from '../../common/iconHelper';
|
||||
import { EntryType, FileProjectEntry } from '../projectEntry';
|
||||
|
||||
/**
|
||||
* TreeNode root that represents an entire project
|
||||
|
||||
Reference in New Issue
Block a user