Java Code Examples for org.apache.commons.collections4.MapUtils#getInteger()

The following examples show how to use org.apache.commons.collections4.MapUtils#getInteger() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SysPermissionServiceImpl.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@Override
	public PageResult<SysPermission> findPermissions(Map<String, Object> params) {
		//设置分页信息,分别是当前页数和每页显示的总记录数【记住:必须在mapper接口中的方法执行之前设置该分页信息】
		if (MapUtils.getInteger(params, "page")!=null && MapUtils.getInteger(params, "limit")!=null)
			PageHelper.startPage(MapUtils.getInteger(params, "page"),MapUtils.getInteger(params, "limit"),true);
		List<SysPermission> list  = sysPermissionDao.findList(params);
		PageInfo<SysPermission> pageInfo = new PageInfo(list);

		return PageResult.<SysPermission>builder().data(pageInfo.getList()).code(0).count(pageInfo.getTotal()).build()  ;

//		int total = sysPermissionDao.count(params);
//		List<SysPermission> list = Collections.emptyList();
//
//		if (total > 0) {
//			PageUtil.pageParamConver(params, false);
//			list = sysPermissionDao.findList(params);
//
//		}
//		return PageResult.<SysPermission>builder().data(list).code(0).count((long)total).build()  ;
	}
 
Example 2
Source File: SysRoleServiceImpl.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@Override
public PageResult<SysRole> findRoles(Map<String, Object> params) {
	//设置分页信息,分别是当前页数和每页显示的总记录数【记住:必须在mapper接口中的方法执行之前设置该分页信息】
	if (MapUtils.getInteger(params, "page")!=null && MapUtils.getInteger(params, "limit")!=null)
		PageHelper.startPage(MapUtils.getInteger(params, "page"),MapUtils.getInteger(params, "limit"),true);
	List<SysRole> list =  sysRoleDao.findList(params);
	PageInfo<SysRole> pageInfo = new PageInfo(list);

	return PageResult.<SysRole>builder().data(pageInfo.getList()).code(0).count(pageInfo.getTotal()).build()  ;

	/*int total = sysRoleDao.count(params);
	List<SysRole> list = Collections.emptyList();
	if (total > 0) {
		PageUtil.pageParamConver(params, false);

		list = sysRoleDao.findList(params);
	}
	return PageResult.<SysRole>builder().data(list).code(0).count((long)total).build()  ;*/
}
 
Example 3
Source File: DimensionAnalysisPipeline.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * Alternate constructor for use by RCAFrameworkLoader
 *
 * @param outputName pipeline output name
 * @param inputNames input pipeline names
 * @param properties configuration properties ({@code PROP_K}, {@code PROP_PARALLELISM})
 */
public DimensionAnalysisPipeline(String outputName, Set<String> inputNames, Map<String, Object> properties) {
  super(outputName, inputNames);
  this.metricDAO = DAORegistry.getInstance().getMetricConfigDAO();
  this.datasetDAO = DAORegistry.getInstance().getDatasetConfigDAO();
  this.cache = ThirdEyeCacheRegistry.getInstance().getQueryCache();
  this.executor = Executors.newFixedThreadPool(MapUtils.getInteger(properties, PROP_PARALLELISM, PROP_PARALLELISM_DEFAULT));
  this.k = MapUtils.getInteger(properties, PROP_K, PROP_K_DEFAULT);
}
 
Example 4
Source File: MetricBreakdownPipeline.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * Alternate constructor for use by RCAFrameworkLoader
 * @param outputName pipeline output name
 * @param inputNames input pipeline names
 * @param properties configuration properties ({@code PROP_K}, {@code PROP_PARALLELISM})
 */
