Search in sources :

Example 1 with MenuData

use of com.terran4j.commons.api2doc.controller.MenuData in project commons by terran4j.

the class DocMenuBuilder method getMenuGroup.

public MenuData getMenuGroup(ApiFolderObject folder) {
    String folderId = folder.getId();
    String folderName = folder.getName();
    MenuData menuGroup = new MenuData();
    menuGroup.setId(folderId);
    menuGroup.setIndex(folderId);
    menuGroup.setName(folderName);
    menuGroup.setFolder(true);
    menuGroup.setOrder(folder.getOrder());
    List<MenuData> children = new ArrayList<>();
    Map<String, String> mds = folder.getMds();
    if (mds != null && mds.size() > 0) {
        for (String md : mds.values()) {
            MenuData menu = getMenu(md, folderId);
            children.add(menu);
        }
    }
    List<ApiDocObject> docs = folder.getDocs();
    if (docs != null) {
        for (ApiDocObject doc : docs) {
            MenuData menu = getMenu(doc, folderId);
            children.add(menu);
        }
    }
    Collections.sort(children);
    menuGroup.setChildren(children);
    return menuGroup;
}
Also used : ArrayList(java.util.ArrayList) ApiDocObject(com.terran4j.commons.api2doc.domain.ApiDocObject) MenuData(com.terran4j.commons.api2doc.controller.MenuData)

Example 2 with MenuData

use of com.terran4j.commons.api2doc.controller.MenuData in project commons by terran4j.

the class DocMenuBuilder method getMenu.

public MenuData getMenu(ApiDocObject doc, String folderId) {
    MenuData menu = new MenuData();
    String pageId = "api-" + folderId + "-" + doc.getId();
    menu.setId(pageId);
    menu.setIndex(pageId);
    String url = getPageURL(pageId);
    menu.setUrl(url);
    menu.setFolder(false);
    menu.setName(doc.getName());
    menu.setOrder(doc.getOrder());
    return menu;
}
Also used : MenuData(com.terran4j.commons.api2doc.controller.MenuData)

Example 3 with MenuData

use of com.terran4j.commons.api2doc.controller.MenuData in project commons by terran4j.

the class DocMenuBuilder method getMenuGroups.

public List<MenuData> getMenuGroups() {
    List<MenuData> menuGroups = new ArrayList<>();
    List<ApiFolderObject> folders = apiDocService.getFolders();
    if (folders == null || folders.size() == 0) {
        return menuGroups;
    }
    for (ApiFolderObject folder : folders) {
        MenuData menuGroup = getMenuGroup(folder);
        menuGroups.add(menuGroup);
    }
    Collections.sort(menuGroups);
    return menuGroups;
}
Also used : ApiFolderObject(com.terran4j.commons.api2doc.domain.ApiFolderObject) ArrayList(java.util.ArrayList) MenuData(com.terran4j.commons.api2doc.controller.MenuData)

Example 4 with MenuData

use of com.terran4j.commons.api2doc.controller.MenuData in project commons by terran4j.

the class DocMenuBuilder method getMenu.

public MenuData getMenu(String mdFileName, String folderId) {
    int offset = mdFileName.indexOf("-");
    String orderText = mdFileName.substring(0, offset);
    int order = Integer.parseInt(orderText);
    String docName = mdFileName.substring(offset + 1, mdFileName.length() - ".md".length());
    String docId = ApiFolderObject.name2Id(mdFileName);
    MenuData menu = new MenuData();
    String pageId = "md-" + folderId + "-" + docId;
    menu.setId(pageId);
    menu.setIndex(pageId);
    String url = getPageURL(pageId);
    menu.setUrl(url);
    menu.setFolder(false);
    menu.setName(docName);
    menu.setOrder(order);
    return menu;
}
Also used : MenuData(com.terran4j.commons.api2doc.controller.MenuData)

Aggregations

MenuData (com.terran4j.commons.api2doc.controller.MenuData)4 ArrayList (java.util.ArrayList)2 ApiDocObject (com.terran4j.commons.api2doc.domain.ApiDocObject)1 ApiFolderObject (com.terran4j.commons.api2doc.domain.ApiFolderObject)1