Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 28
Registered: ‎11-04-2015
Accepted Solution

Offline WF - maximum elemements

Hi all,

 

I don't want to let user create more than one (or defined amount )  element in offline WF. So steps are:

  1. start offline WF 
  2. capture 
  3. if user wants to create next element (+1 then defined in code), he gets alert and element is not saved (automatically deleted).

has anybody already solved it and has a working sample for that JAVA plugin?

 

thx

Lukas

Highlighted
Frequent Contributor
Posts: 77
Registered: ‎10-12-2015

Re: Offline WF - maximum elemements

[ Edited ]

Hi Lukas,

 

I believe this can be achieved by implementing the IValidator interface.


Here's a sample:

package com.hgdn.gmsc.extensions;
public class SampleClientValidationHandler implements IValidator
{
 
       public List<ValidationError> validate(List<PersistenceElement> elements)
       {
              List<ValidationError> validationErrors  = new ArrayList<ValidationError>();
              Feature featureToEdit = ((EditPlugin) ApplicationContext.getPluginCurator().getByName("EditPlugin")).getEditSettings().getFeature();
              if(elements.size() == 0 || !featureToEdit.getName().equals("FeatureName"))
                     return validationErrors;
             
              if(elements.size()>1)
                     validationErrors.add(new ValidationError("Only one element may be saved using this workflow", true));
                    
       return validationErrors;
       }
}

 

IValidator is following the Service Loader Pattern. This means that you have to create a file und META-INF/services: com.intergraph.web.plugin.edit.validation.IValidator and add your instance using package name + class name: com.hgdn.gmsc.extensions.SampleClientValidationHandler

 

IValidator_Meta_Inf.JPG

 

The above sample first checks if a certain feature is active and if so, validates if only one element has been modified.

 

Hope this helps

Contributor
Posts: 28
Registered: ‎11-04-2015

Re: Offline WF - maximum elemements

Hi,

 

it looks good. I will forwarrd it to develepor.

 

Thx 

 

Lukas

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.