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 TypeMethodDescriptionvoidvoidvoidaddWarning(String message) voidaddWarning(Map<String, String> warnings) voidChecks the validity of the processintAdds an exception error to the errors to report.Adds an exception error to the errors to report.voidProcess is failing due to provided exception.getReportList(String taskInfo) booleanReports if the process contains errorsbooleanReports if the process contains warningsbooleanisDescendantOf(Class... clazz) booleanChecks if a response is an error -- If so add the response message to the list of errorsbooleanChecks if a Response is an error with optional expected error codesbooleanChecks if a Response is an error with optional expected error codesbooleanvoidprintReport(PrintStream out) Prints a report of errors and warnings to the provided printstream.voidsetErrorsAsWarnings(boolean errorsAsWarnings) voidsetExceptionOnErrors(boolean exceptionOnErrors) Determines whether to throw an exception on errors or just log.voidsetParentProcess(GenericProcess process) voidsetProcessId(String processId) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
-