Let the user specify an edit summary
This commit is contained in:
parent
5faa432aa6
commit
5e99e0d2e3
@ -8,6 +8,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<div class="wikibase-perform-edits-area">
|
<div class="wikibase-perform-edits-area">
|
||||||
<p>You are logged in as <span bind="loggedInUsername"></span>.</p>
|
<p>You are logged in as <span bind="loggedInUsername"></span>.</p>
|
||||||
|
<p>Edit summary: <input type="text" name="editSummary" bind="editSummary" value="#openrefine" /></p>
|
||||||
<div class="wikibase-login-buttons">
|
<div class="wikibase-login-buttons">
|
||||||
<button class="button cancel-button" bind="cancelButton">Cancel</button>
|
<button class="button cancel-button" bind="cancelButton">Cancel</button>
|
||||||
<button class="button button-primary" bind="performEditsButton">Perform edits</button>
|
<button class="button button-primary" bind="performEditsButton">Perform edits</button>
|
||||||
|
@ -24,6 +24,7 @@ PerformEditsDialog.launch = function(logged_in_username) {
|
|||||||
{},
|
{},
|
||||||
{ strategy : "SNAK_QUALIFIERS",
|
{ strategy : "SNAK_QUALIFIERS",
|
||||||
action: "MERGE",
|
action: "MERGE",
|
||||||
|
summary: elmts.editSummary.val(),
|
||||||
},
|
},
|
||||||
{ includeEngine: true, cellsChanged: true, columnStatsChanged: true },
|
{ includeEngine: true, cellsChanged: true, columnStatsChanged: true },
|
||||||
{ onDone:
|
{ onDone:
|
||||||
|
@ -18,9 +18,11 @@ public class PerformWikibaseEditsCommand extends EngineDependentCommand {
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
String strategy = request.getParameter("strategy");
|
String strategy = request.getParameter("strategy");
|
||||||
String action = request.getParameter("action");
|
String action = request.getParameter("action");
|
||||||
|
String summary = request.getParameter("summary");
|
||||||
return new PerformWikibaseEditsOperation(engineConfig,
|
return new PerformWikibaseEditsOperation(engineConfig,
|
||||||
DuplicateDetectionStrategy.valueOf(strategy),
|
DuplicateDetectionStrategy.valueOf(strategy),
|
||||||
OnDuplicateAction.valueOf(action));
|
OnDuplicateAction.valueOf(action),
|
||||||
|
summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.io.LineNumberReader;
|
|||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ import org.wikidata.wdtk.datamodel.interfaces.DataObjectFactory;
|
|||||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||||
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument;
|
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument;
|
||||||
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
||||||
|
import org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue;
|
||||||
import org.wikidata.wdtk.util.WebResourceFetcherImpl;
|
import org.wikidata.wdtk.util.WebResourceFetcherImpl;
|
||||||
import org.wikidata.wdtk.wikibaseapi.ApiConnection;
|
import org.wikidata.wdtk.wikibaseapi.ApiConnection;
|
||||||
import org.wikidata.wdtk.wikibaseapi.WikibaseDataEditor;
|
import org.wikidata.wdtk.wikibaseapi.WikibaseDataEditor;
|
||||||
@ -59,14 +61,17 @@ public class PerformWikibaseEditsOperation extends EngineDependentOperation {
|
|||||||
|
|
||||||
private DuplicateDetectionStrategy strategy;
|
private DuplicateDetectionStrategy strategy;
|
||||||
private OnDuplicateAction duplicateAction;
|
private OnDuplicateAction duplicateAction;
|
||||||
|
private String summary;
|
||||||
|
|
||||||
public PerformWikibaseEditsOperation(
|
public PerformWikibaseEditsOperation(
|
||||||
JSONObject engineConfig,
|
JSONObject engineConfig,
|
||||||
DuplicateDetectionStrategy strategy,
|
DuplicateDetectionStrategy strategy,
|
||||||
OnDuplicateAction duplicateAction) {
|
OnDuplicateAction duplicateAction,
|
||||||
|
String summary) {
|
||||||
super(engineConfig);
|
super(engineConfig);
|
||||||
this.strategy = strategy;
|
this.strategy = strategy;
|
||||||
this.duplicateAction = duplicateAction;
|
this.duplicateAction = duplicateAction;
|
||||||
|
this.summary = summary;
|
||||||
|
|
||||||
// getEngine(request, project);
|
// getEngine(request, project);
|
||||||
}
|
}
|
||||||
@ -76,10 +81,15 @@ public class PerformWikibaseEditsOperation extends EngineDependentOperation {
|
|||||||
JSONObject engineConfig = obj.getJSONObject("engineConfig");
|
JSONObject engineConfig = obj.getJSONObject("engineConfig");
|
||||||
String strategy = obj.getString("duplicate_strategy");
|
String strategy = obj.getString("duplicate_strategy");
|
||||||
String action = obj.getString("duplicate_action");
|
String action = obj.getString("duplicate_action");
|
||||||
|
String summary = obj.getString("summary");
|
||||||
|
if (summary == null) {
|
||||||
|
summary = "#openrefine";
|
||||||
|
}
|
||||||
return new PerformWikibaseEditsOperation(
|
return new PerformWikibaseEditsOperation(
|
||||||
engineConfig,
|
engineConfig,
|
||||||
DuplicateDetectionStrategy.valueOf(strategy),
|
DuplicateDetectionStrategy.valueOf(strategy),
|
||||||
OnDuplicateAction.valueOf(action));
|
OnDuplicateAction.valueOf(action),
|
||||||
|
summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,6 +105,8 @@ public class PerformWikibaseEditsOperation extends EngineDependentOperation {
|
|||||||
writer.value(strategy.name());
|
writer.value(strategy.name());
|
||||||
writer.key("duplicate_action");
|
writer.key("duplicate_action");
|
||||||
writer.value(duplicateAction.name());
|
writer.value(duplicateAction.name());
|
||||||
|
writer.key("summary");
|
||||||
|
writer.value(summary);
|
||||||
writer.key("engineConfig");
|
writer.key("engineConfig");
|
||||||
writer.value(getEngineConfig());
|
writer.value(getEngineConfig());
|
||||||
writer.endObject();
|
writer.endObject();
|
||||||
@ -111,7 +123,7 @@ public class PerformWikibaseEditsOperation extends EngineDependentOperation {
|
|||||||
project,
|
project,
|
||||||
createEngine(project),
|
createEngine(project),
|
||||||
getBriefDescription(project),
|
getBriefDescription(project),
|
||||||
"#openrefine"
|
summary
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,6 +235,9 @@ public class PerformWikibaseEditsOperation extends EngineDependentOperation {
|
|||||||
// New item
|
// New item
|
||||||
if (update.getItemId().getId() == "Q0") {
|
if (update.getItemId().getId() == "Q0") {
|
||||||
NewEntityIdValue newCell = (NewEntityIdValue)update.getItemId();
|
NewEntityIdValue newCell = (NewEntityIdValue)update.getItemId();
|
||||||
|
update.normalizeLabelsAndAliases();
|
||||||
|
|
||||||
|
|
||||||
ItemDocument itemDocument = factory.getItemDocument(
|
ItemDocument itemDocument = factory.getItemDocument(
|
||||||
update.getItemId(),
|
update.getItemId(),
|
||||||
update.getLabels(),
|
update.getLabels(),
|
||||||
@ -236,7 +251,11 @@ public class PerformWikibaseEditsOperation extends EngineDependentOperation {
|
|||||||
newItemLibrary.setQid(newCell, createdDoc.getItemId().getId());
|
newItemLibrary.setQid(newCell, createdDoc.getItemId().getId());
|
||||||
} else {
|
} else {
|
||||||
// Existing item
|
// Existing item
|
||||||
wbde.updateStatements(update.getItemId(),
|
wbde.updateTermsStatements(update.getItemId(),
|
||||||
|
update.getLabels(),
|
||||||
|
update.getDescriptions(),
|
||||||
|
update.getAliases(),
|
||||||
|
new ArrayList<MonolingualTextValue>(),
|
||||||
update.getAddedStatements(),
|
update.getAddedStatements(),
|
||||||
update.getDeletedStatements(), _summary);
|
update.getDeletedStatements(), _summary);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user