本文整理汇总了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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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});
}
示例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);
}
示例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();
}
});
}
}
示例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));
}
}
示例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));
}
}
示例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;
}
示例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;
}
示例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));
}
}
示例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;
}
示例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;
}