当前位置: 首页>>代码示例>>Java>>正文


Java DataSource类代码示例

本文整理汇总了Java中org.md2k.datakitapi.source.datasource.DataSource的典型用法代码示例。如果您正苦于以下问题:Java DataSource类的具体用法?Java DataSource怎么用?Java DataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DataSource类属于org.md2k.datakitapi.source.datasource包,在下文中一共展示了DataSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createJSONHeader

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
private Gson createJSONHeader(JsonWriter writer, DataSource ds, UserInfo userInfo, StudyInfo studyInfo) throws IOException {
    CerebralCortexDataPackage header = generateCerebralCortexHeader(userInfo, studyInfo, ds);

    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    writer.beginObject();
    writer.name("userinfo");
    gson.toJson(header.userinfo, UserInfo.class, writer);
    writer.name("studyinfo");
    gson.toJson(header.studyinfo, StudyInfo.class, writer);
    writer.name("datasource");
    gson.toJson(header.datasource, DataSource.class, writer);

    writer.name("data");
    writer.beginArray();
    return gson;
}
 
开发者ID:MD2Korg,项目名称:DataExporter,代码行数:17,代码来源:DataExport.java

示例2: generateGzipJSON

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
/**
 * Generate a Gzipped JSON byte array
 *
 * @param result List of data items
 * @param ds     DataSource object
 * @return byte array representing a Gzipped JSON representation of the CerebralCortexDataPackage object
 */
private ByteOutputArray generateGzipJSON(UserInfo ui, StudyInfo si, DataSource ds, Iterator iter, boolean segmentData) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    boolean additionalData = false;
    try {
        GZIPOutputStream gzip = new GZIPOutputStream(bos);
        OutputStreamWriter osw = new OutputStreamWriter(gzip, StandardCharsets.UTF_8);
        JsonWriter writer = new JsonWriter(osw);
        writer.setIndent("  ");
        createJSONHeader(writer, ds, ui, si);
        additionalData = createJSONDataRepresentation(writer, iter, segmentData);
        createJSONFooter(writer);
        writer.close();
        osw.close();
        gzip.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

    return new ByteOutputArray(bos.toByteArray(), additionalData);
}
 
开发者ID:MD2Korg,项目名称:DataExporter,代码行数:28,代码来源:DataExport.java

示例3: publishGzipJSONData

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
/**
 * Upload method for publishing data to the Cerebral Cortex webservice
 *
 * @param request URL
 * @param id      of the datastream to publish
 */
public boolean publishGzipJSONData(String request, Integer id) {
    DataSource ds = getDataSource(id);
    UserInfo userInfo = getUserInfo();
    StudyInfo studyInfo = getStudyInfo();

    SQLiteIterator sqli = new SQLiteIterator(statement, id, PUBLISH_BUFFER_SIZE);

    boolean success = false;
    ByteOutputArray boa;
    int count = 0;
    do {
        System.out.print("Iteration: " + count++ + " ... ");
        boa = generateGzipJSON(userInfo, studyInfo, ds, sqli, true);
        success = publishData(request, boa.data);
        System.out.println("Done");
        if (!success) {
            return success;
        }
    } while (boa.additionalData);
    return success;
}
 
开发者ID:MD2Korg,项目名称:DataExporter,代码行数:28,代码来源:DataExport.java

