public interface TableValidatorESP extends BaseESP
import com.canto.cumulus.Cumulus; import com.canto.cumulus.GUID; import com.canto.cumulus.Item; import com.canto.cumulus.constants.TableAction; import com.canto.cumulus.server.esp.modules.validator.TableValidatorESP; import com.canto.cumulus.server.esp.modules.validator.ValidatorConfigurator; import com.canto.cumulus.utils.JPack; import java.util.EnumSet; import java.util.Locale; public class NonEmptyCategoryNameTableValidator implements TableValidatorESP { private static final GUID ID = new GUID ("{21BD27AB-171E-4BE7-A5EF-3AB68C50C908}"); //replace with your own GUID @Override public GUID getID () { return ID; } @Override public String getName (Locale locale) { return "Category Name Validator"; } @Override public String getUserInterfaceCheckboxText (Locale locale) { return "Enforce non-empty category names"; } @Override public EnumSetgetSupportedTableActions (String tableName) { return Cumulus.TABLE_NAME_CATEGORIES.equals (tableName) ? EnumSet.of (TableAction.CREATE, TableAction.UPDATE) : null; } @Override public boolean hasConfigurator () { return false; } @Override public ValidatorConfigurator createConfigurator (JPack configuration) { return null; } @Override public String validate (Locale locale, Object itemObj, TableAction tableAction, JPack configurationData) { Item item = (Item) itemObj; if (!item.hasValue (GUID.UID_CAT_NAME) || item.getStringValue (GUID.UID_CAT_NAME).isEmpty ()) { return "Category name should not be empty"; } else { return null; } } }
Modifier and Type | Method and Description |
---|---|
ValidatorConfigurator |
createConfigurator(JPack configuration)
Returns a configurator instance that is initialized with the given data.
|
java.lang.String |
getName(java.util.Locale locale)
Returns the name for this validator.
|
java.util.EnumSet<TableAction> |
getSupportedTableActions(java.lang.String tableName)
Returns the supported actions for the given table.
|
java.lang.String |
getUserInterfaceCheckboxText(java.util.Locale locale)
Returns the text being displayed with the JCheckBox in the preferences dialog that enables or disabled the validator.
|
boolean |
hasConfigurator()
Returns whether this validator has some specific user interface for configuration.
|
java.lang.String |
validate(java.util.Locale locale,
java.lang.Object item,
TableAction tableAction,
JPack configurationData)
The actual worker method that should validate the content of the given table item to comply with the validation rules specified by the configuration
data.
|
java.lang.String getName(java.util.Locale locale)
locale
- the language to get the name forjava.lang.String getUserInterfaceCheckboxText(java.util.Locale locale)
locale
- the language to get the text forjava.util.EnumSet<TableAction> getSupportedTableActions(java.lang.String tableName)
tableName
- the table to return the supported actions fornull
or empty set in case the table is not supported, otherwise the set of supported actionsboolean hasConfigurator()
true
if this validator has some specific user interface for configuration, false
otherwiseValidatorConfigurator createConfigurator(JPack configuration)
configuration
- the configuration datajava.lang.String validate(java.util.Locale locale, java.lang.Object item, TableAction tableAction, JPack configurationData)
locale
- The language to present the error with in case of a failed validationitem
- The item to work on. Needs to be casted to Item
for the actual worktableAction
- The action that would be executed on the given item in case the validation is successful.configurationData
- The pack containing the configuration previously configured using the ValidatorConfigurator
instance of this validatornull
if the current value is validwww.canto.com
Canto, the Canto logo, the Cumulus logo, and Cumulus are registered trademarks of Canto GmbH, registered in the U.S. and other countries.