Skip to content

Commit

Permalink
Copy Seq cross lpars
Browse files Browse the repository at this point in the history
Signed-off-by: likhithanimma1 <[email protected]>
  • Loading branch information
likhithanimma1 committed Nov 27, 2024
1 parent 95700e2 commit d666151
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 9 deletions.
12 changes: 12 additions & 0 deletions packages/zowe-explorer-api/src/extend/MainframeInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,18 @@ export namespace MainframeInteraction {
* @returns {Promise<zosfiles.IZosFilesResponse>}
*/
copyDataSet?(fromDataSetName: string, toDataSetName: string, enq?: string, replace?: boolean): Promise<zosfiles.IZosFilesResponse>;

/**
* Copies a dataSet to cross Lpar
*
*/
copyDataSetCrossLpar(
toDataSetName: string,
toMemberName: string,
options: zosfiles.ICrossLparCopyDatasetOptions,
sourceOptions: zosfiles.IGetOptions,
targetProfile: imperative.IProfileLoaded
): Promise<zosfiles.IZosFilesResponse>;
}

/**
Expand Down
28 changes: 21 additions & 7 deletions packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,26 @@ export namespace ZoweExplorerZosmf {
}

public getSessionFromCommandArgument(cmdArgs: imperative.ICommandArguments): imperative.Session {
console.log("What are the command arguments that came here", cmdArgs);
const sessCfg = zosmf.ZosmfSession.createSessCfgFromArgs(cmdArgs);
imperative.ConnectionPropsForSessCfg.resolveSessCfgProps(sessCfg, cmdArgs);
const sessionToUse = new imperative.Session(sessCfg);
return sessionToUse;
}

public getSession(profile?: imperative.IProfileLoaded): imperative.Session {
if (!this.session) {
try {
this.session = this._getSession(profile || this.profile);
} catch (error) {
// todo: initialize and use logging
imperative.Logger.getAppLogger().error(error as string);
}
try {
console.log("in get session", profile);
this.session = this._getSession(profile || this.profile);
} catch (error) {
// todo: initialize and use logging
imperative.Logger.getAppLogger().error(error as string);
}
return this.session;
}

private _getSession(serviceProfile: imperative.IProfileLoaded): imperative.Session {
console.log("Service Profile", serviceProfile);
let cmdArgs: imperative.ICommandArguments = {
$0: "zowe",
_: [""],
Expand Down Expand Up @@ -376,6 +377,19 @@ export namespace ZoweExplorerZosmf {
{ "from-dataset": { dsn: fromDataSetName }, enq, replace, responseTimeout: this.profile?.profile?.responseTimeout }
);
}
public copyDataSetCrossLpar(
toDataSetName: string,
toMemberName: string,
options: zosfiles.ICrossLparCopyDatasetOptions,
sourceOptions: zosfiles.IGetOptions,
targetProfile: imperative.IProfileLoaded
): Promise<zosfiles.IZosFilesResponse> {
const sourceSession = this.getSession();
console.log("This is target profile", targetProfile);
const targetSession = this.getSession(targetProfile);
console.log("This is sourceSession,targetSession", sourceSession, targetSession);
return zosfiles.Copy.dataSetCrossLPAR(sourceSession, { dsn: toDataSetName, member: toMemberName }, options, sourceOptions, targetSession);
}
}

/**
Expand Down
10 changes: 10 additions & 0 deletions packages/zowe-explorer-ftp-extension/src/ZoweExplorerFtpMvsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,16 @@ export class FtpMvsApi extends AbstractFtpApi implements MainframeInteraction.IM
throw new ZoweFtpExtensionError("Copy dataset is not supported in ftp extension.");
}

public copyDataSetCrossLpar(
toDataSetName: string,
toMemberName: string,
options: zosfiles.ICrossLparCopyDatasetOptions,
sourceOptions: zosfiles.IGetOptions,
targetProfile: imperative.IProfileLoaded
): Promise<zosfiles.IZosFilesResponse> {
throw new ZoweFtpExtensionError("Copy dataset cross lpar is not supported in ftp extension.");
}

public async renameDataSet(currentDataSetName: string, newDataSetName: string): Promise<zosfiles.IZosFilesResponse> {
const result = this.getDefaultResponse();
let connection;
Expand Down
1 change: 1 addition & 0 deletions packages/zowe-explorer/l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@
]
},
"Cannot perform the copy operation as the data sets selected have different types": "Cannot perform the copy operation as the data sets selected have different types",
"Copying data sets cross lpars is not yet supported for this profile.": "Copying data sets cross lpars is not yet supported for this profile.",
"Migration of data set {0} requested./Data Set name": {
"message": "Migration of data set {0} requested.",
"comment": [
Expand Down
4 changes: 4 additions & 0 deletions packages/zowe-explorer/l10n/poeditor.json
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@
"zowe.history.deprecationMsg": {
"Changes made here will not be reflected in Zowe Explorer, use right-click Edit History option to access information from local storage.": ""
},
"copyDataSetsCrossLpar": {
"Copy Cross Lpar": ""
},
"Enter command here...": "",
"Page Size:": "",
"Page": "",
Expand Down Expand Up @@ -786,6 +789,7 @@
"Fetching data set...": "",
"Error encountered when refreshing data set view. {0}": "",
"Cannot perform the copy operation as the data sets selected have different types": "",
"Copying data sets cross lpars is not yet supported for this profile.": "",
"Migration of data set {0} requested.": "",
"Recall of data set {0} requested.": "",
"Unable to gather more information": "",
Expand Down
22 changes: 21 additions & 1 deletion packages/zowe-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@
"command": "zowe.manualPoll",
"key": "f5",
"when": "editorIsOpen && resourceScheme == zosspool"
},
{
"command": "zowe.ds.copyDataSetsCrossLpar",
"key": "ctrl+c",
"mac": "cmd+c",
"when": "focusedView == zowe.ds.explorer"
}
],
"commands": [
Expand Down Expand Up @@ -276,6 +282,11 @@
"title": "%copyFile%",
"category": "Zowe Explorer"
},
{
"command": "zowe.ds.copyDataSetsCrossLpar",
"title": "%copyDataSetsCrossLpar%",
"category": "Zowe Explorer"
},
{
"command": "zowe.ds.hMigrateDataSet",
"title": "%hMigrateDataSet%",
Expand Down Expand Up @@ -1004,10 +1015,15 @@
"command": "zowe.ds.copyDataSets",
"group": "001_zowe_dsCreate@6"
},
{
"when": "view == zowe.ds.explorer && viewItem =~ /^(?!.*profile=zftp.*)(ds|member|pds).*/",
"command": "zowe.ds.copyDataSetsCrossLpar",
"group": "001_zowe_dsCreate@7"
},
{
"when": "view == zowe.ds.explorer && viewItem =~ /^(?!.*profile=zftp.*)(session|pds).*/ && !listMultiSelection",
"command": "zowe.ds.pasteDataSets",
"group": "001_zowe_dsCreate@7"
"group": "001_zowe_dsCreate@8"
},
{
"when": "view == zowe.ds.explorer && viewItem =~ /^(?!.*_fav.*)session.*/ && !listMultiSelection",
Expand Down Expand Up @@ -1336,6 +1352,10 @@
"command": "zowe.ds.copyDataSets",
"when": "never"
},
{
"command": "zowe.ds.copyDataSetsCrossLpar",
"when": "never"
},
{
"command": "zowe.ds.showAttributes",
"when": "never"
Expand Down
3 changes: 2 additions & 1 deletion packages/zowe-explorer/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,6 @@
"compareWithSelectedReadOnly": "Compare with Selected (Read-Only)",
"openWithEncoding": "Open with Encoding",
"copyExternalLink": "Copy External Link",
"zowe.history.deprecationMsg": "Changes made here will not be reflected in Zowe Explorer, use right-click Edit History option to access information from local storage."
"zowe.history.deprecationMsg": "Changes made here will not be reflected in Zowe Explorer, use right-click Edit History option to access information from local storage.",
"copyDataSetsCrossLpar": "Copy Cross Lpar"
}
93 changes: 93 additions & 0 deletions packages/zowe-explorer/src/trees/dataset/DatasetActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,77 @@ export class DatasetActions {
}
}

