| @ -1,9 +1,16 @@ | |||||
| eclipse.preferences.version=1 | eclipse.preferences.version=1 | ||||
| org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 | |||||
| org.eclipse.jdt.core.compiler.compliance=1.5 | |||||
| org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | |||||
| org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 | |||||
| org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | |||||
| org.eclipse.jdt.core.compiler.compliance=11 | |||||
| org.eclipse.jdt.core.compiler.debug.lineNumber=generate | |||||
| org.eclipse.jdt.core.compiler.debug.localVariable=generate | |||||
| org.eclipse.jdt.core.compiler.debug.sourceFile=generate | |||||
| org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | |||||
| org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||||
| org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | |||||
| org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||||
| org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore | |||||
| org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning | |||||
| org.eclipse.jdt.core.compiler.processAnnotations=disabled | org.eclipse.jdt.core.compiler.processAnnotations=disabled | ||||
| org.eclipse.jdt.core.compiler.release=disabled | |||||
| org.eclipse.jdt.core.compiler.source=1.5 | |||||
| org.eclipse.jdt.core.compiler.release=enabled | |||||
| org.eclipse.jdt.core.compiler.source=11 | |||||
| @ -1,8 +1,22 @@ | |||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
| <modelVersion>4.0.0</modelVersion> | |||||
| <groupId>com.antoniofrische</groupId> | |||||
| <artifactId>perifericosAdvisor</artifactId> | |||||
| <version>0.0.1-SNAPSHOT</version> | |||||
| <name>PerifericosAdvisor</name> | |||||
| <description>una recomandacion de diferentes perifericos</description> | |||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
| <modelVersion>4.0.0</modelVersion> | |||||
| <groupId>com.openwebinars</groupId> | |||||
| <artifactId>19-MovieAdvisor</artifactId> | |||||
| <version>0.0.1-SNAPSHOT</version> | |||||
| <name>19-MovieAdvisor</name> | |||||
| <description>Ejemplo que integra todos los conocimientos del curso de Spring.</description> | |||||
| <dependencies> | |||||
| <dependency> | |||||
| <groupId>org.springframework</groupId> | |||||
| <artifactId>spring-context</artifactId> | |||||
| <version>5.0.8.RELEASE</version> | |||||
| </dependency> | |||||
| </dependencies> | |||||
| <properties> | |||||
| <maven.compiler.source>1.8</maven.compiler.source> | |||||
| <maven.compiler.target>1.8</maven.compiler.target> | |||||
| </properties> | |||||
| </project> | </project> | ||||
| @ -0,0 +1,36 @@ | |||||
| package com.antoniofrische.perifericosAdvisor.config; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.context.annotation.ComponentScan; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.context.annotation.PropertySource; | |||||
| @Configuration | |||||
| @ComponentScan(basePackages="com.antoniofrische.perifericosAdvisor") | |||||
| @PropertySource("classpath:/movieadvisor.properties") | |||||
| public class AppConfig { | |||||
| @Value("${file.path}") | |||||
| public String file; | |||||
| @Value("${file.csv.separator}") | |||||
| public String separator; | |||||
| @Value("${file.csv.list_separator}") | |||||
| public String listSeparator; | |||||
| public String getFile() { | |||||
| return file; | |||||
| } | |||||
| public String getSeparator() { | |||||
| return separator; | |||||
| } | |||||
| public String getListSeparator() { | |||||
| return listSeparator; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,15 @@ | |||||
| package com.antoniofrische.perifericosAdvisor.dao; | |||||
| import java.util.Collection; | |||||
| import com.antoniofrische.perifericosAdvisor.model.Periferico; | |||||
| public interface PerifericoDao { | |||||
| public Periferico findById(long id); | |||||
| public Collection<Periferico> findAll(); | |||||
| public void insert(Periferico periferico); | |||||
| public void edit(Periferico periferico); | |||||
| public void delete(long id); | |||||
| } | |||||
| @ -0,0 +1,75 @@ | |||||
| package com.antoniofrische.perifericosAdvisor.dao; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Collection; | |||||
| import java.util.List; | |||||
| import java.util.Optional; | |||||
| import javax.annotation.PostConstruct; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Repository; | |||||
| import com.antoniofrische.perifericosAdvisor.config.AppConfig; | |||||
| import com.antoniofrische.perifericosAdvisor.model.Periferico; | |||||
| @Repository | |||||
| public class PerifericoDaoImplMemory implements PerifericoDao { | |||||
| public List<Periferico> perifericos = new ArrayList<Periferico>(); | |||||
| @Autowired | |||||
| private AppConfig appConfig; | |||||
| @PostConstruct | |||||
| public void init() { | |||||
| perifericos = UtilPerifericoFileReader.readFile(appConfig.getFile(), appConfig.getSeparator(), appConfig.getListSeparator()); | |||||
| } | |||||
| public Periferico findById(long id) { | |||||
| Optional<Periferico> result = perifericos | |||||
| .stream() | |||||
| .filter(f -> f.getId() == id) | |||||
| .findFirst(); | |||||
| return result.orElse(null); | |||||
| } | |||||
| public Collection<Periferico> findAll() { | |||||
| return perifericos; | |||||
| } | |||||
| public void insert(Periferico periferico) { | |||||
| perifericos.add(periferico); | |||||
| } | |||||
| public void edit(Periferico periferico) { | |||||
| int index = getIndexOf(periferico.getId()); | |||||
| if (index != -1) | |||||
| perifericos.set(index, periferico); | |||||
| } | |||||
| public void delete(long id) { | |||||
| int index = getIndexOf(id); | |||||
| if (index != -1) | |||||
| perifericos.remove(index); | |||||
| } | |||||
| private int getIndexOf(long id) { | |||||
| boolean encontrado = false; | |||||
| int index = 0; | |||||
| while (!encontrado && index < perifericos.size()) { | |||||
| if (perifericos.get(index).getId() == id) | |||||
| encontrado = true; | |||||
| else | |||||
| index++; | |||||
| } | |||||
| return (encontrado) ? index : -1; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,40 @@ | |||||
| package com.antoniofrische.perifericosAdvisor.dao; | |||||
| import java.nio.file.Files; | |||||
| import java.nio.file.Paths; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Arrays; | |||||
| import java.util.List; | |||||
| import java.util.stream.Collectors; | |||||
| import org.springframework.util.ResourceUtils; | |||||
| import com.antoniofrische.perifericosAdvisor.model.Periferico; | |||||
| public class UtilPerifericoFileReader { | |||||
| public static List<Periferico> readFile(final String path, final String separator, final String listSeparator) { | |||||
| List<Periferico> result = new ArrayList<>(); | |||||
| try { | |||||
| result = Files | |||||
| .lines(Paths.get(ResourceUtils.getFile(path).toURI())) | |||||
| .skip(1) | |||||
| .map(line -> { | |||||
| String[] values = line.split(separator); | |||||
| return new Perifericos(Long.parseLong(values[0]), values[1], values[2],values[3],values[4],values[5],Boolean.parseBoolean(values[6])); | |||||
| }).collect(Collectors.toList()); | |||||
| } catch (Exception e) { | |||||
| System.err.println("Error de lectura del fichero de datos: imdb_data"); | |||||
| System.exit(-1); | |||||
| } | |||||
| return result; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,113 @@ | |||||
| package com.antoniofrische.perifericosAdvisor.model; | |||||
| public class Periferico { | |||||
| private int id; | |||||
| private String marca; | |||||
| private String nombre; | |||||
| private String descripcion; | |||||
| private String tipo; | |||||
| private String color; | |||||
| private boolean ifcable; | |||||
| public Periferico(int id, String marca, String nombre, String descripcion, String tipo, String color,boolean ifcable) { | |||||
| this.id = id; | |||||
| this.marca = marca; | |||||
| this.nombre = nombre; | |||||
| this.descripcion = descripcion; | |||||
| this.tipo = tipo; | |||||
| this.color = color; | |||||
| this.ifcable = ifcable; | |||||
| } | |||||
| public int getId() { | |||||
| return id; | |||||
| } | |||||
| public String getMarca() { | |||||
| return marca; | |||||
| } | |||||
| public String getNombre() { | |||||
| return nombre; | |||||
| } | |||||
| public String getDescripcion() { | |||||
| return descripcion; | |||||
| } | |||||
| public String getTipo() { | |||||
| return tipo; | |||||
| } | |||||
| public String getColor() { | |||||
| return color; | |||||
| } | |||||
| public boolean isIfcable() { | |||||
| return ifcable; | |||||
| } | |||||
| @Override | |||||
| public int hashCode() { | |||||
| final int prime = 31; | |||||
| int result = 1; | |||||
| result = prime * result + ((color == null) ? 0 : color.hashCode()); | |||||
| result = prime * result + ((descripcion == null) ? 0 : descripcion.hashCode()); | |||||
| result = prime * result + id; | |||||
| result = prime * result + (ifcable ? 1231 : 1237); | |||||
| result = prime * result + ((marca == null) ? 0 : marca.hashCode()); | |||||
| result = prime * result + ((nombre == null) ? 0 : nombre.hashCode()); | |||||
| result = prime * result + ((tipo == null) ? 0 : tipo.hashCode()); | |||||
| return result; | |||||
| } | |||||
| @Override | |||||
| public boolean equals(Object obj) { | |||||
| if (this == obj) | |||||
| return true; | |||||
| if (obj == null) | |||||
| return false; | |||||
| if (getClass() != obj.getClass()) | |||||
| return false; | |||||
| Periferico other = (Periferico) obj; | |||||
| if (color == null) { | |||||
| if (other.color != null) | |||||
| return false; | |||||
| } else if (!color.equals(other.color)) | |||||
| return false; | |||||
| if (descripcion == null) { | |||||
| if (other.descripcion != null) | |||||
| return false; | |||||
| } else if (!descripcion.equals(other.descripcion)) | |||||
| return false; | |||||
| if (id != other.id) | |||||
| return false; | |||||
| if (ifcable != other.ifcable) | |||||
| return false; | |||||
| if (marca == null) { | |||||
| if (other.marca != null) | |||||
| return false; | |||||
| } else if (!marca.equals(other.marca)) | |||||
| return false; | |||||
| if (nombre == null) { | |||||
| if (other.nombre != null) | |||||
| return false; | |||||
| } else if (!nombre.equals(other.nombre)) | |||||
| return false; | |||||
| if (tipo == null) { | |||||
| if (other.tipo != null) | |||||
| return false; | |||||
| } else if (!tipo.equals(other.tipo)) | |||||
| return false; | |||||
| return true; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return "perifericos [id=" + id + ", marca=" + marca + ", nombre=" + nombre + ", descripcion=" + descripcion | |||||
| + ", tipo=" + tipo + ", color=" + color + ", ifcable=" + ifcable + "]"; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,52 @@ | |||||
| Sintaxis: java -jar movieadvisor.jar [OPCIONES] | |||||
| -lg | |||||
| Lista los diferentes géneros de películas de la colección. | |||||
| No se pueden utilizar más parámetros. | |||||
| -ag genero1,genero2,genero... | |||||
| Lista aquellas películas que pertenecen a al menos uno de los géneros | |||||
| que se indican. El listado de géneros no puede incluir espacios. | |||||
| -tg genero1,genero2,genero... | |||||
| Lista aquellas películas que pertenecen a todos y cada uno de los | |||||
| géneros que se indican. El listado de géneros no puede incluir espacios. | |||||
| -y año | |||||
| Lista aquellas películas que se estrenaron en el año indicado. | |||||
| El año debe expresarse con 4 cifras. | |||||
| -b desde,hasta | |||||
| Lista aquellas películas que se estrenaron entre los años DESDE y HASTA. | |||||
| Los años indicados están incluidos. Deben expresarse con 4 cifras. | |||||
| -t titulo | |||||
| Lista aquellas películas cuyo título contiene la cadena proporcionada. | |||||
| Se ignorará el uso de mayúsculas/minúsculas en la comparación. | |||||
| -h | |||||
| Muestra este mensaje de ayuda. | |||||
| EJEMPLOS DE USO | |||||
| java -jar movieadvisor.jar -y 2018 -ag Action,Comedy | |||||
| Muestra las películas estrenadas de 2018 de acción y/o de comedia. | |||||
| java -jar movieadvisor.jar -t heart | |||||
| Muestra las películas cuyo título contiene la palabra heart. | |||||
| java -jar movieadvisor.jar -td Action,Sci-Fi -b 1990,2010 -t star | |||||
| Muestra las películas cuyo título contiene la palabra star, pertenecen al | |||||
| género de acción y ciencia ficción y fueron estrenadas entre 1990 y 2010. | |||||
| java -jar movieadvisor.jar -lg | |||||
| Muestra un listado con todos los géneros. | |||||
| LICENCIAS | |||||
| Los datos utilizados sobre películas utilizados en este ejemplo son | |||||
| reales y están sacados del sitio web www.imdb.com. Ten en cuenta | |||||
| que solo puede ser usada con fines personales y no comerciales. | |||||
| @ -0,0 +1,16 @@ | |||||
| id;marca;nombre;descripcion;tipo;color;cable | |||||
| 30;Razer;Pro gamingX;Raton de alta calidad;raton,negro y blanco;true | |||||
| 32;Roccat;Kone Aimo;Raton con alta DPI;raton,Blanco;true | |||||
| 33;Logitech;G930;Volante para videojuegos;Volante,negro y azul;true | |||||
| 40;HyperX;gamingTX;Altavozes para juagar;altavozes,negro y gris;true | |||||
| 12;Razer;Fly pro gaming;Raton mas ligero del mercado;raton,Rojo;false | |||||
| 23;HyperX;Pro XDR 2;Pantalla con colores reales;Pantalla,negro;true | |||||
| 51;MarsGaming;Alfombria MG18;alfombria para la mejor presicion en los jeugos;Alfombria,rojo y blanco;false | |||||
| 46;Roccat;Khan aimo;cascos confortables para horas de juego;Cascos,negro;true | |||||
| 90;HyperX;Hiper gaming H15;Teclado para quien quiere montar se lo mismo;teclado,rojo;true | |||||
| 37;HyperX;Alloy Core RGB;Teclado a mejor precio;teclado,negro y verde;true | |||||
| 18;Razer;titanium GPU;Suporte para aguantar tajetas graficas;suporte,negro metallico;true | |||||
| 02;Logitech;G815 lightspeed;Teclado de alta calidad con bluetooth;teclado,blanco;false | |||||
| 11;MarsGaming;MG318 bulletproof;cascos speciales para ambientes ruidosos;cascos,blanco;true | |||||
| 66;Razer;Enki;silla confortable para gaming;silla,negro y gris;false | |||||
| 91;Logitech;lightspeed pro 10;Raton inalambrico para llevar;raton,gris;false | |||||
| @ -0,0 +1,3 @@ | |||||
| file.path=classpath:imdb_data.csv | |||||
| file.csv.separator=; | |||||
| file.csv.list_separator=, | |||||
| @ -1,8 +0,0 @@ | |||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
| <modelVersion>4.0.0</modelVersion> | |||||
| <groupId>com.antoniofrische</groupId> | |||||
| <artifactId>perifericosAdvisor</artifactId> | |||||
| <version>0.0.1-SNAPSHOT</version> | |||||
| <name>PerifericosAdvisor</name> | |||||
| <description>una recomandacion de diferentes perifericos</description> | |||||
| </project> | |||||
| @ -1,7 +1,7 @@ | |||||
| #Generated by Maven Integration for Eclipse | #Generated by Maven Integration for Eclipse | ||||
| #Sat Nov 26 10:36:42 CET 2022 | |||||
| #Sat Nov 26 11:46:12 CET 2022 | |||||
| m2e.projectLocation=C\:\\Users\\AntonioFrische\\OneDrive - ABACCO Solutions\\Documents\\Schule_22_23_CFGS\\Acceso_Datos\\SpringTool_4\\SpringWorkspace\\perifericosAdvisor | m2e.projectLocation=C\:\\Users\\AntonioFrische\\OneDrive - ABACCO Solutions\\Documents\\Schule_22_23_CFGS\\Acceso_Datos\\SpringTool_4\\SpringWorkspace\\perifericosAdvisor | ||||
| m2e.projectName=perifericosAdvisor | m2e.projectName=perifericosAdvisor | ||||
| groupId=com.antoniofrische | |||||
| artifactId=perifericosAdvisor | |||||
| groupId=com.openwebinars | |||||
| artifactId=19-MovieAdvisor | |||||
| version=0.0.1-SNAPSHOT | version=0.0.1-SNAPSHOT | ||||
| @ -0,0 +1,22 @@ | |||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
| <modelVersion>4.0.0</modelVersion> | |||||
| <groupId>com.openwebinars</groupId> | |||||
| <artifactId>19-MovieAdvisor</artifactId> | |||||
| <version>0.0.1-SNAPSHOT</version> | |||||
| <name>19-MovieAdvisor</name> | |||||
| <description>Ejemplo que integra todos los conocimientos del curso de Spring.</description> | |||||
| <dependencies> | |||||
| <dependency> | |||||
| <groupId>org.springframework</groupId> | |||||
| <artifactId>spring-context</artifactId> | |||||
| <version>5.0.8.RELEASE</version> | |||||
| </dependency> | |||||
| </dependencies> | |||||
| <properties> | |||||
| <maven.compiler.source>1.8</maven.compiler.source> | |||||
| <maven.compiler.target>1.8</maven.compiler.target> | |||||
| </properties> | |||||
| </project> | |||||
| @ -0,0 +1,52 @@ | |||||
| Sintaxis: java -jar movieadvisor.jar [OPCIONES] | |||||
| -lg | |||||
| Lista los diferentes géneros de películas de la colección. | |||||
| No se pueden utilizar más parámetros. | |||||
| -ag genero1,genero2,genero... | |||||
| Lista aquellas películas que pertenecen a al menos uno de los géneros | |||||
| que se indican. El listado de géneros no puede incluir espacios. | |||||
| -tg genero1,genero2,genero... | |||||
| Lista aquellas películas que pertenecen a todos y cada uno de los | |||||
| géneros que se indican. El listado de géneros no puede incluir espacios. | |||||
| -y año | |||||
| Lista aquellas películas que se estrenaron en el año indicado. | |||||
| El año debe expresarse con 4 cifras. | |||||
| -b desde,hasta | |||||
| Lista aquellas películas que se estrenaron entre los años DESDE y HASTA. | |||||
| Los años indicados están incluidos. Deben expresarse con 4 cifras. | |||||
| -t titulo | |||||
| Lista aquellas películas cuyo título contiene la cadena proporcionada. | |||||
| Se ignorará el uso de mayúsculas/minúsculas en la comparación. | |||||
| -h | |||||
| Muestra este mensaje de ayuda. | |||||
| EJEMPLOS DE USO | |||||
| java -jar movieadvisor.jar -y 2018 -ag Action,Comedy | |||||
| Muestra las películas estrenadas de 2018 de acción y/o de comedia. | |||||
| java -jar movieadvisor.jar -t heart | |||||
| Muestra las películas cuyo título contiene la palabra heart. | |||||
| java -jar movieadvisor.jar -td Action,Sci-Fi -b 1990,2010 -t star | |||||
| Muestra las películas cuyo título contiene la palabra star, pertenecen al | |||||
| género de acción y ciencia ficción y fueron estrenadas entre 1990 y 2010. | |||||
| java -jar movieadvisor.jar -lg | |||||
| Muestra un listado con todos los géneros. | |||||
| LICENCIAS | |||||
| Los datos utilizados sobre películas utilizados en este ejemplo son | |||||
| reales y están sacados del sitio web www.imdb.com. Ten en cuenta | |||||
| que solo puede ser usada con fines personales y no comerciales. | |||||
| @ -0,0 +1,16 @@ | |||||
| id;marca;nombre;descripcion;tipo;color;cable | |||||
| 30;Razer;Pro gamingX;Raton de alta calidad;raton,negro y blanco;true | |||||
| 32;Roccat;Kone Aimo;Raton con alta DPI;raton,Blanco;true | |||||
| 33;Logitech;G930;Volante para videojuegos;Volante,negro y azul;true | |||||
| 40;HyperX;gamingTX;Altavozes para juagar;altavozes,negro y gris;true | |||||
| 12;Razer;Fly pro gaming;Raton mas ligero del mercado;raton,Rojo;false | |||||
| 23;HyperX;Pro XDR 2;Pantalla con colores reales;Pantalla,negro;true | |||||
| 51;MarsGaming;Alfombria MG18;alfombria para la mejor presicion en los jeugos;Alfombria,rojo y blanco;false | |||||
| 46;Roccat;Khan aimo;cascos confortables para horas de juego;Cascos,negro;true | |||||
| 90;HyperX;Hiper gaming H15;Teclado para quien quiere montar se lo mismo;teclado,rojo;true | |||||
| 37;HyperX;Alloy Core RGB;Teclado a mejor precio;teclado,negro y verde;true | |||||
| 18;Razer;titanium GPU;Suporte para aguantar tajetas graficas;suporte,negro metallico;true | |||||
| 02;Logitech;G815 lightspeed;Teclado de alta calidad con bluetooth;teclado,blanco;false | |||||
| 11;MarsGaming;MG318 bulletproof;cascos speciales para ambientes ruidosos;cascos,blanco;true | |||||
| 66;Razer;Enki;silla confortable para gaming;silla,negro y gris;false | |||||
| 91;Logitech;lightspeed pro 10;Raton inalambrico para llevar;raton,gris;false | |||||
| @ -0,0 +1,3 @@ | |||||
| file.path=classpath:imdb_data.csv | |||||
| file.csv.separator=; | |||||
| file.csv.list_separator=, | |||||