Page tree
Skip to end of metadata
Go to start of metadata
Lernziel

Anlegen eines generischen BOs und implementierung einer generischen Regel

Voraussetzungen

Mindestens zwei Businessobjekte mit gleichen Feldinhalten (z.B. fortlaufende Nummer)

Referenz Nuclos-Handbuch

Official


 

Beispielfall 1: Nummernkreise

In einem Projekt gibt es mehrere BOs, die bei der Neuanlage eine automatische Nummer vom System vergeben bekommen.

Bei den betroffenen BOs handelt es sich um:

  • Angebot
  • Auftrag
  • Lieferschein
  • Bestellung

Die bisherige Implementierung wurde über Verwendung von instanceof gelöst (siehe Codeausschnitt rechts) und soll nun über ein Generisches BO abgelöst werden.

 

Bisherige Implementierung:
public void insert(InsertContext context) throws BusinessException {
        final Modifiable<?> businessObject = context.getBusinessObject(Modifiable.class);
        if (businessObject instanceof Angebot) {
            ((Angebot) businessObject).setAngebotsnr(NummernkreiseLogik.getNextValue(Angebot.class));
        } else if (businessObject instanceof Auftrag) {
            ((Auftrag) businessObject).setAuftragsnr(NummernkreiseLogik.getNextValue(Auftrag.class));
        } else if (businessObject instanceof Lieferschein) {
            ((Lieferschein) businessObject).setLieferscheinnr(NummernkreiseLogik.getNextValue(Lieferschein.class));
        } else if (businessObject instanceof Bestellung) {
            ((Bestellung) businessObject).setBestellnr(NummernkreiseLogik.getNextValue(Bestellung.class));
        } 
    }

Zunächst wird ein neues generisches Businessobjekt namens 'Nummerierbar' mit dem Businessobjekt erstellt.

Dieses BO erhält genau ein Attribut "Nummer".

Der Datentyp muss dem Datentyp des Feldes in den implentierenden BOs entsprechen !

Das BO enthält keine speziellen Berechtigungen und auch kein Layout. Es dient nur als abstraktes Businessobjekt für die Geschäftsregel bei der Nummergenerierung.

Das BO Nummerierbar wird einem beliebigen Nuclet zugewiesen.

Nun wird das Mapping für die generische Implementierung konfiguriert. Für jedes implementierende BO wird ein Datensatz mit dem entsprechenden Attribut-Mapping erzeugt. 

-> ->

Daraufhin wird vom System eine Klasse "Nummerierbar.java" erzeugt, die die entsprechenden generischen Konstruktoren und Funktionen enthält:

