mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
First step to make name and namespace editable in migration
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@
|
||||
<tr>
|
||||
<th>Original name</th>
|
||||
<th>Type</th>
|
||||
<th>New namespace and name</th>
|
||||
<th>New namespace</th>
|
||||
<th>New name</th>
|
||||
<th>Strategy</th>
|
||||
</tr>
|
||||
{{#repositories}}
|
||||
@@ -58,12 +59,15 @@
|
||||
{{type}}
|
||||
</td>
|
||||
<td>
|
||||
{{newNamespace}}/{{newName}}
|
||||
<input class="input" type="text" name="namespace-{{id}}" value="{{newNamespace}}">
|
||||
</td>
|
||||
<td>
|
||||
<input class="input" type="text" name="name-{{id}}" value="{{newName}}">
|
||||
</td>
|
||||
<td>
|
||||
<div class="field">
|
||||
<div class="control select">
|
||||
<select name="{{id}}">
|
||||
<select name="strategy-{{id}}">
|
||||
{{#strategies}}
|
||||
<option>{{name}}</option>
|
||||
{{/strategies}}
|
||||
@@ -74,6 +78,9 @@
|
||||
</tr>
|
||||
{{/repositories}}
|
||||
</table>
|
||||
{{#repositories}}
|
||||
<input type="hidden" name="ids" value="{{id}}">
|
||||
{{/repositories}}
|
||||
<button class="button is-primary" type="submit">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user