Example usage for org.apache.commons.lang NumberUtils createBigDecimal

List of usage examples for org.apache.commons.lang NumberUtils createBigDecimal

Introduction

In this page you can find the example usage for org.apache.commons.lang NumberUtils createBigDecimal.

Prototype

public static BigDecimal createBigDecimal(String val) 

Source Link

Document

Convert a String to a BigDecimal.

Usage

From source file:org.gocom.components.coframe.framework.AppApplicationService.java

@SuppressWarnings("deprecation")
public void deleteApplicationById(String id) {
    AppApplication appApplication = AppApplication.FACTORY.create();
    appApplication.setAppid(NumberUtils.createBigDecimal(id));
    try {/*from w  w w.jav  a 2s .  c  o m*/
        getDASTemplate().deleteEntityCascade(appApplication);
    } catch (Throwable t) {
        log.error("Delete application [appid=" + appApplication.getAppid()
                + "] failure, please do the operation again or contact the sysadmin.", t);
    }

}

From source file:org.gocom.components.coframe.framework.AppFuncgroupService.java

public void deleteFuncGroupById(String id) {
    AppFuncgroup appFuncgroup = AppFuncgroup.FACTORY.create();
    appFuncgroup.setFuncgroupid(NumberUtils.createBigDecimal(id));
    try {/*w w  w. j  a va2 s .c o m*/
        getDASTemplate().deleteEntityCascade(appFuncgroup);
    } catch (Throwable t) {
        log.error("Delete funcgroup [funcgroupid=" + appFuncgroup.getFuncgroupid()
                + "] failure, please do the operation again or contact the sysadmin.", t);
    }
}

From source file:org.gocom.components.coframe.framework.AppFuncgroupService.java

public void modifyFuncGroupRelation(String funcGroupId, String targetGroupId) {
    //?currentGroup
    AppFuncgroup currentGroup = AppFuncgroup.FACTORY.create();
    currentGroup.setFuncgroupid(NumberUtils.createBigDecimal(funcGroupId));
    getDASTemplate().expandEntity(currentGroup);
    String currentAppId = currentGroup.getAppApplication().getAppid().toString();

    //targetGroup
    AppFuncgroup targetGroup = AppFuncgroup.FACTORY.create();
    targetGroup.setFuncgroupid(NumberUtils.createBigDecimal(targetGroupId));
    getDASTemplate().expandEntity(targetGroup);
    String targetAppId = targetGroup.getAppApplication().getAppid().toString();

    //?? funcGroups
    AppFuncgroup[] groups = getChildFuncGroups(currentGroup);

    //??funcGroups
    List<AppFuncgroup> updateList = new ArrayList<AppFuncgroup>();
    List<String> idList = new ArrayList<String>();
    for (AppFuncgroup funcGroup : groups) {
        //?//from   w  w  w.ja  va 2  s.c om
        if (StringUtils.equals(funcGroup.getFuncgroupid().toString(), funcGroupId)) {
            //?
            funcGroup.setAppFuncgroup(targetGroup);
            funcGroup.setFuncgroupseq(targetGroup.getFuncgroupseq() + funcGroupId + ".");
        } else {
            funcGroup.setFuncgroupseq(StringUtils.replace(funcGroup.getFuncgroupseq(),
                    currentGroup.getFuncgroupseq(), targetGroup.getFuncgroupseq() + funcGroupId + "."));
        }
        //???appid
        if (!StringUtils.equals(currentAppId, targetAppId)) {
            funcGroup.setAppApplication(targetGroup.getAppApplication());
        }
        updateList.add(funcGroup);
        idList.add(funcGroup.getFuncgroupid().toString());
    }
    targetGroup.setSubcount(
            targetGroup.getSubcount().add(NumberUtils.createBigDecimal(String.valueOf(groups.length))));
    updateList.add(targetGroup);
    try {
        //??
        getDASTemplate().updateEntityBatch(updateList.toArray(new AppFuncgroup[updateList.size()]));
        //???
        if (!StringUtils.equals(currentAppId, targetAppId)) {
            BeanFactory beanFactory = BeanFactory.newInstance();
            IAppFunctionService functionService = beanFactory.getBean("AppFunctionBean");
            String[] funcGroupIds = idList.toArray(new String[idList.size()]);
            AppFunction[] functions = functionService.getFunctionsByFuncGroupIds(funcGroupIds);
            //?
            functionService.updateResoucesBatch(functions);
        }
    } catch (Throwable t) {
        log.error("Update funcgroup failure, please do the operation again or contact the sysadmin.", t);
    }
}

From source file:org.gocom.components.coframe.framework.AppMenuService.java

public void modifyMenuRelation(String menuId, String targetMenuId) {
    //currentMenu
    AppMenu currentMenu = AppMenu.FACTORY.create();
    currentMenu.setMenuid(menuId);//from  ww  w .  jav  a 2  s .com
    getDASTemplate().expandEntity(currentMenu);

    //tagertmenu
    AppMenu targetMenu = AppMenu.FACTORY.create();
    targetMenu.setMenuid(targetMenuId);
    getDASTemplate().expandEntity(targetMenu);

    //currentMenu?
    AppMenu[] appMenus = queryChildMenu(currentMenu);

    List<AppMenu> updateList = new ArrayList<AppMenu>();
    currentMenu.setAppMenu(targetMenu);
    for (AppMenu appmenu : appMenus) {
        //currentmenuparentcurrentmenu??seq
        if (StringUtils.equals(appmenu.getMenuid(), menuId)) {
            appmenu.setAppMenu(targetMenu);
            appmenu.setMenuseq(targetMenu.getMenuseq() + menuId + ".");
        } else {
            appmenu.setMenuseq(StringUtils.replace(appmenu.getMenuseq(), currentMenu.getMenuseq(),
                    targetMenu.getMenuseq() + menuId + "."));
        }
        appmenu.setMenulevel((short) ((int) appmenu.getAppMenu().getMenulevel() + 1));
        updateList.add(appmenu);
    }
    //tagertmenusubcount
    targetMenu.setSubcount(
            targetMenu.getSubcount().add(NumberUtils.createBigDecimal(String.valueOf(appMenus.length))));
    updateList.add(targetMenu);
    //?menu
    try {
        getDASTemplate().updateEntityBatch(updateList.toArray(new AppMenu[updateList.size()]));
    } catch (Throwable t) {
        log.error("Update menus failure, please do the operation again or contact the sysadmin.", t);
    }
}