|
|
|
|
@ -4,6 +4,7 @@ package de.srsoftware.umbrella.tags;
@@ -4,6 +4,7 @@ package de.srsoftware.umbrella.tags;
|
|
|
|
|
import static de.srsoftware.tools.jdbc.Condition.equal; |
|
|
|
|
import static de.srsoftware.tools.jdbc.Condition.isNull; |
|
|
|
|
import static de.srsoftware.tools.jdbc.Query.*; |
|
|
|
|
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL; |
|
|
|
|
import static de.srsoftware.umbrella.core.Constants.*; |
|
|
|
|
import static de.srsoftware.umbrella.core.Constants.ERROR_FAILED_CREATE_TABLE; |
|
|
|
|
import static de.srsoftware.umbrella.core.Constants.USER_ID; |
|
|
|
|
@ -16,9 +17,7 @@ import de.srsoftware.tools.jdbc.Query;
@@ -16,9 +17,7 @@ import de.srsoftware.tools.jdbc.Query;
|
|
|
|
|
import de.srsoftware.umbrella.core.exceptions.UmbrellaException; |
|
|
|
|
import java.sql.Connection; |
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
import java.util.Collection; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
public class SqliteDb implements TagDB{ |
|
|
|
|
private static final int INITIAL_DB_VERSION = 1; |
|
|
|
|
@ -110,6 +109,23 @@ CREATE TABLE IF NOT EXISTS "{0}" (
@@ -110,6 +109,23 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Map<String, List<Long>> getUses(String tag, long userId) { |
|
|
|
|
try { |
|
|
|
|
var rs = select(ALL).from(TABLE_TAGS).where(TAG,equal(tag)).where(USER_ID,equal(userId)).exec(db); |
|
|
|
|
var result = new HashMap<String,List<Long>>(); |
|
|
|
|
while (rs.next()){ |
|
|
|
|
var module = rs.getString(MODULE); |
|
|
|
|
var entityId = rs.getLong(ID); |
|
|
|
|
result.computeIfAbsent(module, k -> new ArrayList<>()).add(entityId); |
|
|
|
|
} |
|
|
|
|
rs.close(); |
|
|
|
|
return result; |
|
|
|
|
} catch (SQLException e){ |
|
|
|
|
throw new UmbrellaException("Failed to load uses of tag \"{0}\"!",tag); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void init(){ |
|
|
|
|
var version = createTables(); |
|
|
|
|
LOG.log(INFO,"Updated task db to version {0}",version); |
|
|
|
|
|