/**
* Copy data sets cross lpars
*
* @export
* @param {ZoweDatasetNode} node Node to copy,
* @param {ZoweDatasetNode[]} nodeList - Multiple selected Nodes to copy
* @param datasetProvider
*/
public static async copyDataSetsCrossLpar(node, nodeList: ZoweDatasetNode[], datasetProvider: Types.IZoweDatasetTreeType): Promise<void> {
ZoweLogger.trace("dataset.actions.copyDataSetsCrossLpar called.");
let selectedNodes: ZoweDatasetNode[] = [];
if (!(node || nodeList)) {
selectedNodes = datasetProvider.getTreeView().selection as ZoweDatasetNode[];
} else {
selectedNodes = SharedUtils.getSelectedNodeList(node, nodeList) as ZoweDatasetNode[];
}
const unique = [...new Set(selectedNodes.map((item) => item.contextValue))];
if (unique.length > 1) {
Gui.showMessage(vscode.l10n.t("Cannot perform the copy operation as the data sets selected have different types"));
return;
}
const inputBoxOptions: vscode.InputBoxOptions = {
placeHolder: "Enter the name of cross lpar profile",
};
const crossProfileName = await Gui.showInputBox(inputBoxOptions);
if (crossProfileName != null) {
const allProfiles = Profiles.getInstance().allProfiles;
const crossProfile = allProfiles.find((profile) => profile.name === crossProfileName);
if (crossProfile === undefined) {
Gui.errorMessage("There is no such profile that you wanna copy to please create one such to copy");
return;
}
const mvsApi = ZoweExplorerApiRegister.getMvsApi(node.getProfile());
if (mvsApi?.copyDataSetCrossLpar == null) {
await Gui.errorMessage(vscode.l10n.t("Copying data sets cross lpars is not yet supported for this profile."));
} else {
//Actually it should be from here the loop for multiselect
await Gui.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: DatasetActions.localizedStrings.copyingFiles,
},
async (progress) => {
return new Promise<void>((resolve) => {
for (const [index, currNode] of selectedNodes.entries()) {
Gui.reportProgress(progress, selectedNodes.length, index, "Copying Files");
const options: zosfiles.ICrossLparCopyDatasetOptions = {
"from-dataset": { dsn: currNode.label as string },
responseTimeout: currNode.getProfile()?.profile?.responseTimeout,
};
const sourceOptions: zosfiles.IGetOptions = {
volume: undefined,
};
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
mvsApi.copyDataSetCrossLpar(currNode.getLabel() as string, null, options, sourceOptions, crossProfile);
} catch (err) {
ZoweLogger.error(err);
}
}
resolve();
});
}
);
}
} else {
await Gui.showMessage(vscode.l10n.t("No selection made. Operation cancelled."));
return;
}
}

