| margaretha | d3c0fc9 | 2017-10-25 15:03:32 +0200 | [diff] [blame] | 1 | package de.ids_mannheim.korap.service; |
| 2 | |
| 3 | import java.util.List; |
| 4 | |
| margaretha | 49cb688 | 2018-07-04 04:19:54 +0200 | [diff] [blame] | 5 | import org.apache.logging.log4j.LogManager; |
| 6 | import org.apache.logging.log4j.Logger; |
| margaretha | d3c0fc9 | 2017-10-25 15:03:32 +0200 | [diff] [blame] | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | import org.springframework.stereotype.Service; |
| 9 | |
| margaretha | 5b70879 | 2023-05-12 16:55:29 +0200 | [diff] [blame] | 10 | import de.ids_mannheim.korap.core.entity.Resource; |
| margaretha | d3c0fc9 | 2017-10-25 15:03:32 +0200 | [diff] [blame] | 11 | import de.ids_mannheim.korap.dao.ResourceDao; |
| 12 | import de.ids_mannheim.korap.dto.ResourceDto; |
| 13 | import de.ids_mannheim.korap.dto.converter.ResourceConverter; |
| margaretha | a0d4d3c | 2018-01-02 12:06:11 +0100 | [diff] [blame] | 14 | import de.ids_mannheim.korap.web.controller.ResourceController; |
| margaretha | d3c0fc9 | 2017-10-25 15:03:32 +0200 | [diff] [blame] | 15 | |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 16 | /** |
| 17 | * ResourceService defines the logic behind |
| 18 | * {@link ResourceController}. |
| margaretha | a0d4d3c | 2018-01-02 12:06:11 +0100 | [diff] [blame] | 19 | * |
| 20 | * @author margaretha |
| 21 | * |
| 22 | */ |
| margaretha | d3c0fc9 | 2017-10-25 15:03:32 +0200 | [diff] [blame] | 23 | @Service |
| 24 | public class ResourceService { |
| 25 | |
| margaretha | dda4ef7 | 2018-12-06 14:20:51 +0100 | [diff] [blame] | 26 | public static Logger jlog = LogManager.getLogger(ResourceService.class); |
| 27 | public static boolean DEBUG = false; |
| margaretha | d3c0fc9 | 2017-10-25 15:03:32 +0200 | [diff] [blame] | 28 | |
| 29 | @Autowired |
| 30 | private ResourceDao resourceDao; |
| 31 | @Autowired |
| 32 | private ResourceConverter resourceConverter; |
| 33 | |
| 34 | public List<ResourceDto> getResourceDtos () { |
| 35 | List<Resource> resources = resourceDao.getAllResources(); |
| margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 36 | List<ResourceDto> resourceDtos = resourceConverter |
| 37 | .convertToResourcesDto(resources); |
| margaretha | dda4ef7 | 2018-12-06 14:20:51 +0100 | [diff] [blame] | 38 | if (DEBUG) { |
| 39 | jlog.debug("/info " + resourceDtos.toString()); |
| 40 | } |
| margaretha | d3c0fc9 | 2017-10-25 15:03:32 +0200 | [diff] [blame] | 41 | return resourceDtos; |
| 42 | } |
| 43 | |
| 44 | } |