Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 13.00 KB | None | 0 0
  1. package de.swe1.bestellverwaltung.domain;
  2.  
  3. import static javax.xml.bind.annotation.XmlAccessType.FIELD;
  4. import static javax.persistence.CascadeType.PERSIST;
  5. import static javax.persistence.CascadeType.REMOVE;
  6. import java.io.Serializable;
  7. import java.net.URI;
  8.  
  9. import javax.persistence.Column;
  10. import javax.persistence.Entity;
  11. import javax.persistence.FetchType;
  12. import javax.persistence.GeneratedValue;
  13. import javax.persistence.GenerationType;
  14. import javax.persistence.Id;
  15. import javax.persistence.JoinColumn;
  16. import javax.persistence.ManyToOne;
  17. import javax.persistence.NamedQueries;
  18. import javax.persistence.NamedQuery;
  19. import javax.persistence.OneToMany;
  20. import javax.persistence.Table;
  21. import javax.persistence.Temporal;
  22. import javax.persistence.TemporalType;
  23. import javax.persistence.Transient;
  24. import javax.persistence.Version;
  25. import javax.validation.Valid;
  26. import javax.validation.constraints.Min;
  27. import javax.validation.constraints.NotNull;
  28. import javax.xml.bind.annotation.XmlAccessorType;
  29. import javax.xml.bind.annotation.XmlAttribute;
  30. import javax.xml.bind.annotation.XmlElement;
  31. import javax.xml.bind.annotation.XmlElementWrapper;
  32. import javax.xml.bind.annotation.XmlRootElement;
  33. import javax.xml.bind.annotation.XmlTransient;
  34.  
  35. import org.hibernate.validator.constraints.NotEmpty;
  36.  
  37. import de.swe1.kundenverwaltung.domain.Kunde;
  38. import de.swe1.util.IdGroup;
  39. import de.swe1.util.PreExistingGroup;
  40.  
  41. import java.util.Date;
  42. import java.util.List;
  43.  
  44. /**
  45.  * The persistent class for the bestellung database table.
  46.  */
  47. @Entity
  48. @Table(name = "bestellung")
  49.  
  50. @NamedQueries({
  51.  
  52.         @NamedQuery(name = Bestellung.FIND_BESTELLUNG_BY_IDBESTELLUNG,
  53.                     query = "Select b "
  54.                           + "From Bestellung b "
  55.                           + "Where b.id=:" + Bestellung.PARAM_BESTELLUNG_IDBESTELLUNG),
  56.        
  57.         @NamedQuery(name = Bestellung.FIND_BESTELLUNG_BY_KUNDE_IDKUNDE,
  58.                     query = "Select b "
  59.                           + "From Bestellung b "
  60.                           + "Where b.kunde.idKunde=:" + Bestellung.PARAM_BESTELLUNG_KUNDE_IDKUNDE),
  61.                          
  62.         @NamedQuery(name = Bestellung.FIND_BESTELLUNG_BY_KUNDE_LOGINKUNDE,
  63.                     query = "Select b "
  64.                           + "From Bestellung b "
  65.                           + "Where b.kunde.loginname=:" + Bestellung.PARAM_BESTELLUNG_KUNDE_LOGINKUNDE),
  66.                    
  67.         @NamedQuery(name = Bestellung.FIND_KUNDE_BY_IDBESTELLUNG,
  68.                     query = "Select b.kunde "
  69.                           + "From Bestellung b "
  70.                           + "Where b.id=:" + Bestellung.PARAM_BESTELLUNG_IDBESTELLUNG),
  71.                          
  72.         @NamedQuery(name = Bestellung.FIND_BESTELLUNG_BY_TRACKINGNUMMER,
  73.                     query = "Select b "
  74.                           + "From Bestellung b "
  75.                           + "Where b.trackingnummer=:" + Bestellung.PARAM_BESTELLUNG_TRACKINGNUMMER),
  76.                  
  77.         @NamedQuery(name = Bestellung.FIND_BESTELLUNG_BY_STATUS,
  78.                     query = "Select b "
  79.                           + "From Bestellung b "
  80.                           + "Where b.status=:" + Bestellung.PARAM_BESTELLUNG_STATUS),
  81.                          
  82.         @NamedQuery(name = Bestellung.FIND_BESTELLUNG_BY_KOMPLETT,
  83.                     query = "Select b "
  84.                           + "From Bestellung b "
  85.                           + "Where b.bestellungKomplett=:" + Bestellung.PARAM_BESTELLUNG_KOMPLETT),
  86.                          
  87.         @NamedQuery(name = Bestellung.FIND_BESTELLUNG_BY_EINGANG,
  88.                     query = "Select b "
  89.                           + "From Bestellung b "
  90.                           + "Where b.bestellungEingang=:" + Bestellung.PARAM_BESTELLUNG_EINGANG),
  91.                    
  92.         @NamedQuery(name = Bestellung.COUNT_BESTELLUNG_BY_KUNDE_GESCHLECHT,
  93.                     query = "Select Count(b) "
  94.                           + "FROM Bestellung b "
  95.                           + "Where b.kunde.geschlecht=:" + Bestellung.PARAM_BESTELLUNG_KUNDE_GESCHLECHT),
  96.  
  97.         @NamedQuery(name = Bestellung.COUNT_BESTELLUNG_BY_KUNDE_ANSCHRIFT_PLZ,
  98.                     query = "Select Count(b)"
  99.                           + "FROM Bestellung b "
  100.                           + "Where b.kunde.anschrift.plz =:" + Bestellung.PARAM_BESTELLUNG_KUNDE_ANSCHRIFT_PLZ)
  101.  
  102. })
  103. @XmlRootElement
  104. @XmlAccessorType(FIELD)
  105. public class Bestellung implements Serializable {
  106.    
  107.     /** The Constant serialVersionUID. */
  108.     private static final long serialVersionUID = 1L;
  109.    
  110.     //String-Konstanten fuer die @Named-Queries
  111.     /** The Constant PREFIX. */
  112.     public static final String PREFIX = "Bestellung.";
  113.    
  114.     /** The Constant FIND_BESTELLUNG. */
  115.     public static final String FIND_BESTELLUNG = PREFIX + "FindBestellung.";
  116.    
  117.     /** The Constant FIND_BESTELLUNG_BY_IDBESTELLUNG. */
  118.     public static final String FIND_BESTELLUNG_BY_IDBESTELLUNG = FIND_BESTELLUNG  + "ById";
  119.    
  120.     /** The Constant FIND_BESTELLUNG_BY_STATUS. */
  121.     public static final String FIND_BESTELLUNG_BY_STATUS = FIND_BESTELLUNG + "ByStatus";
  122.    
  123.     /** The Constant FIND_BESTELLUNG_BY_TRACKINGNUMMER. */
  124.     public static final String FIND_BESTELLUNG_BY_TRACKINGNUMMER = FIND_BESTELLUNG  + "ByTrackingnummer";
  125.    
  126.     /** The Constant FIND_BESTELLUNG_BY_KOMPLETT. */
  127.     public static final String FIND_BESTELLUNG_BY_KOMPLETT = FIND_BESTELLUNG  + "ByKomplett";
  128.    
  129.     /** The Constant FIND_BESTELLUNG_BY_EINGANG. */
  130.     public static final String FIND_BESTELLUNG_BY_EINGANG = FIND_BESTELLUNG  + "ByEingang";
  131.    
  132.     /** The Constant FIND_BESTELLUNG_BY_KUNDE_IDKUNDE. */
  133.     public static final String FIND_BESTELLUNG_BY_KUNDE_IDKUNDE = FIND_BESTELLUNG  + "ByKundeIdKunde";
  134.    
  135.     /** The Constant FIND_BESTELLUNG_BY_KUNDE_LOGINKUNDE. */
  136.     public static final String FIND_BESTELLUNG_BY_KUNDE_LOGINKUNDE = FIND_BESTELLUNG  + "ByKundeLoginKunde";
  137.    
  138.    
  139.     /** The Constant FIND_KUNDE_BY_IDBESTELLUNG. */
  140.     public static final String FIND_KUNDE_BY_IDBESTELLUNG = PREFIX + "Find_KundeByIdBestllung";
  141.    
  142.     /** The Constant COUNT_BESTELLUNG_BY_KUNDE_GESCHLECHT. */
  143.     public static final String COUNT_BESTELLUNG_BY_KUNDE_GESCHLECHT = PREFIX + "CountBestellungByKunde.Geschlecht";
  144.    
  145.     /** The Constant COUNT_BESTELLUNG_BY_KUNDE_ANSCHRIFT_PLZ. */
  146.     public static final String COUNT_BESTELLUNG_BY_KUNDE_ANSCHRIFT_PLZ = PREFIX + "CountBestellungByKunde.Anschrift.Plz";
  147.    
  148.     //Parameter fuer die @Named-Queries
  149.     /** The Constant PARAM_BESTELLUNG_IDBESTELLUNG. */
  150.     public static final String PARAM_BESTELLUNG_IDBESTELLUNG = "id";
  151.    
  152.     /** The Constant PARAM_BESTELLUNG_STATUS. */
  153.     public static final String PARAM_BESTELLUNG_STATUS = "status";
  154.    
  155.     /** The Constant PARAM_BESTELLUNG_TRACKINGNUMMER. */
  156.     public static final String PARAM_BESTELLUNG_TRACKINGNUMMER = "trackingnummer";
  157.    
  158.     /** The Constant PARAM_BESTELLUNG_KOMPLETT. */
  159.     public static final String PARAM_BESTELLUNG_KOMPLETT = "komplett";
  160.    
  161.     /** The Constant PARAM_BESTELLUNG_EINGANG. */
  162.     public static final String PARAM_BESTELLUNG_EINGANG = "eingangDatum";
  163.    
  164.     /** The Constant PARAM_BESTELLUNG_KUNDE_IDKUNDE. */
  165.     public static final String PARAM_BESTELLUNG_KUNDE_IDKUNDE = "idKunde";
  166.    
  167.     /** The Constant PARAM_BESTELLUNG_KUNDE_LOGINKUNDE. */
  168.     public static final String PARAM_BESTELLUNG_KUNDE_LOGINKUNDE = "loginKunde";
  169.    
  170.     /** The Constant PARAM_BESTELLUNG_KUNDE_GESCHLECHT. */
  171.     public static final String PARAM_BESTELLUNG_KUNDE_GESCHLECHT = "geschlechtKunde";
  172.    
  173.     /** The Constant PARAM_BESTELLUNG_KUNDE_ANSCHRIFT_PLZ. */
  174.     public static final String PARAM_BESTELLUNG_KUNDE_ANSCHRIFT_PLZ = "kundeAnschriftPlz";
  175.    
  176.     /** The Constant MIN_ID. */
  177.     public static final int MIN_ID = 0;
  178.    
  179.     public static final int ERSTE_VERSION = 0;
  180.  
  181.     /** The id. @uml.property name = "id" */
  182.     @Id
  183.     @GeneratedValue(strategy = GenerationType.AUTO)
  184.     @Column(name = "id_bestellung")
  185.     @Min(value = MIN_ID, message = "{bestellverwaltung.bestellung.id.min}", groups = IdGroup.class)
  186.     @XmlAttribute(name = "id", required = true)
  187.     private int id;
  188.  
  189.     /** The bestellung eingang. @uml.property name = "bestellungEingang" */
  190.     @Temporal(TemporalType.TIMESTAMP)
  191.     @Column(name = "bestellung_eingang")
  192.     private Date bestellungEingang = new Date();
  193.  
  194.     /** The bestellung komplett. @uml.property name = "bestellungKomplett" */
  195.     @Temporal(TemporalType.TIMESTAMP)
  196.     @Column(name = "bestellung_komplett")
  197.     @XmlElement(name = "bestellung_komplett")
  198.     private Date bestellungKomplett =  new Date();
  199.  
  200.     /** The rechnung id rechnung. @uml.property name = "rechnungIdRechnung" */
  201.     @Column(name = "rechnung_id_rechnung")
  202.     private String rechnungIdRechnung;
  203.  
  204.     /** The status. @uml.property name = "status" */
  205.     private String status;
  206.  
  207.     /** The trackingnummer. @uml.property name = "trackingnummer" */
  208.     private String trackingnummer;
  209.  
  210.     //bi-directional many-to-one association to Kunde
  211.     /** The kunde. @uml.property name = "kunde" @uml.associationEnd */
  212.     @ManyToOne(fetch = FetchType.EAGER)
  213.     @NotNull(message = "{bestellverwaltung.bestellung.kunde.notNull}", groups = PreExistingGroup.class)
  214.     @XmlTransient
  215.     private Kunde kunde;
  216.  
  217.     //bi-directional many-to-one association to Bestellposition
  218.     /** The bestellpositionen. @uml.property  name = "bestellpositionen" */
  219.     @OneToMany(fetch = FetchType.EAGER, cascade = { PERSIST, REMOVE }, orphanRemoval = true)
  220.     @JoinColumn(name = "bestellung_id_bestellung")
  221.     @NotEmpty(message = "{bestellverwaltung.bestellung.bestellpositionen.notEmpty}")
  222.     @Valid
  223.     @XmlElementWrapper(name = "bestellpositionen")
  224.     @XmlElement(name = "bestellposition")
  225.     private List<Bestellposition> bestellpositionen;
  226.    
  227.     @Version
  228.     @XmlTransient
  229.     private int version = ERSTE_VERSION;
  230.    
  231.     /** The kunde uri. */
  232.     @Transient
  233.     @XmlElement(name = "kunde")
  234.     private URI kundeUri;
  235.  
  236.     /**
  237.      * Instantiates a new bestellung.
  238.      */
  239.     public Bestellung() {
  240.         bestellungEingang = new Date();
  241.     }
  242.  
  243.     /**
  244.      * Gets the id.
  245.      *
  246.      * @return the id
  247.      * @uml.property name = "id"
  248.      */
  249.     public int getId() {
  250.         return this.id;
  251.     }
  252.  
  253.     /**
  254.      * Sets the id.
  255.      *
  256.      * @param id the new id
  257.      * @uml.property name = "id"
  258.      */
  259.     public void setId(int id) {
  260.         this.id = id;
  261.     }
  262.  
  263.     /**
  264.      * Gets the bestellung eingang.
  265.      *
  266.      * @return the bestellung eingang
  267.      * @uml.property name = "bestellungEingang"
  268.      */
  269.     public Date getBestellungEingang() {
  270.         return this.bestellungEingang;
  271.     }
  272.  
  273.     /**
  274.      * Sets the bestellung eingang.
  275.      *
  276.      * @param bestellungEingang the new bestellung eingang
  277.      * @uml.property name = "bestellungEingang"
  278.      */
  279.     public void setBestellungEingang(Date bestellungEingang) {
  280.         this.bestellungEingang = bestellungEingang;
  281.     }
  282.  
  283.     /**
  284.      * Gets the bestellung komplett.
  285.      *
  286.      * @return the bestellung komplett
  287.      * @uml.property name = "bestellungKomplett"
  288.      */
  289.     public Date getBestellungKomplett() {
  290.         return this.bestellungKomplett;
  291.     }
  292.  
  293.     /**
  294.      * Sets the bestellung komplett.
  295.      *
  296.      * @param bestellungKomplett the new bestellung komplett
  297.      * @uml.property name = "bestellungKomplett"
  298.      */
  299.     public void setBestellungKomplett(Date bestellungKomplett) {
  300.         this.bestellungKomplett = bestellungKomplett;
  301.     }
  302.  
  303.     /**
  304.      * Gets the rechnung id rechnung.
  305.      *
  306.      * @return the rechnung id rechnung
  307.      * @uml.property name = "rechnungIdRechnung"
  308.      */
  309.     public String getRechnungIdRechnung() {
  310.         return this.rechnungIdRechnung;
  311.     }
  312.  
  313.     /**
  314.      * Sets the rechnung id rechnung.
  315.      *
  316.      * @param rechnungIdRechnung the new rechnung id rechnung
  317.      * @uml.property name = "rechnungIdRechnung"
  318.      */
  319.     public void setRechnungIdRechnung(String rechnungIdRechnung) {
  320.         this.rechnungIdRechnung = rechnungIdRechnung;
  321.     }
  322.  
  323.     /**
  324.      * Gets the status.
  325.      *
  326.      * @return the status
  327.      * @uml.property name = "status"
  328.      */
  329.     public String getStatus() {
  330.         return this.status;
  331.     }
  332.  
  333.     /**
  334.      * Sets the status.
  335.      *
  336.      * @param status the new status
  337.      * @uml.property name = "status"
  338.      */
  339.     public void setStatus(String status) {
  340.         this.status = status;
  341.     }
  342.  
  343.     /**
  344.      * Gets the trackingnummer.
  345.      *
  346.      * @return the trackingnummer
  347.      * @uml.property name = "trackingnummer"
  348.      */
  349.     public String getTrackingnummer() {
  350.         return this.trackingnummer;
  351.     }
  352.  
  353.     /**
  354.      * Sets the trackingnummer.
  355.      *
  356.      * @param trackingnummer the new trackingnummer
  357.      * @uml.property name = "trackingnummer"
  358.      */
  359.     public void setTrackingnummer(String trackingnummer) {
  360.         this.trackingnummer = trackingnummer;
  361.     }
  362.  
  363.     /**
  364.      * Gets the kunde.
  365.      *
  366.      * @return the kunde
  367.      * @uml.property name = "kunde"
  368.      */
  369.     public Kunde getKunde() {
  370.         return this.kunde;
  371.     }
  372.  
  373.     /**
  374.      * Sets the kunde.
  375.      *
  376.      * @param kunde the new kunde
  377.      * @uml.property name = "kunde"
  378.      */
  379.     public void setKunde(Kunde kunde) {
  380.         this.kunde = kunde;
  381.     }
  382.  
  383.     /**
  384.      * Sets the bestellpositionen.
  385.      *
  386.      * @param bestellpositionen the new bestellpositionen
  387.      * @uml.property name = "bestellpositionen"
  388.      */
  389.     public void setBestellpositionen(List<Bestellposition> bestellpositionen) {
  390.         this.bestellpositionen = bestellpositionen;
  391.     }
  392.  
  393.     /**
  394.      * Gets the bestellpositionen.
  395.      *
  396.      * @return the bestellpositionen
  397.      * @uml.property name = "bestellpositionen"
  398.      */
  399.     public List<Bestellposition> getBestellpositionen() {
  400.         return bestellpositionen;
  401.     }
  402.  
  403.     /**
  404.      * Sets the kunde uri.
  405.      *
  406.      * @param kundeUri the new kunde uri
  407.      */
  408.     public void setKundeUri(URI kundeUri) {
  409.         this.kundeUri = kundeUri;
  410.     }
  411.  
  412.     /**
  413.      * Gets the kunde uri.
  414.      *
  415.      * @return the kunde uri
  416.      */
  417.     public URI getKundeUri() {
  418.         return kundeUri;
  419.     }
  420.  
  421.     /**
  422.      * Gets the id kunde.
  423.      *
  424.      * @return the id kunde
  425.      */
  426.     public Object getIdKunde() {
  427.         Object idKunde = this.getKunde().getIdKunde();
  428.         return idKunde;
  429.     }
  430.  
  431.     public void setVersion(int version) {
  432.         this.version = version;
  433.     }
  434.  
  435.     public int getVersion() {
  436.         return version;
  437.     }
  438. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement