Search in sources :

Example 6 with LookupValues

use of pl.x3E.adInterface.LookupValues in project adempiere by adempiere.

the class ADServiceImpl method login.

public ADLoginResponseDocument login(ADLoginRequestDocument req) throws XFireFault {
    authenticate(webServiceName, "login");
    // TODO: Implement security layer
    log.log(Level.SEVERE, "Warning: Security layer not implemented yet - opening web service " + webServiceName + " implies a security risk for server");
    ADLoginResponseDocument res = ADLoginResponseDocument.Factory.newInstance();
    ADLoginResponse lr = res.addNewADLoginResponse();
    ADLoginRequest r = req.getADLoginRequest();
    if (// initial phase - return possible translations
    r.getStage() == 0) {
        LookupValues langs = lr.addNewLangs();
        for (int i = 0; i < Language.getLanguageCount(); i++) {
            Language language = Language.getLanguage(i);
            LookupValue lv = langs.addNewLv();
            lv.setKey(language.getAD_Language());
            lv.setVal(language.getName());
        }
    } else if (// Verify user and pass
    r.getStage() == 1) {
        KeyNamePair[] roles = null;
        KeyNamePair[] clients = null;
        KeyNamePair[] orgs = null;
        KeyNamePair[] warehouses = null;
        Login login = new Login(m_cs.getM_ctx());
        roles = login.getRoles(r.getUser(), r.getPass());
        if (roles == null) {
            lr.setStatus(-1);
            return res;
        } else {
            if (r.getRoleID() == -1 && roles != null && roles.length > 0)
                r.setRoleID(Integer.parseInt(roles[0].getID()));
            if (r.getRoleID() > -1)
                clients = login.getClients(new KeyNamePair(r.getRoleID(), ""));
            if (r.getClientID() == -1 && clients != null && clients.length > 0)
                r.setClientID(Integer.parseInt(clients[0].getID()));
            if (r.getClientID() > -1)
                orgs = login.getOrgs(new KeyNamePair(r.getClientID(), ""));
            if (r.getOrgID() == -1 && orgs != null && orgs.length > 0)
                r.setOrgID(Integer.parseInt(orgs[0].getID()));
            if (r.getOrgID() > -1)
                warehouses = login.getWarehouses(new KeyNamePair(r.getOrgID(), ""));
            ADLookup.fillLookupValues(lr.addNewRoles(), roles);
            ADLookup.fillLookupValues(lr.addNewClients(), clients);
            ADLookup.fillLookupValues(lr.addNewOrgs(), orgs);
            ADLookup.fillLookupValues(lr.addNewWarehouses(), warehouses);
        }
    } else if (// Verify user and pass
    r.getStage() == 2) {
        Login login = new Login(m_cs.getM_ctx());
        KeyNamePair[] roles = login.getRoles(r.getUser(), r.getPass());
        if (roles != null) {
            KeyNamePair org = new KeyNamePair(r.getRoleID(), Integer.toString(r.getRoleID()));
            String error = login.validateLogin(org);
            if (error != null && error.length() > 0) {
                lr.setStatus(-1);
                return res;
            }
            int AD_User_ID = Env.getAD_User_ID(m_cs.getM_ctx());
            if (!m_cs.login(AD_User_ID, r.getRoleID(), r.getClientID(), r.getOrgID(), r.getWarehouseID(), r.getLang())) {
                lr.setStatus(-1);
                return res;
            }
        } else {
            lr.setStatus(-1);
            return res;
        }
    }
    return res;
}
Also used : ADLoginRequest(pl.x3E.adInterface.ADLoginRequest) ADLoginResponseDocument(pl.x3E.adInterface.ADLoginResponseDocument) Language(org.compiere.util.Language) LookupValues(pl.x3E.adInterface.LookupValues) Login(org.compiere.util.Login) KeyNamePair(org.compiere.util.KeyNamePair) ADLoginResponse(pl.x3E.adInterface.ADLoginResponse) LookupValue(pl.x3E.adInterface.LookupValue)

Example 7 with LookupValues

use of pl.x3E.adInterface.LookupValues in project adempiere by adempiere.

the class ADServiceImpl method fillField.

private void fillField(Field f, GridFieldVO fo) {
    ////(griddieldvo) adempiere specific
    f.setADColumnID(fo.AD_Column_ID);
    f.setADProcessID(fo.AD_Process_ID);
    f.setADReferenceValueID(fo.AD_Reference_Value_ID);
    f.setADWindowID(fo.AD_Window_ID);
    f.setCallout(fo.Callout);
    f.setColumnName(fo.ColumnName);
    f.setDefaultValue(fo.DefaultValue);
    f.setDefaultValue2(fo.DefaultValue2);
    f.setDescription(fo.Description);
    f.setDisplayLength(fo.DisplayLength);
    f.setDisplayLogic(fo.DisplayLogic);
    f.setDisplayType(fo.displayType);
    f.setFieldGroup(fo.FieldGroup);
    f.setFieldLength(fo.FieldLength);
    f.setHeader(fo.Header);
    f.setHelp(fo.Help);
    f.setIsAlwaysUpdateable(fo.IsAlwaysUpdateable);
    f.setIsDisplayed(fo.IsDisplayed);
    f.setIsEncryptedColumn(fo.IsEncryptedColumn);
    f.setIsEncryptedField(fo.IsEncryptedField);
    f.setIsFieldOnly(fo.IsFieldOnly);
    f.setIsHeading(fo.IsHeading);
    f.setIsKey(fo.IsKey);
    f.setIsMandatory(fo.IsMandatory);
    f.setIsParent(fo.IsParent);
    f.setIsProcess(fo.isProcess);
    f.setIsRange(fo.IsRange);
    f.setIsReadOnly(fo.IsReadOnly);
    f.setIsSameLine(fo.IsSameLine);
    f.setIsSelectionColumn(fo.IsSelectionColumn);
    f.setIsUpdateable(fo.IsUpdateable);
    if (DisplayType.isLookup(fo.displayType)) {
        GridField ff = new GridField(fo);
        ArrayList<String> deps = ff.getDependentOn();
        Lookup lookup = ff.getLookup();
        LookupInfo li = f.addNewLookupInfo();
        if (fo.lookupInfo != null) {
            li.setZoomWindow(fo.lookupInfo.ZoomWindow);
            li.setZoomWindow(fo.lookupInfo.ZoomWindow);
        }
        //if (deps.size()==0)
        if (lookup != null && (fo.ValidationCode == null || (fo.ValidationCode != null && fo.ValidationCode.length() == 0))) {
            LookupValues lvs = f.addNewLookup();
            //System.out.println( "lookup "+fo.ColumnName+" "+lookup.getSize() );
            //if(lookup.size() == 0) - nie robic tego
            //	System.out.println("lookup refresh ["+fo.ColumnName+"]= "+lookup.refresh());
            /*if(lookup.getSize() > 0)*/
            // the last was false, 2007-05-11
            ArrayList ar = lookup.getData(ff.isMandatory(false), true, !ff.isReadOnly(), true);
            if (ar != null && ar.size() > 0) {
                Object[] list = ar.toArray();
                for (int i = 0; i < list.length; i++) {
                    boolean isNumber = list[0] instanceof KeyNamePair;
                    LookupValue lv = lvs.addNewLv();
                    if (isNumber) {
                        KeyNamePair p = (KeyNamePair) list[i];
                        lv.setKey(Integer.toString(p.getKey()));
                        lv.setVal(p.getName());
                    //System.out.println( "LV " + p.getKey() + " - "+ p.getName() );						
                    } else {
                        ValueNamePair p = (ValueNamePair) list[i];
                        lv.setKey(p.getValue());
                        lv.setVal(p.getName());
                    //System.out.println( "LV " + p.getValue() + " - "+ p.getName());
                    }
                }
            }
        }
    }
}
Also used : LookupInfo(pl.x3E.adInterface.LookupInfo) ArrayList(java.util.ArrayList) GridField(org.compiere.model.GridField) Lookup(org.compiere.model.Lookup) MLookup(org.compiere.model.MLookup) LookupValues(pl.x3E.adInterface.LookupValues) KeyNamePair(org.compiere.util.KeyNamePair) ValueNamePair(org.compiere.util.ValueNamePair) LookupValue(pl.x3E.adInterface.LookupValue)

Example 8 with LookupValues

use of pl.x3E.adInterface.LookupValues in project adempiere by adempiere.

the class ADServiceImpl method getRegion.

private LookupValues getRegion(MLocation location) {
    MRegion[] regions = MRegion.getRegions(location.getCtx(), location.getC_Country_ID());
    int comp = location.getC_Region_ID();
    if (comp == 0)
        comp = Env.getContextAsInt(m_cs.getM_ctx(), "C_Region_ID");
    LookupValues lvs = LookupValues.Factory.newInstance();
    for (int i = 0; i < regions.length; i++) {
        LookupValue lv = lvs.addNewLv();
        lv.setKey(String.valueOf(regions[i].getC_Region_ID()));
        lv.setVal(regions[i].getName());
    }
    return lvs;
}
Also used : LookupValues(pl.x3E.adInterface.LookupValues) MRegion(org.compiere.model.MRegion) LookupValue(pl.x3E.adInterface.LookupValue)

Aggregations

LookupValues (pl.x3E.adInterface.LookupValues)8 Lookup (org.compiere.model.Lookup)4 LookupValue (pl.x3E.adInterface.LookupValue)4 GridField (org.compiere.model.GridField)3 MLookup (org.compiere.model.MLookup)3 KeyNamePair (org.compiere.util.KeyNamePair)2 DataField (pl.x3E.adInterface.DataField)2 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 JasperPrint (net.sf.jasperreports.engine.JasperPrint)1 MCountry (org.compiere.model.MCountry)1 MProcess (org.compiere.model.MProcess)1 MProcessPara (org.compiere.model.MProcessPara)1 MRegion (org.compiere.model.MRegion)1 Language (org.compiere.util.Language)1 Login (org.compiere.util.Login)1 ValueNamePair (org.compiere.util.ValueNamePair)1 ADLoginRequest (pl.x3E.adInterface.ADLoginRequest)1 ADLoginResponse (pl.x3E.adInterface.ADLoginResponse)1