Nummerierbar.java
import org.nuclos.businessentity.*; 
import org.nuclos.api.businessobject.Dependent; 
import org.nuclos.api.businessobject.Flag; 
import org.nuclos.api.UID; 
import org.nuclos.api.businessobject.GenericBusinessObject; 
import java.util.List; 
import java.util.ArrayList; 
import java.util.HashSet; 
/**
 * BusinessObject: Nummerierbar
 *<br>
 *<br>Nuclet: org.nuclet.tulteclico
 *<br>DB-Name: [generic]
 *<br>Editable: true
 *<br>Localized: false
 *<br>Statemodel: false
**/
public class Nummerierbar implements GenericBusinessObject<Long> {
private org.nuclos.api.businessobject.BusinessObject<Long> businessObject;
public Nummerierbar(org.nuclet.tulteclico.Lieferschein businessObject) {
    this.businessObject = businessObject;
}
public Nummerierbar(org.nuclet.tulteclico.Bestellung businessObject) {
    this.businessObject = businessObject;
}
public Nummerierbar(org.nuclet.tulteclico.Auftrag businessObject) {
    this.businessObject = businessObject;
}
public Nummerierbar(org.nuclet.tulteclico.Angebot businessObject) {
    this.businessObject = businessObject;
}
public org.nuclos.api.UID getEntityUid() {
        return businessObject.getEntityUid();
}
public org.nuclos.api.businessobject.BusinessObject<Long> getBusinessObject() {
        return businessObject;
}
public java.lang.String getEntity() {
        return businessObject.getEntity();
}
public java.lang.Long getId() {
        return businessObject.getId();
}
public java.lang.Integer getVersion() {
        return businessObject.getVersion();
}
public boolean isInsert() {
        return businessObject.isInsert();
}
public boolean isUpdate() {
        return businessObject.isUpdate();
}
public boolean isDelete() {
        return businessObject.isDelete();
}
/**
 * Getter-Method for attribute: changedAt
 *<br>
 *<br>Entity: Nummerierbar
 *<br>DB-Name: DATCHANGED
 *<br>Data type: org.nuclos.common2.InternalTimestamp
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: null
 *<br>Precision: null
**/
public java.util.Date getChangedAt() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Lieferschein) {
        return ((org.nuclet.tulteclico.Lieferschein) this.businessObject).getChangedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Bestellung) {
        return ((org.nuclet.tulteclico.Bestellung) this.businessObject).getChangedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftrag) {
        return ((org.nuclet.tulteclico.Auftrag) this.businessObject).getChangedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebot) {
        return ((org.nuclet.tulteclico.Angebot) this.businessObject).getChangedAt();
    }
    // not implemented attribute:
    return null;
}
/**
 * Getter-Method for attribute: changedBy
 *<br>
 *<br>Entity: Nummerierbar
 *<br>DB-Name: STRCHANGED
 *<br>Data type: java.lang.String
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public java.lang.String getChangedBy() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Lieferschein) {
        return ((org.nuclet.tulteclico.Lieferschein) this.businessObject).getChangedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Bestellung) {
        return ((org.nuclet.tulteclico.Bestellung) this.businessObject).getChangedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftrag) {
        return ((org.nuclet.tulteclico.Auftrag) this.businessObject).getChangedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebot) {
        return ((org.nuclet.tulteclico.Angebot) this.businessObject).getChangedBy();
    }
    // not implemented attribute:
    return null;
}
/**
 * Getter-Method for attribute: createdAt
 *<br>
 *<br>Entity: Nummerierbar
 *<br>DB-Name: DATCREATED
 *<br>Data type: org.nuclos.common2.InternalTimestamp
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: null
 *<br>Precision: null
**/
public java.util.Date getCreatedAt() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Lieferschein) {
        return ((org.nuclet.tulteclico.Lieferschein) this.businessObject).getCreatedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Bestellung) {
        return ((org.nuclet.tulteclico.Bestellung) this.businessObject).getCreatedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftrag) {
        return ((org.nuclet.tulteclico.Auftrag) this.businessObject).getCreatedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebot) {
        return ((org.nuclet.tulteclico.Angebot) this.businessObject).getCreatedAt();
    }
    // not implemented attribute:
    return null;
}
/**
 * Getter-Method for attribute: createdBy
 *<br>
 *<br>Entity: Nummerierbar
 *<br>DB-Name: STRCREATED
 *<br>Data type: java.lang.String
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public java.lang.String getCreatedBy() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Lieferschein) {
        return ((org.nuclet.tulteclico.Lieferschein) this.businessObject).getCreatedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Bestellung) {
        return ((org.nuclet.tulteclico.Bestellung) this.businessObject).getCreatedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftrag) {
        return ((org.nuclet.tulteclico.Auftrag) this.businessObject).getCreatedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebot) {
        return ((org.nuclet.tulteclico.Angebot) this.businessObject).getCreatedBy();
    }
    // not implemented attribute:
    return null;
}
/**
 * Getter-Method for attribute: nummer
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Nummerierbar
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.String
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public java.lang.String getNummer() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Lieferschein) {
        return ((org.nuclet.tulteclico.Lieferschein) this.businessObject).getLieferscheinnr();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Bestellung) {
        return ((org.nuclet.tulteclico.Bestellung) this.businessObject).getBestellnr();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftrag) {
        return ((org.nuclet.tulteclico.Auftrag) this.businessObject).getAuftragsnr();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebot) {
        return ((org.nuclet.tulteclico.Angebot) this.businessObject).getAngebotsnr();
    }
    // not implemented attribute:
    return null;
}
/**
 * Setter-Method for attribute: nummer
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Nummerierbar
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.String
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public void setNummer(java.lang.String pNummer) {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Lieferschein) {
        ((org.nuclet.tulteclico.Lieferschein) this.businessObject).setLieferscheinnr(pNummer);
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Bestellung) {
        ((org.nuclet.tulteclico.Bestellung) this.businessObject).setBestellnr(pNummer);
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftrag) {
        ((org.nuclet.tulteclico.Auftrag) this.businessObject).setAuftragsnr(pNummer);
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebot) {
        ((org.nuclet.tulteclico.Angebot) this.businessObject).setAngebotsnr(pNummer);
    }
}
 }

 

 

Wir generieren nun im Server Regelmanager eine neue Regel, die bei der Neuanlage ausgeführt werden soll.

 

 

Diese Regel wird allen implementierenden BOs entsprechend zugewiesen.

Die Reihenfolge und weitere Bedingungen der Ausführung kann hierbei nach wie vor individuell vorgenommen werden.

Nun wird der Regelcode ausgearbeitet.

Zum Vergleich siehe den alten Regelcode (mit instanceof) oben.

Statt dem jeweiligen BusinessObject wird das generische BO "Nummerierbar" über den Context abgeholt. In der Klasse stehen jeweils die Getter und Setter der definierten Felder zur Verfügung.

 


Beispielfall 2: Summenberechnung in Belegpositionen

In einem Projekt gibt es BOs für Angebot, Auftrag und Rechnung. Alle diese BOs enthalten ein Unterformular mit Belegpositionen und Spalten für Einzelpreis, Menge und Gesamtpreis. In allen Fällen berechnet sich der Gesamtpreis:

 Gesamtpreis = Einzelpreis * Menge

Statt diese Implementierung in jedem BO einzeln vorzunehmen, möchten wir uns wieder dem Feature Generische Implementierung bedienen.

Die Berechnung findet in diesem Fall nur in den Belegpositionen statt. Dennoch benötigen wir jeweils ein generisches BO für den Hauptdatensatz und für das Unterformular. Wir erstellen also zwei Generische BOs:

  • Beleg (Attribute für Gesamtsummen)
  • Belegposition (mit den Attributen Einzelpreis, Menge, Gesamtpreis und Referenzfeld zum Beleg)

und erzeugen die benötigten Datensätze in der generischen Implementierung.

 

Das System erzeugt zwei generische Klassen:

Beleg.java
//Copyright (C) 2010  Novabit Informationssysteme GmbH
//
//This file is part of Nuclos.
//
//Nuclos is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//Nuclos is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with Nuclos.  If not, see <http://www.gnu.org/licenses/>.


package org.nuclet.tulteclico;


import org.nuclos.businessentity.*; 
import org.nuclos.api.businessobject.Dependent; 
import org.nuclos.api.businessobject.Flag; 
import org.nuclos.api.UID; 
import org.nuclos.api.businessobject.GenericBusinessObject; 
import java.util.List; 
import java.util.ArrayList; 
import java.util.HashSet; 

/**
 * BusinessObject: Beleg
 *<br>
 *<br>Nuclet: org.nuclet.tulteclico
 *<br>DB-Name: [generic]
 *<br>Editable: true
 *<br>Localized: false
 *<br>Statemodel: false
**/
public class Beleg implements GenericBusinessObject<Long> {

private org.nuclos.api.businessobject.BusinessObject<Long> businessObject;

public Beleg(org.nuclet.tulteclico.RechnungAusgang businessObject) {
    this.businessObject = businessObject;
}

public Beleg(org.nuclet.tulteclico.Auftrag businessObject) {
    this.businessObject = businessObject;
}

public Beleg(org.nuclet.tulteclico.Angebot businessObject) {
    this.businessObject = businessObject;
}

public org.nuclos.api.UID getEntityUid() {
        return businessObject.getEntityUid();
}

public org.nuclos.api.businessobject.BusinessObject<Long> getBusinessObject() {
        return businessObject;
}

public java.lang.String getEntity() {
        return businessObject.getEntity();
}

public java.lang.Long getId() {
        return businessObject.getId();
}

public java.lang.Integer getVersion() {
        return businessObject.getVersion();
}

public boolean isInsert() {
        return businessObject.isInsert();
}

public boolean isUpdate() {
        return businessObject.isUpdate();
}

public boolean isDelete() {
        return businessObject.isDelete();
}


/**
 * Getter-Method for attribute: createdAt
 *<br>
 *<br>Entity: Beleg
 *<br>DB-Name: DATCREATED
 *<br>Data type: org.nuclos.common2.InternalTimestamp
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: null
 *<br>Precision: null
**/
public java.util.Date getCreatedAt() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.RechnungAusgang) {
        return ((org.nuclet.tulteclico.RechnungAusgang) this.businessObject).getCreatedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftrag) {
        return ((org.nuclet.tulteclico.Auftrag) this.businessObject).getCreatedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebot) {
        return ((org.nuclet.tulteclico.Angebot) this.businessObject).getCreatedAt();
    }
    // not implemented attribute:
    return null;
}


