no message

dmp-refactoring
Diamantis Tziotzios 1 month ago
parent 1408cc0a59
commit d884f577f4

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

@ -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))
);
}
}
}

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

@ -34,6 +34,6 @@ public class DepositClientImpl implements DepositClient {
@Override
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();
}
}

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

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

@ -23,14 +23,11 @@ import { takeUntil } from 'rxjs/operators';
styleUrls: ['./dmp-deposit-dropdown.component.scss']
})
export class DmpDepositDropdown extends BaseComponent implements OnInit {
@Input()
inputRepos: DepositConfiguration[];
@Input()
dmp: Dmp;
@Input() inputRepos: DepositConfiguration[];
@Input() dmp: Dmp;
outputRepos = [];
logos: Map<string, SafeResourceUrl> = new Map<string, SafeResourceUrl>();
@Output()
outputReposEmitter: EventEmitter<EntityDoi[]> = new EventEmitter<EntityDoi[]>();
@Output() outputReposEmitter: EventEmitter<EntityDoi[]> = new EventEmitter<EntityDoi[]>();
private oauthLock: boolean;
constructor(
@ -50,7 +47,7 @@ export class DmpDepositDropdown extends BaseComponent implements OnInit {
}
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.forEach(repo => {

@ -501,7 +501,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
}
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() {

Loading…
Cancel
Save