Search in sources :

Example 1 with UserRolePermissionsKey

use of org.adempiere.ad.security.UserRolePermissionsKey in project metasfresh-webui-api by metasfresh.

the class MenuRestController method getMenuTree.

private MenuTree getMenuTree() {
    final UserRolePermissionsKey userRolePermissionsKey = userSession.getUserRolePermissionsKey();
    final String adLanguage = userSession.getAD_Language();
    return menuTreeRepository.getMenuTree(userRolePermissionsKey, adLanguage);
}
Also used : UserRolePermissionsKey(org.adempiere.ad.security.UserRolePermissionsKey)

Example 2 with UserRolePermissionsKey

use of org.adempiere.ad.security.UserRolePermissionsKey in project metasfresh-webui-api by metasfresh.

the class MenuTreeLoader method getUserRolePermissions.

private IUserRolePermissions getUserRolePermissions() {
    if (_userRolePermissions == null) {
        final UserRolePermissionsKey userRolePermissionsKey = getUserRolePermissionsKey();
        _userRolePermissions = userRolePermissionsDAO.retrieveUserRolePermissions(userRolePermissionsKey);
    }
    return _userRolePermissions;
}
Also used : UserRolePermissionsKey(org.adempiere.ad.security.UserRolePermissionsKey)

Example 3 with UserRolePermissionsKey

use of org.adempiere.ad.security.UserRolePermissionsKey in project metasfresh-webui-api by metasfresh.

the class MenuTreeRepository method getUserSessionMenuTree.

public MenuTree getUserSessionMenuTree() {
    final UserRolePermissionsKey userRolePermissionsKey = userSession.getUserRolePermissionsKey();
    final String adLanguage = userSession.getAD_Language();
    return getMenuTree(userRolePermissionsKey, adLanguage);
}
Also used : UserRolePermissionsKey(org.adempiere.ad.security.UserRolePermissionsKey)

Example 4 with UserRolePermissionsKey

use of org.adempiere.ad.security.UserRolePermissionsKey in project metasfresh-webui-api by metasfresh.

the class SqlViewRowIdsOrderedSelectionFactory method createOrderedSelection.

@Override
public ViewRowIdsOrderedSelection createOrderedSelection(final ViewEvaluationCtx viewEvalCtx, final ViewId viewId, final List<DocumentFilter> filters, final List<DocumentQueryOrderBy> orderBys) {
    final UserRolePermissionsKey permissionsKey = viewEvalCtx.getPermissionsKey();
    final IUserRolePermissions permissions = Services.get(IUserRolePermissionsDAO.class).retrieveUserRolePermissions(permissionsKey);
    final int queryLimit = permissions.getConstraint(WindowMaxQueryRecordsConstraint.class).or(WindowMaxQueryRecordsConstraint.DEFAULT).getMaxQueryRecordsPerRole();
    // 
    // 
    final SqlCreateSelection sqlCreates = newSqlViewSelectionQueryBuilder().buildSqlCreateSelectionFrom(viewEvalCtx, viewId, filters, orderBys, queryLimit);
    logger.trace("Creating selection using {}", sqlCreates);
    // Create selection lines if any => insert into T_WEBUI_ViewSelectionLine
    if (sqlCreates.getSqlCreateSelectionLines() != null) {
        final SqlAndParams sqlCreateSelectionLines = sqlCreates.getSqlCreateSelectionLines();
        final Stopwatch stopwatch = Stopwatch.createStarted();
        final long linesCount = DB.executeUpdateEx(sqlCreateSelectionLines.getSql(), sqlCreateSelectionLines.getSqlParamsArray(), ITrx.TRXNAME_ThreadInherited);
        logger.trace("Created selection lines {}, linesCount={}, duration={}", viewId, linesCount, stopwatch);
    }
    // 
    // Create selection rows => insert into T_WEBUI_ViewSelection
    final long rowsCount;
    {
        final SqlAndParams sqlCreateSelection = sqlCreates.getSqlCreateSelection();
        final Stopwatch stopwatch = Stopwatch.createStarted();
        rowsCount = DB.executeUpdateEx(sqlCreateSelection.getSql(), sqlCreateSelection.getSqlParamsArray(), ITrx.TRXNAME_ThreadInherited);
        logger.trace("Created selection {}, rowsCount={}, duration={}", viewId, rowsCount, stopwatch);
    }
    return ViewRowIdsOrderedSelection.builder().setViewId(viewId).setSize(rowsCount).setOrderBys(orderBys).setQueryLimit(queryLimit).build();
}
Also used : UserRolePermissionsKey(org.adempiere.ad.security.UserRolePermissionsKey) SqlCreateSelection(de.metas.ui.web.view.descriptor.SqlViewSelectionQueryBuilder.SqlCreateSelection) SqlAndParams(de.metas.ui.web.view.descriptor.SqlAndParams) Stopwatch(com.google.common.base.Stopwatch) IUserRolePermissionsDAO(org.adempiere.ad.security.IUserRolePermissionsDAO) IUserRolePermissions(org.adempiere.ad.security.IUserRolePermissions) WindowMaxQueryRecordsConstraint(org.adempiere.ad.security.permissions.WindowMaxQueryRecordsConstraint)

Example 5 with UserRolePermissionsKey

use of org.adempiere.ad.security.UserRolePermissionsKey in project metasfresh-webui-api by metasfresh.

the class ViewEvaluationCtx method newInstanceFromCurrentContext.

public static final ViewEvaluationCtx newInstanceFromCurrentContext() {
    final Properties ctx = Env.getCtx();
    final String adLanguage = Env.getAD_Language(ctx);
    final UserRolePermissionsKey permissionsKey = UserRolePermissionsKey.of(ctx);
    return new ViewEvaluationCtx(adLanguage, permissionsKey);
}
Also used : UserRolePermissionsKey(org.adempiere.ad.security.UserRolePermissionsKey) Properties(java.util.Properties)

Aggregations

UserRolePermissionsKey (org.adempiere.ad.security.UserRolePermissionsKey)5 Stopwatch (com.google.common.base.Stopwatch)1 SqlAndParams (de.metas.ui.web.view.descriptor.SqlAndParams)1 SqlCreateSelection (de.metas.ui.web.view.descriptor.SqlViewSelectionQueryBuilder.SqlCreateSelection)1 Properties (java.util.Properties)1 IUserRolePermissions (org.adempiere.ad.security.IUserRolePermissions)1 IUserRolePermissionsDAO (org.adempiere.ad.security.IUserRolePermissionsDAO)1 WindowMaxQueryRecordsConstraint (org.adempiere.ad.security.permissions.WindowMaxQueryRecordsConstraint)1