From 528e5279c8fe79441be3e011626f503789f79a9b Mon Sep 17 00:00:00 2001 From: "CITE\\dtziotzios" Date: Tue, 29 Jan 2019 18:33:17 +0200 Subject: [PATCH 1/3] dataset draft save without validation --- .../app/ui/dataset/dataset-wizard/dataset-wizard.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts index f51f72ea8..cd694c24e 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts @@ -285,7 +285,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr save() { - if (!this.isFormValid()) { return; } + //if (!this.isFormValid()) { return; } this.formGroup.get('status').setValue('0'); this.submit(); } From 0552870362095affdeb0f9ae4e9e992d33ad0f39 Mon Sep 17 00:00:00 2001 From: dtziotzios Date: Wed, 30 Jan 2019 18:37:49 +0200 Subject: [PATCH 2/3] Removes and refactors endpoints from Project. --- .../main/java/eu/eudat/controllers/DMPs.java | 2 +- .../java/eu/eudat/controllers/Projects.java | 52 ++++++------------- .../eudat/logic/managers/ProjectManager.java | 2 + dmp-frontend/src/app/core/model/dmp/dmp.ts | 4 +- .../app/core/model/project/project-listing.ts | 34 +++++++----- .../src/app/core/model/project/project.ts | 24 --------- .../src/app/core/query/dmp/dmp-criteria.ts | 4 +- .../src/app/core/services/dmp/dmp.service.ts | 2 +- .../dataset/external-dataset.service.ts | 4 +- .../core/services/project/project.service.ts | 27 ++++------ .../dmp-profile-criteria.component.ts | 4 +- .../app/ui/dmp/editor/dmp-editor.component.ts | 4 +- .../src/app/ui/dmp/editor/dmp-editor.model.ts | 4 +- .../criteria/dmp-criteria.component.ts | 11 ++-- .../ui/dmp/listing/dmp-listing.component.ts | 4 +- .../ui/dmp/wizard/dmp-wizard-editor.model.ts | 6 +-- .../explore-dataset-listing.component.ts | 2 +- .../explore-dataset-filters.component.ts | 35 +++++++++---- .../editor/project-editor.component.ts | 6 +-- .../ui/project/editor/project-editor.model.ts | 6 +-- 20 files changed, 107 insertions(+), 130 deletions(-) delete mode 100644 dmp-frontend/src/app/core/model/project/project.ts diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index a5f0dc577..166c31262 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -79,7 +79,7 @@ public class DMPs extends BaseController { } @Transactional - @RequestMapping(method = RequestMethod.POST, value = {"/post"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity> createOrUpdate(@RequestBody eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan, Principal principal) throws Exception { this.dataManagementPlanManager.createOrUpdate(this.getApiContext(), dataManagementPlan, principal); diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Projects.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Projects.java index 2265d58f9..b7dd42a32 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Projects.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/Projects.java @@ -33,79 +33,59 @@ import static eu.eudat.types.Authorities.ANONYMOUS; @RestController @CrossOrigin -@RequestMapping(value = {"/api"}) +@RequestMapping(value = {"/api/projects/"}) public class Projects extends BaseController { + private ProjectManager projectManager; @Autowired - public Projects(ApiContext apiContext) { + public Projects(ApiContext apiContext, ProjectManager projectManager) { super(apiContext); + this.projectManager = projectManager; } - @RequestMapping(method = RequestMethod.POST, value = {"/projects/getPaged"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.POST, value = {"/paged"}, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest, Principal principal) throws Exception { - DataTableData dataTable = new ProjectManager().getPaged(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), projectTableRequest, principal); + DataTableData dataTable = this.projectManager.getPaged(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), projectTableRequest, principal); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE)); } - @RequestMapping(method = RequestMethod.GET, value = {"/projects/getSingle/{id}"}, produces = "application/json") + @RequestMapping(method = RequestMethod.GET, value = {"{id}"}, produces = "application/json") public @ResponseBody ResponseEntity> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException { - eu.eudat.models.data.project.Project project = new ProjectManager().getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), id); + eu.eudat.models.data.project.Project project = this.projectManager.getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), id); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(project).status(ApiMessageCode.NO_MESSAGE)); } - @Transactional - @RequestMapping(method = RequestMethod.POST, value = {"/projects/createOrUpdate"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity> addProject(@Valid @RequestBody eu.eudat.models.data.project.Project project, Principal principal) throws IOException, ParseException { - ProjectManager.createOrUpdate(this.getApiContext().getOperationsContext().getFileStorageService(), this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getContentDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(), project, principal); + this.projectManager.createOrUpdate(this.getApiContext().getOperationsContext().getFileStorageService(), this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getContentDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(), project, principal); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created")); } - @Transactional - @RequestMapping(method = RequestMethod.DELETE, value = {"/projects/inactivate/{id}"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity> inactivate(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException { - Project project = new ProjectManager().inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), id); + this.projectManager.inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), id); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); } - - @RequestMapping(method = RequestMethod.POST, value = {"/projects/getWithExternal"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.POST, value = {"/external"}, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException { - List dataTable = new ProjectManager().getCriteriaWithExternal(this.getApiContext(), projectCriteria, this.getApiContext().getOperationsContext().getRemoteFetcher()); + List dataTable = this.projectManager.getCriteriaWithExternal(this.getApiContext(), projectCriteria, this.getApiContext().getOperationsContext().getRemoteFetcher()); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE)); } - @RequestMapping(method = RequestMethod.POST, value = {"/projects/get"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.POST, value = {"get"}, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity>> get(@RequestBody ProjectCriteriaRequest projectCriteria, @ClaimedAuthorities(claims = {ANONYMOUS}) Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException { - List dataTable = new ProjectManager().getCriteria(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), projectCriteria, this.getApiContext().getOperationsContext().getRemoteFetcher()); + List dataTable = this.projectManager.getCriteria(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), projectCriteria, this.getApiContext().getOperationsContext().getRemoteFetcher()); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE)); } - @RequestMapping(method = RequestMethod.GET, value = {"/external/projects"}, produces = "application/json") - public @ResponseBody - ResponseEntity> listExternalProjects(@RequestParam(value = "query", required = false) String query, Principal principal) throws HugeResultSet, NoURLFound { - List> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getProjects(query); - ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(projectsExternalSourcesModel).status(ApiMessageCode.SUCCESS_MESSAGE)); - } - - @Transactional - @RequestMapping(method = RequestMethod.DELETE, value = {"/delete/{id}"}, produces = "application/json") - public @ResponseBody - ResponseEntity> delete(@PathVariable(value = "id") UUID id, Principal principal) throws Exception { - try{ - new ProjectManager().delete(this.getApiContext(), id); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked")); - }catch (ProjectWithDMPsDeleteException exception){ - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage())); - } - } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ProjectManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ProjectManager.java index 48b2695e7..c9c1e5c6b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ProjectManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ProjectManager.java @@ -25,6 +25,7 @@ import eu.eudat.logic.proxy.fetching.RemoteFetcher; import eu.eudat.queryable.QueryableList; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.helpers.FileStorageService; +import org.springframework.stereotype.Component; import java.io.IOException; import java.text.ParseException; @@ -35,6 +36,7 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; +@Component public class ProjectManager { public DataTableData getPaged(ProjectDao projectRepository, ProjectTableRequest projectTableRequest, Principal principal) throws Exception { diff --git a/dmp-frontend/src/app/core/model/dmp/dmp.ts b/dmp-frontend/src/app/core/model/dmp/dmp.ts index 969f3144a..6fcea9ae8 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp.ts @@ -1,7 +1,7 @@ import { Status } from "../../common/enum/Status"; import { DmpProfile, DmpProfileDefinition } from "../dmp-profile/dmp-profile"; import { OrganizationModel } from "../organisation/organization"; -import { ProjectModel } from "../project/project"; +import { ProjectListingModel } from "../project/project-listing"; import { ResearcherModel } from "../researcher/researcher"; import { UserModel } from "../user/user"; import { DmpDynamicField } from "./dmp-dynamic-field"; @@ -16,7 +16,7 @@ export interface DmpModel { lockable: boolean; description: String; profiles: DmpProfile[]; - project: ProjectModel; + project: ProjectListingModel; organisations: OrganizationModel[]; researchers: ResearcherModel[]; associatedUsers: UserModel[]; diff --git a/dmp-frontend/src/app/core/model/project/project-listing.ts b/dmp-frontend/src/app/core/model/project/project-listing.ts index 7dbbe1ebc..823326dfd 100644 --- a/dmp-frontend/src/app/core/model/project/project-listing.ts +++ b/dmp-frontend/src/app/core/model/project/project-listing.ts @@ -1,16 +1,26 @@ import { UrlListingItem } from "../../../library/url-listing/url-listing-item"; -import { ContentFile } from "./project"; +import { ProjectType } from '../../common/enum/project-type'; +import { Status } from '../../common/enum/Status'; export interface ProjectListingModel { - id: String; - label: String; - abbreviation: String; - reference: String; - uri: String; - status: String; - startDate: Date; - endDate: Date; - description: String; - files: ContentFile[]; - dmps: UrlListingItem[]; + id?: string; + label?: string; + abbreviation?: string; + reference?: string; + type?: ProjectType; + uri?: String; + status?: Status; + startDate?: Date; + endDate?: Date; + description?: String; + contentUrl?: string; + files?: ContentFile[]; + dmps?: UrlListingItem[]; +} + +export interface ContentFile { + filename?: string; + id?: string; + location?: string; + type?: string; } diff --git a/dmp-frontend/src/app/core/model/project/project.ts b/dmp-frontend/src/app/core/model/project/project.ts deleted file mode 100644 index 8b4a39571..000000000 --- a/dmp-frontend/src/app/core/model/project/project.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { ProjectType } from '../../common/enum/project-type'; -import { Status } from '../../common/enum/Status'; - -export interface ProjectModel { - id?: string; - label?: string; - abbreviation?: string; - reference?: string; - type?: ProjectType; - uri?: String; - status?: Status; - startDate?: Date; - endDate?: Date; - description?: String; - contentUrl?: string; - files?: ContentFile[]; -} - -export interface ContentFile { - filename?: string; - id?: string; - location?: string; - type?: string; -} diff --git a/dmp-frontend/src/app/core/query/dmp/dmp-criteria.ts b/dmp-frontend/src/app/core/query/dmp/dmp-criteria.ts index e70f3fdb2..f95cee86c 100644 --- a/dmp-frontend/src/app/core/query/dmp/dmp-criteria.ts +++ b/dmp-frontend/src/app/core/query/dmp/dmp-criteria.ts @@ -1,8 +1,8 @@ -import { ProjectModel } from "../../model/project/project"; +import { ProjectListingModel } from "../../model/project/project-listing"; import { BaseCriteria } from "../base-criteria"; export class DmpCriteria extends BaseCriteria { - public projects: ProjectModel[] = []; + public projects: ProjectListingModel[] = []; public groupIds: string[]; public allVersions: boolean; } diff --git a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts index 03b397454..47714e971 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts @@ -35,7 +35,7 @@ export class DmpService { return this.http.get(this.actionUrl + id + '/unlock', { headers: this.headers }); } createDmp(dataManagementPlanModel: DmpModel): Observable { - return this.http.post(this.actionUrl + 'post', dataManagementPlanModel, { headers: this.headers }); + return this.http.post(this.actionUrl , dataManagementPlanModel, { headers: this.headers }); } inactivate(id: String): Observable { diff --git a/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts b/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts index ff431b62c..103777966 100644 --- a/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts @@ -20,8 +20,8 @@ export class ExternalDatasetService { return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest); } - /* get(requestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'get', requestItem); + /* get(requestItem: RequestItem): Observable { + return this.http.post(this.actionUrl + 'get', requestItem); }*/ getWithExternal(requestItem: RequestItem): Observable { diff --git a/dmp-frontend/src/app/core/services/project/project.service.ts b/dmp-frontend/src/app/core/services/project/project.service.ts index 209e58b61..1f894e4b9 100644 --- a/dmp-frontend/src/app/core/services/project/project.service.ts +++ b/dmp-frontend/src/app/core/services/project/project.service.ts @@ -5,7 +5,6 @@ import { environment } from '../../../../environments/environment'; import { RequestItem } from '../../query/request-item'; import { DataTableData } from '../../model/data-table/data-table-data'; import { DataTableRequest } from '../../model/data-table/data-table-request'; -import { ProjectModel } from '../../model/project/project'; import { ProjectListingModel } from '../../model/project/project-listing'; import { ProjectCriteria } from '../../query/project/project-criteria'; import { BaseHttpService } from '../http/base-http.service'; @@ -21,30 +20,24 @@ export class ProjectService { } getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); + return this.http.post>(this.actionUrl + 'paged', dataTableRequest, { headers: this.headers }); } - get(requestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'get', requestItem, { headers: this.headers }); + getWithExternal(requestItem: RequestItem): Observable { + return this.http.post(this.actionUrl + 'external', requestItem, { headers: this.headers }); } - getWithExternal(requestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'getWithExternal', requestItem, { headers: this.headers }); + getSingle(id: string): Observable { + return this.http.get(this.actionUrl + id, { headers: this.headers }); } - getSingle(id: string): Observable { - return this.http.get(this.actionUrl + 'getSingle/' + id, { headers: this.headers }); + createProject(projectModel: ProjectListingModel): Observable { + return this.http.post(this.actionUrl, projectModel, { headers: this.headers }); } - createProject(projectModel: ProjectModel): Observable { - return this.http.post(this.actionUrl + 'createOrUpdate', projectModel, { headers: this.headers }); + // Actually sets it inactive. + delete(id: String): Observable { + return this.http.delete(this.actionUrl + id, { headers: this.headers }); } - inactivate(id: String): Observable { - return this.http.delete(this.actionUrl + 'inactivate/' + id, { headers: this.headers }); - } - - public delete(id: string): Observable { - return this.http.delete(this.actionUrl + 'delete' + id, { headers: this.headers }); - } } diff --git a/dmp-frontend/src/app/ui/admin/dmp-profile/listing/criteria/dmp-profile-criteria.component.ts b/dmp-frontend/src/app/ui/admin/dmp-profile/listing/criteria/dmp-profile-criteria.component.ts index 51bb34bef..94a6e514b 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-profile/listing/criteria/dmp-profile-criteria.component.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-profile/listing/criteria/dmp-profile-criteria.component.ts @@ -1,6 +1,6 @@ import { Component, Input, OnInit } from '@angular/core'; import { ValidationErrorModel } from '../../../../../common/forms/validation/error-model/validation-error-model'; -import { ProjectModel } from '../../../../../core/model/project/project'; +import { ProjectListingModel } from '../../../../../core/model/project/project-listing'; import { DmpCriteria } from '../../../../../core/query/dmp/dmp-criteria'; import { DmpProfileCriteria } from '../../../../../core/query/dmp/dmp-profile-criteria'; import { BaseCriteriaComponent } from '../../../../misc/criteria/base-criteria.component'; @@ -16,7 +16,7 @@ export class DmpProfileCriteriaComponent extends BaseCriteriaComponent implement showProject: boolean; public criteria: DmpProfileCriteria = new DmpProfileCriteria(); filteringProjectsAsync = false; - filteredProjects: ProjectModel[]; + filteredProjects: ProjectListingModel[]; constructor( ) { diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index 78c56839f..ebd459640 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -14,7 +14,7 @@ import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing import { DatasetProfileModel } from '../../../core/model/dataset/dataset-profile'; import { DmpModel } from '../../../core/model/dmp/dmp'; import { ExternalSourceItemModel } from '../../../core/model/external-sources/external-source-item'; -import { ProjectModel } from '../../../core/model/project/project'; +import { ProjectListingModel } from '../../../core/model/project/project-listing'; import { UserModel } from '../../../core/model/user/user'; import { BaseCriteria } from '../../../core/query/base-criteria'; import { DatasetProfileCriteria } from '../../../core/query/dataset-profile/dataset-profile-criteria'; @@ -149,7 +149,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC }); } else if (projectId != null) { this.isNew = true; - this.projectService.getSingle(projectId).map(data => data as ProjectModel) + this.projectService.getSingle(projectId).map(data => data as ProjectListingModel) .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.dmp = new DmpEditorModel(); diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.model.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.model.ts index b65d95ee9..18f6a1fab 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.model.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.model.ts @@ -8,7 +8,7 @@ import { DmpModel } from "../../../core/model/dmp/dmp"; import { DmpDynamicField } from "../../../core/model/dmp/dmp-dynamic-field"; import { DmpDynamicFieldDependency } from "../../../core/model/dmp/dmp-dynamic-field-dependency"; import { OrganizationModel } from "../../../core/model/organisation/organization"; -import { ProjectModel } from "../../../core/model/project/project"; +import { ProjectListingModel } from "../../../core/model/project/project-listing"; import { ResearcherModel } from "../../../core/model/researcher/researcher"; import { UserModel } from "../../../core/model/user/user"; import { ValidJsonValidator } from "../../../library/auto-complete/auto-complete-custom-validator"; @@ -23,7 +23,7 @@ export class DmpEditorModel { public creator: UserModel; public status: Status = Status.Active; public description: String; - public project: ProjectModel; + public project: ProjectListingModel; public organisations: OrganizationModel[] = []; public researchers: ResearcherModel[] = []; public profiles: DmpProfile[] = []; diff --git a/dmp-frontend/src/app/ui/dmp/listing/criteria/dmp-criteria.component.ts b/dmp-frontend/src/app/ui/dmp/listing/criteria/dmp-criteria.component.ts index 4e402010e..06c214356 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/criteria/dmp-criteria.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/criteria/dmp-criteria.component.ts @@ -3,13 +3,14 @@ import { FormBuilder, FormControl } from '@angular/forms'; import { TranslateService } from '@ngx-translate/core'; import { takeUntil } from 'rxjs/operators'; import { ValidationErrorModel } from '../../../../common/forms/validation/error-model/validation-error-model'; -import { ProjectModel } from '../../../../core/model/project/project'; +import { ProjectListingModel } from '../../../../core/model/project/project-listing'; import { DmpCriteria } from '../../../../core/query/dmp/dmp-criteria'; import { ProjectCriteria } from '../../../../core/query/project/project-criteria'; import { ProjectService } from '../../../../core/services/project/project.service'; import { MultipleAutoCompleteConfiguration } from '../../../../library/auto-complete/multiple/multiple-auto-complete-configuration'; import { RequestItem } from '../../../../core/query/request-item'; import { BaseCriteriaComponent } from '../../../misc/criteria/base-criteria.component'; +import { DataTableRequest } from '../../../../core/model/data-table/data-table-request'; @Component({ selector: 'app-dmp-criteria-component', @@ -20,7 +21,7 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni @Input() showProject: boolean; filteringProjectsAsync = false; - filteredProjects: ProjectModel[]; + filteredProjects: ProjectListingModel[]; public formGroup = new FormBuilder().group({ like: new FormControl(), projects: new FormControl() @@ -71,9 +72,11 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni } filterProject(query: string) { - const projectRequestItem: RequestItem = new RequestItem(); + const fields: Array = new Array(); + fields.push('asc'); + const projectRequestItem: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); projectRequestItem.criteria = new ProjectCriteria(); projectRequestItem.criteria.like = query; - return this.projectService.get(projectRequestItem); + return this.projectService.getPaged(projectRequestItem).map(x => x.data); } } diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts index 578c392ca..d9761d989 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts @@ -14,7 +14,7 @@ import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent'; import { DmpInvitationDialogComponent } from '../invitation/dmp-invitation.component'; import { DmpCriteriaComponent } from './criteria/dmp-criteria.component'; -import { ProjectModel } from '../../../core/model/project/project'; +import { ProjectListingModel } from '../../../core/model/project/project-listing'; @Component({ selector: 'app-dmp-listing-component', @@ -52,7 +52,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread if (params['projectId']) { this.projectId = params['projectId']; this.showProject = false; - const project: ProjectModel = { + const project: ProjectListingModel = { id: this.projectId } this.criteria.setCriteria({ like: null, projects: [project], groupIds: null, allVersions: false }); diff --git a/dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard-editor.model.ts b/dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard-editor.model.ts index 12d127923..dcaa915c9 100644 --- a/dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard-editor.model.ts +++ b/dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard-editor.model.ts @@ -8,7 +8,7 @@ import { DmpModel } from "../../../core/model/dmp/dmp"; import { DmpDynamicField } from "../../../core/model/dmp/dmp-dynamic-field"; import { DmpDynamicFieldDependency } from "../../../core/model/dmp/dmp-dynamic-field-dependency"; import { OrganizationModel } from "../../../core/model/organisation/organization"; -import { ProjectModel } from "../../../core/model/project/project"; +import { ProjectListingModel } from "../../../core/model/project/project-listing"; import { ResearcherModel } from "../../../core/model/researcher/researcher"; import { UserModel } from "../../../core/model/user/user"; import { ValidJsonValidator } from "../../../library/auto-complete/auto-complete-custom-validator"; @@ -23,7 +23,7 @@ export class DmpWizardEditorModel { public creator: UserModel; public status: Status = Status.Active; public description: String; - public project: ProjectModel; + public project: ProjectListingModel; public organisations: OrganizationModel[] = []; public researchers: ResearcherModel[] = []; public profiles: DmpProfile[] = []; @@ -146,4 +146,4 @@ export class DmpDynamicFieldDependencyEditorModel { queryProperty: [this.queryProperty] }); } -} \ No newline at end of file +} diff --git a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.ts b/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.ts index e68027e8e..ee958077e 100644 --- a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.ts +++ b/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.ts @@ -118,7 +118,7 @@ export class DatasetDataSource extends DataSource { let fields: Array = new Array(); if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; } const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); - request.criteria = this._criteria; + request.criteria = new ExploreDatasetCriteriaModel(); //if (this.dmpId) request.criteria.allVersions = true; return this._service.getPublicPaged(request); }) diff --git a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.ts b/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.ts index 313f19a0b..aabb94594 100644 --- a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.ts +++ b/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.ts @@ -7,7 +7,7 @@ import { BaseComponent } from '../../../core/common/base/base.component'; import { ProjectStateType } from '../../../core/common/enum/project-state-type'; import { DatasetProfileModel } from '../../../core/model/dataset/dataset-profile'; import { ExternalSourceItemModel } from '../../../core/model/external-sources/external-source-item'; -import { ProjectModel } from '../../../core/model/project/project'; +import { ProjectListingModel } from '../../../core/model/project/project-listing'; import { ExploreDatasetCriteriaModel } from '../../../core/query/explore-dataset/explore-dataset-criteria'; import { ProjectCriteria } from '../../../core/query/project/project-criteria'; import { TagCriteria } from '../../../core/query/tag/tag-criteria'; @@ -15,6 +15,7 @@ import { DatasetService } from '../../../core/services/dataset/dataset.service'; import { ExternalSourcesService } from '../../../core/services/external-sources/external-sources.service'; import { ProjectService } from '../../../core/services/project/project.service'; import { RequestItem } from '../../../core/query/request-item'; +import { DataTableRequest } from '../../../core/model/data-table/data-table-request'; @Component({ selector: 'app-explore-dataset-filters-component', @@ -28,10 +29,10 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI public filteringTagsAsync = false; public filteredTags: ExternalSourceItemModel[]; ProjectStateType = ProjectStateType; - projects: Observable; + projects: Observable; profiles: Observable; dmpOrganisations: Observable; - projectOptions: Observable; + projectOptions: Observable; projectStateOptions: Observable; @ViewChild('facetAccordion') accordion: MatAccordion; @@ -86,11 +87,16 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI this.facetCriteria.projects = []; } if (event.option.selected) { - const projectCriteria = new ProjectCriteria(); - projectCriteria.projectStateType = this.facetCriteria.projectStatus; - projectCriteria['length'] = 10; - const dataTableRequest: RequestItem = { criteria: projectCriteria }; - this.projects = this.projectService.get(dataTableRequest); + // const projectCriteria = new ProjectCriteria(); + // projectCriteria.projectStateType = this.facetCriteria.projectStatus; + //projectCriteria['length'] = 10; + const fields: Array = new Array(); + fields.push('asc'); + const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); + dataTableRequest.criteria = new ProjectCriteria(); + dataTableRequest.criteria.projectStateType = this.facetCriteria.projectStatus; + dataTableRequest.criteria['length'] = 10; + this.projects = this.projectService.getPaged(dataTableRequest).map(x => x.data); this.facetCriteria.projects = []; } this.facetCriteriaChange.emit(this.facetCriteria); @@ -138,13 +144,20 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI this.facetCriteriaChange.emit(this.facetCriteria); } - public projectSearch(value: string): Observable { + public projectSearch(value: string): Observable { + const projectCriteria = new ProjectCriteria(); projectCriteria.projectStateType = this.facetCriteria.projectStatus; projectCriteria['length'] = 10; projectCriteria.like = value; - const dataTableRequest: RequestItem = { criteria: projectCriteria }; - return this.projectService.get(dataTableRequest); + + const fields: Array = new Array(); + fields.push('asc'); + + const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); + dataTableRequest.criteria = projectCriteria; + //const dataTableRequest: RequestItem = { criteria: projectCriteria }; + return this.projectService.getPaged(dataTableRequest).map(x => x.data); } public dmpOrganisationSearch(value: string): Observable { diff --git a/dmp-frontend/src/app/ui/project/editor/project-editor.component.ts b/dmp-frontend/src/app/ui/project/editor/project-editor.component.ts index 654e2aa38..8e63e9d9a 100644 --- a/dmp-frontend/src/app/ui/project/editor/project-editor.component.ts +++ b/dmp-frontend/src/app/ui/project/editor/project-editor.component.ts @@ -9,7 +9,7 @@ import { environment } from '../../../../environments/environment'; import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model'; import { BaseComponent } from '../../../core/common/base/base.component'; import { ProjectType } from '../../../core/common/enum/project-type'; -import { ProjectModel } from '../../../core/model/project/project'; +import { ProjectListingModel } from '../../../core/model/project/project-listing'; import { ProjectFileUploadService } from '../../../core/services/project/project-file-upload.service'; import { ProjectService } from '../../../core/services/project/project.service'; import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component'; @@ -53,7 +53,7 @@ export class ProjectEditorComponent extends BaseComponent implements OnInit, IBr if (itemId != null) { this.isNew = false; - this.projectService.getSingle(itemId).map(data => data as ProjectModel) + this.projectService.getSingle(itemId).map(data => data as ProjectListingModel) .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.project = new ProjectEditorModel().fromModel(data); @@ -124,7 +124,7 @@ export class ProjectEditorComponent extends BaseComponent implements OnInit, IBr }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result) { - this.projectService.inactivate(this.project.id) + this.projectService.delete(this.project.id) .pipe(takeUntil(this._destroyed)) .subscribe( complete => { this.onCallbackSuccess() }, diff --git a/dmp-frontend/src/app/ui/project/editor/project-editor.model.ts b/dmp-frontend/src/app/ui/project/editor/project-editor.model.ts index b4778608a..eea42c273 100644 --- a/dmp-frontend/src/app/ui/project/editor/project-editor.model.ts +++ b/dmp-frontend/src/app/ui/project/editor/project-editor.model.ts @@ -4,7 +4,7 @@ import { ValidationErrorModel } from '../../../common/forms/validation/error-mod import { ValidationContext } from '../../../common/forms/validation/validation-context'; import { ProjectType } from '../../../core/common/enum/project-type'; import { Status } from '../../../core/common/enum/Status'; -import { ContentFile, ProjectModel } from '../../../core/model/project/project'; +import { ContentFile, ProjectListingModel } from '../../../core/model/project/project-listing'; export class ProjectEditorModel { public id: string; @@ -21,7 +21,7 @@ export class ProjectEditorModel { public files: ContentFile[]; public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - fromModel(item: ProjectModel): ProjectEditorModel { + fromModel(item: ProjectListingModel): ProjectEditorModel { this.id = item.id; this.label = item.label; this.type = item.type; @@ -81,4 +81,4 @@ export function startEndValidator(formGroup: FormGroup) { return { 'startAfterEndError': { } }; } return null; - } \ No newline at end of file + } From 5d514d66101ac69de8b8bac43e27b3105b0f2efc Mon Sep 17 00:00:00 2001 From: dtziotzios Date: Thu, 31 Jan 2019 12:16:09 +0200 Subject: [PATCH 3/3] One more file for the refactor on endpoint for Project --- .../app/core/services/project/project-file-upload.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmp-frontend/src/app/core/services/project/project-file-upload.service.ts b/dmp-frontend/src/app/core/services/project/project-file-upload.service.ts index e72ef95f7..393271a29 100644 --- a/dmp-frontend/src/app/core/services/project/project-file-upload.service.ts +++ b/dmp-frontend/src/app/core/services/project/project-file-upload.service.ts @@ -2,7 +2,7 @@ import { HttpHeaders } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { environment } from '../../../../environments/environment'; -import { ContentFile } from '../../model/project/project'; +import { ContentFile } from '../../model/project/project-listing'; import { BaseHttpService } from '../http/base-http.service'; @Injectable()