Search in sources :

Example 11 with PhoneNumber

use of sqlite.kripton111.model.PhoneNumber in project kripton by xcesco.

the class PhoneDaoImpl method selectById.

/**
 * <h2>Select SQL:</h2>
 *
 * <pre>SELECT id, action, number, country_code, contact_name, contact_id FROM phone_number WHERE id = ${id}</pre>
 *
 * <h2>Projected columns:</h2>
 * <dl>
 * 	<dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
 * 	<dt>action</dt><dd>is associated to bean's property <strong>action</strong></dd>
 * 	<dt>number</dt><dd>is associated to bean's property <strong>number</strong></dd>
 * 	<dt>country_code</dt><dd>is associated to bean's property <strong>countryCode</strong></dd>
 * 	<dt>contact_name</dt><dd>is associated to bean's property <strong>contactName</strong></dd>
 * 	<dt>contact_id</dt><dd>is associated to bean's property <strong>contactId</strong></dd>
 * </dl>
 *
 * <h2>Query's parameters:</h2>
 * <dl>
 * 	<dt>${id}</dt><dd>is binded to method's parameter <strong>id</strong></dd>
 * </dl>
 *
 * @param id
 * 	is binded to <code>${id}</code>
 * @return selected bean or <code>null</code>.
 */
@Override
public PhoneNumber selectById(long id) {
    KriptonContentValues _contentValues = contentValues();
    // query SQL is statically defined
    String _sql = SELECT_BY_ID_SQL1;
    // add where arguments
    _contentValues.addWhereArgs(String.valueOf(id));
    String[] _sqlArgs = _contentValues.whereArgsAsArray();
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // manage log
        Logger.info(_sql);
        // log for where parameters -- BEGIN
        int _whereParamCounter = 0;
        for (String _whereParamItem : _contentValues.whereArgs()) {
            Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
        }
    // log for where parameters -- END
    }
    // log section END
    try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
        // log section BEGIN
        if (_context.isLogEnabled()) {
            Logger.info("Rows found: %s", _cursor.getCount());
        }
        // log section END
        PhoneNumber resultBean = null;
        if (_cursor.moveToFirst()) {
            int index0 = _cursor.getColumnIndex("id");
            int index1 = _cursor.getColumnIndex("action");
            int index2 = _cursor.getColumnIndex("number");
            int index3 = _cursor.getColumnIndex("country_code");
            int index4 = _cursor.getColumnIndex("contact_name");
            int index5 = _cursor.getColumnIndex("contact_id");
            resultBean = new PhoneNumber();
            resultBean.id = _cursor.getLong(index0);
            if (!_cursor.isNull(index1)) {
                resultBean.action = ActionType.valueOf(_cursor.getString(index1));
            }
            if (!_cursor.isNull(index2)) {
                resultBean.number = _cursor.getString(index2);
            }
            if (!_cursor.isNull(index3)) {
                resultBean.countryCode = _cursor.getString(index3);
            }
            if (!_cursor.isNull(index4)) {
                resultBean.contactName = _cursor.getString(index4);
            }
            if (!_cursor.isNull(index5)) {
                resultBean.contactId = _cursor.getString(index5);
            }
        }
        return resultBean;
    }
}
Also used : KriptonContentValues(com.abubusoft.kripton.android.sqlite.KriptonContentValues) PhoneNumber(sqlite.kripton186.model.PhoneNumber) Cursor(android.database.Cursor)

Example 12 with PhoneNumber

use of sqlite.kripton111.model.PhoneNumber in project kripton by xcesco.

the class PhoneDaoImpl method selectByNumber.

/**
 * <h2>Select SQL:</h2>
 *
 * <pre>SELECT id, action, number, country_code, contact_name, contact_id FROM phone_number WHERE number = ${number}</pre>
 *
 * <h2>Projected columns:</h2>
 * <dl>
 * 	<dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
 * 	<dt>action</dt><dd>is associated to bean's property <strong>action</strong></dd>
 * 	<dt>number</dt><dd>is associated to bean's property <strong>number</strong></dd>
 * 	<dt>country_code</dt><dd>is associated to bean's property <strong>countryCode</strong></dd>
 * 	<dt>contact_name</dt><dd>is associated to bean's property <strong>contactName</strong></dd>
 * 	<dt>contact_id</dt><dd>is associated to bean's property <strong>contactId</strong></dd>
 * </dl>
 *
 * <h2>Query's parameters:</h2>
 * <dl>
 * 	<dt>${number}</dt><dd>is binded to method's parameter <strong>number</strong></dd>
 * </dl>
 *
 * @param number
 * 	is binded to <code>${number}</code>
 * @return selected bean or <code>null</code>.
 */
