// Path: my-aktion/src/main/java/de/dpunkt/myaktion/data/CampaignProducer.java
// @SessionScoped
// public class CampaignProducer implements Serializable {
// 
//     private static final long serialVersionUID = -1828660647917534556L;
// 
//     private enum Mode {
//         EDIT, ADD
//     }
// 
//     private Campaign campaign;
//     private Mode mode;
// 
//     @Produces
//     @Named
//     public Campaign getSelectedCampaign() {
//         return campaign;
//     }
// 
//     public void setSelectedCampaign(Campaign campaign) {
//         this.campaign = campaign;
//     }
// 
//     @Produces
//     @Named
//     public boolean isAddMode() {
//         return mode == Mode.ADD;
//     }
// 
//     public void prepareAddCampaign() {
//         this.campaign = new Campaign();
//         this.mode = Mode.ADD;
//     }
// 
//     public void prepareEditCampaign(Campaign campaign) {
//         this.campaign = campaign;
//         this.mode = Mode.EDIT;
//     }
// 
// }
// 
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Campaign.java
// @NamedQueries({
//         @NamedQuery(name = Campaign.findByOrganizer, query = "SELECT c FROM Campaign c WHERE c.organizer = :organizer ORDER BY c.name"),
//         @NamedQuery(name = Campaign.findAll, query = "SELECT a FROM Campaign a ORDER BY a.name"),
//         @NamedQuery(name = Campaign.getAmountDonatedSoFar, query = "SELECT SUM(d.amount) FROM Donation d WHERE d.campaign = :campaign")
// })
// @Entity
// public class Campaign {
//     public static final String findByOrganizer = "Campaign.findByOrganizer";
//     public static final String findAll = "Campaign.findAll";
//     public static final String getAmountDonatedSoFar = "Campaign.getAmountDonatedSoFar";
// 
//     @NotNull
//     @Size(min = 4, max = 30, message = "{campaign.name.size}")
//     private String name;
// 
//     @NotNull(message = "{campaign.targetAmount.notNull}")
//     @DecimalMin(value = "10.00", message = "{campaign.targetAmount.decimalMin}")
//     private Double targetAmount;
// 
//     @NotNull(message = "{campaign.donationMinimum.notNull}")
//     @DecimalMin(value = "1.00", message = "{campaign.donationMinimum.decimalMin}")
//     private Double donationMinimum;
// 
//     @Transient
//     private Double amountDonatedSoFar;
// 
//     @AttributeOverrides({@AttributeOverride(name = "name", column = @Column(name = "accountName"))})
//     @Embedded
//     private Account account;
// 
//     @GeneratedValue
//     @Id
//     private Long id;
// 
//     @OneToMany(mappedBy = "campaign", cascade = CascadeType.REMOVE)
//     private List<Donation> donations;
// 
//     @ManyToOne
//     private Organizer organizer;
// 
//     public Campaign() {
//         account = new Account();
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public Double getTargetAmount() {
//         return targetAmount;
//     }
// 
//     public void setTargetAmount(Double targetAmount) {
//         this.targetAmount = targetAmount;
//     }
// 
//     public Double getDonationMinimum() {
//         return donationMinimum;
//     }
// 
//     public void setDonationMinimum(Double donationMinimum) {
//         this.donationMinimum = donationMinimum;
//     }
// 
//     public Double getAmountDonatedSoFar() {
//         return amountDonatedSoFar;
//     }
// 
//     public void setAmountDonatedSoFar(Double amountDonatedSoFar) {
//         this.amountDonatedSoFar = amountDonatedSoFar;
//     }
// 
//     public Account getAccount() {
//         return account;
//     }
// 
//     public void setAccount(Account account) {
//         this.account = account;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public List<Donation> getDonations() {
//         return donations;
//     }
// 
//     public void setDonations(List<Donation> donations) {
//         this.donations = donations;
//     }
// 
//     public Organizer getOrganizer() {
//         return organizer;
//     }
// 
//     public void setOrganizer(Organizer organizer) {
//         this.organizer = organizer;
//     }
// }


import de.dpunkt.myaktion.data.CampaignProducer;
import de.dpunkt.myaktion.model.Campaign;
import de.dpunkt.myaktion.util.Events.Added;
import de.dpunkt.myaktion.util.Events.Updated;
import javax.enterprise.event.Event;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
package de.dpunkt.myaktion.controller;



@ViewScoped
@Named
public class EditCampaignController implements Serializable {
    private static final long serialVersionUID = 2815796004558360299L;

    @Inject
    @Added
    private Event<Campaign> campaignAddEvent;

    @Inject
    @Updated
    private Event<Campaign> campaignUpdateEvent;

    @Inject
    private CampaignProducer campaignProducer;

    public String doSave() {
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/data/CampaignProducer.java
// @SessionScoped
// public class CampaignProducer implements Serializable {
// 
//     private static final long serialVersionUID = -1828660647917534556L;
// 
//     private enum Mode {
//         EDIT, ADD
//     }
// 
//     private Campaign campaign;
//     private Mode mode;
// 
//     @Produces
//     @Named
//     public Campaign getSelectedCampaign() {
//         return campaign;
//     }
// 
//     public void setSelectedCampaign(Campaign campaign) {
//         this.campaign = campaign;
//     }
// 
//     @Produces
//     @Named
//     public boolean isAddMode() {
//         return mode == Mode.ADD;
//     }
// 
//     public void prepareAddCampaign() {
//         this.campaign = new Campaign();
//         this.mode = Mode.ADD;
//     }
// 
//     public void prepareEditCampaign(Campaign campaign) {
//         this.campaign = campaign;
//         this.mode = Mode.EDIT;
//     }
// 
// }
// 
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Campaign.java
// @NamedQueries({
//         @NamedQuery(name = Campaign.findByOrganizer, query = "SELECT c FROM Campaign c WHERE c.organizer = :organizer ORDER BY c.name"),
//         @NamedQuery(name = Campaign.findAll, query = "SELECT a FROM Campaign a ORDER BY a.name"),
//         @NamedQuery(name = Campaign.getAmountDonatedSoFar, query = "SELECT SUM(d.amount) FROM Donation d WHERE d.campaign = :campaign")
// })
// @Entity
// public class Campaign {
//     public static final String findByOrganizer = "Campaign.findByOrganizer";
//     public static final String findAll = "Campaign.findAll";
//     public static final String getAmountDonatedSoFar = "Campaign.getAmountDonatedSoFar";
// 
//     @NotNull
//     @Size(min = 4, max = 30, message = "{campaign.name.size}")
//     private String name;
// 
//     @NotNull(message = "{campaign.targetAmount.notNull}")
//     @DecimalMin(value = "10.00", message = "{campaign.targetAmount.decimalMin}")
//     private Double targetAmount;
// 
//     @NotNull(message = "{campaign.donationMinimum.notNull}")
//     @DecimalMin(value = "1.00", message = "{campaign.donationMinimum.decimalMin}")
//     private Double donationMinimum;
// 
//     @Transient
//     private Double amountDonatedSoFar;
// 
//     @AttributeOverrides({@AttributeOverride(name = "name", column = @Column(name = "accountName"))})
//     @Embedded
//     private Account account;
// 
//     @GeneratedValue
//     @Id
//     private Long id;
// 
//     @OneToMany(mappedBy = "campaign", cascade = CascadeType.REMOVE)
//     private List<Donation> donations;
// 
//     @ManyToOne
//     private Organizer organizer;
// 
//     public Campaign() {
//         account = new Account();
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public Double getTargetAmount() {
//         return targetAmount;
//     }
// 
//     public void setTargetAmount(Double targetAmount) {
//         this.targetAmount = targetAmount;
//     }
// 
//     public Double getDonationMinimum() {
//         return donationMinimum;
//     }
// 
//     public void setDonationMinimum(Double donationMinimum) {
//         this.donationMinimum = donationMinimum;
//     }
// 
//     public Double getAmountDonatedSoFar() {
//         return amountDonatedSoFar;
//     }
// 
//     public void setAmountDonatedSoFar(Double amountDonatedSoFar) {
//         this.amountDonatedSoFar = amountDonatedSoFar;
//     }
// 
//     public Account getAccount() {
//         return account;
//     }
// 
//     public void setAccount(Account account) {
//         this.account = account;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public List<Donation> getDonations() {
//         return donations;
//     }
// 
//     public void setDonations(List<Donation> donations) {
//         this.donations = donations;
//     }
// 
//     public Organizer getOrganizer() {
//         return organizer;
//     }
// 
//     public void setOrganizer(Organizer organizer) {
//         this.organizer = organizer;
//     }
// }


// Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/EditCampaignController.java
import de.dpunkt.myaktion.data.CampaignProducer;
import de.dpunkt.myaktion.model.Campaign;
import de.dpunkt.myaktion.util.Events.Added;
import de.dpunkt.myaktion.util.Events.Updated;
import javax.enterprise.event.Event;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;

package de.dpunkt.myaktion.controller;



@ViewScoped
@Named
public class EditCampaignController implements Serializable {
    private static final long serialVersionUID = 2815796004558360299L;

    @Inject
    @Added
    private Event<Campaign> campaignAddEvent;

    @Inject
    @Updated
    private Event<Campaign> campaignUpdateEvent;

    @Inject
    private CampaignProducer campaignProducer;

    public String doSave() {
        if (campaignProducer.isAddMode()) {