diff --git a/src/main/java/at/ac/uibk/gitsearch/repository/search/MetaDataRepository.java b/src/main/java/at/ac/uibk/gitsearch/repository/search/MetaDataRepository.java index c4b7cbd4e7acf7324a22c1589b7d7bdf8887b6b3..85848ab7f0f101b71ec2278d9b278008f8c2abef 100644 --- a/src/main/java/at/ac/uibk/gitsearch/repository/search/MetaDataRepository.java +++ b/src/main/java/at/ac/uibk/gitsearch/repository/search/MetaDataRepository.java @@ -37,7 +37,7 @@ import at.ac.uibk.gitsearch.service.dto.SearchInputDTO; import at.ac.uibk.gitsearch.service.dto.SearchResultsDTO; import at.ac.uibk.gitsearch.service.dto.SearchResultsDTO.GitProject; import at.ac.uibk.gitsearch.service.dto.SearchResultsDTO.Person; -import at.ac.uibk.gitsearch.service.dto.SearchResultsDTO.SearchResultDTO; +import at.ac.uibk.gitsearch.service.dto.SearchResultDTO; @Repository public class MetaDataRepository { @@ -324,7 +324,6 @@ public class MetaDataRepository { SearchResultDTOWrapper entry = objectMapper.readValue(searchHit.getSourceAsString(), SearchResultDTOWrapper.class); final SearchResultDTO metadata = entry.getMetadata(); - // metadata.setProject(entry.getProject()); return metadata; } diff --git a/src/main/java/at/ac/uibk/gitsearch/service/SearchService.java b/src/main/java/at/ac/uibk/gitsearch/service/SearchService.java index 2e1bb5a94c12a16ad99ab724acccd488895285ee..dbac225179dc13f85cd9a94c5530d8bc68803cc4 100644 --- a/src/main/java/at/ac/uibk/gitsearch/service/SearchService.java +++ b/src/main/java/at/ac/uibk/gitsearch/service/SearchService.java @@ -32,7 +32,7 @@ import at.ac.uibk.gitsearch.security.jwt.TokenProvider; import at.ac.uibk.gitsearch.service.dto.AutoCompleteEntry; import at.ac.uibk.gitsearch.service.dto.SearchInputDTO; import at.ac.uibk.gitsearch.service.dto.SearchResultsDTO; -import at.ac.uibk.gitsearch.service.dto.SearchResultsDTO.SearchResultDTO; +import at.ac.uibk.gitsearch.service.dto.SearchResultDTO; /** * Service for exercise/course search results @@ -201,7 +201,7 @@ public class SearchService { /** * temporary static test data. * - * @param infoString just a string to add to testdata description. + * @param searchString just a string to add to testdata description. * @return */ @SuppressWarnings("unused") @@ -209,7 +209,7 @@ public class SearchService { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.findAndRegisterModules(); - List<SearchResultDTO> loadedMetaData = new ArrayList<SearchResultsDTO.SearchResultDTO>(); + List<SearchResultDTO> loadedMetaData = new ArrayList<>(); for (String testFile : new String[] { "metaData1.yaml", "metaData2.yaml" }) { log.debug("reading test data from {} ", testFile); diff --git a/src/main/java/at/ac/uibk/gitsearch/service/dto/SearchResultDTO.java b/src/main/java/at/ac/uibk/gitsearch/service/dto/SearchResultDTO.java new file mode 100644 index 0000000000000000000000000000000000000000..85383d4ab49eca8d184c79cbe3347fc9db765504 --- /dev/null +++ b/src/main/java/at/ac/uibk/gitsearch/service/dto/SearchResultDTO.java @@ -0,0 +1,398 @@ +package at.ac.uibk.gitsearch.service.dto; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.Arrays; +import java.util.Objects; + +public class SearchResultDTO { + + public SearchResultDTO() { + // default constructor + } + + private String metadataVersion; // just for YAML test data reader + private String title; + private String identifier; + private String version; + private String structure; + + private String description; + private SearchResultsDTO.ExerciseType type; + private String license; + private String[] keyword; + + private String[] format; + private String[] programmingLanguage; + private String[] language; + private String status; + + private String educationLevel; + + private String gitURL; + + @JsonIgnore + private String audience; + + private String timeRequired; + + private SearchResultsDTO.GitProject project; + + @JsonIgnore + private String[] collectionContent; + + public String getTimeRequired() { + return timeRequired; + } + + public void setTimeRequired(String timeRequired) { + this.timeRequired = timeRequired; + } + + private SearchResultsDTO.Person[] creator; + private SearchResultsDTO.Person[] publisher; + private SearchResultsDTO.Person[] contributor; + + private boolean deprecated; + + private String difficulty; + private String[] source; + + private String[] requires; + private String image; + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public SearchResultsDTO.ExerciseType getType() { + return type; + } + + public void setType(SearchResultsDTO.ExerciseType type) { + this.type = type; + } + + public String[] getLanguage() { + return language; + } + + public void setLanguage(String[] language) { + this.language = language; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getEducationLevel() { + return educationLevel; + } + + public void setEducationLevel(String educationLevel) { + this.educationLevel = educationLevel; + } + + public String getAudience() { + return audience; + } + + public void setAudience(String audience) { + this.audience = audience; + } + + public SearchResultsDTO.Person[] getCreator() { + return creator; + } + + public void setCreator(SearchResultsDTO.Person[] creator) { + this.creator = creator; + } + + public SearchResultsDTO.Person[] getPublisher() { + return publisher; + } + + public void setPublisher(SearchResultsDTO.Person[] publisher) { + this.publisher = publisher; + } + + public SearchResultsDTO.Person[] getContributor() { + return contributor; + } + + public void setContributor(SearchResultsDTO.Person[] contributor) { + this.contributor = contributor; + } + + public boolean isDeprecated() { + return deprecated; + } + + public void setDeprecated(boolean deprecated) { + this.deprecated = deprecated; + } + + public String getDifficulty() { + return difficulty; + } + + public void setDifficulty(String difficulty) { + this.difficulty = difficulty; + } + + public String[] getSource() { + return source; + } + + public void setSource(String[] source) { + this.source = source; + } + + public String[] getRequires() { + return requires; + } + + public void setRequires(String[] requires) { + this.requires = requires; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + private String repositoryURL; + + public String getMetadataVersion() { + return metadataVersion; + } + + public void setMetadataVersion(String metadataVersion) { + this.metadataVersion = metadataVersion; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getLicense() { + return license; + } + + public void setLicense(String license) { + this.license = license; + } + + public String[] getKeyword() { + return keyword; + } + + public void setKeyword(String[] keyword) { + this.keyword = keyword; + } + + public String[] getFormat() { + return format; + } + + public void setFormat(String[] format) { + this.format = format; + } + + public String[] getProgrammingLanguage() { + return programmingLanguage; + } + + public void setProgrammingLanguage(String[] programmingLanguage) { + this.programmingLanguage = programmingLanguage; + } + + public String getRepositoryURL() { + return repositoryURL; + } + + public void setRepositoryURL(String repositoryURL) { + this.repositoryURL = repositoryURL; + } + + public String getStructure() { + return structure; + } + + public void setStructure(String structure) { + this.structure = structure; + } + + public String getGitURL() { + return gitURL; + } + + public void setGitURL(String gitURL) { + this.gitURL = gitURL; + } + + public SearchResultsDTO.GitProject getProject() { + return project; + } + + public void setProject(SearchResultsDTO.GitProject project) { + this.project = project; + } + + /** + * clone constructor + * + * @param toClone + */ + public SearchResultDTO(SearchResultDTO toClone) { + super(); + this.metadataVersion = toClone.metadataVersion; + this.title = toClone.title; + this.identifier = toClone.identifier; + this.version = toClone.version; + this.structure = toClone.structure; + this.description = toClone.description; + this.type = toClone.type; + this.license = toClone.license; + this.keyword = toClone.keyword; + this.format = toClone.format; + this.programmingLanguage = toClone.programmingLanguage; + this.language = toClone.language; + this.status = toClone.status; + this.educationLevel = toClone.educationLevel; + this.gitURL = toClone.gitURL; + this.audience = toClone.audience; + this.timeRequired = toClone.timeRequired; + this.collectionContent = toClone.collectionContent; + this.creator = toClone.creator; + this.publisher = toClone.publisher; + this.contributor = toClone.contributor; + this.deprecated = toClone.deprecated; + this.difficulty = toClone.difficulty; + this.source = toClone.source; + this.requires = toClone.requires; + this.image = toClone.image; + this.repositoryURL = toClone.repositoryURL; + } + + @Override + public String toString() { + return "SearchResultDTO [audience=" + audience + ", collectionContent=" + Arrays.toString(collectionContent) + + ", contributor=" + Arrays.toString(contributor) + ", creator=" + Arrays.toString(creator) + + ", deprecated=" + deprecated + ", description=" + description + ", difficulty=" + difficulty + + ", educationLevel=" + educationLevel + ", format=" + Arrays.toString(format) + ", gitURL=" + gitURL + + ", identifier=" + identifier + ", image=" + image + ", keyword=" + Arrays.toString(keyword) + + ", language=" + Arrays.toString(language) + ", license=" + license + ", metadataVersion=" + + metadataVersion + ", programmingLanguage=" + Arrays.toString(programmingLanguage) + ", publisher=" + + Arrays.toString(publisher) + ", repositoryURL=" + repositoryURL + ", requires=" + Arrays.toString(requires) + + ", source=" + Arrays.toString(source) + ", status=" + status + ", structure=" + structure + + ", timeRequired=" + timeRequired + ", title=" + title + ", type=" + type + ", version=" + version + + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((audience == null) ? 0 : audience.hashCode()); + result = prime * result + Arrays.hashCode(collectionContent); + result = prime * result + Arrays.hashCode(contributor); + result = prime * result + Arrays.hashCode(creator); + result = prime * result + (deprecated ? 1231 : 1237); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((difficulty == null) ? 0 : difficulty.hashCode()); + result = prime * result + ((educationLevel == null) ? 0 : educationLevel.hashCode()); + result = prime * result + Arrays.hashCode(format); + result = prime * result + ((gitURL == null) ? 0 : gitURL.hashCode()); + result = prime * result + ((identifier == null) ? 0 : identifier.hashCode()); + result = prime * result + ((image == null) ? 0 : image.hashCode()); + result = prime * result + Arrays.hashCode(keyword); + result = prime * result + Arrays.hashCode(language); + result = prime * result + ((license == null) ? 0 : license.hashCode()); + result = prime * result + ((metadataVersion == null) ? 0 : metadataVersion.hashCode()); + result = prime * result + Arrays.hashCode(programmingLanguage); + result = prime * result + ((project == null) ? 0 : project.hashCode()); + result = prime * result + Arrays.hashCode(publisher); + result = prime * result + ((repositoryURL == null) ? 0 : repositoryURL.hashCode()); + result = prime * result + Arrays.hashCode(requires); + result = prime * result + Arrays.hashCode(source); + result = prime * result + ((status == null) ? 0 : status.hashCode()); + result = prime * result + ((structure == null) ? 0 : structure.hashCode()); + result = prime * result + ((timeRequired == null) ? 0 : timeRequired.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + ((version == null) ? 0 : version.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof SearchResultDTO)) { + return false; + } + SearchResultDTO other = (SearchResultDTO) obj; + return Objects.equals(this.audience, other.audience) + && Arrays.equals(this.collectionContent, other.collectionContent) + && Arrays.equals(this.contributor, other.contributor) + && Arrays.equals(this.creator, other.creator) + && this.deprecated == other.deprecated + && Objects.equals(this.description, other.description) + && Objects.equals(this.difficulty, other.difficulty) + && Objects.equals(this.educationLevel, other.educationLevel) + && Arrays.equals(this.format, other.format) + && Objects.equals(this.gitURL, other.gitURL) + && Objects.equals(this.identifier, other.identifier) + && Objects.equals(this.image, other.image) + && Arrays.equals(this.keyword, other.keyword) + && Arrays.equals(this.language, other.language) + && Objects.equals(this.license, other.license) + && Objects.equals(this.metadataVersion, other.metadataVersion) + && Arrays.equals(this.programmingLanguage, other.programmingLanguage) + && Objects.equals(this.project, other.project) + && Arrays.equals(this.publisher, other.publisher) + && Objects.equals(this.repositoryURL, other.repositoryURL) + && Arrays.equals(this.requires, other.requires) + && Arrays.equals(this.source, other.source) + && Objects.equals(this.status, other.status) + && Objects.equals(this.structure, other.structure) + && Objects.equals(this.timeRequired, other.timeRequired) + && Objects.equals(this.title, other.title) + && this.type == other.type + && Objects.equals(this.version, other.version); + } +} diff --git a/src/main/java/at/ac/uibk/gitsearch/service/dto/SearchResultsDTO.java b/src/main/java/at/ac/uibk/gitsearch/service/dto/SearchResultsDTO.java index c156aabbb709b90a07bc0df42cfb69d745c4a275..121490daf2efb2c71b5f48a8fe04a1284b531740 100644 --- a/src/main/java/at/ac/uibk/gitsearch/service/dto/SearchResultsDTO.java +++ b/src/main/java/at/ac/uibk/gitsearch/service/dto/SearchResultsDTO.java @@ -1,11 +1,9 @@ package at.ac.uibk.gitsearch.service.dto; -import java.util.Arrays; import java.util.List; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonValue; public class SearchResultsDTO { @@ -179,398 +177,6 @@ public class SearchResultsDTO { } } - public static class SearchResultDTO { - - public SearchResultDTO() { - // default constructor - } - - private String metadataVersion; // just for YAML test data reader - private String title; - private String identifier; - private String version; - private String structure; - - private String description; - private ExerciseType type; - private String license; - private String[] keyword; - - private String[] format; - private String[] programmingLanguage; - private String[] language; - private String status; - - private String educationLevel; - - private String gitURL; - - @JsonIgnore - private String audience; - - private String timeRequired; - - private GitProject project; - - @JsonIgnore - private String[] collectionContent; - - public String getTimeRequired() { - return timeRequired; - } - - public void setTimeRequired(String timeRequired) { - this.timeRequired = timeRequired; - } - - private Person[] creator; - private Person[] publisher; - private Person[] contributor; - - private boolean deprecated; - - private String difficulty; - private String[] source; - - private String[] requires; - private String image; - - public String getIdentifier() { - return identifier; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public ExerciseType getType() { - return type; - } - - public void setType(ExerciseType type) { - this.type = type; - } - - public String[] getLanguage() { - return language; - } - - public void setLanguage(String[] language) { - this.language = language; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getEducationLevel() { - return educationLevel; - } - - public void setEducationLevel(String educationLevel) { - this.educationLevel = educationLevel; - } - - public String getAudience() { - return audience; - } - - public void setAudience(String audience) { - this.audience = audience; - } - - public Person[] getCreator() { - return creator; - } - - public void setCreator(Person[] creator) { - this.creator = creator; - } - - public Person[] getPublisher() { - return publisher; - } - - public void setPublisher(Person[] publisher) { - this.publisher = publisher; - } - - public Person[] getContributor() { - return contributor; - } - - public void setContributor(Person[] contributor) { - this.contributor = contributor; - } - - public boolean isDeprecated() { - return deprecated; - } - - public void setDeprecated(boolean deprecated) { - this.deprecated = deprecated; - } - - public String getDifficulty() { - return difficulty; - } - - public void setDifficulty(String difficulty) { - this.difficulty = difficulty; - } - - public String[] getSource() { - return source; - } - - public void setSource(String[] source) { - this.source = source; - } - - public String[] getRequires() { - return requires; - } - - public void setRequires(String[] requires) { - this.requires = requires; - } - - public String getImage() { - return image; - } - - public void setImage(String image) { - this.image = image; - } - - private String repositoryURL; - - public String getMetadataVersion() { - return metadataVersion; - } - - public void setMetadataVersion(String metadataVersion) { - this.metadataVersion = metadataVersion; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getLicense() { - return license; - } - - public void setLicense(String license) { - this.license = license; - } - - public String[] getKeyword() { - return keyword; - } - - public void setKeyword(String[] keyword) { - this.keyword = keyword; - } - - public String[] getFormat() { - return format; - } - - public void setFormat(String[] format) { - this.format = format; - } - - public String[] getProgrammingLanguage() { - return programmingLanguage; - } - - public void setProgrammingLanguage(String[] programmingLanguage) { - this.programmingLanguage = programmingLanguage; - } - - public String getRepositoryURL() { - return repositoryURL; - } - - public void setRepositoryURL(String repositoryURL) { - this.repositoryURL = repositoryURL; - } - - public String getStructure() { - return structure; - } - - public void setStructure(String structure) { - this.structure = structure; - } - - public String getGitURL() { - return gitURL; - } - - public void setGitURL(String gitURL) { - this.gitURL = gitURL; - } - - public GitProject getProject() { - return project; - } - - public void setProject(GitProject project) { - this.project = project; - } - - /** - * clone constructor - * - * @param toClone - */ - public SearchResultDTO(SearchResultDTO toClone) { - super(); - this.metadataVersion = toClone.metadataVersion; - this.title = toClone.title; - this.identifier = toClone.identifier; - this.version = toClone.version; - this.structure = toClone.structure; - this.description = toClone.description; - this.type = toClone.type; - this.license = toClone.license; - this.keyword = toClone.keyword; - this.format = toClone.format; - this.programmingLanguage = toClone.programmingLanguage; - this.language = toClone.language; - this.status = toClone.status; - this.educationLevel = toClone.educationLevel; - this.gitURL = toClone.gitURL; - this.audience = toClone.audience; - this.timeRequired = toClone.timeRequired; - this.collectionContent = toClone.collectionContent; - this.creator = toClone.creator; - this.publisher = toClone.publisher; - this.contributor = toClone.contributor; - this.deprecated = toClone.deprecated; - this.difficulty = toClone.difficulty; - this.source = toClone.source; - this.requires = toClone.requires; - this.image = toClone.image; - this.repositoryURL = toClone.repositoryURL; - } - - @Override - public String toString() { - return "SearchResultDTO [audience=" + audience + ", collectionContent=" + Arrays.toString(collectionContent) - + ", contributor=" + Arrays.toString(contributor) + ", creator=" + Arrays.toString(creator) - + ", deprecated=" + deprecated + ", description=" + description + ", difficulty=" + difficulty - + ", educationLevel=" + educationLevel + ", format=" + Arrays.toString(format) + ", gitURL=" + gitURL - + ", identifier=" + identifier + ", image=" + image + ", keyword=" + Arrays.toString(keyword) - + ", language=" + Arrays.toString(language) + ", license=" + license + ", metadataVersion=" - + metadataVersion + ", programmingLanguage=" + Arrays.toString(programmingLanguage) + ", publisher=" - + Arrays.toString(publisher) + ", repositoryURL=" + repositoryURL + ", requires=" + Arrays.toString(requires) - + ", source=" + Arrays.toString(source) + ", status=" + status + ", structure=" + structure - + ", timeRequired=" + timeRequired + ", title=" + title + ", type=" + type + ", version=" + version - + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((audience == null) ? 0 : audience.hashCode()); - result = prime * result + Arrays.hashCode(collectionContent); - result = prime * result + Arrays.hashCode(contributor); - result = prime * result + Arrays.hashCode(creator); - result = prime * result + (deprecated ? 1231 : 1237); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((difficulty == null) ? 0 : difficulty.hashCode()); - result = prime * result + ((educationLevel == null) ? 0 : educationLevel.hashCode()); - result = prime * result + Arrays.hashCode(format); - result = prime * result + ((gitURL == null) ? 0 : gitURL.hashCode()); - result = prime * result + ((identifier == null) ? 0 : identifier.hashCode()); - result = prime * result + ((image == null) ? 0 : image.hashCode()); - result = prime * result + Arrays.hashCode(keyword); - result = prime * result + Arrays.hashCode(language); - result = prime * result + ((license == null) ? 0 : license.hashCode()); - result = prime * result + ((metadataVersion == null) ? 0 : metadataVersion.hashCode()); - result = prime * result + Arrays.hashCode(programmingLanguage); - result = prime * result + ((project == null) ? 0 : project.hashCode()); - result = prime * result + Arrays.hashCode(publisher); - result = prime * result + ((repositoryURL == null) ? 0 : repositoryURL.hashCode()); - result = prime * result + Arrays.hashCode(requires); - result = prime * result + Arrays.hashCode(source); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result + ((structure == null) ? 0 : structure.hashCode()); - result = prime * result + ((timeRequired == null) ? 0 : timeRequired.hashCode()); - result = prime * result + ((title == null) ? 0 : title.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((version == null) ? 0 : version.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof SearchResultDTO)) { - return false; - } - SearchResultDTO other = (SearchResultDTO) obj; - return Objects.equals(this.audience, other.audience) - && Arrays.equals(this.collectionContent, other.collectionContent) - && Arrays.equals(this.contributor, other.contributor) - && Arrays.equals(this.creator, other.creator) - && this.deprecated == other.deprecated - && Objects.equals(this.description, other.description) - && Objects.equals(this.difficulty, other.difficulty) - && Objects.equals(this.educationLevel, other.educationLevel) - && Arrays.equals(this.format, other.format) - && Objects.equals(this.gitURL, other.gitURL) - && Objects.equals(this.identifier, other.identifier) - && Objects.equals(this.image, other.image) - && Arrays.equals(this.keyword, other.keyword) - && Arrays.equals(this.language, other.language) - && Objects.equals(this.license, other.license) - && Objects.equals(this.metadataVersion, other.metadataVersion) - && Arrays.equals(this.programmingLanguage, other.programmingLanguage) - && Objects.equals(this.project, other.project) - && Arrays.equals(this.publisher, other.publisher) - && Objects.equals(this.repositoryURL, other.repositoryURL) - && Arrays.equals(this.requires, other.requires) - && Arrays.equals(this.source, other.source) - && Objects.equals(this.status, other.status) - && Objects.equals(this.structure, other.structure) - && Objects.equals(this.timeRequired, other.timeRequired) - && Objects.equals(this.title, other.title) - && this.type == other.type - && Objects.equals(this.version, other.version); - } - } - private List<SearchResultDTO> searchResult; /**