use of org.compiere.util.TrxRunnable in project adempiere by adempiere.
the class VCreateFromPanel method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
try {
Trx.run(new TrxRunnable() {
public void run(String trxName) {
if (save(trxName)) {
createFrom.dispose();
}
}
});
} catch (Exception ex) {
ADialog.error(createFrom.getWindowNo(), this, "Error", ex.getLocalizedMessage());
}
} else // Cancel
if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
createFrom.dispose();
} else // Trifon
if (e.getActionCommand().equals(SELECT_ALL)) {
dataTable.selectAll();
dataTable.matchCheckWithSelectedRows();
info();
}
}
use of org.compiere.util.TrxRunnable in project adempiere by adempiere.
the class WCreateFromWindow method onEvent.
public void onEvent(Event e) throws Exception {
// OK - Save
if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) {
try {
Trx.run(new TrxRunnable() {
public void run(String trxName) {
if (save(trxName)) {
dispose();
}
}
});
} catch (Exception ex) {
FDialog.error(windowNo, this, "Error", ex.getLocalizedMessage());
}
} else // Cancel
if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) {
dispose();
} else // Trifon
if (e.getTarget().getId().equals(SELECT_ALL)) {
ListModelTable model = dataTable.getModel();
int rows = model.getSize();
for (int i = 0; i < rows; i++) {
model.setValueAt(new Boolean(true), i, 0);
}
//refresh
dataTable.setModel(model);
info();
}
}
use of org.compiere.util.TrxRunnable in project adempiere by adempiere.
the class VPayment method saveChanges.
// actionPerformed
/**************************************************************************
* Save Changes
* @return true, if Window can exit
*/
private boolean saveChanges() {
// BF [ 1920179 ] perform the save in a trx's context.
final boolean[] success = new boolean[] { false };
final TrxRunnable r = new TrxRunnable() {
public void run(String trxName) {
success[0] = saveChangesInTrx(trxName);
}
};
try {
Trx.run(r);
} catch (Throwable e) {
success[0] = false;
ADialog.error(m_WindowNo, this, "PaymentError", e.getLocalizedMessage());
}
if (m_cashLine != null)
m_cashLine.set_TrxName(null);
if (m_mPayment != null)
m_mPayment.set_TrxName(null);
if (m_mPaymentOriginal != null)
m_mPayment.set_TrxName(null);
return success[0];
}
use of org.compiere.util.TrxRunnable in project adempiere by adempiere.
the class VCreateFromDialog method actionPerformed.
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
try {
Trx.run(new TrxRunnable() {
public void run(String trxName) {
if (save(trxName)) {
dispose();
}
}
});
} catch (Exception ex) {
ADialog.error(windowNo, this, "Error", ex.getLocalizedMessage());
}
} else // Cancel
if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
dispose();
} else // Trifon
if (e.getActionCommand().equals(SELECT_ALL)) {
dataTable.selectAll();
dataTable.matchCheckWithSelectedRows();
info();
}
}
use of org.compiere.util.TrxRunnable in project adempiere by adempiere.
the class RollupWorkflow method doIt.
// prepare
protected String doIt() throws Exception {
//Get account schema
MAcctSchema accountSchema = MAcctSchema.get(getCtx(), getAccountingSchemaId());
//Get cost type
MCostType costType = MCostType.get(getCtx(), getCostTypeId());
//Get cost element to process
final List<MCostElement> costElements = getCostElementId() > 0 ? Arrays.asList(MCostElement.get(getCtx(), getCostElementId())) : MCostElement.getCostElement(getCtx(), get_TrxName());
routingService = RoutingServiceFactory.get().getRoutingService(getAD_Client_ID());
//Iterate product ids based on parameters
Arrays.stream(getProductIds()).filter(productId -> productId > 0).forEach(productId -> {
MProduct product = MProduct.get(getCtx(), productId);
log.info("Product: " + product);
int workflowId = 0;
MPPProductPlanning productPlanning = null;
if (workflowId <= 0)
workflowId = MWorkflow.getWorkflowSearchKey(product);
if (workflowId <= 0) {
productPlanning = MPPProductPlanning.find(getCtx(), getOrganizationId(), getWarehouseId(), getResourcePlantId(), product.get_ID(), get_TrxName());
if (productPlanning != null)
workflowId = productPlanning.getAD_Workflow_ID();
else
createNotice(product, "@NotFound@ @PP_Product_Planning_ID@");
}
if (workflowId <= 0)
createNotice(product, "@NotFound@ @AD_Workflow_ID@");
else {
Trx.run(new TrxRunnable() {
MAcctSchema accountSchema;
MCostType costType;
MProduct product;
MPPProductPlanning productPlanning;
int workflowId;
public TrxRunnable setParameters(MAcctSchema accountSchema, MCostType costType, MProduct product, MPPProductPlanning productPlanning, int workflowId) {
this.accountSchema = accountSchema;
this.costType = costType;
this.product = product;
this.productPlanning = productPlanning;
this.workflowId = workflowId;
return this;
}
public void run(String trxName) {
MWorkflow workflow = new MWorkflow(getCtx(), workflowId, trxName);
costElements.stream().filter(costElement -> costElement != null && CostEngine.isActivityControlElement(costElement)).forEach(costElement -> {
rollup(accountSchema, costType, costElement, product, workflow, trxName);
});
if (productPlanning != null) {
productPlanning.load(trxName);
productPlanning.setYield(workflow.getYield());
productPlanning.saveEx();
}
}
}.setParameters(accountSchema, costType, product, productPlanning, workflowId));
}
});
return "@OK@";
}
Aggregations