implement checkstyle
This commit is contained in:
parent
b37437bce5
commit
79754cb7d3
17
pom.xml
17
pom.xml
|
@ -239,6 +239,23 @@
|
|||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<configuration>
|
||||
<configLocation>${project.basedir}/src/main/resources/checkstyle.xml</configLocation>
|
||||
<consoleOutput>true</consoleOutput>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
|
@ -22,14 +22,17 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/dataSources")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Data sources", description = "API endpoints to explore data sources")
|
||||
public class DataSourceController
|
||||
{
|
||||
public class DataSourceController {
|
||||
|
||||
private final DataSourceService dataSourceService;
|
||||
|
||||
|
|
|
@ -22,14 +22,17 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/organizations")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Organizations", description = "API endpoints to explore organizations")
|
||||
public class OrganizationController
|
||||
{
|
||||
public class OrganizationController {
|
||||
|
||||
private final OrganizationService organizationService;
|
||||
|
||||
|
|
|
@ -22,14 +22,17 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/projects")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Projects", description = "API endpoints to explore projects")
|
||||
public class ProjectController
|
||||
{
|
||||
public class ProjectController {
|
||||
|
||||
private final ProjectService projectService;
|
||||
|
||||
|
|
|
@ -23,14 +23,17 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/researchProducts")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Research products", description = "API endpoints to explore research products")
|
||||
public class ResearchProductsController
|
||||
{
|
||||
public class ResearchProductsController {
|
||||
|
||||
private final ResearchProductService researchProductService;
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package eu.openaire.api.dto.request.validators;
|
||||
|
||||
import eu.openaire.api.dto.request.*;
|
||||
import eu.openaire.api.dto.request.DataSourceRequest;
|
||||
import eu.openaire.api.dto.request.OrganizationRequest;
|
||||
import eu.openaire.api.dto.request.PaginatedRequest;
|
||||
import eu.openaire.api.dto.request.ProjectRequest;
|
||||
import eu.openaire.api.dto.request.ResearchProductsRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
|
|
|
@ -10,7 +10,11 @@ import java.time.ZoneOffset;
|
|||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Utils {
|
||||
|
||||
|
|
|
@ -3,7 +3,11 @@ package eu.openaire.api.mappers.query;
|
|||
import eu.openaire.api.dto.request.DataSourceRequest;
|
||||
import eu.openaire.api.mappers.Utils;
|
||||
import eu.openaire.api.solr.SolrQueryParams;
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.Named;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
@ -15,7 +19,7 @@ public interface DataSourceRequestMapper {
|
|||
@Mapping(target = "rows", source = "pageSize")
|
||||
@Mapping(target = "debugQuery", source = "debugQuery")
|
||||
@Mapping(target = "cursor", source = "cursor")
|
||||
@Mapping(target = "sort", expression = "java( eu.openaire.api.mappers.Utils.formatSortByParam(src.getSortBy(), SolrFieldsMapper.dataSourceSortMapping) )")
|
||||
@Mapping(target = "sort", expression = "java( eu.openaire.api.mappers.Utils.formatSortByParam(src.getSortBy(), SolrFieldsMapper.DATASOURCE_SORT_MAPPING) )")
|
||||
SolrQueryParams toSolrQuery(DataSourceRequest src);
|
||||
|
||||
@Named("calculateStart")
|
||||
|
@ -26,7 +30,7 @@ public interface DataSourceRequestMapper {
|
|||
@AfterMapping
|
||||
default void paramsCustomMapping(DataSourceRequest src, @MappingTarget SolrQueryParams solrQueryParams) {
|
||||
|
||||
final Map<String, String> solrFieldMapping = SolrFieldsMapper.dataSourceFieldMapping;
|
||||
final Map<String, String> solrFieldMapping = SolrFieldsMapper.DATASOURCE_FIELD_MAPPING;
|
||||
|
||||
var qList = new ArrayList<String>();
|
||||
|
||||
|
|
|
@ -3,7 +3,11 @@ package eu.openaire.api.mappers.query;
|
|||
import eu.openaire.api.dto.request.OrganizationRequest;
|
||||
import eu.openaire.api.mappers.Utils;
|
||||
import eu.openaire.api.solr.SolrQueryParams;
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.Named;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
@ -11,12 +15,10 @@ import java.util.Map;
|
|||
@Mapper(componentModel = "spring")
|
||||
public interface OrganizationRequestMapper {
|
||||
|
||||
|
||||
|
||||
@Mapping(target = "start", expression = "java( calculateStart(src.getPage(), src.getPageSize()) )")
|
||||
@Mapping(target = "rows", source = "pageSize")
|
||||
@Mapping(target = "debugQuery", source = "debugQuery")
|
||||
@Mapping(target = "sort", expression = "java( eu.openaire.api.mappers.Utils.formatSortByParam(src.getSortBy(), SolrFieldsMapper.organizationSortMapping) )")
|
||||
@Mapping(target = "sort", expression = "java( eu.openaire.api.mappers.Utils.formatSortByParam(src.getSortBy(), SolrFieldsMapper.ORGANIZATION_SORT_MAPPING) )")
|
||||
SolrQueryParams toSolrQuery(OrganizationRequest src);
|
||||
|
||||
@Named("calculateStart")
|
||||
|
@ -27,7 +29,7 @@ public interface OrganizationRequestMapper {
|
|||
@AfterMapping
|
||||
default void paramsCustomMapping(OrganizationRequest src, @MappingTarget SolrQueryParams solrQueryParams) {
|
||||
|
||||
final Map<String, String> solrFieldMapping = SolrFieldsMapper.organizationFieldsMapping;
|
||||
final Map<String, String> solrFieldMapping = SolrFieldsMapper.ORGANIZATION_FIELDS_MAPPING;
|
||||
|
||||
var qList = new ArrayList<String>();
|
||||
|
||||
|
|
|
@ -3,7 +3,11 @@ package eu.openaire.api.mappers.query;
|
|||
import eu.openaire.api.dto.request.ProjectRequest;
|
||||
import eu.openaire.api.mappers.Utils;
|
||||
import eu.openaire.api.solr.SolrQueryParams;
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.Named;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
@ -15,7 +19,7 @@ public interface ProjectRequestMapper {
|
|||
@Mapping(target = "start", expression = "java( calculateStart(src.getPage(), src.getPageSize()) )")
|
||||
@Mapping(target = "rows", source = "pageSize")
|
||||
@Mapping(target = "debugQuery", source = "debugQuery")
|
||||
@Mapping(target = "sort", expression = "java( eu.openaire.api.mappers.Utils.formatSortByParam(src.getSortBy(), SolrFieldsMapper.projectSortMapping) )")
|
||||
@Mapping(target = "sort", expression = "java( eu.openaire.api.mappers.Utils.formatSortByParam(src.getSortBy(), SolrFieldsMapper.PROJECT_SORT_MAPPING) )")
|
||||
SolrQueryParams toSolrQuery(ProjectRequest src);
|
||||
|
||||
@Named("calculateStart")
|
||||
|
@ -26,7 +30,7 @@ public interface ProjectRequestMapper {
|
|||
@AfterMapping
|
||||
default void paramsCustomMapping(ProjectRequest src, @MappingTarget SolrQueryParams solrQueryParams) {
|
||||
|
||||
final Map<String, String> solrFieldMapping = SolrFieldsMapper.projectFieldMapping;
|
||||
final Map<String, String> solrFieldMapping = SolrFieldsMapper.PROJECT_FIELD_MAPPING;
|
||||
|
||||
var qList = new ArrayList<String>();
|
||||
|
||||
|
|
|
@ -3,7 +3,11 @@ package eu.openaire.api.mappers.query;
|
|||
import eu.openaire.api.dto.request.ResearchProductsRequest;
|
||||
import eu.openaire.api.mappers.Utils;
|
||||
import eu.openaire.api.solr.SolrQueryParams;
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.Named;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -16,7 +20,7 @@ public interface ResearchProductsRequestMapper {
|
|||
@Mapping(target = "start", expression = "java( calculateStart(src.getPage(), src.getPageSize()) )")
|
||||
@Mapping(target = "rows", source = "pageSize")
|
||||
@Mapping(target = "debugQuery", source = "debugQuery")
|
||||
@Mapping(target = "sort", expression = "java( eu.openaire.api.mappers.Utils.formatSortByParam(src.getSortBy(), SolrFieldsMapper.researchProductSortMapping) )")
|
||||
@Mapping(target = "sort", expression = "java( eu.openaire.api.mappers.Utils.formatSortByParam(src.getSortBy(), SolrFieldsMapper.RESEARCH_PRODUCT_SORT_MAPPING) )")
|
||||
SolrQueryParams toSolrQuery(ResearchProductsRequest src);
|
||||
|
||||
@Named("calculateStart")
|
||||
|
@ -27,7 +31,7 @@ public interface ResearchProductsRequestMapper {
|
|||
@AfterMapping
|
||||
default void paramsCustomMapping(ResearchProductsRequest src, @MappingTarget SolrQueryParams solrQueryParams) {
|
||||
|
||||
final Map<String, String> solrFieldMapping = SolrFieldsMapper.researchProductFieldMapping;
|
||||
final Map<String, String> solrFieldMapping = SolrFieldsMapper.RESEARCH_PRODUCT_FIELD_MAPPING;
|
||||
|
||||
var qList = new ArrayList<String>();
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Map;
|
|||
public class SolrFieldsMapper {
|
||||
|
||||
// mappings for the organization entity
|
||||
public static final Map<String, String> organizationFieldsMapping = java.util.Map.ofEntries(
|
||||
public static final Map<String, String> ORGANIZATION_FIELDS_MAPPING = java.util.Map.ofEntries(
|
||||
|
||||
// search field mapping
|
||||
Map.entry("search", "__all:(%s)"),
|
||||
|
@ -23,12 +23,12 @@ public class SolrFieldsMapper {
|
|||
|
||||
);
|
||||
|
||||
public static final Map<String, String> organizationSortMapping = Map.ofEntries(
|
||||
public static final Map<String, String> ORGANIZATION_SORT_MAPPING = Map.ofEntries(
|
||||
Map.entry("relevance", "score")
|
||||
);
|
||||
|
||||
// mappings for the datasource entity
|
||||
public static final Map<String, String> dataSourceFieldMapping = Map.ofEntries(
|
||||
public static final Map<String, String> DATASOURCE_FIELD_MAPPING = Map.ofEntries(
|
||||
|
||||
// search field mapping
|
||||
Map.entry("search", "__all:(%s)"),
|
||||
|
@ -48,13 +48,13 @@ public class SolrFieldsMapper {
|
|||
Map.entry("relCollectedFromDatasourceId", "collectedfromdatasourceid:(%s)")
|
||||
);
|
||||
|
||||
public static final Map<String, String> dataSourceSortMapping = Map.ofEntries(
|
||||
public static final Map<String, String> DATASOURCE_SORT_MAPPING = Map.ofEntries(
|
||||
Map.entry("relevance", "score")
|
||||
);
|
||||
|
||||
|
||||
// mappings for the project entity
|
||||
public static final Map<String, String> projectFieldMapping = Map.ofEntries(
|
||||
public static final Map<String, String> PROJECT_FIELD_MAPPING = Map.ofEntries(
|
||||
|
||||
// search field mapping
|
||||
Map.entry("search", "__all:(%s)"),
|
||||
|
@ -81,13 +81,13 @@ public class SolrFieldsMapper {
|
|||
|
||||
);
|
||||
|
||||
public static final Map<String, String> projectSortMapping = Map.ofEntries(
|
||||
public static final Map<String, String> PROJECT_SORT_MAPPING = Map.ofEntries(
|
||||
Map.entry("relevance", "score"),
|
||||
Map.entry("startDate", "projectstartyear"),
|
||||
Map.entry("endDate", "projectendyear")
|
||||
);
|
||||
|
||||
public static final Map<String, String> researchProductFieldMapping = Map.ofEntries(
|
||||
public static final Map<String, String> RESEARCH_PRODUCT_FIELD_MAPPING = Map.ofEntries(
|
||||
|
||||
// search field mapping
|
||||
Map.entry("search", "__all:(%s)"),
|
||||
|
@ -134,7 +134,7 @@ public class SolrFieldsMapper {
|
|||
|
||||
);
|
||||
|
||||
public static final Map<String, String> researchProductSortMapping = Map.ofEntries(
|
||||
public static final Map<String, String> RESEARCH_PRODUCT_SORT_MAPPING = Map.ofEntries(
|
||||
|
||||
Map.entry("relevance", "score"),
|
||||
Map.entry("publicationDate", "resultdateofacceptance"),
|
||||
|
|
|
@ -5,7 +5,12 @@ import eu.dnetlib.dhp.oa.model.Indicator;
|
|||
import eu.dnetlib.dhp.oa.model.graph.Datasource;
|
||||
import eu.dnetlib.dhp.oa.model.graph.DatasourcePid;
|
||||
import eu.dnetlib.dhp.oa.model.graph.DatasourceSchemeValue;
|
||||
import eu.dnetlib.dhp.schema.solr.*;
|
||||
import eu.dnetlib.dhp.schema.solr.CodeLabel;
|
||||
import eu.dnetlib.dhp.schema.solr.Journal;
|
||||
import eu.dnetlib.dhp.schema.solr.Measure;
|
||||
import eu.dnetlib.dhp.schema.solr.Pid;
|
||||
import eu.dnetlib.dhp.schema.solr.SolrRecord;
|
||||
import eu.dnetlib.dhp.schema.solr.Subject;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Named;
|
||||
|
@ -55,22 +60,25 @@ public interface DatasourceMapper {
|
|||
|
||||
@Named("mapPids")
|
||||
default List<DatasourcePid> mapPids(List<Pid> pids ) {
|
||||
if(pids == null)
|
||||
if (pids == null) {
|
||||
return null;
|
||||
}
|
||||
return pids.stream().map(this::mapPid).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Named("mapSubjects")
|
||||
default List<String> mapSubjects(List<Subject> sbjs ) {
|
||||
if(sbjs == null)
|
||||
if (sbjs == null) {
|
||||
return null;
|
||||
}
|
||||
return sbjs.stream().map(Subject::getValue).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Named("mapPolicies")
|
||||
default List<String> mapPolicies(List<CodeLabel> policies ) {
|
||||
if(policies == null)
|
||||
if (policies == null) {
|
||||
return null;
|
||||
}
|
||||
return policies.stream().map(CodeLabel::getLabel).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,9 @@ public interface OrganizationMapper {
|
|||
|
||||
@Named("mapPids")
|
||||
default List<OrganizationPid> mapPids(List<Pid> pids ) {
|
||||
if(pids == null)
|
||||
if (pids == null) {
|
||||
return null;
|
||||
}
|
||||
return pids.stream().map(this::mapPid).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,11 @@ import eu.dnetlib.dhp.oa.model.graph.Funder;
|
|||
import eu.dnetlib.dhp.oa.model.graph.Fundings;
|
||||
import eu.dnetlib.dhp.oa.model.graph.Granted;
|
||||
import eu.dnetlib.dhp.oa.model.graph.Project;
|
||||
import eu.dnetlib.dhp.schema.solr.*;
|
||||
import eu.dnetlib.dhp.schema.solr.Funding;
|
||||
import eu.dnetlib.dhp.schema.solr.FundingLevel;
|
||||
import eu.dnetlib.dhp.schema.solr.Measure;
|
||||
import eu.dnetlib.dhp.schema.solr.SolrRecord;
|
||||
import eu.dnetlib.dhp.schema.solr.Subject;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Named;
|
||||
|
@ -40,23 +44,26 @@ public interface ProjectMapper {
|
|||
|
||||
@Named("mapSubjects")
|
||||
default List<String> mapSubjects(List<Subject>subjectList) {
|
||||
if(subjectList == null)
|
||||
if (subjectList == null) {
|
||||
return null;
|
||||
}
|
||||
return subjectList.stream().map(Subject::getValue).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Named("mapOpenAccessMandate")
|
||||
default Boolean mapOpenAccessMandate(String mandate) {
|
||||
if(mandate == null)
|
||||
if (mandate == null) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return Boolean.parseBoolean(mandate);
|
||||
}
|
||||
|
||||
|
||||
@Named("mapFunding")
|
||||
default List<Funder> mapFundings(Funding funding) {
|
||||
if(funding == null)
|
||||
if (funding == null) {
|
||||
return null;
|
||||
}
|
||||
return Collections.singletonList(mapFunding(funding));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,19 +2,29 @@ package eu.openaire.api.mappers.response.entities;
|
|||
|
||||
import eu.dnetlib.dhp.oa.model.APC;
|
||||
import eu.dnetlib.dhp.oa.model.AccessRight;
|
||||
import eu.dnetlib.dhp.oa.model.AlternateIdentifier;
|
||||
import eu.dnetlib.dhp.oa.model.AuthorPid;
|
||||
import eu.dnetlib.dhp.oa.model.AuthorPidSchemeValue;
|
||||
import eu.dnetlib.dhp.oa.model.Container;
|
||||
import eu.dnetlib.dhp.oa.model.OpenAccessRoute;
|
||||
import eu.dnetlib.dhp.oa.model.*;
|
||||
import eu.dnetlib.dhp.oa.model.Indicator;
|
||||
import eu.dnetlib.dhp.oa.model.ResultCountry;
|
||||
import eu.dnetlib.dhp.oa.model.ResultPid;
|
||||
import eu.dnetlib.dhp.oa.model.SubjectSchemeValue;
|
||||
import eu.dnetlib.dhp.oa.model.graph.GraphResult;
|
||||
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
||||
import eu.dnetlib.dhp.schema.solr.Author;
|
||||
import eu.dnetlib.dhp.schema.solr.BestAccessRight;
|
||||
import eu.dnetlib.dhp.schema.solr.Country;
|
||||
import eu.dnetlib.dhp.schema.solr.Instance;
|
||||
import eu.dnetlib.dhp.schema.solr.Journal;
|
||||
import eu.dnetlib.dhp.schema.solr.Language;
|
||||
import eu.dnetlib.dhp.schema.solr.Measure;
|
||||
import eu.dnetlib.dhp.schema.solr.OpenAccessColor;
|
||||
import eu.dnetlib.dhp.schema.solr.Pid;
|
||||
import eu.dnetlib.dhp.schema.solr.SolrRecord;
|
||||
import eu.dnetlib.dhp.schema.solr.Subject;
|
||||
import eu.dnetlib.dhp.schema.solr.*;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Named;
|
||||
|
@ -73,15 +83,17 @@ public interface ResearchProductMapper {
|
|||
|
||||
@Named("mapPids")
|
||||
default List<ResultPid> mapPids(List<Pid> pids ) {
|
||||
if(pids == null)
|
||||
if (pids == null) {
|
||||
return null;
|
||||
}
|
||||
return pids.stream().map(this::mapPid).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Named("mapAltIds")
|
||||
default List<AlternateIdentifier> mapAltIds(List<Pid> altIdentifiers) {
|
||||
if(altIdentifiers == null)
|
||||
if (altIdentifiers == null) {
|
||||
return null;
|
||||
}
|
||||
return altIdentifiers.stream().map(this::mapAltId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -95,8 +107,9 @@ public interface ResearchProductMapper {
|
|||
|
||||
@Named("mapSubjects")
|
||||
default List<eu.dnetlib.dhp.oa.model.Subject> mapSubjects(List<Subject> sbjs ) {
|
||||
if(sbjs == null)
|
||||
if (sbjs == null) {
|
||||
return null;
|
||||
}
|
||||
return sbjs.stream().map(this::mapSubject).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -109,8 +122,9 @@ public interface ResearchProductMapper {
|
|||
|
||||
@Named("mapCountries")
|
||||
default List<ResultCountry> mapCountries(List<Country> countryList) {
|
||||
if(countryList == null)
|
||||
if (countryList == null) {
|
||||
return null;
|
||||
}
|
||||
return countryList.stream().map(this::mapCountry).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -124,8 +138,9 @@ public interface ResearchProductMapper {
|
|||
|
||||
@Named("mapAuthor")
|
||||
default List<eu.dnetlib.dhp.oa.model.Author> mapAuthors(List<Author> authorsList) {
|
||||
if(authorsList == null)
|
||||
if (authorsList == null) {
|
||||
return null;
|
||||
}
|
||||
return authorsList.stream().map(this::mapAuthor).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -135,8 +150,9 @@ public interface ResearchProductMapper {
|
|||
|
||||
@Named("mapAuthorPid")
|
||||
default AuthorPid mapAuthorPid(List<Pid> authorPidList) {
|
||||
if(authorPidList == null)
|
||||
if (authorPidList == null) {
|
||||
return null;
|
||||
}
|
||||
List<Pid> orcid = authorPidList
|
||||
.stream()
|
||||
.filter(ap -> ModelConstants.ORCID.equals(ap.getTypeCode()))
|
||||
|
@ -144,8 +160,9 @@ public interface ResearchProductMapper {
|
|||
if (orcid.size() == 1) {
|
||||
return getAuthorPid(orcid.get(0));
|
||||
}
|
||||
if (orcid.size() > 1 )
|
||||
if (orcid.size() > 1 ) {
|
||||
return null;
|
||||
}
|
||||
orcid = authorPidList
|
||||
.stream()
|
||||
.filter(ap -> ModelConstants.ORCID_PENDING.equals(ap.getTypeCode()))
|
||||
|
@ -166,8 +183,9 @@ public interface ResearchProductMapper {
|
|||
|
||||
@Named("mapBestAccessRight")
|
||||
default eu.dnetlib.dhp.oa.model.BestAccessRight mapBestAccessRight(BestAccessRight bestAccessRight) {
|
||||
if(bestAccessRight == null)
|
||||
if (bestAccessRight == null) {
|
||||
return null;
|
||||
}
|
||||
if (Constants.ACCESS_RIGHTS_COAR_MAP.containsKey(bestAccessRight.getCode())) {
|
||||
String code = Constants.ACCESS_RIGHTS_COAR_MAP.get(bestAccessRight.getCode());
|
||||
return
|
||||
|
@ -182,8 +200,9 @@ public interface ResearchProductMapper {
|
|||
|
||||
@Named("mapInstances")
|
||||
default List<eu.dnetlib.dhp.oa.model.Instance> mapInstances(List<Instance> instanceList) {
|
||||
if(instanceList == null)
|
||||
if (instanceList == null) {
|
||||
return null;
|
||||
}
|
||||
return instanceList.stream().map(this::mapInstance).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -198,8 +217,9 @@ public interface ResearchProductMapper {
|
|||
|
||||
@Named("mapAccessRight")
|
||||
default AccessRight mapAccessRight(eu.dnetlib.dhp.schema.solr.AccessRight accessright) {
|
||||
if(accessright==null)
|
||||
if (accessright == null) {
|
||||
return null;
|
||||
}
|
||||
AccessRight ar = new AccessRight();
|
||||
if (Constants.ACCESS_RIGHTS_COAR_MAP.containsKey(accessright.getLabel())) {
|
||||
String code = Constants.ACCESS_RIGHTS_COAR_MAP.get(accessright.getLabel());
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
package eu.openaire.api.mappers.response.entities;
|
||||
|
||||
import eu.dnetlib.dhp.oa.model.AuthorPid;
|
||||
import eu.dnetlib.dhp.oa.model.BipIndicators;
|
||||
import eu.dnetlib.dhp.oa.model.Indicator;
|
||||
import eu.dnetlib.dhp.oa.model.UsageCounts;
|
||||
import eu.dnetlib.dhp.oa.model.graph.DatasourcePid;
|
||||
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
||||
import eu.dnetlib.dhp.schema.solr.Measure;
|
||||
import eu.dnetlib.dhp.schema.solr.Pid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static Indicator mapIndicators(List<Measure> measureList) {
|
||||
if(measureList == null)
|
||||
if (measureList == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Indicator i = new Indicator();
|
||||
for (Measure m : measureList) {
|
||||
switch (m.getId()) {
|
||||
|
@ -28,36 +25,44 @@ public class Utils {
|
|||
break;
|
||||
case Constants.BIP_INFLUENCE:
|
||||
m.getUnit().forEach(u -> {
|
||||
if (u.getCode().equals("class"))
|
||||
if (u.getCode().equals("class")) {
|
||||
getImpactMeasure(i).setInfluenceClass(u.getLabel());
|
||||
if (u.getCode().equals("score"))
|
||||
}
|
||||
if (u.getCode().equals("score")) {
|
||||
getImpactMeasure(i).setInfluence(Double.parseDouble(u.getLabel()));
|
||||
}
|
||||
});
|
||||
break;
|
||||
case Constants.BIP_POPULARITY:
|
||||
m.getUnit().forEach(u -> {
|
||||
if (u.getCode().equals("class"))
|
||||
if (u.getCode().equals("class")) {
|
||||
getImpactMeasure(i).setPopularityClass(u.getLabel());
|
||||
if (u.getCode().equals("score"))
|
||||
}
|
||||
if (u.getCode().equals("score")) {
|
||||
getImpactMeasure(i).setPopularity(Double.parseDouble(u.getLabel()));
|
||||
}
|
||||
});
|
||||
break;
|
||||
case Constants.BIP_INFLUENCE_ALT:
|
||||
m.getUnit().forEach(u -> {
|
||||
if (u.getCode().equals("class"))
|
||||
if (u.getCode().equals("class")) {
|
||||
getImpactMeasure(i).setCitationClass(u.getLabel());
|
||||
if (u.getCode().equals("score"))
|
||||
}
|
||||
if (u.getCode().equals("score")) {
|
||||
getImpactMeasure(i).setCitationCount(Double.parseDouble(u.getLabel()));
|
||||
}
|
||||
});
|
||||
break;
|
||||
case Constants.BIP_POPULARITY_ALT:
|
||||
break;
|
||||
case Constants.BIP_IMPULSE:
|
||||
m.getUnit().forEach(u -> {
|
||||
if (u.getCode().equals("class"))
|
||||
if (u.getCode().equals("class")) {
|
||||
getImpactMeasure(i).setImpulseClass(u.getLabel());
|
||||
if (u.getCode().equals("score"))
|
||||
}
|
||||
if (u.getCode().equals("score")) {
|
||||
getImpactMeasure(i).setImpulse(Double.parseDouble(u.getLabel()));
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
|
||||
<!--
|
||||
Checks to make sure the code meets the ActiveMQ coding guidelines which
|
||||
|
||||
It also enforces a bunch of other "BestPractices like method
|
||||
lengths, if/try depths, etc...
|
||||
-->
|
||||
|
||||
<module name="Checker">
|
||||
<module name="TreeWalker">
|
||||
|
||||
<!-- Checks for Naming Conventions. -->
|
||||
<!-- See http://checkstyle.sf.net/config_naming.html -->
|
||||
<module name="ConstantName"/>
|
||||
<module name="LocalFinalVariableName"/>
|
||||
<module name="LocalVariableName"/>
|
||||
<module name="MemberName"/>
|
||||
<module name="MethodName"/>
|
||||
<module name="PackageName"/>
|
||||
<module name="ParameterName"/>
|
||||
<module name="StaticVariableName"/>
|
||||
<module name="TypeName"/>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="IllegalImport"/>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="MethodLength">
|
||||
<property name="max" value="200"/>
|
||||
<property name="countEmpty" value="false"/>
|
||||
</module>
|
||||
<module name="ParameterNumber">
|
||||
<property name="max" value="7"/>
|
||||
</module>
|
||||
|
||||
|
||||
<!-- Checks for whitespace -->
|
||||
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
|
||||
<module name="WhitespaceAfter">
|
||||
<property name="tokens" value="COMMA, SEMI"/>
|
||||
</module>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN,TYPE_EXTENSION_AND"/>
|
||||
</module>
|
||||
|
||||
<!-- Checks for blocks. You know, those {}'s -->
|
||||
<!-- See http://checkstyle.sf.net/config_blocks.html -->
|
||||
<module name="LeftCurly"/>
|
||||
<module name="RightCurly"/>
|
||||
<module name="NeedBraces">
|
||||
<property name="tokens"
|
||||
value="LITERAL_DO, LITERAL_ELSE, LITERAL_FOR, LITERAL_IF, LITERAL_WHILE"/>
|
||||
</module>
|
||||
|
||||
<!-- Checks for common coding problems -->
|
||||
<!-- See http://checkstyle.sf.net/config_coding.html -->
|
||||
<!--<module name="ArrayTrailingComma"/>-->
|
||||
<!--<module name="AvoidInlineConditionals"/>-->
|
||||
<module name="CovariantEquals"/>
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="EqualsHashCode"/>
|
||||
|
||||
<module name="IllegalInstantiation"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
|
||||
<module name="NestedIfDepth">
|
||||
<property name="max" value="8"/>
|
||||
</module>
|
||||
<module name="NestedTryDepth">
|
||||
<property name="max" value="8"/>
|
||||
</module>
|
||||
<module name="EmptyCatchBlock"/>
|
||||
<module name="OneTopLevelClass"/>
|
||||
</module>
|
||||
</module>
|
Loading…
Reference in New Issue