Skip to content

Commit

Permalink
Close #2; Add GUI, favicon, and routing for application
Browse files Browse the repository at this point in the history
  • Loading branch information
kbmakevin committed Apr 19, 2018
1 parent 2de45c9 commit 2d629f0
Show file tree
Hide file tree
Showing 16 changed files with 337 additions and 294 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
name="GroupKOPS_COMP303_Assignment3_JPA"
transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:/jndi/faq</non-jta-data-source>
<class>com.faqapp.models.Faq</class>
<class>com.faqapp.models.FaqPK</class>
<class>com.faqapp.models.Topic</class>
<class>com.faq.app.model.Faq</class>
<class>com.faq.app.model.FaqPK</class>
<class>com.faq.app.model.Topic</class>
</persistence-unit>
</persistence>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
name="GroupKOPS_COMP303_Assignment3_JPA"
transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:/jndi/faq</non-jta-data-source>
<class>com.faqapp.models.Faq</class>
<class>com.faqapp.models.FaqPK</class>
<class>com.faqapp.models.Topic</class>
<class>com.faq.app.model.Faq</class>
<class>com.faq.app.model.FaqPK</class>
<class>com.faq.app.model.Topic</class>
</persistence-unit>
</persistence>
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
package com.faqapp.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.Query;

import com.faqapp.models.Faq;

public class DatabaseOperations {
// PERSISTENCE_UNIT_NAME is the name recorded in the persistence.xml file
private static final String PERSISTENCE_UNIT_NAME = "GroupKOPS_COMP303_Assignment3_JPA";
private static EntityManager em = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME)
.createEntityManager();
private static EntityTransaction et = em.getTransaction();

public static List<Faq> getAllFaqRecords() {
Query query = em.createQuery("SELECT f FROM Faq f");
List<Faq> faqList = query.getResultList();
if (faqList != null && faqList.size() > 0) {
return faqList;
} else {
return null;
}
}
}
package com.faq.app.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;

import com.faq.app.model.Faq;

public class DatabaseOperations {
// PERSISTENCE_UNIT_NAME is the name recorded in the persistence.xml file
private static final String PERSISTENCE_UNIT_NAME = "GroupKOPS_COMP303_Assignment3_JPA";
private static EntityManager em = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME)
.createEntityManager();
private static EntityTransaction et = em.getTransaction();

public static List<Faq> getAllFaqRecords() {
TypedQuery<Faq> query = em.createNamedQuery("Faq.findAll", Faq.class);
// Query query = em.createQuery("SELECT f FROM Faq f");
List<Faq> faqList = query.getResultList();
if (faqList != null && faqList.size() > 0) {
return faqList;
} else {
return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
package com.faqapp.models;

import java.io.Serializable;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;

/**
* The persistent class for the faq database table.
*
*/
@Entity
@NamedQuery(name = "Faq.findAll", query = "SELECT f FROM Faq f")
public class Faq implements Serializable {
private static final long serialVersionUID = 1L;

@EmbeddedId
private FaqPK id;

private String answer;

private String question;

// bi-directional many-to-one association to Topic
@ManyToOne
@JoinColumn(name = "topic_id", insertable = false, updatable = false)
private Topic topic;

public Faq() {
}

public FaqPK getId() {
return this.id;
}

public void setId(FaqPK id) {
this.id = id;
}

public String getAnswer() {
return this.answer;
}

public void setAnswer(String answer) {
this.answer = answer;
}

public String getQuestion() {
return this.question;
}

public void setQuestion(String question) {
this.question = question;
}

public Topic getTopic() {
return this.topic;
}

public void setTopic(Topic topic) {
this.topic = topic;
}

package com.faq.app.model;

import java.io.Serializable;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;

/**
* The persistent class for the faq database table.
*
*/
@Entity
@NamedQuery(name = "Faq.findAll", query = "SELECT f FROM Faq f")
public class Faq implements Serializable {
private static final long serialVersionUID = 1L;

@EmbeddedId
private FaqPK id;

private String answer;

private String question;

// bi-directional many-to-one association to Topic
@ManyToOne
@JoinColumn(name = "topic_id", insertable = false, updatable = false)
private Topic topic;

public Faq() {
}

public FaqPK getId() {
return this.id;
}

public void setId(FaqPK id) {
this.id = id;
}

public String getAnswer() {
return this.answer;
}

public void setAnswer(String answer) {
this.answer = answer;
}

public String getQuestion() {
return this.question;
}

public void setQuestion(String question) {
this.question = question;
}

public Topic getTopic() {
return this.topic;
}

public void setTopic(Topic topic) {
this.topic = topic;
}

}
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
package com.faqapp.models;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
* The primary key class for the faq database table.
*
*/
@Embeddable
public class FaqPK implements Serializable {
// default serial version id, required for serializable classes.
private static final long serialVersionUID = 1L;

// @Column(name="topic_id", insertable=false, updatable=false)
@Column(name = "topic_id")
private int topicId;

@Column(name = "question_id")
private int questionId;

public FaqPK() {
}

public int getTopicId() {
return this.topicId;
}

public void setTopicId(int topicId) {
this.topicId = topicId;
}

public int getQuestionId() {
return this.questionId;
}

public void setQuestionId(int questionId) {
this.questionId = questionId;
}

public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof FaqPK)) {
return false;
}
FaqPK castOther = (FaqPK) other;
return (this.topicId == castOther.topicId) && (this.questionId == castOther.questionId);
}

public int hashCode() {
final int prime = 31;
int hash = 17;
hash = hash * prime + this.topicId;
hash = hash * prime + this.questionId;

return hash;
}
package com.faq.app.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
* The primary key class for the faq database table.
*
*/
@Embeddable
public class FaqPK implements Serializable {
// default serial version id, required for serializable classes.
private static final long serialVersionUID = 1L;

// @Column(name="topic_id", insertable=false, updatable=false)
@Column(name = "topic_id")
private int topicId;

@Column(name = "question_id")
private int questionId;

public FaqPK() {
}

public int getTopicId() {
return this.topicId;
}

public void setTopicId(int topicId) {
this.topicId = topicId;
}

public int getQuestionId() {
return this.questionId;
}

public void setQuestionId(int questionId) {
this.questionId = questionId;
}

public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof FaqPK)) {
return false;
}
FaqPK castOther = (FaqPK) other;
return (this.topicId == castOther.topicId) && (this.questionId == castOther.questionId);
}

public int hashCode() {
final int prime = 31;
int hash = 17;
hash = hash * prime + this.topicId;
hash = hash * prime + this.questionId;

return hash;
}
}
Loading

0 comments on commit 2d629f0

Please sign in to comment.