Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions sql/01-pg_create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,32 @@ INCREMENT BY 1;
CREATE TABLE ie_batch
(
b_id INT4 PRIMARY KEY,
b_name VARCHAR(5000) UNIQUE
b_name VARCHAR(5000) UNIQUE,
b_is_active BOOLEAN NOT NULL
);


CREATE TABLE ie_eval_type
(
et_id INT4 PRIMARY KEY,
et_description VARCHAR(5000) NOT NULL
et_description VARCHAR(5000) NOT NULL,
et_is_active BOOLEAN NOT NULL
);

CREATE TABLE ie_person_role
(
pr_id INT4 PRIMARY KEY,
pr_title VARCHAR(5000) NOT NULL
pr_title VARCHAR(5000) NOT NULL,
pr_is_active BOOLEAN NOT NULL
);

CREATE TABLE ie_person
(
p_id INT4 PRIMARY KEY,
p_firstname VARCHAR(5000) NOT NULL,
p_lastname VARCHAR(5000) NOT NULL,
p_role INT4 NOT NULL, FOREIGN KEY(p_role) REFERENCES ie_person_role(pr_id) ON DELETE CASCADE
p_role INT4 NOT NULL, FOREIGN KEY(p_role) REFERENCES ie_person_role(pr_id) ON DELETE CASCADE,
p_is_active BOOLEAN NOT NULL
);

CREATE TABLE ie_eval
Expand All @@ -74,14 +78,16 @@ CREATE TABLE ie_eval
e_date DATE NOT NULL,
e_eval_type INT4 NOT NULL,FOREIGN KEY(e_eval_type) REFERENCES ie_eval_type(et_id) ON DELETE CASCADE,
e_pid_trainee INT4 NOT NULL, FOREIGN KEY(e_pid_trainee) REFERENCES ie_person(p_id) ON DELETE CASCADE,
e_batch INT4 NOT NULL, FOREIGN KEY(e_batch) REFERENCES ie_batch(b_id) ON DELETE CASCADE
e_batch INT4 NOT NULL, FOREIGN KEY(e_batch) REFERENCES ie_batch(b_id) ON DELETE CASCADE,
e_is_active BOOLEAN NOT NULL
);

CREATE TABLE ie_eval_comment
(
ec_id INT4 PRIMARY KEY,
ec_text VARCHAR(5000) NOT NULL,
ec_eid INT4 NOT NULL, FOREIGN KEY(ec_eid) REFERENCES ie_eval(e_id) ON DELETE CASCADE
ec_eid INT4 NOT NULL, FOREIGN KEY(ec_eid) REFERENCES ie_eval(e_id) ON DELETE CASCADE,
ec_is_active BOOLEAN NOT NULL
);

CREATE TABLE ie_person_batch
Expand All @@ -94,7 +100,8 @@ CREATE TABLE ie_person_batch
CREATE TABLE ie_subject
(
s_id INT4 PRIMARY KEY,
s_subject VARCHAR(150) NOT NULL
s_subject VARCHAR(150) NOT NULL,
s_is_active BOOLEAN NOT NULL
);

CREATE TABLE ie_question_pool
Expand All @@ -105,7 +112,8 @@ CREATE TABLE ie_question_pool
qp_max_knowledge_score INT4 NOT NULL,
qp_sid INT4 NOT NULL, FOREIGN KEY(qp_sid) REFERENCES ie_subject(s_id) ON DELETE CASCADE,
qp_count INT4 DEFAULT 0 NOT NULL,
qp_last_date_used DATE
qp_last_date_used DATE,
qp_is_active BOOLEAN NOT NULL
);

CREATE TABLE ie_question_eval
Expand All @@ -114,12 +122,14 @@ CREATE TABLE ie_question_eval
qe_communication_score INT4 NOT NULL,
qe_knowledge_score INT4 NOT NULL,
qe_eid INT4 NOT NULL, FOREIGN KEY(qe_eid) REFERENCES ie_eval(e_id) ON DELETE CASCADE,
qe_qpid INT4 NOT NULL, FOREIGN KEY(qe_qpid) REFERENCES ie_question_pool(qp_id) ON DELETE CASCADE
qe_qpid INT4 NOT NULL, FOREIGN KEY(qe_qpid) REFERENCES ie_question_pool(qp_id) ON DELETE CASCADE,
qe_is_active BOOLEAN NOT NULL
);

