First step to make name and namespace editable in migration

This commit is contained in:
René Pfeuffer
2019-06-07 14:16:23 +02:00
parent 70de4d7292
commit df9a3c12dd
4 changed files with 41 additions and 8 deletions

View File

@@ -19,6 +19,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -65,8 +66,13 @@ class MigrationWizardServlet extends HttpServlet {
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
resp.setStatus(200);
req.getParameterMap().forEach(
(name, strategy) -> migrationStrategyDao.set(name, MigrationStrategy.valueOf(strategy[0]))
Arrays.stream(req.getParameterValues("ids")).forEach(
id -> {
String strategy = req.getParameter("strategy-" + id);
String namespace = req.getParameter("namespace-" + id);
String name = req.getParameter("name-" + id);
migrationStrategyDao.set(id, MigrationStrategy.valueOf(strategy), namespace, name);
}
);
MustacheFactory mf = new DefaultMustacheFactory();

View File

@@ -23,8 +23,8 @@ public class MigrationStrategyDao {
return plan.get(id);
}
public void set(String repositoryId, MigrationStrategy strategy) {
plan.set(repositoryId, strategy);
public void set(String repositoryId, MigrationStrategy strategy, String newNamespace, String newName) {
plan.set(repositoryId, strategy, newNamespace, newName);
store.set(plan);
}
}

View File

@@ -28,10 +28,12 @@ class RepositoryMigrationPlan {
.map(RepositoryEntry::getDataMigrationStrategy);
}
public void set(String repositoryId, MigrationStrategy strategy) {
public void set(String repositoryId, MigrationStrategy strategy, String newNamespace, String newName) {
Optional<RepositoryEntry> entry = findEntry(repositoryId);
if (entry.isPresent()) {
entry.get().setStrategy(strategy);
entry.get().setNewNamespace(newNamespace);
entry.get().setNewName(newName);
} else {
entries.add(new RepositoryEntry(repositoryId, strategy));
}
@@ -49,6 +51,8 @@ class RepositoryMigrationPlan {
private String repositoryId;
private MigrationStrategy dataMigrationStrategy;
private String newNamespace;
private String newName;
RepositoryEntry() {
}
@@ -62,8 +66,24 @@ class RepositoryMigrationPlan {
return dataMigrationStrategy;
}
public String getNewNamespace() {
return newNamespace;
}
public String getNewName() {
return newName;
}
private void setStrategy(MigrationStrategy strategy) {
this.dataMigrationStrategy = strategy;
}
private void setNewNamespace(String newNamespace) {
this.newNamespace = newNamespace;
}
private void setNewName(String newName) {
this.newName = newName;
}
}
}