Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laura bernal #2

Open
wants to merge 21 commits into
base: camilo
Choose a base branch
from
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
43 changes: 3 additions & 40 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@
<artifactId>postgresql</artifactId>
<version>42.0.0</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.191</version>
</dependency>


<!-- Faces dependencies -->
<dependency>
Expand Down Expand Up @@ -211,47 +207,14 @@
</executions>
</plugin>
<!-- create local H2 database -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.184</version>
</dependency>
</dependencies>
<configuration>
<driver>org.h2.Driver</driver>
<url>jdbc:h2:file:./target/db/testdb;MODE=PostgreSQL</url>
<username>sa</username>
<password> </password>
<autocommit>false</autocommit>
<!--skip>${maven.test.skip}</skip!-->
</configuration>
<executions>
<execution>
<id>create-db</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<srcFiles>
<srcFile>tables.sql</srcFile>
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>

<!-- Tomcat embedded plugin. -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8080</port>
<port>8081</port>
<path>/</path>
</configuration>
</plugin>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/edu/eci/cvds/entities/Estado.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package edu.eci.cvds.entities;

public enum Estado {
ACTIVO, INACTIVO
}
5 changes: 5 additions & 0 deletions src/main/java/edu/eci/cvds/entities/EstadoIniciativa.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package edu.eci.cvds.entities;

public enum EstadoIniciativa {
ESPERA, REVISION, PROYECTO, SOLUCIONADO
}
154 changes: 154 additions & 0 deletions src/main/java/edu/eci/cvds/entities/Iniciativa.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package edu.eci.cvds.entities;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

public class Iniciativa {

private int id;
private String nombre;
private String area;
private Usuario proponente;
private String descripcion;
private EstadoIniciativa estado;
private Date fechaDeInicio;
private Date fechaDeFin;
private List<String> palabrasClave;
private List<Usuario> votos;
private List<Usuario> interesados;

public Iniciativa(){}

public Iniciativa(int id, String nombre, String area, Usuario proponente, String descripcion, EstadoIniciativa estado, Date fechaDeInicio){
this.id = id;
this.nombre = nombre;
this.area = area;
this.proponente = proponente;
this.descripcion = descripcion;
this.estado = estado;
this.fechaDeInicio = fechaDeInicio;
this.fechaDeFin = fechaDeInicio;
this.interesados = new ArrayList<>();
this.votos = new ArrayList<>();
this.palabrasClave = new ArrayList<>();

}

public Iniciativa(int id, String nombre, String area, Usuario proponente, String descripcion, EstadoIniciativa estado, Date fechaDeInicio, Date fechaDeFin, List<String> palabrasClave){
this.id = id;
this.nombre = nombre;
this.area = area;
this.proponente = proponente;
this.descripcion = descripcion;
this.estado = estado;
this.fechaDeInicio = fechaDeInicio;
this.fechaDeFin = fechaDeFin;
this.palabrasClave = palabrasClave;
this.interesados = new ArrayList<>();
this.votos = new ArrayList<>();

}

public int getId() {
return id;
}

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

public String getNombre() {
return nombre;
}

public void setNombre(String nombre) {
this.nombre = nombre;
}

public String getArea() {
return area;
}

public void setArea(String area) {
this.area = area;
}

public String getDescripcion() {
return descripcion;
}

public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}

public EstadoIniciativa getEstado() {
return estado;
}

public void setEstado(EstadoIniciativa estado) {
this.estado = estado;
}

public Date getFechaDeInicio() {
return fechaDeInicio;
}

public void setFechaDeInicio(Date fechaDeInicio) {
this.fechaDeInicio = fechaDeInicio;
}

public Date getFechaDeFin() {
return fechaDeFin;
}

public void setFechaDeFin(Date fechaDeFin) {
this.fechaDeFin = fechaDeFin;
}

public List<String> getPalabrasClave() {
return palabrasClave;
}

public void setPalabrasClave(List<String> palabrasClave) {
this.palabrasClave = palabrasClave;
}

public List<Usuario> getVotos() {
return votos;
}

public void setVotos(List<Usuario> votos) {
this.votos = votos;
}

public List<Usuario> getInteresados() {
return interesados;
}

public void setInteresados(List<Usuario> interesados) {
this.interesados = interesados;
}

public Usuario getProponente() {
return proponente;
}

public void setProponente(Usuario proponente) {
this.proponente = proponente;
}

@Override
public String toString() {
return "Iniciativa{" +
"id=" + id +
", nombre='" + nombre + '\'' +
", area='" + area + '\'' +
", proponente=" + proponente.getCorreo()+
", descripcion='" + descripcion + '\'' +
", estado=" + estado.name() +
", fechaDeInicio=" + fechaDeInicio+
", fechaDeFin=" + fechaDeFin + +
'}';
}
}
5 changes: 5 additions & 0 deletions src/main/java/edu/eci/cvds/entities/Rol.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package edu.eci.cvds.entities;