示例4: register

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
public PendingResult<DataSourceClient> register(final DataSourceBuilder dataSourceBuilder) throws DataKitException {
    PendingResult<DataSourceClient> pendingResult = new PendingResult<DataSourceClient>() {
        @Override
        public DataSourceClient await() {
            try {
                registerData = null;
                lock();
                DataSource dataSource = prepareDataSource(dataSourceBuilder);
                Bundle bundle = new Bundle();
                bundle.putParcelable(DataSource.class.getSimpleName(), dataSource);
                prepareAndSend(bundle, MessageType.REGISTER);
                semaphoreReceive.tryAcquire(WAIT_TIME, TimeUnit.MILLISECONDS);
            } catch (Exception e) {
                registerData = null;
            } finally {
                unlock();
            }
            return registerData;
        }
    };
    return pendingResult;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKitAPI,代码行数:23,代码来源:DataKitAPIExecute.java

示例5: find

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
public PendingResult<ArrayList<DataSourceClient>> find(final DataSourceBuilder dataSourceBuilder) throws DataKitException {
    PendingResult<ArrayList<DataSourceClient>> pendingResult = new PendingResult<ArrayList<DataSourceClient>>() {
        @Override
        public ArrayList<DataSourceClient> await() {
            try {
                findData = null;
                lock();
                final DataSource dataSource = dataSourceBuilder.build();
                Bundle bundle = new Bundle();
                bundle.putParcelable(DataSource.class.getSimpleName(), dataSource);
                prepareAndSend(bundle, MessageType.FIND);
                semaphoreReceive.tryAcquire(WAIT_TIME, TimeUnit.MILLISECONDS);
            } catch (Exception e) {
                findData = null;
            } finally {
                unlock();
            }
            return findData;
        }
    };
    return pendingResult;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKitAPI,代码行数:23,代码来源:DataKitAPIExecute.java

示例6: prepareSelectionArgs

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
private synchronized String[] prepareSelectionArgs(DataSource dataSource) {
    ArrayList<String> selectionArgs = new ArrayList<>();
    if (dataSource.getId() != null) selectionArgs.add(dataSource.getId());
    if (dataSource.getType() != null) selectionArgs.add(dataSource.getType());
    if (dataSource.getPlatform() != null && dataSource.getPlatform().getId() != null)
        selectionArgs.add(dataSource.getPlatform().getId());
    if (dataSource.getPlatform() != null && dataSource.getPlatform().getType() != null)
        selectionArgs.add(dataSource.getPlatform().getType());
    if (dataSource.getPlatformApp() != null && dataSource.getPlatformApp().getId() != null)
        selectionArgs.add(dataSource.getPlatformApp().getId());
    if (dataSource.getPlatformApp() != null && dataSource.getPlatformApp().getType() != null)
        selectionArgs.add(dataSource.getPlatformApp().getType());
    if (dataSource.getApplication() != null && dataSource.getApplication().getId() != null)
        selectionArgs.add(dataSource.getApplication().getId());
    if (dataSource.getApplication() != null && dataSource.getApplication().getType() != null)
        selectionArgs.add(dataSource.getApplication().getType());
    if (selectionArgs.size() == 0) return null;
    return selectionArgs.toArray(new String[selectionArgs.size()]);
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKit,代码行数:20,代码来源:DatabaseTable_DataSource.java

示例7: findDataSource

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
public synchronized ArrayList<DataSourceClient> findDataSource(SQLiteDatabase db, DataSource dataSource) {
        ArrayList<DataSourceClient> dataSourceClients = new ArrayList<>();
        SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
        queryBuilder.setTables(TABLE_NAME);
        String[] columns = new String[]{C_DS_ID, C_DATASOURCE};
        String selection = prepareSelection(dataSource);
        String[] selectionArgs = prepareSelectionArgs(dataSource);
        Cursor mCursor = db.query(TABLE_NAME, columns, selection, selectionArgs, null, null, null);
        try {
            if (mCursor.moveToFirst()) {
                do {
                    byte[] bytes = mCursor.getBlob(mCursor.getColumnIndex(C_DATASOURCE));
                    DataSource curDataSource = fromBytes(bytes);
                    DataSourceClient dataSourceClient = new DataSourceClient(mCursor.getInt(mCursor.getColumnIndex(C_DS_ID)),
                            curDataSource, new Status(Status.DATASOURCE_EXIST));
//                    DataSourceClient dataSourceClient = new DataSourceClient(mCursor.getInt(mCursor.getColumnIndex(C_DS_ID)),
//                            DataSource.fromBytes(mCursor.getBlob(mCursor.getColumnIndex(C_DATASOURCE))), new Status(Status.DATASOURCE_EXIST));
                    dataSourceClients.add(dataSourceClient);
                } while (mCursor.moveToNext());
            }
            mCursor.close();
        }catch (Exception ignored){

        }
        return dataSourceClients;
    }
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKit,代码行数:27,代码来源:DatabaseTable_DataSource.java

示例8: prepareDataSource

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
public synchronized ContentValues prepareDataSource(DataSource dataSource) {
//        byte[] dataSourceArray = dataSource.toBytes();
        byte[] dataSourceArray = toBytes(dataSource);

        long curTime = DateTime.getDateTime();
        ContentValues cValues = new ContentValues();
        if (dataSource.getId() != null) cValues.put(C_DATASOURCE_ID, dataSource.getId());
        if (dataSource.getType() != null) cValues.put(C_DATASOURCE_TYPE, dataSource.getType());
        if (dataSource.getPlatform() != null && dataSource.getPlatform().getId() != null)
            cValues.put(C_PLATFORM_ID, dataSource.getPlatform().getId());
        if (dataSource.getPlatform() != null && dataSource.getPlatform().getType() != null)
            cValues.put(C_PLATFROM_TYPE, dataSource.getPlatform().getType());
        if (dataSource.getPlatformApp() != null && dataSource.getPlatformApp().getId() != null)
            cValues.put(C_PLATFORMAPP_ID, dataSource.getPlatformApp().getId());
        if (dataSource.getPlatformApp() != null && dataSource.getPlatformApp().getType() != null)
            cValues.put(C_PLATFROMAPP_TYPE, dataSource.getPlatformApp().getType());
        if (dataSource.getApplication() != null && dataSource.getApplication().getId() != null)
            cValues.put(C_APPLICATION_ID, dataSource.getApplication().getId());
        if (dataSource.getApplication() != null && dataSource.getApplication().getType() != null)
            cValues.put(C_APPLICATION_TYPE, dataSource.getApplication().getType());
        cValues.put(C_CREATEDATETIME, curTime);
        cValues.put(C_DATASOURCE, dataSourceArray);
        return cValues;
    }
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKit,代码行数:25,代码来源:DatabaseTable_DataSource.java

示例9: updateSummary

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
public Status updateSummary(DataSource dataSource, DataType dataType) {
    Status status=null;
    for(int i=0;i<4;i++) {
        int ds_id=registerSummary(dataSource, i);
        long updatedTimestamp = getUpdatedTimestamp(dataType.getDateTime(), i);
        ArrayList<DataType> dataTypeLast = query(ds_id, 1);
        if(dataTypeLast.size()==0){
            status= publishers.receivedData(ds_id, new DataType[]{createDataType(dataType, null, updatedTimestamp)}, false);
        }else if(i==0){
            status= publishers.receivedData(ds_id, new DataType[]{createDataType(dataType, dataTypeLast.get(0), updatedTimestamp)}, true);
        }else if (dataTypeLast.get(0).getDateTime() != updatedTimestamp) {
            status= publishers.receivedData(ds_id, new DataType[]{createDataType(dataType, null, updatedTimestamp)}, false);
        } else {
            status= publishers.receivedData(ds_id, new DataType[]{createDataType(dataType, dataTypeLast.get(0),updatedTimestamp)}, true);
        }
    }
    return status;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKit,代码行数:19,代码来源:RoutingManager.java

示例10: setConfigDataQualityView

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
void setConfigDataQualityView(ArrayList<ConfigDataQualityView> configDataQualityViews, DataSource dataSource) {
    for(int i=0;i<configDataQualityViews.size();i++){
        DataSource confDataSource=configDataQualityViews.get(i).getPlotter().getDatasource();
        if(confDataSource.getType().equals(DataSourceType.RESPIRATION) && confDataSource.getType().equals(dataSource.getId())) {
            configDataQualityView = configDataQualityViews.get(i);
            return;
        }
        if(confDataSource.getType().equals(DataSourceType.ECG) && confDataSource.getType().equals(dataSource.getId())) {
            configDataQualityView = configDataQualityViews.get(i);
            return;
        }
        if(confDataSource.getPlatform()==null || confDataSource.getPlatform().getId()==null || confDataSource.getPlatform().getType()==null) {
        }
        else if(confDataSource.getPlatform().getType().equals(dataSource.getPlatform().getType()) && confDataSource.getPlatform().getId().equals(dataSource.getPlatform().getId())) {
            configDataQualityView = configDataQualityViews.get(i);
            return;
        }
    }
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:20,代码来源:DataQualityInfo.java

示例11: set

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
@Override
public void set() {
    Log.d(TAG, "set()...");
    clear();
    dataQualities.clear();
    dataQualityInfos.clear();
    final ArrayList<DataSource> dataQuality = modelManager.getConfigManager().getConfig().getData_quality();
    if (dataQuality == null || dataQuality.size() == 0) return;
    for (int i = 0; i < dataQuality.size(); i++) {
        dataQualityInfos.add(new DataQualityInfo());
        final int finalI = i;
        dataQualities.add(new DataQuality(modelManager.getContext(), dataQuality.get(i),dataQualityInfos.get(i),  new ReceiveCallBack() {
            @Override
            public void onReceive(DataTypeInt sample) {
                dataQualityInfos.get(finalI).set(sample);
            }
        }));
    }
    for (int i = 0; i < dataQuality.size(); i++)
        dataQualities.get(i).start();
    status = new Status(rank, Status.SUCCESS);
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:23,代码来源:DataQualityManager.java

示例12: readDataSourceFromFile

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
private void readDataSourceFromFile(){
    try {
        Log.d(TAG, "readDataSourceFromFile()...");
        ArrayList<DataSource> dataSources = Configuration.getDataSources();
        if(dataSources==null) throw new FileNotFoundException();
        Log.d(TAG, "readDataSourceFromFile() .. datasource_size=" + dataSources.size());
        for (int i = 0; i < dataSources.size(); i++) {
            String deviceId = dataSources.get(i).getPlatform().getMetadata().get(METADATA.DEVICE_ID);
            String platformId = dataSources.get(i).getPlatform().getId();
            MicrosoftBand microsoftBand = find(deviceId);
            if (microsoftBand == null) {
                microsoftBand = new MicrosoftBand(context, platformId,deviceId);
                microsoftBands.add(microsoftBand);
            }
            microsoftBand.setEnabled(true);
            microsoftBand.setEnabled(dataSources.get(i), true);
        }
    } catch (FileNotFoundException e) {
        Toast.makeText(context,"Microsoft Band is not configured",Toast.LENGTH_LONG).show();
    }
    Log.d(TAG,"...readDataSourceFromFile()");
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-MicrosoftBand,代码行数:23,代码来源:MicrosoftBands.java

示例13: writeDataSourceToFile

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
void writeDataSourceToFile() throws IOException {
    ArrayList<DataSource> dataSources = new ArrayList<>();
    if (microsoftBands == null) throw new NullPointerException();
    if (microsoftBands.size() == 0) throw new EmptyStackException();
    for (int i = 0; i < microsoftBands.size(); i++) {
        if(!microsoftBands.get(i).enabled) continue;
        Platform platform= microsoftBands.get(i).getPlatform();
        for(int j=0;j< microsoftBands.get(i).getSensors().size();j++) {
            if(!microsoftBands.get(i).getSensors().get(j).isEnabled()) continue;
            DataSourceBuilder dataSourceBuilder= microsoftBands.get(i).getSensors().get(j).createDataSourceBuilder(microsoftBands.get(i).getPlatform());
            if(dataSourceBuilder==null) continue;
            dataSourceBuilder=dataSourceBuilder.setPlatform(platform);
            DataSource dataSource = dataSourceBuilder.build();
            dataSources.add(dataSource);
        }
    }
    if(dataSources.size()==0) Toast.makeText(context,"Error: MicrosoftBand is not configured propoerly...",Toast.LENGTH_SHORT).show();
    Configuration.write(dataSources);
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-MicrosoftBand,代码行数:20,代码来源:MicrosoftBands.java

示例14: addPreferenceScreenSensors

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
protected void addPreferenceScreenSensors() {
    ArrayList<DataSource> dataSources = null;
    try {
        dataSources = Configuration.getDataSources();
    } catch (FileNotFoundException e) {
        return;
    }
    String dataSourceType, platformId, dataSourceId, platformType, deviceId;
    PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("dataSourceType");
    preferenceCategory.removeAll();
    for (int i = 0; i < dataSources.size(); i++) {
        platformId = dataSources.get(i).getPlatform().getId();
        dataSourceType = dataSources.get(i).getType();
        dataSourceId = dataSources.get(i).getId();
        platformType = dataSources.get(i).getPlatform().getType();
        deviceId = dataSources.get(i).getPlatform().getMetadata().get(METADATA.DEVICE_ID);
        Preference preference = createPreference(dataSourceType, dataSourceId, platformType, platformId, deviceId);
        preferenceCategory.addPreference(preference);
    }
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-AutoSense,代码行数:21,代码来源:PrefsFragmentPlot.java

示例15: onCreate

import org.md2k.datakitapi.source.datasource.DataSource; //导入依赖的package包/类
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent intent = getIntent();
        DataSource dataSource=intent.getParcelableExtra(DataSource.class.getSimpleName());
        if(dataSource==null) {
            finish();
            return;
        }
        dataSourceType = dataSource.getType();

/*
        platformId = intent.getStringExtra("platformid");
        platformType = intent.getStringExtra("platformtype");
        deviceId = intent.getStringExtra("deviceId");
        dataSourceId = intent.getStringExtra("datasourceid");
*/
//        if (dataSourceType == null) finish();

    }
 
开发者ID:MD2Korg,项目名称:mCerebrum-AutoSense,代码行数:21,代码来源:ActivityPlot.java


注:本文中的org.md2k.datakitapi.source.datasource.DataSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。