no message

This commit is contained in:
Diamantis Tziotzios 2024-03-27 10:42:00 +02:00
parent 1408cc0a59
commit d884f577f4
8 changed files with 79 additions and 14 deletions

View File

@ -74,7 +74,7 @@ public class DmpReferencePersist {
.iff(() -> !this.isNull(item.getReference())) .iff(() -> !this.isNull(item.getReference()))
.on(DmpReferencePersist._reference) .on(DmpReferencePersist._reference)
.over(item.getReference()) .over(item.getReference())
.using(() -> this.validatorFactory.validator(ReferencePersist.ReferencePersistValidator.class)), .using(() -> this.validatorFactory.validator(ReferencePersist.ReferenceWithoutTypePersistValidator.class)),
this.spec() this.spec()
.must(() -> !this.isNull(item.getData())) .must(() -> !this.isNull(item.getData()))
.failOn(DmpReferencePersist._data).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpReferencePersist._data}, LocaleContextHolder.getLocale())), .failOn(DmpReferencePersist._data).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpReferencePersist._data}, LocaleContextHolder.getLocale())),

View File

@ -208,4 +208,73 @@ public class ReferencePersist {
} }
} }
@Component(ReferencePersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ReferenceWithoutTypePersistValidator extends BaseValidator<ReferencePersist> {
public static final String ValidatorName = "ReferencePersistValidator";
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
protected ReferenceWithoutTypePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@Override
protected Class<ReferencePersist> modelClass() {
return ReferencePersist.class;
}
@Override
protected List<Specification> specifications(ReferencePersist item) {
return Arrays.asList(
this.spec()
.iff(() -> this.isValidGuid(item.getId()))
.must(() -> this.isValidHash(item.getHash()))
.failOn(ReferencePersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._hash}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isValidGuid(item.getId()))
.must(() -> !this.isValidHash(item.getHash()))
.failOn(ReferencePersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getLabel()))
.failOn(ReferencePersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getLabel()))
.must(() -> this.lessEqualLength(item.getLabel(), ReferenceEntity._labelLength))
.failOn(ReferencePersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{ReferencePersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getReference()))
.failOn(ReferencePersist._reference).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._reference}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getReference()))
.must(() -> this.lessEqualLength(item.getReference(), ReferenceEntity._referenceLength))
.failOn(ReferencePersist._reference).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{ReferencePersist._reference}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getAbbreviation()))
.must(() -> this.lessEqualLength(item.getAbbreviation(), ReferenceEntity._abbreviationLength))
.failOn(ReferencePersist._abbreviation).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{ReferencePersist._abbreviation}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getSource()))
.failOn(ReferencePersist._source).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._source}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getSource()))
.must(() -> this.lessEqualLength(item.getSource(), ReferenceEntity._sourceLength))
.failOn(ReferencePersist._source).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{ReferencePersist._source}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getSourceType()))
.failOn(ReferencePersist._sourceType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._sourceType}, LocaleContextHolder.getLocale())),
this.refSpec()
.iff(() -> !this.isNull(item.getDefinition()))
.on(ReferencePersist._definition)
.over(item.getDefinition())
.using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class))
);
}
}
} }

View File

@ -148,12 +148,12 @@ public class FieldPersist {
.iff(() -> FieldType.isReferenceType(fieldType) && !this.isListNullOrEmpty(item.getReferences())) .iff(() -> FieldType.isReferenceType(fieldType) && !this.isListNullOrEmpty(item.getReferences()))
.on(FieldPersist._references) .on(FieldPersist._references)
.over(item.getReferences()) .over(item.getReferences())
.using((itm) -> this.validatorFactory.validator(ReferencePersist.ReferencePersistValidator.class)), .using((itm) -> this.validatorFactory.validator(ReferencePersist.ReferenceWithoutTypePersistValidator.class)),
this.refSpec() this.refSpec()
.iff(() -> FieldType.isReferenceType(fieldType) && !this.isNull(item.getReference())) .iff(() -> FieldType.isReferenceType(fieldType) && !this.isNull(item.getReference()))
.on(FieldPersist._reference) .on(FieldPersist._reference)
.over(item.getReference()) .over(item.getReference())
.using(() -> this.validatorFactory.validator(ReferencePersist.ReferencePersistValidator.class)), .using(() -> this.validatorFactory.validator(ReferencePersist.ReferenceWithoutTypePersistValidator.class)),
this.refSpec() this.refSpec()
.iff(() -> FieldType.isExternalIdentifierType(fieldType) && !this.isNull(item.getExternalIdentifier())) .iff(() -> FieldType.isExternalIdentifierType(fieldType) && !this.isNull(item.getExternalIdentifier()))
.on(FieldPersist._externalIdentifier) .on(FieldPersist._externalIdentifier)

View File

@ -34,6 +34,6 @@ public class DepositClientImpl implements DepositClient {
@Override @Override
public String getLogo() { public String getLogo() {
return depositClient.get().uri("/logo/").header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).accept(MediaType.APPLICATION_JSON).exchangeToMono(mono -> mono.bodyToMono(String.class)).block(); return depositClient.get().uri("/logo/").exchangeToMono(mono -> mono.bodyToMono(String.class)).block();
} }
} }

View File

@ -1,7 +1,7 @@
deposit: deposit:
sources: sources:
- url: http://dev04.local.cite.gr:55330/zenodo - url: http://dev04.local.cite.gr:55330/zenodo
repositoryId: zenodo repositoryId: Zenodo
pdfTransformerId: docx-file-transformer pdfTransformerId: docx-file-transformer
rdaTransformerId: rda-file-transformer rdaTransformerId: rda-file-transformer
issuer-url: ${IDP_ISSUER_URI_TOKEN} issuer-url: ${IDP_ISSUER_URI_TOKEN}

View File

@ -445,7 +445,6 @@ export class DescriptionFieldEditorModel implements DescriptionFieldPersist {
abbreviation: descriptionReference.reference.abbreviation, abbreviation: descriptionReference.reference.abbreviation,
sourceType: descriptionReference.reference.sourceType sourceType: descriptionReference.reference.sourceType
}) })
} }
}) })
} }

View File

@ -23,14 +23,11 @@ import { takeUntil } from 'rxjs/operators';
styleUrls: ['./dmp-deposit-dropdown.component.scss'] styleUrls: ['./dmp-deposit-dropdown.component.scss']
}) })
export class DmpDepositDropdown extends BaseComponent implements OnInit { export class DmpDepositDropdown extends BaseComponent implements OnInit {
@Input() @Input() inputRepos: DepositConfiguration[];
inputRepos: DepositConfiguration[]; @Input() dmp: Dmp;
@Input()
dmp: Dmp;
outputRepos = []; outputRepos = [];
logos: Map<string, SafeResourceUrl> = new Map<string, SafeResourceUrl>(); logos: Map<string, SafeResourceUrl> = new Map<string, SafeResourceUrl>();
@Output() @Output() outputReposEmitter: EventEmitter<EntityDoi[]> = new EventEmitter<EntityDoi[]>();
outputReposEmitter: EventEmitter<EntityDoi[]> = new EventEmitter<EntityDoi[]>();
private oauthLock: boolean; private oauthLock: boolean;
constructor( constructor(
@ -50,7 +47,7 @@ export class DmpDepositDropdown extends BaseComponent implements OnInit {
} }
ngOnInit(): void { ngOnInit(): void {
for (var i = 0; i < this.dmp.entityDois.length; i++) { for (var i = 0; i < this.dmp?.entityDois?.length; i++) {
this.inputRepos = this.inputRepos.filter(r => this.hasDoi(r, this.dmp.entityDois, i)); this.inputRepos = this.inputRepos.filter(r => this.hasDoi(r, this.dmp.entityDois, i));
} }
this.inputRepos.forEach(repo => { this.inputRepos.forEach(repo => {

View File

@ -501,7 +501,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
} }
get inputRepos() { get inputRepos() {
return this.depositRepos.filter(repo => !this.dmp.entityDois.find(doi => doi.repositoryId === repo.repositoryId)); return this.depositRepos.filter(repo => !this.dmp.entityDois?.find(doi => doi.repositoryId === repo.repositoryId));
} }
moreDeposit() { moreDeposit() {