Usando las firmas del MagicDraw
This commit is contained in:
@@ -23,10 +23,7 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private int userID;
|
||||
private UserType userType;
|
||||
private List<QuestionTO> pendingQuestions;
|
||||
protected String title;
|
||||
protected String message;
|
||||
protected String response;
|
||||
private List<QuestionTO> allQuestions;
|
||||
protected QuestionTO selected;
|
||||
|
||||
public QuestionsMBean() {
|
||||
@@ -40,36 +37,41 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
||||
this.selected = null;
|
||||
|
||||
this.loadQuestions();
|
||||
this.printSelected();
|
||||
}
|
||||
|
||||
private void printSelected() {
|
||||
System.out.println("Selected: ");
|
||||
|
||||
private void printSelected(String asd) {
|
||||
if(asd!=null) {
|
||||
asd = "'" + asd + "'";
|
||||
}else {
|
||||
asd = "";
|
||||
}
|
||||
System.out.println("Selected " + asd + ": ");
|
||||
System.out.println(this.selected);
|
||||
}
|
||||
|
||||
public List<QuestionTO> getPendingQuestions() {
|
||||
return pendingQuestions;
|
||||
return allQuestions;
|
||||
}
|
||||
|
||||
public void setPendingQuestions(List<QuestionTO> value) {
|
||||
this.pendingQuestions = value;
|
||||
this.allQuestions = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cargará las preguntas enviadas al médico o escritas por el paciente, esto irá
|
||||
* en función del tipo de usuario en sesión
|
||||
*/
|
||||
private void loadQuestions() {
|
||||
this.printSelected();
|
||||
this.printSelected("");
|
||||
if (userType == UserType.FAMILY_DOCTOR) {
|
||||
// Listar las preguntas destinadas a él
|
||||
// El método disponible del API básico es referente al doctor
|
||||
this.pendingQuestions = getRemoteManagerMedicalTest().listAllPendingQuestions(userID);
|
||||
this.allQuestions = getRemoteManagerMedicalTest().listAllPendingQuestions(userID);
|
||||
} else if (userType == UserType.PATIENT) {
|
||||
// Listar las preguntas realiadas por él
|
||||
// Para reutilizar la misma view, necesitaremos nuevos métodos para el API de
|
||||
// cara a recoger sus preguntas realizadas.
|
||||
this.pendingQuestions = getRemoteManagerMedicalTest().listAllMyQuestions(userID);
|
||||
this.allQuestions = getRemoteManagerMedicalTest().listAllMyQuestions(userID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,61 +86,57 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
||||
public void setShowCreate() {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
public boolean getDisabledMessage() {
|
||||
if(this.selected != null) {
|
||||
if (this.selected != null) {
|
||||
return this.selected.getStatus() != QuestionStatus.NEW;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDisabledMessage() {
|
||||
return this.getDisabledMessage();
|
||||
}
|
||||
|
||||
|
||||
public void setDisabledMessage(boolean bval) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
this.printSelected();
|
||||
this.printSelected("onSelect antes");
|
||||
this.selected = (QuestionTO) event.getObject();
|
||||
this.printSelected();
|
||||
this.printSelected("onSelect despues");
|
||||
}
|
||||
|
||||
public void onUnSelect(SelectEvent event) {
|
||||
this.selected = null;
|
||||
}
|
||||
|
||||
|
||||
public void setSelected(QuestionTO selected) {
|
||||
this.printSelected();
|
||||
this.printSelected("setSelected antes");
|
||||
this.selected = selected;
|
||||
this.printSelected("setSelected despues");
|
||||
}
|
||||
|
||||
|
||||
public QuestionTO getSelected() {
|
||||
return this.selected;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
public void answerQuestion() {
|
||||
// Es un selected recuperado de la lista
|
||||
getRemoteManagerMedicalTest().answerQuestion(this.selected.getId(), this.selected.getResponse());
|
||||
this.init();
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public void setResponse(String response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
this.printSelected();
|
||||
getRemoteManagerMedicalTest().answerQuestion(this.selected);
|
||||
public void askQuestion() {
|
||||
// Es un question nuevo
|
||||
QuestionTO q = this.selected;
|
||||
getRemoteManagerMedicalTest().askQuestion(q.getPatient().getId(), q.getTitle(), q.getMessage());
|
||||
this.init();
|
||||
}
|
||||
|
||||
|
||||
public void create() {
|
||||
this.printSelected();
|
||||
this.printSelected("create start");
|
||||
String template = "";
|
||||
this.selected = new QuestionTO();
|
||||
this.selected.setId(-1);
|
||||
@@ -148,7 +146,7 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
||||
this.selected.setStatus(QuestionStatus.NEW);
|
||||
this.selected.getPatient().setId(Integer.parseInt(SessionUtils.getloggedOnUser().getId()));
|
||||
this.selected.getPatient().setName(SessionUtils.getloggedOnUser().getName());
|
||||
this.printSelected();
|
||||
this.printSelected("create end");
|
||||
}
|
||||
|
||||
public boolean getShowPanelDetail() {
|
||||
@@ -163,4 +161,28 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
||||
//
|
||||
}
|
||||
|
||||
public boolean getAskButton() {
|
||||
return this.selected == null ? (userType == UserType.PATIENT)
|
||||
: (userType == UserType.PATIENT && this.selected.getStatus() == QuestionStatus.NEW);
|
||||
}
|
||||
|
||||
public boolean isAskButton() {
|
||||
return this.getAskButton();
|
||||
}
|
||||
|
||||
public void setAskButton() {
|
||||
}
|
||||
|
||||
public boolean getAnswerButton() {
|
||||
return this.selected == null ? (userType == UserType.FAMILY_DOCTOR)
|
||||
: (userType == UserType.FAMILY_DOCTOR && this.selected.getStatus() == QuestionStatus.PENDING);
|
||||
}
|
||||
|
||||
public boolean isAnswerButton() {
|
||||
return this.getAnswerButton();
|
||||
}
|
||||
|
||||
public void setAnswerButton() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user