/**
 * Getter-Method for attribute: createdBy
 *<br>
 *<br>Entity: Beleg
 *<br>DB-Name: STRCREATED
 *<br>Data type: java.lang.String
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public java.lang.String getCreatedBy() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.RechnungAusgang) {
        return ((org.nuclet.tulteclico.RechnungAusgang) this.businessObject).getCreatedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftrag) {
        return ((org.nuclet.tulteclico.Auftrag) this.businessObject).getCreatedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebot) {
        return ((org.nuclet.tulteclico.Angebot) this.businessObject).getCreatedBy();
    }
    // not implemented attribute:
    return null;
}


/**
 * Getter-Method for attribute: changedAt
 *<br>
 *<br>Entity: Beleg
 *<br>DB-Name: DATCHANGED
 *<br>Data type: org.nuclos.common2.InternalTimestamp
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: null
 *<br>Precision: null
**/
public java.util.Date getChangedAt() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.RechnungAusgang) {
        return ((org.nuclet.tulteclico.RechnungAusgang) this.businessObject).getChangedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftrag) {
        return ((org.nuclet.tulteclico.Auftrag) this.businessObject).getChangedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebot) {
        return ((org.nuclet.tulteclico.Angebot) this.businessObject).getChangedAt();
    }
    // not implemented attribute:
    return null;
}


