當前位置: 首頁>>代碼示例>>Java>>正文


Java AnalyticsDataAPI類代碼示例

本文整理匯總了Java中org.wso2.carbon.analytics.api.AnalyticsDataAPI的典型用法代碼示例。如果您正苦於以下問題:Java AnalyticsDataAPI類的具體用法?Java AnalyticsDataAPI怎麽用?Java AnalyticsDataAPI使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AnalyticsDataAPI類屬於org.wso2.carbon.analytics.api包,在下文中一共展示了AnalyticsDataAPI類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAllEventsForDevice

import org.wso2.carbon.analytics.api.AnalyticsDataAPI; //導入依賴的package包/類
private static EventRecords getAllEventsForDevice(String tableName, String query, List<SortByField> sortByFields
        , int offset, int limit) throws AnalyticsException {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
    EventRecords eventRecords = new EventRecords();
    int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
    if (eventCount == 0) {
        eventRecords.setCount(0);
    }
    List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, offset, limit,
                                                                    sortByFields);
    List<String> recordIds = getRecordIds(resultEntries);
    AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
    eventRecords.setCount(eventCount);
    eventRecords.setList(AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response));
    return eventRecords;
}
 
開發者ID:wso2,項目名稱:carbon-device-mgt,代碼行數:18,代碼來源:DeviceEventManagementServiceImpl.java

示例2: extractTableSchema

import org.wso2.carbon.analytics.api.AnalyticsDataAPI; //導入依賴的package包/類
public static String extractTableSchema(String path, int tenantId) throws AnalyticsTableNotAvailableException,
        AnalyticsException {
    if (path == null) {
        return null;
    }
    AnalyticsDataAPI analyticsDataApi = (AnalyticsDataAPI) PrivilegedCarbonContext.getThreadLocalCarbonContext()
            .getOSGiService(AnalyticsDataAPI.class, null);
    // table schema will be something like; <col1_name> <col1_type>,<col2_name> <col2_type>
    StringBuilder sb = new StringBuilder();
    AnalyticsSchema analyticsSchema = analyticsDataApi.getTableSchema(tenantId, path);
    Map<String, ColumnDefinition> columnsMap = analyticsSchema.getColumns();
    for (Iterator<Map.Entry<String, ColumnDefinition>> iterator = columnsMap.entrySet().iterator(); iterator
            .hasNext();) {
        Map.Entry<String, ColumnDefinition> column = iterator.next();
        sb.append(column.getKey() + " " + column.getValue().getType().name() + ",");
    }

    return sb.substring(0, sb.length() - 1);
}
 
開發者ID:wso2-attic,項目名稱:carbon-ml,代碼行數:20,代碼來源:MLUtils.java

示例3: extractHeaderLine

import org.wso2.carbon.analytics.api.AnalyticsDataAPI; //導入依賴的package包/類
public static String extractHeaderLine(String path, int tenantId) throws AnalyticsTableNotAvailableException,
        AnalyticsException {
    if (path == null) {
        return null;
    }

    AnalyticsDataAPI analyticsDataApi = (AnalyticsDataAPI) PrivilegedCarbonContext.getThreadLocalCarbonContext()
            .getOSGiService(AnalyticsDataAPI.class, null);
    // header line will be something like; <col1_name>,<col2_name>
    StringBuilder sb = new StringBuilder();
    AnalyticsSchema analyticsSchema = analyticsDataApi.getTableSchema(tenantId, path);
    Map<String, ColumnDefinition> columnsMap = analyticsSchema.getColumns();
    for (String columnName : columnsMap.keySet()) {
        sb.append(columnName + ",");
    }

    return sb.substring(0, sb.length() - 1);
}
 
開發者ID:wso2-attic,項目名稱:carbon-ml,代碼行數:19,代碼來源:MLUtils.java

示例4: getAllEventsForDevice

import org.wso2.carbon.analytics.api.AnalyticsDataAPI; //導入依賴的package包/類
public static List<SensorRecord> getAllEventsForDevice(String tableName, String query,
                                                       List<SortByField> sortByFields) throws AnalyticsException {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
    int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
    // limiting the data read from the server
    int start = 0;
    int dataCount = 100;
    if (eventCount == 0) {
        return null;
    } else if (eventCount >= dataCount){
        start = eventCount - dataCount;
    }

    List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, start, eventCount,
                                                                    sortByFields);
    List<String> recordIds = getRecordIds(resultEntries);
    AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
    Map<String, SensorRecord> sensorDatas = createSensorData(AnalyticsDataAPIUtil.listRecords(
            analyticsDataAPI, response));
    List<SensorRecord> sortedSensorData = getSortedSensorData(sensorDatas, resultEntries);
    return sortedSensorData;
}
 
開發者ID:wso2,項目名稱:product-iots,代碼行數:24,代碼來源:APIUtil.java

示例5: getAllEventsForDevice

import org.wso2.carbon.analytics.api.AnalyticsDataAPI; //導入依賴的package包/類
/**
 * Get sensor data for a device.
 *
 * @param tableName    table name of the data source
 * @param query        query for the table
 * @param sortByFields list of fields to sort the data by
 * @return List of SensorRecords that is sorted by the fields provided
 * @throws AnalyticsException
 */