/**
* Migrate data sets
*
Expand Down Expand Up @@ -1606,6 +1677,28 @@ export class DatasetActions {
});
}

// public static async copySequentialDatasetscrossLpar(nodes: ZoweDatasetNode[]): Promise<void> {
// await DatasetActions.copyProcessor(nodes, "ps", async (node: ZoweDatasetNode, dsname: string, replace: Definitions.ShouldReplace) => {
// const lbl = node.getLabel().toString();
// const mvsApi = ZoweExplorerApiRegister.getMvsApi(node.getProfile());
// if (mvsApi?.copyDataSetCrossLpar == null) {
// await Gui.errorMessage(vscode.l10n.t("Copying data sets cross lpars is not supported."));
// } else {
// await Gui.withProgress(
// {
// location: vscode.ProgressLocation.Window,
// title: DatasetActions.localizedStrings.copyingFiles,
// },
// () => {
// // return mvsApi.copyDataSet(lbl, dsname, null, replace === "replace");
// // eslint-disable-next-line @typescript-eslint/no-unsafe-return
// return mvsApi.copyDataSetCrossLpar(lbl, null, options, sourceOptions, crossProfile[0]);
// }
// );
// }
// });
// }

/**
* copies given partitioned dataset nodes
*
Expand Down
5 changes: 5 additions & 0 deletions packages/zowe-explorer/src/trees/dataset/DatasetInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ export class DatasetInit {
DatasetActions.copyDataSets(node, nodeList, datasetProvider)
)
);
context.subscriptions.push(
vscode.commands.registerCommand("zowe.ds.copyDataSetsCrossLpar", async (node, nodeList) =>
DatasetActions.copyDataSetsCrossLpar(node, nodeList, datasetProvider)
)
);
context.subscriptions.push(
vscode.commands.registerCommand("zowe.ds.pasteDataSets", async (node: ZoweDatasetNode) => {
if (!node) {
Expand Down

0 comments on commit d666151

Please sign in to comment.