use of org.springframework.roo.addon.web.mvc.views.components.EntityItem in project spring-roo by spring-projects.
the class ThymeleafViewGeneratorServiceImpl method addCreateDetailsView.
protected void addCreateDetailsView(String moduleName, JpaEntityMetadata entityMetadata, MemberDetails entity, ControllerMetadata controllerMetadata, ThymeleafMetadata viewMetadata, ViewContext<ThymeleafMetadata> ctx) {
// Process elements to generate
Document newDoc = null;
// Getting new viewName
String viewName = getViewsFolder(moduleName).concat(ctx.getControllerPath()).concat("/").concat(controllerMetadata.getDetailsPathAsString("/")).concat("/create").concat(getViewsExtension());
// Get root entity metadata
EntityItem entityItem = createEntityItem(entityMetadata, ctx, TABLE_SUFFIX);
DetailEntityItem detail = createDetailEntityItem(viewMetadata, entity, entityMetadata, ctx.getEntityName(), ctx, DETAIL_SUFFIX, entityItem);
detail.addConfigurationElement("entityLabel", StringUtils.uncapitalize(FieldItem.buildLabel(detail.getEntityName(), "")));
ctx.addExtraParameter("entity", entityItem);
ctx.addExtraParameter("detail", detail);
ctx.addExtraParameter("select2_placeholder", getCreateDetailsSelect2PlaceholderLabelKey(controllerMetadata, ctx));
// Check if new view to generate exists or not
if (existsFile(viewName)) {
Document existingDoc = loadExistingDoc(viewName);
if (!isUserManagedDocument(existingDoc)) {
newDoc = mergeCreateDetailsView("createDetail", existingDoc, ctx, entityItem, detail);
}
} else {
newDoc = process("createDetail", ctx);
}
// Write newDoc on disk
writeDoc(newDoc, viewName);
}
use of org.springframework.roo.addon.web.mvc.views.components.EntityItem in project spring-roo by spring-projects.
the class ThymeleafViewGeneratorServiceImpl method addDetailsItemViews.
@Override
public void addDetailsItemViews(String moduleName, JpaEntityMetadata entityMetadata, MemberDetails entity, ControllerMetadata controllerMetadata, ThymeleafMetadata viewMetadata, ViewContext<ThymeleafMetadata> ctx) {
super.addDetailsItemViews(moduleName, entityMetadata, entity, controllerMetadata, viewMetadata, ctx);
// Get root entity metadata
EntityItem entityItem = createEntityItem(entityMetadata, ctx, TABLE_SUFFIX);
DetailEntityItem detail = createDetailEntityItem(viewMetadata, entity, entityMetadata, ctx.getEntityName(), ctx, DETAIL_SUFFIX, entityItem);
detail.addConfigurationElement("entityLabel", StringUtils.uncapitalize(FieldItem.buildLabel(detail.getEntityName(), "")));
ViewContext<ThymeleafMetadata> childCtx = createViewContext(controllerMetadata, controllerMetadata.getLastDetailEntity(), controllerMetadata.getLastDetailsInfo().childEntityMetadata, viewMetadata);
// TODO
addShowDetailsCompositionView(moduleName, entityMetadata, viewMetadata, entityItem, detail, childCtx);
addUpdateDetailsCompositionView(moduleName, entityMetadata, viewMetadata, entityItem, detail, childCtx);
childCtx.addExtraParameter("detail", detail);
addListDeleteModalDetailView(moduleName, entityMetadata, entity, controllerMetadata, childCtx);
addListDeleteModalDetailBatchView(moduleName, entityMetadata, entity, controllerMetadata, childCtx);
}
use of org.springframework.roo.addon.web.mvc.views.components.EntityItem in project spring-roo by spring-projects.
the class ThymeleafViewGeneratorServiceImpl method addFinderFormView.
@Override
public void addFinderFormView(String moduleName, JpaEntityMetadata entityMetadata, ThymeleafMetadata viewMetadata, JavaType formBean, String finderName, ViewContext<ThymeleafMetadata> ctx) {
// Getting formBean details
MemberDetails formBeanDetails = getMemberDetailsScanner().getMemberDetails(getClass().getName(), getTypeLocationService().getTypeDetails(formBean));
// Getting entity fields that should be included on view
List<FieldMetadata> formBeanFields = getPersistentFields(formBeanDetails.getFields());
List<FieldItem> fields = getFieldViewItems(entityMetadata, formBeanFields, ctx.getEntityName(), true, ctx, TABLE_SUFFIX);
// Process elements to generate
Document newDoc = null;
// Getting new viewName
String viewName = getViewsFolder(moduleName).concat(ctx.getControllerPath()).concat("/").concat(finderName).concat("Form").concat(getViewsExtension());
EntityItem entityItem = createEntityItem(entityMetadata, ctx, TABLE_SUFFIX);
ctx.addExtraParameter("finderName", finderName.replace("findBy", "by"));
ctx.addExtraParameter("entity", entityItem);
ctx.addExtraParameter("fields", fields);
// Check if new view to generate exists or not
if (existsFile(viewName)) {
Document existingDoc = loadExistingDoc(viewName);
if (!isUserManagedDocument(existingDoc)) {
newDoc = mergeListView("finderForm", existingDoc, ctx, entityItem, fields, new ArrayList<List<DetailEntityItem>>());
}
} else {
newDoc = process("finderForm", ctx);
}
// Write newDoc on disk
writeDoc(newDoc, viewName);
}
use of org.springframework.roo.addon.web.mvc.views.components.EntityItem in project spring-roo by spring-projects.
the class ThymeleafViewGeneratorServiceImpl method addCreateDetailsCompositionView.
protected void addCreateDetailsCompositionView(String moduleName, JpaEntityMetadata entityMetadata, MemberDetails entity, ControllerMetadata controllerMetadata, ThymeleafMetadata viewMetadata, ViewContext<ThymeleafMetadata> ctx) {
// Process elements to generate
Document newDoc = null;
// Getting new viewName
String viewName = getViewsFolder(moduleName).concat(ctx.getControllerPath()).concat("/").concat(controllerMetadata.getDetailsPathAsString("/")).concat("/create").concat(getViewsExtension());
// Get root entity metadata
EntityItem entityItem = createEntityItem(entityMetadata, ctx, TABLE_SUFFIX);
DetailEntityItem detail = createDetailEntityItem(viewMetadata, entity, entityMetadata, ctx.getEntityName(), ctx, DETAIL_SUFFIX, entityItem);
ViewContext<ThymeleafMetadata> childCtx = createViewContext(controllerMetadata, controllerMetadata.getLastDetailEntity(), controllerMetadata.getLastDetailsInfo().childEntityMetadata, viewMetadata);
detail.addConfigurationElement("entityLabel", StringUtils.uncapitalize(FieldItem.buildLabel(detail.getEntityName(), "")));
childCtx.addExtraParameter("entity", entityItem);
childCtx.addExtraParameter("detail", detail);
// Check if new view to generate exists or not
if (existsFile(viewName)) {
Document existingDoc = loadExistingDoc(viewName);
if (!isUserManagedDocument(existingDoc)) {
newDoc = mergeDetailsCompositionView("createDetailComposition", existingDoc, childCtx, entityItem, detail, (List<FieldItem>) detail.getConfiguration().get("fields"));
}
} else {
childCtx.addExtraParameter("fields", detail.getConfiguration().get("fields"));
newDoc = process("createDetailComposition", childCtx);
}
// Write newDoc on disk
writeDoc(newDoc, viewName);
}
use of org.springframework.roo.addon.web.mvc.views.components.EntityItem in project spring-roo by spring-projects.
the class ThymeleafViewGeneratorServiceImpl method addDetailsViews.
@Override
public void addDetailsViews(String moduleName, JpaEntityMetadata entityMetadata, MemberDetails entity, ControllerMetadata controllerMetadata, ThymeleafMetadata viewMetadata, ViewContext<ThymeleafMetadata> ctx) {
super.addDetailsViews(moduleName, entityMetadata, entity, controllerMetadata, viewMetadata, ctx);
// Get root entity metadata
EntityItem entityItem = createEntityItem(entityMetadata, ctx, TABLE_SUFFIX);
DetailEntityItem detail = createDetailEntityItem(viewMetadata, entity, entityMetadata, ctx.getEntityName(), ctx, DETAIL_SUFFIX, entityItem);
detail.addConfigurationElement("entityLabel", StringUtils.uncapitalize(FieldItem.buildLabel(detail.getEntityName(), "")));
if (controllerMetadata.getLastDetailsInfo().type == JpaRelationType.AGGREGATION) {
addCreateDetailsView(moduleName, entityMetadata, entity, controllerMetadata, viewMetadata, ctx);
} else {
addCreateDetailsCompositionView(moduleName, entityMetadata, entity, controllerMetadata, viewMetadata, ctx);
}
ctx.addExtraParameter("detail", detail);
addListDeleteModalDetailView(moduleName, entityMetadata, entity, controllerMetadata, ctx);
addListDeleteModalDetailBatchView(moduleName, entityMetadata, entity, controllerMetadata, ctx);
}
Aggregations