/**
 * Getter-Method for attribute: changedBy
 *<br>
 *<br>Entity: Beleg
 *<br>DB-Name: STRCHANGED
 *<br>Data type: java.lang.String
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public java.lang.String getChangedBy() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.RechnungAusgang) {
        return ((org.nuclet.tulteclico.RechnungAusgang) this.businessObject).getChangedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftrag) {
        return ((org.nuclet.tulteclico.Auftrag) this.businessObject).getChangedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebot) {
        return ((org.nuclet.tulteclico.Angebot) this.businessObject).getChangedBy();
    }
    // not implemented attribute:
    return null;
}


/**
 * Getter-Method for attribute: beleg
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.String
 *<br>Reference entity: Beleg
 *<br>Reference field: changedBy
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public List<org.nuclet.tulteclico.Belegposition> getBelegposition(Flag... flags) {
    List<org.nuclet.tulteclico.Belegposition> result = new ArrayList<>();
    if (this.businessObject instanceof org.nuclet.tulteclico.RechnungAusgang) {
        for (org.nuclet.tulteclico.Rechnungsposition sub : ((org.nuclet.tulteclico.RechnungAusgang) this.businessObject).getRechnungsposition(flags)) {
            org.nuclet.tulteclico.Belegposition subGBO = new org.nuclet.tulteclico.Belegposition(sub);
            result.add(subGBO);
        }
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftrag) {
        for (org.nuclet.tulteclico.Auftragsposition sub : ((org.nuclet.tulteclico.Auftrag) this.businessObject).getAuftragsposition(flags)) {
            org.nuclet.tulteclico.Belegposition subGBO = new org.nuclet.tulteclico.Belegposition(sub);
            result.add(subGBO);
        }
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebot) {
        for (org.nuclet.tulteclico.Angebotsposition sub : ((org.nuclet.tulteclico.Angebot) this.businessObject).getAngebotsposition(flags)) {
            org.nuclet.tulteclico.Belegposition subGBO = new org.nuclet.tulteclico.Belegposition(sub);
            result.add(subGBO);
        }
    }
    return result;

}


/**
 * Insert-Method for attribute: beleg
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.String
 *<br>Reference entity: Beleg
 *<br>Reference field: changedBy
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public void insertBelegposition(org.nuclet.tulteclico.Belegposition pBelegposition) {
    if (this.businessObject instanceof org.nuclet.tulteclico.RechnungAusgang) {
        ((org.nuclet.tulteclico.RechnungAusgang) this.businessObject).insertRechnungsposition((org.nuclet.tulteclico.Rechnungsposition)pBelegposition.getBusinessObject());
    }
if (this.businessObject instanceof org.nuclet.tulteclico.Auftrag) {
        ((org.nuclet.tulteclico.Auftrag) this.businessObject).insertAuftragsposition((org.nuclet.tulteclico.Auftragsposition)pBelegposition.getBusinessObject());
    }
if (this.businessObject instanceof org.nuclet.tulteclico.Angebot) {
        ((org.nuclet.tulteclico.Angebot) this.businessObject).insertAngebotsposition((org.nuclet.tulteclico.Angebotsposition)pBelegposition.getBusinessObject());
    }

}


/**
 * Delete-Method for attribute: beleg
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.String
 *<br>Reference entity: Beleg
 *<br>Reference field: changedBy
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public void deleteBelegposition(org.nuclet.tulteclico.Belegposition pBelegposition) {
    if (this.businessObject instanceof org.nuclet.tulteclico.RechnungAusgang) {
        ((org.nuclet.tulteclico.RechnungAusgang) this.businessObject).deleteRechnungsposition((org.nuclet.tulteclico.Rechnungsposition)pBelegposition.getBusinessObject());
    }
if (this.businessObject instanceof org.nuclet.tulteclico.Auftrag) {
        ((org.nuclet.tulteclico.Auftrag) this.businessObject).deleteAuftragsposition((org.nuclet.tulteclico.Auftragsposition)pBelegposition.getBusinessObject());
    }
if (this.businessObject instanceof org.nuclet.tulteclico.Angebot) {
        ((org.nuclet.tulteclico.Angebot) this.businessObject).deleteAngebotsposition((org.nuclet.tulteclico.Angebotsposition)pBelegposition.getBusinessObject());
    }

}
 }

Belegposition.java
//Copyright (C) 2010  Novabit Informationssysteme GmbH
//
//This file is part of Nuclos.
//
//Nuclos is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//Nuclos is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with Nuclos.  If not, see <http://www.gnu.org/licenses/>.


package org.nuclet.tulteclico;


import org.nuclos.businessentity.*; 
import org.nuclos.api.businessobject.Dependent; 
import org.nuclos.api.businessobject.Flag; 
import org.nuclos.api.UID; 
import org.nuclos.api.businessobject.GenericBusinessObject; 
import java.util.List; 
import java.util.ArrayList; 
import java.util.HashSet; 

/**
 * BusinessObject: Belegposition
 *<br>
 *<br>Nuclet: org.nuclet.tulteclico
 *<br>DB-Name: [generic]
 *<br>Editable: true
 *<br>Localized: false
 *<br>Statemodel: false
**/
public class Belegposition implements GenericBusinessObject<Long> {

private org.nuclos.api.businessobject.BusinessObject<Long> businessObject;

public Belegposition(org.nuclet.tulteclico.Rechnungsposition businessObject) {
    this.businessObject = businessObject;
}

public Belegposition(org.nuclet.tulteclico.Auftragsposition businessObject) {
    this.businessObject = businessObject;
}

public Belegposition(org.nuclet.tulteclico.Angebotsposition businessObject) {
    this.businessObject = businessObject;
}

public org.nuclos.api.UID getEntityUid() {
        return businessObject.getEntityUid();
}

public org.nuclos.api.businessobject.BusinessObject<Long> getBusinessObject() {
        return businessObject;
}

public java.lang.String getEntity() {
        return businessObject.getEntity();
}

public java.lang.Long getId() {
        return businessObject.getId();
}

public java.lang.Integer getVersion() {
        return businessObject.getVersion();
}

public boolean isInsert() {
        return businessObject.isInsert();
}

public boolean isUpdate() {
        return businessObject.isUpdate();
}

public boolean isDelete() {
        return businessObject.isDelete();
}


/**
 * Getter-Method for attribute: changedBy
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: STRCHANGED
 *<br>Data type: java.lang.String
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public java.lang.String getChangedBy() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        return ((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).getChangedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        return ((org.nuclet.tulteclico.Auftragsposition) this.businessObject).getChangedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        return ((org.nuclet.tulteclico.Angebotsposition) this.businessObject).getChangedBy();
    }
    // not implemented attribute:
    return null;
}


/**
 * Getter-Method for attribute: changedAt
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: DATCHANGED
 *<br>Data type: org.nuclos.common2.InternalTimestamp
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: null
 *<br>Precision: null
**/
public java.util.Date getChangedAt() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        return ((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).getChangedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        return ((org.nuclet.tulteclico.Auftragsposition) this.businessObject).getChangedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        return ((org.nuclet.tulteclico.Angebotsposition) this.businessObject).getChangedAt();
    }
    // not implemented attribute:
    return null;
}


