26QString QgsRaiseExceptionAlgorithm::name()
const
28 return QStringLiteral(
"raiseexception" );
36QString QgsRaiseExceptionAlgorithm::displayName()
const
38 return QObject::tr(
"Raise exception" );
41QStringList QgsRaiseExceptionAlgorithm::tags()
const
43 return QObject::tr(
"abort,warn,error,cancel" ).split(
',' );
46QString QgsRaiseExceptionAlgorithm::group()
const
48 return QObject::tr(
"Modeler tools" );
51QString QgsRaiseExceptionAlgorithm::groupId()
const
53 return QStringLiteral(
"modelertools" );
56QString QgsRaiseExceptionAlgorithm::shortHelpString()
const
58 return QObject::tr(
"This algorithm raises an exception and cancels a model's execution.\n\n"
59 "The exception message can be customized, and optionally an expression based condition "
60 "can be specified. If an expression condition is used, then the exception will only "
61 "be raised if the expression result is true. A false result indicates that no exception "
62 "will be raised, and the model execution can continue uninterrupted." );
65QString QgsRaiseExceptionAlgorithm::shortDescription()
const
67 return QObject::tr(
"Raises an exception and cancels a model's execution." );
70QgsRaiseExceptionAlgorithm *QgsRaiseExceptionAlgorithm::createInstance()
const
72 return new QgsRaiseExceptionAlgorithm();
75void QgsRaiseExceptionAlgorithm::initAlgorithm(
const QVariantMap & )
83 const QString expression = parameterAsExpression( parameters, QStringLiteral(
"CONDITION" ), context );
84 if ( !expression.isEmpty() )
88 if ( exp.hasParserError() )
90 throw QgsProcessingException( QObject::tr(
"Error parsing condition expression: %1" ).arg( exp.parserErrorString() ) );
92 if ( !exp.evaluate( &expContext ).toBool() )
96 const QString error = parameterAsString( parameters, QStringLiteral(
"MESSAGE" ), context );
105QString QgsRaiseWarningAlgorithm::name()
const
107 return QStringLiteral(
"raisewarning" );
115QString QgsRaiseWarningAlgorithm::displayName()
const
117 return QObject::tr(
"Raise warning" );
120QStringList QgsRaiseWarningAlgorithm::tags()
const
122 return QObject::tr(
"abort,warn,error,cancel" ).split(
',' );
125QString QgsRaiseWarningAlgorithm::group()
const
127 return QObject::tr(
"Modeler tools" );
130QString QgsRaiseWarningAlgorithm::groupId()
const
132 return QStringLiteral(
"modelertools" );
135QString QgsRaiseWarningAlgorithm::shortHelpString()
const
137 return QObject::tr(
"This algorithm raises a warning message in the log.\n\n"
138 "The warning message can be customized, and optionally an expression based condition "
139 "can be specified. If an expression condition is used, then the warning will only "
140 "be logged if the expression result is true. A false result indicates that no warning "
144QString QgsRaiseWarningAlgorithm::shortDescription()
const
146 return QObject::tr(
"Raises an warning message." );
149QgsRaiseWarningAlgorithm *QgsRaiseWarningAlgorithm::createInstance()
const
151 return new QgsRaiseWarningAlgorithm();
154void QgsRaiseWarningAlgorithm::initAlgorithm(
const QVariantMap & )
162 const QString expression = parameterAsExpression( parameters, QStringLiteral(
"CONDITION" ), context );
163 if ( !expression.isEmpty() )
167 if ( exp.hasParserError() )
169 throw QgsProcessingException( QObject::tr(
"Error parsing condition expression: %1" ).arg( exp.parserErrorString() ) );
171 if ( !exp.evaluate( &expContext ).toBool() )
172 return QVariantMap();
175 const QString warning = parameterAsString( parameters, QStringLiteral(
"MESSAGE" ), context );
177 return QVariantMap();
185QString QgsRaiseMessageAlgorithm::name()
const
187 return QStringLiteral(
"raisemessage" );
195QString QgsRaiseMessageAlgorithm::displayName()
const
197 return QObject::tr(
"Raise message" );
200QStringList QgsRaiseMessageAlgorithm::tags()
const
202 return QObject::tr(
"information" ).split(
',' );
205QString QgsRaiseMessageAlgorithm::group()
const
207 return QObject::tr(
"Modeler tools" );
210QString QgsRaiseMessageAlgorithm::groupId()
const
212 return QStringLiteral(
"modelertools" );
215QString QgsRaiseMessageAlgorithm::shortHelpString()
const
217 return QObject::tr(
"This algorithm raises an information message in the log.\n\n"
218 "The message can be customized, and optionally an expression based condition "
219 "can be specified. If an expression condition is used, then the message will only "
220 "be logged if the expression result is true. A false result indicates that no message "
224QString QgsRaiseMessageAlgorithm::shortDescription()
const
226 return QObject::tr(
"Raises an information message." );
229QgsRaiseMessageAlgorithm *QgsRaiseMessageAlgorithm::createInstance()
const
231 return new QgsRaiseMessageAlgorithm();
234void QgsRaiseMessageAlgorithm::initAlgorithm(
const QVariantMap & )
242 const QString expression = parameterAsExpression( parameters, QStringLiteral(
"CONDITION" ), context );
243 if ( !expression.isEmpty() )
247 if ( exp.hasParserError() )
249 throw QgsProcessingException( QObject::tr(
"Error parsing condition expression: %1" ).arg( exp.parserErrorString() ) );
251 if ( !exp.evaluate( &expContext ).toBool() )
252 return QVariantMap();
255 const QString info = parameterAsString( parameters, QStringLiteral(
"MESSAGE" ), context );
257 return QVariantMap();
QFlags< ProcessingAlgorithmFlag > ProcessingAlgorithmFlags
Flags indicating how and when an algorithm operates and should be exposed to users.
@ HideFromToolbox
Algorithm should be hidden from the toolbox.
@ SkipGenericModelLogging
When running as part of a model, the generic algorithm setup and results logging should be skipped.
@ CustomException
Algorithm raises custom exception notices, don't use the standard ones.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Class for parsing and evaluation of expressions (formerly called "search strings").
virtual Qgis::ProcessingAlgorithmFlags flags() const
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
virtual void pushWarning(const QString &warning)
Pushes a warning informational message from the algorithm.
An expression parameter for processing algorithms.
A string parameter for processing algorithms.