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


Java DataTypeJSONObject类代码示例

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


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

示例1: writeToDataKit

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private boolean writeToDataKit() {
    try {
        DataKitAPI dataKitAPI = DataKitAPI.getInstance(modelManager.getContext());
        if (!isValid()) return false;
        Gson gson = new Gson();
        JsonObject sample = new JsonParser().parse(gson.toJson(dayTypeNew)).getAsJsonObject();
        DataSourceClient dataSourceClient = dataKitAPI.register(createDataSourceBuilder());
        DataTypeJSONObject dataTypeJSONObject = new DataTypeJSONObject(DateTime.getDateTime(), sample);
        dataKitAPI.insert(dataSourceClient, dataTypeJSONObject);
        dayTypeDB = dayTypeNew;
    } catch (DataKitException e) {
        LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
        return false;
    }
    return true;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:17,代码来源:DayTypeManager.java

示例2: readFromDataKit

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private StudyInfo readFromDataKit() {
    StudyInfo studyInfo = null;
    try {
        DataKitAPI dataKitAPI = DataKitAPI.getInstance(modelManager.getContext());

        DataSourceClient dataSourceClient = dataKitAPI.register(createDataSourceBuilder());
        ArrayList<DataType> dataTypes = dataKitAPI.query(dataSourceClient, 1);
        if (dataTypes.size() != 0) {
            DataTypeJSONObject dataTypeJSONObject = (DataTypeJSONObject) dataTypes.get(0);
            Gson gson = new Gson();
            studyInfo = gson.fromJson(dataTypeJSONObject.getSample().toString(), StudyInfo.class);
        }
    } catch (Exception ignored) {
        LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
    }
    return studyInfo;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:18,代码来源:StudyInfoManager.java

示例3: writeToDataKit

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private boolean writeToDataKit() {
    try {
        DataKitAPI dataKitAPI = DataKitAPI.getInstance(modelManager.getContext());
        Log.d(TAG, "StudyInfoManager...writeToDataKit()");
        Gson gson = new Gson();
        JsonObject sample = new JsonParser().parse(gson.toJson(studyInfoFile)).getAsJsonObject();

        DataSourceClient dataSourceClient = dataKitAPI.register(createDataSourceBuilder());
        DataTypeJSONObject dataTypeJSONObject = new DataTypeJSONObject(DateTime.getDateTime(), sample);
        dataKitAPI.insert(dataSourceClient, dataTypeJSONObject);
        studyInfoDB = studyInfoFile;
        return true;
    } catch (DataKitException e) {
        LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
        return false;
    }
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:18,代码来源:StudyInfoManager.java

示例4: writeToDataKit

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private boolean writeToDataKit(){
    try {
        DataKitAPI dataKitAPI = DataKitAPI.getInstance(modelManager.getContext());
        if (isInDatabase) return false;
        if (userInfo == null) return false;
        if (userInfo.getUser_id() == null) return false;
        if (userInfo.getUser_id().length() == 0) return false;
        Gson gson = new Gson();
        JsonObject sample = new JsonParser().parse(gson.toJson(userInfo)).getAsJsonObject();

        DataSourceClient dataSourceClient = dataKitAPI.register(createDataSourceBuilder());
        DataTypeJSONObject dataTypeJSONObject = new DataTypeJSONObject(DateTime.getDateTime(), sample);
        dataKitAPI.insert(dataSourceClient, dataTypeJSONObject);
        isInDatabase = true;
        return true;
    } catch (DataKitException e) {
        LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
        return false;
    }
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:21,代码来源:UserInfoManager.java

示例5: readFromDataKit

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private PrivacyData readFromDataKit() {
    PrivacyData privacyData = null;
    try {
        DataKitAPI dataKitAPI = DataKitAPI.getInstance(modelManager.getContext());
        ArrayList<DataSourceClient> dataSourceClients = dataKitAPI.find(createDataSourceBuilder());
        if (dataSourceClients.size() > 0) {
            ArrayList<DataType> dataTypes = dataKitAPI.query(dataSourceClients.get(0), 1);
            if (dataTypes.size() != 0) {
                try {
                    DataTypeJSONObject dataTypeJSONObject = (DataTypeJSONObject) dataTypes.get(0);
                    Gson gson = new Gson();
                    privacyData = gson.fromJson(dataTypeJSONObject.getSample().toString(), PrivacyData.class);
                } catch (Exception ignored) {
                    privacyData = null;
                    LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
                }
            }
        }
    } catch (DataKitException e) {
        privacyData=null;
        LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
    }
    return privacyData;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:25,代码来源:PrivacyControlManager.java

示例6: insertPrivacy

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
public void insertPrivacy(PrivacyData privacyData){
    this.privacyData=privacyData;
    Gson gson=new Gson();
    JsonObject sample = new JsonParser().parse(gson.toJson(privacyData)).getAsJsonObject();
    DataTypeJSONObject dataTypeJSONObject = new DataTypeJSONObject(DateTime.getDateTime(), sample);
    insert(dsIdPrivacy, new DataTypeJSONObject[]{dataTypeJSONObject});
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKit,代码行数:8,代码来源:PrivacyManager.java

示例7: queryLastPrivacyData

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private PrivacyData queryLastPrivacyData() {
    Gson gson = new Gson();
    dsIdPrivacy = routingManager.register(createDataSourcePrivacy()).getDs_id();

    ArrayList<DataType> dataTypes = routingManager.query(dsIdPrivacy, 1);

    if (dataTypes == null || dataTypes.size() == 0) return null;
    DataTypeJSONObject dataTypeJSONObject = (DataTypeJSONObject) dataTypes.get(0);
    return gson.fromJson(dataTypeJSONObject.getSample().toString(), PrivacyData.class);
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-DataKit,代码行数:11,代码来源:PrivacyManager.java

示例8: subscribeNotificationResponse

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private void subscribeNotificationResponse() throws DataKitException {
    Log.d(TAG, "subscribeNotificationResponse...");
    for (int i = 0; i < dataSourceClientResponses.size(); i++) {
        DataKitAPI.getInstance(context).subscribe(dataSourceClientResponses.get(i), new OnReceiveListener() {
            @Override
            public void onReceived(final DataType dataType) {
                Thread t = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            DataTypeJSONObject dataTypeJSONObject = (DataTypeJSONObject) dataType;
                            Gson gson = new Gson();
                            NotificationResponse notificationResponse = gson.fromJson(dataTypeJSONObject.getSample().toString(), NotificationResponse.class);
                            Log.d(TAG, "notification_acknowledge = " + notificationResponse.getStatus());
                            handler.removeCallbacks(runnableNotify);
                            switch (notificationResponse.getStatus()) {
                                case NotificationResponse.OK:
                                case NotificationResponse.CANCEL:
                                    clear();
                                    callback.onResponse(notificationResponse.getStatus());
                                    break;
                                case NotificationResponse.TIMEOUT:
                                    clear();
                                    callback.onResponse(notificationResponse.getStatus());
                                    break;
                            }
                        } catch (DataKitException e) {
                            LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Constants.INTENT_RESTART));
                        } catch (Exception ignored) {

                        }
                    }
                });
                t.start();
            }
        });
    }
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:39,代码来源:NotifierManager.java

示例9: insertDataToDataKit

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private void insertDataToDataKit(NotificationRequests notificationRequests) {
    try {
        DataKitAPI dataKitAPI = DataKitAPI.getInstance(context);
        Gson gson = new Gson();
        JsonObject sample = new JsonParser().parse(gson.toJson(notificationRequests)).getAsJsonObject();
        DataTypeJSONObject dataTypeJSONObject = new DataTypeJSONObject(DateTime.getDateTime(), sample);
        dataKitAPI.insert(dataSourceClientRequest, dataTypeJSONObject);
        Log.d(TAG, "...insertDataToDataKit()");
    } catch (DataKitException e) {
        LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Constants.INTENT_RESTART));
    }
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:13,代码来源:NotifierManager.java

示例10: readFromDataKit

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private void readFromDataKit() {
    try {
        dayTypeDB = null;
        DataKitAPI dataKitAPI = DataKitAPI.getInstance(modelManager.getContext());
        DataSourceClient dataSourceClient = dataKitAPI.register(createDataSourceBuilder());
        ArrayList<DataType> dataTypes = dataKitAPI.query(dataSourceClient, 1);
        if (dataTypes.size() != 0) {
            DataTypeJSONObject dataTypeJSONObject = (DataTypeJSONObject) dataTypes.get(0);
            Gson gson = new Gson();
            dayTypeDB = gson.fromJson(dataTypeJSONObject.getSample().toString(), DayTypeInfo.class);
        }
    } catch (DataKitException e) {
        LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
    }
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:16,代码来源:DayTypeManager.java

示例11: createDataSourceBuilder

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private DataSourceBuilder createDataSourceBuilder() {
    Platform platform = new PlatformBuilder().setType(PlatformType.PHONE).build();
    DataSourceBuilder dataSourceBuilder = new DataSourceBuilder().setType(DataSourceType.TYPE_OF_DAY).setPlatform(platform);
    dataSourceBuilder = dataSourceBuilder.setMetadata(METADATA.NAME, "Pre/Post Quit Day");
    dataSourceBuilder = dataSourceBuilder.setMetadata(METADATA.DESCRIPTION, "Defines type of Day");
    dataSourceBuilder = dataSourceBuilder.setMetadata(METADATA.DATA_TYPE, DataTypeJSONObject.class.getName());
    dataSourceBuilder = dataSourceBuilder.setDataDescriptors(createDataDescriptors());
    return dataSourceBuilder;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:10,代码来源:DayTypeManager.java

示例12: createDataSourceBuilder

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private DataSourceBuilder createDataSourceBuilder() {
    Platform platform = new PlatformBuilder().setType(PlatformType.PHONE).setMetadata(METADATA.NAME, "Phone").build();
    DataSourceBuilder dataSourceBuilder = new DataSourceBuilder().setType(DataSourceType.STUDY_INFO).setPlatform(platform);
    dataSourceBuilder = dataSourceBuilder.setMetadata(METADATA.NAME, "Study Info");
    dataSourceBuilder = dataSourceBuilder.setMetadata(METADATA.DESCRIPTION, "Contains study_id and study_name as a json object");
    dataSourceBuilder = dataSourceBuilder.setMetadata(METADATA.DATA_TYPE, DataTypeJSONObject.class.getName());
    return dataSourceBuilder;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:9,代码来源:StudyInfoManager.java

示例13: readFromDataKit

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private void readFromDataKit() {
    try {
        DataKitAPI dataKitAPI = DataKitAPI.getInstance(modelManager.getContext());
        DataSourceClient dataSourceClient = dataKitAPI.register(createDataSourceBuilder());
        ArrayList<DataType> dataTypes = dataKitAPI.query(dataSourceClient, 1);
        if (dataTypes.size() != 0) {
            DataTypeJSONObject dataTypeJSONObject = (DataTypeJSONObject) dataTypes.get(0);
            Gson gson = new Gson();
            userInfo = gson.fromJson(dataTypeJSONObject.getSample().toString(), UserInfo.class);
            isInDatabase = true;
        }
    } catch (DataKitException e) {
        LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
    }
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:16,代码来源:UserInfoManager.java

示例14: createDataSourceBuilder

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private DataSourceBuilder createDataSourceBuilder() {
    Platform platform = new PlatformBuilder().setType(PlatformType.PHONE).setMetadata(METADATA.NAME, "Phone").build();
    DataSourceBuilder dataSourceBuilder = new DataSourceBuilder().setType(DataSourceType.USER_INFO).setPlatform(platform);
    dataSourceBuilder = dataSourceBuilder.setMetadata(METADATA.NAME, "User Info");
    dataSourceBuilder = dataSourceBuilder.setMetadata(METADATA.DESCRIPTION, "Contains user_id as a json object");
    dataSourceBuilder = dataSourceBuilder.setMetadata(METADATA.DATA_TYPE, DataTypeJSONObject.class.getName());
    return dataSourceBuilder;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:9,代码来源:UserInfoManager.java

示例15: getRunningTime

import org.md2k.datakitapi.datatype.DataTypeJSONObject; //导入依赖的package包/类
private long getRunningTime(){
    long runningTime = 0;
    try {
        PrivacyData lastPrivacyData = null;
        PrivacyData curPrivacyData = null;
        long lastTime=0;
        long curTime=0;
        DayStartEndInfoManager dayStartEndInfoManager = (DayStartEndInfoManager) modelManager.getModel(ModelFactory.MODEL_DAY_START_END);
        long dayStartTime = dayStartEndInfoManager.getDayStartTime();
        long dayEndTime = dayStartEndInfoManager.getDayEndTime();
        if (dayStartTime == -1 || dayStartTime < dayEndTime) return 0;
        DataKitAPI dataKitAPI = DataKitAPI.getInstance(modelManager.getContext());
        ArrayList<DataSourceClient> dataSourceClients = dataKitAPI.find(createDataSourceBuilder());
        if (dataSourceClients.size() > 0) {
            ArrayList<DataType> dataTypes = dataKitAPI.query(dataSourceClients.get(0), dayStartTime, DateTime.getDateTime());
            for (int i = 0; i < dataTypes.size(); i++) {
                try {
                    DataTypeJSONObject dataTypeJSONObject = (DataTypeJSONObject) dataTypes.get(i);
                    Gson gson = new Gson();
                    curPrivacyData = gson.fromJson(dataTypeJSONObject.getSample().toString(), PrivacyData.class);
                    curTime=dataTypeJSONObject.getDateTime();
                    Log.d(TAG,"privacyData...cur_status="+curPrivacyData.isStatus()+" cur_duration="+curPrivacyData.getDuration().getValue()+" curTime="+curTime+" starttime="+curPrivacyData.getStartTimeStamp());
                    if (curPrivacyData.isStatus()) {
                        lastPrivacyData = curPrivacyData;
                        lastTime=curTime;
                        runningTime += curPrivacyData.getDuration().getValue();
                        Log.d(TAG,"privacyData...cur_status="+curPrivacyData.isStatus()+" cur_duration="+curPrivacyData.getDuration().getValue()+" curTime="+curTime+" starttime="+curPrivacyData.getStartTimeStamp()+" runningtime="+runningTime);
                    } else {
                        if (lastPrivacyData != null) {
                            runningTime -= lastPrivacyData.getDuration().getValue();
                            runningTime += curTime - lastTime;
                            Log.d(TAG,"privacyData...cur_status="+curPrivacyData.isStatus()+" cur_duration="+curPrivacyData.getDuration().getValue()+" curTime="+curTime+" starttime="+curPrivacyData.getStartTimeStamp()+" lastTime="+lastTime+" lastStarttime="+lastPrivacyData.getStartTimeStamp()+" runningtime="+runningTime+" used="+(curTime - lastTime));
                            lastPrivacyData = null;
                        }
                    }
                } catch (Exception ignored) {
                    LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
                }
            }
        }
    } catch (DataKitException e) {
        LocalBroadcastManager.getInstance(modelManager.getContext()).sendBroadcast(new Intent(Constants.INTENT_RESTART));
    }
    return runningTime;
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-Study,代码行数:46,代码来源:PrivacyControlManager.java


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