FairEmail/app/src/main/java/eu/faircode/email/DaoOperation.java

76 lines
2.6 KiB
Java
Raw Normal View History

2018-08-02 13:33:06 +00:00
package eu.faircode.email;
/*
2018-08-14 05:53:24 +00:00
This file is part of FairEmail.
2018-08-02 13:33:06 +00:00
2018-08-14 05:53:24 +00:00
FairEmail is free software: you can redistribute it and/or modify
2018-08-02 13:33:06 +00:00
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
2018-10-29 10:46:49 +00:00
FairEmail is distributed in the hope that it will be useful,
2018-08-02 13:33:06 +00:00
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
2018-10-29 10:46:49 +00:00
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
2018-08-02 13:33:06 +00:00
2018-12-31 08:04:33 +00:00
Copyright 2018-2019 by Marcel Bokhorst (M66B)
2018-08-02 13:33:06 +00:00
*/
import java.util.List;
import androidx.lifecycle.LiveData;
2018-08-08 06:55:47 +00:00
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
2018-08-02 13:33:06 +00:00
@Dao
public interface DaoOperation {
2018-12-03 14:46:24 +00:00
@Query("SELECT * FROM operation" +
" WHERE folder = :folder" +
2018-12-08 18:03:24 +00:00
" ORDER BY" +
" CASE WHEN name = '" + EntityOperation.SYNC + "' THEN" +
" CASE WHEN :outbox THEN -1 ELSE 1 END" +
" ELSE 0" +
" END" +
", id")
List<EntityOperation> getOperationsByFolder(long folder, boolean outbox);
2018-08-09 20:45:42 +00:00
@Query("SELECT operation.*, account.name AS accountName, folder.name AS folderName" +
" FROM operation" +
" JOIN folder ON folder.id = operation.folder" +
2018-12-21 08:03:54 +00:00
" LEFT JOIN account ON account.id = folder.account" +
" ORDER BY operation.id")
LiveData<List<TupleOperationEx>> liveOperations();
2018-08-13 06:59:05 +00:00
2018-12-02 13:19:54 +00:00
@Query("SELECT * FROM operation WHERE folder = :folder ORDER BY id")
LiveData<List<EntityOperation>> liveOperations(long folder);
2018-12-01 14:38:02 +00:00
@Query("SELECT * FROM operation ORDER BY id")
List<EntityOperation> getOperations();
2018-12-11 17:59:02 +00:00
@Query("SELECT * FROM operation WHERE error IS NOT NULL")
List<EntityOperation> getOperationsError();
2018-12-02 13:19:54 +00:00
@Query("SELECT COUNT(id) FROM operation" +
" WHERE folder = :folder" +
" AND (:name IS NULL OR operation.name = :name)")
int getOperationCount(long folder, String name);
2018-08-04 22:35:47 +00:00
@Query("SELECT COUNT(id) FROM operation" +
" WHERE folder = :folder" +
" AND message = :message")
int getOperationCount(long folder, long message);
2018-12-01 14:13:57 +00:00
@Query("UPDATE operation SET error = :error WHERE id = :id")
int setOperationError(long id, String error);
2018-08-12 08:16:41 +00:00
@Insert
long insertOperation(EntityOperation operation);
2018-08-02 13:33:06 +00:00
@Query("DELETE FROM operation WHERE id = :id")
void deleteOperation(long id);
}