diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/resource/ResourceAjaxController.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/resource/ResourceAjaxController.java index e154e2f8..a9ec2707 100644 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/resource/ResourceAjaxController.java +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/resource/ResourceAjaxController.java @@ -25,11 +25,12 @@ public class ResourceAjaxController extends AbstractResourceController { @PostMapping("/") public SimpleResource newResource(@RequestParam final String name, @RequestParam final String type, + @RequestParam(required = false, defaultValue = "") final String subtype, @RequestParam(required = false, defaultValue = "") final String description, @RequestParam final String content) throws InformationServiceException { - return service.saveNewResource(name, type, description, content); + return service.saveNewResource(name, type, subtype, description, content); } @DeleteMapping("/{resId}") diff --git a/frontends/dnet-is-application/src/app/common/is.model.ts b/frontends/dnet-is-application/src/app/common/is.model.ts index 1da787c2..7ea47b6f 100644 --- a/frontends/dnet-is-application/src/app/common/is.model.ts +++ b/frontends/dnet-is-application/src/app/common/is.model.ts @@ -54,6 +54,7 @@ export interface SimpleResource { id: string, name: string, type: string, + subtype?: string, description?: string, creationDate?: string, modificationDate?: string diff --git a/frontends/dnet-is-application/src/app/common/is.service.ts b/frontends/dnet-is-application/src/app/common/is.service.ts index b0dc096a..ed6297dc 100644 --- a/frontends/dnet-is-application/src/app/common/is.service.ts +++ b/frontends/dnet-is-application/src/app/common/is.service.ts @@ -72,11 +72,12 @@ export class ISService { }); } - addSimpleResource(name: string, type: string, description: string, content: string, onSuccess: Function, relatedForm?: FormGroup): void { + addSimpleResource(name: string, type: string, subtype: string, description: string, content: string, onSuccess: Function, relatedForm?: FormGroup): void { const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded') let body = new HttpParams() .set('name', name) .set('type', type) + .set('subtype', subtype) .set('description', description) .set('content', content); this.client.post('/ajax/resources/', body, { headers: headers }).subscribe({ diff --git a/frontends/dnet-is-application/src/app/resources/metadata-dialog.html b/frontends/dnet-is-application/src/app/resources/metadata-dialog.html index 1c391d15..c017f64d 100644 --- a/frontends/dnet-is-application/src/app/resources/metadata-dialog.html +++ b/frontends/dnet-is-application/src/app/resources/metadata-dialog.html @@ -13,9 +13,14 @@ + + SubType (optional) + + + Name - + This field is required diff --git a/frontends/dnet-is-application/src/app/resources/new-dialog.html b/frontends/dnet-is-application/src/app/resources/new-dialog.html index 4ed97939..031a4380 100644 --- a/frontends/dnet-is-application/src/app/resources/new-dialog.html +++ b/frontends/dnet-is-application/src/app/resources/new-dialog.html @@ -5,10 +5,15 @@ Name - + This field is required + + SubType (optional) + + + Description @@ -16,7 +21,7 @@ Content ({{data.contentType}}) - + This field is required diff --git a/frontends/dnet-is-application/src/app/resources/resources.component.html b/frontends/dnet-is-application/src/app/resources/resources.component.html index 17ce536b..6463697a 100644 --- a/frontends/dnet-is-application/src/app/resources/resources.component.html +++ b/frontends/dnet-is-application/src/app/resources/resources.component.html @@ -12,14 +12,18 @@ - {{r.name}} {{type.contentType}} + + {{r.name}} + {{r.subtype}} + {{type.contentType}} +

{{r.description}}

- Id: {{r.id}}
Creation date: {{r.creationDate}}
Modification date: - {{r.modificationDate}} + Id: {{r.id}}
+ Creation date: {{r.creationDate}}
+ Modification date: {{r.modificationDate}}

diff --git a/frontends/dnet-is-application/src/app/resources/resources.component.ts b/frontends/dnet-is-application/src/app/resources/resources.component.ts index c801a65a..1d5c2570 100644 --- a/frontends/dnet-is-application/src/app/resources/resources.component.ts +++ b/frontends/dnet-is-application/src/app/resources/resources.component.ts @@ -3,7 +3,7 @@ import { ISService } from '../common/is.service'; import { ActivatedRoute } from '@angular/router'; import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { ResourceType, SimpleResource } from '../common/is.model'; -import { FormControl, FormGroup } from '@angular/forms'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; @Component({ selector: 'app-resources', @@ -115,12 +115,16 @@ export class ResContentDialog { }) export class ResMetadataDialog { metadataForm = new FormGroup({ - name: new FormControl(''), + name: new FormControl('', [Validators.required]), + subtype: new FormControl(''), description: new FormControl('') }); constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, public service: ISService) { this.metadataForm.get('name')?.setValue(data.name); + if (data.subtype) { + this.metadataForm.get('subtype')?.setValue(data.subtype); + } if (data.description) { this.metadataForm.get('description')?.setValue(data.description); } @@ -143,9 +147,10 @@ export class ResMetadataDialog { }) export class ResCreateNewDialog { newResourceForm = new FormGroup({ - name: new FormControl(''), + name: new FormControl('', [Validators.required]), + subtype: new FormControl(''), description: new FormControl(''), - content: new FormControl('') + content: new FormControl('', [Validators.required]) }); constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, public service: ISService) { } @@ -153,10 +158,11 @@ export class ResCreateNewDialog { onSubmit(): void { let name: string = this.newResourceForm.get('name')?.value!; let type: string = this.data.id!; + let subtype: string = this.newResourceForm.get('subtype')?.value!; let description: string = this.newResourceForm.get('description')?.value!; let content: string = this.newResourceForm.get('content')?.value!; - this.service.addSimpleResource(name, type, description, content, (data: void) => this.dialogRef.close(1), this.newResourceForm); + this.service.addSimpleResource(name, type, subtype, description, content, (data: void) => this.dialogRef.close(1), this.newResourceForm); } onNoClick(): void { this.dialogRef.close(); diff --git a/libs/dnet-is-common/src/main/java/eu/dnetlib/is/model/resource/SimpleResource.java b/libs/dnet-is-common/src/main/java/eu/dnetlib/is/model/resource/SimpleResource.java index b585512f..6a73a64e 100644 --- a/libs/dnet-is-common/src/main/java/eu/dnetlib/is/model/resource/SimpleResource.java +++ b/libs/dnet-is-common/src/main/java/eu/dnetlib/is/model/resource/SimpleResource.java @@ -24,6 +24,9 @@ public class SimpleResource implements Serializable { @Column(name = "type") private String type; + @Column(name = "subtype") + private String subtype; + @Column(name = "description") private String description; @@ -57,6 +60,14 @@ public class SimpleResource implements Serializable { this.type = type; } + public String getSubtype() { + return subtype; + } + + public void setSubtype(final String subtype) { + this.subtype = subtype; + } + public String getDescription() { return description; } diff --git a/libs/dnet-is-common/src/main/resources/sql/schema.sql b/libs/dnet-is-common/src/main/resources/sql/schema.sql index bf24c389..58989441 100644 --- a/libs/dnet-is-common/src/main/resources/sql/schema.sql +++ b/libs/dnet-is-common/src/main/resources/sql/schema.sql @@ -139,6 +139,7 @@ CREATE TABLE resources ( description text, content text NOT NULL DEFAULT '', type text NOT NULL REFERENCES resource_types(id), + subtype text, creation_date timestamp NOT NULL DEFAULT now(), modification_date timestamp NOT NULL DEFAULT now() ); diff --git a/libs/dnet-is-services/src/main/java/eu/dnetlib/is/resource/SimpleResourceService.java b/libs/dnet-is-services/src/main/java/eu/dnetlib/is/resource/SimpleResourceService.java index 42fbb7cb..993c9fed 100644 --- a/libs/dnet-is-services/src/main/java/eu/dnetlib/is/resource/SimpleResourceService.java +++ b/libs/dnet-is-services/src/main/java/eu/dnetlib/is/resource/SimpleResourceService.java @@ -60,6 +60,7 @@ public class SimpleResourceService { @Transactional public SimpleResource saveNewResource(final String name, final String type, + final String subtype, final String description, final String content) throws InformationServiceException { @@ -71,6 +72,7 @@ public class SimpleResourceService { res.setId(UUID.randomUUID().toString()); res.setName(name); res.setType(type); + res.setSubtype(subtype); res.setDescription(description); res.setCreationDate(now); res.setModificationDate(now);