2 Commits

10 changed files with 115 additions and 57 deletions
Split View
  1. +12
    -0
      README.md
  2. +54
    -9
      src/main/java/com/ims/studentManager/StudentManagerHelp.java
  3. +9
    -8
      src/main/java/com/ims/studentManager/StudentManagerRunApp.java
  4. +9
    -9
      src/main/java/com/ims/studentManger/Package/Student.java
  5. +15
    -15
      src/main/resources/bbdd.csv
  6. +1
    -1
      target/classes/META-INF/maven/com.ims/MovieAdvisor/pom.properties
  7. +15
    -15
      target/classes/bbdd.csv
  8. BIN
      target/classes/com/ims/studentManager/StudentManagerHelp.class
  9. BIN
      target/classes/com/ims/studentManager/StudentManagerRunApp.class
  10. BIN
      target/classes/com/ims/studentManger/Package/Student.class

+ 12
- 0
README.md View File

@ -0,0 +1,12 @@
Id | Name | Grade | Courses |
------------- | -------------|------------- | -------------|
1 | Juan | 1DAM | PSP,PRG |
2 | Pepe | 2DAM | AADD |
3 | Alberto | 1DAM | AADD,ING |
4 | Ivan | 2DAM | PSP,PRG |
5 | Anna | SMX | ING |
6 | Eva | 1DAM | DIN,PRG |
7 | Toni | SMX | ERP |
8 | Vicente | 2DAM | PRG,AADD |
9 | Jesus | SMX | ING |
10 | Daniel | 1DAM | PRG,AADD |

+ 54
- 9
src/main/java/com/ims/studentManager/StudentManagerHelp.java View File

@ -1,6 +1,5 @@
package com.ims.studentManager;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
@ -13,25 +12,71 @@ import org.springframework.util.ResourceUtils;
@Component
public class StudentManagerHelp {
private String help;
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"));
help = "Sintaxis: java -jar movieadvisor.jar [OPCIONES]\r\n"
+ "\r\n"
+ " -lg\r\n"
+ " Lista los diferentes alumnos del instituto.\r\n"
+ " No se pueden utilizar más parámetros.\r\n"
+ " \r\n"
+ " -ag genero1,genero2,genero...\r\n"
+ " Lista aquellas películas que pertenecen a al menos uno de los géneros \r\n"
+ " que se indican. El listado de géneros no puede incluir espacios.\r\n"
+ " \r\n"
+ " -tg genero1,genero2,genero...\r\n"
+ " Lista aquellas películas que pertenecen a todos y cada uno de los \r\n"
+ " géneros que se indican. El listado de géneros no puede incluir espacios. \r\n"
+ " \r\n"
+ " -y año\r\n"
+ " Lista aquellas películas que se estrenaron en el año indicado.\r\n"
+ " El año debe expresarse con 4 cifras.\r\n"
+ " \r\n"
+ " -b desde,hasta\r\n"
+ " Lista aquellas películas que se estrenaron entre los años DESDE y HASTA.\r\n"
+ " Los años indicados están incluidos. Deben expresarse con 4 cifras.\r\n"
+ " \r\n"
+ " -t titulo\r\n"
+ " Lista aquellas películas cuyo título contiene la cadena proporcionada.\r\n"
+ " Se ignorará el uso de mayúsculas/minúsculas en la comparación.\r\n"
+ " \r\n"
+ " -h\r\n"
+ " Muestra este mensaje de ayuda.\r\n"
+ " \r\n"
+ "EJEMPLOS DE USO\r\n"
+ "\r\n"
+ "java -jar movieadvisor.jar -y 2018 -ag Action,Comedy\r\n"
+ "Muestra las películas estrenadas de 2018 de acción y/o de comedia.\r\n"
+ "\r\n"
+ "java -jar movieadvisor.jar -t heart\r\n"
+ "Muestra las películas cuyo título contiene la palabra heart.\r\n"
+ "\r\n"
+ "java -jar movieadvisor.jar -td Action,Sci-Fi -b 1990,2010 -t star\r\n"
+ "Muestra las películas cuyo título contiene la palabra star, pertenecen al \r\n"
+ "género de acción y ciencia ficción y fueron estrenadas entre 1990 y 2010. \r\n"
+ "\r\n"
+ "java -jar movieadvisor.jar -lg\r\n"
+ "Muestra un listado con todos los géneros.\r\n"
+ "\r\n"
+ "\r\n"
+ "LICENCIAS\r\n"
+ "\r\n"
+ "Los datos utilizados sobre películas utilizados en este ejemplo son\r\n"
+ "reales y están sacados del sitio web www.imdb.com. Ten en cuenta\r\n"
+ "que solo puede ser usada con fines personales y no comerciales.";
// @formatter:on
} catch (IOException e) {
System.err.println("Error cargando el texto de ayuda");
System.exit(-1);
}
}
public String getHelp() {
return help;
}


+ 9
- 8
src/main/java/com/ims/studentManager/StudentManagerRunApp.java View File

