implemented restoring of wiki tags from tag and bookmark database

This commit is contained in:
2025-09-12 01:56:28 +02:00
parent f13da92b48
commit 4bc717756f
9 changed files with 74 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ import static de.srsoftware.umbrella.bookmarks.Constants.*;
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;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
import static de.srsoftware.umbrella.tags.Constants.*;
import static java.lang.System.Logger.Level.*;
import static java.text.MessageFormat.format;
@@ -279,4 +280,14 @@ CREATE TABLE IF NOT EXISTS {0} (
throw new UmbrellaException("Failed to save tags: {0}",String.join(", ",tags));
}
}
@Override
public void updateId(String module, Object oldId, Object newId) {
try {
update(TABLE_TAGS).set(ENTITY_ID).where(MODULE,equal(module)).where(ENTITY_ID,equal(oldId)).prepare(db).apply(newId).close();
LOG.log(DEBUG,"Updated tag @ {0}.{1} → {0}.{2}",module,oldId,newId);
} catch (SQLException e) {
throw databaseException("Failed to update {0}.{1} → {0}.{2}",module,oldId,newId);
}
}
}

View File

@@ -16,4 +16,7 @@ public interface TagDB {
Set<String> list(long userId, String module, long entityId);
void save(Collection<Long> userIds, String module, long entityId, Collection<String> tags);
void updateId(String module, Object oldId, Object newId);
}

View File

@@ -25,7 +25,7 @@ import java.util.*;
import org.json.JSONArray;
public class TagModule extends BaseHandler implements TagService {
private final SqliteDb tagDb;
private final TagDB tagDb;
public TagModule(Configuration config) {
super();
@@ -131,4 +131,9 @@ public class TagModule extends BaseHandler implements TagService {
save(module,entityId,userIds,List.of(tag));
return tag;
}
@Override
public void updateId(String module, Object oldId, Object newId) {
tagDb.updateId(module,oldId,newId);
}
}