Proyectos de Subversion Android Microlearning - Inconcert

Rev

Rev 14 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 gabriel 1
package com.cesams.twogetskills.inconcert.dao;
2
 
3
import androidx.room.Dao;
14 gabriel 4
import androidx.room.Delete;
1 gabriel 5
import androidx.room.Insert;
6
import androidx.room.Query;
7
import androidx.room.Update;
8
 
9
import com.cesams.twogetskills.inconcert.entity.Capsule;
10
import com.cesams.twogetskills.inconcert.room.ResultCount;
11
 
12
import java.util.List;
13
 
14
@Dao
15
public interface CapsuleDao {
16
 
18 efrain 17
    @Query("SELECT * FROM tb_capsules WHERE uuid IN (select capsule_uuid from tb_progress WHERE user_uuid = :useruUuid AND type = 'c' AND progress <= 100 AND completed = 0 ORDER BY updated_on DESC LIMIT 1) LIMIT 1")
18
    Capsule selectLastInProgress(String useruUuid);
19
 
20
    @Query("SELECT * FROM tb_capsules WHERE uuid NOT IN (select capsule_uuid from tb_progress WHERE user_uuid = :useruUuid AND type = 'c')  ORDER BY name")
21
    List<Capsule> selectAllPending(String useruUuid);
22
 
23
    @Query("SELECT * FROM tb_capsules WHERE name LIKE :search AND uuid NOT IN (select capsule_uuid from tb_progress WHERE user_uuid = :useruUuid AND type = 'c')  ORDER BY name")
24
    List<Capsule> selectAllPendingWithSearch(String useruUuid, String search);
25
 
26
    @Query("SELECT * FROM tb_capsules WHERE uuid IN (select capsule_uuid from tb_progress WHERE user_uuid = :useruUuid AND type = 'c' AND progress <= 100 AND completed = 0 ORDER BY updated_on DESC)  ORDER BY name")
27
    List<Capsule> selectAllInProgress(String useruUuid);
28
 
29
    @Query("SELECT * FROM tb_capsules WHERE name LIKE :search AND uuid  IN (select capsule_uuid from tb_progress WHERE user_uuid = :useruUuid AND type = 'c' AND progress <= 100 AND completed = 0 ORDER BY updated_on DESC)  ORDER BY name")
30
    List<Capsule> selectAllInProgressWithSearch(String useruUuid, String search);
31
 
32
 
33
 
34
    @Query("SELECT * FROM tb_capsules WHERE uuid  IN (select capsule_uuid from tb_progress WHERE user_uuid = :useruUuid AND type = 'c' AND progress >= 100 AND completed = 1 ORDER BY updated_on DESC)  ORDER BY name")
35
    List<Capsule> selectAllCompleted(String useruUuid);
36
 
37
    @Query("SELECT * FROM tb_capsules WHERE name LIKE :search AND uuid IN (select capsule_uuid from tb_progress WHERE user_uuid = :useruUuid AND type = 'c' AND progress >= 100 AND completed = 1 ORDER BY updated_on DESC)  ORDER BY name")
38
    List<Capsule> selectAllCompletedWithSearch(String useruUuid, String search);
39
 
1 gabriel 40
    @Query("SELECT * FROM tb_capsules ORDER BY position, name")
41
    List<Capsule> selectAll();
42
 
43
    @Query("SELECT * FROM tb_capsules WHERE topic_uuid = :topicUuid ORDER BY position, name")
44
    List<Capsule> selectAllByTopicUuid(String topicUuid);
45
 
46
    @Query("SELECT * FROM tb_capsules WHERE topic_uuid = :topicUuid ORDER BY added_on DESC")
47
    List<Capsule> selectAllByTopicUuidandOrder(String topicUuid);
48
 
49
 
50
    @Query("SELECT * FROM tb_capsules WHERE uuid = :uuid LIMIT 1")
51
    Capsule selectByUuid(String uuid);
52
 
53
    @Query("SELECT COUNT(*) AS count FROM tb_capsules WHERE topic_uuid = :topicUuid LIMIT 1")
54
    ResultCount getCountByTopicUuid(String topicUuid);
55
 
56
    @Query("SELECT COUNT(*) AS count FROM tb_capsules LIMIT 1")
57
    ResultCount getCount();
58
 
59
    @Insert
60
    void insert(Capsule capsule);
61
 
62
 
63
    @Update
64
    void update(Capsule capsule);
65
 
14 gabriel 66
    @Query("UPDATE tb_capsules set total_comments= :total_comments, total_rating= :total_rating where uuid=:uuid")
67
    void updateByUuid(String uuid, String total_comments, String total_rating);
68
 
1 gabriel 69
    @Query("DELETE FROM tb_capsules WHERE uuid = :uuid")
70
    void removeByUuid(String uuid);
71
 
72
    @Query("DELETE FROM tb_capsules")
73
    void removeAll();
74
 
75
}