This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit a4ba445f authored by Eduard Frankford's avatar Eduard Frankford
Browse files

intermediate commit

parent a1e67809
Branches
Tags
2 merge requests!50Merge 2021 May Sprint,!47More search fields
...@@ -7,7 +7,7 @@ import at.ac.uibk.gitsearch.service.dto.UserProvidedMetadataDTO.ExerciseType; ...@@ -7,7 +7,7 @@ import at.ac.uibk.gitsearch.service.dto.UserProvidedMetadataDTO.ExerciseType;
public class SearchInputMetadataDTO { public class SearchInputMetadataDTO {
private String programmingLanguage; private String programmingLanguage;
private String keyword; private String keyword;
private String naturalLanguage; private List<String> naturalLanguage;
private String license; private String license;
private String author; private String author;
private List<ExerciseType> types; private List<ExerciseType> types;
...@@ -17,14 +17,14 @@ public class SearchInputMetadataDTO { ...@@ -17,14 +17,14 @@ public class SearchInputMetadataDTO {
public SearchInputMetadataDTO(String programmingLanguage, public SearchInputMetadataDTO(String programmingLanguage,
String keyword, String keyword,
String naturalLanguage,
String license, String license,
String author) { String author,
List<String> naturalLanguage) {
this.programmingLanguage = mapEmptyString(programmingLanguage); this.programmingLanguage = mapEmptyString(programmingLanguage);
this.keyword = mapEmptyString(keyword); this.keyword = mapEmptyString(keyword);
this.naturalLanguage = mapEmptyString(naturalLanguage);
this.license = mapEmptyString(license); this.license = mapEmptyString(license);
this.author = mapEmptyString(author); this.author = mapEmptyString(author);
this.naturalLanguage = naturalLanguage;
} }
private static String mapEmptyString(String str) { private static String mapEmptyString(String str) {
...@@ -54,12 +54,12 @@ public class SearchInputMetadataDTO { ...@@ -54,12 +54,12 @@ public class SearchInputMetadataDTO {
this.keyword = mapEmptyString(keyword); this.keyword = mapEmptyString(keyword);
} }
public String getNaturalLanguage() { public List<String> getNaturalLanguage() {
return naturalLanguage; return naturalLanguage;
} }
public void setNaturalLanguage(String naturalLanguage) { public void setNaturalLanguage(List<String> naturalLanguage) {
this.naturalLanguage = mapEmptyString(naturalLanguage); this.naturalLanguage = naturalLanguage;
} }
public String getLicense() { public String getLicense() {
...@@ -96,7 +96,7 @@ public class SearchInputMetadataDTO { ...@@ -96,7 +96,7 @@ public class SearchInputMetadataDTO {
public String toString() { public String toString() {
return "programmingLanguage: " + this.programmingLanguage return "programmingLanguage: " + this.programmingLanguage
+ ", keyword: " + this.keyword + ", keyword: " + this.keyword
+ ", naturalLanguage: " + this.naturalLanguage + ", naturalLanguage: " + this.naturalLanguage.toString()
+ ", license: " + this.license + ", license: " + this.license
+ ", author: " + this.author; + ", author: " + this.author;
} }
......
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<div class="nav-item dropdown"> <div class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);"> <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);">
<span jhiTranslate="exercise.metadata.language.mix">Language(s)</span> <span jhiTranslate="exercise.metadata.language.mix">Language(s)</span>
</a><span *ngFor="let language of languageValues, let isLast=last">{{'exercise.metadata.' + language | translate}}{{isLast ? '' : ', '}}</span> </a><span *ngFor="let language of getSelectedLanguages(), let isLast=last">{{'exercise.metadata.' + language | translate}}{{isLast ? '' : ', '}}</span>
<div class="dropdown-menu" style="padding-left: 10px;"> <div class="dropdown-menu" style="padding-left: 10px;">
<table><tr *ngFor="let language of languageValues"><td> <table><tr *ngFor="let language of languageValues"><td>
<input class="form-check-input" [value]="language" type="checkbox" queryParamName="{{language}}"> <input class="form-check-input" [value]="language" type="checkbox" queryParamName="{{language}}">
......
...@@ -8,6 +8,11 @@ export enum IExerciseType { ...@@ -8,6 +8,11 @@ export enum IExerciseType {
OTHER = 'other', OTHER = 'other',
} }
export enum ILanguages {
GERMAN = 'de',
ENGLISH = 'en',
}
// just a cheap trick, to make enum available to HTML. // just a cheap trick, to make enum available to HTML.
// see https://stackoverflow.com/questions/35835984/how-to-use-a-typescript-enum-value-in-an-angular2-ngswitch-statement // see https://stackoverflow.com/questions/35835984/how-to-use-a-typescript-enum-value-in-an-angular2-ngswitch-statement
// export function IExerciseTypeAware(constructor: Function) { // export function IExerciseTypeAware(constructor: Function) {
......
import {IExerciseType } from 'app/shared/model/exercise.model'; import { IExerciseType } from 'app/shared/model/exercise.model';
export class MetadataSearchInput { export class MetadataSearchInput {
public keyword: string; public keyword: string;
public programmingLanguage: string; public programmingLanguage: string;
public naturalLanguage: string; public naturalLanguage: Array<String>;
public license: string; public license: string;
public author: string; public author: string;
public types: Array<IExerciseType> public types: Array<IExerciseType>;
public constructor() { public constructor() {
this.keyword = ''; this.keyword = '';
this.programmingLanguage = ''; this.programmingLanguage = '';
this.naturalLanguage = ''; this.naturalLanguage = [];
this.license = ''; this.license = '';
this.author = ''; this.author = '';
this.types = []; this.types = [];
......
import { MetadataSearchInput } from 'app/shared/model/search/metadata-search-input.model'; import { MetadataSearchInput } from 'app/shared/model/search/metadata-search-input.model';
import {IExerciseType } from 'app/shared/model/exercise.model'; import { IExerciseType, ILanguages } from 'app/shared/model/exercise.model';
export class SearchInput { export class SearchInput {
public fulltextQuery: string; public fulltextQuery: string;
...@@ -20,13 +20,20 @@ export class SearchInput { ...@@ -20,13 +20,20 @@ export class SearchInput {
this.metadata.author = value.author; this.metadata.author = value.author;
this.metadata.license = value.license; this.metadata.license = value.license;
this.metadata.naturalLanguage = [];
Object.keys(ILanguages).forEach(typeName => {
if (value[typeName]) {
const eType = ILanguages[typeName];
this.metadata.naturalLanguage.push(eType);
}
});
this.metadata.types = []; this.metadata.types = [];
Object.keys(IExerciseType).forEach( Object.keys(IExerciseType).forEach(typeName => {
typeName => { if (value[typeName]) {
if(value[typeName]) { const eType = IExerciseType[typeName];
const eType = IExerciseType[typeName]; this.metadata.types.push(eType);
this.metadata.types.push(eType) }
} });
})
} }
} }
...@@ -104,7 +104,7 @@ public class SearchServiceIT { ...@@ -104,7 +104,7 @@ public class SearchServiceIT {
@Test @Test
public void testSearchByAutor() throws Exception { public void testSearchByAutor() throws Exception {
final String PODLIPNIG = "Stefan Podlipnig"; final String PODLIPNIG = "Stefan Podlipnig";
final SearchInputMetadataDTO searchMetadata = new SearchInputMetadataDTO(null, null, null, null, PODLIPNIG); final SearchInputMetadataDTO searchMetadata = new SearchInputMetadataDTO(null, null, null, PODLIPNIG,null);
SearchInputDTO searchQuery = new SearchInputDTO(null, searchMetadata, null, null, null, 0); SearchInputDTO searchQuery = new SearchInputDTO(null, searchMetadata, null, null, null, 0);
SearchResultsDTO searchResultPage = searchService.searchResultPage(searchQuery, 0, SearchInputDTO.PAGE_SIZE); SearchResultsDTO searchResultPage = searchService.searchResultPage(searchQuery, 0, SearchInputDTO.PAGE_SIZE);
...@@ -131,7 +131,7 @@ public class SearchServiceIT { ...@@ -131,7 +131,7 @@ public class SearchServiceIT {
@Test @Test
public void testCreatorSearch() throws IOException { public void testCreatorSearch() throws IOException {
searchClient.getLowLevelClient().getNodes().forEach(n -> {LOGGER.info("Using node {}", n);}); searchClient.getLowLevelClient().getNodes().forEach(n -> {LOGGER.info("Using node {}", n);});
final SearchInputMetadataDTO searchMetadata = new SearchInputMetadataDTO(null, null, null, null, "Podlipnig"); final SearchInputMetadataDTO searchMetadata = new SearchInputMetadataDTO(null, null, null, "Podlipnig",null);
SearchInputDTO searchQuery = new SearchInputDTO(null, searchMetadata, null, null, null, 0); SearchInputDTO searchQuery = new SearchInputDTO(null, searchMetadata, null, null, null, 0);
SearchResultsDTO searchResultPage = searchService.searchResultPage(searchQuery, 0, SearchInputDTO.PAGE_SIZE); SearchResultsDTO searchResultPage = searchService.searchResultPage(searchQuery, 0, SearchInputDTO.PAGE_SIZE);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment