Browse Source

Error en algunas classes por sintaxis y lo ha cambiado todo.

master
Cristobal Bernal Mayordomo 2 years ago
parent
commit
90a3478263
10 changed files with 0 additions and 318 deletions
  1. +0
    -13
      src/main/java/com/cristobalbernal/loladvisor/LolAdvisorApplication.java
  2. +0
    -33
      src/main/java/com/cristobalbernal/loladvisor/config/AppConfig.java
  3. +0
    -13
      src/main/java/com/cristobalbernal/loladvisor/dao/LolDao.java
  4. +0
    -76
      src/main/java/com/cristobalbernal/loladvisor/dao/LolDaoImplMemory.java
  5. +0
    -38
      src/main/java/com/cristobalbernal/loladvisor/dao/UtilLolFileReader.java
  6. +0
    -68
      src/main/java/com/cristobalbernal/loladvisor/model/Lol.java
  7. +0
    -13
      src/main/java/com/cristobalbernal/loladvisor/service/LolQueryService.java
  8. +0
    -47
      src/main/java/com/cristobalbernal/loladvisor/service/LolQueryServices.java
  9. +0
    -17
      src/main/java/com/cristobalbernal/loladvisor/service/LolService.java
  10. +0
    -0
      src/main/resources/Ayuda.txt

+ 0
- 13
src/main/java/com/cristobalbernal/loladvisor/LolAdvisorApplication.java View File

@ -1,13 +0,0 @@
package com.cristobalbernal.loladvisor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class LolAdvisorApplication {
public static void main(String[] args) {
SpringApplication.run(LolAdvisorApplication.class, args);
}
}

+ 0
- 33
src/main/java/com/cristobalbernal/loladvisor/config/AppConfig.java View File

