use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class ReleaseInOutBound method doIt.
/**
* Process - Generate Export Format
* @return info
*/
@Override
protected String doIt() throws Exception {
List<MWMInOutBoundLine> outBoundLines = (List<MWMInOutBoundLine>) getInstancesForSelection(get_TrxName());
outBoundLines.stream().forEach(outBoundLine -> {
if (outBoundLine.getDD_OrderLine_ID() > 0) {
MDDOrderLine orderDistributionLine = (MDDOrderLine) outBoundLine.getDD_OrderLine();
if (orderDistributionLine.getWM_InOutBoundLine_ID() <= 0) {
orderDistributionLine.setWM_InOutBoundLine_ID(orderDistributionLine.getWM_InOutBoundLine_ID());
orderDistributionLine.saveEx();
}
if (orderDistributionLine.getM_LocatorTo_ID() == outBoundLocator.getM_Locator_ID())
return;
}
BigDecimal qtySupply = createDistributionOrder(outBoundLine);
if (isCreateSupply() && qtySupply.signum() > 0) {
Env.setContext(outBoundLine.getCtx(), IsCreateSupply, "Y");
createSupply(outBoundLine, qtySupply);
}
});
if (orderDistribution != null && getDocumentAction() != null) {
orderDistribution.setDocAction(getDocumentAction());
orderDistribution.setDocStatus(org.compiere.process.DocAction.STATUS_InProgress);
orderDistribution.completeIt();
orderDistribution.save();
}
if (isPrintPickList() && orderDistribution != null) {
// Get Format & Data
ReportEngine reportEngine = getReportEngine("DistributionOrder_Header ** TEMPLATE **", "DD_Order_Header_v", orderDistribution.getDD_Order_ID());
if (reportEngine == null)
throw new AdempiereException("@NotFound@ @AD_PrintFormat_ID@");
ReportCtl.preview(reportEngine);
// prints only original
reportEngine.print();
}
//@DocumentNo@ " + order.getDocumentNo();
return "";
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class GenerateShipmentOutBound method processingMovements.
public void processingMovements() {
distributionOrders.entrySet().stream().forEach(entry -> {
I_DD_Order distributionOrder = entry.getValue();
List<Integer> orderIds = new ArrayList<Integer>();
orderIds.add(distributionOrder.getDD_Order_ID());
ProcessInfo processInfo = ProcessBuilder.create(getCtx()).process(MovementGenerate.getProcessId()).withSelectedRecordsIds(orderIds).withParameter(MWMInOutBound.COLUMNNAME_M_Warehouse_ID, distributionOrder.getM_Warehouse_ID()).withParameter(MMovement.COLUMNNAME_MovementDate, getMovementDate()).withoutTransactionClose().execute(get_TrxName());
if (processInfo.isError())
throw new AdempiereException(processInfo.getSummary());
addLog(processInfo.getSummary());
Arrays.stream(processInfo.getIDs()).forEach(recordId -> {
MMovement movement = new MMovement(getCtx(), recordId, get_TrxName());
if (movement != null && movement.get_ID() > 0)
GenerateMovement.printDocument(movement, "Inventory Move Hdr (Example)", processInfo.getWindowNo());
else
throw new AdempiereException("@M_Movement_ID@ @NotFound@");
});
});
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class WMRuleEngine method applyDefinition.
/**
* Apply Definition for Warehouse Strategy
* @param inOutBoundLine Order Bound Line
* @param warehouseAreaTypeId Area Type Id
* @param warehouseSectionTypeId Section Type Id
* */
private MWMStrategy applyDefinition(MWMInOutBoundLine inOutBoundLine, int warehouseAreaTypeId, int warehouseSectionTypeId) {
StringBuffer whereClause = new StringBuffer("(");
whereClause.append(MWMDefinition.COLUMNNAME_M_Product_ID + " IN (0,?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_M_Product_ID + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_M_Product_Category_ID + " IN (0,?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_M_Product_Category_ID + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_Group1 + " IN ('',?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_Group1 + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_Group2 + " IN ('',?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_Group2 + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_Classification + " IN ('',?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_Classification + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_C_BPartner_ID + " IN (0,?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_C_BPartner_ID + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_C_BP_Group_ID + " IN (0,?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_C_BP_Group_ID + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_WM_Area_Type_ID + " IN (0,?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_WM_Area_Type_ID + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_WM_Section_Type_ID + " IN (0,?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_WM_Section_Type_ID + " IS NULL");
whereClause.append(")");
whereClause.append(" AND EXISTS (SELECT 1 FROM " + MWMStrategy.Table_Name);
whereClause.append(" WHERE ");
whereClause.append(MWMStrategy.Table_Name + "." + MWMStrategy.COLUMNNAME_WM_Strategy_ID + "=");
whereClause.append(MWMDefinition.Table_Name + "." + MWMDefinition.COLUMNNAME_WM_Strategy_ID);
whereClause.append(" AND ");
whereClause.append(MWMStrategy.COLUMNNAME_InOutBoundType + "=?");
whereClause.append(")");
MProduct product = inOutBoundLine.getMProduct();
MBPartner partner = inOutBoundLine.getBPartner();
MWMDefinition definition = new Query(inOutBoundLine.getCtx(), MWMDefinition.Table_Name, whereClause.toString(), inOutBoundLine.get_TrxName()).setClient_ID().setParameters(product.getM_Product_ID(), product.getM_Product_Category_ID(), product.getGroup1(), product.getGroup2(), product.getClassification(), partner.getC_BPartner_ID(), partner.getC_BP_Group_ID(), warehouseAreaTypeId, warehouseSectionTypeId, MWMStrategy.INOUTBOUNDTYPE_OutboundOperation).first();
if (definition == null) {
throw new AdempiereException("@WM_Definition_ID@ @NotFound@");
}
return definition.getWarehouseStrategy();
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class GridTabDataBinder method valueChange.
/**
* @param e
*/
public void valueChange(ValueChangeEvent e) {
if (// only active records
gridTab.isProcessed()) {
Object source = e.getSource();
if (source instanceof WEditor) {
// Elaine 2009/05/06
WEditor editor = (WEditor) source;
GridField gridField = editor.getGridField();
if (gridField != null) {
if (!gridField.isEditable(true)) {
logger.config("(" + gridTab.toString() + ") " + e.getPropertyName());
return;
}
} else if (!editor.isReadWrite()) {
logger.config("(" + gridTab.toString() + ") " + e.getPropertyName());
return;
}
} else {
logger.config("(" + gridTab.toString() + ") " + e.getPropertyName());
return;
}
}
// processed
logger.config("(" + gridTab.toString() + ") " + e.getPropertyName() + "=" + e.getNewValue() + " (" + e.getOldValue() + ") " + (e.getOldValue() == null ? "" : e.getOldValue().getClass().getName()));
// Get Row/Col Info
GridTable mTable = gridTab.getTableModel();
int row = gridTab.getCurrentRow();
int col = mTable.findColumn(e.getPropertyName());
//
if (e.getNewValue() == null && e.getOldValue() != null && // some editors return "" instead of null
e.getOldValue().toString().length() > 0)
// this is the original code from GridController, don't know what it does there but it breaks ignore button for web ui
// mTable.setChanged (true);
mTable.setValueAt(e.getNewValue(), row, col);
else {
Object newValue = e.getNewValue();
Integer[] newValues = null;
if (newValue instanceof Integer[]) {
newValues = ((Integer[]) newValue);
newValue = newValues[0];
if (newValues.length > 1) {
Integer[] valuesCopy = new Integer[newValues.length - 1];
System.arraycopy(newValues, 1, valuesCopy, 0, valuesCopy.length);
newValues = valuesCopy;
} else {
newValues = null;
}
} else if (newValue instanceof Object[]) {
logger.severe("Multiple values can only be processed for IDs (Integer)");
throw new IllegalArgumentException("Multiple Selection values not available for this field. " + e.getPropertyName());
}
mTable.setValueAt(newValue, row, col);
// Force Callout
if (e.getPropertyName().equals("S_ResourceAssignment_ID")) {
GridField mField = gridTab.getField(col);
if (mField != null && mField.getCallout().length() > 0) {
// Dependencies & Callout
gridTab.processFieldChange(mField);
}
}
if (newValues != null && newValues.length > 0) {
// Save data, since record need to be used for generating clones.
if (!gridTab.dataSave(false)) {
throw new AdempiereException("SaveError");
}
// Retrieve the current record ID
int recordId = gridTab.getKeyID(gridTab.getCurrentRow());
Trx trx = Trx.get(Trx.createTrxName(), true);
trx.start();
try {
saveMultipleRecords(Env.getCtx(), gridTab.getTableName(), e.getPropertyName(), recordId, newValues, trx.getTrxName());
trx.commit();
gridTab.dataRefreshAll();
} catch (Exception ex) {
trx.rollback();
logger.severe(ex.getMessage());
throw new AdempiereException("SaveError");
} finally {
trx.close();
}
}
}
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class ServerPushTemplate method execute.
/**
* Execute callback in UI thread
* @param callback
*/
public void execute(IServerPushCallback callback) {
boolean inUIThread = Executions.getCurrent() != null;
boolean desktopActivated = false;
try {
if (!inUIThread) {
//10 minutes timeout
if (Executions.activate(desktop, 10 * 60 * 1000)) {
desktopActivated = true;
} else {
throw new DesktopUnavailableException("Timeout activating desktop.");
}
}
callback.updateUI();
} catch (DesktopUnavailableException de) {
throw de;
} catch (Exception e) {
throw new AdempiereException("Failed to update client in server push worker thread.", e);
} finally {
if (!inUIThread && desktopActivated) {
Executions.deactivate(desktop);
}
}
}
Aggregations