CREATE TABLE ie_question_comment
(
qc_id INT4 PRIMARY KEY,
qc_comment_text VARCHAR(5000) NOT NULL,
qc_eid INT4 NOT NULL, FOREIGN KEY(qc_eid) REFERENCES ie_question_eval(qe_id) ON DELETE CASCADE
qc_eid INT4 NOT NULL, FOREIGN KEY(qc_eid) REFERENCES ie_question_eval(qe_id) ON DELETE CASCADE,
qc_is_active BOOLEAN NOT NULL
);
343 changes: 172 additions & 171 deletions sql/02-pg_fill_tables.sql

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions src/main/java/com/revature/controllers/AdminController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.revature.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.revature.services.PersonLogic;

@CrossOrigin
@RestController
@RequestMapping(value = "/api/v1/admin/")
public class AdminController {


@Autowired
private PersonLogic personLogic;


@RequestMapping(method = RequestMethod.DELETE, value = "persons/{personId}")
public ResponseEntity<String> deletePerson(@PathVariable Integer personId){
return ResponseEntity.ok(personLogic.deletePersonAdmin(personId));
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ResponseEntity<Page<Person>> getPerson(Pageable pageable, @RequestParam(d
return ResponseEntity.ok(personLogic.getPersonsByLastnameAndPersonRole(pageable, lastname, roleSearch));
} else if((!"".equals(firstname)) && !("".equals(lastname))) {
return ResponseEntity.ok(personLogic.getPersonsByFirstnameAndLastnameAndPersonRole(pageable, firstname, lastname, roleSearch));
} else{
} else{ //if roleSearch is null the return will be all persons with isActive=true
return ResponseEntity.ok(personLogic.getAllPersonsByPersonRole(pageable, roleSearch));
}

Expand Down
27 changes: 22 additions & 5 deletions src/main/java/com/revature/domain/Batch.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ public class Batch {
@Column(name="b_name")
private String name;

@Column(name="b_is_active")
private boolean isActive;

@ManyToMany
@JoinTable(name="ie_person_batch", joinColumns=@JoinColumn(name="batch_id"), inverseJoinColumns=@JoinColumn(name="person_id"))
private Set<Person> persons;

public Batch() {}

public Batch(String name) {
public Batch(String name, boolean isActive) {
super();
this.name = name;
this.isActive = isActive;
}

public Set<Person> getPersons(){
Expand All @@ -62,12 +66,21 @@ public String getName() {
public void setName(String name) {
this.name = name;
}

public void setisActive(boolean isActive){
this.isActive = isActive;
}

public boolean isActive(){
return isActive;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + id;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + (isActive ? 1231 : 1237);
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
Expand All @@ -81,7 +94,12 @@ public boolean equals(Object obj) {
if (getClass() != obj.getClass())
return false;
Batch other = (Batch) obj;
if (id != other.id)
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (isActive != other.isActive)
return false;
if (name == null) {
if (other.name != null)
Expand All @@ -93,8 +111,7 @@ public boolean equals(Object obj) {

@Override
public String toString() {
return "Batch [id=" + id + ", name=" + name+ "]";
return "Batch [id=" + id + ", name=" + name + ", isActive=" + isActive + "]";
}


}
23 changes: 19 additions & 4 deletions src/main/java/com/revature/domain/Eval.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class Eval implements Serializable{
@OneToMany(mappedBy="eval", cascade = CascadeType.ALL)
private List<EvalComment> comments;

@Column(name="e_is_active")
private boolean isActive;

@Transient
private int evalKnowledgeScore;

Expand All @@ -58,7 +61,7 @@ public class Eval implements Serializable{
public Eval() {/*empty constructor needed*/}

public Eval(Integer week, Date date, EvalType evalType, Person trainee, Batch batch,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Constructor has 8 parameters, which is greater than 7 authorized. rule

List<QuestionEval> questions, List<EvalComment> comments) {
List<QuestionEval> questions, List<EvalComment> comments, boolean isActive) {
super();
this.week = week;
this.date = date;
Expand All @@ -67,6 +70,7 @@ public Eval(Integer week, Date date, EvalType evalType, Person trainee, Batch ba
this.batch = batch;
this.questions = questions;
this.comments = comments;
this.isActive = isActive;
}

public Integer getId() {
Expand Down Expand Up @@ -133,6 +137,14 @@ public void setComments(List<EvalComment> comments) {
this.comments = comments;
}

public boolean isActive() {
return isActive;
}

public void setisActive(boolean isActive) {
this.isActive = isActive;
}

public int getEvalKnowledgeScore() {
return evalKnowledgeScore;
}
Expand Down Expand Up @@ -164,7 +176,7 @@ public int getEvalMaxCommunicationScore() {
public void setEvalMaxCommunicationScore(int evalMaxCommunicationScore) {
this.evalMaxCommunicationScore = evalMaxCommunicationScore;
}

@Override
public int hashCode() {
final int prime = 31;
Expand All @@ -174,6 +186,7 @@ public int hashCode() {
result = prime * result + ((date == null) ? 0 : date.hashCode());
result = prime * result + ((evalType == null) ? 0 : evalType.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + (isActive ? 1231 : 1237);
result = prime * result + ((questions == null) ? 0 : questions.hashCode());
result = prime * result + ((trainee == null) ? 0 : trainee.hashCode());
result = prime * result + ((week == null) ? 0 : week.hashCode());
Expand Down Expand Up @@ -214,6 +227,8 @@ public boolean equals(Object obj) {
return false;
} else if (!id.equals(other.id))
return false;
if (isActive != other.isActive)
return false;
if (questions == null) {
if (other.questions != null)
return false;
Expand All @@ -235,8 +250,8 @@ public boolean equals(Object obj) {
@Override
public String toString() {
return "Eval [id=" + id + ", week=" + week + ", date=" + date + ", evalType=" + evalType + ", trainee="
+ trainee + ", batch=" + batch + ", questions=" + questions + ", comments=" + comments + "]";
+ trainee + ", batch=" + batch + ", questions=" + questions + ", comments=" + comments + ", isActive="
+ isActive + "]";
}


}
26 changes: 18 additions & 8 deletions src/main/java/com/revature/domain/EvalComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ public class EvalComment implements Serializable {
@JoinColumn(name="ec_eid")
private Eval eval;

@Column(name="ec_is_active")
private boolean isActive;

public EvalComment(){}

public EvalComment(String commentText, Eval eval) {
public EvalComment(String commentText, Eval eval, boolean isActive) {
super();
this.commentText = commentText;
this.eval = eval;
this.isActive=isActive;
}

public Integer getId() {
Expand All @@ -54,14 +58,22 @@ public Eval getEval() {
public void setEval(Eval eval) {
this.eval = eval;
}

public boolean isActive() {
return isActive;
}

public void setisActive(boolean isActive) {
this.isActive = isActive;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((commentText == null) ? 0 : commentText.hashCode());
// result = prime * result + ((eval == null) ? 0 : eval.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + (isActive ? 1231 : 1237);
return result;
}

Expand All @@ -79,21 +91,19 @@ public boolean equals(Object obj) {
return false;
} else if (!commentText.equals(other.commentText))
return false;
if (eval == null) {
if (other.eval != null)
return false;
} else if (!eval.equals(other.eval))
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (isActive != other.isActive)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Replace this if-then-else statement by a single return statement. rule

return false;
return true;
}

@Override
public String toString() {
return "EvalComment [id=" + id + ", commentText=" + commentText + "]";
return "EvalComment [id=" + id + ", commentText=" + commentText + ", isActive=" + isActive + "]";
}

}
Loading