use of com.ibm.as400.access.AS400Message in project IBMiProgTool by vzupka.
the class CreateAndDeleteInIBMi method createSourceMember.
/**
* Create Source Member.
*/
protected void createSourceMember() {
sourceFilesAndTypes = new TreeMap<>();
// Table of Standard Source Physical File Names (keys) and default Source Types (values)
sourceFilesAndTypes.put("QCLSRC", "CLLE");
sourceFilesAndTypes.put("QDDSSRC", "DSPF");
sourceFilesAndTypes.put("QRPGLESRC", "RPGLE");
sourceFilesAndTypes.put("QRPGSRC", "RPG");
sourceFilesAndTypes.put("QCBLLESRC", "CBLLE");
sourceFilesAndTypes.put("QCBLSRC", "CBL");
sourceFilesAndTypes.put("QCMDSRC", "CMD");
sourceFilesAndTypes.put("QCSRC", "C");
sourceFilesAndTypes.put("QTBLSRC", "TBL");
// Get library name from the IFS path string
extractNamesFromIfsPath(mainWindow.rightPathString);
// "true" stands for changing result to upper case
String memberName = new GetTextFromDialog("CREATE NEW SOURCE MEMBER").getTextFromDialog("Library", "Source member name", libraryName, "", true, currentX, currentY);
if (memberName == null) {
return;
}
if (memberName.isEmpty()) {
memberName = "MEMBER.MBR";
}
// Set source type according to the source physical file name
String sourceType = getDefaultSourceType(fileName);
// Build command ADDPFM to create a member in the source physical file
String commandText = "ADDPFM FILE(" + libraryName + "/" + fileName + ") MBR(" + memberName + ")" + " TEXT('Member " + memberName + "')" + " SRCTYPE(" + sourceType + ")";
// Enable calling CL commands
CommandCall command = new CommandCall(remoteServer);
try {
// Run the command
command.run(commandText);
// Get messages from the command if any
AS400Message[] as400MessageList = command.getMessageList();
String msgType;
// Send all messages from the command. After ESCAPE message - return.
for (AS400Message as400Message : as400MessageList) {
if (as400Message.getType() == AS400Message.ESCAPE) {
msgType = "Error";
row = msgType + ": message from the ADDPFM command is " + as400Message.getID() + " " + as400Message.getText();
mainWindow.msgVector.add(row);
mainWindow.showMessages();
return;
} else {
msgType = "Info";
row = msgType + ": message from the ADDPFM command is " + as400Message.getID() + " " + as400Message.getText();
mainWindow.msgVector.add(row);
mainWindow.showMessages();
}
}
} catch (Exception exc) {
exc.printStackTrace();
row = "Error: Creating source member " + ifsFile.toString() + " - " + exc.toString() + ".";
mainWindow.msgVector.add(row);
mainWindow.showMessages();
return;
}
}
use of com.ibm.as400.access.AS400Message in project IBMiProgTool by vzupka.
the class CreateAndDeleteInIBMi method copyLibrary.
/**
* Copy library
*/
protected void copyLibrary() {
extractNamesFromIfsPath(mainWindow.rightPathString);
// "false" stands for not changing result to upper case
String newLibraryName = new GetTextFromDialog("COPY LIBRARY").getTextFromDialog("Library name", "New library name", libraryName, "", true, currentX, currentY);
// Enable calling CL commands
CommandCall command = new CommandCall(remoteServer);
// Build command CPYLIB to copy the library
String commandText = "CPYLIB FROMLIB(" + libraryName + ") TOLIB(" + newLibraryName + ") CRTLIB(*YES) ";
try {
// Run the command
command.run(commandText);
// Get messages from the command if any
AS400Message[] as400MessageList = command.getMessageList();
String msgType;
// Send all messages from the command. After ESCAPE message - return.
for (AS400Message as400Message : as400MessageList) {
if (as400Message.getType() == AS400Message.ESCAPE) {
msgType = "Error";
row = msgType + ": message from the CPYLIB command is " + as400Message.getID() + " " + as400Message.getText();
mainWindow.msgVector.add(row);
mainWindow.showMessages();
return;
} else {
msgType = "Info";
row = msgType + ": message from the CPYLIB command is " + as400Message.getID() + " " + as400Message.getText();
mainWindow.msgVector.add(row);
mainWindow.showMessages();
}
}
} catch (Exception exc) {
exc.printStackTrace();
row = "Error: Copying library " + libraryName + " - " + exc.toString() + ".";
mainWindow.msgVector.add(row);
mainWindow.showMessages();
return;
}
row = "Comp: Library " + libraryName + " was copied to " + newLibraryName + ".";
mainWindow.msgVector.add(row);
// PARENT NODE of deleted node will be reloaded and the deleted node will disappear from the tree.
// Get parent path string
mainWindow.rightPathString = mainWindow.rightPathString.substring(0, mainWindow.rightPathString.lastIndexOf("/"));
// Get parent node
mainWindow.rightNode = (DefaultMutableTreeNode) mainWindow.rightNode.getParent();
mainWindow.showMessages();
}
use of com.ibm.as400.access.AS400Message in project IBMiProgTool by vzupka.
the class CreateAndDeleteInIBMi method createIfsDirectory.
/**
* Create IFS directory.
*/
protected void createIfsDirectory() {
// Enable calling CL commands
CommandCall cmdCall = new CommandCall(remoteServer);
// "false" stands for not changing result to upper case
String directoryName = new GetTextFromDialog("CREATE NEW DIRECTORY").getTextFromDialog("Parent directory", "New directory name", mainWindow.rightPathString + "/", "", false, currentX, currentY);
// User canceled creating the directory
if (directoryName == null) {
return;
}
if (directoryName.isEmpty()) {
directoryName = "New directory";
}
try {
// Get path to the newly created directory by adding its name to the parent directory path
IFSFile ifsFile = new IFSFile(remoteServer, mainWindow.rightPathString + "/" + directoryName);
// Create new directory
ifsFile.mkdir();
// String for command CHGATR to set CCSID attribute of the new directory
String command_CHGATR = "CHGATR OBJ('" + mainWindow.rightPathString + "/" + directoryName + "') ATR(*CCSID) VALUE(" + ibmCcsid + ") SUBTREE(*ALL)";
System.out.println(command_CHGATR);
// Perform the command
cmdCall.run(command_CHGATR);
// Get messages from the command if any
AS400Message[] as400MessageList = cmdCall.getMessageList();
// Send all messages from the command. After ESCAPE message - return.
for (AS400Message as400Message : as400MessageList) {
if (as400Message.getType() == AS400Message.ESCAPE) {
row = "Error: Change CCSID attribute with command CHGATR - " + as400Message.getID() + " " + as400Message.getText();
mainWindow.msgVector.add(row);
mainWindow.showMessages();
} else {
row = "Info: Change CCSID attribute with command CHGATR - " + as400Message.getID() + " " + as400Message.getText();
mainWindow.msgVector.add(row);
mainWindow.showMessages();
}
}
row = "Comp: IFS directory " + ifsFile.toString() + " created in directory " + mainWindow.rightPathString + " - CCSID " + ibmCcsid + ".";
mainWindow.msgVector.add(row);
mainWindow.showMessages();
} catch (Exception exc) {
exc.printStackTrace();
row = "Error:" + exc.toString();
mainWindow.msgVector.add(row);
mainWindow.showMessages();
}
}
use of com.ibm.as400.access.AS400Message in project IBMiProgTool by vzupka.
the class Compile method performCommand.
/**
* @param compileCommandText
*/
protected void performCommand(String compileCommandText) {
if (compileCommandText == null) {
return;
}
// Create object for calling CL commands
CommandCall cmdCall = new CommandCall(remoteServer);
try {
// Get current server job
Job currentJob = new Job();
currentJob = cmdCall.getServerJob();
// Set job attributes
currentJob.setLoggingLevel(4);
currentJob.setLoggingCLPrograms("*YES");
currentJob.setLoggingSeverity(0);
currentJob.setLoggingText(Job.LOGGING_TEXT_SECLVL);
// Get library list from the file "UserLibraryList.lib"
String liblParameter = "";
List<String> items = Files.readAllLines(libraryListPath);
if (!items.isEmpty()) {
items.get(0);
String[] userUserLibraryList = items.get(0).split(",");
for (int idx = 1; idx < userUserLibraryList.length; idx++) {
liblParameter += userUserLibraryList[idx].trim() + " ";
}
}
if (liblParameter.isEmpty()) {
liblParameter = "*NONE";
}
// Get current library for the file "CurrentLibrary.lib"
String curlibParameter = "";
List<String> curlib = Files.readAllLines(currentLibraryPath);
if (!curlib.isEmpty()) {
// The only item is the current library name or *CRTDFT
curlibParameter += curlib.get(0);
}
// Build command CHGLIBL
String commandChgLiblText = "CHGLIBL LIBL(" + liblParameter + ") CURLIB(" + curlibParameter + ")";
// Perform the GHGLIBL command
// -------
cmdCall.run(commandChgLiblText);
// Perform the compile command
// -------------------
cmdCall.run(compileCommandText);
// Get messages from the command if any
AS400Message[] messagelist = cmdCall.getMessageList();
String[] strArr = new String[messagelist.length];
// Print all messages
String type = "";
int msgType;
for (int idx = 0; idx < messagelist.length; idx++) {
msgType = messagelist[idx].getType();
switch(msgType) {
case AS400Message.ESCAPE:
{
type = "*ESCAPE";
}
case AS400Message.DIAGNOSTIC:
{
type = "*DIAGNOSTIC";
}
case AS400Message.COMPLETION:
{
type = "*COMPLETION";
}
case AS400Message.NOTIFY:
{
type = "*NOTIFY";
}
case AS400Message.INFORMATIONAL:
{
type = "*INFORMATIONAL";
}
}
strArr[idx] = messagelist[idx].getID() + " " + type + ": " + messagelist[idx].getText();
row = strArr[idx];
msgVector.add(row);
if (!messagelist[idx].getHelp().isEmpty()) {
strArr[idx] = " " + messagelist[idx].getHelp();
row = strArr[idx];
msgVector.add(row);
}
}
reloadMessages();
} catch (Exception exc) {
exc.printStackTrace();
}
}
Aggregations