Package co.ecg.alpaca.toolkit.task
Class GenericProcess
java.lang.Object
co.ecg.alpaca.toolkit.task.GenericProcess
- All Implemented Interfaces:
Loggable
- Direct Known Subclasses:
IterableProcess
An abstract process that is error-able and tracks its state.
- Author:
- Matthew Keathley on 5/10/16.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGenericProcess
(GenericProcess parentProcess) GenericProcess
(String processId) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
addWarning
(String message) void
addWarning
(Map<String, String> warnings) void
Checks the validity of the processint
Adds an exception error to the errors to report.Adds an exception error to the errors to report.void
Process is failing due to provided exception.getReportList
(String taskInfo) boolean
Reports if the process contains errorsboolean
Reports if the process contains warningsboolean
isDescendantOf
(Class... clazz) boolean
Checks if a response is an error -- If so add the response message to the list of errorsboolean
Checks if a Response is an error with optional expected error codesboolean
Checks if a Response is an error with optional expected error codesboolean
void
printReport
(PrintStream out) Prints a report of errors and warnings to the provided printstream.void
setErrorsAsWarnings
(boolean errorsAsWarnings) void
setExceptionOnErrors
(boolean exceptionOnErrors) Determines whether to throw an exception on errors or just log.void
setParentProcess
(GenericProcess process) void
setProcessId
(String processId) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface co.ecg.alpaca.toolkit.task.Loggable
getProcessLogger, logger
-
Field Details
-
log
public transient org.slf4j.Logger log
-
-
Constructor Details
-
GenericProcess
public GenericProcess() -
GenericProcess
-
GenericProcess
-
-
Method Details
-
getProcessContext
-
getLogIdentifier
-
getParentProcess
-
setProcessId
-
setExceptionOnErrors
public void setExceptionOnErrors(boolean exceptionOnErrors) Determines whether to throw an exception on errors or just log.- Parameters:
exceptionOnErrors
- a boolean
-
hasErrors
public boolean hasErrors()Reports if the process contains errors- Returns:
- True IFF there was 0+ errors reported.
-
errorCount
public int errorCount() -
hasWarnings
public boolean hasWarnings()Reports if the process contains warnings- Returns:
- True IFF there was 0+ warnings reported.
-
getErrors
-
fail
Process is failing due to provided exception. Errors will be added to parent if provided.- Parameters:
throwable
- The throwable reason that the process is failing.- Throws:
ProcessTerminatingException
-
getWarnings
-
checkValidity
Checks the validity of the process- Throws:
ProcessTerminatingException
- Thrown if the process has errors.
-
printReport
Prints a report of errors and warnings to the provided printstream.- Parameters:
out
- The printstream to write the report
-
getReportList
-
getReportList
-
getReport
-
exception
Adds an exception error to the errors to report.- Parameters:
throwable
- The throwable to process.
-
exception
Adds an exception error to the errors to report.- Parameters:
throwable
- The throwable to process.
-
isError
Checks if a response is an error -- If so add the response message to the list of errors- Parameters:
response
- The response to check- Returns:
- true IFF the response is an error
-
isError
Checks if a Response is an error with optional expected error codes- Parameters:
response
- The response to checkexpectedErrorCodes
- The array of expected error codes- Returns:
- true IFF the response is an error
-
isError
public boolean isError(Response response, boolean markErrorCodesAsWarnings, String... expectedErrorCodes) Checks if a Response is an error with optional expected error codes- Parameters:
response
- The response to checkmarkErrorCodesAsWarnings
- Flag to add expected error codes as warning messages.expectedErrorCodes
- The array of expected error codes- Returns:
- true IFF the response is an error
-
isErrorsAsWarnings
public boolean isErrorsAsWarnings() -
setErrorsAsWarnings
public void setErrorsAsWarnings(boolean errorsAsWarnings) -
addWarning
-
addWarning
-
addError
-
addError
-
getProcessId
-
setParentProcess
-
isDescendantOf
-