Search in sources :

Example 1 with DetailEntityItem

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;
}
Also used : RooJavaType(org.springframework.roo.model.RooJavaType) JavaType(org.springframework.roo.model.JavaType) DetailEntityItem(org.springframework.roo.addon.web.mvc.views.components.DetailEntityItem) ControllerType(org.springframework.roo.addon.web.mvc.controller.annotations.ControllerType)

Example 2 with DetailEntityItem

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);
}
Also used : DetailEntityItem(org.springframework.roo.addon.web.mvc.views.components.DetailEntityItem) Document(org.jsoup.nodes.Document) EntityItem(org.springframework.roo.addon.web.mvc.views.components.EntityItem) DetailEntityItem(org.springframework.roo.addon.web.mvc.views.components.DetailEntityItem)

Example 3 with DetailEntityItem

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);
}
Also used : DetailEntityItem(org.springframework.roo.addon.web.mvc.views.components.DetailEntityItem) EntityItem(org.springframework.roo.addon.web.mvc.views.components.EntityItem) DetailEntityItem(org.springframework.roo.addon.web.mvc.views.components.DetailEntityItem)

Example 4 with DetailEntityItem

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);
}
Also used : FieldMetadata(org.springframework.roo.classpath.details.FieldMetadata) DetailEntityItem(org.springframework.roo.addon.web.mvc.views.components.DetailEntityItem) ArrayList(java.util.ArrayList) MemberDetails(org.springframework.roo.classpath.scanner.MemberDetails) FieldItem(org.springframework.roo.addon.web.mvc.views.components.FieldItem) Document(org.jsoup.nodes.Document) EntityItem(org.springframework.roo.addon.web.mvc.views.components.EntityItem) DetailEntityItem(org.springframework.roo.addon.web.mvc.views.components.DetailEntityItem)

Example 5 with DetailEntityItem

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);
}
Also used : DetailEntityItem(org.springframework.roo.addon.web.mvc.views.components.DetailEntityItem) ArrayList(java.util.ArrayList) List(java.util.List) Document(org.jsoup.nodes.Document) EntityItem(org.springframework.roo.addon.web.mvc.views.components.EntityItem) DetailEntityItem(org.springframework.roo.addon.web.mvc.views.components.DetailEntityItem)

Aggregations

DetailEntityItem (org.springframework.roo.addon.web.mvc.views.components.DetailEntityItem)11 EntityItem (org.springframework.roo.addon.web.mvc.views.components.EntityItem)8 ArrayList (java.util.ArrayList)5 Document (org.jsoup.nodes.Document)5 FieldMetadata (org.springframework.roo.classpath.details.FieldMetadata)5 List (java.util.List)4 FieldItem (org.springframework.roo.addon.web.mvc.views.components.FieldItem)4 MemberDetails (org.springframework.roo.classpath.scanner.MemberDetails)4 JavaType (org.springframework.roo.model.JavaType)4 RooJavaType (org.springframework.roo.model.RooJavaType)4 RepositoryJpaMetadata (org.springframework.roo.addon.layers.repository.jpa.addon.RepositoryJpaMetadata)2 ClassOrInterfaceTypeDetails (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)2 JdkJavaType (org.springframework.roo.model.JdkJavaType)2 JpaJavaType (org.springframework.roo.model.JpaJavaType)2 Jsr303JavaType (org.springframework.roo.model.Jsr303JavaType)2 SpringJavaType (org.springframework.roo.model.SpringJavaType)2 SpringletsJavaType (org.springframework.roo.model.SpringletsJavaType)2 Element (org.jsoup.nodes.Element)1 JpaEntityMetadata (org.springframework.roo.addon.jpa.addon.entity.JpaEntityMetadata)1 ControllerMetadata (org.springframework.roo.addon.web.mvc.controller.addon.ControllerMetadata)1