1 |
|
package com.loopback.androidapps.saveapp; |
2 |
|
|
3 |
|
import java.util.ArrayList; |
4 |
|
|
5 |
|
import android.content.ContentValues; |
6 |
|
import android.database.Cursor; |
7 |
|
import android.util.Log; |
8 |
|
|
|
|
| 60,7% |
Uncovered Elements: 33 (84) |
Complexity: 23 |
Complexity Density: 0,42 |
|
9 |
|
public class Place implements SaveAppTable { |
10 |
|
public static DBManager dbManager; |
11 |
|
private int id; |
12 |
|
private String type; |
13 |
|
private String description; |
14 |
|
private Cursor cursor; |
15 |
|
public static SaveApp saveApp; |
16 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
17 |
70
|
public Place() {... |
18 |
70
|
type = null; |
19 |
70
|
description = null; |
20 |
70
|
dbManager = saveApp.getDbManager(); |
21 |
|
} |
22 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
23 |
0
|
public Place(int _id, String _type, String _description) {... |
24 |
0
|
dbManager = saveApp.getDbManager(); |
25 |
0
|
this.id = _id; |
26 |
0
|
this.type = _type; |
27 |
0
|
this.description = _description; |
28 |
|
} |
29 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
30 |
0
|
public void setId(int id) {... |
31 |
0
|
this.id = id; |
32 |
|
} |
33 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
34 |
0
|
public int getId() {... |
35 |
0
|
return id; |
36 |
|
} |
37 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
38 |
0
|
public void setSymbol(String symbol) {... |
39 |
0
|
this.type = symbol; |
40 |
|
} |
41 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
0
|
public String getSymbol() {... |
43 |
0
|
return type; |
44 |
|
} |
45 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
0
|
public void setDescription(String description) {... |
47 |
0
|
this.description = description; |
48 |
|
} |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
32
|
public String getDescription() {... |
51 |
32
|
return description; |
52 |
|
} |
53 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
54 |
0
|
public int insert(String _address, double _longitude, double _latitude) {... |
55 |
|
|
56 |
|
|
57 |
0
|
Log.i("PL", "Inserting Addres..."); |
58 |
|
|
59 |
0
|
ContentValues cv = new ContentValues(); |
60 |
0
|
cv.put(DBManager.PLACE_COLUMN_TYPE, type); |
61 |
0
|
cv.put(DBManager.PLACE_COLUMN_DESC, description); |
62 |
0
|
return dbManager.insert(DBManager.PLACE_TABLE, cv); |
63 |
|
} |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
65 |
0
|
public void update() {... |
66 |
0
|
ContentValues cv = new ContentValues(); |
67 |
0
|
cv.put(DBManager.PLACE_COLUMN_TYPE, type); |
68 |
0
|
cv.put(DBManager.PLACE_COLUMN_DESC, description); |
69 |
0
|
dbManager.update(id, DBManager.PLACE_TABLE, cv); |
70 |
|
} |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
72 |
0
|
public void delete() {... |
73 |
0
|
dbManager.delete(id, DBManager.PLACE_TABLE); |
74 |
|
} |
75 |
|
|
|
|
| 84,6% |
Uncovered Elements: 2 (13) |
Complexity: 3 |
Complexity Density: 0,33 |
|
76 |
32
|
public void inflate(int _id) {... |
77 |
32
|
id = _id; |
78 |
32
|
cursor = dbManager.select(id, DBManager.PLACE_TABLE_ID); |
79 |
32
|
int i = 0; |
80 |
32
|
Log.i("PL", "Read Cursor"); |
81 |
32
|
if (cursor.moveToFirst()) |
82 |
32
|
do { |
83 |
32
|
description = cursor.getString(cursor |
84 |
|
.getColumnIndexOrThrow(DBManager.PLACE_COLUMN_DESC)); |
85 |
32
|
type = cursor.getString(cursor |
86 |
|
.getColumnIndexOrThrow(DBManager.PLACE_COLUMN_TYPE)); |
87 |
32
|
i++; |
88 |
32
|
} while (cursor.moveToNext()); |
89 |
|
} |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
0
|
public boolean existType(String value) {... |
92 |
0
|
return dbManager.exist(DBManager.PLACE_TABLE, |
93 |
|
DBManager.PLACE_COLUMN_TYPE, value); |
94 |
|
} |
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
96 |
5
|
public boolean existDescription(String value) {... |
97 |
5
|
return dbManager.exist(DBManager.PLACE_TABLE, |
98 |
|
DBManager.PLACE_COLUMN_DESC, value); |
99 |
|
} |
100 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0,5 |
|
101 |
5
|
public int insertOrGetId(String value) {... |
102 |
5
|
if (existDescription(value)) |
103 |
2
|
return dbManager.getId(DBManager.PLACE_TABLE, |
104 |
|
DBManager.PLACE_COLUMN_DESC, value); |
105 |
|
else{ |
106 |
3
|
description=value; |
107 |
3
|
return insert(); |
108 |
|
} |
109 |
|
} |
110 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
111 |
3
|
public int insert() {... |
112 |
3
|
ContentValues cv = new ContentValues(); |
113 |
3
|
cv.put(DBManager.PLACE_COLUMN_TYPE, type); |
114 |
3
|
cv.put(DBManager.PLACE_COLUMN_DESC, description); |
115 |
3
|
return dbManager.insert(DBManager.PLACE_TABLE, cv); |
116 |
|
} |
117 |
|
|
|
|
| 94,7% |
Uncovered Elements: 1 (19) |
Complexity: 4 |
Complexity Density: 0,31 |
|
118 |
14
|
public String[] selectPlaces() {... |
119 |
14
|
ArrayList<String> places = new ArrayList<String>(); |
120 |
14
|
cursor = dbManager.selectFilter(DBManager.PLACE_TABLE,DBManager.PLACE_COLUMN_DESC,1,"1"); |
121 |
14
|
int i = 0; |
122 |
14
|
Log.i("AC", "Read Cursor"); |
123 |
14
|
if (cursor.moveToFirst()) |
124 |
14
|
do { |
125 |
29
|
description = cursor.getString(cursor |
126 |
|
.getColumnIndexOrThrow(DBManager.PLACE_COLUMN_DESC)); |
127 |
29
|
places.add(description); |
128 |
29
|
i++; |
129 |
29
|
} while (cursor.moveToNext()); |
130 |
14
|
String[] placeStrings = new String[places.size()]; |
131 |
43
|
for (int j = 0; j< places.size();j++) { |
132 |
29
|
placeStrings[j]=places.get(j); |
133 |
|
} |
134 |
|
|
135 |
14
|
return placeStrings; |
136 |
|
} |
137 |
|
} |