/**
 * Getter-Method for attribute: createdBy
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: STRCREATED
 *<br>Data type: java.lang.String
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public java.lang.String getCreatedBy() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        return ((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).getCreatedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        return ((org.nuclet.tulteclico.Auftragsposition) this.businessObject).getCreatedBy();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        return ((org.nuclet.tulteclico.Angebotsposition) this.businessObject).getCreatedBy();
    }
    // not implemented attribute:
    return null;
}


/**
 * Getter-Method for attribute: gesamtpreis
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.Double
 *<br>Localized: false
 *<br>Output format: #,##0.00
 *<br>Scale: 9
 *<br>Precision: 2
**/
public java.math.BigDecimal getGesamtpreis() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        return ((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).getGesamtpreis();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        return ((org.nuclet.tulteclico.Auftragsposition) this.businessObject).getGesamtpreis();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        return ((org.nuclet.tulteclico.Angebotsposition) this.businessObject).getGesamtpreis();
    }
    // not implemented attribute:
    return null;
}


/**
 * Setter-Method for attribute: gesamtpreis
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.Double
 *<br>Localized: false
 *<br>Output format: #,##0.00
 *<br>Scale: 9
 *<br>Precision: 2
**/
public void setGesamtpreis(java.math.BigDecimal pGesamtpreis) {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        ((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).setGesamtpreis(pGesamtpreis);
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        ((org.nuclet.tulteclico.Auftragsposition) this.businessObject).setGesamtpreis(pGesamtpreis);
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        ((org.nuclet.tulteclico.Angebotsposition) this.businessObject).setGesamtpreis(pGesamtpreis);
    }

}


