Nuclos event rule Status change: interface, StateChangeContext, structure, assignment in the server rule manager, example code (Java). |
Language: Deutsch · English
Event rule „Status change“: interface, context and an example – how to react to this Nuclos event.
On this page |
This server-side rule runs on a status change (before the change). It can be assigned to a status model.
Skeleton of the rule class (the rule editor creates it automatically):
package org.nuclet.lager;
import org.nuclos.api.rule.StateChangeRule;
import org.nuclos.api.context.StateChangeContext;
import org.nuclos.api.annotation.Rule;
import org.nuclos.api.exception.BusinessException;
/** @name
* @description
* @usage
* @change
*/
@Rule(name="Statuswechsel Lagerbestand", description="Statuswechsel Lagerbestand")
public class StatuswechselLagerbestand implements StateChangeRule {
public void changeState(StateChangeContext context) throws BusinessException {
}
} |
The context |
Assign it to the target via drag-and-drop in the server rule manager. Optionally restrict execution to a status or an action; control the order with the arrow buttons.
package org.nuclet.company;
import org.nuclos.api.rule.StateChangeRule;
import org.nuclos.api.context.StateChangeContext;
import org.nuclos.api.annotation.Rule;
import org.nuclos.api.exception.BusinessException;
/** @name
* @description
* @usage
* @change
*/
@Rule(name="BeauftragungPrüfen", description="Beauftragung prüfen")
public class BeauftragungPrüfen implements StateChangeRule {
public void changeState(StateChangeContext context) throws BusinessException {
Auftrag neuerAuftrag = context.getBusinessObject(Auftrag.class);
if (neuerAuftrag.getBestellwert() == null)
throw new BusinessException("Der Bestellwert darf nicht leer sein.");
if (neuerAuftrag.getKunde() == null)
throw new BusinessException("Es wurde kein Kunde für diesen Auftrag hinterlegt.");
if (neuerAuftrag.getAuftragsnr() == null)
throw new BusinessException("Der Auftrag besitzt keine Nummer.");
}
} |