Examples of TblEFromTemplateE


Examples of com.mobius.model.entity.TblEFromTemplateE

            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();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.