@ -1,33 +0,0 @@
package com.cristobalbernal.loladvisor.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.cristobalbernal")
@PropertySource("classpath:/application.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
- 13
src/main/java/com/cristobalbernal/loladvisor/dao/LolDao.java View File

@ -1,13 +0,0 @@
package com.cristobalbernal.loladvisor.dao;
import com.cristobalbernal.loladvisor.model.Lol;
import java.util.Collection;
public interface LolDao {
public Lol findById(long id);
public Collection<Lol> findAll();
public void insert(Lol lol);
public void edit(Lol lol);
public void delete(long id);
}

+ 0
- 76
src/main/java/com/cristobalbernal/loladvisor/dao/LolDaoImplMemory.java View File

@ -1,76 +0,0 @@
package com.cristobalbernal.loladvisor.dao;
import com.cristobalbernal.loladvisor.config.AppConfig;
import com.cristobalbernal.loladvisor.model.Lol;
import org.springframework.stereotype.Repository;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
@Repository
public class LolDaoImplMemory implements LolDao{
public List<Lol> lols = new ArrayList<>();
private AppConfig appConfig;
public void init() {
lols = UtilLolFileReader.readFile(appConfig.getFile(), appConfig.getSeparator(), appConfig.getListSeparator());
}
@Override
public Lol findById(long id) {
Optional<Lol> result = lols
.stream()
.filter(f -> f.getId() == id)
.findFirst();
// @formatter:on
return result.orElse(null);
}
@Override
public Collection<Lol> findAll() {
return lols;
}
@Override
public void insert(Lol lol) {
lols.add(lol);
}
@Override
public void edit(Lol lol) {
int i = getIndexOf(lol.getId());
if(i != -1)
lols.set(i, lol);
}
@Override
public void delete(long id) {
int index = getIndexOf(id);
if(index != -1)
lols.remove(index);
}
private int getIndexOf(long id) {
boolean encontrado = false;
int index = 0;
while(!encontrado && index < lols.size()) {
if(lols.get(index).getId() == id){
encontrado = true;
} else{
index++;
}
}
return (encontrado) ? index : -1;
}
}

+ 0
- 38
src/main/java/com/cristobalbernal/loladvisor/dao/UtilLolFileReader.java View File

@ -1,38 +0,0 @@
package com.cristobalbernal.loladvisor.dao;
import com.cristobalbernal.loladvisor.model.Lol;
import org.springframework.util.ResourceUtils;
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;
public class UtilLolFileReader {
public static List<Lol> readFile(final String path, final String separator, final String listSeparator) {
List<Lol> result = new ArrayList<>();
try {
// @formatter:off
result = Files
.lines(Paths.get(ResourceUtils.getFile(path).toURI()))
.skip(1)
.map(line -> {
String[] values = line.split(separator);
return new Lol(Long.parseLong(values[0]), values[1],
Arrays.asList(values[2].split(listSeparator)),
values[3],values[4]);
}).collect(Collectors.toList());
// @formatter:on
} catch (Exception e) {
System.err.println("Error de lectura del fichero de datos");
System.exit(-1);
}
return result;
}
}

+ 0
- 68
src/main/java/com/cristobalbernal/loladvisor/model/Lol.java View File

@ -1,68 +0,0 @@
package com.cristobalbernal.loladvisor.model;
import java.util.List;
public class Lol {
private long id;
private String nombre;
private List<String> rol;
private String dificultad;
private String genero;
public Lol(long id, String nombre, List<String> rol, String dificultad, String genero) {
this.id = id;
this.nombre = nombre;
this.rol = rol;
this.dificultad = dificultad;
this.genero = genero;
}
public long getId() {
return id;
}
public String getNombre() {
return nombre;
}
public String getDificultad() {
return dificultad;
}
public void setId(long id) {
this.id = id;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public List<String> getRol() {
return rol;
}
public void setRol(List<String> rol) {
this.rol = rol;
}
public void setDificultad(String dificultad) {
this.dificultad = dificultad;
}
public String getGenero() {
return genero;
}
public void setGenero(String genero) {
this.genero = genero;
}
@Override
public String toString() {
return "Lol{" +
"id=" + id +
", nombre='" + nombre + '\'' +
", rol=" + rol +
", dificultad='" + dificultad + '\'' +
", genero='" + genero + '\'' +
'}';
}
}

+ 0
- 13
src/main/java/com/cristobalbernal/loladvisor/service/LolQueryService.java View File

@ -1,13 +0,0 @@
package com.cristobalbernal.loladvisor.service;
import com.cristobalbernal.loladvisor.model.Lol;
import java.util.Collection;
public interface LolQueryService {
public Collection<Lol> exec();
public LolQueryService anyGenre(String... genres);
public LolQueryService allGenres(String... genres);
public LolQueryService titleContains(String title);
}

+ 0
- 47
src/main/java/com/cristobalbernal/loladvisor/service/LolQueryServices.java View File

@ -1,47 +0,0 @@
package com.cristobalbernal.loladvisor.service;
import com.cristobalbernal.loladvisor.dao.LolDao;
import com.cristobalbernal.loladvisor.model.Lol;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Collection;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@Service
public class LolQueryServices implements LolQueryService {
private LolDao dao;
private Predicate<Lol> predicate;
@Override
public Collection<Lol> exec() {
return dao.findAll()
.stream()
.filter(predicate)
.collect(Collectors.toList());
}
@Override
public LolQueryService anyGenre(String... genres) {
Predicate<Lol> pAnyGenre = (vg -> Arrays.stream(genres).anyMatch(vg.getNombre()::contains));
predicate = (predicate == null) ? pAnyGenre : predicate.and(pAnyGenre);
return this;
}
@Override
public LolQueryService allGenres(String... genres) {
Predicate<Lol> pAllGenre = (vg -> Arrays.stream(genres).allMatch(vg.getNombre()::contains));
predicate = (predicate == null) ? pAllGenre : predicate.and(pAllGenre);
return this;
}
@Override
public LolQueryService titleContains(String title) {
Predicate<Lol> pTitleContains = (vg -> vg.getNombre().toLowerCase().contains(title.toLowerCase()));
predicate = (predicate == null) ? pTitleContains : predicate.and(pTitleContains);
return this;
}
}

+ 0
- 17
src/main/java/com/cristobalbernal/loladvisor/service/LolService.java View File

@ -1,17 +0,0 @@
package com.cristobalbernal.loladvisor.service;
import com.cristobalbernal.loladvisor.dao.LolDao;
import java.util.Collection;
public class LolService {
LolDao filmDao;
LolQueryService queryService;
public Collection<String> findAllGenres(){
return null;
}
}

+ 0
- 0
src/main/resources/Ayuda.txt View File


Loading…
Cancel
Save