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
2 merge requests!50Merge 2021 May Sprint,!47More search fields
......@@ -7,7 +7,7 @@ import at.ac.uibk.gitsearch.service.dto.UserProvidedMetadataDTO.ExerciseType;
public class SearchInputMetadataDTO {
private String programmingLanguage;
private String keyword;
private String naturalLanguage;
private List<String> naturalLanguage;
private String license;
private String author;
private List<ExerciseType> types;
......@@ -17,14 +17,14 @@ public class SearchInputMetadataDTO {
public SearchInputMetadataDTO(String programmingLanguage,
String keyword,
String naturalLanguage,
String license,
String author) {
String author,
List<String> naturalLanguage) {
this.programmingLanguage = mapEmptyString(programmingLanguage);
this.keyword = mapEmptyString(keyword);
this.naturalLanguage = mapEmptyString(naturalLanguage);
this.license = mapEmptyString(license);
this.author = mapEmptyString(author);
this.naturalLanguage = naturalLanguage;
}
private static String mapEmptyString(String str) {
......@@ -54,12 +54,12 @@ public class SearchInputMetadataDTO {
this.keyword = mapEmptyString(keyword);
}
public String getNaturalLanguage() {
public List<String> getNaturalLanguage() {
return naturalLanguage;
}
public void setNaturalLanguage(String naturalLanguage) {
this.naturalLanguage = mapEmptyString(naturalLanguage);
public void setNaturalLanguage(List<String> naturalLanguage) {
this.naturalLanguage = naturalLanguage;
}
public String getLicense() {
......@@ -96,7 +96,7 @@ public class SearchInputMetadataDTO {
public String toString() {
return "programmingLanguage: " + this.programmingLanguage
+ ", keyword: " + this.keyword
+ ", naturalLanguage: " + this.naturalLanguage
+ ", naturalLanguage: " + this.naturalLanguage.toString()
+ ", license: " + this.license
+ ", author: " + this.author;
}
......
......@@ -77,7 +77,7 @@
<div class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);">
<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;">
<table><tr *ngFor="let language of languageValues"><td>
<input class="form-check-input" [value]="language" type="checkbox" queryParamName="{{language}}">
......
......@@ -8,6 +8,11 @@ export enum IExerciseType {
OTHER = 'other',
}
export enum ILanguages {
GERMAN = 'de',
ENGLISH = 'en',
}
// 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
// export function IExerciseTypeAware(constructor: Function) {
......
import {IExerciseType } from 'app/shared/model/exercise.model';
import { IExerciseType } from 'app/shared/model/exercise.model';
export class MetadataSearchInput {
public keyword: string;
public programmingLanguage: string;
public naturalLanguage: string;
public naturalLanguage: Array<String>;
public license: string;
public author: string;
public types: Array<IExerciseType>
public types: Array<IExerciseType>;
public constructor() {
this.keyword = '';
this.programmingLanguage = '';
this.naturalLanguage = '';
this.naturalLanguage = [];
this.license = '';
this.author = '';
this.types = [];
......
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 {
public fulltextQuery: string;
......@@ -20,13 +20,20 @@ export class SearchInput {
this.metadata.author = value.author;
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 = [];
Object.keys(IExerciseType).forEach(
typeName => {
if(value[typeName]) {
const eType = IExerciseType[typeName];
this.metadata.types.push(eType)
}
})
Object.keys(IExerciseType).forEach(typeName => {
if (value[typeName]) {
const eType = IExerciseType[typeName];
this.metadata.types.push(eType);
}
});
}
}
......@@ -104,7 +104,7 @@ public class SearchServiceIT {
@Test
public void testSearchByAutor() throws Exception {
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);
SearchResultsDTO searchResultPage = searchService.searchResultPage(searchQuery, 0, SearchInputDTO.PAGE_SIZE);
......@@ -131,7 +131,7 @@ public class SearchServiceIT {
@Test
public void testCreatorSearch() throws IOException {
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);
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