Class KitValidator
java.lang.Object
net.sf.basedb.util.overview.validator.BasicNodeValidator<I>
net.sf.basedb.util.overview.validator.NameableNodeValidator<Kit>
net.sf.basedb.util.overview.validator.KitValidator
- All Implemented Interfaces:
NodeValidator<Kit>
Validator implementation for kits. Validation rules:
- Missing item:
Validator.MISSING_KIT
- Access denied:
Validator.DENIED_KIT
- Incorrect hardware type:
Validator.INCORRECT_KITTYPE
- Using kit after expiration date:
Validator.KIT_USED_AFTER_EXPIRATIONDATE
- Since:
- 3.7
- Author:
- Nicklas
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ItemSubtype
getExpectedKitSubtype
(DbControl dc, BasicItem parentItem, boolean useDefault) Get the subtype of the associated kit that we expect for the given parent item.protected Fix
getMissingItemFix
(DbControl dc, Node parentNode) Subclasses should override this method if they have a suggessted fix for a missing item problem.void
postValidate
(DbControl dc, OverviewContext context, Node node, Node parentNode) Checks if the hardware is of the correct hardware type and, if a project is active, the hardware is included as a default hardware for the project.boolean
preMissingItem
(DbControl dc, OverviewContext context, Node parentNode) If the parent item has a subtype that is related to a KIT subtype, report the missing item as aValidator.MISSING_KIT
failure.Methods inherited from class net.sf.basedb.util.overview.validator.BasicNodeValidator
getDeniedItemFix, postDeniedItem, postMissingItem, postValidateFolder, preDeniedItem, preValidate
-
Constructor Details
-
KitValidator
public KitValidator()
-
-
Method Details
-
preMissingItem
If the parent item has a subtype that is related to a KIT subtype, report the missing item as aValidator.MISSING_KIT
failure. Otherwise, ignore the missing kit.- Specified by:
preMissingItem
in interfaceNodeValidator<Kit>
- Overrides:
preMissingItem
in classBasicNodeValidator<Kit>
- Parameters:
dc
- A DbControl to use if the validation needs to access the databasecontext
- The current overview contextparentNode
- The parent node that is missing the item- Returns:
- Always false
-
postValidate
Checks if the hardware is of the correct hardware type and, if a project is active, the hardware is included as a default hardware for the project.- Specified by:
postValidate
in interfaceNodeValidator<Kit>
- Overrides:
postValidate
in classNameableNodeValidator<Kit>
- Parameters:
dc
- A DbControl to use if the validation needs to access the databasecontext
- The current overview contextnode
- The node object that represents itemparentNode
- The parent node that is linked with the item
-
getMissingItemFix
Description copied from class:BasicNodeValidator
Subclasses should override this method if they have a suggessted fix for a missing item problem. The default implementation does nothing, but the following template may be usable by most subclasses:new Fix("Add item to parent", parentNode.getItem())
- Specified by:
getMissingItemFix
in classBasicNodeValidator<Kit>
- Returns:
- Suggested fix is to add a hardware to the parent item
-
getExpectedKitSubtype
Get the subtype of the associated kit that we expect for the given parent item.
-