Environment: On premises only Pluglets can enable the customization of the validation in Electrical & Electronics Architecture. The following example shows how to write rules. Each rule is implemented by a pluglet of Java code. Public APIs are provided to enable you or your corporate IT department to create customized rules. A pluglet has to import the five packages below in the code and the rule must implement the four
functions of interface
Here is an example implementation of a very simple rule: import com.dassault_systemes.eea.cateeanavitf.CATEEAApiNavException; import com.dassault_systemes.eea.cateeanavitf.CATEEAApiNavServices; import com.dassault_systemes.eea.cateeanavitf.CATEEANavItf; import com.dassault_systemes.eew.rulesIft.EEWRuleLevel; import com.dassault_systemes.eew.rulesIft.IEEWRule; public class TestNameStartsWith implements IEEWRule { Public TestNameStartsWith(){}; @Override public String getId() { return "TheNameTestRule"; } @Override public String validate(Object object) { CATEEANavItf api; try { api = CATEEAApiNavServices.getNavFactory().createNavItf(); if (!api.getName(object).startsWith( "Flow_" )) return "A flow name should start by Flow_"; } catch (CATEEAApiNavException e) { e.printStackTrace(); } return null; } @Override public boolean isAvailable(Object object) { CATEEANavItf api; try { api = CATEEAApiNavServices.getNavFactory().createNavItf(); return api.isFlow(object); } catch (CATEEAApiNavException e) { e.printStackTrace(); } return false; } @Override public EEWRuleLevel getLevel() { return EEWRuleLevel.ERROR ; } } |