Writing Pluglets

A pluglet is a plug-in project, which contains scripts. Pluglets are used to make extensions to the workbench in a simple way. Pluglets are written in Java. It is possible to customize Electrical & Electronics Architecture using pluglet scripts.

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 IEEWRule:

  • getId() returns a String uniquely identifying the rule. This String may be arbitrary.
  • getLevel() returns whether the rule returns an Info, a Warning, or an Error. It is the rule severity.
  • isAvailable(Object object) returns whether the rule applies or not to the object argument. Test functions on EE objects are available in the API, for example isFunction(o) or isFlow(o), ...
  • validate(Object object) is the implementation of the verification code of the rule. It must return null, if the rule is validated by the object. Otherwise, it must return a String, which is displayed as the description of the error on the object.
  • And a default constructor

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 ; 
 }
}