implemented creation of wiki tables
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -58,6 +58,7 @@ onMount(fetchModules);
|
||||
<a href="#" onclick={() => go('/bookmark')}>{t('bookmarks')}</a>
|
||||
<a href="#" onclick={() => go('/notes')}>{t('notes')}</a>
|
||||
<a href="#" onclick={() => go('/time')}>{t('timetracking')}</a>
|
||||
<a href="#" onclick={() => go('/wiki')}>{t('wiki')}</a>
|
||||
<a href="https://svelte.dev/tutorial/svelte/state" target="_blank">{t('tutorial')}</a>
|
||||
{#each modules as module,i}
|
||||
{#if module.name.trim()}<a href={module.url}>{module.name}</a>{/if}
|
||||
|
||||
5
wiki/build.gradle.kts
Normal file
5
wiki/build.gradle.kts
Normal file
@@ -0,0 +1,5 @@
|
||||
description = "Umbrella : Wiki"
|
||||
|
||||
dependencies{
|
||||
implementation(project(":core"))
|
||||
}
|
||||
@@ -5,4 +5,10 @@ public class Constants {
|
||||
private Constants(){}
|
||||
|
||||
public static final String CONFIG_DATABASE = "umbrella.modules.wiki.database";
|
||||
public static final String CONTENT = "content";
|
||||
public static final String PAGE_ID = "page_id";
|
||||
public static final String PERMISSIONS = "permissions";
|
||||
public static final String TABLE_PAGES = "pages";
|
||||
public static final String TABLE_PAGES_USERS = "pages_users";
|
||||
public static final String VERSION = "version";
|
||||
}
|
||||
|
||||
@@ -3,6 +3,22 @@ package de.srsoftware.umbrella.wiki;
|
||||
import de.srsoftware.umbrella.core.BaseDb;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.Constants.DESCRIPTION;
|
||||
import static de.srsoftware.umbrella.core.Constants.DUE_DATE;
|
||||
import static de.srsoftware.umbrella.core.Constants.ERROR_FAILED_CREATE_TABLE;
|
||||
import static de.srsoftware.umbrella.core.Constants.EST_TIME;
|
||||
import static de.srsoftware.umbrella.core.Constants.NAME;
|
||||
import static de.srsoftware.umbrella.core.Constants.NO_INDEX;
|
||||
import static de.srsoftware.umbrella.core.Constants.SHOW_CLOSED;
|
||||
import static de.srsoftware.umbrella.core.Constants.START_DATE;
|
||||
import static de.srsoftware.umbrella.core.Constants.STATUS;
|
||||
import static de.srsoftware.umbrella.core.model.Status.OPEN;
|
||||
import static de.srsoftware.umbrella.wiki.Constants.*;
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
public class SqliteDb extends BaseDb implements WikiDb {
|
||||
private static final System.Logger LOG = System.getLogger("TaskDb");
|
||||
@@ -16,9 +32,35 @@ public class SqliteDb extends BaseDb implements WikiDb {
|
||||
protected int createTables() {
|
||||
int currentVersion = createSettingsTable();
|
||||
switch (currentVersion){
|
||||
case 0: ; // TODO
|
||||
case 0:
|
||||
createPagesTable();
|
||||
createPagesUsersTable();
|
||||
}
|
||||
|
||||
return setCurrentVersion(3);
|
||||
return setCurrentVersion(1);
|
||||
}
|
||||
|
||||
private void createPagesUsersTable() {
|
||||
var sql = "CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) NOT NULL, {2} INT NOT NULL, {3} INT NOT NULL, PRIMARY KEY({1}, {2}))";
|
||||
try {
|
||||
var stmt = db.prepareStatement(format(sql, TABLE_PAGES_USERS, PAGE_ID, USER_ID, PERMISSIONS));
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR, ERROR_FAILED_CREATE_TABLE, TABLE_PAGES, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void createPagesTable() {
|
||||
var sql = "CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) NOT NULL, {2} INT NOT NULL, {3} TEXT NOT NULL, PRIMARY KEY({1},{2}))";
|
||||
try {
|
||||
var stmt = db.prepareStatement(format(sql, TABLE_PAGES, ID, VERSION, CONTENT));
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR, ERROR_FAILED_CREATE_TABLE, TABLE_PAGES, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user