From 9edbfc0926c14edc06c271bb368c2a8b9e39c8bd Mon Sep 17 00:00:00 2001 From: Lukas Rosenthaler Date: Thu, 25 Nov 2021 22:00:02 +0100 Subject: [PATCH 1/2] Bugfixes --- src/app/edit/edit-book/edit-book.component.ts | 40 ++++--- .../edit-company/edit-company.component.ts | 15 ++- .../edit/edit-lexia/edit-lexia.component.ts | 12 +- .../edit-passage/edit-passage.component.ts | 42 ++++--- .../edit/edit-person/edit-person.component.ts | 107 +++++++++++++++--- .../edit/edit-venue/edit-venue.component.ts | 15 ++- src/app/edit/edit.component.ts | 4 +- src/app/services/knora.service.ts | 44 +++++++ 8 files changed, 218 insertions(+), 61 deletions(-) diff --git a/src/app/edit/edit-book/edit-book.component.ts b/src/app/edit/edit-book/edit-book.component.ts index 6c1c5161..74367891 100644 --- a/src/app/edit/edit-book/edit-book.component.ts +++ b/src/app/edit/edit-book/edit-book.component.ts @@ -202,7 +202,8 @@ class BookIds { Written by → (person) *
- Is Lexia → (lexia)
- Performed by (company)
- Performed by actor (person)
- Performed in (venue)
- = 3) { + if (performedInName.length >= 3) { this.knoraService.getResourcesByLabel(performedInName, this.knoraService.wwOntology + 'venue').subscribe( res => { this.options = res; @@ -1420,18 +1422,23 @@ export class EditBookComponent implements OnInit { this.working = true; console.log('this.value:', this.value); if (this.inData.bookIri === undefined) { - if (this.form.valid) { + if (this.form.valid + && this.value.genres[0].genreIri + && this.value.writtenBy[0].writtenByIri + && !this.value.creationDate.isEmpty()) { this.knoraService.createBook(this.value).subscribe( res => { console.log('CREATE_RESULT:', res); this.working = false; - this.location.back(); + if (res === 'error') { + this.snackBar.open('Error storing the book object!', 'OK', {duration: 10000}); + } else { + this.location.back(); + } }, error => { - this.snackBar.open('Error storing the passage object!', 'OK'); console.log('EditCompany.save(): ERROR', error); this.working = false; - this.location.back(); } ); } else { @@ -1520,9 +1527,7 @@ export class EditBookComponent implements OnInit { this.knoraService.wwOntology + 'hasCreationDate', creationDateValue); } else { - console.log('**********> UPDATE KNORA started...'); const creationDateValue = this.form.controls.creationDate.value; - console.log('**********> UPDATE KNORA TO DATE:', creationDateValue); gaga = this.knoraService.updateDateValue( this.resId, this.knoraService.wwOntology + 'book', @@ -1962,7 +1967,7 @@ export class EditBookComponent implements OnInit { this.location.back(); }, error => { - this.snackBar.open('Fehler beim Speichern der Daten des book-Eintrags!', 'OK'); + this.snackBar.open('Fehler beim Speichern der Daten des book-Eintrags!', 'OK', {duration: 10000}); this.working = false; this.location.back(); }); @@ -1986,10 +1991,13 @@ export class EditBookComponent implements OnInit { this.knoraService.deleteResource(this.resId, 'book', this.lastmod, data.comment).subscribe( res => { this.working = false; + if (res === 'error') { + this.snackBar.open('Error while deleting the book entry!', 'OK', {duration: 10000}); + } this.location.back(); }, error => { - this.snackBar.open('Error while deleting the book entry!', 'OK'); + this.snackBar.open('Error while deleting the book entry!', 'OK', {duration: 10000}); console.log('deleteResource:ERROR:: ', error); this.working = false; this.location.back(); diff --git a/src/app/edit/edit-company/edit-company.component.ts b/src/app/edit/edit-company/edit-company.component.ts index 50221abd..d4b6af68 100644 --- a/src/app/edit/edit-company/edit-company.component.ts +++ b/src/app/edit/edit-company/edit-company.component.ts @@ -546,10 +546,14 @@ export class EditCompanyComponent implements OnInit { res => { console.log('CREATE_RESULT:', res); this.working = false; - this.location.back(); + if (res === 'error') { + this.snackBar.open('Error storing the company object!', 'OK', {duration: 10000}); + } else { + this.location.back(); + } }, error => { - this.snackBar.open('Error storing the company object!', 'OK'); + this.snackBar.open('Error storing the company object!', 'OK', {duration: 10000}); console.log('EditCompany.save(): ERROR', error); this.working = false; this.location.back(); @@ -717,7 +721,7 @@ export class EditCompanyComponent implements OnInit { this.location.back(); }, error => { - this.snackBar.open('Fehler beim Speichern der Daten des company-Eintrags!', 'OK'); + this.snackBar.open('Fehler beim Speichern der Daten des company-Eintrags!', 'OK', {duration: 10000}); this.working = false; this.location.back(); }); @@ -742,10 +746,13 @@ export class EditCompanyComponent implements OnInit { this.knoraService.deleteResource(this.resId, 'company', this.lastmod, data.comment).subscribe( res => { this.working = false; + if (res === 'error') { + this.snackBar.open('Error while deleting the company entry!', 'OK', {duration: 10000}); + } this.location.back(); }, error => { - this.snackBar.open('Error while deleting the company entry!', 'OK'); + this.snackBar.open('Error while deleting the company entry!', 'OK', {duration: 10000}); console.log('deleteResource:ERROR:: ', error); this.working = false; this.location.back(); diff --git a/src/app/edit/edit-lexia/edit-lexia.component.ts b/src/app/edit/edit-lexia/edit-lexia.component.ts index ea70d40b..4dfe730f 100644 --- a/src/app/edit/edit-lexia/edit-lexia.component.ts +++ b/src/app/edit/edit-lexia/edit-lexia.component.ts @@ -15,7 +15,7 @@ import {MatSnackBar} from '@angular/material/snack-bar'; import {Location} from '@angular/common'; import {MatDialog, MatDialogConfig} from '@angular/material/dialog'; import {ConfirmationComponent, ConfirmationResult} from '../confirmation/confirmation.component'; -import {toArray} from "rxjs/operators"; +import {toArray} from 'rxjs/operators'; interface ValInfo { @@ -376,7 +376,7 @@ export class EditLexiaComponent implements OnInit { if (formalClassIri === undefined) { formalClasses.push(this.fb.group({formalClassIri: this.formalClassTypes[0].iri})); this.data.formalClassIris.push(this.formalClassTypes[0].iri); - this.valIds.formalClasses.push({id: undefined, changed: false, toBeDeleted: false}); + this.valIds.formalClasses.push({id: undefined, changed: true, toBeDeleted: false}); } else { formalClasses.push(this.fb.group({formalClassIri})); this.data.formalClassIris.push(formalClassIri); @@ -526,12 +526,16 @@ export class EditLexiaComponent implements OnInit { save(): void { this.working = true; if (this.inData.lexiaIri === undefined) { - if (this.form.valid) { + if (this.form.valid && this.value.formalClassIris[0]) { this.knoraService.createLexia(this.value).subscribe( res => { console.log('CREATE_RESULT:', res); this.working = false; - this.location.back(); + if (res === 'error') { + this.snackBar.open('Error storing the lexia object!', 'OK'); + } else { + this.location.back(); + } }, error => { this.snackBar.open('Error storing the lexia object!', 'OK'); diff --git a/src/app/edit/edit-passage/edit-passage.component.ts b/src/app/edit/edit-passage/edit-passage.component.ts index 3f3423d8..436304dd 100644 --- a/src/app/edit/edit-passage/edit-passage.component.ts +++ b/src/app/edit/edit-passage/edit-passage.component.ts @@ -130,7 +130,7 @@ class PassageIds { Function voices *
- @@ -165,7 +165,7 @@ class PassageIds { Markings *
- @@ -597,6 +597,7 @@ export class EditPassageComponent implements OnInit { [{containsName: '', containsIri: ''}], '', '', '', '', '', '', '', [{mentionedInName: '', mentionedInIri: ''}]); + this.form.setValue({label, internalId, displayedTitle, functionVoices, markings, researchField, status, text, occursInName: occursIn.occursInName, occursInIri: occursIn.occursInIri, contributedByName: contributedBy.contributedByName, contributedByIri: contributedBy.contributedByIri, @@ -800,7 +801,7 @@ export class EditPassageComponent implements OnInit { if (functionVoice === undefined) { functionVoices.push(this.fb.group({functionVoiceIri: this.functionVoiceTypes[0].iri})); this.data.functionVoices.push({functionVoiceIri: this.functionVoiceTypes[0].iri}); - this.valIds.functionVoices.push({id: undefined, changed: false, toBeDeleted: false}); + this.valIds.functionVoices.push({id: undefined, changed: true, toBeDeleted: false}); } else { functionVoices.push(this.fb.group({functionVoiceIri: functionVoice.iri})); this.data.functionVoices.push({functionVoiceIri: functionVoice.iri}); @@ -826,7 +827,7 @@ export class EditPassageComponent implements OnInit { if (marking === undefined) { markings.push(this.fb.group({markingIri: this.markingTypes[0].iri})); this.data.markings.push({markingIri: this.markingTypes[0].iri}); - this.valIds.markings.push({id: undefined, changed: false, toBeDeleted: false}); + this.valIds.markings.push({id: undefined, changed: true, toBeDeleted: false}); } else { markings.push(this.fb.group({markingIri: marking.iri})); this.data.markings.push({markingIri: marking.iri}); @@ -949,9 +950,10 @@ export class EditPassageComponent implements OnInit { case 'mentionedIn': const mentionedIn = this.getMentionedIn(); const mentionedInName = mentionedIn.value[index].mentionedInName; + console.log('mentionedIn', mentionedInName); this.valIds.mentionedIn[index].changed = true; - if (mentionedIn.length >= 3) { + if (mentionedInName.length >= 3) { this.knoraService.getResourcesByLabel(mentionedInName, this.knoraService.wwOntology + 'passage').subscribe( res => { this.options = res; @@ -971,19 +973,21 @@ export class EditPassageComponent implements OnInit { } switch(what) { case 'occursIn': + this.form.controls.occursInIri.setValue(res[0].id); // must be for unknown reasons this.form.value.occursInName = res[0].label; this.form.value.occursInIri = res[0].id; this.value.occursIn = { - occursInName: this.form.value.occursInName, - occursInIri: this.form.value.occursInIri + occursInName: res[0].label, + occursInIri: res[0].id }; break; case 'contributedBy': + this.form.controls.contributedByIri.setValue(res[0].id); // must be for unknown reasons this.form.value.contributedByName = res[0].label; this.form.value.contributedByIri = res[0].id; this.value.contributedBy = { - contributedByName: this.form.value.contributedByName, - contributedByIri: this.form.value.contributedByIri + contributedByName: res[0].label, + contributedByIri: res[0].id }; break; case 'contains': @@ -1001,6 +1005,7 @@ export class EditPassageComponent implements OnInit { } _handleInput(what: string, index?: number): void { + console.log('_handleInput'); this.onChange(this.form.value); switch (what) { case 'label': @@ -1224,22 +1229,28 @@ export class EditPassageComponent implements OnInit { save(): void { this.working = true; + console.log('this.value:', this.value); if (this.inData.passageIri === undefined) { - if (this.form.valid) { + if (this.form.valid && this.value.occursIn.occursInIri && this.value.contributedBy.contributedByIri) { this.knoraService.createPassage(this.value).subscribe( res => { console.log('CREATE_RESULT:', res); this.working = false; - this.location.back(); + if (res === 'error') { + this.snackBar.open('Error storing the passage object!', 'OK', {duration: 10000}); + } else { + this.location.back(); + } }, error => { - this.snackBar.open('Error storing the passage object!', 'OK'); + this.snackBar.open('Error storing the passage object!', 'OK', {duration: 10000}); console.log('EditCompany.save(): ERROR', error); this.working = false; this.location.back(); } ); } else { + console.log('Incomplete:', this.value); this.snackBar.open('Invalid/incomplete data in form – Please check!', 'OK', {duration: 10000}); @@ -1746,7 +1757,7 @@ export class EditPassageComponent implements OnInit { this.location.back(); }, error => { - this.snackBar.open('Fehler beim Speichern der Daten des company-Eintrags!', 'OK'); + this.snackBar.open('Fehler beim Speichern der Daten des company-Eintrags!', 'OK', {duration: 10000}); this.working = false; this.location.back(); }); @@ -1772,10 +1783,13 @@ export class EditPassageComponent implements OnInit { this.knoraService.deleteResource(this.resId, 'passage', this.lastmod, data.comment).subscribe( res => { this.working = false; + if (res === 'error') { + this.snackBar.open('Error while deleting the passage entry!', 'OK', {duration: 10000}); + } this.location.back(); }, error => { - this.snackBar.open('Error while deleting the passage entry!', 'OK'); + this.snackBar.open('Error while deleting the passage entry!', 'OK', {duration: 10000}); console.log('deleteResource:ERROR:: ', error); this.working = false; this.location.back(); diff --git a/src/app/edit/edit-person/edit-person.component.ts b/src/app/edit/edit-person/edit-person.component.ts index 7e508fa0..3d6dffbe 100644 --- a/src/app/edit/edit-person/edit-person.component.ts +++ b/src/app/edit/edit-person/edit-person.component.ts @@ -26,6 +26,7 @@ class PersonIds { public description: ValInfo; public birthDate: ValInfo; public deathDate: ValInfo; + public activeDate: ValInfo; public extraInfo: ValInfo; public lexias: ValInfo[]; @@ -38,6 +39,7 @@ class PersonIds { this.description = {id: undefined, changed: false, toBeDeleted: false}; this.birthDate = {id: undefined, changed: false, toBeDeleted: false}; this.deathDate = {id: undefined, changed: false, toBeDeleted: false}; + this.activeDate = {id: undefined, changed: false, toBeDeleted: false}; this.extraInfo = {id: undefined, changed: false, toBeDeleted: false}; this.lexias = []; } @@ -136,7 +138,7 @@ class PersonIds {
  - Birthdate + Birth date @@ -151,7 +153,7 @@ class PersonIds {
- Deathdate + Death date @@ -165,6 +167,21 @@ class PersonIds {
+ + Active date + +   + + +
+
- + @@ -245,7 +262,7 @@ export class EditPersonComponent implements OnInit { resId: string; lastmod: string; data: PersonData = new PersonData('', '', '', '', '', - '', new DateValue(), new DateValue(), '', []); + '', new DateValue(), new DateValue(), new DateValue(), '', []); nLexias: number; working: boolean; public valIds: PersonIds = new PersonIds(); @@ -283,6 +300,7 @@ export class EditPersonComponent implements OnInit { this.form.controls.description.value, this.form.controls.birthDate.value, this.form.controls.deathDate.value, + this.form.controls.activeDate.value, this.form.controls.extraInfo.value, lexiaValues, ); @@ -290,12 +308,12 @@ export class EditPersonComponent implements OnInit { set value(knoraVal: PersonData | null) { const { - label, internalId, firstName, lastName, genderIri, description, birthDate, deathDate, extraInfo, lexias + label, internalId, firstName, lastName, genderIri, description, birthDate, deathDate, activeDate, extraInfo, lexias } = knoraVal || new PersonData('', '', '', '', '', - '', new DateValue(), new DateValue(), '', [{lexiaName: '', lexiaIri: ''}]); + '', new DateValue(), new DateValue(), new DateValue(), '', [{lexiaName: '', lexiaIri: ''}]); this.form.setValue({ - label, internalId, firstName, lastName, genderIri, description, birthDate, deathDate, extraInfo, lexias + label, internalId, firstName, lastName, genderIri, description, birthDate, deathDate, activeDate, extraInfo, lexias }); } @@ -362,6 +380,13 @@ export class EditPersonComponent implements OnInit { this.data.deathDate = dateValue; break; } + case this.knoraService.wwOntology + 'hasActiveDate': { + const dateValue = DateValue.parseDateValueFromKnora(ele.values[0]); + this.form.controls.activeDate.setValue(dateValue); + this.valIds.activeDate = {id: ele.ids[0], changed: false, toBeDeleted: false}; + this.data.activeDate = dateValue; + break; + } case this.knoraService.wwOntology + 'hasPersonExtraInfo': { this.form.controls.extraInfo.setValue(ele.values[0]); this.valIds.extraInfo = {id: ele.ids[0], changed: false, toBeDeleted: false}; @@ -385,10 +410,11 @@ export class EditPersonComponent implements OnInit { label: [this.data.label, [Validators.required, Validators.minLength(5)]], firstName: [this.data.firstName, []], lastName: [this.data.lastName, [Validators.required]], - genderIri: [this.data.genderIri, [Validators.required]], + genderIri: [this.data.genderIri || this.genderTypes[0].iri, [Validators.required]], description: [this.data.description, [Validators.required]], birthDate: [this.data.birthDate, []], deathDate: [this.data.deathDate, []], + activeDate: [this.data.activeDate, []], internalId: [this.data.internalId, [Validators.required]], extraInfo: this.data.extraInfo, lexias: this.fb.array([ @@ -489,6 +515,9 @@ export class EditPersonComponent implements OnInit { case 'deathDate': this.valIds.deathDate.changed = true; break; + case 'activeDate': + this.valIds.activeDate.changed = true; + break; case 'extraInfo': this.valIds.extraInfo.changed = true; break; @@ -512,6 +541,10 @@ export class EditPersonComponent implements OnInit { this.valIds.deathDate.toBeDeleted = !this.valIds.deathDate.toBeDeleted; console.log('_handleDelete("deathDate")'); break; + case 'activeDate': + this.valIds.activeDate.toBeDeleted = !this.valIds.activeDate.toBeDeleted; + console.log('_handleDelete("activeDate")'); + break; case 'extraInfo': this.valIds.extraInfo.toBeDeleted = !this.valIds.extraInfo.toBeDeleted; console.log('_handleDelete("extraInfo")'); @@ -529,7 +562,6 @@ export class EditPersonComponent implements OnInit { } break; } - } _handleUndo(what: string, index?: number): void { @@ -568,6 +600,11 @@ export class EditPersonComponent implements OnInit { //this.form.controls.deathDateEnd.setValue(this.data.deathDateEnd); this.valIds.deathDate.changed = false; break; + case 'activeDate': + this.form.controls.activeDate.setValue(this.data.activeDate); + //this.form.controls.activeDateEnd.setValue(this.data.activeDateEnd); + this.valIds.activeDate.changed = false; + break; case 'extraInfo': this.form.controls.extraInfo.setValue(this.data.extraInfo); this.valIds.extraInfo.changed = false; @@ -582,15 +619,21 @@ export class EditPersonComponent implements OnInit { save(): void { this.working = true; if (this.inData.personIri === undefined) { - if (this.form.valid) { + const ok1 = this.value.activeDate.isEmpty() && (!this.value.birthDate.isEmpty() || !this.value.deathDate.isEmpty()); + const ok2 = !this.value.activeDate.isEmpty() && (this.value.birthDate.isEmpty() && this.value.deathDate.isEmpty()); + if (this.form.valid && (ok1 || ok2)) { this.knoraService.createPerson(this.value).subscribe( res => { console.log('CREATE_RESULT:', res); this.working = false; - this.location.back(); + if (res === 'error') { + this.snackBar.open('Error storing the person object!', 'OK', {duration: 10000}); + } else { + this.location.back(); + } }, error => { - this.snackBar.open('Error storing the person object!', 'OK'); + this.snackBar.open('Error storing the person object!', 'OK', {duration: 10000}); console.log('EditPerson.save(): ERROR', error); this.working = false; this.location.back(); @@ -803,7 +846,35 @@ export class EditPersonComponent implements OnInit { obs.push(gaga); } - console.log('this.valIds.extraInfo:', this.valIds.extraInfo); + if (this.valIds.activeDate.toBeDeleted && this.valIds.activeDate.id !== undefined) { + const gaga: Observable = this.knoraService.deleteDateValue( + this.resId, + this.knoraService.wwOntology + 'person', + this.valIds.activeDate.id as string, + this.knoraService.wwOntology + 'hasActiveDate'); + obs.push(gaga); + } else if (this.valIds.activeDate.changed) { + let gaga: Observable; + if (this.valIds.activeDate.id === undefined) { + const activeDateValue = this.form.controls.activeDate.value; + gaga = this.knoraService.createDateValue( + this.resId, + this.knoraService.wwOntology + 'person', + this.knoraService.wwOntology + 'hasActiveDate', + activeDateValue); + } else { + const activeDate = this.form.value.activeDate; + const activeDateValue = this.form.controls.activeDate.value; + gaga = this.knoraService.updateDateValue( + this.resId, + this.knoraService.wwOntology + 'person', + this.valIds.deathDate.id as string, + this.knoraService.wwOntology + 'hasActiveDate', + activeDateValue); + } + obs.push(gaga); + } + if (this.valIds.extraInfo.toBeDeleted && this.valIds.extraInfo.id !== undefined) { const gaga: Observable = this.knoraService.deleteTextValue( this.resId, @@ -865,7 +936,7 @@ export class EditPersonComponent implements OnInit { this.location.back(); }, error => { - this.snackBar.open('Fehler beim Speichern der Daten des person-Eintrags!', 'OK'); + this.snackBar.open('Fehler beim Speichern der Daten des person-Eintrags!', 'OK', {duration: 10000}); this.working = false; this.location.back(); }); @@ -879,7 +950,7 @@ export class EditPersonComponent implements OnInit { confirmationConfig.disableClose = true; confirmationConfig.data = { title: 'Delete company', - text: 'Do You really want to delete this comapany?' + text: 'Do You really want to delete this person?' }; const dialogRef = this.dialog.open(ConfirmationComponent, confirmationConfig); @@ -890,16 +961,18 @@ export class EditPersonComponent implements OnInit { this.knoraService.deleteResource(this.resId, 'person', this.lastmod, data.comment).subscribe( res => { this.working = false; + if (res === 'error') { + this.snackBar.open('Error while deleting the person entry!', 'OK', {duration: 10000}); + } this.location.back(); }, error => { - this.snackBar.open('Error while deleting the company entry!', 'OK'); + this.snackBar.open('Error while deleting the person entry!', 'OK', {duration: 10000}); console.log('deleteResource:ERROR:: ', error); this.working = false; this.location.back(); }); } }); - } } diff --git a/src/app/edit/edit-venue/edit-venue.component.ts b/src/app/edit/edit-venue/edit-venue.component.ts index 92e75e82..527aa1f8 100644 --- a/src/app/edit/edit-venue/edit-venue.component.ts +++ b/src/app/edit/edit-venue/edit-venue.component.ts @@ -430,10 +430,14 @@ export class EditVenueComponent implements OnInit { res => { console.log('CREATE_RESULT:', res); this.working = false; - this.location.back(); + if (res === 'error') { + this.snackBar.open('Error storing the venue object!', 'OK', {duration: 10000}); + } else { + this.location.back(); + } }, error => { - this.snackBar.open('Error storing the venue object!', 'OK'); + this.snackBar.open('Error storing the venue object!', 'OK', {duration: 10000}); console.log('EditVenue.save(): ERROR', error); this.working = false; this.location.back(); @@ -571,7 +575,7 @@ export class EditVenueComponent implements OnInit { this.location.back(); }, error => { - this.snackBar.open('Fehler beim Speichern der Daten des venue-Eintrags!', 'OK'); + this.snackBar.open('Fehler beim Speichern der Daten des venue-Eintrags!', 'OK', {duration: 10000}); this.working = false; this.location.back(); }); @@ -595,10 +599,13 @@ export class EditVenueComponent implements OnInit { this.knoraService.deleteResource(this.resId, 'venue', this.lastmod, data.comment).subscribe( res => { this.working = false; + if (res === 'error') { + this.snackBar.open('Error while deleting the venue entry!', 'OK', {duration: 10000}); + } this.location.back(); }, error => { - this.snackBar.open('Error while deleting the venue entry!', 'OK'); + this.snackBar.open('Error while deleting the venue entry!', 'OK', {duration: 10000}); console.log('deleteResource:ERROR:: ', error); this.working = false; this.location.back(); diff --git a/src/app/edit/edit.component.ts b/src/app/edit/edit.component.ts index eb360fa3..b8787556 100644 --- a/src/app/edit/edit.component.ts +++ b/src/app/edit/edit.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import {KnoraService} from "../services/knora.service"; +import {KnoraService} from '../services/knora.service'; import { ControlValueAccessor, FormArray, @@ -9,7 +9,7 @@ import { NgControl, Validators } from '@angular/forms'; -import {Router} from "@angular/router"; +import {Router} from '@angular/router'; @Component({ selector: 'app-edit', diff --git a/src/app/services/knora.service.ts b/src/app/services/knora.service.ts index 29c14863..0db3f031 100644 --- a/src/app/services/knora.service.ts +++ b/src/app/services/knora.service.ts @@ -79,6 +79,7 @@ export class PersonData { public description: string, // hasDescription (1) public birthDate?: DateValue, // hasBirthDate (0-1) public deathDate?: DateValue, // hasDeathDate (0-1) + public activeDate?: DateValue, // hasActiveDate (0-1) public extraInfo?: string, // hasPersonExtraInfo (0-1) public lexias?: {lexiaName: string; lexiaIri: string}[], // isLexiaPersonValue (0-n) ) {} @@ -1092,6 +1093,49 @@ export class KnoraService { ]; } + const activeVal = new DateValue( + data.activeDate.calendar, + data.activeDate.timeSpan, + data.activeDate.startYear, + data.activeDate.startMonth, + data.activeDate.startDay, + data.activeDate.endYear, + data.activeDate.endMonth, + data.activeDate.endDay); + if (!activeVal.isEmpty()) { + const activeDateVal = new CreateDateValue(); + activeDateVal.calendar = activeVal.calendar; + if (activeVal.startYear < 0) { + activeDateVal.startEra = 'BCE'; + if (activeVal.calendar === DateCalendar.JULIAN) { + activeDateVal.startYear = -activeVal.startYear; // Todo: depending on handling of year 0 in Knora +/- 1 + } else { + activeDateVal.startYear = -activeVal.startYear; // Todo: depending on handling of year 0 in Knora +/- 1 + } + } else { + activeDateVal.startEra = 'CE'; + activeDateVal.startYear = activeVal.startYear; + } + activeDateVal.startMonth = activeVal.startMonth; + activeDateVal.startDay = activeVal.startDay; + if (activeVal.endYear < 0) { + activeDateVal.endEra = 'BCE'; + if (activeVal.calendar === DateCalendar.JULIAN) { + activeDateVal.endYear = -activeVal.endYear; // Todo: depending on handling of year 0 in Knora +/- 1 + } else { + activeDateVal.endYear = -activeVal.endYear; // Todo: depending on handling of year 0 in Knora +/- 1 + } + } else { + activeDateVal.endEra = 'CE'; + activeDateVal.endYear = activeVal.endYear; + } + activeDateVal.endMonth = activeVal.endMonth; + activeDateVal.endDay = activeVal.endDay; + props[this.wwOntology + 'hasActiveDate'] = [ + activeDateVal + ]; + } + if (data.extraInfo !== null && data.extraInfo !== undefined && data.extraInfo !== '') { const extraInfoIdVal = new CreateTextValueAsString(); extraInfoIdVal.text = data.extraInfo; From 63dbb0c26f37d200d1fe675768ccd4b618817141 Mon Sep 17 00:00:00 2001 From: Lukas Rosenthaler Date: Thu, 25 Nov 2021 22:15:24 +0100 Subject: [PATCH 2/2] Version push --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b3c8718c..a44a83c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "0826-wordweb-app", - "version": "2.10.16", + "version": "2.10.17", "scripts": { "ng": "ng", "start": "ng serve",