@ -16,18 +16,18 @@ import com.ims.studentManger.Package.Student;
public class StudentManagerRunApp {
@Autowired
private StudentService studentService;
StudentService studentService;
@Autowired
private StudentQueryService studentQueryService;
StudentQueryService studentQueryService;
private StudentManagerHelp help;
StudentManagerHelp help;
public void run(String args[]) {
if(args.length < 1) {
System.out.println("Error de sintaxis");
System.out.println(help.getHelp());
//System.out.println(help.getHelp());
} else if(args.length == 1) {
switch(args[0].toLowerCase()) {
case "-lm":
@ -38,15 +38,15 @@ public class StudentManagerRunApp {
break;
default:
System.out.println("Error de sintaxis");
System.out.println(help.getHelp());
//System.out.println(help.getHelp());
}
} else if (args.length % 2 != 0) {
System.out.println("Error de sintaxis");
System.out.println(help.getHelp());
//System.out.println(help.getHelp());
} else if (args.length > 8) {
System.out.println("Error de sintaxis");
System.out.println(help.getHelp());
//System.out.println(help.getHelp());
} else {
List<String[]> argumentos = new ArrayList<>();
@ -76,11 +76,12 @@ public class StudentManagerRunApp {
break;
default: error = true;
System.out.println("Error de sintaxis");
System.out.println(help.getHelp());
//System.out.println(help.getHelp());
}
}
if(!error) {
System.out.println("Hola");
Collection<Student> result = studentQueryService.exec();
System.out.printf("%s\t%-50s\t%s\t%s\n","ID","NAME","GRADE","MARKS");
if(result != null) {


+ 9
- 9
src/main/java/com/ims/studentManger/Package/Student.java View File

@ -18,13 +18,13 @@ public class Student {
private long id;
private String name;
private String grade;
private List<String> marks;
private List<String> courses;
public Student(long id, String name, String grade, List<String> marks) {
this.id = id;
this.name = name;
this.marks = marks;
this.courses = marks;
this.grade = grade;
}
@ -45,11 +45,11 @@ public class Student {
}
public List<String> getMarks() {
return marks;
return courses;
}
public void setMarks(List<String> marks) {
this.marks = marks;
this.courses = marks;
}
public String getGrade() {
@ -66,7 +66,7 @@ public class Student {
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 + ((courses == null) ? 0 : courses.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@ -87,10 +87,10 @@ public class Student {
return false;
if (id != other.id)
return false;
if (marks == null) {
if (other.marks != null)
if (courses == null) {
if (other.courses != null)
return false;
} else if (!marks.equals(other.marks))
} else if (!courses.equals(other.courses))
return false;
if (name == null) {
if (other.name != null)
@ -102,7 +102,7 @@ public class Student {
@Override
public String toString() {
return "Student [id=" + id + ", name=" + name + ", marks=" + marks + ", grade=" + grade + "]";
return "Student [id=" + id + ", name=" + name + ", marks=" + courses + ", grade=" + grade + "]";
}


+ 15
- 15
src/main/resources/bbdd.csv View File

@ -1,16 +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
1;Juan;1DAM;PSP,PRG
2;Pepe;2DAM;AADD
3;Alberto;1DAM;AADD,ING
4;Ivan;2DAM;PSP,PRG
5;Anna;SMX;ING
6;Eva;1DAM;DIN,PRG
7;Toni;SMX;ERP
8;Vicente;2DAM;PRG,AADD
9;Jesus;SMX;ING
10;Daniel;1DAM;PRG,AADD
11;Sandra;SMX;PRG
12;Alejandro;SMX;AADD,ERP
13;Martina;1DAM;DIN,PRG
14;Rocio;1DAM;ING,PSP
15;Godofredo;2DAM;ERP

+ 1
- 1
target/classes/META-INF/maven/com.ims/MovieAdvisor/pom.properties View File

@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Thu Nov 17 19:27:49 CET 2022
#Fri Nov 18 18:49:54 CET 2022
m2e.projectLocation=C\:\\Users\\Ivan\\Documents\\workspace-spring-tool-suite-4-4.16.0.RELEASE\\MovieAdvisor
m2e.projectName=MovieAdvisor
groupId=com.ims


+ 15
- 15
target/classes/bbdd.csv View File

@ -1,16 +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
1;Juan;1DAM;PSP,PRG
2;Pepe;2DAM;AADD
3;Alberto;1DAM;AADD,ING
4;Ivan;2DAM;PSP,PRG
5;Anna;SMX;ING
6;Eva;1DAM;DIN,PRG
7;Toni;SMX;ERP
8;Vicente;2DAM;PRG,AADD
9;Jesus;SMX;ING
10;Daniel;1DAM;PRG,AADD
11;Sandra;SMX;PRG
12;Alejandro;SMX;AADD,ERP
13;Martina;1DAM;DIN,PRG
14;Rocio;1DAM;ING,PSP
15;Godofredo;2DAM;ERP

BIN
target/classes/com/ims/studentManager/StudentManagerHelp.class View File


BIN
target/classes/com/ims/studentManager/StudentManagerRunApp.class View File


BIN
target/classes/com/ims/studentManger/Package/Student.class View File


Loading…
Cancel
Save