/**
 * Getter-Method for attribute: createdAt
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: DATCREATED
 *<br>Data type: org.nuclos.common2.InternalTimestamp
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: null
 *<br>Precision: null
**/
public java.util.Date getCreatedAt() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        return ((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).getCreatedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        return ((org.nuclet.tulteclico.Auftragsposition) this.businessObject).getCreatedAt();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        return ((org.nuclet.tulteclico.Angebotsposition) this.businessObject).getCreatedAt();
    }
    // not implemented attribute:
    return null;
}


/**
 * Getter-Method for attribute: einzelpreis
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.Double
 *<br>Localized: false
 *<br>Output format: #,##0.00
 *<br>Scale: 9
 *<br>Precision: 2
**/
public java.math.BigDecimal getEinzelpreis() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        return ((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).getEinzelpreis();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        return ((org.nuclet.tulteclico.Auftragsposition) this.businessObject).getEinzelpreis();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        return ((org.nuclet.tulteclico.Angebotsposition) this.businessObject).getEinzelpreis();
    }
    // not implemented attribute:
    return null;
}


/**
 * Setter-Method for attribute: einzelpreis
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.Double
 *<br>Localized: false
 *<br>Output format: #,##0.00
 *<br>Scale: 9
 *<br>Precision: 2
**/
public void setEinzelpreis(java.math.BigDecimal pEinzelpreis) {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        ((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).setEinzelpreis(pEinzelpreis);
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        ((org.nuclet.tulteclico.Auftragsposition) this.businessObject).setEinzelpreis(pEinzelpreis);
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        ((org.nuclet.tulteclico.Angebotsposition) this.businessObject).setEinzelpreis(pEinzelpreis);
    }

}


