Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
pl.fhframework.docs.converter.service.UserService Maven / Gradle / Ivy
package pl.fhframework.docs.converter.service;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import pl.fhframework.docs.converter.model.ForeignUser;
import pl.fhframework.docs.converter.model.User;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Created by Amadeusz Szkiladz on 12.12.2016.
*/
@Service
public class UserService {
public static final String ALL_USERS_CATEGORY = "All users";
public static final String EMPTY_CATEGORY = "";
public static final String ADMINS_CATEGORY = "Admins";
public static final String OTHER_USERS_CATEGORY = "Other users";
public User findByLastName(String s) {
return findAll().stream().filter(u -> u.getLastName().equals(s)).findFirst().orElse(null);
}
public List findAll() {
return Stream.of(new User("admin", "[email protected] ", "Jack", "Abell", 25, LocalDateTime.of(2012, 12, 12, 9, 21)),
new User("approver", "[email protected] ", "Marcelino", "Putz", 44, LocalDateTime.of(2014, 5, 5, 16, 5)),
new User("analyst", "[email protected] ", "Erlinda", "Thorp", 65, LocalDateTime.of(2016, 10, 9, 10, 01))).collect(Collectors.toList());
}
public MultiValueMap getComboData() {
MultiValueMap usersByCategory = new LinkedMultiValueMap<>();
usersByCategory.add(ALL_USERS_CATEGORY, new User("admin", "[email protected] ", "Jack", "Abell", 25, LocalDateTime.of(2012, 12, 12, 9, 21)));
usersByCategory.add(ALL_USERS_CATEGORY, new User("approver", "[email protected] ", "Marcelino", "Putz", 44, LocalDateTime.of(2014, 5, 5, 16, 5)));
usersByCategory.add(ALL_USERS_CATEGORY, new User("analyst", "[email protected] ", "Erlinda", "Thorp", 65, LocalDateTime.of(2016, 10, 9, 10, 01)));
usersByCategory.add(ADMINS_CATEGORY, new User("admin", "[email protected] ", "Jack", "Abell", 25, LocalDateTime.of(2012, 12, 12, 9, 21)));
usersByCategory.add(OTHER_USERS_CATEGORY, new User("approver", "[email protected] ", "Marcelino", "Putz", 44, LocalDateTime.of(2014, 5, 5, 16, 5)));
usersByCategory.add(OTHER_USERS_CATEGORY, new User("analyst", "[email protected] ", "Erlinda", "Thorp", 65, LocalDateTime.of(2016, 10, 9, 10, 01)));
return usersByCategory;
}
public MultiValueMap getSelect2ComboData() {
MultiValueMap usersByCategory = new LinkedMultiValueMap<>();
usersByCategory.add(EMPTY_CATEGORY, new User("admin", "[email protected] ", "Jack", "Abell", 25, LocalDateTime.of(2012, 12, 12, 9, 21)));
usersByCategory.add(EMPTY_CATEGORY, new User("approver", "[email protected] ", "Marcelino", "Putz", 44, LocalDateTime.of(2014, 5, 5, 16, 5)));
usersByCategory.add(EMPTY_CATEGORY, new User("analyst", "[email protected] ", "Erlinda", "Thorp", 65, LocalDateTime.of(2016, 10, 9, 10, 01)));
usersByCategory.add(EMPTY_CATEGORY, new User("admin", "[email protected] ", "Jack", "Abell", 25, LocalDateTime.of(2012, 12, 12, 9, 21)));
usersByCategory.add(EMPTY_CATEGORY, new User("approver", "[email protected] ", "Marcelino", "Putz", 44, LocalDateTime.of(2014, 5, 5, 16, 5)));
usersByCategory.add(EMPTY_CATEGORY, new User("analyst", "[email protected] ", "Erlinda", "Thorp", 65, LocalDateTime.of(2016, 10, 9, 10, 01)));
return usersByCategory;
}
public List findAllForeignUsers() {
return Stream.of(new ForeignUser("admin", "[email protected] ", "Jack", "Abell", 25, LocalDateTime.of(2012, 12, 12, 9, 21), "FBSYS1", "Foreign System 1"),
new ForeignUser("approver", "[email protected] ", "Marcelino", "Putz", 44, LocalDateTime.of(2014, 5, 5, 16, 5), "FBSYS2", "Foreign System 2"),
new ForeignUser("analyst", "[email protected] ", "Erlinda", "Thorp", 65, LocalDateTime.of(2016, 10, 9, 10, 01), "FBSYS3", "Foreign System 3")).collect(Collectors.toList());
}
}