Commit d61fa358 authored by trang.nguyen's avatar trang.nguyen

Update several files

parent f1ad44b5
/target/
/.settings/
/.metadata/
.classpath
.project
\ No newline at end of file
/bin/
/target/
/.settings/
/.metadata/
.classpath
.project
/.vscode/
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.dpunkt</groupId>
<artifactId>my-aktion</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>8.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-neo4j</artifactId>
<version>5.4.1.Final</version>
</dependency>
</dependencies>
<build>
<finalName>my-aktion</finalName>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>2.0.2.Final</version>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.dpunkt</groupId>
<artifactId>my-aktion</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>8.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-neo4j</artifactId>
<version>5.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-jdbc-driver</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>
<build>
<finalName>my-aktion</finalName>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>2.0.2.Final</version>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
</project>
package de.dpunkt.myaktion.controller;
import java.io.Serializable;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import de.dpunkt.myaktion.model.Donation;
import de.dpunkt.myaktion.model.Donation.Status;
import de.dpunkt.myaktion.services.DonationService;
@ViewScoped
@Named
public class DonateMoneyController implements Serializable {
private static final long serialVersionUID = 5493038842003809106L;
private String textColor = "000000";
private String bgColor = "ffffff";
private Long campaignId;
private Donation donation;
@Inject
private DonationService donationService;
@Inject
private FacesContext facesContext;
@Inject
private Logger logger;
@PostConstruct
public void init() {
this.donation = new Donation();
}
public Long getCampaignId() {
return campaignId;
}
public void setCampaignId(Long campaignId) {
this.campaignId = campaignId;
}
public Donation getDonation() {
return donation;
}
public void setDonation(Donation donation) {
this.donation = donation;
}
public String getTextColor() {
return textColor;
}
public void setTextColor(String textColor) {
this.textColor = textColor;
}
public String getBgColor() {
return bgColor;
}
public void setBgColor(String bgColor) {
this.bgColor = bgColor;
}
public String doDonation() {
getDonation().setStatus(Status.IN_PROCESS);
donationService.addDonation(getCampaignId(), getDonation());
logger.log(Level.INFO, "log.donateMoney.thank_you",
new Object[] { getDonation().getDonorName(), getDonation().getAmount() });
final ResourceBundle resourceBundle = facesContext.getApplication().getResourceBundle(facesContext, "msg");
final String msg = resourceBundle.getString("donateMoney.thank_you");
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, msg, null));
init();
return Pages.DONATE_MONEY;
}
package de.dpunkt.myaktion.controller;
import java.io.Serializable;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import de.dpunkt.myaktion.model.Donation;
import de.dpunkt.myaktion.model.Donation.Status;
import de.dpunkt.myaktion.services.DonationService;
@ViewScoped
@Named
public class DonateMoneyController implements Serializable {
private static final long serialVersionUID = 5493038842003809106L;
private String textColor = "000000";
private String bgColor = "ffffff";
private Long campaignId;
private Donation donation;
@Inject
private DonationService donationService;
@Inject
private FacesContext facesContext;
@Inject
private Logger logger;
@PostConstruct
public void init() {
this.donation = new Donation();
}
public Long getCampaignId() {
return campaignId;
}
public void setCampaignId(Long campaignId) {
this.campaignId = campaignId;
}
public Donation getDonation() {
return donation;
}
public void setDonation(Donation donation) {
this.donation = donation;
}
public String getTextColor() {
return textColor;
}
public void setTextColor(String textColor) {
this.textColor = textColor;
}
public String getBgColor() {
return bgColor;
}
public void setBgColor(String bgColor) {
this.bgColor = bgColor;
}
public String doDonation() {
getDonation().setStatus(Status.IN_PROCESS);
donationService.addDonation(getCampaignId(), getDonation());
logger.log(Level.INFO, "log.donateMoney.thank_you",
new Object[] { getDonation().getDonorName(), getDonation().getAmount() });
final ResourceBundle resourceBundle = facesContext.getApplication().getResourceBundle(facesContext, "msg");
final String msg = resourceBundle.getString("donateMoney.thank_you");
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, msg, null));
init();
return Pages.DONATE_MONEY;
}
}
\ No newline at end of file
package de.dpunkt.myaktion.controller;
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.Deleted;
import de.dpunkt.myaktion.util.Events.Update;
import javax.enterprise.event.Event;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
@ViewScoped
@Named
public class EditCampaignController implements Serializable {
private static final long serialVersionUID = 2815796004558360299L;
/*
* @Inject public EditCampaignController(CampaignListProducer
* campaignListProducer){ this.campaignListProducer = campaignListProducer; }
*
* @Inject public void setCampaignListProducer(CampaignListProducer
* campaignListProducer) { this.campaignListProducer = campaignListProducer; }
*
*/
@Inject
private CampaignProducer CampaignProducer;
@Inject
@Added
private Event<Campaign> campaignAddEvent;
@Inject
@Deleted
private Event<Campaign> campaignDeleteEvent;
@Inject
@Update
private Event<Campaign> campaignUpdateEvent;
public String doSave() {
if (CampaignProducer.isAddMode()) {
campaignAddEvent.fire(CampaignProducer.getSelectedCampaign());
} else {
campaignUpdateEvent.fire(CampaignProducer.getSelectedCampaign());
}
return Pages.LIST_CAMPAIGNS;
}
public String doCancel() {
return Pages.LIST_CAMPAIGNS;
}
}
package de.dpunkt.myaktion.controller;
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.Deleted;
import de.dpunkt.myaktion.util.Events.Update;
import javax.enterprise.event.Event;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
@ViewScoped
@Named
public class EditCampaignController implements Serializable {
private static final long serialVersionUID = 2815796004558360299L;
/*
* @Inject public EditCampaignController(CampaignListProducer
* campaignListProducer){ this.campaignListProducer = campaignListProducer; }
*
* @Inject public void setCampaignListProducer(CampaignListProducer
* campaignListProducer) { this.campaignListProducer = campaignListProducer; }
*
*/
@Inject
private CampaignProducer CampaignProducer;
@Inject
@Added
private Event<Campaign> campaignAddEvent;
@Inject
@Deleted
private Event<Campaign> campaignDeleteEvent;
@Inject
@Update
private Event<Campaign> campaignUpdateEvent;
public String doSave() {
if (CampaignProducer.isAddMode()) {
campaignAddEvent.fire(CampaignProducer.getSelectedCampaign());
} else {
campaignUpdateEvent.fire(CampaignProducer.getSelectedCampaign());
}
return Pages.LIST_CAMPAIGNS;
}
public String doCancel() {
return Pages.LIST_CAMPAIGNS;
}
}
package de.dpunkt.myaktion.controller;
import de.dpunkt.myaktion.data.CampaignProducer;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.List;
@SessionScoped
@Named
public class EditDonationFormController implements Serializable {
private static final long serialVersionUID = -4210085664588144340L;
private String textColor = "000000";
private String bgColor = "ffffff";
@Inject
private CampaignProducer campaignProducer;
@Inject
EntityManager entityManager;
public String doOk() {
return Pages.LIST_CAMPAIGNS;
}
@Inject
private HttpServletRequest req;
private String getAppUrl() {
String scheme = req.getScheme();
String serverName = req.getServerName();
int serverPort = req.getServerPort();
String contextPath = req.getContextPath();
return scheme + "://" + serverName + ":" + serverPort + contextPath;
}
public String getUrl() {
return getAppUrl() + "/" + Pages.DONATE_MONEY + ".jsf" + "?bgColor=" + bgColor + "&textColor=" + textColor
+ "&campaignId=" + campaignProducer.getSelectedCampaign().getId();
}
public String getAnotherUrl() {
Long idOfThisCampaign = campaignProducer.getSelectedCampaign().getId();
TypedQuery <Long> query = entityManager.createQuery("SELECT c.id FROM Campaign c", Long.class);
List<Long> campaigns = query.getResultList();
for ( Long thisId : campaigns) {
if (thisId != idOfThisCampaign) {
campaignProducer.getAnotherSelectedCampaign().setId(thisId);
}
}
return getAppUrl() + "/" + Pages.DONATE_MONEY + ".jsf" + "?bgColor="
+ bgColor + "&textColor=" + textColor + "&campaignId="
+ campaignProducer.getAnotherSelectedCampaign().getId();
//campaigns.forEach(Campaign -> Campaign.setAmountDonatedSoFar(getAmountDonatedSoFar(Campaign)));
//return getAppUrl() + "/" + Pages.DONATE_MONEY + ".jsf" + "?bgColor="
//+ bgColor + "&textColor=" + textColor + "&campaignId=";
// + campaignService.findID(Campaign);
}
public String getTextColor() {
return textColor;
}
public void setTextColor(String textColor) {
this.textColor = textColor;
}
public String getBgColor() {
return bgColor;
}
public void setBgColor(String bgColor) {
this.bgColor = bgColor;
}
package de.dpunkt.myaktion.controller;
import de.dpunkt.myaktion.data.CampaignProducer;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.List;
@SessionScoped
@Named
public class EditDonationFormController implements Serializable {
private static final long serialVersionUID = -4210085664588144340L;
private String textColor = "000000";
private String bgColor = "ffffff";
@Inject
private CampaignProducer campaignProducer;
@Inject
EntityManager entityManager;
public String doOk() {
return Pages.LIST_CAMPAIGNS;
}
@Inject
private HttpServletRequest req;
private String getAppUrl() {
String scheme = req.getScheme();
String serverName = req.getServerName();
int serverPort = req.getServerPort();
String contextPath = req.getContextPath();
return scheme + "://" + serverName + ":" + serverPort + contextPath;
}
public String getUrl() {
return getAppUrl() + "/" + Pages.DONATE_MONEY + ".jsf" + "?bgColor=" + bgColor + "&textColor=" + textColor
+ "&campaignId=" + campaignProducer.getSelectedCampaign().getId();
}
public String getTextColor() {
return textColor;
}
public void setTextColor(String textColor) {
this.textColor = textColor;
}
public String getBgColor() {
return bgColor;
}
public void setBgColor(String bgColor) {
this.bgColor = bgColor;
}
}
\ No newline at end of file
package de.dpunkt.myaktion.controller;
import de.dpunkt.myaktion.data.CampaignProducer;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.List;
@SessionScoped
@Named
public class EditDonationMoreFormController implements Serializable {
private static final long serialVersionUID = -4210085664588144340L;
private String textColor = "000000";
private String bgColor = "ffffff";
@Inject
private CampaignProducer campaignProducer;
@Inject
EntityManager entityManager;
public String doOk() {
return Pages.LIST_CAMPAIGNS;
}
@Inject
private HttpServletRequest req;
private String getAppUrl() {
String scheme = req.getScheme();
String serverName = req.getServerName();
int serverPort = req.getServerPort();
String contextPath = req.getContextPath();
return scheme + "://" + serverName + ":" + serverPort + contextPath;
}
public String getUrl() {
Long idOfThisCampaign = campaignProducer.getSelectedCampaign().getId();
TypedQuery <Long> query = entityManager.createQuery("MATCH (n:Campaign) RETURN n.id", Long.class);
// TypedQuery <Long> query = entityManager.createQuery("SELECT c.id FROM Campaign c", Long.class);
List<Long> campaigns = query.getResultList();
for ( Long thisId : campaigns) {