Commit cd74ff653a842ec19b814d0056c259712e42d441

Authored by Ali B
1 parent ac812b32

Working on SQLite database tables and objects

Risiko/.idea/caches/build_file_checksums.ser 0 → 100644
No preview for this file type
Risiko/.idea/codeStyles/Project.xml 0 → 100644
  1 +<component name="ProjectCodeStyleConfiguration">
  2 + <code_scheme name="Project" version="173">
  3 + <Objective-C-extensions>
  4 + <file>
  5 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
  6 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
  7 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
  8 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
  9 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
  10 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
  11 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
  12 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
  13 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
  14 + </file>
  15 + <class>
  16 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
  17 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
  18 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
  19 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
  20 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
  21 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
  22 + </class>
  23 + <extensions>
  24 + <pair source="cpp" header="h" fileNamingConvention="NONE" />
  25 + <pair source="c" header="h" fileNamingConvention="NONE" />
  26 + </extensions>
  27 + </Objective-C-extensions>
  28 + </code_scheme>
  29 +</component>
0 30 \ No newline at end of file
... ...
Risiko/.idea/misc.xml
... ... @@ -30,20 +30,4 @@
30 30 <component name="ProjectType">
31 31 <option name="id" value="Android" />
32 32 </component>
33   - <component name="masterDetails">
34   - <states>
35   - <state key="ProjectJDKs.UI">
36   - <settings>
37   - <last-edited>1.8</last-edited>
38   - <splitter-proportions>
39   - <option name="proportions">
40   - <list>
41   - <option value="0.2" />
42   - </list>
43   - </option>
44   - </splitter-proportions>
45   - </settings>
46   - </state>
47   - </states>
48   - </component>
49 33 </project>
50 34 \ No newline at end of file
... ...
Risiko/.idea/vcs.xml
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <project version="4">
3 3 <component name="VcsDirectoryMappings">
4   - <mapping directory="$PROJECT_DIR$" vcs="Git" />
  4 + <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
5 5 </component>
6 6 </project>
7 7 \ No newline at end of file
... ...
Risiko/app/src/main/java/database/DatabaseHelper.java 0 → 100644
  1 +package database;
  2 +
  3 +
  4 +import android.content.Context;
  5 +import android.database.sqlite.SQLiteDatabase;
  6 +import android.database.sqlite.SQLiteOpenHelper;
  7 +
  8 +public class DatabaseHelper extends SQLiteOpenHelper {
  9 +
  10 + private static DatabaseHelper instance;
  11 + private static final String TAG = "DatabaseHelper";
  12 + private static final String DATABASE_NAME = "risk_eval.db";
  13 + private static final int DATABASE_VERSION = 1;
  14 +
  15 + private DatabaseHelper(Context context){
  16 + super(context, DATABASE_NAME, null, DATABASE_VERSION);
  17 + }
  18 +
  19 + public static synchronized DatabaseHelper getInstance(Context context){
  20 + if(instance == null){
  21 + instance = new DatabaseHelper(context.getApplicationContext());
  22 + }
  23 + return instance;
  24 + }
  25 +
  26 + @Override
  27 + public void onCreate(SQLiteDatabase db) {
  28 + EvaluationTable.onCreate(db);
  29 + IncidentTable.onCreate(db);
  30 + }
  31 +
  32 + @Override
  33 + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  34 + EvaluationTable.onUpgrade(db, oldVersion, newVersion);
  35 + IncidentTable.onUpgrade(db, oldVersion, newVersion);
  36 + }
  37 +
  38 +}
... ...
Risiko/app/src/main/java/database/DatabaseSource.java 0 → 100644
  1 +package database;
  2 +
  3 +import android.content.Context;
  4 +
  5 +public class DatabaseSource {
  6 +
  7 + private DatabaseHelper helper;
  8 +
  9 + public DatabaseSource(Context context){
  10 + this.helper = DatabaseHelper.getInstance(context);
  11 + }
  12 +
  13 +}
