package com.company.demo.portal.controllers;

import com.company.demo.entity.MenuItem;
import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.cuba.core.app.DataService;
import com.haulmont.cuba.core.global.LoadContext;
import com.haulmont.cuba.core.global.Metadata;
import com.haulmont.cuba.core.global.View;
import com.haulmont.cuba.restapi.ConversionFactory;
import com.haulmont.cuba.restapi.Convertor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.inject.Inject;
import java.util.List;

@Controller
public class MenuController {

    protected Logger log = LoggerFactory.getLogger(getClass());

    @Inject
    protected ConversionFactory conversionFactory;

    @Inject
    protected DataService dataService;

    @Inject
    protected Metadata metadata;

    @CrossOrigin(origins = "*")
    @RequestMapping(value = "/menu", method = RequestMethod.GET)
    @ResponseBody
    public String menu() {
        LoadContext<MenuItem> foodLoadContext = new LoadContext<>(MenuItem.class)
            .setQuery(LoadContext.createQuery("select u from demo$MenuItem u"))
            .setView(View.LOCAL);

        List<MenuItem> entities = dataService.loadList(foodLoadContext);
        MetaClass metaClass = metadata.getClassNN(MenuItem.class);

        Convertor convertor = conversionFactory.getConvertor("json");

        try {
            return convertor.process((List) entities, metaClass, foodLoadContext.getView());
        } catch (Exception e) {
            log.error("Error converting json", e);
            return "";
        }
    }
}
@@ -407,17 +407,17 @@
 .Convert
-o
+e
 r;%0Aimpor
@@ -1582,17 +1582,17 @@
  Convert
-o
+e
 r conver
@@ -1592,17 +1592,17 @@
  convert
-o
+e
 r = conv
@@ -1625,17 +1625,17 @@
 tConvert
-o
+e
 r(%22json%22
@@ -1678,17 +1678,17 @@
  convert
-o
+e
 r.proces

Fix Converter in portal