Esqueleto de proyecto inicial.
This commit is contained in:
13
1.sources/MyHealth/src/META-INF/application.xml
Normal file
13
1.sources/MyHealth/src/META-INF/application.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<application>
|
||||
<display-name>MyHealth</display-name>
|
||||
<module>
|
||||
<web>
|
||||
<web-uri>MyHealth.war</web-uri>
|
||||
<context-root>/MyHealth</context-root>
|
||||
</web>
|
||||
</module>
|
||||
<module>
|
||||
<ejb>MyHealth.jar</ejb>
|
||||
</module>
|
||||
</application>
|
||||
|
||||
15
1.sources/MyHealth/src/META-INF/persistence.xml
Normal file
15
1.sources/MyHealth/src/META-INF/persistence.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
|
||||
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
|
||||
version="1.0">
|
||||
<persistence-unit name="MyHealth">
|
||||
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
||||
<jta-data-source>java:jboss/postgresDS</jta-data-source>
|
||||
<properties>
|
||||
<property name="hibernate.dialect"
|
||||
value="org.hibernate.dialect.PostgreSQL94Dialect" />
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
||||
29
1.sources/MyHealth/src/TO/medicalTest/MedicalTestTO.java
Normal file
29
1.sources/MyHealth/src/TO/medicalTest/MedicalTestTO.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package TO.medicalTest;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Transfer object (TO) MedicalSpecialtyTO Para el intercambio de datos entre la
|
||||
* capa de interfaz y la capa de negocio
|
||||
*
|
||||
* Además esta clase facilita la implementación futura de una Capa SOA (Se
|
||||
* define la anotación para la serialización de esta clase: @XmlRootElement(name
|
||||
* = "medicalspeciality")
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "MedicalTestTO")
|
||||
public class MedicalTestTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
public MedicalTestTO() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
29
1.sources/MyHealth/src/TO/profile/ProfileTO.java
Normal file
29
1.sources/MyHealth/src/TO/profile/ProfileTO.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package TO.profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Transfer object (TO) MedicalSpecialtyTO Para el intercambio de datos entre la
|
||||
* capa de interfaz y la capa de negocio
|
||||
*
|
||||
* Además esta clase facilita la implementación futura de una Capa SOA (Se
|
||||
* define la anotación para la serialización de esta clase: @XmlRootElement(name
|
||||
* = "medicalspeciality")
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "ProfileTO")
|
||||
public class ProfileTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
public ProfileTO() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
29
1.sources/MyHealth/src/TO/systemAdmin/SystemAdminTO.java
Normal file
29
1.sources/MyHealth/src/TO/systemAdmin/SystemAdminTO.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package TO.systemAdmin;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Transfer object (TO) MedicalSpecialtyTO Para el intercambio de datos entre la
|
||||
* capa de interfaz y la capa de negocio
|
||||
*
|
||||
* Además esta clase facilita la implementación futura de una Capa SOA (Se
|
||||
* define la anotación para la serialización de esta clase: @XmlRootElement(name
|
||||
* = "medicalspeciality")
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "SystemAdminTO")
|
||||
public class SystemAdminTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
public SystemAdminTO() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
29
1.sources/MyHealth/src/TO/visit/VisitTO.java
Normal file
29
1.sources/MyHealth/src/TO/visit/VisitTO.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package TO.visit;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Transfer object (TO) MedicalSpecialtyTO Para el intercambio de datos entre la
|
||||
* capa de interfaz y la capa de negocio
|
||||
*
|
||||
* Además esta clase facilita la implementación futura de una Capa SOA (Se
|
||||
* define la anotación para la serialización de esta clase: @XmlRootElement(name
|
||||
* = "medicalspeciality")
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "TestClass")
|
||||
public class VisitTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
public VisitTO() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
52
1.sources/MyHealth/src/common/AuthorizationFilter.java
Normal file
52
1.sources/MyHealth/src/common/AuthorizationFilter.java
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
package common;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
@WebFilter(filterName = "AuthFilter", urlPatterns = { "*.xhtml" })
|
||||
public class AuthorizationFilter implements Filter {
|
||||
|
||||
public AuthorizationFilter() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
try {
|
||||
|
||||
HttpServletRequest reqt = (HttpServletRequest) request;
|
||||
HttpServletResponse resp = (HttpServletResponse) response;
|
||||
HttpSession ses = reqt.getSession(false);
|
||||
|
||||
String reqURI = reqt.getRequestURI();
|
||||
if (reqURI.indexOf("/login.xhtml") >= 0 || (ses != null && ses.getAttribute("username") != null)
|
||||
|| reqURI.indexOf("/public/") >= 0 || reqURI.contains("javax.faces.resource"))
|
||||
chain.doFilter(request, response);
|
||||
else
|
||||
resp.sendRedirect(reqt.getContextPath() + "/faces/login.xhtml");
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
}
|
||||
30
1.sources/MyHealth/src/common/SessionUtils.java
Normal file
30
1.sources/MyHealth/src/common/SessionUtils.java
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
package common;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
public class SessionUtils {
|
||||
|
||||
public static HttpSession getSession() {
|
||||
return (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
|
||||
}
|
||||
|
||||
public static HttpServletRequest getRequest() {
|
||||
return (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
|
||||
}
|
||||
|
||||
public static String getUserName() {
|
||||
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
|
||||
return session.getAttribute("username").toString();
|
||||
}
|
||||
|
||||
public static String getUserId() {
|
||||
HttpSession session = getSession();
|
||||
if (session != null)
|
||||
return (String) session.getAttribute("userid");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package ejb.medicalTest;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
|
||||
/**
|
||||
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
||||
* métodos de la capa de negocio que implementan la logica de negocio y la
|
||||
* interacción con la capa de persistencia.
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@Stateless
|
||||
public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
|
||||
// Persistence Unit Context
|
||||
@PersistenceContext(unitName = "MyHealth")
|
||||
private EntityManager entman;
|
||||
|
||||
public void ejbMethod(String parameter) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package ejb.medicalTest;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
/**
|
||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para
|
||||
* los clientes del EJB
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@Remote
|
||||
public interface MedicalTestFacadeRemote {
|
||||
/**
|
||||
* Definimos la interfaz remota
|
||||
*/
|
||||
public void ejbMethod(String parameter);
|
||||
}
|
||||
28
1.sources/MyHealth/src/ejb/profile/ProfileFacadeBean.java
Normal file
28
1.sources/MyHealth/src/ejb/profile/ProfileFacadeBean.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package ejb.profile;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
|
||||
/**
|
||||
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
||||
* métodos de la capa de negocio que implementan la logica de negocio y la
|
||||
* interacción con la capa de persistencia.
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@Stateless
|
||||
public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
|
||||
// Persistence Unit Context
|
||||
@PersistenceContext(unitName = "MyHealth")
|
||||
private EntityManager entman;
|
||||
|
||||
public void ejbMethod(String parameter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
18
1.sources/MyHealth/src/ejb/profile/ProfileFacadeRemote.java
Normal file
18
1.sources/MyHealth/src/ejb/profile/ProfileFacadeRemote.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package ejb.profile;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
/**
|
||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para
|
||||
* los clientes del EJB
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@Remote
|
||||
public interface ProfileFacadeRemote {
|
||||
/**
|
||||
* Definimos la interfaz remota
|
||||
*/
|
||||
public void ejbMethod(String parameter);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package ejb.systemAdmin;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
|
||||
/**
|
||||
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
||||
* métodos de la capa de negocio que implementan la logica de negocio y la
|
||||
* interacción con la capa de persistencia.
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@Stateless
|
||||
public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
|
||||
// Persistence Unit Context
|
||||
@PersistenceContext(unitName = "MyHealth")
|
||||
private EntityManager entman;
|
||||
|
||||
public void ejbMethod(String parameter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package ejb.systemAdmin;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
/**
|
||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para
|
||||
* los clientes del EJB
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@Remote
|
||||
public interface SystemAdminFacadeRemote {
|
||||
/**
|
||||
* Definimos la interfaz remota
|
||||
*/
|
||||
public void ejbMethod(String parameter);
|
||||
}
|
||||
28
1.sources/MyHealth/src/ejb/visit/VisitFacadeBean.java
Normal file
28
1.sources/MyHealth/src/ejb/visit/VisitFacadeBean.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package ejb.visit;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
|
||||
/**
|
||||
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
||||
* métodos de la capa de negocio que implementan la logica de negocio y la
|
||||
* interacción con la capa de persistencia.
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@Stateless
|
||||
public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
|
||||
// Persistence Unit Context
|
||||
@PersistenceContext(unitName = "MyHealth")
|
||||
private EntityManager entman;
|
||||
|
||||
public void ejbMethod(String parameter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
18
1.sources/MyHealth/src/ejb/visit/VisitFacadeRemote.java
Normal file
18
1.sources/MyHealth/src/ejb/visit/VisitFacadeRemote.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package ejb.visit;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
/**
|
||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para
|
||||
* los clientes del EJB
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@Remote
|
||||
public interface VisitFacadeRemote {
|
||||
/**
|
||||
* Definimos la interfaz remota
|
||||
*/
|
||||
public void ejbMethod(String parameter);
|
||||
}
|
||||
50
1.sources/MyHealth/src/jpa/TestTableJPA.java
Normal file
50
1.sources/MyHealth/src/jpa/TestTableJPA.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package jpa;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* Calse JPA MedicalSpecialty, para interactuar con la base de datos.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "TestTable")
|
||||
public class TestTableJPA implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* Class constructor methods
|
||||
*/
|
||||
public TestTableJPA() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TestTableJPA(String name, String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Id
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
15
1.sources/MyHealth/src/log4j.properties
Normal file
15
1.sources/MyHealth/src/log4j.properties
Normal file
@@ -0,0 +1,15 @@
|
||||
### direct log messages to stdout ###
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
||||
|
||||
### direct messages to file hibernate.log ###
|
||||
#log4j.appender.file=org.apache.log4j.FileAppender
|
||||
#log4j.appender.file.File=hibernate.log
|
||||
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
||||
|
||||
### set log levels - for more verbose logging change 'info' to 'debug' ###
|
||||
|
||||
log4j.rootLogger= info, stdout
|
||||
@@ -0,0 +1,51 @@
|
||||
package managedbean.medicalTest;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.medicalTest.MedicalTestFacadeRemote;
|
||||
|
||||
/**
|
||||
* ManagedBEan que gestiona la edición y actualización de una especialidad
|
||||
* médica.
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "MedicalTestMBean")
|
||||
@SessionScoped
|
||||
public class MedicalTestMBean implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@EJB
|
||||
private MedicalTestFacadeRemote remoteManager;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public MedicalTestMBean() throws Exception {
|
||||
initializeAdminFacadeRemote();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (MedicalTestFacadeRemote) ctx
|
||||
.lookup("java:app/myHealth.jar/MedicalTestFacadeBean!ejb.component.MedicalTestFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
51
1.sources/MyHealth/src/managedbean/profile/ProfileMBean.java
Normal file
51
1.sources/MyHealth/src/managedbean/profile/ProfileMBean.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package managedbean.profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
|
||||
/**
|
||||
* ManagedBEan que gestiona la edición y actualización de una especialidad
|
||||
* médica.
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "ManagedBeanName")
|
||||
@SessionScoped
|
||||
public class ProfileMBean implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@EJB
|
||||
private ProfileFacadeRemote remoteManager;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public ProfileMBean() throws Exception {
|
||||
initializeAdminFacadeRemote();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (ProfileFacadeRemote) ctx
|
||||
.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
68
1.sources/MyHealth/src/managedbean/systemAdmin/Login.java
Normal file
68
1.sources/MyHealth/src/managedbean/systemAdmin/Login.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package managedbean.systemAdmin;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import common.SessionUtils;
|
||||
|
||||
@ManagedBean
|
||||
@SessionScoped
|
||||
public class Login implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1094801825228386363L;
|
||||
|
||||
private String Password;
|
||||
private String msg;
|
||||
private String userName;
|
||||
|
||||
public String getPassword() {
|
||||
return Password;
|
||||
}
|
||||
|
||||
public void setPassword(String pwd) {
|
||||
this.Password = pwd;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getuserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setuserName(String user) {
|
||||
this.userName = user;
|
||||
}
|
||||
|
||||
// validate login
|
||||
public String validateUsernamePassword() {
|
||||
// TODO: Validar login
|
||||
boolean valid = true;
|
||||
if (valid) {
|
||||
HttpSession session = SessionUtils.getSession();
|
||||
session.setAttribute("username", userName);
|
||||
return "home";
|
||||
} else {
|
||||
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN,
|
||||
"Usuario o contraseña incorrecta", "Por favor, intentalo de nuevo"));
|
||||
return "login";
|
||||
}
|
||||
}
|
||||
|
||||
// logout event, invalidate session
|
||||
public String logout() {
|
||||
HttpSession session = SessionUtils.getSession();
|
||||
session.invalidate();
|
||||
return "home";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package managedbean.systemAdmin;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.systemAdmin.SystemAdminFacadeRemote;
|
||||
|
||||
/**
|
||||
* ManagedBEan que gestiona la edición y actualización de una especialidad
|
||||
* médica.
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "SystemAdminMBean")
|
||||
@SessionScoped
|
||||
public class SystemAdminMBean implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@EJB
|
||||
private SystemAdminFacadeRemote remoteManager;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public SystemAdminMBean() throws Exception {
|
||||
initializeAdminFacadeRemote();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (SystemAdminFacadeRemote) ctx
|
||||
.lookup("java:app/myHealth.jar/ClassFacadeBean!ejb.component.SystemAdminFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
51
1.sources/MyHealth/src/managedbean/visit/VisitMBean.java
Normal file
51
1.sources/MyHealth/src/managedbean/visit/VisitMBean.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package managedbean.visit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.visit.VisitFacadeRemote;
|
||||
|
||||
/**
|
||||
* ManagedBEan que gestiona la edición y actualización de una especialidad
|
||||
* médica.
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@ManagedBean(name = "SystemAdminMBean")
|
||||
@SessionScoped
|
||||
public class VisitMBean implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@EJB
|
||||
private VisitFacadeRemote remoteManager;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public VisitMBean() throws Exception {
|
||||
initializeAdminFacadeRemote();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (VisitFacadeRemote) ctx
|
||||
.lookup("java:app/myHealth.jar/ClassFacadeBean!ejb.component.VisitFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user