Versionen im Vergleich

Schlüssel

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

...

Eine bestehende Nuclos-Instanz umfasst die Entität das Businessobjekt Bestellungen. Diese wiederum besitzt den Reiter Positionen, der alle Artikel einer konkreten Bestellung auflistet. Die Aufgabe besteht darin, nach erfolgreichem Anlegen einer neuen Bestellung einen Rückmeldungsstichtag (heute + 7 Tage) automatisch einzurichten. Aber nur, wenn die Bestellung fehlerfrei angelegt wurde.

Quellcode

...


Codeblock
package org.nuclet.companyprojekt; 

import org.nuclos.api.ruleannotation.InsertFinalRuleRule; 
import org.nuclos.api.context.InsertContext; 
import org.nuclos.api.annotation.Rule; 
import org.nuclos.api.exception.BusinessException; 
import java.util.Calendar;
import org.nuclos.api.providerrule.BusinessObjectProviderInsertFinalRule; 

/** 
 * @name AnsprechpartnerErstellen       
  * @description Unterstützende Regel zum Erstellen neuer Ansprechpartner aus Unterprojekten
  * @usage       
  * @change      
 * 
 */
@Rule(name="BestellungStichtagAnsprechpartnerErstellen", description="BestellungStichtagUnterstützende Regel zum Erstellen neuer Ansprechpartner aus Unterprojekten")
public class BestellungStichtagAnsprechpartnerErstellen implements InsertFinalRule {
  
  	public void insertFinal(InsertContext context) throws BusinessException { 
        final Ansprechpartner BestellungboAnsprechpartner curBestellung = context.getBusinessObject(BestellungAnsprechpartner.class);
          
          Calendar recallDay = Calendar.getInstance();
          recallDay.add(Calendar.DAY_OF_MONTH, 7);if (boAnsprechpartner.getUnterprojektsrefId() != null) {
          
  final Unterprojekt boUnterprojekt =     curBestellung.setRecallTermin(recallDay.getTimeUnterprojekt.get(boAnsprechpartner.getUnterprojektsrefId());
          
		  //
 Due to the fact that this is an InsertFinal rule we have to save the changed data again.
		  // Updating the same entry twice - like in this case - might cause infinite loops, because updating via BusinessObjectProvider
		  // activates the normal Nuclos save-process und might run the same rule again and again. So better be careful.
          BusinessObjectProvider.update(curBestellung boUnterprojekt.setAnsprechpartnerrefId(boAnsprechpartner.getId());
        
            boUnterprojekt.save();
          
    }
	}
}