@POST
 @Path("view/save")
 public Response save(Request request) {
   final Map<String, Object> data = request.getData();
   final ObjectMapper om = Beans.get(ObjectMapper.class);
   try {
     final String type = (String) data.get("type");
     final String json = om.writeValueAsString(data);
     AbstractView view = null;
     switch (type) {
       case "dashboard":
         view = om.readValue(json, Dashboard.class);
         break;
     }
     if (view != null) {
       return service.saveView(view, AuthUtils.getUser());
     }
   } catch (Exception e) {
   }
   return null;
 }
  @Transactional
  public void prepareTest3() {
    final MetaSelect select = new MetaSelect();
    final MetaSelectItem item = new MetaSelectItem();

    final MetaSelectRepository selects = Beans.get(MetaSelectRepository.class);
    final ContactRepository contacts = Beans.get(ContactRepository.class);

    item.setValue("pizza");
    item.setTitle("Pizza");
    select.addItem(item);
    select.setName("food.selection");

    selects.save(select);

    Contact c = new Contact();
    c.setFirstName("John");
    c.setLastName("Smith");
    c.setEmail("*****@*****.**");
    c.setFood("pizza");

    contacts.save(c);
  }
  @Transactional(rollbackOn = {AxelorException.class, Exception.class})
  protected void generatePurchaseProposal(MrpLine mrpLine) throws AxelorException {

    Product product = mrpLine.getProduct();
    Location location = mrpLine.getLocation();
    LocalDate maturityDate = mrpLine.getMaturityDate();

    Partner supplierPartner = product.getDefaultSupplierPartner();

    if (supplierPartner == null) {
      throw new AxelorException(
          String.format(I18n.get(IExceptionMessage.MRP_LINE_1), product.getFullName()),
          IException.CONFIGURATION_ERROR);
    }

    Company company = location.getCompany();

    PurchaseOrder purchaseOrder =
        purchaseOrderRepo.save(
            purchaseOrderServiceSupplychainImpl.createPurchaseOrder(
                this.user,
                company,
                null,
                supplierPartner.getCurrency(),
                maturityDate,
                "MRP-" + this.today.toString(), // TODO sequence on mrp
                null,
                location,
                this.today,
                supplierPartner.getPurchasePriceList(),
                supplierPartner));
    Unit unit = product.getPurchasesUnit();
    BigDecimal qty = mrpLine.getQty();
    if (unit == null) {
      unit = product.getUnit();
    } else {
      qty =
          Beans.get(UnitConversionService.class)
              .convertWithProduct(product.getUnit(), unit, qty, product);
    }
    purchaseOrder.addPurchaseOrderLineListItem(
        purchaseOrderLineService.createPurchaseOrderLine(
            purchaseOrder, product, product.getName(), qty, unit));

    purchaseOrderServiceSupplychainImpl.computePurchaseOrder(purchaseOrder);
  }