Merge branch 'ui-refactoring' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-refactoring

This commit is contained in:
Diamantis Tziotzios 2019-02-15 13:41:21 +02:00
commit f3168f4e06
9 changed files with 18 additions and 11 deletions

View File

@ -24,9 +24,9 @@ public class ResearcherDaoImpl extends DatabaseAccess<Researcher> implements Res
public QueryableList<Researcher> getWithCriteria(ResearcherCriteria criteria) { public QueryableList<Researcher> getWithCriteria(ResearcherCriteria criteria) {
QueryableList<Researcher> query = asQueryable(); QueryableList<Researcher> query = asQueryable();
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) ->builder.or(builder.like(root.get("reference"), "%" + criteria.getLike().toUpperCase() + "%"))); query.where((builder, root) ->builder.or(builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%")));
if (criteria.getName() != null && !criteria.getName().isEmpty()) if (criteria.getName() != null && !criteria.getName().isEmpty())
query.where((builder, root) ->builder.or(builder.like(root.get("label"), "%" + criteria.getName().toUpperCase() + "%"))); query.where((builder, root) ->builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getName().toUpperCase() + "%")));
return query; return query;
} }

View File

@ -56,6 +56,7 @@ public class Admin extends BaseController {
eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
datasetprofile.setDefinition(modelDefinition.getDefinition()); datasetprofile.setDefinition(modelDefinition.getDefinition());
datasetprofile.setStatus(modelDefinition.getStatus()); datasetprofile.setStatus(modelDefinition.getStatus());
datasetprofile.setLabel(modelDefinition.getLabel());
this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile); this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
} }

View File

@ -2,6 +2,7 @@ package eu.eudat.logic.managers;
import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.dao.entities.DatasetProfileDao; import eu.eudat.data.dao.entities.DatasetProfileDao;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest; import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest;
@ -49,7 +50,8 @@ public class DatasetProfileManager {
} }
public List<DatasetProfileListingModel> getAll(DatasetProfileDao datasetProfileRepository) throws IllegalAccessException, InstantiationException { public List<DatasetProfileListingModel> getAll(DatasetProfileDao datasetProfileRepository) throws IllegalAccessException, InstantiationException {
QueryableList<DatasetProfile> items = datasetProfileRepository.getAll(); DatasetProfileCriteria criteria = new DatasetProfileCriteria();
QueryableList<DatasetProfile> items = datasetProfileRepository.getWithCriteria(criteria);
List<DatasetProfileListingModel> datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item)); List<DatasetProfileListingModel> datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
return datasetProfiles; return datasetProfiles;
} }

View File

@ -14,6 +14,7 @@ import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* Created by ikalyvas on 2/5/2018. * Created by ikalyvas on 2/5/2018.
@ -40,7 +41,6 @@ public class ResearcherManager {
.build(); .build();
researchers.add(researcher); researchers.add(researcher);
} }
researchers.stream().distinct(); return researchers.stream().distinct().collect(Collectors.toList());
return researchers;
} }
} }

View File

@ -42,8 +42,9 @@ export class DatasetProfileService {
return this.http.post<DatasetProfile>(this.actionUrl + 'datasetprofile/clone/' + id, {}); return this.http.post<DatasetProfile>(this.actionUrl + 'datasetprofile/clone/' + id, {});
} }
delete(id: string): Observable<DatasetProfile> { delete(id: string, data): Observable<DatasetProfile> {
return this.http.delete<DatasetProfile>(this.actionUrl + id, {}); return this.http.post<DatasetProfile>(this.actionUrl + 'addDmp/' + id, data);
//return this.http.delete<DatasetProfile>(this.actionUrl + id, {});
} }
} }

View File

@ -58,7 +58,7 @@ export class ExternalSourcesService {
} }
public searchDMPResearchers(requestItem: RequestItem<ResearcherCriteria>): Observable<ExternalSourceItemModel[]> { public searchDMPResearchers(requestItem: RequestItem<ResearcherCriteria>): Observable<ExternalSourceItemModel[]> {
return this.http.post<ExternalSourceItemModel[]>(environment.Server + '/researchers/getWithExternal', requestItem, { headers: this.headers }); return this.http.post<ExternalSourceItemModel[]>(environment.Server + 'researchers/getWithExternal', requestItem, { headers: this.headers });
} }
public searchDMPOrganizations(like: string): Observable<ExternalSourceItemModel[]> { public searchDMPOrganizations(like: string): Observable<ExternalSourceItemModel[]> {

View File

@ -7,6 +7,7 @@ import { Observable, of as observableOf, Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, mergeMap, startWith, tap } from 'rxjs/operators'; import { debounceTime, distinctUntilChanged, map, mergeMap, startWith, tap } from 'rxjs/operators';
import { AutoCompleteGroup } from '../auto-complete-group'; import { AutoCompleteGroup } from '../auto-complete-group';
import { MultipleAutoCompleteConfiguration } from './multiple-auto-complete-configuration'; import { MultipleAutoCompleteConfiguration } from './multiple-auto-complete-configuration';
import { switchMap } from 'rxjs/internal/operators/switchMap';
@Component({ @Component({
selector: 'app-multiple-auto-complete', selector: 'app-multiple-auto-complete',
@ -189,7 +190,7 @@ export class MultipleAutoCompleteComponent implements OnInit, MatFormFieldContro
debounceTime(this.requestDelay), debounceTime(this.requestDelay),
distinctUntilChanged(), distinctUntilChanged(),
tap(() => { this.loading = true; }), tap(() => { this.loading = true; }),
mergeMap(query => { switchMap(query => {
// If its a valid object, a selection just made and the object is set as the value of the form control. That means we should fire an extra request to the server. // If its a valid object, a selection just made and the object is set as the value of the form control. That means we should fire an extra request to the server.
if (this._isValidObject(query)) { return observableOf([]); } if (this._isValidObject(query)) { return observableOf([]); }

View File

@ -7,6 +7,7 @@ import { Observable, of as observableOf, Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, mergeMap, startWith, tap } from 'rxjs/operators'; import { debounceTime, distinctUntilChanged, map, mergeMap, startWith, tap } from 'rxjs/operators';
import { AutoCompleteGroup } from '../auto-complete-group'; import { AutoCompleteGroup } from '../auto-complete-group';
import { SingleAutoCompleteConfiguration } from './single-auto-complete-configuration'; import { SingleAutoCompleteConfiguration } from './single-auto-complete-configuration';
import { switchMap } from 'rxjs/internal/operators/switchMap';
@Component({ @Component({
@ -167,7 +168,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
debounceTime(this.requestDelay), debounceTime(this.requestDelay),
distinctUntilChanged(), distinctUntilChanged(),
tap(() => { this.loading = true; }), tap(() => { this.loading = true; }),
mergeMap(query => { switchMap(query => {
// If its a valid object, a selection just made and the object is set as the value of the form control. That means we should fire an extra request to the server. // If its a valid object, a selection just made and the object is set as the value of the form control. That means we should fire an extra request to the server.
if (this._isValidObject(query)) { return observableOf([]); } if (this._isValidObject(query)) { return observableOf([]); }

View File

@ -204,7 +204,8 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
}); });
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) { if (result) {
this.datasetProfileService.delete(this.datasetProfileId) this.form.get('status').setValue(DatasetProfileEnum.DELETED);
this.datasetProfileService.delete(this.datasetProfileId,this.form.value)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => { complete => {