use of it.cnr.bulkinfo.BulkInfoImpl.FieldProperty in project cool-jconon by consiglionazionaledellericerche.
the class PrintService method formNameMessage.
private String formNameMessage(FieldProperty fieldProperty, BulkInfo bulkInfo, PrintDetailBulk detail, ApplicationModel applicationModel, Folder application, String labelKey) {
String message = "";
if (fieldProperty.getAttribute("formName") != null) {
List<Object> params = new ArrayList<Object>();
FieldPropertySet printForm1 = bulkInfo.getPrintForms().get(fieldProperty.getAttribute("formName"));
if (printForm1 != null && printForm1.getKey() != null && printForm1.getKey().equals("false")) {
if (labelKey != null)
detail.addField(new Pair<String, String>(null, applicationModel.getMessage(labelKey)));
printField(printForm1, applicationModel, application, detail, bulkInfo);
} else {
for (FieldProperty paramFieldProperty : bulkInfo.getPrintForm(fieldProperty.getAttribute("formName"))) {
Object param = applicationModel.getProperties().get(paramFieldProperty.getAttribute("property"));
if (param == null)
param = application.getPropertyValue(paramFieldProperty.getAttribute("property"));
if (param == null)
param = "";
params.add(param);
}
message = message.concat(applicationModel.getMessage(labelKey, params.toArray()));
}
} else {
message = message.concat(applicationModel.getMessage(labelKey));
}
return message;
}
use of it.cnr.bulkinfo.BulkInfoImpl.FieldProperty in project cool-jconon by consiglionazionaledellericerche.
the class ApplicationService method validateAspects.
protected List<JSONErrorPair> validateAspects(Map<String, Object> map, Folder call, Folder application, Session cmisSession) {
List<JSONErrorPair> listError = new ArrayList<JSONErrorPair>();
List<String> listAspect = getDichiarazioniList(call, application);
for (String aspect : listAspect) {
BulkInfo bulkInfoAspect = bulkInfoService.find(aspect);
FieldProperty flag = null;
if (bulkInfoAspect != null) {
for (FieldProperty fieldProperty : bulkInfoAspect.getForm(aspect)) {
if (fieldProperty.isRadioGroupType() || fieldProperty.isCheckboxType()) {
flag = fieldProperty;
break;
}
}
for (FieldProperty fieldProperty : bulkInfoAspect.getForm(aspect)) {
if (flag != null) {
if (!fieldProperty.equals(flag) && fieldProperty.getAttributes().get("class").contains(flag.getName() + '_' + map.get(flag.getProperty())) && !fieldProperty.isNullable() && !Optional.ofNullable(fieldProperty.getAttributes().get("class")).map(s -> s.contains("double_show")).orElse(Boolean.FALSE)) {
addError(listError, map, fieldProperty.getProperty(), cmisSession.getTypeDefinition(aspect).getPropertyDefinitions().get(fieldProperty.getProperty()).getDisplayName());
} else {
if (fieldProperty.equals(flag) && !fieldProperty.isNullable()) {
addError(listError, map, fieldProperty.getProperty(), cmisSession.getTypeDefinition(aspect).getPropertyDefinitions().get(fieldProperty.getProperty()).getDisplayName());
}
}
} else {
if (!fieldProperty.isNullable()) {
addError(listError, map, fieldProperty.getProperty(), cmisSession.getTypeDefinition(aspect).getPropertyDefinitions().get(fieldProperty.getProperty()).getDisplayName());
}
}
}
}
}
return listError;
}
use of it.cnr.bulkinfo.BulkInfoImpl.FieldProperty in project cool-jconon by consiglionazionaledellericerche.
the class ApplicationService method validateBaseTableMap.
protected List<JSONErrorPair> validateBaseTableMap(Map<String, Object> map, Folder call, Folder application, Session cmisSession) {
List<JSONErrorPair> listError = new ArrayList<JSONErrorPair>();
listError.addAll(validateAspects(map, call, application, cmisSession));
List<String> listSezioniDomanda = getSezioniDomandaList(call);
BulkInfo bulkInfo = bulkInfoService.find(JCONONFolderType.JCONON_APPLICATION.value().replace(":", "_"));
for (String sezione : listSezioniDomanda) {
for (FieldProperty fieldProperty : bulkInfo.getForm(sezione)) {
if (Optional.ofNullable(fieldProperty.getProperty()).isPresent() && Optional.ofNullable(fieldProperty.getAttribute("visible")).filter(x -> x.equalsIgnoreCase("true")).isPresent()) {
// TAB DATI ANAGRAFICI - Controlli particolari
if (fieldProperty.getProperty().equals(JCONONPropertyIds.APPLICATION_FL_CITTADINO_ITALIANO.value())) {
addError(listError, map, fieldProperty.getProperty());
if (map.get(JCONONPropertyIds.APPLICATION_FL_CITTADINO_ITALIANO.value()) != null) {
if ((Boolean) map.get(JCONONPropertyIds.APPLICATION_FL_CITTADINO_ITALIANO.value())) {
addError(listError, map, JCONONPropertyIds.APPLICATION_CODICE_FISCALE.value());
Object codiceFiscale = map.get(JCONONPropertyIds.APPLICATION_CODICE_FISCALE.value());
if (codiceFiscale != null) {
// controllo formale della validita' del codice fiscale
controllaCodiceFiscale(map, application);
}
} else
addError(listError, map, JCONONPropertyIds.APPLICATION_NAZIONE_CITTADINANZA.value());
}
} else if (fieldProperty.getProperty().equals(JCONONPropertyIds.APPLICATION_CODICE_FISCALE.value()) || fieldProperty.getProperty().equals(JCONONPropertyIds.APPLICATION_NAZIONE_CITTADINANZA.value())) {
LOGGER.debug("field " + fieldProperty.getProperty());
} else if (fieldProperty.getProperty().equals(JCONONPropertyIds.APPLICATION_CAP_RESIDENZA.value())) {
if (map.get(JCONONPropertyIds.APPLICATION_NAZIONE_RESIDENZA.value()) != null && ((String) map.get(JCONONPropertyIds.APPLICATION_NAZIONE_RESIDENZA.value())).toUpperCase().equals("ITALIA"))
addError(listError, map, JCONONPropertyIds.APPLICATION_CAP_RESIDENZA.value());
} else if (fieldProperty.getProperty().equals(JCONONPropertyIds.APPLICATION_CAP_COMUNICAZIONI.value())) {
if (map.get(JCONONPropertyIds.APPLICATION_NAZIONE_COMUNICAZIONI.value()) != null && ((String) map.get(JCONONPropertyIds.APPLICATION_NAZIONE_COMUNICAZIONI.value())).toUpperCase().equals("ITALIA"))
addError(listError, map, JCONONPropertyIds.APPLICATION_CAP_COMUNICAZIONI.value());
} else if (fieldProperty.getProperty().equals(JCONONPropertyIds.APPLICATION_EMAIL_COMUNICAZIONI.value())) {
if (application == null || application.getPropertyValue(JCONONPropertyIds.APPLICATION_FL_CITTADINO_ITALIANO.value()) == null || application.getPropertyValue(JCONONPropertyIds.APPLICATION_FL_CITTADINO_ITALIANO.value()).equals(Boolean.FALSE))
addError(listError, map, JCONONPropertyIds.APPLICATION_EMAIL_COMUNICAZIONI.value());
} else if (fieldProperty.getProperty().equals(JCONONPropertyIds.APPLICATION_EMAIL_PEC_COMUNICAZIONI.value())) {
if (application == null || application.getPropertyValue(JCONONPropertyIds.APPLICATION_FL_CITTADINO_ITALIANO.value()) == null || application.getPropertyValue(JCONONPropertyIds.APPLICATION_FL_CITTADINO_ITALIANO.value()).equals(Boolean.TRUE))
addError(listError, map, JCONONPropertyIds.APPLICATION_EMAIL_PEC_COMUNICAZIONI.value());
} else
addError(listError, map, fieldProperty.getProperty(), application.getType().getPropertyDefinitions().get(fieldProperty.getProperty()).getDisplayName());
if ((fieldProperty.isRadioGroupType() || fieldProperty.isCheckboxType()) && !fieldProperty.getProperty().equals(JCONONPropertyIds.APPLICATION_SESSO.value()) && map.get(fieldProperty.getProperty()) != null) {
Collection<FieldProperty> radioForm = bulkInfo.getForm(fieldProperty.getProperty() + ((Boolean) map.get(fieldProperty.getProperty()) ? "_true" : "_false").replace(":", "_"));
if (radioForm != null && !radioForm.isEmpty()) {
for (FieldProperty radioFieldProperty : bulkInfo.getForm(fieldProperty.getProperty() + ((Boolean) map.get(fieldProperty.getProperty()) ? "_true" : "_false").replace(":", "_"))) {
if (!radioFieldProperty.isNullable())
addError(listError, map, radioFieldProperty.getProperty(), application.getType().getPropertyDefinitions().get(radioFieldProperty.getProperty()).getDisplayName());
}
}
}
}
}
}
List<String> properties = call.getPropertyValue(JCONONPropertyIds.CALL_ELENCO_FIELD_NOT_REQUIRED.value());
if (properties != null) {
for (String property : properties) {
for (Iterator<JSONErrorPair> iterator = listError.iterator(); iterator.hasNext(); ) {
JSONErrorPair error = iterator.next();
if (error.getFirst().startsWith(property))
iterator.remove();
}
}
}
return listError;
}
use of it.cnr.bulkinfo.BulkInfoImpl.FieldProperty in project cool-jconon by consiglionazionaledellericerche.
the class PrintService method printField.
@SuppressWarnings("unchecked")
private void printField(FieldPropertySet printForm, ApplicationModel applicationModel, Folder application, PrintDetailBulk detail, BulkInfo bulkInfo) {
for (FieldProperty printFieldProperty : printForm.getFieldProperties()) {
if (printFieldProperty.getAttribute("formName") != null) {
Object objValue = application.getPropertyValue(printFieldProperty.getAttribute("formName"));
FieldPropertySet printFormDetail = bulkInfo.getPrintForms().get(printFieldProperty.getAttribute("formName"));
for (FieldProperty printFieldPropertyDetail : printFormDetail.getFieldProperties()) {
if (printFieldPropertyDetail.getAttribute("key") != null && printFieldPropertyDetail.getAttribute("key").equals(String.valueOf(objValue))) {
detail.addField(new Pair<String, String>(null, applicationModel.getMessage(printFieldPropertyDetail.getAttribute("label"))));
}
}
final Optional<String> dichiarazioniEmptyMessage = getDichiarazioniEmptyMessage();
if (dichiarazioniEmptyMessage.isPresent() && Optional.ofNullable(detail.getFields()).orElse(Collections.emptyList()).isEmpty()) {
detail.addField(new Pair<String, String>(null, dichiarazioniEmptyMessage.get()));
}
continue;
}
String message = null;
String label = printFieldProperty.getAttribute("label");
if (label == null) {
String labelJSON = printFieldProperty.getAttribute("jsonlabel");
if (labelJSON != null) {
JSONObject jsonLabel = new JSONObject(labelJSON);
message = applicationModel.getMessage(jsonLabel.getString("key"));
if (message == null || message.equalsIgnoreCase(jsonLabel.getString("key")))
message = jsonLabel.getString("default");
} else {
FieldProperty subProperty = printFieldProperty.getSubProperty("jsonlabel");
label = subProperty.getAttribute("key");
message = applicationModel.getMessage(label);
if (message == null || message.equalsIgnoreCase(subProperty.getAttribute("key")))
message = subProperty.getAttribute("default");
}
} else {
message = applicationModel.getMessage(label);
}
String value;
Object objValue = application.getPropertyValue(printFieldProperty.getProperty());
if (objValue == null && printFieldProperty.getProperty() != null) {
final Optional<String> dichiarazioniEmptyMessage = getDichiarazioniEmptyMessage();
if (dichiarazioniEmptyMessage.isPresent() && Optional.ofNullable(detail.getFields()).orElse(Collections.emptyList()).isEmpty()) {
detail.addField(new Pair<String, String>(null, dichiarazioniEmptyMessage.get()));
}
continue;
} else if (printFieldProperty.getProperty() == null) {
detail.addField(new Pair<String, String>(null, message));
} else {
if (application.getProperty(printFieldProperty.getProperty()).isMultiValued()) {
List<Object> values = (List<Object>) objValue;
if (values.isEmpty()) {
final Optional<String> dichiarazioniEmptyMessage = getDichiarazioniEmptyMessage();
if (dichiarazioniEmptyMessage.isPresent() && Optional.ofNullable(detail.getFields()).orElse(Collections.emptyList()).isEmpty()) {
detail.addField(new Pair<String, String>(null, dichiarazioniEmptyMessage.get()));
}
return;
}
if (values.size() > 1) {
for (int k = 0; k < values.size(); k++) {
detail.addField(new Pair<String, String>(k == 0 ? (message + "<br>") : "", String.valueOf(values.get(k))));
}
} else {
value = StringUtils.collectionToDelimitedString(((Collection<?>) objValue), ", ");
detail.addField(new Pair<String, String>(message, value));
}
} else {
if (printFieldProperty.getAttribute("widget") != null) {
if (printFieldProperty.getAttribute("widget").contains("ui.datepicker")) {
value = StringUtil.DATEFORMAT.format(((Calendar) objValue).getTime());
} else if (printFieldProperty.getAttribute("widget").contains("ui.datetimepicker")) {
value = StringUtil.DATETIMEFORMAT.format(((Calendar) objValue).getTime());
} else {
if (objValue instanceof Boolean) {
if (printFieldProperty.getAttribute("generated") != null)
value = Boolean.valueOf(String.valueOf(objValue)) ? "" : "No";
else
value = "";
} else {
value = String.valueOf(objValue);
}
}
} else {
value = String.valueOf(objValue);
}
if (Optional.ofNullable(label).isPresent()) {
final String finalLabel = label.concat("_").concat(value);
final Optional<String> message1 = Optional.ofNullable(applicationModel.getMessage(finalLabel));
if (message1.isPresent() && !message1.get().equals(finalLabel)) {
message = message1.get();
value = "";
}
}
detail.addField(new Pair<String, String>(message, value));
}
}
}
}
use of it.cnr.bulkinfo.BulkInfoImpl.FieldProperty in project cool-jconon by consiglionazionaledellericerche.
the class PrintService method getDichiarazioni.
/**
* 1. Prendiamo tutte le associazioni della domanda (application)
* 2. Per ogni associazione prendiamo il corrispondente PrintForm dal BulkInfo
* (passato come parametro)
* 3. Per ogni fieldProperty del PrintForm si costruisce una riga(?) dell'output
*
* @param bulkInfo
* @param application
* @param callProperty
* @return
*/
protected List<PrintDetailBulk> getDichiarazioni(BulkInfo bulkInfo, Folder application, JCONONPropertyIds callProperty, ApplicationModel applicationModel, Dichiarazioni dichiarazione) {
List<PrintDetailBulk> result = new ArrayList<PrintDetailBulk>();
// Recupero il bando
// chi e' il parent?
Folder call = application.getParents().get(0);
List<String> associations = call.getPropertyValue(callProperty.value());
boolean isCittadinoItaliano = (boolean) Optional.ofNullable(application.getProperty(JCONONPropertyIds.APPLICATION_FL_CITTADINO_ITALIANO.value())).map(Property::getValue).orElse(Boolean.TRUE);
if (isCittadinoItaliano) {
associations.remove(P_JCONON_APPLICATION_ASPECT_GODIMENTO_DIRITTI);
} else {
associations.remove(P_JCONON_APPLICATION_ASPECT_ISCRIZIONE_LISTE_ELETTORALI);
}
for (int i = 0; i < associations.size(); i++) {
String association = associations.get(i);
FieldProperty fieldProperty = null;
FieldPropertySet printForm = bulkInfoService.find(association).getPrintForms().get(association);
if (printForm != null) {
Property<?> property = application.getProperty(printForm.getKey());
if (property != null) {
fieldProperty = printForm.getFieldProperty(property.getValueAsString());
}
PrintDetailBulk detail = new PrintDetailBulk();
detail.setTitle(getTitle(i, dichiarazione));
if (printForm.getKey() == null) {
printField(printForm, applicationModel, application, detail, bulkInfo);
} else {
String labelKey = fieldProperty != null ? fieldProperty.getAttribute("label") : null;
if (application.getPropertyValue(printForm.getKey()) == null || fieldProperty == null || labelKey == null) {
final Optional<String> dichiarazioniEmptyMessage = getDichiarazioniEmptyMessage();
if (!dichiarazioniEmptyMessage.isPresent()) {
continue;
} else {
detail.addField(new Pair<String, String>(null, dichiarazioniEmptyMessage.get()));
}
} else {
detail.addField(new Pair<String, String>(null, formNameMessage(fieldProperty, bulkInfo, detail, applicationModel, application, labelKey)));
}
}
if (detail.getFields() != null && !detail.getFields().isEmpty())
result.add(detail);
}
}
return result;
}
Aggregations