Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

...

Dafür erstellen wir eine UpdateFinal-Regel. Diese wird nur im Anschluss an einen fehlerfreien Update-Process ausgeführt. Wir lesen die Positionen aus und aktualisieren sie mit Hilfe des BusinessObjectProviders.

Quellcode

 


Codeblock
package org.nuclet.company; 

import java.util.List;
import org.nuclos.api.rule.UpdateRule; 
import org.nuclos.api.context.UpdateContext; 
import org.nuclos.api.annotation.Rule; 
import org.nuclos.api.exception.BusinessException; 

/** @name        
  * @description 
  * @usage       
  * @change      
*/
@Rule(name="UpdateFinalBestellung", description="UpdateFinalBestellung")
public class UpdateFinalBestellung implements UpdateFinalRule {
    public void updateFinal(UpdateContext context) throws BusinessException { 
     
		    // this is the businessObject after storing the updated data in the database
            Bestellung curBestellung = context.getBusinessObject(Bestellung.class);
        
            // changes are not recognized, because data has already been saved
            // the following description will not be stored in the database
            curBestellung.setKurzbeschreibung("Bestellung wurde im Schnellverfahren abgeschlossen.");
           
			// we want to re-update all positions after the order has been updated properly
			// so we use the QueryProvider
            for (Bestellposition pos : curBestellung.getPosition()) {
                pos.setBemerkung("Position im Gesamtkontext von " + curBestellung.getNr());
                BusinessObjectProviderpos.updatesave(pos);
            }
           
 	}
}