Store original repository name in migration plan

This commit is contained in:
René Pfeuffer
2019-07-01 15:30:03 +02:00
parent cedf5019b0
commit c881a3eca7
6 changed files with 44 additions and 14 deletions

View File

@@ -100,13 +100,14 @@ class MigrationWizardServlet extends HttpServlet {
}
repositoryLineEntries.stream()
.map(RepositoryLineEntry::getId)
.forEach(
id -> {
entry-> {
String id = entry.getId();
String originalName = entry.getOriginalName();
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);
migrationStrategyDao.set(id, originalName, MigrationStrategy.valueOf(strategy), namespace, name);
}
);
@@ -150,6 +151,7 @@ class MigrationWizardServlet extends HttpServlet {
private static class RepositoryLineEntry {
private final String id;
private final String originalName;
private final String type;
private final String path;
private MigrationStrategy selectedStrategy;
@@ -160,6 +162,7 @@ class MigrationWizardServlet extends HttpServlet {
public RepositoryLineEntry(V1Repository repository) {
this.id = repository.getId();
this.originalName = repository.getName();
this.type = repository.getType();
this.path = repository.getType() + "/" + repository.getName();
this.selectedStrategy = MigrationStrategy.COPY;
@@ -189,6 +192,10 @@ class MigrationWizardServlet extends HttpServlet {
return id;
}
public String getOriginalName() {
return originalName;
}
public String getType() {
return type;
}

View File

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

View File

@@ -29,14 +29,14 @@ class RepositoryMigrationPlan {
.findFirst();
}
public void set(String repositoryId, MigrationStrategy strategy, String newNamespace, String newName) {
public void set(String repositoryId, String originalName, MigrationStrategy strategy, String newNamespace, String newName) {
Optional<RepositoryMigrationEntry> entry = get(repositoryId);
if (entry.isPresent()) {
entry.get().setStrategy(strategy);
entry.get().setNewNamespace(newNamespace);
entry.get().setNewName(newName);
} else {
entries.add(new RepositoryMigrationEntry(repositoryId, strategy, newNamespace, newName));
entries.add(new RepositoryMigrationEntry(repositoryId, originalName, strategy, newNamespace, newName));
}
}
@@ -45,6 +45,7 @@ class RepositoryMigrationPlan {
static class RepositoryMigrationEntry {
private String repositoryId;
private String originalName;
private MigrationStrategy dataMigrationStrategy;
private String newNamespace;
private String newName;
@@ -52,13 +53,18 @@ class RepositoryMigrationPlan {
RepositoryMigrationEntry() {
}
RepositoryMigrationEntry(String repositoryId, MigrationStrategy dataMigrationStrategy, String newNamespace, String newName) {
RepositoryMigrationEntry(String repositoryId, String originalName, MigrationStrategy dataMigrationStrategy, String newNamespace, String newName) {
this.repositoryId = repositoryId;
this.originalName = originalName;
this.dataMigrationStrategy = dataMigrationStrategy;
this.newNamespace = newNamespace;
this.newName = newName;
}
public String getOriginalName() {
return originalName;
}
public MigrationStrategy getDataMigrationStrategy() {
return dataMigrationStrategy;
}