org.wso2.carbon.registry.core.Registry.getAverageRating()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中org.wso2.carbon.registry.core.Registry.getAverageRating方法的一些代码示例,展示了Registry.getAverageRating的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registry.getAverageRating方法的具体详情如下:
包路径:org.wso2.carbon.registry.core.Registry
类名称:Registry
方法名:getAverageRating

Registry.getAverageRating介绍

暂无

代码示例

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.registry.extensions

public static void copyRatings(Registry registry, String newPath, String path) throws RegistryException {
  float averageRating = registry.getAverageRating(path);
  registry.rateResource(newPath,
      new Float(averageRating).intValue());
}

代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl

public float getAverageRating(String uuid, String assetType) throws AppManagementException {
  float rating = 0;
  try {
    GenericArtifactManager artifactManager = AppManagerUtil.getArtifactManager(registry, assetType);
    GenericArtifact genericArtifact = artifactManager.getGenericArtifact(uuid);
    rating = registry.getAverageRating(genericArtifact.getPath());
  } catch (RegistryException e) {
    handleException("Failed to retrieve rating", e);
  }
  return rating;
}

代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl

public Set<WebApp> getTopRatedAPIs(int limit) throws AppManagementException {
  int returnLimit = 0;
  SortedSet<WebApp> apiSortedSet = new TreeSet<WebApp>(new APINameComparator());
  try {
    GenericArtifactManager artifactManager = AppManagerUtil.getArtifactManager(registry, AppMConstants.API_KEY);
    GenericArtifact[] genericArtifacts = artifactManager.getAllGenericArtifacts();
    if (genericArtifacts == null || genericArtifacts.length == 0) {
      return apiSortedSet;
    }
    for (GenericArtifact genericArtifact : genericArtifacts) {
      String status = genericArtifact.getAttribute(AppMConstants.API_OVERVIEW_STATUS);
      if (status.equals(AppMConstants.PUBLISHED)) {
        String artifactPath = genericArtifact.getPath();
        float rating = registry.getAverageRating(artifactPath);
        if (rating > AppMConstants.TOP_TATE_MARGIN && (returnLimit < limit)) {
          returnLimit++;
          apiSortedSet.add(AppManagerUtil.getAPI(genericArtifact, registry));
        }
      }
    }
  } catch (RegistryException e) {
    handleException("Failed to get top rated WebApp", e);
  }
  return apiSortedSet;
}

代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl

BigDecimal bigDecimal = new BigDecimal(registry.getAverageRating(artifactPath));
BigDecimal res = bigDecimal.setScale(1, RoundingMode.HALF_UP);
api.setRating(res.floatValue());

相关文章