26 QString QgsRaiseExceptionAlgorithm::name()
const
28 return QStringLiteral(
"raiseexception" );
31 QgsProcessingAlgorithm::Flags QgsRaiseExceptionAlgorithm::flags()
const
36 QString QgsRaiseExceptionAlgorithm::displayName()
const
38 return QObject::tr(
"Raise exception" );
41 QStringList QgsRaiseExceptionAlgorithm::tags()
const
43 return QObject::tr(
"abort,warn,error,cancel" ).split(
',' );
46 QString QgsRaiseExceptionAlgorithm::group()
const
48 return QObject::tr(
"Modeler tools" );
51 QString QgsRaiseExceptionAlgorithm::groupId()
const
53 return QStringLiteral(
"modelertools" );
56 QString 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." );
65 QString QgsRaiseExceptionAlgorithm::shortDescription()
const
67 return QObject::tr(
"Raises an exception and cancels a model's execution." );
70 QgsRaiseExceptionAlgorithm *QgsRaiseExceptionAlgorithm::createInstance()
const
72 return new QgsRaiseExceptionAlgorithm();
75 void 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 );
105 QString QgsRaiseWarningAlgorithm::name()
const
107 return QStringLiteral(
"raisewarning" );
110 QgsProcessingAlgorithm::Flags QgsRaiseWarningAlgorithm::flags()
const
115 QString QgsRaiseWarningAlgorithm::displayName()
const
117 return QObject::tr(
"Raise warning" );
120 QStringList QgsRaiseWarningAlgorithm::tags()
const
122 return QObject::tr(
"abort,warn,error,cancel" ).split(
',' );
125 QString QgsRaiseWarningAlgorithm::group()
const
127 return QObject::tr(
"Modeler tools" );
130 QString QgsRaiseWarningAlgorithm::groupId()
const
132 return QStringLiteral(
"modelertools" );
135 QString 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 "
144 QString QgsRaiseWarningAlgorithm::shortDescription()
const
146 return QObject::tr(
"Raises an warning message." );
149 QgsRaiseWarningAlgorithm *QgsRaiseWarningAlgorithm::createInstance()
const
151 return new QgsRaiseWarningAlgorithm();
154 void 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();