Search in sources :

Example 1 with EntityItem

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);
}
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 2 with EntityItem

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);
}
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 3 with EntityItem

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);
}
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 4 with EntityItem

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

Example 5 with EntityItem

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

Aggregations

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