@ -0,0 +1,51 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<classpath> | |||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | |||
<attributes> | |||
<attribute name="optional" value="true"/> | |||
<attribute name="maven.pomderived" value="true"/> | |||
</attributes> | |||
</classpathentry> | |||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | |||
<attributes> | |||
<attribute name="maven.pomderived" value="true"/> | |||
</attributes> | |||
</classpathentry> | |||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | |||
<attributes> | |||
<attribute name="optional" value="true"/> | |||
<attribute name="maven.pomderived" value="true"/> | |||
<attribute name="test" value="true"/> | |||
</attributes> | |||
</classpathentry> | |||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> | |||
<attributes> | |||
<attribute name="maven.pomderived" value="true"/> | |||
<attribute name="test" value="true"/> | |||
</attributes> | |||
</classpathentry> | |||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | |||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | |||
<attributes> | |||
<attribute name="maven.pomderived" value="true"/> | |||
</attributes> | |||
</classpathentry> | |||
<classpathentry kind="src" path="target/generated-sources/annotations"> | |||
<attributes> | |||
<attribute name="optional" value="true"/> | |||
<attribute name="maven.pomderived" value="true"/> | |||
<attribute name="ignore_optional_problems" value="true"/> | |||
<attribute name="m2e-apt" value="true"/> | |||
</attributes> | |||
</classpathentry> | |||
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations"> | |||
<attributes> | |||
<attribute name="optional" value="true"/> | |||
<attribute name="maven.pomderived" value="true"/> | |||
<attribute name="ignore_optional_problems" value="true"/> | |||
<attribute name="m2e-apt" value="true"/> | |||
<attribute name="test" value="true"/> | |||
</attributes> | |||
</classpathentry> | |||
<classpathentry kind="output" path="target/classes"/> | |||
</classpath> |
@ -0,0 +1,23 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<projectDescription> | |||
<name>MovieAdvisor</name> | |||
<comment></comment> | |||
<projects> | |||
</projects> | |||
<buildSpec> | |||
<buildCommand> | |||
<name>org.eclipse.jdt.core.javabuilder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
<buildCommand> | |||
<name>org.eclipse.m2e.core.maven2Builder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
</buildSpec> | |||
<natures> | |||
<nature>org.eclipse.jdt.core.javanature</nature> | |||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | |||
</natures> | |||
</projectDescription> |
@ -0,0 +1,2 @@ | |||
eclipse.preferences.version=1 | |||
org.eclipse.jdt.apt.aptEnabled=false |
@ -0,0 +1,17 @@ | |||
eclipse.preferences.version=1 | |||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | |||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate | |||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 | |||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | |||
org.eclipse.jdt.core.compiler.compliance=17 | |||
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.enumIdentifier=error | |||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | |||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning | |||
org.eclipse.jdt.core.compiler.processAnnotations=disabled | |||
org.eclipse.jdt.core.compiler.release=disabled | |||
org.eclipse.jdt.core.compiler.source=17 |
@ -0,0 +1,4 @@ | |||
activeProfiles= | |||
eclipse.preferences.version=1 | |||
resolveWorkspaceProjects=true | |||
version=1 |
@ -0,0 +1,21 @@ | |||
<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.ims</groupId> | |||
<artifactId>MovieAdvisor</artifactId> | |||
<version>0.0.1-SNAPSHOT</version> | |||
<name>MovieAdvisor</name> | |||
<description>Gran recomendador de peliculas</description> | |||
<dependencies> | |||
<dependency> | |||
<groupId>org.springframework</groupId> | |||
<artifactId>spring-context</artifactId> | |||
<version>5.3.23</version> | |||
</dependency> | |||
<!--https://www.baeldung.com/spring-postconstruct-predestroy --> | |||
<dependency> | |||
<groupId>javax.annotation</groupId> | |||
<artifactId>javax.annotation-api</artifactId> | |||
<version>1.3.2</version> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@ -0,0 +1,37 @@ | |||
package com.ims.studentManager.ConfigPackage; | |||
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.ims") | |||
@PropertySource("classpath:/movieadvisor.properties") | |||
public class AppConfig { | |||
@Value("${file.path}") | |||
private String file; | |||
@Value("${file.csv.separator}") | |||
private String separator; | |||
@Value("${file.csv.list_separator}") | |||
private String listSeparator; | |||
public String getFile() { | |||
return file; | |||
} | |||
public String getSeparator() { | |||
return separator; | |||
} | |||
public String getListSeparator() { | |||
return listSeparator; | |||
} | |||
} |
@ -0,0 +1,22 @@ | |||
package com.ims.studentManager; | |||
import org.springframework.context.ApplicationContext; | |||
import org.springframework.context.annotation.AnnotationConfigApplicationContext; | |||
import com.ims.studentManager.ConfigPackage.AppConfig; | |||
public class StudentManagerApp { | |||
public static void main(String args[]) { | |||
ApplicationContext appContext = new AnnotationConfigApplicationContext(AppConfig.class); | |||
StudentManagerRunApp runApp = appContext.getBean(StudentManagerRunApp.class); | |||
runApp.run(args); | |||
((AnnotationConfigApplicationContext) appContext).close(); | |||
} | |||
} |
@ -0,0 +1,39 @@ | |||
package com.ims.studentManager; | |||
import java.io.FileNotFoundException; | |||
import java.io.IOException; | |||
import java.nio.file.Files; | |||
import java.nio.file.Paths; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.PostConstruct; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.util.ResourceUtils; | |||
@Component | |||
public class StudentManagerHelp { | |||
private String help; | |||
@PostConstruct | |||
public void init() { | |||
try { | |||
// @formatter:off | |||
help = Files | |||
.lines(Paths.get(ResourceUtils.getFile("classpath:ayuda.txt").toURI())) | |||
.collect(Collectors.joining("\n")); | |||
// @formatter:on | |||
} catch (IOException e) { | |||
System.err.println("Error cargando el texto de ayuda"); | |||
System.exit(-1); | |||
} | |||
} | |||
public String getHelp() { | |||
return help; | |||
} | |||
} |
@ -0,0 +1,99 @@ | |||
package com.ims.studentManager; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Component; | |||
import com.ims.studentManager.service.StudentQueryService; | |||
import com.ims.studentManager.service.StudentService; | |||
import com.ims.studentManger.Package.Student; | |||
@Component | |||
public class StudentManagerRunApp { | |||
@Autowired | |||
private StudentService studentService; | |||
@Autowired | |||
private StudentQueryService studentQueryService; | |||
private StudentManagerHelp help; | |||
public void run(String args[]) { | |||
if(args.length < 1) { | |||
System.out.println("Error de sintaxis"); | |||
System.out.println(help.getHelp()); | |||
} else if(args.length == 1) { | |||
switch(args[0].toLowerCase()) { | |||
case "-lm": | |||
studentService.findAllMarks().forEach(System.out::println); | |||
break; | |||
case "-h": | |||
System.out.println(help.getHelp()); | |||
break; | |||
default: | |||
System.out.println("Error de sintaxis"); | |||
System.out.println(help.getHelp()); | |||
} | |||
} else if (args.length % 2 != 0) { | |||
System.out.println("Error de sintaxis"); | |||
System.out.println(help.getHelp()); | |||
} else if (args.length > 8) { | |||
System.out.println("Error de sintaxis"); | |||
System.out.println(help.getHelp()); | |||
} else { | |||
List<String[]> argumentos = new ArrayList<>(); | |||
for(int i = 0;i<args.length;i+=2) { | |||
argumentos.add(new String[] {args[i], args[i+1]}); | |||
} | |||
boolean error = false; | |||
for(String[] argumento : argumentos) { | |||
switch(argumento[0].toLowerCase()) { | |||
case "-am": | |||
studentQueryService.anyMark(argumento[1].split(",")); | |||
break; | |||
case "-tg": | |||
studentQueryService.allMarks(argumento[1].split(",")); | |||
break; | |||
case "-g": | |||
studentQueryService.grade(argumento[1]); | |||
break; | |||
case "-b": | |||
String[] marks = argumento[1].split(","); | |||
studentQueryService.betweenAvgMark(Float.parseFloat(marks[0]), Float.parseFloat(marks[1])); | |||
break; | |||
case "-t": | |||
studentQueryService.nameContains(argumento[1]); | |||
break; | |||
default: error = true; | |||
System.out.println("Error de sintaxis"); | |||
System.out.println(help.getHelp()); | |||
} | |||
} | |||
if(!error) { | |||
Collection<Student> result = studentQueryService.exec(); | |||
System.out.printf("%s\t%-50s\t%s\t%s\n","ID","NAME","GRADE","MARKS"); | |||
if(result != null) { | |||
result.forEach(f -> System.out.printf("%s\t%-50s\t%s\t%s\n",f.getId() | |||
,f.getName(),f.getGrade(), | |||
f.getMarks().stream().collect(Collectors.joining(", ")))); | |||
}else { | |||
System.out.println("No hay Alumnos con esos criterios. No lo siento, deja de usarme"); | |||
} | |||
} | |||
} | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
package com.ims.studentManager.dao; | |||
import java.util.Collection; | |||
import com.ims.studentManger.Package.Student; | |||
public interface StudentDao { | |||
public Student findById(long id); | |||
public Collection<Student> findAll(); | |||
public void insert(Student student); | |||
public void edit(Student student); | |||
public void delete(long id); | |||
} |
@ -0,0 +1,75 @@ | |||
package com.ims.studentManager.dao; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import java.util.Optional; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Repository; | |||
import com.ims.studentManager.ConfigPackage.AppConfig; | |||
import com.ims.studentManger.Package.Student; | |||
@Repository | |||
public class StudentDaoImplMemory implements StudentDao{ | |||
public List<Student> students = new ArrayList<>(); | |||
@Autowired | |||
private AppConfig appConfig; | |||
public void init() { | |||
students = UtilStudentFileReader.readFile(appConfig.getFile(),appConfig.getSeparator(),appConfig.getListSeparator()); | |||
} | |||
public Student findById(long id) { | |||
// @formatter:off | |||
Optional<Student> result = students | |||
.stream() | |||
.filter(f -> f.getId() == id) | |||
.findFirst(); | |||
// @formatter:on | |||
return result.orElse(null); | |||
} | |||
public Collection<Student> findAll() { | |||
return students; | |||
} | |||
public void insert(Student student) { | |||
students.add(student); | |||
} | |||
public void edit(Student student) { | |||
int index = getIndexOf(student.getId()); | |||
if(index != -1) | |||
students.set(index, student); | |||
} | |||
public void delete(long id) { | |||
int index = getIndexOf(id); | |||
if(index != -1) | |||
students.remove(index); | |||
} | |||
private int getIndexOf(long id) { | |||
boolean encontrado = false; | |||
int index = 0; | |||
while(!encontrado && index < students.size()) { | |||
if(students.get(index).getId() == id) | |||
encontrado = true; | |||
else | |||
index++; | |||
} | |||
return (encontrado) ? index : -1; | |||
} | |||
} |
@ -0,0 +1,42 @@ | |||
package com.ims.studentManager.dao; | |||
import java.io.FileNotFoundException; | |||
import java.io.IOException; | |||
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.ims.studentManger.Package.Student; | |||
public class UtilStudentFileReader { | |||
public static List<Student> readFile(final String path,final String separator,final String listSeparator) { | |||
List<Student> result = new ArrayList<>(); | |||
//@formatter:off | |||
try { | |||
result = Files.lines(Paths.get(ResourceUtils.getFile(path).toURI())) | |||
.skip(1) | |||
.map(line -> { | |||
String[] values = line.split(separator); | |||
return new Student(Long.parseLong(values[0]),values[1],values[2], | |||
Arrays.asList(values[3].split(listSeparator))); | |||
}).collect(Collectors.toList()); | |||
} catch (IOException e) { | |||
System.out.println("Error en la lectura de datos del fichero"); | |||
e.printStackTrace(); | |||
} | |||
//@formatter:on | |||
return result; | |||
} | |||
} |
@ -0,0 +1,16 @@ | |||
package com.ims.studentManager.service; | |||
import java.util.Collection; | |||
import com.ims.studentManger.Package.Student; | |||
public interface StudentQueryService { | |||
public Collection<Student> exec(); | |||
public StudentQueryService anyMark(String... marks); | |||
public StudentQueryService allMarks(String... marks); | |||
public StudentQueryService grade(String grade); | |||
public StudentQueryService betweenAvgMark(float max,float min); | |||
public StudentQueryService nameContains(String name); | |||
} |
@ -0,0 +1,75 @@ | |||
package com.ims.studentManager.service; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import java.util.function.Predicate; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.PostConstruct; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import com.ims.studentManager.dao.StudentDao; | |||
import com.ims.studentManger.Package.Student; | |||
@Service | |||
public class StudentQueryServiceImpl implements StudentQueryService { | |||
@Autowired | |||
private StudentDao dao; | |||
private Predicate<Student> predicate; | |||
@PostConstruct | |||
public void init() { | |||
predicate = null; | |||
} | |||
@Override | |||
public Collection<Student> exec() { | |||
// @formatter:off | |||
return dao.findAll() | |||
.stream() | |||
.filter(predicate) | |||
.collect(Collectors.toList()); | |||
// @formatter:on | |||
} | |||
@Override | |||
public StudentQueryService anyMark(String... marks) { | |||
Predicate<Student> pAnyMark = (student -> Arrays.stream(marks).allMatch(student.getMarks()::contains)); | |||
predicate = (predicate == null) ? pAnyMark : predicate.and(pAnyMark); | |||
return this; | |||
} | |||
@Override | |||
public StudentQueryService allMarks(String... marks) { | |||
Predicate<Student> pAllMarks = (student -> Arrays.stream(marks).anyMatch(student.getMarks()::contains)); | |||
predicate = (predicate == null) ? pAllMarks : predicate.and(pAllMarks); | |||
return this; | |||
} | |||
@Override | |||
public StudentQueryService grade(String grade) { | |||
Predicate<Student> pGrade = (student -> student.getGrade().equalsIgnoreCase(grade)); | |||
predicate = (predicate == null) ? pGrade : predicate.and(pGrade); | |||
return this; | |||
} | |||
@Override | |||
public StudentQueryService betweenAvgMark(float max, float min) { | |||
// TODO Auto-generated method stub | |||
return null; | |||
} | |||
@Override | |||
public StudentQueryService nameContains(String name) { | |||
Predicate<Student> pNameContains = (student -> student.getName().toLowerCase().contains(name.toLowerCase())); | |||
predicate = (predicate == null) ? pNameContains : predicate.and(pNameContains); | |||
return this; | |||
} | |||
} |
@ -0,0 +1,65 @@ | |||
package com.ims.studentManager.service; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import com.ims.studentManager.dao.StudentDao; | |||
import com.ims.studentManger.Package.Student; | |||
@Service | |||
public class StudentService { | |||
@Autowired | |||
StudentDao studentDao; | |||
@Autowired | |||
StudentQueryService queryService; | |||
public Collection<String> findAllMarks() { | |||
List<String> result = null; | |||
// @formatter:off | |||
result = studentDao.findAll() | |||
.stream() | |||
.map(f -> f.getMarks()) | |||
.flatMap(lista -> lista.stream()) | |||
.distinct() | |||
.sorted() | |||
.collect(Collectors.toList()); | |||
// @formatter:on | |||
return result; | |||
} | |||
public Collection<Student> findByAnyMark(String... marks) { | |||
return queryService.anyMark(marks).exec(); | |||
} | |||
public Collection<Student> findByAllMarks(String... marks) { | |||
return queryService.allMarks(marks).exec(); | |||
} | |||
public Collection<Student> findByGrade(String grade) { | |||
return queryService.grade(grade).exec(); | |||
} | |||
public Collection<Student> findBetweenYears(float max, float min) { | |||
return queryService.betweenAvgMark(max, min).exec(); | |||
} | |||
public Collection<Student> findByNameContains(String title) { | |||
return queryService.nameContains(title).exec(); | |||
} | |||
public Collection<Student> findAll() { | |||
return studentDao.findAll(); | |||
} | |||
} |
@ -0,0 +1,110 @@ | |||
package com.ims.studentManger.Package; | |||
import java.util.List; | |||
/** | |||
* | |||
* La clase modelo que articula el programa. Permite | |||
* manejar la información mínima sobre una película. | |||
* Si hubíeramos utilizado Spring Data y una base de datos, | |||
* seguramente estaría anotada con @Entity | |||
* | |||
* | |||
* @author OpenWebinars | |||
* | |||
*/ | |||
public class Student { | |||
private long id; | |||
private String name; | |||
private String grade; | |||
private List<String> marks; | |||
public Student(long id, String name, String grade, List<String> marks) { | |||
this.id = id; | |||
this.name = name; | |||
this.marks = marks; | |||
this.grade = grade; | |||
} | |||
public long getId() { | |||
return id; | |||
} | |||
public void setId(long id) { | |||
this.id = id; | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
public List<String> getMarks() { | |||
return marks; | |||
} | |||
public void setMarks(List<String> marks) { | |||
this.marks = marks; | |||
} | |||
public String getGrade() { | |||
return grade; | |||
} | |||
public void setGrade(String grade) { | |||
this.grade = grade; | |||
} | |||
@Override | |||
public int hashCode() { | |||
final int prime = 31; | |||
int result = 1; | |||
result = prime * result + ((grade == null) ? 0 : grade.hashCode()); | |||
result = prime * result + (int) (id ^ (id >>> 32)); | |||
result = prime * result + ((marks == null) ? 0 : marks.hashCode()); | |||
result = prime * result + ((name == null) ? 0 : name.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; | |||
Student other = (Student) obj; | |||
if (grade == null) { | |||
if (other.grade != null) | |||
return false; | |||
} else if (!grade.equals(other.grade)) | |||
return false; | |||
if (id != other.id) | |||
return false; | |||
if (marks == null) { | |||
if (other.marks != null) | |||
return false; | |||
} else if (!marks.equals(other.marks)) | |||
return false; | |||
if (name == null) { | |||
if (other.name != null) | |||
return false; | |||
} else if (!name.equals(other.name)) | |||
return false; | |||
return true; | |||
} | |||
@Override | |||
public String toString() { | |||
return "Student [id=" + id + ", name=" + name + ", marks=" + marks + ", grade=" + grade + "]"; | |||
} | |||
} |
@ -0,0 +1,51 @@ | |||
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;name;grade;marks | |||
1;Juan;1ºDAM;5,3,4,6,5 | |||
2;Pepe;2ºDAM;6,5,7,5,6 | |||
3;Alberto;1ºDAM;7,8,5,4,9 | |||
4;Ivan;2ºDAM;3,6,5,4,2 | |||
5;Anna;SMX;,8,5,7,6,9 | |||
6;Eva;1ºDAM;5,5,5,4,5 | |||
7;Toñi;SMX;4,9,7,9,6 | |||
8;Vicente;2ºDAM;6,5,7,5,6 | |||
9;Jesus;SMX;4,3,5,7,6 | |||
10;Daniel;1ºDAM;1,2,7,6,4 | |||
11;Sandra;SMX;4,5,5,4,6 | |||
12;Alejandro;SMX;7,9,4,5,3 | |||
13;Martina;1ºDAM;5,1,9,7,6 | |||
14;Rocio;1ºDAM;5,6,4,8,9 | |||
15;Godofredo;2ºDAM;9,9,9,9,9 |
@ -0,0 +1,3 @@ | |||
file.path=classpath:bbdd.csv | |||
file.csv.separator=; | |||
file.csv.list_separator=, |
@ -0,0 +1,5 @@ | |||
Manifest-Version: 1.0 | |||
Built-By: Ivan | |||
Build-Jdk: 17.0.4.1 | |||
Created-By: Maven Integration for Eclipse | |||
@ -0,0 +1,7 @@ | |||
#Generated by Maven Integration for Eclipse | |||
#Thu Nov 17 19:27:49 CET 2022 | |||
m2e.projectLocation=C\:\\Users\\Ivan\\Documents\\workspace-spring-tool-suite-4-4.16.0.RELEASE\\MovieAdvisor | |||
m2e.projectName=MovieAdvisor | |||
groupId=com.ims | |||
artifactId=MovieAdvisor | |||
version=0.0.1-SNAPSHOT |
@ -0,0 +1,21 @@ | |||
<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.ims</groupId> | |||
<artifactId>MovieAdvisor</artifactId> | |||
<version>0.0.1-SNAPSHOT</version> | |||
<name>MovieAdvisor</name> | |||
<description>Gran recomendador de peliculas</description> | |||
<dependencies> | |||
<dependency> | |||
<groupId>org.springframework</groupId> | |||
<artifactId>spring-context</artifactId> | |||
<version>5.3.23</version> | |||
</dependency> | |||
<!--https://www.baeldung.com/spring-postconstruct-predestroy --> | |||
<dependency> | |||
<groupId>javax.annotation</groupId> | |||
<artifactId>javax.annotation-api</artifactId> | |||
<version>1.3.2</version> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@ -0,0 +1,51 @@ | |||
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;name;grade;marks | |||
1;Juan;1ºDAM;5,3,4,6,5 | |||
2;Pepe;2ºDAM;6,5,7,5,6 | |||
3;Alberto;1ºDAM;7,8,5,4,9 | |||
4;Ivan;2ºDAM;3,6,5,4,2 | |||
5;Anna;SMX;,8,5,7,6,9 | |||
6;Eva;1ºDAM;5,5,5,4,5 | |||
7;Toñi;SMX;4,9,7,9,6 | |||
8;Vicente;2ºDAM;6,5,7,5,6 | |||
9;Jesus;SMX;4,3,5,7,6 | |||
10;Daniel;1ºDAM;1,2,7,6,4 | |||
11;Sandra;SMX;4,5,5,4,6 | |||
12;Alejandro;SMX;7,9,4,5,3 | |||
13;Martina;1ºDAM;5,1,9,7,6 | |||
14;Rocio;1ºDAM;5,6,4,8,9 | |||
15;Godofredo;2ºDAM;9,9,9,9,9 |
@ -0,0 +1,3 @@ | |||
file.path=classpath:bbdd.csv | |||
file.csv.separator=; | |||
file.csv.list_separator=, |