public static List<SensorRecord> getAllEventsForDevice(String tableName, String query,
                                                       List<SortByField> sortByFields) throws AnalyticsException {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
    int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
    if (eventCount == 0) {
        return null;
    }
    List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, 0, eventCount,
            sortByFields);
    List<String> recordIds = getRecordIds(resultEntries);
    AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
    Map<String, SensorRecord> sensorDatas = createSensorData(AnalyticsDataAPIUtil.listRecords(
            analyticsDataAPI, response));
    List<SensorRecord> sortedSensorData = getSortedSensorData(sensorDatas, resultEntries);
    return sortedSensorData;
}
 
開發者ID:wso2,項目名稱:product-iots,代碼行數:27,代碼來源:APIUtil.java

示例6: getAllEventsForDevice

import org.wso2.carbon.analytics.api.AnalyticsDataAPI; //導入依賴的package包/類
public static List<SensorRecord> getAllEventsForDevice(String tableName, String query,
                                                       List<SortByField> sortByFields) throws AnalyticsException {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
    int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
    if (eventCount == 0) {
        return null;
    }
    List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, 0, eventCount,
            sortByFields);
    List<String> recordIds = getRecordIds(resultEntries);
    AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
    Map<String, SensorRecord> sensorDatas = createSensorData(AnalyticsDataServiceUtils.listRecords(
            analyticsDataAPI, response));
    List<SensorRecord> sortedSensorData = getSortedSensorData(sensorDatas, resultEntries);
    return sortedSensorData;
}
 
開發者ID:wso2,項目名稱:product-iots,代碼行數:18,代碼來源:APIUtil.java

示例7: getEventBeans

import org.wso2.carbon.analytics.api.AnalyticsDataAPI; //導入依賴的package包/類
private List<Event> getEventBeans(AnalyticsDataAPI analyticsDataAPI, int tenantId, String tableName,
                                  List<String> columns,
                                  List<SearchResultEntry> searchResults) throws AnalyticsException {
    List<String> ids = getIds(searchResults);
    List<String> requiredColumns = (columns == null || columns.isEmpty()) ? null : columns;
    AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, requiredColumns, ids);
    List<Record> records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response);
    Map<String, Event> eventBeanMap = getEventBeanKeyedWithIds(records);
    return getSortedEventBeans(eventBeanMap, searchResults);
}
 
開發者ID:wso2,項目名稱:carbon-device-mgt,代碼行數:11,代碼來源:GeoLocationBasedServiceImpl.java

示例8: getAnalyticsDataAPI

import org.wso2.carbon.analytics.api.AnalyticsDataAPI; //導入依賴的package包/類
private static AnalyticsDataAPI getAnalyticsDataAPI() {
    PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    AnalyticsDataAPI analyticsDataAPI =
            (AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null);
    if (analyticsDataAPI == null) {
        String msg = "Analytics api service has not initialized.";
        log.error(msg);
        throw new IllegalStateException(msg);
    }
    return analyticsDataAPI;
}
 
開發者ID:wso2,項目名稱:carbon-device-mgt,代碼行數:12,代碼來源:DeviceEventManagementServiceImpl.java

示例9: getAnalyticsDataAPI

import org.wso2.carbon.analytics.api.AnalyticsDataAPI; //導入依賴的package包/類
public static AnalyticsDataAPI getAnalyticsDataAPI() {
    PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    AnalyticsDataAPI analyticsDataAPI =
            (AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null);
    if (analyticsDataAPI == null) {
        String msg = "Analytics api service has not initialized.";
        log.error(msg);
        throw new IllegalStateException(msg);
    }
    return analyticsDataAPI;
}
 
開發者ID:wso2,項目名稱:carbon-device-mgt,代碼行數:12,代碼來源:DeviceMgtAPIUtils.java

示例10: getAnalyticsDataAPI

import org.wso2.carbon.analytics.api.AnalyticsDataAPI; //導入依賴的package包/類
public static AnalyticsDataAPI getAnalyticsDataAPI() {
    PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    AnalyticsDataAPI analyticsDataAPI =
            (AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null);
    if (analyticsDataAPI == null) {
        throw new IllegalStateException("Analytics api service has not initialized");
    }
    return analyticsDataAPI;
}
 
開發者ID:wso2,項目名稱:product-iots,代碼行數:10,代碼來源:APIUtil.java

示例11: getAnalyticsDataAPI

import org.wso2.carbon.analytics.api.AnalyticsDataAPI; //導入依賴的package包/類
/**
 * @return AnalyticthsDataAPI for the context
 */
public static AnalyticsDataAPI getAnalyticsDataAPI() {
    PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    AnalyticsDataAPI analyticsDataAPI =
            (AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null);
    if (analyticsDataAPI == null) {
        String msg = "Analytics api service has not initialized.";
        log.error(msg);
        throw new IllegalStateException(msg);
    }
    return analyticsDataAPI;
}
 
開發者ID:wso2,項目名稱:product-iots,代碼行數:15,代碼來源:APIUtil.java


注:本文中的org.wso2.carbon.analytics.api.AnalyticsDataAPI類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。