Skip to content
Snippets Groups Projects
Commit 4eda151f authored by singold's avatar singold
Browse files

Merge remote-tracking branch 'origin/master'

parents abae1030 1168705b
No related branches found
No related tags found
No related merge requests found
Showing
with 137 additions and 55 deletions
......@@ -4,16 +4,20 @@ import org.primefaces.PrimeFaces;
import uy.edu.fing.tse.central.business.BusinessLocal;
import uy.edu.fing.tse.dto.Fact;
import uy.edu.fing.tse.dto.State;
import uy.edu.fing.tse.dto.User;
import uy.edu.fing.tse.dto.StateHistory;
import uy.edu.fing.tse.dto.UserBO;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@RequestScoped
@ViewScoped
@Named("gestionHechos")
public class GestionHechosBean implements Serializable {
......@@ -22,13 +26,23 @@ public class GestionHechosBean implements Serializable {
@EJB
private BusinessLocal service;
@Inject
SecurityBean securityBean;
@PostConstruct
public void init() {
estados = service.listarEstados();
filteredFacts = service.listarHechos();
facts = service.listarHechos();
checkers = service.listarUsuarios().stream()
.filter(u -> u instanceof UserBO)
.map(u -> (UserBO) u)
.filter(u -> u.getRole().getName().equalsIgnoreCase("checker"))
.collect(Collectors.toList());
}
private List<UserBO> checkers;
private List<State> estados;
private List<Fact> facts;
......@@ -36,13 +50,14 @@ public class GestionHechosBean implements Serializable {
private List<Fact> filteredFacts;
private String filterTitulo = "";
private String filterDesc = "";
private String filterEstado = "";
private Long idHecho;
private Fact hecho;
private String checkerMail = "";
public List<Fact> getFilteredFacts() {
return filteredFacts;
}
......@@ -86,13 +101,57 @@ public class GestionHechosBean implements Serializable {
public void setFacts(List<Fact> facts) {
this.facts = facts;
}
public void setService(BusinessLocal service) {
this.service = service;
}
public void editar(Fact f) {
public void asignar(Fact f) {
PrimeFaces.current().executeScript("window.location.href='verHecho.xhtml?id=" + f.getId() + "'");
}
public void verificar() {
State s = new State();
s.setValue("En Proceso");
StateHistory sh = new StateHistory();
sh.setState(s);
sh.setDate(new Date());
UserBO userBO = new UserBO();
userBO.setMail(checkerMail);
sh.setUser(userBO);
hecho.setActualState(s);
hecho.addHistory(sh);
service.updateHecho(hecho);
}
public void aVerificar(Fact f) {
nexState(f, "A Comprobar");
}
public void cancelar(Fact f) {
nexState(f, "Cancelado");
}
public void publicar(Fact f) {
nexState(f, "Publicado");
}
private void nexState(Fact f, String state) {
State s = new State();
s.setValue(state);
StateHistory sh = new StateHistory();
sh.setState(s);
sh.setDate(new Date());
UserBO userBO = new UserBO();
userBO.setMail(securityBean.getUser());
sh.setUser(userBO);
f.setActualState(s);
f.addHistory(sh);
service.updateHecho(f);
}
public void setIdHecho(Long idHecho) {
this.idHecho = idHecho;
hecho = service.buscarHecho(idHecho);
......@@ -109,5 +168,21 @@ public class GestionHechosBean implements Serializable {
public void setHecho(Fact hecho) {
this.hecho = hecho;
}
public String getCheckerMail() {
return checkerMail;
}
public void setCheckerMail(String checkerMail) {
this.checkerMail = checkerMail;
}
public List<UserBO> getCheckers() {
return checkers;
}
public void setCheckers(List<UserBO> checkers) {
this.checkers = checkers;
}
}
......@@ -98,13 +98,7 @@ public class GestionUsuariosBean implements Serializable {
public List<User> getCheckers() {
List<User> todoslosusers = service.listarUsuarios();
checkers = new ArrayList<>();
for (User u : todoslosusers) {
if (isBO(u)) {
if (getRole(u).toLowerCase().equals("checker")) {
checkers.add(u);
}
}
}
todoslosusers.stream().filter(this::isBO).filter(u -> getRole(u).equalsIgnoreCase("checker")).forEach(u -> checkers.add(u));
return checkers;
}
......
......@@ -99,7 +99,7 @@ public class UserLoginBean implements Serializable {
//TODO
if (valid) {
final var s = securityLocal.register(user);
PrimeFaces.current().executeScript("window.location.href='jsf/listarHechos.xhtml'");
PrimeFaces.current().executeScript("window.location.href='gestionUsuarios.xhtml'");
} else {
FacesContext.getCurrentInstance().addMessage(
null,
......
......@@ -10,7 +10,7 @@
<ui:define name="contenido">
<h:form>
<p:outputPanel style="font-size: 30px;text-align: center">
<h:outputText value="Gestion de Notificacion"/>
<h:outputText value="Gestion de Sistema"/>
</p:outputPanel>
</h:form>
......
......@@ -45,11 +45,25 @@
<p:growl id="message" showDetail="true"/>
<p:commandButton value="Enviar Verificación" action="#{gestionHechos.editar(hecho)}" update="dataHecho"
disabled="#{hecho.EstaVerifcado()}">
<p:commandButton value="Solicitar Verificación" action="#{gestionHechos.aVerificar(hecho)}"
update="dataHecho" rendered="#{hecho.actualState.value=='Nuevo'}">
<p:confirm header="Confirmar" message="¿Enviar Solicitud?" icon="pi pi-exclamation-triangle"/>
</p:commandButton>
<p:commandButton value="Asignar Verificación" action="#{gestionHechos.asignar(hecho)}"
update="dataHecho" rendered="#{hecho.actualState.value=='A Comprobar'}"/>
<p:commandButton value="Publicar Verificación" action="#{gestionHechos.publicar(hecho)}"
update="dataHecho" rendered="#{hecho.actualState.value=='Verificado'}">
<p:confirm header="Confirmar" message="¿Publicar Verificación?"
icon="pi pi-exclamation-triangle"/>
</p:commandButton>
<p:commandButton value="Cancelar" action="#{gestionHechos.cancelar(hecho)}"
update="dataHecho" rendered="#{hecho.actualState.value!='Cancelado'}">
<p:confirm header="Confirmar" message="¿Cancelar Verificacion?"
icon="pi pi-exclamation-triangle"/>
</p:commandButton>
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton value="Si" type="button" styleClass="ui-confirmdialog-yes" icon="pi pi-check"/>
......
......@@ -38,9 +38,9 @@
<p:commandButton value="Borrar" action="#{gestionUsuarios.borrar(u)}" update="dataUser">
<p:confirm header="Borrar" message="¿Desea Borrar el usuario?" icon="pi pi-exclamation-triangle"/>
</p:commandButton>
<p:commandButton value="Editar" action="#{gestionUsuarios.editar(u)}">
<p:confirm header="Editar" message="¿Desea Editar el usuario?" icon="pi pi-exclamation-triangle"/>
</p:commandButton>
<p:commandButton value="Editar" action="#{gestionUsuarios.editar(u)}"/>
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton value="Si" type="button" styleClass="ui-confirmdialog-yes" icon="pi pi-check"/>
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="pi pi-times"/>
......
......@@ -17,8 +17,6 @@
</f:metadata>
<p:dataTable var="hecho" id="dataHecho" value="#{gestionHechos.hecho}" widgetVar="NoticiasTable">
<p:column headerText="Titulo" >
<h:outputText value="#{gestionHechos.hecho.title}"/>
</p:column>
......@@ -30,19 +28,15 @@
</p:column>
<p:column headerText="Asignar Checker" >
<p:selectOneMenu id="roles" value="#{gestionUsuarios.checkers}" dynamic="true" style="width:125px">
<p:selectOneMenu id="roles" value="#{gestionHechos.checkerMail}" dynamic="true" style="width:125px">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{gestionUsuarios.checkers}" />
<f:selectItems value="#{gestionHechos.checkers}" var="c" itemLabel="#{c.mail}"
itemValue="#{c.mail}"/>
</p:selectOneMenu>
</p:column>
</p:dataTable>
<h:commandButton styleClass="btn btn-primary" action="#{gestionUsuarios.guardar()}"
<h:commandButton styleClass="btn btn-primary" action="#{gestionHechos.verificar()}"
value="Guardar" style="font-size:20px"/>
</h:form>
</ui:define>
</ui:decorate>
......
package uy.edu.fing.tse.dto;
import org.primefaces.PrimeFaces;
import java.io.Serializable;
import java.nio.file.attribute.FileAttribute;
import java.util.ArrayList;
import java.util.List;
......@@ -78,23 +75,4 @@ public final class Fact implements Serializable {
public void addHistory(StateHistory history) {
this.history.add(history);
}
public void setEstado() {
PrimeFaces.current().executeScript("window.location.href='verHecho.xhtml");
}
public Boolean EstaVerifcado() {
return (actualState.getValue().equals("En Proceso") || actualState.getValue().equals("Verificado") || (actualState.getValue().equals("A Comprobar")));
}
public void CancelarHecho() {
this.actualState.setValue("Cancelar");
}
public void PublicarHecho() {
this.actualState.setValue("Publicado");
}
}
......@@ -56,5 +56,7 @@ public interface Business extends Serializable {
List<Fact> buscarHechos(Date fDesde, Date fHasta, String texto);
void subscribirse(long idUser, long idHecho);
void updateHecho(Fact fact);
}
......@@ -186,6 +186,33 @@ public class BusinessBean implements BusinessLocal, BusinessRemote {
@Override
public void subscribirse(long idUser, long idHecho) {
//TODO
}
@Override
public void updateHecho(Fact fact) {
final var state = estados.find(fact.getActualState().getValue());
fact.setActualState(state);
if (fact.getCategory() != null) {
final var cat = categorias.find(fact.getCategory().getName());
fact.setCategory(cat);
}
if (fact.getScore() != null) {
final var score = calificaciones.find(fact.getScore().getValue());
fact.setScore(score);
}
for (StateHistory sh : fact.getHistory()) {
final var u = usuarios.find(sh.getUser().getMail());
sh.setUser(u);
final var s = estados.find(sh.getState().getValue());
sh.setState(s);
}
hechos.update(fact);
}
}
......@@ -16,14 +16,12 @@ import uy.edu.fing.tse.dto.external.Verification;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import java.io.IOException;
import java.util.Date;
import java.util.concurrent.TimeoutException;
@Singleton
@Startup
//@Singleton
//@Startup
public class MessageConsumer {
private static final Logger LOG = LoggerFactory.getLogger(MessageConsumer.class);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment