Search in sources :

Example 16 with MLocation

use of org.compiere.model.MLocation in project adempiere by adempiere.

the class InventoryUtil method getCreateWarehouse.

/**
	 * Helper Method : Create Warehouse
	 */
public static MWarehouse getCreateWarehouse(int AD_Org_ID, String value) {
    if (AD_Org_ID <= 0)
        AD_Org_ID = getFirst_Org_ID();
    Properties ctx = Env.getCtx();
    String whereClause = "AD_Org_ID=? AND Value=?";
    MWarehouse wh = new Query(ctx, MWarehouse.Table_Name, whereClause, null).setParameters(new Object[] { AD_Org_ID, value }).setClient_ID().firstOnly();
    if (wh != null)
        return wh;
    wh = new MWarehouse(ctx, 0, null);
    wh.setAD_Org_ID(AD_Org_ID);
    wh.setValue(value);
    wh.setName(value);
    MLocation loc = new MLocation(ctx, 0, null);
    loc.saveEx();
    wh.setC_Location_ID(loc.get_ID());
    wh.saveEx();
    return wh;
}
Also used : Query(org.compiere.model.Query) Properties(java.util.Properties) MLocation(org.compiere.model.MLocation) MWarehouse(org.compiere.model.MWarehouse)

Example 17 with MLocation

use of org.compiere.model.MLocation in project adempiere by adempiere.

the class MLocationTest method testMLocationCreation.

public void testMLocationCreation() {
    location = new MLocation(getCtx(), 0, getTrxName());
    // location.loadDefaults();
    location.setC_Country_ID(100);
    location.setC_Region_ID(103);
    location.setCity("Windsor");
    location.setAddress1("nyb");
    location.setAddress2("");
    location.setPostal("95492");
    location.setPostal_Add("95492");
    location.setAD_Org_ID(0);
    boolean saveResult = location.save();
    assertTrue("MLocation.save()", saveResult);
    try {
        commit();
    } catch (Exception e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : MLocation(org.compiere.model.MLocation)

Example 18 with MLocation

use of org.compiere.model.MLocation in project adempiere by adempiere.

the class ADServiceImpl method saveLocation.

public StandardResponseDocument saveLocation(LocationDocument req) throws XFireFault {
    authenticate(webServiceName, "saveLocation");
    StandardResponseDocument ret = StandardResponseDocument.Factory.newInstance();
    StandardResponse resp = ret.addNewStandardResponse();
    Location rloc = req.getLocation();
    MLocation location = new MLocation(m_cs.getM_ctx(), rloc.getCLocationID(), null);
    //log.fine("doPost updating C_Location_ID=" + C_Location_ID + " - " + targetBase);
    location.setAddress1(rloc.getAddress1());
    location.setAddress2(rloc.getAddress2());
    location.setCity(rloc.getCity());
    location.setPostal(rloc.getPostalCode());
    location.setC_Country_ID(rloc.getCCountryID());
    location.setC_Region_ID(rloc.getCRegionID());
    //  Save Location
    location.save();
    resp.setRecordID(location.getC_Location_ID());
    return ret;
}
Also used : StandardResponse(pl.x3E.adInterface.StandardResponse) MLocation(org.compiere.model.MLocation) StandardResponseDocument(pl.x3E.adInterface.StandardResponseDocument) MLocation(org.compiere.model.MLocation) Location(pl.x3E.adInterface.Location)

Example 19 with MLocation

use of org.compiere.model.MLocation in project adempiere by adempiere.

the class MRPUtil method getCreateWarehouse.

/**
	 * Helper Method : Create Warehouse
	 */
public static I_M_Warehouse getCreateWarehouse(int AD_Org_ID, String value) {
    Properties ctx = Env.getCtx();
    int AD_Client_ID = Env.getAD_Client_ID(ctx);
    String whereClause = "AD_Client_ID=? AND AD_Org_ID=? AND Value=?";
    MWarehouse wh = new Query(ctx, MWarehouse.Table_Name, whereClause, null).setParameters(new Object[] { AD_Client_ID, AD_Org_ID, value }).firstOnly();
    if (wh != null)
        return wh;
    wh = new MWarehouse(ctx, 0, null);
    wh.setAD_Org_ID(AD_Org_ID);
    wh.setValue(value);
    wh.setName(value);
    MLocation loc = new MLocation(ctx, 0, null);
    loc.saveEx();
    wh.setC_Location_ID(loc.get_ID());
    wh.saveEx();
    return wh;
}
Also used : Query(org.compiere.model.Query) Properties(java.util.Properties) MLocation(org.compiere.model.MLocation) MWarehouse(org.compiere.model.MWarehouse)

Example 20 with MLocation

use of org.compiere.model.MLocation in project adempiere by adempiere.

the class Generator method generateSessionEquiv.

private void generateSessionEquiv(HttpServletCM thisServlet, HttpServletRequest httpRequest, Properties ctx) {
    xmlCode.append("<session>\n");
    HttpSession thisSession = httpRequest.getSession(false);
    if (thisSession != null) {
        if (thisSession.getAttribute(WebInfo.NAME) != null) {
            WebInfo wi = (WebInfo) thisSession.getAttribute(WebInfo.NAME);
            xmlCode.append("<WebInfo>\n");
            xmlCode.append("<Info><![CDATA[" + wi.getInfo() + "]]></Info>\n");
            if (wi.getUser_ID() > 0) {
                MUser thisUser = MUser.get(ctx, wi.getAD_User_ID());
                xmlCode = thisUser.get_xmlString(xmlCode);
                MBPartner thisBPartner = new MBPartner(ctx, wi.getC_BPartner_ID(), null);
                if (thisBPartner != null)
                    xmlCode = thisBPartner.get_xmlString(xmlCode);
                MBPartnerLocation thisBPartnerLocation = thisBPartner.getPrimaryC_BPartner_Location();
                if (thisBPartnerLocation != null)
                    xmlCode = thisBPartnerLocation.get_xmlString(xmlCode);
                MLocation thisLocation = MLocation.getBPLocation(ctx, thisBPartnerLocation.get_ID(), null);
                if (thisLocation != null)
                    xmlCode = thisLocation.get_xmlString(xmlCode);
                MBPBankAccount[] theseBPBankAccount = thisBPartner.getBankAccounts(true);
                if (theseBPBankAccount != null && theseBPBankAccount.length > 0)
                    for (int i = 0; i < theseBPBankAccount.length; i++) xmlCode = theseBPBankAccount[i].get_xmlString(xmlCode);
                if (thisSession.getAttribute("EMail") == null)
                    thisSession.setAttribute("EMail", thisUser.getEMail());
            }
            if (wi.getWebUser().getPasswordMessage() != null) {
                xmlCode.append("<PasswordMessage><![CDATA[" + wi.getWebUser().getPasswordMessage() + "]]></PasswordMessage>\n");
                wi.getWebUser().setPasswordMessage(null);
            }
            if (wi.getWebUser().getSaveErrorMessage() != null) {
                xmlCode.append("<SaveErrorMessage><![CDATA[" + wi.getWebUser().getSaveErrorMessage() + "]]></SaveErrorMessage>\n");
                wi.getWebUser().setSaveErrorMessage(null);
            }
            if (thisSession.getAttribute("hdrMessage") != null) {
                xmlCode.append("<hdrMessage><![CDATA[" + thisSession.getAttribute("hdrMessage") + "]]></hdrMessage>\n");
                thisSession.removeAttribute("hdrMessage");
            }
            xmlCode.append("<WebUser>\n");
            xmlCode.append("<LoggedIn>" + wi.getWebUser().isLoggedIn() + "</LoggedIn>\n");
            xmlCode.append("</WebUser>\n");
            xmlCode.append("</WebInfo>\n");
        }
        if (thisSession.getAttribute("EMail") != null)
            xmlCode.append("<EMail><![CDATA[" + thisSession.getAttribute("EMail") + "]]></EMail>\n");
    }
    xmlCode.append("</session>\n");
}
Also used : HttpSession(javax.servlet.http.HttpSession) MBPBankAccount(org.compiere.model.MBPBankAccount) MBPartner(org.compiere.model.MBPartner) WebInfo(org.compiere.util.WebInfo) MUser(org.compiere.model.MUser) MLocation(org.compiere.model.MLocation) MBPartnerLocation(org.compiere.model.MBPartnerLocation)

Aggregations

MLocation (org.compiere.model.MLocation)28 MBPartner (org.compiere.model.MBPartner)13 MBPartnerLocation (org.compiere.model.MBPartnerLocation)10 Properties (java.util.Properties)8 MUser (org.compiere.model.MUser)7 PreparedStatement (java.sql.PreparedStatement)6 ResultSet (java.sql.ResultSet)6 HttpSession (javax.servlet.http.HttpSession)6 BigDecimal (java.math.BigDecimal)5 SQLException (java.sql.SQLException)5 Query (org.compiere.model.Query)5 org.apache.ecs.xhtml.button (org.apache.ecs.xhtml.button)4 MInvoice (org.compiere.model.MInvoice)4 MInvoiceLine (org.compiere.model.MInvoiceLine)4 MClient (org.compiere.model.MClient)3 MDocType (org.compiere.model.MDocType)3 Timestamp (java.sql.Timestamp)2 org.apache.ecs.xhtml.b (org.apache.ecs.xhtml.b)2 org.apache.ecs.xhtml.form (org.apache.ecs.xhtml.form)2 org.apache.ecs.xhtml.p (org.apache.ecs.xhtml.p)2