/**
 * Getter-Method for attribute: menge
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.Integer
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 9
 *<br>Precision: null
**/
public java.lang.Integer getMenge() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        return ((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).getPos();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        return ((org.nuclet.tulteclico.Auftragsposition) this.businessObject).getPos();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        return ((org.nuclet.tulteclico.Angebotsposition) this.businessObject).getPos();
    }
    // not implemented attribute:
    return null;
}


/**
 * Setter-Method for attribute: menge
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.Integer
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 9
 *<br>Precision: null
**/
public void setMenge(java.lang.Integer pMenge) {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        ((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).setPos(pMenge);
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        ((org.nuclet.tulteclico.Auftragsposition) this.businessObject).setPos(pMenge);
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        ((org.nuclet.tulteclico.Angebotsposition) this.businessObject).setPos(pMenge);
    }

}


/**
 * Getter-Method for attribute: beleg
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.String
 *<br>Reference entity: Beleg
 *<br>Reference field: changedBy
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public java.lang.String getBeleg() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        return ((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).getRechnung();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        return ((org.nuclet.tulteclico.Auftragsposition) this.businessObject).getAuftrag();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        return ((org.nuclet.tulteclico.Angebotsposition) this.businessObject).getAngebot();
    }
    // not implemented attribute:
    return null;
}


/**
 * Getter-Method for attribute: beleg
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.String
 *<br>Reference entity: Beleg
 *<br>Reference field: changedBy
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public java.lang.Long getBelegId() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        return ((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).getRechnungId();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        return ((org.nuclet.tulteclico.Auftragsposition) this.businessObject).getAuftragId();
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        return ((org.nuclet.tulteclico.Angebotsposition) this.businessObject).getAngebotId();
    }
    // not implemented attribute:
    return null;
}


/**
 * Setter-Method for attribute: beleg
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.String
 *<br>Reference entity: Beleg
 *<br>Reference field: changedBy
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public void setBelegId(java.lang.Long pBelegId) {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        ((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).setRechnungId(pBelegId);
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        ((org.nuclet.tulteclico.Auftragsposition) this.businessObject).setAuftragId(pBelegId);
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        ((org.nuclet.tulteclico.Angebotsposition) this.businessObject).setAngebotId(pBelegId);
    }

}


/**
 * Getter-Method for attribute: beleg
 *<br>
 *<br>Attribute Information:<br>
 *<br>
 *<br>Entity: Belegposition
 *<br>DB-Name: [generic]
 *<br>Data type: java.lang.String
 *<br>Reference entity: Beleg
 *<br>Reference field: changedBy
 *<br>Localized: false
 *<br>Output format: null
 *<br>Scale: 255
 *<br>Precision: null
**/
public org.nuclet.tulteclico.Beleg getBelegBO() {
    // all implemented BOs:
    if (this.businessObject instanceof org.nuclet.tulteclico.Rechnungsposition) {
        return new org.nuclet.tulteclico.Beleg(((org.nuclet.tulteclico.Rechnungsposition) this.businessObject).getRechnungBO());
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Auftragsposition) {
        return new org.nuclet.tulteclico.Beleg(((org.nuclet.tulteclico.Auftragsposition) this.businessObject).getAuftragBO());
    }
    if (this.businessObject instanceof org.nuclet.tulteclico.Angebotsposition) {
        return new org.nuclet.tulteclico.Beleg(((org.nuclet.tulteclico.Angebotsposition) this.businessObject).getAngebotBO());
    }
    // not implemented attribute:
    return null;
}
 }

Die Regel wird im Regelmanager allen relevanten BOs zugewiesen und der Regelcode entsprechend programmiert