use of org.springframework.roo.addon.web.mvc.views.components.DetailEntityItem in project spring-roo by spring-projects.
the class ThymeleafViewGeneratorServiceImpl method createDetailEntityItem.
@Override
protected DetailEntityItem createDetailEntityItem(ThymeleafMetadata detailController, MemberDetails entityMembers, JpaEntityMetadata entityMetadata, String entityName, ViewContext<ThymeleafMetadata> ctx, String detailSuffix, EntityItem rootEntity) {
JavaType detailItemController;
JavaType detailCollectionController;
final ControllerType type = detailController.getControllerMetadata().getType();
if (type == ControllerType.DETAIL) {
detailCollectionController = detailController.getDestination();
detailItemController = detailController.getDetailItemController();
} else {
detailCollectionController = detailController.getDetailCollectionController();
detailItemController = detailController.getDestination();
}
JavaType itemController = detailController.getItemController();
JavaType relatedCollectionController = detailController.getRelatedCollectionController();
JavaType relatedItemController = detailController.getRelatedItemController();
DetailEntityItem item = super.createDetailEntityItem(detailController, entityMembers, entityMetadata, entityName, ctx, detailSuffix, rootEntity);
item.addConfigurationElement("mvcDetailControllerName", detailController.getMvcControllerName());
item.addConfigurationElement("mvcDetailItemControllerName", detailItemController.getSimpleTypeName());
item.addConfigurationElement("mvcDetailCollectionControllerName", detailCollectionController.getSimpleTypeName());
if (relatedItemController != null) {
item.addConfigurationElement("select2MethodName", ThymeleafMetadata.SELECT2_METHOD_NAME);
item.addConfigurationElement("select2ControllerName", relatedCollectionController.getSimpleTypeName());
}
return item;
}
use of org.springframework.roo.addon.web.mvc.views.components.DetailEntityItem 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.DetailEntityItem 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.DetailEntityItem 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.DetailEntityItem 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);
}
Aggregations