class BadgeClassExtensionServiceImpl implements BadgeClassExtensionService {

  @Override
  public List<BadgeClassExtension> search(
      List<String> issuerList,
      List<String> badgeList,
      String rootOrgId,
      String type,
      String subtype,
      List<String> roles) {
    Map<String, Object> propertyMap = new HashMap<>();

    if (rootOrgId != null) {
      propertyMap.put(JsonKey.ROOT_ORG_ID, rootOrgId);
    }

    if (type != null) {
      propertyMap.put(JsonKey.TYPE, type);
    }

    if (subtype != null) {
      propertyMap.put(JsonKey.SUBTYPE, subtype);
    }

    Response response =
        cassandraOperation.getRecordsByProperties(
            Util.KEY_SPACE_NAME, BADGE_CLASS_EXT_TABLE_NAME, propertyMap);
    List<Map<String, Object>> badgeClassExtList =
        (List<Map<String, Object>>) response.get(JsonKey.RESPONSE);

    return badgeClassExtList
        .stream()
        .map(badgeClassExtMap -> new BadgeClassExtension(badgeClassExtMap))
        .filter(
            badgeClassExt ->
                roles == null
                    || CollectionUtils.isEmpty(badgeClassExt.getRoles())
                    || !Collections.disjoint(roles, badgeClassExt.getRoles()))
        .filter(
            badgeClassExt ->
                CollectionUtils.isEmpty(issuerList)
                    || issuerList.contains(badgeClassExt.getIssuerId()))
        .filter(
            badgeClassExt ->
                CollectionUtils.isEmpty(badgeList)
                    || badgeList.contains(badgeClassExt.getBadgeId()))
        .collect(Collectors.toList());
  }

  public  BadgeClassExtensionServiceImpl();
  public  BadgeClassExtensionServiceImpl(CassandraOperation cassandraOperation);

}