@Override
public PhoneNumber selectByNumber(String number) {
    KriptonContentValues _contentValues = contentValues();
    // query SQL is statically defined
    String _sql = SELECT_BY_NUMBER_SQL2;
    // add where arguments
    _contentValues.addWhereArgs((number == null ? "" : number));
    String[] _sqlArgs = _contentValues.whereArgsAsArray();
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // manage log
        Logger.info(_sql);
        // log for where parameters -- BEGIN
        int _whereParamCounter = 0;
        for (String _whereParamItem : _contentValues.whereArgs()) {
            Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
        }
    // log for where parameters -- END
    }
    // log section END
    try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
        // log section BEGIN
        if (_context.isLogEnabled()) {
            Logger.info("Rows found: %s", _cursor.getCount());
        }
        // log section END
        PhoneNumber resultBean = null;
        if (_cursor.moveToFirst()) {
            int index0 = _cursor.getColumnIndex("id");
            int index1 = _cursor.getColumnIndex("action");
            int index2 = _cursor.getColumnIndex("number");
            int index3 = _cursor.getColumnIndex("country_code");
            int index4 = _cursor.getColumnIndex("contact_name");
            int index5 = _cursor.getColumnIndex("contact_id");
            resultBean = new PhoneNumber();
            resultBean.id = _cursor.getLong(index0);
            if (!_cursor.isNull(index1)) {
                resultBean.action = ActionType.valueOf(_cursor.getString(index1));
            }
            if (!_cursor.isNull(index2)) {
                resultBean.number = _cursor.getString(index2);
            }
            if (!_cursor.isNull(index3)) {
                resultBean.countryCode = _cursor.getString(index3);
            }
            if (!_cursor.isNull(index4)) {
                resultBean.contactName = _cursor.getString(index4);
            }
            if (!_cursor.isNull(index5)) {
                resultBean.contactId = _cursor.getString(index5);
            }
        }
        return resultBean;
    }
}
Also used : KriptonContentValues(com.abubusoft.kripton.android.sqlite.KriptonContentValues) PhoneNumber(sqlite.kripton186.model.PhoneNumber) Cursor(android.database.Cursor)

Example 13 with PhoneNumber

use of sqlite.kripton111.model.PhoneNumber in project kripton by xcesco.

the class PhoneDaoImpl method selectAll.

/**
 * <h2>Select SQL:</h2>
 *
 * <pre>SELECT id, action_type, number, country_code, contact_name, contact_id FROM phone_number ORDER BY contact_name, number</pre>
 *
 * <h2>Projected columns:</h2>
 * <dl>
 * 	<dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
 * 	<dt>action_type</dt><dd>is associated to bean's property <strong>actionType</strong></dd>
 * 	<dt>number</dt><dd>is associated to bean's property <strong>number</strong></dd>
 * 	<dt>country_code</dt><dd>is associated to bean's property <strong>countryCode</strong></dd>
 * 	<dt>contact_name</dt><dd>is associated to bean's property <strong>contactName</strong></dd>
 * 	<dt>contact_id</dt><dd>is associated to bean's property <strong>contactId</strong></dd>
 * </dl>
 *
 * @return collection of bean or empty collection.
 */
@Override
public List<PhoneNumber> selectAll() {
    KriptonContentValues _contentValues = contentValues();
    // query SQL is statically defined
    String _sql = SELECT_ALL_SQL3;
    // add where arguments
    String[] _sqlArgs = _contentValues.whereArgsAsArray();
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // manage log
        Logger.info(_sql);
        // log for where parameters -- BEGIN
        int _whereParamCounter = 0;
        for (String _whereParamItem : _contentValues.whereArgs()) {
            Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
        }
    // log for where parameters -- END
    }
    // log section END
    try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
        // log section BEGIN
        if (_context.isLogEnabled()) {
            Logger.info("Rows found: %s", _cursor.getCount());
        }
        // log section END
        ArrayList<PhoneNumber> resultList = new ArrayList<PhoneNumber>(_cursor.getCount());
        PhoneNumber resultBean = null;
        if (_cursor.moveToFirst()) {
            int index0 = _cursor.getColumnIndex("id");
            int index1 = _cursor.getColumnIndex("action_type");
            int index2 = _cursor.getColumnIndex("number");
            int index3 = _cursor.getColumnIndex("country_code");
            int index4 = _cursor.getColumnIndex("contact_name");
            int index5 = _cursor.getColumnIndex("contact_id");
            do {
                resultBean = new PhoneNumber();
                resultBean.id = _cursor.getLong(index0);
                if (!_cursor.isNull(index1)) {
                    resultBean.actionType = ActionType.valueOf(_cursor.getString(index1));
                }
                if (!_cursor.isNull(index2)) {
                    resultBean.number = _cursor.getString(index2);
                }
                if (!_cursor.isNull(index3)) {
                    resultBean.countryCode = _cursor.getString(index3);
                }
                if (!_cursor.isNull(index4)) {
                    resultBean.contactName = _cursor.getString(index4);
                }
                if (!_cursor.isNull(index5)) {
                    resultBean.contactId = _cursor.getString(index5);
                }
                resultList.add(resultBean);
            } while (_cursor.moveToNext());
        }
        return resultList;
    }
}
Also used : KriptonContentValues(com.abubusoft.kripton.android.sqlite.KriptonContentValues) ArrayList(java.util.ArrayList) PhoneNumber(sqlite.kripton111.model.PhoneNumber) Cursor(android.database.Cursor)

