Polish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Projekt stworzonej wtyczki jest dostępny w publicznym repozytorium http://192.168.1.61/developers/tutorials. Skompilowana wersja do pobrania tutaj:
WstępKurs ten opisuje proces tworzenia wtyczki dla systemu PlusWorkflow w wersji co najmniej 3.1. Wtyczka ta będzie udostępniała walidator formularza, który:
Przygotowanie walidatoraPierwszym krokiem jest stworzenie definicji walidatora oraz jego metody walidującej. W ten sposób informujemy edytor procesów, że taki walidator jest dostępny i może zostać wykorzystany przy budowie formularza zadania. W tym celu należy stworzyć klasę z odpowiednim zestawem adnotacji oraz metodę walidującą:
DefinicjaPowyżej zdefiniowaliśmy walidator
W definicji akcji podaliśmy również kategorię Categories.TEST. Niezbędne jest stworzenie takiej kategorii lub wykorzystanie kategorii, która już istnieje. Implementacja kategorii wygląda następująco:
Metoda walidującaOprócz definicji walidatora zaimplementowaliśmy również metodę walidującą.
W metodzie walidującej zdefiniowaliśmy parametry wejściowe.
Podczas wywoływania metody do wszystkich parametrów zostaną wstrzyknięte zdefiniowane parametry i obiekty pomocnicze.
Metoda walidująca weryfikuje czy parametr pesel_param jest numerem PESEL. Jeżeli nie jest, to dodaje tłumaczoną informacje o tym do obiektu ValidationErrors oraz oznacza, że chodzi o zmienną podaną w parametrze. Konfiguracja wtyczkiWalidator został już zdefiniowany. Należy jeszcze "powiedzieć" systemowi, że wtyczka udostępnia walidator i funkcję oraz korzysta z tłumaczeń. Plik suncode-plugin.xml powinien wyglądać następująco:
Wykorzystanie walidatora w zadaniuStworzony walidator będzie mógł być wykorzystany w edytorze procesów po uruchomieniu wtyczki. Aby sprawdzić jego działanie należy stworzyć prosty proces, a następnie dodać nasz walidator do przycisku akceptacji. Aby to zrobić należy wejść w formularz zadania, następnie wejść w edycję przycisku akceptacji i rozwinąć zakładkę Walidatory. Następnie przy pomocy przycisku należy dodać walidator. Po dodaniu walidatora pojawi się okno z jego definicją. Należy uzupełnić parametr walidatora oraz warunek wywołania. W tym momencie dodaliśmy walidator do przycisku akceptującego zadanie, który będzie weryfikował czy zmienna Pesel jest numerem PESEL. Walidacja będzie wywoływana tylko jeżeli zmienna Imię i Nazwisko nie będzie pusta. Poniżej został przedstawiony wynik walidacji błędnego numeru PESEL. |
English | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
The project of the created plugin is available in the public repository http://192.168.1.61/developers/tutorials. A compiled version can be downloaded here:
IntroductionThis course describes the process of creating a plug-in for the PlusWorkflow system at least 3.1 version. This plugin will provide a form validator which:
Validator preparationThe first step is to create a validator definition and its validating method. In this way, you inform the process editor that such validator is available and can be used to build a task form. To do this, create a class with the appropriate set of annotations and a validating method:
DefinitionAbove we have defined the
In action definition we have also provided the Categories.TEST. It is necessary to create such category or use category that already exists. The category implementation looks as follows:
Validation methodDespite of validator definition we have also implemented validation method.
In validation method, we defined the input parameters.
When calling the method, to all parameters will be injected defined parameters and auxiliary objects.
The validation method verifies whether the pesel_param parameter is a PESEL number. If it is not, then it adds the translated information about it to the ValidationErrors object and means that it is about the variable given in the parameter. Plugin configurationThe validator has already been defined. It is necessary to "tell" the system that the plug-in provides the validator and function and uses the translations. The suncode-plugin.xml file should look like this:
Using validator in taskStThe created validator can be used in the process editor after running the plugin. To check its operation, create a simple process and then add our validator to the acceptance button. To do this, enter the task form, then enter the acceptance edition button and expand the Validators tab. Next, use the button to add the validator. After adding the validator, a window with its definition will appear. The validator parameter and the calling condition must be filled. At this point, we added the validator to the button accepting the task, which will verify if the variable Peselis the PESELnumber. Validation will be called only if the variable Nameand Last namewill not be empty. The validation result of the incorrect number PESEL is presented below: |