Add-on type: Procedure (pagp)
General
A Procedure provides a PicApport user with a certain number of actions for a number of selected photos. Examples for such actions are:
- Special reports based on metadata of the selected images
- Automatic tagging
- Upload photos to web services
- File operations on the selected photos (modify, copy etc.)
- Creation of maps etc.
A procedure can provide the user with an input form to enter parameters. It is also possible to link certain actions to user permissions. The individual actions are declared as a Map together with their parameters in the init() method.
A groovy script is recognized as a Procedure if it extends the class: de.contecon.picapport.groovy.PhotoFileProcessor
See also de.contecon.picapport.groovy.PhotoFileProcessor for the methods that can be overwritten to create your own Procedure.
Updating
When a Procedure has been updated it will automatically be reloaded and compiled when:
- When the PicApport Server starts
- Before execution
- When the reloadaddons console command is executed
If components of the web interface or menu etc. change during development, the web interface must be reloaded to make these changes visible after the Add-on has been reloaded.
The init() Method
The init() method of a Procedure must return a Map which defines the metadata of the Procedure:
version | String | no | Version information |
functions | List of Function-Key-Value pairs | no | A list of at least one function or action that is provided by this Add-on. A function must have a unique id for this Add-on (f1 in the example below). A Function has the following paramaters |
name | String | no | Name of this function that should be displayed in the menue. |
desc | String | yes | Optional description |
permission | String | yes | PicApport permission required to execute this function. See PicApport – Usermanagement – PicApport Wiki (contecon.de) for valid pap:* permissions. |
parameter | Optional List of Parameter-Key-Value pairs | yes | An optional list of parameters for this function. A parameter must have a unique id inside this function. |
| |||||||||||||||||||||||||
i18n | Key/Value pairs | yes | Optional key/value pairs for translation. Function keys: [isoLanguage].[functionId].name → Translation of Function-name Parameter keys: [isoLanguage].[functionId].[paramaterId].[parameterOption] see example below |
Example of an init() Method with i18n support
def ADDON_TYPE_ID = "osm.org" ; def en_Title = 'OpenStreetMap (OSM) Reverse geocoding' ; def de_Title = 'OpenStreetMap (OSM) Inverse Geokodierung' ; def en_Options=[ 'Write only when empty' , 'Always overwrite' , 'no Changes (just test)' , 'Remove OpenStreetMap metadata' , 'Show OpenStreetMap metadata of photos' ]; def de_Options=[ 'Schreibe nur wenn leer' , 'Immer überschreiben' , 'keine Änderungen (nur testen)' , 'OpenStreetMap Metadaten entfernen' , 'OpenStreetMap Daten der Fotos anzeigen' ]; public Map init(IAddonContext addonContext) { addonContext.getLogger().logMessage( " Addon loaded Autor: E. Schreiner (c)2020 Contecon Software GmbH" ); def meta = [ version: '1.0.0' , functions: [ f1: [ name: en_Title, desc: 'Converts geographic coordinates (latitude, longitude)\nto a readable address or place name' , permission: 'pap:editmeta:photo' , parameter: [ mode: [ type: 'select' , label: 'Overwrite' , options: en_Options, value: '0' ], language: [ type: 'text' , label: 'language' , value: System.getProperty( "user.language" ) ], analyseResult: [ type: 'checkbox' , label: 'Analyse result' , value: false ] ] ] ], i18n: [ 'de.f1.name' : de_Title, 'de.f1.desc' : 'Mittels Geokoordinaten werden textuelle Lokationsangaben gesucht,\nalso etwa Städtenamen, Straßennamen, etc...' , 'de.f1.mode.label' : 'Überschreiben' , 'de.f1.mode.options' : de_Options, 'de.f1.language.label' : 'Sprache' , 'de.f1.analyseResult.label' : 'Analysiere Ergebnis' , ], ] } |
Sample Implementation of a Procedure
See PicApport Add-on: GroovyProceduresTestTool – PicApport Wiki (contecon.de) which contains a download-URL for our sample implementation of a Procedure