Example 14 with PhoneNumber

use of sqlite.kripton111.model.PhoneNumber in project kripton by xcesco.

the class PhoneDaoImpl method selectById.

/**
 * <h2>Select SQL:</h2>
 *
 * <pre>SELECT id, action_type, number, country_code, contact_name, contact_id FROM phone_number WHERE id = ${id}</pre>
 *
 * <h2>Projected columns:</h2>
 * <dl>
 * 	<dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
 * 	<dt>action_type</dt><dd>is associated to bean's property <strong>actionType</strong></dd>
 * 	<dt>number</dt><dd>is associated to bean's property <strong>number</strong></dd>
 * 	<dt>country_code</dt><dd>is associated to bean's property <strong>countryCode</strong></dd>
 * 	<dt>contact_name</dt><dd>is associated to bean's property <strong>contactName</strong></dd>
 * 	<dt>contact_id</dt><dd>is associated to bean's property <strong>contactId</strong></dd>
 * </dl>
 *
 * <h2>Query's parameters:</h2>
 * <dl>
 * 	<dt>${id}</dt><dd>is binded to method's parameter <strong>id</strong></dd>
 * </dl>
 *
 * @param id
 * 	is binded to <code>${id}</code>
 * @return selected bean or <code>null</code>.
 */
@Override
public PhoneNumber selectById(long id) {
    KriptonContentValues _contentValues = contentValues();
    // query SQL is statically defined
    String _sql = SELECT_BY_ID_SQL1;
    // add where arguments
    _contentValues.addWhereArgs(String.valueOf(id));
    String[] _sqlArgs = _contentValues.whereArgsAsArray();
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // manage log
        Logger.info(_sql);
        // log for where parameters -- BEGIN
        int _whereParamCounter = 0;
        for (String _whereParamItem : _contentValues.whereArgs()) {
            Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
        }
    // log for where parameters -- END
    }
    // log section END
    try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
        // log section BEGIN
        if (_context.isLogEnabled()) {
            Logger.info("Rows found: %s", _cursor.getCount());
        }
        // log section END
        PhoneNumber resultBean = null;
        if (_cursor.moveToFirst()) {
            int index0 = _cursor.getColumnIndex("id");
            int index1 = _cursor.getColumnIndex("action_type");
            int index2 = _cursor.getColumnIndex("number");
            int index3 = _cursor.getColumnIndex("country_code");
            int index4 = _cursor.getColumnIndex("contact_name");
            int index5 = _cursor.getColumnIndex("contact_id");
            resultBean = new PhoneNumber();
            resultBean.id = _cursor.getLong(index0);
            if (!_cursor.isNull(index1)) {
                resultBean.actionType = ActionType.valueOf(_cursor.getString(index1));
            }
            if (!_cursor.isNull(index2)) {
                resultBean.number = _cursor.getString(index2);
            }
            if (!_cursor.isNull(index3)) {
                resultBean.countryCode = _cursor.getString(index3);
            }
            if (!_cursor.isNull(index4)) {
                resultBean.contactName = _cursor.getString(index4);
            }
            if (!_cursor.isNull(index5)) {
                resultBean.contactId = _cursor.getString(index5);
            }
        }
        return resultBean;
    }
}
Also used : KriptonContentValues(com.abubusoft.kripton.android.sqlite.KriptonContentValues) PhoneNumber(sqlite.kripton111.model.PhoneNumber) Cursor(android.database.Cursor)

Example 15 with PhoneNumber

use of sqlite.kripton111.model.PhoneNumber in project kripton by xcesco.

