Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@94312 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9ea3d4554e
commit
ee7af95a57
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.td.columnwidget.client.batch;
|
package org.gcube.portlets.user.td.columnwidget.client.batch;
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurrences;
|
||||||
|
|
||||||
import com.google.gwt.editor.client.Editor.Path;
|
import com.google.gwt.editor.client.Editor.Path;
|
||||||
import com.sencha.gxt.core.client.ValueProvider;
|
import com.sencha.gxt.core.client.ValueProvider;
|
||||||
|
@ -16,12 +16,12 @@ import com.sencha.gxt.data.shared.PropertyAccess;
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface OccurencesProperties extends PropertyAccess<Occurences> {
|
public interface OccurrencesProperties extends PropertyAccess<Occurrences> {
|
||||||
|
|
||||||
@Path("value")
|
@Path("value")
|
||||||
ModelKeyProvider<Occurences> id();
|
ModelKeyProvider<Occurrences> id();
|
||||||
|
|
||||||
ValueProvider<Occurences, String> value();
|
ValueProvider<Occurrences, String> value();
|
||||||
ValueProvider<Occurences, Integer> number();
|
ValueProvider<Occurrences, Integer> number();
|
||||||
|
|
||||||
}
|
}
|
|
@ -11,7 +11,7 @@ import org.gcube.portlets.user.td.columnwidget.client.utils.UtilsGXT3;
|
||||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurrences;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceEntry;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceEntry;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.CellData;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.CellData;
|
||||||
|
@ -133,7 +133,7 @@ public class ReplaceBatchPanel extends FramedPanel implements
|
||||||
ColumnConfig<ReplaceEntry, String> valueCol = new ColumnConfig<ReplaceEntry, String>(
|
ColumnConfig<ReplaceEntry, String> valueCol = new ColumnConfig<ReplaceEntry, String>(
|
||||||
props.value(), 130, "Values");
|
props.value(), 130, "Values");
|
||||||
ColumnConfig<ReplaceEntry, Integer> numberCol = new ColumnConfig<ReplaceEntry, Integer>(
|
ColumnConfig<ReplaceEntry, Integer> numberCol = new ColumnConfig<ReplaceEntry, Integer>(
|
||||||
props.number(), 100, "Occurences");
|
props.number(), 100, "Occurrences");
|
||||||
ColumnConfig<ReplaceEntry, String> replacementValueCol = new ColumnConfig<ReplaceEntry, String>(
|
ColumnConfig<ReplaceEntry, String> replacementValueCol = new ColumnConfig<ReplaceEntry, String>(
|
||||||
props.replacementValue(), 130, "Replacement");
|
props.replacementValue(), 130, "Replacement");
|
||||||
|
|
||||||
|
@ -310,8 +310,8 @@ public class ReplaceBatchPanel extends FramedPanel implements
|
||||||
protected void loadData(ListLoadConfig loadConfig,
|
protected void loadData(ListLoadConfig loadConfig,
|
||||||
final AsyncCallback<ListLoadResult<ReplaceEntry>> callback) {
|
final AsyncCallback<ListLoadResult<ReplaceEntry>> callback) {
|
||||||
|
|
||||||
TDGWTServiceAsync.INSTANCE.getOccurencesForBatchReplace(column,
|
TDGWTServiceAsync.INSTANCE.getOccurrencesForBatchReplace(column,
|
||||||
new AsyncCallback<ArrayList<Occurences>>() {
|
new AsyncCallback<ArrayList<Occurrences>>() {
|
||||||
|
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
Log.error("load columns failure:"
|
Log.error("load columns failure:"
|
||||||
|
@ -321,11 +321,18 @@ public class ReplaceBatchPanel extends FramedPanel implements
|
||||||
callback.onFailure(caught);
|
callback.onFailure(caught);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSuccess(ArrayList<Occurences> result) {
|
public void onSuccess(ArrayList<Occurrences> result) {
|
||||||
Log.trace("loaded " + result.size() + " Occurences");
|
Log.trace("loaded " + result.size() + " Occurrences");
|
||||||
callback.onSuccess(new ListLoadResultBean<ReplaceEntry>(
|
ListLoadResultBean<ReplaceEntry> loadedResult=new ListLoadResultBean<ReplaceEntry>(
|
||||||
getRecord(result)));
|
getRecord(result));
|
||||||
|
Log.debug("created "+loadedResult.toString());
|
||||||
|
try {
|
||||||
|
callback.onSuccess(loadedResult);
|
||||||
|
} catch(Throwable e){
|
||||||
|
Log.error("Too many different occurrences");
|
||||||
|
UtilsGXT3.alert("Attention",
|
||||||
|
"Too many different occurrences");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -349,36 +356,28 @@ public class ReplaceBatchPanel extends FramedPanel implements
|
||||||
}
|
}
|
||||||
|
|
||||||
String text = Format.substitute(
|
String text = Format.substitute(
|
||||||
"Assigned {0} ({1} occurences) of {2} ({3} occurences)",
|
"Assigned {0} ({1} occurrences) of {2} ({3} occurrences)",
|
||||||
String.valueOf(assigned), String.valueOf(assignedErrors),
|
String.valueOf(assigned), String.valueOf(assignedErrors),
|
||||||
String.valueOf(total), String.valueOf(totalErrors));
|
String.valueOf(total), String.valueOf(totalErrors));
|
||||||
info.setText(text);
|
info.setText(text);
|
||||||
Log.debug(text);
|
Log.debug(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
protected ArrayList<ReplaceEntry> getRecord(ArrayList<Occurrences> entries) {
|
||||||
* public ArrayList<ReplaceEntry> getReplaceEntries() {
|
|
||||||
* ArrayList<ReplaceEntry> entries = new ArrayList<ReplaceEntry>(); for
|
|
||||||
* (ReplaceEntry record : store.getAll() { if
|
|
||||||
* (record.getAsString(REPLACE_ID_FIELD) != null) { ReplaceEntry entry = new
|
|
||||||
* ReplaceEntry( record.getAsString(ERROR_VALUE_FIELD),
|
|
||||||
* record.getAsString(REPLACE_VALUE_FIELD),
|
|
||||||
* record.getAsString(REPLACE_ID_FIELD)); entries.add(entry); } } return
|
|
||||||
* entries; }
|
|
||||||
*
|
|
||||||
* protected void updateEntries(ArrayList<Occurences> entries) {
|
|
||||||
* store.clear(); ArrayList<ReplaceEntry> records = getRecord(entries);
|
|
||||||
* store.addAll(records); store.commitChanges(); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected ArrayList<ReplaceEntry> getRecord(ArrayList<Occurences> entries) {
|
|
||||||
ArrayList<ReplaceEntry> records = new ArrayList<ReplaceEntry>();
|
ArrayList<ReplaceEntry> records = new ArrayList<ReplaceEntry>();
|
||||||
for (Occurences entry : entries)
|
try {
|
||||||
|
for (Occurrences entry : entries)
|
||||||
records.add(getRecord(entry));
|
records.add(getRecord(entry));
|
||||||
|
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.debug("Error creating records:"+e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return records;
|
return records;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ReplaceEntry getRecord(Occurences entry) {
|
protected ReplaceEntry getRecord(Occurrences entry) {
|
||||||
ReplaceEntry data = null;
|
ReplaceEntry data = null;
|
||||||
if (column.isViewColumn()) {
|
if (column.isViewColumn()) {
|
||||||
data = new ReplaceEntry(entry.getValue(), entry.getRowId(),
|
data = new ReplaceEntry(entry.getValue(), entry.getRowId(),
|
||||||
|
@ -412,19 +411,20 @@ public class ReplaceBatchPanel extends FramedPanel implements
|
||||||
}
|
}
|
||||||
|
|
||||||
if (effectiveReplaceList.size() == 0) {
|
if (effectiveReplaceList.size() == 0) {
|
||||||
UtilsGXT3.alert("Attention",
|
UtilsGXT3
|
||||||
"Select at least one value to replace");
|
.alert("Attention", "Select at least one value to replace");
|
||||||
} else {
|
} else {
|
||||||
startReplaceBatch(effectiveReplaceList);
|
startReplaceBatch(effectiveReplaceList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void startReplaceBatch(ArrayList<ReplaceEntry> effectiveReplaceList){
|
protected void startReplaceBatch(
|
||||||
ReplaceBatchColumnSession replaceBatchColumnSession=new ReplaceBatchColumnSession(trId, column, effectiveReplaceList, column.isViewColumn());
|
ArrayList<ReplaceEntry> effectiveReplaceList) {
|
||||||
|
ReplaceBatchColumnSession replaceBatchColumnSession = new ReplaceBatchColumnSession(
|
||||||
|
trId, column, effectiveReplaceList, column.isViewColumn());
|
||||||
parent.startBatchReplace(replaceBatchColumnSession);
|
parent.startBatchReplace(replaceBatchColumnSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void close() {
|
protected void close() {
|
||||||
parent.close();
|
parent.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue