Skip to content

Commit

Permalink
Make the 'log' object private in ActionBase and BaseTransformMeta apa…
Browse files Browse the repository at this point in the history
  • Loading branch information
nadment committed Oct 2, 2024
1 parent d7d88fb commit f5a2e64
Show file tree
Hide file tree
Showing 212 changed files with 1,034 additions and 1,081 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public class BaseTransform<Meta extends ITransformMeta, Data extends ITransformD

private String transformName;

protected ILogChannel log;
private ILogChannel log;

private String containerObjectId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public boolean processRow() throws HopException {
putRow(getInputRowMeta(), r); // copy row to possible alternate rowset(s).

if (checkFeedback(getLinesRead())) {
if (log.isBasic()) {
if (isBasic()) {
logBasic(BaseMessages.getString(PKG, "Dummy.Log.LineNumber") + getLinesRead());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected boolean openNextFile() {
resultFile.setComment("File was read by an Text File input transform");
addResultFile(resultFile);
}
if (log.isBasic()) {
if (isBasic()) {
logBasic("Opening file: " + data.file.getName().getFriendlyURI());
}

Expand Down Expand Up @@ -214,7 +214,7 @@ protected void prepareToRowProcessing() throws HopException {
data.convertRowMeta = data.outputRowMeta.cloneToType(IValueMeta.TYPE_STRING);

BaseFileInputTransformUtils.handleMissingFiles(
data.files, log, meta.errorHandling.errorIgnored, data.dataErrorLineHandler);
data.files, getLogChannel(), meta.errorHandling.errorIgnored, data.dataErrorLineHandler);

// Count the number of repeat fields...
for (int i = 0; i < meta.inputFields.length; i++) {
Expand Down Expand Up @@ -311,7 +311,7 @@ private IRowMeta[] filesFromPreviousTransform() throws HopException {
}

if (data.files.nrOfFiles() == 0) {
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(PKG, "BaseFileInputTransform.Log.Error.NoFilesSpecified"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public abstract class ActionBase
protected IWorkflowEngine<WorkflowMeta> parentWorkflow;

/** The log channel interface object, used for logging */
protected ILogChannel log;
private ILogChannel log;

/** The log level */
private LogLevel logLevel = DefaultLogLevel.getLogLevel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public Result execute(Result previousResult, int nr) {
} else if (!checkedFiles.isEmpty()) {
oneFileLocked = isOneSpecifiedFileLocked();
} else {
log.logBasic(
logBasic(
"This action didn't execute any locking checks "
+ "as there were no lines to check and no arguments provided.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private void addFilenameToResult(
resultFile.setComment("");
result.getResultFiles().put(resultFile.getFile().toString(), resultFile);

if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(PKG, "ActionCreateFile.FileAddedToResult", targetFilename));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public Result execute(Result previousResult, int nr) {
// Folder already exists: there is no reason to try and create it.
//
result.setResult(true);
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(CONST_FOLDER + realFolderName + "] already exists, not recreating.");
}
}
Expand All @@ -118,7 +118,7 @@ public Result execute(Result previousResult, int nr) {

// No Folder yet, create an empty Folder.
folderObject.createFolder();
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(CONST_FOLDER + realFolderName + "] created!");
}
result.setResult(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public Result execute(Result previousResult, int nr) {
// Let's check the limit time
if ((iMaximumTimeout >= 0) && (now >= (timeStart + iMaximumTimeout))) {
// We have reached the time limit
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionDelay.WaitTimeIsElapsed.Label"));
}
continueLoop = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public Result execute(Result previousResult, int nr) {
} else {
// File already deleted, no reason to try to delete it
result.setResult(true);
if (log.isBasic()) {
if (isBasic()) {
logBasic(
BaseMessages.getString(
PKG, "ActionDeleteFile.File_Already_Deleted", realFilename));
Expand All @@ -134,7 +134,7 @@ public Result execute(Result previousResult, int nr) {
result.setResult(false);
result.setNrErrors(1);
}
if (log.isBasic()) {
if (isBasic()) {
logBasic(BaseMessages.getString(PKG, "ActionDeleteFile.File_Deleted", realFilename));
}
result.setResult(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public Result execute(Result result, int nr) throws HopException {
result.setResult(false);
result.setNrErrors(1);

if (argFromPrevious && log.isDetailed()) {
if (argFromPrevious && isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG,
Expand All @@ -179,7 +179,7 @@ public Result execute(Result result, int nr) throws HopException {
// a root pdi-folder.
// It is much more likely to be a mistake than a desirable action, so we don't delete
// anything
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionDeleteFiles.NoPathProvided"));
}
} else {
Expand Down Expand Up @@ -233,7 +233,7 @@ private Multimap<String, String> populateDataForJobExecution(
String pathToFile = resultRow.getString(0, null);
String fileMask = resultRow.getString(1, null);

if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(PKG, "ActionDeleteFiles.ProcessingRow", pathToFile, fileMask));
}
Expand All @@ -242,7 +242,7 @@ private Multimap<String, String> populateDataForJobExecution(
}
} else if (arguments != null) {
for (int i = 0; i < arguments.length; i++) {
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG, "ActionDeleteFiles.ProcessingArg", arguments[i], filemasks[i]));
Expand All @@ -264,37 +264,37 @@ boolean processFile(String path, String wildcard, IWorkflowEngine<WorkflowMeta>
if (fileFolder.exists()) {
if (fileFolder.getType() == FileType.FOLDER) {

if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionDeleteFiles.ProcessingFolder", path));
}

int totalDeleted =
fileFolder.delete(
new TextFileSelector(fileFolder.toString(), wildcard, parentWorkflow));

if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG, "ActionDeleteFiles.TotalDeleted", String.valueOf(totalDeleted)));
}
isDeleted = true;
} else {

if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionDeleteFiles.ProcessingFile", path));
}
isDeleted = fileFolder.delete();
if (!isDeleted) {
logError(BaseMessages.getString(PKG, "ActionDeleteFiles.CouldNotDeleteFile", path));
} else {
if (log.isBasic()) {
if (isBasic()) {
logBasic(BaseMessages.getString(PKG, "ActionDeleteFiles.FileDeleted", path));
}
}
}
} else {
// File already deleted, no reason to try to delete it
if (log.isBasic()) {
if (isBasic()) {
logBasic(BaseMessages.getString(PKG, "ActionDeleteFiles.FileAlreadyDeleted", path));
}
isDeleted = true;
Expand Down Expand Up @@ -348,7 +348,7 @@ public boolean includeFile(FileSelectInfo info) {
if (includeSubfolders
&& (info.getFile().getType() == FileType.FILE)
&& getFileWildcard(shortFilename, fileWildcard)) {
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG, "ActionDeleteFiles.DeletingFile", info.getFile().toString()));
Expand All @@ -359,7 +359,7 @@ && getFileWildcard(shortFilename, fileWildcard)) {
// In the Base Folder...
if ((info.getFile().getType() == FileType.FILE)
&& getFileWildcard(shortFilename, fileWildcard)) {
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG, "ActionDeleteFiles.DeletingFile", info.getFile().toString()));
Expand All @@ -369,7 +369,7 @@ && getFileWildcard(shortFilename, fileWildcard)) {
}
}
} catch (Exception e) {
log.logError(
logError(
BaseMessages.getString(PKG, "ActionDeleteFiles.Error.Exception.DeleteProcessError"),
BaseMessages.getString(
PKG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public Result execute(Result result, int nr) throws HopException {
successConditionBrokenExit = false;
nrLimitFolders = Const.toInt(resolve(getLimitFolders()), 10);

if (argFromPrevious && log.isDetailed()) {
if (argFromPrevious && isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG,
Expand Down Expand Up @@ -229,7 +229,7 @@ public Result execute(Result result, int nr) throws HopException {
}
}

if (log.isDetailed()) {
if (isDetailed()) {
logDetailed("=======================================");
logDetailed(
BaseMessages.getString(PKG, "ActionDeleteFolders.Log.Info.NrError", "" + nrErrors));
Expand Down Expand Up @@ -283,14 +283,14 @@ private boolean deleteFolder(String folderName) {
// the file or folder exists
if (filefolder.getType() == FileType.FOLDER) {
// It's a folder
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(PKG, "ActionDeleteFolders.ProcessingFolder", folderName));
}
// Delete Files
int count = filefolder.delete(new TextFileSelector());

if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG, "ActionDeleteFolders.TotalDeleted", folderName, String.valueOf(count)));
Expand All @@ -302,7 +302,7 @@ private boolean deleteFolder(String folderName) {
}
} else {
// File already deleted, no reason to try to delete it
if (log.isBasic()) {
if (isBasic()) {
logBasic(
BaseMessages.getString(PKG, "ActionDeleteFolders.FolderAlreadyDeleted", folderName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ public Result execute(Result previousResult, int nr) {
if (previousResult != null) {
try {
int size = previousResult.getResultFiles().size();
if (log.isBasic()) {
if (isBasic()) {
logBasic(
BaseMessages.getString(PKG, "ActionDeleteResultFilenames.log.FilesFound", "" + size));
}
if (!specifyWildcard) {
// Delete all files
previousResult.getResultFiles().clear();
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG, "ActionDeleteResultFilenames.log.DeletedFiles", "" + size));
Expand All @@ -183,7 +183,7 @@ public Result execute(Result previousResult, int nr) {
// Remove file from result files list
result.getResultFiles().remove(resultFile.getFile().toString());

if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG, "ActionDeleteResultFilenames.log.DeletedFile", file.toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public Result execute(Result previousResult, int nr) throws HopException {
int indexOfResultFieldIncludeSubfolders = -1;

// as such we must get rows
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG,
Expand Down Expand Up @@ -456,7 +456,7 @@ public Result execute(Result previousResult, int nr) throws HopException {
break;
case SOURCE_FILES_FILENAMES_RESULT:
List<ResultFile> resultFiles = result.getResultFilesList();
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public Result execute(Result previousResult, int nr) {
boolean successOK = false;

int nrRowsLimit = Const.toInt(resolve(limit), 0);
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(PKG, "ActionEvalTableContent.Log.nrRowsLimit", "" + nrRowsLimit));
}
Expand All @@ -279,7 +279,7 @@ public Result execute(Result previousResult, int nr) {
if (useVars) {
realCustomSql = resolve(realCustomSql);
}
if (log.isDebug()) {
if (isDebug()) {
logDebug(
BaseMessages.getString(
PKG, "ActionEvalTableContent.Log.EnteredCustomSQL", realCustomSql));
Expand Down Expand Up @@ -312,7 +312,7 @@ public Result execute(Result previousResult, int nr) {
}

if (countSqlStatement != null) {
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG, "ActionEvalTableContent.Log.RunSQLStatement", countSqlStatement));
Expand Down Expand Up @@ -340,7 +340,7 @@ public Result execute(Result previousResult, int nr) {
}
}
} else {
if (log.isDebug()) {
if (isDebug()) {
logDebug(
BaseMessages.getString(
PKG,
Expand All @@ -355,7 +355,7 @@ public Result execute(Result previousResult, int nr) {
rowsCount = row.getInteger(0);
}
}
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG, "ActionEvalTableContent.Log.NrRowsReturned", "" + rowsCount));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ public Result execute(Result previousResult, int nr) {

if (file.exists()
&& file.isReadable()) { // TODO: is it needed to check file for readability?
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(PKG, "ActionFilesExist.File_Exists", realFilefoldername));
}
} else {
missingfiles++;
if (log.isDetailed()) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG, "ActionFilesExist.File_Does_Not_Exist", realFilefoldername));
Expand Down
Loading

0 comments on commit f5a2e64

Please sign in to comment.