-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #2; Add GUI, favicon, and routing for application
- Loading branch information
Showing
16 changed files
with
337 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+1.69 KB
GroupKOPS_COMP303_Assignment3_JPA/build/classes/com/faq/app/dao/DatabaseOperations.class
Binary file not shown.
Binary file renamed
BIN
+1.66 KB
...build/classes/com/faqapp/models/Faq.class → ...build/classes/com/faq/app/model/Faq.class
Binary file not shown.
Binary file renamed
BIN
+1.31 KB
...ild/classes/com/faqapp/models/FaqPK.class → ...ild/classes/com/faq/app/model/FaqPK.class
Binary file not shown.
Binary file renamed
BIN
+2.22 KB
...ild/classes/com/faqapp/models/Topic.class → ...ild/classes/com/faq/app/model/Topic.class
Binary file not shown.
Binary file removed
BIN
-1.56 KB
GroupKOPS_COMP303_Assignment3_JPA/build/classes/com/faqapp/dao/DatabaseOperations.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 29 additions & 28 deletions
57
...rc/com/faqapp/dao/DatabaseOperations.java → ...c/com/faq/app/dao/DatabaseOperations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
132 changes: 66 additions & 66 deletions
132
...nment3_JPA/src/com/faqapp/models/Faq.java → ...nment3_JPA/src/com/faq/app/model/Faq.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
122 changes: 61 additions & 61 deletions
122
...ent3_JPA/src/com/faqapp/models/FaqPK.java → ...ent3_JPA/src/com/faq/app/model/FaqPK.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.