public enum Rol {
ADMINISTRADOR, PERSONAL_PMO, PROPONENTE, PUBLICO
}
24 changes: 19 additions & 5 deletions src/main/java/edu/eci/cvds/entities/Usuario.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ public class Usuario{
private String nombre;
private String correo;
private String contraseña;
private String rol;
private Rol rol;
private Estado estado;

private Usuario(String nombre, String correo, String contraseña, String rol){
public Usuario(){}

public Usuario(String nombre, String correo, String contraseña, Rol rol, Estado estado){
this.nombre = nombre;
this.correo = correo;
this.contraseña = contraseña;
this.rol = rol;
this.estado = estado;
}


public void setNombre(String nombre) {
this.nombre = nombre;
}
Expand All @@ -25,7 +30,7 @@ public void setCorreo(String correo) {
this.contraseña = contraseña;
}

public void setRol(String rol) {
public void setRol(Rol rol) {
this.rol = rol;
}

Expand All @@ -41,17 +46,26 @@ public String getCorreo() {
return contraseña;
}

public String getRol() {
public Rol getRol() {
return rol;
}

public Estado getEstado() {
return estado;
}

public void setEstado(Estado estado) {
this.estado = estado;
}

@Override
public String toString() {
return "Usuario{" +
"nombre='" + nombre + '\'' +
", correo='" + correo + '\'' +
", contraseña='" + contraseña + '\'' +
", rol='" + rol + '\'' +
", rol='" + rol.name() + '\'' +
", estado='" + estado.name() + '\'' +
'}';
}
}
18 changes: 14 additions & 4 deletions src/main/java/edu/eci/cvds/guice/GuiceContextListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import edu.eci.cvds.services.ServiciosIniciativa;
import edu.eci.cvds.services.ServiciosUsuario;
import edu.eci.cvds.services.impl.ServiciosIniciativaImpl;
import edu.eci.cvds.services.impl.ServiciosUsuarioImpl;
import org.mybatis.guice.XMLMyBatisModule;
import org.mybatis.guice.datasource.helper.JdbcHelper;
import com.google.inject.Guice;
Expand All @@ -14,8 +19,6 @@
import edu.eci.cvds.authentication.ShiroSession;
import edu.eci.cvds.persistence.*;
import edu.eci.cvds.persistence.mybatisimpl.*;
import edu.eci.cvds.services.ServiciosBancoDeProyectos;
import edu.eci.cvds.services.impl.ServiciosBancoDeProyectosImpl;


public class GuiceContextListener implements ServletContextListener {
Expand All @@ -32,9 +35,16 @@ protected void initialize() {
install(JdbcHelper.PostgreSQL);
setEnvironmentId("development");
setClassPathResource("mybatis-config.xml");
// TODO Add service class associated to Stub implementation
bind(ServiciosBancoDeProyectos.class).to(ServiciosBancoDeProyectosImpl.class);

//Services
bind(ServiciosUsuario.class).to(ServiciosUsuarioImpl.class);
bind(ServiciosIniciativa.class).to(ServiciosIniciativaImpl.class);

//Persistence
bind(UsuarioDAO.class).to(MyBatisUsuarioDAO.class);
bind(IniciativaDAO.class).to(MyBatisIniciativaDAO.class);

//Authentication
bind(SessionLogger.class).to(ShiroSession.class);

}
Expand Down
54 changes: 54 additions & 0 deletions src/main/java/edu/eci/cvds/persistence/IniciativaDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package edu.eci.cvds.persistence;

import edu.eci.cvds.entities.EstadoIniciativa;
import edu.eci.cvds.entities.Iniciativa;
import org.mybatis.guice.transactional.Transactional;

import java.util.List;

/**
*
*/
public interface IniciativaDAO {

/**
* Crea una nueva inciativa
* @param i Identificador de Iniciativa
* @throws PersistenceException
*/
@Transactional
void insertarIniciativa(Iniciativa i) throws PersistenceException;

/**
* Actuliza una iniciativa
* @param id Identificador de Iniciativa
* @param estado Estado a modificar la iniciativa
* @throws PersistenceException
*/
@Transactional
void modificarIniciativa(int id, EstadoIniciativa estado) throws PersistenceException;

/**
* Busqueda de inicitivas por su identificador
* @param id Identificador de Iniciativa
* @return Iniciativa
* @throws PersistenceException
*/
Iniciativa cargarIniciativa(int id) throws PersistenceException;

/**
* Busqueda de todas las inicitivas
* @return Listado de Iniciativa
* @throws PersistenceException
*/
List<Iniciativa> cargarIniciativas() throws PersistenceException;

/**
* Busqueda de todas las iniciativas por un tag en común
* @param tag palabras o grupo a relacionar iniciativas
* @return Listado de iniciativas
* @throws PersistenceException
*/
List<Iniciativa> cargarIniciativas(String tag) throws PersistenceException;

}
Loading