Search in sources :

Example 1 with QAPicklistType

use of com.qas.web_2005_02.QAPicklistType 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));
    }
}
Also used : PartnerAddress(com.axelor.apps.base.db.PartnerAddress) Address(com.axelor.apps.base.db.Address) PickListEntry(com.axelor.apps.base.db.PickListEntry) AddressLineType(com.qas.web_2005_02.AddressLineType) PicklistEntryType(com.qas.web_2005_02.PicklistEntryType) QAPicklistType(com.qas.web_2005_02.QAPicklistType) AddressService(com.axelor.apps.base.service.AddressService) AppBaseService(com.axelor.apps.base.service.app.AppBaseService) VerifyLevelType(com.qas.web_2005_02.VerifyLevelType) ArrayList(java.util.ArrayList) List(java.util.List) QAAddressType(com.qas.web_2005_02.QAAddressType)

Example 2 with QAPicklistType

use of com.qas.web_2005_02.QAPicklistType 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));
}
Also used : QAPicklistType(com.qas.web_2005_02.QAPicklistType) PartnerAddress(com.axelor.apps.base.db.PartnerAddress) Address(com.axelor.apps.base.db.Address) AddressService(com.axelor.apps.base.service.AddressService) AppBaseService(com.axelor.apps.base.service.app.AppBaseService) PickListEntry(com.axelor.apps.base.db.PickListEntry)

Aggregations

Address (com.axelor.apps.base.db.Address)2 PartnerAddress (com.axelor.apps.base.db.PartnerAddress)2 PickListEntry (com.axelor.apps.base.db.PickListEntry)2 AddressService (com.axelor.apps.base.service.AddressService)2 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)2 QAPicklistType (com.qas.web_2005_02.QAPicklistType)2 AddressLineType (com.qas.web_2005_02.AddressLineType)1 PicklistEntryType (com.qas.web_2005_02.PicklistEntryType)1 QAAddressType (com.qas.web_2005_02.QAAddressType)1 VerifyLevelType (com.qas.web_2005_02.VerifyLevelType)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1