the class PhoneDaoImpl method selectById.

/**
 * <h2>Select SQL:</h2>
 *
 * <pre>SELECT id, action, number, country_code, contact_name, contact_id FROM phone_number WHERE id = ${id}</pre>
 *
 * <h2>Projected columns:</h2>
 * <dl>
 * 	<dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
 * 	<dt>action</dt><dd>is associated to bean's property <strong>action</strong></dd>
 * 	<dt>number</dt><dd>is associated to bean's property <strong>number</strong></dd>
 * 	<dt>country_code</dt><dd>is associated to bean's property <strong>countryCode</strong></dd>
 * 	<dt>contact_name</dt><dd>is associated to bean's property <strong>contactName</strong></dd>
 * 	<dt>contact_id</dt><dd>is associated to bean's property <strong>contactId</strong></dd>
 * </dl>
 *
 * <h2>Query's parameters:</h2>
 * <dl>
 * 	<dt>${id}</dt><dd>is binded to method's parameter <strong>id</strong></dd>
 * </dl>
 *
 * @param id
 * 	is binded to <code>${id}</code>
 * @return selected bean or <code>null</code>.
 */
@Override
public PhoneNumber selectById(long id) {
    KriptonContentValues _contentValues = contentValues();
    // query SQL is statically defined
    String _sql = SELECT_BY_ID_SQL1;
    // add where arguments
    _contentValues.addWhereArgs(String.valueOf(id));
    String[] _sqlArgs = _contentValues.whereArgsAsArray();
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // manage log
        Logger.info(_sql);
        // log for where parameters -- BEGIN
        int _whereParamCounter = 0;
        for (String _whereParamItem : _contentValues.whereArgs()) {
            Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
        }
    // log for where parameters -- END
    }
    // log section END
    try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
        // log section BEGIN
        if (_context.isLogEnabled()) {
            Logger.info("Rows found: %s", _cursor.getCount());
        }
        // log section END
        PhoneNumber resultBean = null;
        if (_cursor.moveToFirst()) {
            int index0 = _cursor.getColumnIndex("id");
            int index1 = _cursor.getColumnIndex("action");
            int index2 = _cursor.getColumnIndex("number");
            int index3 = _cursor.getColumnIndex("country_code");
            int index4 = _cursor.getColumnIndex("contact_name");
            int index5 = _cursor.getColumnIndex("contact_id");
            resultBean = new PhoneNumber();
            resultBean.id = _cursor.getLong(index0);
            if (!_cursor.isNull(index1)) {
                resultBean.action = ActionType.valueOf(_cursor.getString(index1));
            }
            if (!_cursor.isNull(index2)) {
                resultBean.number = _cursor.getString(index2);
            }
            if (!_cursor.isNull(index3)) {
                resultBean.countryCode = _cursor.getString(index3);
            }
            if (!_cursor.isNull(index4)) {
                resultBean.contactName = _cursor.getString(index4);
            }
            if (!_cursor.isNull(index5)) {
                resultBean.contactId = _cursor.getString(index5);
            }
        }
        return resultBean;
    }
}
Also used : KriptonContentValues(com.abubusoft.kripton.android.sqlite.KriptonContentValues) PhoneNumber(sqlite.feature.many2many.case6.model.PhoneNumber) Cursor(android.database.Cursor)

Aggregations

Cursor (android.database.Cursor)15 KriptonContentValues (com.abubusoft.kripton.android.sqlite.KriptonContentValues)15 PhoneNumber (com.google.api.services.people.v1.model.PhoneNumber)6 ArrayList (java.util.ArrayList)5 Person (com.google.api.services.people.v1.model.Person)4 VCard (ezvcard.VCard)4 Telephone (ezvcard.property.Telephone)4 Test (org.junit.Test)4 PhoneNumber (sqlite.feature.many2many.case4.model.PhoneNumber)3 PhoneNumber (sqlite.feature.many2many.case5.model.PhoneNumber)3 PhoneNumber (sqlite.feature.many2many.case6.model.PhoneNumber)3 PhoneNumber (sqlite.kripton111.model.PhoneNumber)3 PhoneNumber (sqlite.kripton186.model.PhoneNumber)3 Address (com.google.api.services.people.v1.model.Address)2 EmailAddress (com.google.api.services.people.v1.model.EmailAddress)2 Name (com.google.api.services.people.v1.model.Name)2 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 Nullable (com.google.gdata.util.common.base.Nullable)2 Pair (com.google.gdata.util.common.base.Pair)2 Email (ezvcard.property.Email)2