public MetricBreakdownPipeline(String outputName, Set<String> inputNames, Map<String, Object> properties) {
  super(outputName, inputNames);
  this.metricDAO = DAORegistry.getInstance().getMetricConfigDAO();
  this.datasetDAO = DAORegistry.getInstance().getDatasetConfigDAO();
  this.cache = ThirdEyeCacheRegistry.getInstance().getQueryCache();
  this.executor = Executors.newFixedThreadPool(MapUtils.getInteger(properties, PROP_PARALLELISM, PROP_PARALLELISM_DEFAULT));
  this.k = MapUtils.getInteger(properties, PROP_K, PROP_K_DEFAULT);

  if (properties.containsKey(PROP_INCLUDE_DIMENSIONS)) {
    this.includeDimensions = new HashSet<>((Collection<String>) properties.get(PROP_INCLUDE_DIMENSIONS));
  } else {
    this.includeDimensions = new HashSet<>();
  }

  if (properties.containsKey(PROP_EXCLUDE_DIMENSIONS)) {
    this.excludeDimensions = new HashSet<>((Collection<String>) properties.get(PROP_EXCLUDE_DIMENSIONS));
  } else {
    this.excludeDimensions = new HashSet<>();
  }

  if (properties.containsKey(PROP_IGNORE_SCORE)) {
    this.ignoreScore = PROP_IGNORE_SCORE_TRUE;
  } else {
    this.ignoreScore = PROP_IGNORE_SCORE_FALSE;
  }
}
 
Example 5
Source File: MetricComponentAnalysisPipeline.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * Alternate constructor for use by RCAFrameworkLoader
 *
 * @param outputName pipeline output name
 * @param inputNames input pipeline names
 * @param properties configuration properties ({@code PROP_K}, {@code PROP_PARALLELISM}, {@code PROP_EXCLUDE_DIMENSIONS})
 */
public MetricComponentAnalysisPipeline(String outputName, Set<String> inputNames, Map<String, Object> properties) {
  super(outputName, inputNames);
  this.metricDAO = DAORegistry.getInstance().getMetricConfigDAO();
  this.datasetDAO = DAORegistry.getInstance().getDatasetConfigDAO();
  this.cache = ThirdEyeCacheRegistry.getInstance().getQueryCache();
  this.executor = Executors.newFixedThreadPool(MapUtils.getInteger(properties, PROP_PARALLELISM, PROP_PARALLELISM_DEFAULT));
  this.k = MapUtils.getInteger(properties, PROP_K, PROP_K_DEFAULT);

  if (properties.containsKey(PROP_EXCLUDE_DIMENSIONS)) {
    this.excludeDimensions = new HashSet<>((Collection<String>) properties.get(PROP_EXCLUDE_DIMENSIONS));
  } else {
    this.excludeDimensions = PROP_EXCLUDE_DIMENSIONS_DEFAULT;
  }
}
 
Example 6
Source File: ThirdEyeEventsPipeline.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * Alternate constructor for RCAFrameworkLoader
 *
 * @param outputName pipeline output name
 * @param inputNames input pipeline names
 * @param properties configuration properties ({@code PROP_STRATEGY})
 */
public ThirdEyeEventsPipeline(String outputName, Set<String> inputNames, Map<String, Object> properties) {
  super(outputName, inputNames);
  this.eventDAO = DAORegistry.getInstance().getEventDAO();
  this.strategy = StrategyType.valueOf(MapUtils.getString(properties, PROP_STRATEGY, PROP_STRATEGY_DEFAULT));
  this.eventType = MapUtils.getString(properties, PROP_EVENT_TYPE, "holiday");
  this.k = MapUtils.getInteger(properties, PROP_K, PROP_K_DEFAULT);
}
 
Example 7
Source File: EntityMappingPipeline.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * Alternate constructor for use by RCAFrameworkLoader
 *
 * @param outputName pipeline output name
 * @param inputNames input pipeline names
 * @param properties configuration properties ({@code PROP_MAPPING_TYPE}, {@code PROP_IS_REWRITER=false}, {@code PROP_MATCH_PREFIX=false}, {@code PROP_IS_COLLECTOR=false}, {@code PROP_DIRECTION=REGULAR}, {@code PROP_ITERATIONS=1})
 */
