|
|
|
|
@ -2,8 +2,8 @@
@@ -2,8 +2,8 @@
|
|
|
|
|
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; |
|
|
|
|
@ -14,7 +14,6 @@ import static java.text.MessageFormat.format;
@@ -14,7 +14,6 @@ import static java.text.MessageFormat.format;
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
@ -72,7 +71,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
@@ -72,7 +71,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
|
|
|
|
{1} VARCHAR(255) NOT NULL, |
|
|
|
|
{2} VARCHAR(20) NOT NULL, |
|
|
|
|
{3} INTEGER NOT NULL, |
|
|
|
|
{4} INTEGER NOT NULL, |
|
|
|
|
{4} INTEGER, |
|
|
|
|
PRIMARY KEY ({1}, {2}, {3}, {4}) |
|
|
|
|
)"""; |
|
|
|
|
try { |
|
|
|
|
@ -91,6 +90,9 @@ CREATE TABLE IF NOT EXISTS "{0}" (
@@ -91,6 +90,9 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
|
|
|
|
Query.delete().from(TABLE_TAGS) |
|
|
|
|
.where(TAG,equal(tag)).where(MODULE,equal(module)).where(ID,equal(entityId)).where(USER_ID,equal(userId)) |
|
|
|
|
.execute(db); |
|
|
|
|
Query.delete().from(TABLE_TAGS) |
|
|
|
|
.where(TAG,equal(tag)).where(MODULE,equal(module)).where(ID,equal(entityId)).where(USER_ID,isNull()) |
|
|
|
|
.execute(db); |
|
|
|
|
return tag; |
|
|
|
|
} catch (SQLException e){ |
|
|
|
|
throw new UmbrellaException("Failed to delete tag {0}",tag); |
|
|
|
|
@ -119,6 +121,8 @@ CREATE TABLE IF NOT EXISTS "{0}" (
@@ -119,6 +121,8 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
|
|
|
|
var tags = new HashSet<String>(); |
|
|
|
|
var rs = select(TAG).from(TABLE_TAGS).where(MODULE,equal(module)).where(ID,equal(entityId)).where(USER_ID,equal(userId)).exec(db); |
|
|
|
|
while (rs.next()) tags.add(rs.getString(1)); |
|
|
|
|
rs = select(TAG).from(TABLE_TAGS).where(MODULE,equal(module)).where(ID,equal(entityId)).where(USER_ID,isNull()).exec(db); |
|
|
|
|
while (rs.next()) tags.add(rs.getString(1)); |
|
|
|
|
rs.close(); |
|
|
|
|
return tags; |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|