Exemplo n.º 1
0
 def invalidModels(self):
     """
     Returns all valid models from workflow parameters.
     :return: (dict) models maps invalid models to their invalidation reason.
     """
     models = dict()
     self._multiStepFeedback = QgsProcessingMultiStepFeedback(
         len(self._param["models"]), self.feedback)
     self._multiStepFeedback.setCurrentStep(0)
     for modelName, modelParam in self._param["models"].items():
         model = DsgToolsProcessingModel(modelParam,
                                         modelName,
                                         feedback=self._multiStepFeedback)
         if not model.isValid():
             models[modelName] = model.validateParameters(modelParam)
     return models
Exemplo n.º 2
0
 def models(self):
     """
     Model parameters defined to run in this workflow.
     :return: (dict) models maps to valid and invalid models.
     """
     models = {"valid": dict(), "invalid": dict()}
     self._multiStepFeedback = QgsProcessingMultiStepFeedback(
         len(self._param["models"]), self.feedback)
     self._multiStepFeedback.setCurrentStep(0)
     for modelName, modelParam in self._param["models"].items():
         model = DsgToolsProcessingModel(modelParam,
                                         modelName,
                                         feedback=self._multiStepFeedback)
         if not model.isValid():
             models["invalid"][modelName] = model.validateParameters(
                 modelParam)
         else:
             models["valid"][modelName] = model
     return models
Exemplo n.º 3
0
 def validateParameters(self, parameters):
     """
     Validates a set of parameters for a valid Workflow.
     :param parameters: (dict) map of workflow attributes to be validated.
     :return: (str) invalidation reason.
     """
     if "displayName" not in parameters or not parameters["displayName"]:
         # this is not a mandatory item, but it defaults to a value
         parameters["displayName"] = self.tr("DSGTools Validation Workflow")
     if "models" not in parameters or not parameters["models"]:
         return self.tr("Workflow seems to have no models associated with it.")
     for modelName, modelParam in parameters["models"].items():
         model=DsgToolsProcessingModel(modelParam, modelName)
         if not model.isValid():
             return self.tr("Model {model} is invalid: '{reason}'.").format(
                 model=modelName, reason=model.validateParameters(modelParam)
             )
     # if "flagLayer" not in parameters or not parameters["flagLayer"]:
     #     self.tr("No flag layer was provided.")
     # if "historyLayer" not in parameters or not parameters["historyLayer"]:
     #     self.tr("No history layer was provided.")
     return ""