1 |
|
package com.loopback.androidapps.saveapp; |
2 |
|
|
3 |
|
import android.content.ContentValues; |
4 |
|
import android.database.Cursor; |
5 |
|
import android.util.Log; |
6 |
|
|
|
|
| 57,8% |
Uncovered Elements: 43 (102) |
Complexity: 26 |
Complexity Density: 0,36 |
|
7 |
|
public class AddressX implements SaveAppTable { |
8 |
|
|
9 |
|
private DBManager dbManager; |
10 |
|
private int id; |
11 |
|
private double latitude; |
12 |
|
private double longitude; |
13 |
|
private String description; |
14 |
|
private int placeId; |
15 |
|
private Cursor cursor; |
16 |
|
public static SaveApp saveApp; |
17 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
|
18 |
61
|
public AddressX() {... |
19 |
61
|
dbManager = saveApp.getDbManager(); |
20 |
61
|
id = 0; |
21 |
61
|
latitude = 0; |
22 |
61
|
longitude = 0; |
23 |
61
|
description = null; |
24 |
61
|
placeId = 0; |
25 |
|
} |
26 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
|
27 |
0
|
public AddressX(int _id) {... |
28 |
0
|
dbManager = saveApp.getDbManager(); |
29 |
0
|
id = _id; |
30 |
0
|
latitude = 0; |
31 |
0
|
longitude = 0; |
32 |
0
|
description = null; |
33 |
0
|
placeId = 0; |
34 |
0
|
inflate(id); |
35 |
|
} |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
|
37 |
0
|
public AddressX(int _id, double _longitude, double _latitude,... |
38 |
|
String _description, int _placeId) { |
39 |
0
|
dbManager = saveApp.getDbManager(); |
40 |
0
|
id = _id; |
41 |
0
|
longitude = _longitude; |
42 |
0
|
latitude = _latitude; |
43 |
0
|
description = _description; |
44 |
0
|
placeId = _placeId; |
45 |
|
} |
46 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
|
47 |
0
|
public AddressX(double _longitude, double _latitude, String _description,... |
48 |
|
int _placeId) { |
49 |
0
|
dbManager = saveApp.getDbManager(); |
50 |
0
|
longitude = _longitude; |
51 |
0
|
latitude = _latitude; |
52 |
0
|
description = _description; |
53 |
0
|
placeId = _placeId; |
54 |
0
|
insert(); |
55 |
|
} |
56 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
57 |
0
|
public void setId(int id) {... |
58 |
0
|
this.id = id; |
59 |
|
} |
60 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
0
|
public int getId() {... |
62 |
0
|
return id; |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
1
|
public void setLatitude(double latitude) {... |
66 |
1
|
this.latitude = latitude; |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
5
|
public double getLatitude() {... |
70 |
5
|
return latitude; |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
73 |
1
|
public void setLongitude(double longitude) {... |
74 |
1
|
this.longitude = longitude; |
75 |
|
} |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
2
|
public double getLongitude() {... |
78 |
2
|
return longitude; |
79 |
|
} |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
0
|
public void setDescription(String description) {... |
82 |
0
|
this.description = description; |
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
32
|
public String getDescription() {... |
86 |
32
|
return description; |
87 |
|
} |
88 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
89 |
0
|
public void setPlaceId(int placeId) {... |
90 |
0
|
this.placeId = placeId; |
91 |
|
} |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
93 |
0
|
public int getPlaceId() {... |
94 |
0
|
return placeId; |
95 |
|
} |
96 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
|
97 |
1
|
public int insert() {... |
98 |
1
|
dbManager = saveApp.getDbManager(); |
99 |
|
|
100 |
1
|
ContentValues cv = new ContentValues(); |
101 |
1
|
cv.put(DBManager.ADDRESS_COLUMN_LATITUDE, latitude); |
102 |
1
|
cv.put(DBManager.ADDRESS_COLUMN_LONGITUDE, longitude); |
103 |
1
|
cv.put(DBManager.ADDRESS_COLUMN_DESC, description); |
104 |
1
|
cv.put(DBManager.ADDRESS_COLUMN_PLACE, placeId); |
105 |
1
|
return dbManager.insert(DBManager.ADDRESS_TABLE, cv); |
106 |
|
} |
107 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
|
108 |
1
|
public void update() {... |
109 |
1
|
dbManager = saveApp.getDbManager(); |
110 |
1
|
ContentValues cv = new ContentValues(); |
111 |
1
|
cv.put(DBManager.ADDRESS_COLUMN_LATITUDE, latitude); |
112 |
1
|
cv.put(DBManager.ADDRESS_COLUMN_LONGITUDE, longitude); |
113 |
1
|
cv.put(DBManager.ADDRESS_COLUMN_DESC, description); |
114 |
1
|
cv.put(DBManager.ADDRESS_COLUMN_PLACE, placeId); |
115 |
1
|
dbManager.update(id, DBManager.ADDRESS_TABLE, cv); |
116 |
|
} |
117 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
118 |
0
|
public void delete() {... |
119 |
0
|
dbManager = saveApp.getDbManager(); |
120 |
0
|
dbManager.delete(id, DBManager.ADDRESS_TABLE); |
121 |
|
} |
122 |
|
|
|
|
| 87,5% |
Uncovered Elements: 2 (16) |
Complexity: 3 |
Complexity Density: 0,25 |
|
123 |
37
|
public void inflate(int _id) {... |
124 |
37
|
dbManager = saveApp.getDbManager(); |
125 |
37
|
id = _id; |
126 |
37
|
cursor = dbManager.select(id, DBManager.ADDRESS_TABLE_ID); |
127 |
37
|
int i = 0; |
128 |
37
|
Log.i("AD", "Read Cursor"); |
129 |
37
|
if (cursor.moveToFirst()) |
130 |
37
|
do { |
131 |
37
|
description = cursor.getString(cursor |
132 |
|
.getColumnIndexOrThrow(DBManager.ADDRESS_COLUMN_DESC)); |
133 |
37
|
longitude = Utilities |
134 |
|
.stringToDouble(cursor.getString(cursor |
135 |
|
.getColumnIndexOrThrow(DBManager.ADDRESS_COLUMN_LONGITUDE))); |
136 |
37
|
latitude = Utilities |
137 |
|
.stringToDouble(cursor.getString(cursor |
138 |
|
.getColumnIndexOrThrow(DBManager.ADDRESS_COLUMN_LATITUDE))); |
139 |
37
|
placeId = Utilities |
140 |
|
.stringToInt(cursor.getString(cursor |
141 |
|
.getColumnIndexOrThrow(DBManager.ADDRESS_COLUMN_PLACE))); |
142 |
37
|
i++; |
143 |
37
|
} while (cursor.moveToNext()); |
144 |
|
} |
145 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
146 |
0
|
public boolean existLongitud(String value) {... |
147 |
0
|
return dbManager.exist(DBManager.ADDRESS_TABLE, |
148 |
|
DBManager.ADDRESS_COLUMN_LONGITUDE, value); |
149 |
|
} |
150 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
151 |
0
|
public boolean existLatitud(String value) {... |
152 |
0
|
return dbManager.exist(DBManager.ADDRESS_TABLE, |
153 |
|
DBManager.ADDRESS_COLUMN_LATITUDE, value); |
154 |
|
} |
155 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0,67 |
|
156 |
6
|
public boolean existDescription(String value) {... |
157 |
6
|
if (value == null) |
158 |
0
|
value = ""; |
159 |
6
|
return dbManager.exist(DBManager.ADDRESS_TABLE, |
160 |
|
DBManager.ADDRESS_COLUMN_DESC, value); |
161 |
|
} |
162 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0,5 |
|
163 |
6
|
public int insertOrGetId(String value) {... |
164 |
6
|
if (existDescription(value)) |
165 |
5
|
return dbManager.getId(DBManager.ADDRESS_TABLE, |
166 |
|
DBManager.ADDRESS_COLUMN_DESC, value); |
167 |
|
else { |
168 |
1
|
description = value; |
169 |
1
|
return insert(); |
170 |
|
} |
171 |
|
} |
172 |
|
} |