use of com.j256.ormlite.dao.Dao in project krypton-android by kryptco.
the class Approval method isGitTagApprovedNow.
public static synchronized boolean isGitTagApprovedNow(Dao<Approval, Long> db, UUID pairingUUID, Long temporaryApprovalSeconds) throws SQLException {
deleteExpiredApprovals(db, temporaryApprovalSeconds);
QueryBuilder query = db.queryBuilder();
return query.where().eq("pairing_uuid", pairingUUID).and().eq("type", ApprovalType.GIT_TAG_SIGNATURES).countOf() > 0;
}
use of com.j256.ormlite.dao.Dao in project krypton-android by kryptco.
the class Approval method isSSHAnyHostApprovedNow.
public static synchronized boolean isSSHAnyHostApprovedNow(Dao<Approval, Long> db, UUID pairingUUID, Long temporaryApprovalSeconds) throws SQLException {
deleteExpiredApprovals(db, temporaryApprovalSeconds);
QueryBuilder query = db.queryBuilder();
return query.where().eq("pairing_uuid", pairingUUID).and().eq("type", ApprovalType.SSH_ANY_HOST).countOf() > 0;
}
use of com.j256.ormlite.dao.Dao in project ETSMobile-Android2 by ApplETS.
the class NoteManager method deleteExpiredListeDesElementsEvaluation.
/**
* Deletes marks in DB that doesn't exist on API
*
* @param
*/
private void deleteExpiredListeDesElementsEvaluation(String id) {
DatabaseHelper dbHelper = new DatabaseHelper(context);
try {
Dao<ListeDesElementsEvaluation, String> listeDesElementsEvaluationDao = dbHelper.getDao(ListeDesElementsEvaluation.class);
ListeDesElementsEvaluation listeDesElementsEvaluation = listeDesElementsEvaluationDao.queryForId(id);
if (listeDesElementsEvaluation != null) {
Dao<ElementEvaluation, String> elementsEvaluationDao = dbHelper.getDao(ElementEvaluation.class);
DeleteBuilder<ElementEvaluation, String> deleteBuilder = elementsEvaluationDao.deleteBuilder();
Where where = deleteBuilder.where();
where.eq("listeDesElementsEvaluation_id", listeDesElementsEvaluation);
deleteBuilder.delete();
}
listeDesElementsEvaluationDao.deleteById(id);
} catch (SQLException e) {
e.printStackTrace();
}
}
use of com.j256.ormlite.dao.Dao in project ETSMobile-Android2 by ApplETS.
the class BottinFragment method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.menu_item_update:
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(R.string.menu_bottin_refresh).setView(getActivity().getLayoutInflater().inflate(R.layout.dialog_bottin, null)).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//Suppression du bottin
DatabaseHelper dbHelper = new DatabaseHelper(getActivity());
try {
Dao<FicheEmploye, ?> ficheEmployeDao = dbHelper.getDao(FicheEmploye.class);
List<FicheEmploye> ficheEmployeList = ficheEmployeDao.queryForAll();
for (FicheEmploye ficheEmploye : ficheEmployeList) {
ficheEmployeDao.delete(ficheEmploye);
}
} catch (SQLException e) {
e.printStackTrace();
}
//Mise à jour de la liste
listDataHeader = new ArrayList<>();
listDataChild = new HashMap<>();
listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);
expListView.setAdapter(listAdapter);
updateUI();
dialogInterface.dismiss();
}
}).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
}
});
builder.create().show();
return true;
}
return super.onOptionsItemSelected(item);
}
use of com.j256.ormlite.dao.Dao in project ETSMobile-Android2 by ApplETS.
the class Utility method loadNotifications.
/**
* Gets MonÉTS notifications and update DB
* @param context
* @param requestListener
*/
public static void loadNotifications(Context context, final RequestListener<Object> requestListener) {
final SecurePreferences securePreferences = new SecurePreferences(context);
final boolean allNotifsLoaded = securePreferences.getBoolean(Constants.ALL_NOTIFS_LOADED, false);
MonETSNotificationsRequest monETSNotificationsRequest;
if (!allNotifsLoaded) {
monETSNotificationsRequest = new MonETSNotificationsRequest(context, false);
} else {
monETSNotificationsRequest = new MonETSNotificationsRequest(context, true);
}
final DataManager dataManager = DataManager.getInstance(context);
dataManager.start();
final DatabaseHelper databaseHelper = new DatabaseHelper(context);
dataManager.sendRequest(monETSNotificationsRequest, new RequestListener<Object>() {
@Override
public void onRequestFailure(SpiceException spiceException) {
requestListener.onRequestFailure(spiceException);
dataManager.stop();
}
@Override
public void onRequestSuccess(Object o) {
if (o instanceof MonETSNotificationList) {
try {
Dao<MonETSNotification, ?> dao = databaseHelper.getDao(MonETSNotification.class);
MonETSNotificationList list = (MonETSNotificationList) o;
for (MonETSNotification monETSNotification : list) {
dao.createOrUpdate(monETSNotification);
}
if (!allNotifsLoaded) {
securePreferences.edit().putBoolean(Constants.ALL_NOTIFS_LOADED, true).commit();
}
requestListener.onRequestSuccess(list);
} catch (SQLException e) {
e.printStackTrace();
}
}
dataManager.stop();
}
});
}
Aggregations