ClassMetadata cmd = service.getClassMetadata(ppr).getDynamicResultSet().getClassMetaData();
Entity entity = service.getRecord(ppr, id, cmd, false).getDynamicResultSet().getRecords()[0];
Map<String, DynamicResultSet> subRecordsMap = service.getRecordsForAllSubCollections(ppr, entity, crumbs);
EntityForm entityForm = formService.createEntityForm(cmd, entity, subRecordsMap, crumbs);
model.addAttribute("entity", entity);
model.addAttribute("entityForm", entityForm);
model.addAttribute("currentUrl", request.getRequestURL().toString());
setModelAttributes(model, sectionKey);
if (sandBoxHelper.isSandBoxable(entityForm.getEntityType())) {
Tab auditTab = new Tab();
auditTab.setTitle("Audit");
auditTab.setOrder(Integer.MAX_VALUE);
auditTab.setTabClass("audit-tab");
entityForm.getTabs().add(auditTab);
}
if (isAjaxRequest(request)) {
entityForm.setReadOnly();
model.addAttribute("viewType", "modal/entityView");
model.addAttribute("modalHeaderType", "viewEntity");
return "modules/modalContainer";
} else {
model.addAttribute("viewType", "entityEdit");