-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gestione nuove dichiarazioni e limiti di lunghezza.
- Loading branch information
Showing
3 changed files
with
139 additions
and
2 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...java/it/cnr/si/cool/jconon/service/application/PercorsoFormativoProfessionaleService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package it.cnr.si.cool.jconon.service.application; | ||
|
||
import it.cnr.cool.web.scripts.exception.ClientMessageException; | ||
import org.apache.chemistry.opencmis.client.api.Folder; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Optional; | ||
import java.util.stream.IntStream; | ||
|
||
@Service | ||
public class PercorsoFormativoProfessionaleService implements ApplicationValidateSend{ | ||
|
||
@Value("${application.send.percorso-formativo-professionale.max-length}") | ||
public int MAXLENGTH; | ||
|
||
@Override | ||
public void validate(Folder call, Folder application) { | ||
|
||
final Integer maxLength = IntStream.range(1, 2) | ||
.map(i -> applicationValue(application, "jconon_application:percorso_formativo_professionale_dimensione" + i)) | ||
.reduce(0, (a, b) -> a + b); | ||
|
||
if (maxLength > MAXLENGTH) { | ||
throw new ClientMessageException("Il numero dei caratteri [" + maxLength + "] supera la dimensione massima [" + MAXLENGTH + "]"); | ||
} | ||
|
||
} | ||
|
||
private Integer applicationValue(Folder application, String property) { | ||
return Optional.ofNullable(application.<String>getPropertyValue(property)) | ||
.map(s -> s.length()) | ||
.orElse(0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters