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);