View difference between Paste ID: 6KMw5kKE and 3PR0R2DK
SHOW: | | - or go back to the newest paste.
1
package com.conceptualsystems.database;
2
3
import android.provider.BaseColumns;
4
5
import java.util.HashMap;
6
import java.util.Map;
7
8
///////////////////////////////////
9
//  CHANGELOG
10
//  =============================
11
//  6/24/11 - v2
12
13
public final class DatabaseSchema {
14
	public static final String DATABASE_NAME = "smskitting";
15
	public static final int DATABASE_VERSION = 5;
16
	public static final String SORT_ASC = " ASC";
17
	public static final String SORT_DESC = " DESC";
18
	public static final String[] ORDERS = {SORT_ASC,SORT_DESC};
19
	public static final int OFF = 0;
20
	public static final int ON = 1;
21-
	public static final Map<String, Class<? implements BaseColumns>> DatabaseTables = new HashMap<String, Class<? implements BaseColumns>>();
21+
	public static final Map<String, Class<? extends Schema>> DatabaseTables = new HashMap<String, Class<? extends Schema>>();
22
	public static final DatabaseSchema instance = new DatabaseSchema();
23
24
	/*** tried this
25
	static {
26
		instance.DatabaseTables.put("kit", KitSchema);
27
	}
28-
	public static final class KitSchema implements BaseColumns {
28+
	***** and this
29
	private DatabaseSchema() {
30
		instance.DatabaseTables.put("KitSchema", KitSchema);
31
	}
32
	 */
33
34
	public static final DatabaseSchema getSchema() {
35
		return instance;
36
	}
37
	
38
	public static final class KitSchema implements Schema {
39
		public static final String TABLE_NAME = "kit";
40
		public static final String COLUMN_ID = "kit_id";
41
		public static final String COLUMN_RAW_ID = "raw_id";
42
		public static final String COLUMN_FIN_ID = "fin_id";
43
		public static final String COLUMN_DATE = "date";
44
		public static final String COLUMN_GROSS = "gross";
45
		public static final String COLUMN_NET = "net";
46
		public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + 
47
				_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + 
48
				COLUMN_ID + " TEXT NOT NULL," + 
49
				COLUMN_RAW_ID + " TEXT," + 
50
				COLUMN_FIN_ID + " TEXT NOT NULL," + 
51
				COLUMN_DATE + " LONG NOT NULL," + 
52
				COLUMN_GROSS + " LONG NOT NULL," + 
53
				COLUMN_NET + " LONG NOT NULL);";
54
		public static final String DROP_TABLE = "DROP TABLE IF EXISTS " + TABLE_NAME;
55
	}
56
57
	public static final class ShipmentSchema implements BaseColumns {
58
		public static final String TABLE_NAME = "shipment";
59
		public static final String COLUMN_ID = "kit_id";
60
		public static final String COLUMN_SHIP_ID = "ship_id";
61
		public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + 
62
				_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + 
63
				COLUMN_SHIP_ID + " TEXT NOT NULL," + 
64
				COLUMN_ID + " TEXT NOT NULL);";
65
		public static final String DROP_TABLE = "DROP TABLE IF EXISTS " + TABLE_NAME;
66
	}
67
	
68
	public static final class TargetSchema implements BaseColumns {
69
		public static final String TABLE_NAME = "target";
70
		public static final String COLUMN_TARGET = "target_weight";
71
		public static final String COLUMN_SHIP_ID = "ship_id";
72
		public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + 
73
				_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + 
74
				COLUMN_SHIP_ID + " TEXT NOT NULL," + 
75
				COLUMN_TARGET + " TEXT NOT NULL);";
76
		public static final String DROP_TABLE = "DROP TABLE IF EXISTS " + TABLE_NAME;
77
	}
78
	
79
	public static final class SiteSchema implements BaseColumns {
80
		public static final String TABLE_NAME = "site";
81
		public static final String COLUMN_LABEL = "label";
82
		public static final String COLUMN_IP = "ip";
83
		public static final String COLUMN_PORT = "port";
84
		public static final String COLUMN_ACTIVATION_CODE = "code";
85
		public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + 
86
				_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + 
87
				COLUMN_LABEL + " TEXT NOT NULL," + 
88
				COLUMN_IP + " TEXT NOT NULL," + 
89
				COLUMN_ACTIVATION_CODE + " TEXT," + 
90
				COLUMN_PORT + " TEXT NOT NULL);";
91
		public static final String DROP_TABLE = "DROP TABLE IF EXISTS " + TABLE_NAME;
92
	}
93
	
94
	public static final class CustomerSchema implements BaseColumns {
95
		public static final String TABLE_NAME = "customers";
96
		public static final String COLUMN_NAME = "name";
97
		public static final String COLUMN_ID = "cust_id";
98
		public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + 
99
				_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + 
100
				COLUMN_ID + " TEXT NOT NULL," + 
101
				COLUMN_NAME + " TEXT NOT NULL);";
102
		public static final String DROP_TABLE = "DROP TABLE IF EXISTS " + TABLE_NAME;
103
	}
104
	
105
	public static final class ProductSchema implements BaseColumns {
106
		public static final String TABLE_NAME = "products";
107
		public static final String COLUMN_NAME = "name";
108
		public static final String COLUMN_ID = "prod_id";
109
		public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + 
110
				_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + 
111
				COLUMN_ID + " TEXT NOT NULL," + 
112
				COLUMN_NAME + " TEXT NOT NULL);";
113
		public static final String DROP_TABLE = "DROP TABLE IF EXISTS " + TABLE_NAME;
114
	}
115
}