Java Code Examples for com.activeandroid.Model#getId()

The following examples show how to use com.activeandroid.Model#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UploaderQueue.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static UploaderQueue newEntryForWatch(String action, Model obj) {
    UserError.Log.d(TAG, "new entry called for watch");
    final UploaderQueue result = new UploaderQueue();
    result.bitfield_wanted = DEFAULT_UPLOAD_CIRCUITS
            | (Pref.getBooleanDefaultFalse("wear_sync") ? WATCH_WEARAPI : 0);
    if (result.bitfield_wanted == 0) return null; // no queue required
    result.timestamp = JoH.tsl();
    result.reference_id = obj.getId();
    // TODO this probably could be neater
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof BgReading ? ((BgReading) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof Treatments ? ((Treatments) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof Calibration ? ((Calibration) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof BloodTest ? ((BloodTest) obj).uuid : null;

    if (result.reference_uuid == null) {
        Log.d(TAG, "reference_uuid was null so refusing to create new entry");
        return null;
    }

    if (result.reference_id < 0) {
        UserError.Log.wtf(TAG, "Watch ERROR ref id was: " + result.reference_id + " for uuid: " + result.reference_uuid + " refusing to create");
        return null;
    }

    result.action = action;

    result.bitfield_complete = 0;
    result.type = obj.getClass().getSimpleName();
    result.saveit();
    if (d) UserError.Log.d(TAG, result.toS());
    last_new_entry = JoH.tsl();
    return result;
}
 
Example 2
Source File: UploaderQueue.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static UploaderQueue newEntryForWatch(String action, Model obj) {
    UserError.Log.d(TAG, "new entry called for watch");
    final UploaderQueue result = new UploaderQueue();
    result.bitfield_wanted = DEFAULT_UPLOAD_CIRCUITS
            | (Pref.getBooleanDefaultFalse("wear_sync") ? WATCH_WEARAPI : 0);
    if (result.bitfield_wanted == 0) return null; // no queue required
    result.timestamp = JoH.tsl();
    result.reference_id = obj.getId();
    // TODO this probably could be neater
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof BgReading ? ((BgReading) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof Treatments ? ((Treatments) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof Calibration ? ((Calibration) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof BloodTest ? ((BloodTest) obj).uuid : null;

    if (result.reference_uuid == null) {
        Log.d(TAG, "reference_uuid was null so refusing to create new entry");
        return null;
    }

    if (result.reference_id < 0) {
        UserError.Log.wtf(TAG, "Watch ERROR ref id was: " + result.reference_id + " for uuid: " + result.reference_uuid + " refusing to create");
        return null;
    }

    result.action = action;

    result.bitfield_complete = 0;
    result.type = obj.getClass().getSimpleName();
    result.saveit();
    if (d) UserError.Log.d(TAG, result.toS());
    last_new_entry = JoH.tsl();
    return result;
}
 
Example 3
Source File: UploaderQueue.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static UploaderQueue newEntry(String action, Model obj) {
    UserError.Log.d(TAG, "new entry called");
    final UploaderQueue result = new UploaderQueue();
    result.bitfield_wanted = DEFAULT_UPLOAD_CIRCUITS
            | (Pref.getBooleanDefaultFalse("cloud_storage_mongodb_enable") ? MONGO_DIRECT : 0)
            | (Pref.getBooleanDefaultFalse("cloud_storage_api_enable") ? NIGHTSCOUT_RESTAPI : 0)
            | (Pref.getBooleanDefaultFalse("cloud_storage_influxdb_enable") ? INFLUXDB_RESTAPI : 0)
            | (Pref.getBooleanDefaultFalse("wear_sync") ? WATCH_WEARAPI : 0);
    if (result.bitfield_wanted == 0) return null; // no queue required
    result.timestamp = JoH.tsl();
    result.reference_id = obj.getId();
    // TODO this probably could be neater
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof BgReading ? ((BgReading) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof Treatments ? ((Treatments) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof Calibration ? ((Calibration) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof BloodTest ? ((BloodTest) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof TransmitterData ? ((TransmitterData) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof LibreBlock ? ((LibreBlock) obj).uuid : null;

    if (result.reference_uuid == null) {
        Log.d(TAG, "reference_uuid was null so refusing to create new entry");
        return null;
    }

    if (result.reference_id < 0) {
        UserError.Log.wtf(TAG, "ERROR ref id was: " + result.reference_id + " for uuid: " + result.reference_uuid + " refusing to create");
        return null;
    }

    result.action = action;

    result.bitfield_complete = 0;
    result.type = obj.getClass().getSimpleName();
    result.saveit();
    if (d) UserError.Log.d(TAG, result.toS());
    last_new_entry = JoH.tsl();
    return result;
}
 
Example 4
Source File: UploaderQueue.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static UploaderQueue newEntry(String action, Model obj) {
    UserError.Log.d(TAG, "new entry called");
    final UploaderQueue result = new UploaderQueue();
    result.bitfield_wanted = DEFAULT_UPLOAD_CIRCUITS
            | (Pref.getBooleanDefaultFalse("cloud_storage_mongodb_enable") ? MONGO_DIRECT : 0)
            | (Pref.getBooleanDefaultFalse("cloud_storage_api_enable") ? NIGHTSCOUT_RESTAPI : 0)
            | (Pref.getBooleanDefaultFalse("cloud_storage_influxdb_enable") ? INFLUXDB_RESTAPI : 0)
            | (Pref.getBooleanDefaultFalse("wear_sync") ? WATCH_WEARAPI : 0);
    if (result.bitfield_wanted == 0) return null; // no queue required
    result.timestamp = JoH.tsl();
    result.reference_id = obj.getId();
    // TODO this probably could be neater
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof BgReading ? ((BgReading) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof Treatments ? ((Treatments) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof Calibration ? ((Calibration) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof BloodTest ? ((BloodTest) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof TransmitterData ? ((TransmitterData) obj).uuid : null;
    if (result.reference_uuid == null)
        result.reference_uuid = obj instanceof LibreBlock ? ((LibreBlock) obj).uuid : null;

    if (result.reference_uuid == null) {
        Log.d(TAG, "reference_uuid was null so refusing to create new entry");
        return null;
    }

    if (result.reference_id < 0) {
        UserError.Log.wtf(TAG, "ERROR ref id was: " + result.reference_id + " for uuid: " + result.reference_uuid + " refusing to create");
        return null;
    }

    result.action = action;

    result.bitfield_complete = 0;
    result.type = obj.getClass().getSimpleName();
    result.saveit();
    if (d) UserError.Log.d(TAG, result.toS());
    last_new_entry = JoH.tsl();
    return result;
}