public EntityMappingPipeline(String outputName, Set<String> inputNames, Map<String, Object> properties) throws IOException {
  super(outputName, inputNames);

  this.entityDAO = DAORegistry.getInstance().getEntityToEntityMappingDAO();
  this.isRewriter = MapUtils.getBoolean(properties, PROP_IS_REWRITER, PROP_IS_REWRITER_DEFAULT);
  this.matchPrefix = MapUtils.getBoolean(properties, PROP_MATCH_PREFIX, PROP_MATCH_PREFIX_DEFAULT);
  this.isCollector = MapUtils.getBoolean(properties, PROP_IS_COLLECTOR, PROP_IS_COLLECTOR_DEFAULT);
  this.direction = MapUtils.getString(properties, PROP_DIRECTION, PROP_DIRECTION_DEFAULT);
  this.iterations = MapUtils.getInteger(properties, PROP_ITERATIONS, PROP_ITERATIONS_DEFAULT);

  if (!Arrays.asList(PROP_DIRECTION_REGULAR, PROP_DIRECTION_REVERSE, PROP_DIRECTION_BOTH).contains(this.direction)) {
    throw new IllegalArgumentException(String.format("Unknown direction '%s'", this.direction));
  }

  if (properties.containsKey(PROP_INPUT_FILTERS)) {
    this.inputFilters = new HashSet<>((Collection<String>) properties.get(PROP_INPUT_FILTERS));
  } else {
    this.inputFilters = new HashSet<>();
  }

  if (properties.containsKey(PROP_OUTPUT_FILTERS)) {
    this.outputFilters = new HashSet<>((Collection<String>) properties.get(PROP_OUTPUT_FILTERS));
  } else {
    this.outputFilters = new HashSet<>();
  }
}
 
Example 8
Source File: PinotThirdEyeDataSourceConfig.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * Returns PinotThirdEyeDataSourceConfig from the given property map.
 *
 * @param properties the properties to setup a PinotThirdEyeDataSourceConfig.
 *
 * @return a PinotThirdEyeDataSourceConfig.
 *
 * @throws IllegalArgumentException is thrown if the property map does not contain all necessary fields, i.e.,
 *                                  controller host and port, cluster name, and the URL to zoo keeper.
 */
static PinotThirdEyeDataSourceConfig createFromProperties(Map<String, Object> properties) {
  ImmutableMap<String, Object> processedProperties = processPropertyMap(properties);
  if (processedProperties == null) {
    throw new IllegalArgumentException(
        "Invalid properties for data source: " + PinotThirdEyeDataSource.DATA_SOURCE_NAME + ", properties="
            + properties);
  }

  String controllerHost = MapUtils.getString(processedProperties, PinotThirdeyeDataSourceProperties.CONTROLLER_HOST.getValue());
  int controllerPort = MapUtils.getInteger(processedProperties, PinotThirdeyeDataSourceProperties.CONTROLLER_PORT.getValue());
  String controllerConnectionScheme = MapUtils.getString(processedProperties, PinotThirdeyeDataSourceProperties.CONTROLLER_CONNECTION_SCHEME.getValue());
  String zookeeperUrl = MapUtils.getString(processedProperties, PinotThirdeyeDataSourceProperties.ZOOKEEPER_URL.getValue());
  String clusterName = MapUtils.getString(processedProperties, PinotThirdeyeDataSourceProperties.CLUSTER_NAME.getValue());

  // brokerUrl and tag are optional
  String brokerUrl = MapUtils.getString(processedProperties, PinotThirdeyeDataSourceProperties.BROKER_URL.getValue());
  String tag = MapUtils.getString(processedProperties, PinotThirdeyeDataSourceProperties.TAG.getValue());

  Builder builder =
      PinotThirdEyeDataSourceConfig.builder().setControllerHost(controllerHost).setControllerPort(controllerPort)
          .setZookeeperUrl(zookeeperUrl).setClusterName(clusterName);
  if (StringUtils.isNotBlank(brokerUrl)) {
    builder.setBrokerUrl(brokerUrl);
  }
  if (StringUtils.isNotBlank(tag)) {
    builder.setTag(tag);
  }
  if (StringUtils.isNotBlank(controllerConnectionScheme)) {
    builder.setControllerConnectionScheme(controllerConnectionScheme);
  }

  return builder.build();
}
 
