use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class ProductStockController method displayStockMoveLine.
public void displayStockMoveLine(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
if (context.get("date") != null && context.getParent().get("locationId") != null) {
LocalDate stockDate = LocalDate.parse(context.get("date").toString());
Long locationId = Long.parseLong(context.getParent().get("locationId").toString());
if (request.getContext().getParent().get("id") != null)
response.setView(ActionView.define(I18n.get("Stock Move Lines")).model(StockMoveLine.class.getName()).add("grid", "stock-move-line-all-grid").add("form", "stock-move-line-all-form").param("search-filters", "stock-move-line-filters").domain("self.product.id = :id AND (self.stockMove.fromStockLocation.id = :locationId OR self.stockMove.toStockLocation.id = :locationId) AND self.stockMove.statusSelect != :status AND (self.stockMove.estimatedDate <= :stockDate OR self.stockMove.realDate <= :stockDate)").context("id", request.getContext().getParent().get("id")).context("locationId", locationId).context("status", StockMoveRepository.STATUS_CANCELED).context("stockDate", stockDate).map());
response.setCanClose(true);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class StockMoveLineController method openTrackNumberWizard.
public void openTrackNumberWizard(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
StockMoveLine stockMoveLine = context.asType(StockMoveLine.class);
StockMove stockMove = null;
if (context.getParent() != null && context.getParent().get("_model").equals("com.axelor.apps.stock.db.StockMove")) {
stockMove = context.getParent().asType(StockMove.class);
} else if (stockMoveLine.getStockMove() != null && stockMoveLine.getStockMove().getId() != null) {
stockMove = Beans.get(StockMoveRepository.class).find(stockMoveLine.getStockMove().getId());
}
boolean _hasWarranty = false, _isPerishable = false;
if (stockMoveLine.getProduct() != null) {
_hasWarranty = stockMoveLine.getProduct().getHasWarranty();
_isPerishable = stockMoveLine.getProduct().getIsPerishable();
}
response.setView(ActionView.define(I18n.get(IExceptionMessage.TRACK_NUMBER_WIZARD_TITLE)).model(Wizard.class.getName()).add("form", "stock-move-line-track-number-wizard-form").param("popup", "reload").param("show-toolbar", "false").param("show-confirm", "false").param("width", "large").param("popup-save", "false").context("_stockMove", stockMove).context("_stockMoveLine", stockMoveLine).context("_hasWarranty", _hasWarranty).context("_isPerishable", _isPerishable).map());
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class StockMoveLineController method splitStockMoveLineByTrackingNumber.
public void splitStockMoveLineByTrackingNumber(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
if (context.get("trackingNumbers") == null) {
response.setAlert(I18n.get(IExceptionMessage.TRACK_NUMBER_WIZARD_NO_RECORD_ADDED_ERROR));
} else {
@SuppressWarnings("unchecked") LinkedHashMap<String, Object> stockMoveLineMap = (LinkedHashMap<String, Object>) context.get("_stockMoveLine");
Integer stockMoveLineId = (Integer) stockMoveLineMap.get("id");
StockMoveLine stockMoveLine = Beans.get(StockMoveLineRepository.class).find(new Long(stockMoveLineId));
@SuppressWarnings("unchecked") ArrayList<LinkedHashMap<String, Object>> trackingNumbers = (ArrayList<LinkedHashMap<String, Object>>) context.get("trackingNumbers");
Beans.get(StockMoveLineService.class).splitStockMoveLineByTrackingNumber(stockMoveLine, trackingNumbers);
response.setCanClose(true);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class AppController method configure.
public void configure(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
MetaView formView = null;
String code = (String) context.get("code");
String appName = Inflector.getInstance().camelize(code);
Model config = (Model) context.get("app" + appName);
String model = "com.axelor.apps.base.db.App" + appName;
if (config != null) {
formView = Beans.get(MetaViewRepository.class).all().filter("self.type = 'form' AND self.model = ? AND self.name like '%-config-form'", model).fetchOne();
}
if (formView == null) {
response.setFlash(I18n.get(IExceptionMessages.NO_CONFIG_REQUIRED));
} else {
response.setView(ActionView.define(I18n.get("Configure") + ": " + context.get("name")).add("form", formView.getName()).model(model).context("_showRecord", config.getId()).param("forceEdit", "true").map());
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class WkfCommonServiceImpl method evalExpression.
@Override
public Object evalExpression(Map<String, Object> varMap, String expr) {
if (Strings.isNullOrEmpty(expr)) {
return null;
}
if (expr.startsWith("${") && expr.endsWith("}")) {
expr = expr.replaceFirst("\\$\\{", "");
expr = expr.substring(0, expr.length() - 1);
}
GroovyScriptHelper helper;
if (varMap instanceof Context) {
helper = new GroovyScriptHelper((Context) varMap);
} else {
SimpleBindings simpleBindings = new SimpleBindings();
simpleBindings.putAll(varMap);
helper = new GroovyScriptHelper(simpleBindings);
}
helper.getBindings().put("$ctx", WkfContextHelper.class);
Object result = null;
try {
result = helper.eval(expr);
} catch (Exception e) {
}
log.debug("Eval expr: {}, result: {}", expr, result);
return result;
}
Aggregations