... ...
Risiko/app/src/main/java/database/EvaluationTable.java 0 → 100644
  1 +package database;
  2 +
  3 +import android.database.sqlite.SQLiteDatabase;
  4 +
  5 +public class EvaluationTable {
  6 +
  7 + public static final String EVALUATION_TABLE = "EVALUATION";
  8 + public static final String EVALUATION_COL_ID = "ID";
  9 + public static final String EVALUATION_COL_ASSOCIATED_ACTIVITY = "ASSOCIATED_ACTIVITY";
  10 + public static final String EVALUATION_COL_TITLE = "TITLE";
  11 + public static final String EVALUATION_COL_OUTCOME = "OUTCOME";
  12 + public static final String EVALUATION_COL_ACTION = "PREVENTIVE_ACTION";
  13 + public static final String EVALUATION_COL_CONSEQUENCE = "CONSEQUENCE";
  14 + public static final String EVALUATION_COL_PROBABILITY = "PROBABILITY";
  15 +
  16 + private static final String EVALUATION_TABLE_CREATE =
  17 + "CREATE TABLE IF NOT EXISTS " + EVALUATION_TABLE + " ("
  18 + + EVALUATION_COL_ID + " INTEGER, "
  19 + + EVALUATION_COL_ASSOCIATED_ACTIVITY + " INTEGER, "
  20 + + EVALUATION_COL_TITLE + " TEXT, "
  21 + + EVALUATION_COL_OUTCOME + " TEXT, "
  22 + + EVALUATION_COL_ACTION + " TEXT, "
  23 + + EVALUATION_COL_CONSEQUENCE + " INTEGER, "
  24 + + EVALUATION_COL_PROBABILITY + " INTEGER, "
  25 + + "PRIMARY KEY (" + EVALUATION_COL_ID + ")) ";
  26 +
  27 + public static void onCreate(SQLiteDatabase database){
  28 + database.execSQL(EVALUATION_TABLE_CREATE);
  29 + }
  30 +
  31 + public static void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion){
  32 + database.execSQL("drop table if exists " + EVALUATION_TABLE);
  33 + onCreate(database);
  34 + }
  35 +
  36 +}
... ...
Risiko/app/src/main/java/database/IncidentTable.java 0 → 100644
  1 +package database;
  2 +
  3 +import android.database.sqlite.SQLiteDatabase;
  4 +
  5 +public class IncidentTable {
  6 +
  7 + public static final String INCIDENT_TABLE = "INCIDENT";
  8 + public static final String INCIDENT_COL_ID = "ID";
  9 + public static final String INCIDENT_COL_ASSOCIATED_EVALUATION = "ASSOCIATED_EVALUATION";
  10 + public static final String INCIDENT_COL_TITLE = "TITLE";
  11 + public static final String INCIDENT_COL_OUTCOME = "OUTCOME";
  12 + public static final String INCIDENT_COL_ACTION = "PREVENTIVE_ACTION";
  13 + public static final String INCIDENT_COL_CONSEQUENCE = "CONSEQUENCE";
  14 + public static final String INCIDENT_COL_PROBABILITY = "PROBABILITY";
  15 +
  16 + private static final String INCIDENT_TABLE_CREATE =
  17 + "CREATE TABLE IF NOT EXISTS " + INCIDENT_TABLE + " ("
  18 + + INCIDENT_COL_ID + " INTEGER, "
  19 + + INCIDENT_COL_TITLE + " TEXT, "
  20 + + INCIDENT_COL_OUTCOME + " TEXT, "
  21 + + INCIDENT_COL_ACTION + " TEXT, "
  22 + + INCIDENT_COL_CONSEQUENCE + " INTEGER, "
  23 + + INCIDENT_COL_PROBABILITY + " INTEGER, "
  24 + + "FOREIGN KEY (" + INCIDENT_COL_ASSOCIATED_EVALUATION + ") REFERENCES " + EvaluationTable.EVALUATION_TABLE + "(" + EvaluationTable.EVALUATION_COL_ID + "),"
  25 + + "PRIMARY KEY (" + INCIDENT_COL_ID + ")) ";
  26 +
  27 + public static void onCreate(SQLiteDatabase database){
  28 + database.execSQL(INCIDENT_TABLE_CREATE);
  29 + }
  30 +
  31 + public static void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion){
  32 + database.execSQL("drop table if exists " + INCIDENT_TABLE);
  33 + onCreate(database);
  34 + }
  35 +
  36 +}
... ...