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:
Giancarlo Panichi 2014-04-04 10:33:26 +00:00
parent 9ea3d4554e
commit ee7af95a57
2 changed files with 47 additions and 47 deletions

View File

@ -3,7 +3,7 @@
*/
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.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>
*
*/
public interface OccurencesProperties extends PropertyAccess<Occurences> {
public interface OccurrencesProperties extends PropertyAccess<Occurrences> {
@Path("value")
ModelKeyProvider<Occurences> id();
ModelKeyProvider<Occurrences> id();
ValueProvider<Occurences, String> value();
ValueProvider<Occurences, Integer> number();
ValueProvider<Occurrences, String> value();
ValueProvider<Occurrences, Integer> number();
}

View File

@ -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.shared.tr.ColumnData;
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.ReplaceEntry;
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>(
props.value(), 130, "Values");
ColumnConfig<ReplaceEntry, Integer> numberCol = new ColumnConfig<ReplaceEntry, Integer>(
props.number(), 100, "Occurences");
props.number(), 100, "Occurrences");
ColumnConfig<ReplaceEntry, String> replacementValueCol = new ColumnConfig<ReplaceEntry, String>(
props.replacementValue(), 130, "Replacement");
@ -310,8 +310,8 @@ public class ReplaceBatchPanel extends FramedPanel implements
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<ReplaceEntry>> callback) {
TDGWTServiceAsync.INSTANCE.getOccurencesForBatchReplace(column,
new AsyncCallback<ArrayList<Occurences>>() {
TDGWTServiceAsync.INSTANCE.getOccurrencesForBatchReplace(column,
new AsyncCallback<ArrayList<Occurrences>>() {
public void onFailure(Throwable caught) {
Log.error("load columns failure:"
@ -321,11 +321,18 @@ public class ReplaceBatchPanel extends FramedPanel implements
callback.onFailure(caught);
}
public void onSuccess(ArrayList<Occurences> result) {
Log.trace("loaded " + result.size() + " Occurences");
callback.onSuccess(new ListLoadResultBean<ReplaceEntry>(
getRecord(result)));
public void onSuccess(ArrayList<Occurrences> result) {
Log.trace("loaded " + result.size() + " Occurrences");
ListLoadResultBean<ReplaceEntry> loadedResult=new ListLoadResultBean<ReplaceEntry>(
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(
"Assigned {0} ({1} occurences) of {2} ({3} occurences)",
"Assigned {0} ({1} occurrences) of {2} ({3} occurrences)",
String.valueOf(assigned), String.valueOf(assignedErrors),
String.valueOf(total), String.valueOf(totalErrors));
info.setText(text);
Log.debug(text);
}
/*
* 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) {
protected ArrayList<ReplaceEntry> getRecord(ArrayList<Occurrences> entries) {
ArrayList<ReplaceEntry> records = new ArrayList<ReplaceEntry>();
for (Occurences entry : entries)
records.add(getRecord(entry));
try {
for (Occurrences entry : entries)
records.add(getRecord(entry));
} catch (Throwable e) {
Log.debug("Error creating records:"+e.getLocalizedMessage());
e.printStackTrace();
}
return records;
}
protected ReplaceEntry getRecord(Occurences entry) {
protected ReplaceEntry getRecord(Occurrences entry) {
ReplaceEntry data = null;
if (column.isViewColumn()) {
data = new ReplaceEntry(entry.getValue(), entry.getRowId(),
@ -403,27 +402,28 @@ public class ReplaceBatchPanel extends FramedPanel implements
}
protected void save() {
ArrayList<ReplaceEntry> effectiveReplaceList=new ArrayList<ReplaceEntry>();
for(ReplaceEntry re:store.getAll()){
if(re.getReplacementValue()!=null){
ArrayList<ReplaceEntry> effectiveReplaceList = new ArrayList<ReplaceEntry>();
for (ReplaceEntry re : store.getAll()) {
if (re.getReplacementValue() != null) {
effectiveReplaceList.add(re);
}
}
if(effectiveReplaceList.size()==0){
UtilsGXT3.alert("Attention",
"Select at least one value to replace");
if (effectiveReplaceList.size() == 0) {
UtilsGXT3
.alert("Attention", "Select at least one value to replace");
} else {
startReplaceBatch(effectiveReplaceList);
}
}
}
protected void startReplaceBatch(ArrayList<ReplaceEntry> effectiveReplaceList){
ReplaceBatchColumnSession replaceBatchColumnSession=new ReplaceBatchColumnSession(trId, column, effectiveReplaceList, column.isViewColumn());
protected void startReplaceBatch(
ArrayList<ReplaceEntry> effectiveReplaceList) {
ReplaceBatchColumnSession replaceBatchColumnSession = new ReplaceBatchColumnSession(
trId, column, effectiveReplaceList, column.isViewColumn());
parent.startBatchReplace(replaceBatchColumnSession);
}
protected void close() {
parent.close();