Example 9
Source File: Paginator.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
/**
 * @param context
 * @param viewSizeName
 * @return value of viewSizeName in context map (as an int) or return
 *         default value from widget.properties
 */
public static Integer getViewSize(Map<String, ? extends Object> context, String viewSizeName) {
    int defaultSize = UtilProperties.getPropertyAsInteger("widget", "widget.form.defaultViewSize", 20);
    if (context.containsKey(viewSizeName)) {
        return MapUtils.getInteger(context, viewSizeName, defaultSize);
    }
    return defaultSize;
}
 
Example 10
Source File: SysRoleServiceImpl.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Override
public PageResult<SysRole> findRoles(Map<String, Object> params) {
    Integer curPage = MapUtils.getInteger(params, "page");
    Integer limit = MapUtils.getInteger(params, "limit");
    Page<SysRole> page = new Page<>(curPage == null ? 0 : curPage, limit == null ? -1 : limit);
    List<SysRole> list = baseMapper.findList(page, params);
    return PageResult.<SysRole>builder().data(list).code(0).count(page.getTotal()).build();
}
 
Example 11
Source File: SysUserServiceImpl.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Override
public PageResult<SysUser> findUsers(Map<String, Object> params) {
    Page<SysUser> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
    List<SysUser> list = baseMapper.findList(page, params);
    long total = page.getTotal();
    if (total > 0) {
        List<Long> userIds = list.stream().map(SysUser::getId).collect(Collectors.toList());

        List<SysRole> sysRoles = roleUserService.findRolesByUserIds(userIds);
        list.forEach(u -> u.setRoles(sysRoles.stream().filter(r -> !ObjectUtils.notEqual(u.getId(), r.getUserId()))
                .collect(Collectors.toList())));
    }
    return PageResult.<SysUser>builder().data(list).code(0).count(total).build();
}
 
Example 12
Source File: SysGeneratorServiceImpl.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Override
public PageResult<Map<String, Object>> queryList(Map<String, Object> map) {
    Page<Map<String, Object>> page = new Page<>(MapUtils.getInteger(map, "page"), MapUtils.getInteger(map, "limit"));

    List<Map<String, Object>> list = sysGeneratorMapper.queryList(page, map);
    return PageResult.<Map<String, Object>>builder().data(list).code(0).count(page.getTotal()).build();
}
 
Example 13
Source File: ClientServiceImpl.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Override
public PageResult<Client> listClient(Map<String, Object> params, boolean isPage) {
    Page<Client> page;
    if (isPage) {
        page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
    } else {
        page = new Page<>(1, -1);
    }
    List<Client> list = baseMapper.findList(page, params);
    page.setRecords(list);
    return PageResult.<Client>builder().data(list).code(0).count(page.getTotal()).build();
}
 
Example 14
Source File: RedisTokensServiceImpl.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Override
public PageResult<TokenVo> listTokens(Map<String, Object> params, String clientId) {
    Integer page = MapUtils.getInteger(params, "page");
    Integer limit = MapUtils.getInteger(params, "limit");
    int[] startEnds = PageUtil.transToStartEnd(page, limit);
    //根据请求参数生成redis的key
    String redisKey = getRedisKey(params, clientId);
    long size = redisRepository.length(redisKey);
    List<TokenVo> result = new ArrayList<>(limit);
    //查询token集合
    List<Object> tokenObjs = redisRepository.getList(redisKey, startEnds[0], startEnds[1]-1);
    if (tokenObjs != null) {
        for (Object obj : tokenObjs) {
            DefaultOAuth2AccessToken accessToken = (DefaultOAuth2AccessToken)obj;
            //构造token对象
            TokenVo tokenVo = new TokenVo();
            tokenVo.setTokenValue(accessToken.getValue());
            tokenVo.setExpiration(accessToken.getExpiration());

            //获取用户信息
            Object authObj = redisRepository.get(SecurityConstants.REDIS_TOKEN_AUTH + accessToken.getValue());
            OAuth2Authentication authentication = (OAuth2Authentication)authObj;
            if (authentication != null) {
                OAuth2Request request = authentication.getOAuth2Request();
                tokenVo.setUsername(authentication.getName());
                tokenVo.setClientId(request.getClientId());
                tokenVo.setGrantType(request.getGrantType());
            }

            result.add(tokenVo);
        }
    }
    return PageResult.<TokenVo>builder().data(result).code(0).count(size).build();
}
 
Example 15
Source File: PageUtil.java    From cloud-service with MIT License 5 votes vote down vote up
/**
 * 转换并校验分页参数<br>
 * mybatis中limit #{start, JdbcType=INTEGER}, #{length,
 * JdbcType=INTEGER}里的类型转换貌似失效<br>
 * 我们这里先把他转成Integer的类型
 * 
 * @param params
 * @param required
 *            分页参数是否是必填
 */
public static void pageParamConver(Map<String, Object> params, boolean required) {
	if (required) {// 分页参数必填时,校验参数
		if (params == null || !params.containsKey(START) || !params.containsKey(LENGTH)) {
			throw new IllegalArgumentException("请检查分页参数," + START + "," + LENGTH);
		}
	}

	if (!CollectionUtils.isEmpty(params)) {
		if (params.containsKey(START)) {
			Integer start = MapUtils.getInteger(params, START);
			if (start < 0) {
				log.error("start:{},重置为0", start);
				start = 0;
			}
			params.put(START, start);
		}

		if (params.containsKey(LENGTH)) {
			Integer length = MapUtils.getInteger(params, LENGTH);
			if (length < 0) {
				log.error("length:{},重置为0", length);
				length = 0;
			}
			params.put(LENGTH, length);
		}
	}
}
 
Example 16
Source File: AbstractIFileService.java    From microservices-platform with Apache License 2.0 4 votes vote down vote up
@Override
public PageResult<FileInfo> findList(Map<String, Object> params) {
    Page<FileInfo> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
    List<FileInfo> list = baseMapper.findList(page, params);
    return PageResult.<FileInfo>builder().data(list).code(0).count(page.getTotal()).build();
}
 
Example 17
Source File: AnomalyEventsPipeline.java    From incubator-pinot with Apache License 2.0 3 votes vote down vote up
/**
 * Alternate constructor for use by RCAFrameworkLoader
 *
 * @param outputName pipeline output name
 * @param inputNames input pipeline names
 * @param properties configuration properties ({@code PROP_K}, {@code PROP_STRATEGY})
 */
public AnomalyEventsPipeline(String outputName, Set<String> inputNames, Map<String, Object> properties) {
  super(outputName, inputNames);
  this.anomalyDAO = DAORegistry.getInstance().getMergedAnomalyResultDAO();
  this.strategy = StrategyType.valueOf(MapUtils.getString(properties, PROP_STRATEGY, PROP_STRATEGY_DEFAULT));
  this.k = MapUtils.getInteger(properties, PROP_K, PROP_K_DEFAULT);
}
 
Example 18
Source File: Paginator.java    From scipio-erp with Apache License 2.0 2 votes vote down vote up
/**
 * @param context
 * @param viewIndexName
 * @param defaultValue
 * @return value of viewIndexName in context map (as an int) or return defaultValue
 */
public static Integer getViewIndex(final Map<String, ? extends Object> context, final String viewIndexName, final int defaultValue) {
    return MapUtils.getInteger(context, viewIndexName, defaultValue);
}