Package com.mobius.model

Examples of com.mobius.model.ResponseEFormTemplate


            EntityManager em = MyEntityManagerFactory.getEm(request.getSession());
            Query query = em.createQuery("SELECT t FROM TblEFromTemplateE t", TblEFromTemplateE.class);
            List<TblEFromTemplateE> list = query.getResultList();
            List<ResponseEFormTemplate> results = new ArrayList<ResponseEFormTemplate>();
            for (TblEFromTemplateE template : list) {
                ResponseEFormTemplate template1 = new ResponseEFormTemplate(template);
                results.add(template1);
            }
            responseData.setSuccess(true);
            responseData.setMax(results.size());
            responseData.setData(results);
View Full Code Here


            query.setParameter("displayName","%"+ name + "%");
            query.setParameter("description","%"+ name + "%");
            List<Object[]> list = query.getResultList();
            List<ResponseEFormTemplate> results = new ArrayList<ResponseEFormTemplate>();
            for (Object[] template : list) {
                ResponseEFormTemplate template1 = new ResponseEFormTemplate();
                template1.setName((String)template[0]);
                template1.setDisplayName((String)template[1]);
                template1.setDescription((String)template[2]);
                results.add(template1);
            }
            responseData.setSuccess(true);
            responseData.setMax(results.size());
            responseData.setData(results);
View Full Code Here

            Query query = em.createQuery("SELECT t FROM TblEFromTemplateE t where t.name=:name", TblEFromTemplateE.class);
            query.setParameter("name", name);
            List<TblEFromTemplateE> list = query.getResultList();
            List<ResponseEFormTemplate> results = new ArrayList<ResponseEFormTemplate>();
            for (TblEFromTemplateE template : list) {
                ResponseEFormTemplate template1 = new ResponseEFormTemplate(template);
                results.add(template1);
            }
            responseData.setSuccess(true);
            responseData.setMax(results.size());
            responseData.setData(results);
View Full Code Here

    @RequestMapping(method = RequestMethod.POST, produces = "application/json", value = "/update")
    public
    @ResponseBody
    ResponseData update(@RequestBody ResponseEFormTemplate rtemplates, BindingResult result, HttpServletRequest request) {
        try {
            ResponseEFormTemplate rtemplate = rtemplates;//.get(0);
            EntityManager em = MyEntityManagerFactory.getEm(request.getSession());
            em.getTransaction().begin();
            Query query = em.createQuery("SELECT t FROM TblEFromTemplateE t where t.name=:name", TblEFromTemplateE.class);
            query.setParameter("name", rtemplate.getName());
            List<TblEFromTemplateE> list = query.getResultList();
            TblEFromTemplateE template = null;
            if (list.size() > 0) {
                template = list.get(0);
                TblEFormTemplateHistoryE history = new TblEFormTemplateHistoryE();
                history.setName(template.getName());
                history.setOryId(template.getId());
                history.setModifiedBy(template.getModifiedBy());
                history.setModifiedOn(template.getModifiedOn());
                history.setTemplateData(template.getTemplateData());
                history.setDisplayName(template.getDisplayName());
                history.setDescription(template.getDescription());
                history.setVersion(template.getVersion());
                em.persist(history);
                template.setVersion(rtemplate.getVersion());
                template.setTemplateData(rtemplate.getJson());
                template.setModifiedOn(new Timestamp(new Date().getTime()));
                template.setDisplayName(rtemplate.getDisplayName());
                template.setDescription(rtemplate.getDescription());
                SecurityContext context = SecurityContextHolder.getContext();
                Authentication authentication = context.getAuthentication();
                String username = "";
                if (authentication instanceof MyAuthenticationToken) {
                    MyAuthenticationToken authenticationToken = (MyAuthenticationToken) authentication;
                    username = authenticationToken.getMyUser().getDomainName();
                }
                template.setModifiedBy(username);
                em.persist(template);
                em.getTransaction().commit();
            } else {
                template = new TblEFromTemplateE();
                template.setName(rtemplate.getName());
                template.setVersion(rtemplate.getVersion());
                template.setTemplateData(rtemplate.getJson());
                template.setModifiedOn(new Timestamp(new Date().getTime()));
                template.setDisplayName(rtemplate.getDisplayName());
                template.setDescription(rtemplate.getDescription());
                SecurityContext context = SecurityContextHolder.getContext();
                Authentication authentication = context.getAuthentication();
                String username = "";
                if (authentication instanceof MyAuthenticationToken) {
                    MyAuthenticationToken authenticationToken = (MyAuthenticationToken) authentication;
                    username = authenticationToken.getMyUser().getDomainName();
                }
                template.setModifiedBy(username);
                em.persist(template);
                em.getTransaction().commit();
                em.refresh(template);
            }
            em.close();
            ResponseData responseData = new ResponseData();
            List<ResponseEFormTemplate> results = new ArrayList<ResponseEFormTemplate>();
            ResponseEFormTemplate template1 = new ResponseEFormTemplate(template);
            results.add(template1);
            responseData.setSuccess(true);
            responseData.setMax(1);
            responseData.setData(results);
            return responseData;
View Full Code Here

TOP

Related Classes of com.mobius.model.ResponseEFormTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.