Skip to content
Snippets Groups Projects
Commit 92161579 authored by Lucas Garrido's avatar Lucas Garrido
Browse files

Implementacion de WEB Alta,Modificar de video

parent bad6ab05
No related branches found
No related tags found
No related merge requests found
......@@ -138,9 +138,7 @@ public class AltaVideo extends HttpServlet {
DtVideo vid = new DtVideo(0, pNombre, pDescripcion,duracion, data, pUrl, Priv, pCategoria, 0, 0);
sys.altaVideo(vid);
RequestDispatcher rd; //objeto para despachar
rd = request.getRequestDispatcher("/IniciarSesion.jsp");
rd.forward(request, response);
response.sendRedirect("/uytube/buscar?texto="+vid.getNombre());
} catch (Exception e) {
System.out.println(e.getMessage());
......
......@@ -5,8 +5,18 @@
*/
package com.uytube;
import Logica.DataType.DtVideo;
import Logica.Enumerados.Privacidad;
import Logica.Fabrica;
import Logica.Interfaces.IUsuario;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Time;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
......@@ -35,7 +45,7 @@ public class ModificarVideo extends HttpServlet {
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet ModificarVideo</title>");
out.println("<title>Servlet ModificarVideo</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet ModificarVideo at " + request.getContextPath() + "</h1>");
......@@ -56,7 +66,25 @@ public class ModificarVideo extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
try {
int id = Integer.parseInt(request.getParameter("id"));
IUsuario sys = Fabrica.getInstancia().getIUsuario();
boolean sesionIniciada = sys.sesionIniciada();
ArrayList<String> cate = sys.listarCategorias();
DtVideo video = sys.seleccionarVideo(id);
request.setAttribute("video", video);
request.setAttribute("Categorias", cate);
request.setAttribute("sesionIniciada", sesionIniciada);
RequestDispatcher rd; //objeto para despachar
rd = request.getRequestDispatcher("/ModificarVideo.jsp");
rd.forward(request, response);
} catch (Exception e) {
RequestDispatcher rd; //objeto para despachar
rd = request.getRequestDispatcher("/");
rd.forward(request, response);
}
}
/**
......@@ -70,7 +98,46 @@ public class ModificarVideo extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
try {
IUsuario sys = Fabrica.getInstancia().getIUsuario();
String pNombre = request.getParameter("nombre");
String pDuracion = request.getParameter("duracion");
String pUrl = request.getParameter("url");
String pDescripcion = request.getParameter("descripcion");
String pCategoria = request.getParameter("categoria");
String pPrivacidad = request.getParameter("privacidad");
String pFecha = request.getParameter("fecha");
Privacidad Priv = Privacidad.PRIVADO;
if (pPrivacidad != null && pPrivacidad.equals("PUBLICO")) {
Priv = Privacidad.PUBLICO;
}
//============ Casteo de string a date =================================
SimpleDateFormat formato = new SimpleDateFormat("yyyy-mm-dd");
Date fechaDate = null;
try {
fechaDate = formato.parse(pFecha);
} catch (ParseException ex) {
RequestDispatcher rd; //objeto para despachar
rd = request.getRequestDispatcher("/");
rd.forward(request, response);
}
java.sql.Date data = new java.sql.Date(fechaDate.getTime());
//======================================================================
//============= Casteo de string a Time ================================
Time duracion = java.sql.Time.valueOf(pDuracion);
//======================================================================
DtVideo vid = new DtVideo(0, pNombre, pDescripcion, duracion, data, pUrl, Priv, pCategoria, 0, 0);
sys.modificarVideo(vid);
response.sendRedirect("/uytube/buscar?texto="+vid.getNombre());
} catch (Exception e) {
System.out.println(e.getMessage());
RequestDispatcher rd; //objeto para despachar
rd = request.getRequestDispatcher("/");
rd.forward(request, response);
}
}
/**
......
......@@ -64,20 +64,19 @@
<%
}
%>
<div class="contenido">
<section class="contenido-flexible">
<!--================== Aca va el contenido central para agregar ========================== -->
<h3>Alta de video</h3>
<form class="form-alta-video" action="/uytube/video-agregar" method="post" >
<div class="form-group row">
<div class="form-group col-md-10">
<div class="form-group col-md-9">
<label for="inputNombre">Nombre</label>
<input type="text" class="form-control" name="nombre" id="inputNombre" placeholder="Nombre del video">
</div>
<div class="form-group col-md-2">
<div class="form-group col-md-3">
<label for="inputDuracion">Duración</label>
<input type="time" step='1' class="form-control" name="duracion" id="inputDuracion" placeholder="Duración">
<input type="time" step='1'class="form-control" name="duracion" id="inputDuracion" placeholder="Duración">
</div>
</div>
<div class="form-group row">
......
......@@ -4,14 +4,179 @@
Author : administrador
--%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="Logica.Enumerados.Privacidad"%>
<%@page import="Logica.DataType.DtVideo"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<html lang="es">
<%
DtVideo video = (DtVideo) request.getAttribute("video");
ArrayList<String> Categorias = (ArrayList) request.getAttribute("Categorias");
boolean sesionIniciada = (boolean) request.getAttribute("sesionIniciada");
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/body.css">
<link rel="stylesheet" type="text/css" href="css/header.css">
<link rel="stylesheet" type="text/css" href="css/menu.css">
<link rel="stylesheet" type="text/css" href="css/widget.css">
<link rel="stylesheet" type="text/css" href="css/footer.css">
<link rel="stylesheet" type="text/css" href="css/contenido-alta-video.css">
<link rel="stylesheet" type="text/css" href="iconos/style.css">
<link rel="icon" type="image/png" href="imagenes/icono.png" />
<title>UyTube</title>
</head>
<body>
<h1>ModificarVideo</h1>
<%
if (sesionIniciada) {
%>
<%@ include file='include/header-usuario.html' %>
<%
} else {
%>
<%@ include file='include/header-visitante.html' %>
<%
}
%>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="relleno-header"></div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<section class="principal">
<%
if (sesionIniciada) {
%>
<%@ include file='include/menu-usuario.html' %>
<%
} else {
%>
<%@ include file='include/menu-visitante.html' %>
<%
}
%>
<div class="contenido">
<section class="contenido-flexible">
<!--================== Aca va el contenido central para agregar ========================== -->
<h3>Modificar de video</h3>
<form class="form-alta-video" action="/uytube/video-modificar" method="post" >
<div class="form-group row">
<div class="form-group col-md-9">
<label for="inputNombre">Nombre</label>
<input value="<%= video.getNombre()%>" type="text" class="form-control" name="nombre" id="inputNombre" placeholder="Nombre del video">
</div>
<div class="form-group col-md-3">
<label for="inputDuracion">Duración</label>
<input value="<%=video.getDuracion()%>" type="time" step='1' class="form-control" name="duracion" id="inputDuracion" placeholder="Duración">
</div>
</div>
<div class="form-group row">
<div class="form-group col-md-12">
<label for="inputUrl">URL</label>
<input value="<%= video.getUrlVideoOriginal()%>"type="url" class="form-control" name="url" id="inputUrl" placeholder="URL">
</div>
</div>
<div class="form-group row">
<div class="form-group col-md-12">
<label for="inputDescripcion">Descripción</label>
<textarea class="form-control" name="descripcion" id="inputDescripcion" rows="3"><%=video.getDescripcion()%></textarea>
</div>
</div>
<div class="form-group row">
<div class="form-group col-md-4">
<label for="cc-name">Privacidad del video</label>
<%
if (video.getPrivacidad() == Privacidad.PRIVADO) {
%>
<div class="custom-control custom-radio">
<input id="publico" name="privacidad" type="radio" class="custom-control-input" >
<label class="custom-control-label" for="publico">Publico</label>
</div>
<div class="custom-control custom-radio">
<input id="privado" name="privacidad" name="foto" type="radio" class="custom-control-input" checked>
<label class="custom-control-label" for="privado">Privado</label>
</div>
<%
}
%>
<% if (video.getPrivacidad() == Privacidad.PUBLICO) {
%>
<div class="custom-control custom-radio">
<input id="publico" name="privacidad" type="radio" class="custom-control-input" checked>
<label class="custom-control-label" for="publico">Publico</label>
</div>
<div class="custom-control custom-radio">
<input id="privado" name="privacidad" name="foto" type="radio" class="custom-control-input">
<label class="custom-control-label" for="privado">Privado</label>
</div>
<%
}
%>
</div>
<div class="form-group col-md-4">
<%
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String fecha = df.format(video.getFechaPublicacion());
%>
<label for="inputFecha">Fecha</label>
<input value="<%= fecha %>" type="date" name="fecha" class="form-control" id="inputFecha">
</div>
<div class="form-group col-md-4">
<label for="inputCategoria">Categoría</label>
<select id="inputCategoria" name="categoria" class="form-control">
<%
for (String l : Categorias) {
if (video.getCategoria().equals(l)) {
%>
<option selected = "selected"> <%= l%> </option>
<%
} else {
%>
<option> <%= l%> </option>
<%
}
}
%>
</select>
</div>
</div>
<button type="submit" class="btn btn-primary">Modificar video</button>
</div>
</form>
<!-- Fin del contenido central -->
</section>
</div>
</section>
</div>
</div>
</div>
<%@ include file='include/widgets.html' %>
<%@ include file='include/footer.html' %>
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/bootstrap.bundle.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/funciones.js"></script>
</body>
</html>
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