de.bund.bva.isyfact.common.web.validation.ValidationModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of isy-web Show documentation
Show all versions of isy-web Show documentation
Die IsyFact-Standards bilden das architektonische, technologische und methodische
Fundament der IsyFact. Sie umfassen allgemeingültige und wiederverwendbare Konzepte und
Komponenten, die für die Entwicklung beliebiger Fachanwendungen relevant sind.
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* The Federal Office of Administration (Bundesverwaltungsamt, BVA)
* licenses this file to you under the Apache License, Version 2.0 (the
* License). You may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package de.bund.bva.isyfact.common.web.validation;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
/**
* The validation model stores the validation messages for a mask.
*
* @deprecated This module is deprecated and will be removed in a future release.
* It is recommended to use isy-angular-widgets instead.
*/
@Deprecated
public class ValidationModel implements Serializable {
/**
* The serial version UID.
*/
private static final long serialVersionUID = 1L;
/**
* Contains the validation errors for the current mask.
*/
private List validationMessages = new ArrayList<>();
/**
* Contains the headline of validation error messages.
*/
private FacesMessage globalValidationFacesMessage;
/**
* Contains the validation errors, which can be displayed as Faces Messages.
*/
private List validationFacesMessages = new ArrayList<>();
public List getValidationMessages() {
return this.validationMessages;
}
public void setValidationMessages(List validationMessages) {
this.validationMessages = validationMessages;
}
public List getValidationFacesMessages() {
return this.validationFacesMessages;
}
public void setValidationFacesMessages(List validationFacesMessages) {
this.validationFacesMessages = validationFacesMessages;
}
public FacesMessage getGlobalValidationFacesMessage() {
return this.globalValidationFacesMessage;
}
public void setGlobalValidationFacesMessage(FacesMessage globalValidationFacesMessage) {
this.globalValidationFacesMessage = globalValidationFacesMessage;
}
/**
* Reads the current validation messages for a given reference.
* @param reference
* the reference.
* @return The associated validation messages.
*/
public List getValidationMessagesForReference(String reference) {
List filteredValidationMessages = new ArrayList<>();
if (this.validationMessages == null) {
return filteredValidationMessages;
}
for (ValidationMessage validationMessage : this.validationMessages) {
if (Strings.isNullOrEmpty(validationMessage.getReference())) {
continue;
}
if (validationMessage.getReference().equals(reference)) {
filteredValidationMessages.add(validationMessage);
}
}
return filteredValidationMessages;
}
/**
* Reads the current validation messages without a reference.
*
* @return The validation messages without a reference.
*/
public List getValidationMessagesWithoutReference() {
List filteredValidationFacesMessages = new ArrayList<>();
if (this.validationMessages == null) {
return filteredValidationFacesMessages;
}
for (FacesMessage validationFacesMessage : this.validationFacesMessages) {
if (Strings.isNullOrEmpty(validationFacesMessage.getSummary())) {
filteredValidationFacesMessages.add(validationFacesMessage);
}
}
return filteredValidationFacesMessages;
}
/**
* Returns a concatenated validation message as a string from all existing validation messages
* for the given reference.
* @param reference
* the reference.
* @return The validation message.
*/
public String getCombinedValidationMessageForReference(String reference) {
List messages = new ArrayList<>();
for (ValidationMessage validationMessage : getValidationMessagesForReference(reference)) {
String message = validationMessage.getMessage();
if (validationMessage.isShowReadableReferenceValidationMessageForReference()) {
message = validationMessage.getReadableReference() + " " + message;
}
messages.add(message);
}
return Joiner.on(", ").join(messages);
}
}