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;
}
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());
}
}
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;
}
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;
}
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");
}
Aggregations