use of com.axelor.apps.base.db.PickListEntry in project axelor-open-suite by axelor.
the class AddressController method validate.
public void validate(ActionRequest request, ActionResponse response) {
Address a = request.getContext().asType(Address.class);
LOG.debug("validate a = {}", a);
String search = a.getAddressL4() + " " + a.getAddressL6();
Map<String, Object> retDict = Beans.get(AddressService.class).validate(Beans.get(AppBaseService.class).getAppBase().getQasWsdlUrl(), search);
LOG.debug("validate retDict = {}", retDict);
VerifyLevelType verifyLevel = (VerifyLevelType) retDict.get("verifyLevel");
if (verifyLevel != null && verifyLevel.value().equals("Verified")) {
QAAddressType address = (QAAddressType) retDict.get("qaAddress");
String addL1;
List<AddressLineType> addressLineType = address.getAddressLine();
addL1 = addressLineType.get(0).getLine();
response.setValue("addressL2", addressLineType.get(1).getLine());
response.setValue("addressL3", addressLineType.get(2).getLine());
response.setValue("addressL4", addressLineType.get(3).getLine());
response.setValue("addressL5", addressLineType.get(4).getLine());
response.setValue("addressL6", addressLineType.get(5).getLine());
response.setValue("inseeCode", addressLineType.get(6).getLine());
response.setValue("certifiedOk", true);
response.setValue("pickList", new ArrayList<QAPicklistType>());
if (addL1 != null) {
response.setFlash("Ligne 1: " + addL1);
}
} else if (verifyLevel != null && (verifyLevel.value().equals("Multiple") || verifyLevel.value().equals("StreetPartial") || verifyLevel.value().equals("InteractionRequired") || verifyLevel.value().equals("PremisesPartial"))) {
LOG.debug("retDict.verifyLevel = {}", retDict.get("verifyLevel"));
QAPicklistType qaPicklist = (QAPicklistType) retDict.get("qaPicklist");
List<PickListEntry> pickList = new ArrayList<>();
if (qaPicklist != null) {
for (PicklistEntryType p : qaPicklist.getPicklistEntry()) {
PickListEntry e = new PickListEntry();
e.setAddress(a);
e.setMoniker(p.getMoniker());
e.setScore(p.getScore().toString());
e.setPostcode(p.getPostcode());
e.setPartialAddress(p.getPartialAddress());
e.setPicklist(p.getPicklist());
pickList.add(e);
}
} else if (retDict.get("qaAddress") != null) {
QAAddressType address = (QAAddressType) retDict.get("qaAddress");
PickListEntry e = new PickListEntry();
List<AddressLineType> addressLineType = address.getAddressLine();
e.setAddress(a);
e.setL2(addressLineType.get(1).getLine());
e.setL3(addressLineType.get(2).getLine());
e.setPartialAddress(addressLineType.get(3).getLine());
e.setL5(addressLineType.get(4).getLine());
e.setPostcode(addressLineType.get(5).getLine());
e.setInseeCode(addressLineType.get(6).getLine());
pickList.add(e);
}
response.setValue("certifiedOk", false);
response.setValue("pickList", pickList);
} else if (verifyLevel != null && verifyLevel.value().equals("None")) {
LOG.debug("address None");
response.setFlash(I18n.get(IExceptionMessage.ADDRESS_3));
}
}
use of com.axelor.apps.base.db.PickListEntry in project axelor-open-suite by axelor.
the class AddressController method select.
public void select(ActionRequest request, ActionResponse response) {
Address a = request.getContext().asType(Address.class);
PickListEntry pickedEntry = null;
if (!a.getPickList().isEmpty()) {
// if (a.pickList*.selected.count { it == true} > 0)
// pickedEntry = a.pickList.find {it.selected == true}
pickedEntry = a.getPickList().get(0);
LOG.debug("select pickedEntry = {}", pickedEntry);
String moniker = pickedEntry.getMoniker();
if (moniker != null) {
com.qas.web_2005_02.Address address = Beans.get(AddressService.class).select(Beans.get(AppBaseService.class).getAppBase().getQasWsdlUrl(), moniker);
LOG.debug("select address = {}", address);
// addressL4: title="N° et Libellé de la voie"
// addressL6: title="Code Postal - Commune"/>
response.setValue("addressL2", address.getQAAddress().getAddressLine().get(1));
response.setValue("addressL3", address.getQAAddress().getAddressLine().get(2));
response.setValue("addressL4", address.getQAAddress().getAddressLine().get(3));
response.setValue("addressL5", address.getQAAddress().getAddressLine().get(4));
response.setValue("addressL6", address.getQAAddress().getAddressLine().get(5));
response.setValue("inseeCode", address.getQAAddress().getAddressLine().get(6));
response.setValue("certifiedOk", true);
response.setValue("pickList", new ArrayList<QAPicklistType>());
} else {
LOG.debug("missing fields for pickedEntry: {}", pickedEntry);
response.setValue("addressL2", pickedEntry.getL2());
response.setValue("addressL3", pickedEntry.getL3());
response.setValue("addressL4", pickedEntry.getPartialAddress());
response.setValue("addressL5", pickedEntry.getL5());
response.setValue("addressL6", pickedEntry.getPostcode());
response.setValue("inseeCode", pickedEntry.getInseeCode());
response.setValue("pickList", new ArrayList<QAPicklistType>());
response.setValue("certifiedOk", true);
}
} else
response.setFlash(I18n.get(IExceptionMessage.ADDRESS_4));
}
Aggregations