Update Batch Replace

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@94504 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-04-08 08:44:51 +00:00
parent 35bebe87b8
commit ac1c35932f
6 changed files with 130 additions and 38 deletions

View File

@ -28,6 +28,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurrences;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.OccurrencesForReplaceBatchColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.clone.CloneTabularResourceSession;
@ -619,7 +620,7 @@ public interface TDGWTService extends RemoteService {
* @param column
* @return
*/
public ArrayList<Occurrences> getOccurrencesForBatchReplace(ColumnData column)
public ArrayList<Occurrences> getOccurrencesForBatchReplace(OccurrencesForReplaceBatchColumnSession occurrencesForReplaceBatchColumnSession)
throws TDGWTServiceException;
/**

View File

@ -27,6 +27,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurrences;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.OccurrencesForReplaceBatchColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.clone.CloneTabularResourceSession;
@ -174,7 +175,7 @@ public interface TDGWTServiceAsync {
void startLabelColumn(LabelColumnSession labelColumnSession,AsyncCallback<Void> callback);
//BatchReplace Operation
void getOccurrencesForBatchReplace(ColumnData column, AsyncCallback<ArrayList<Occurrences>> callback);
void getOccurrencesForBatchReplace(OccurrencesForReplaceBatchColumnSession occurrencesForReplaceBatchColumnSession, AsyncCallback<ArrayList<Occurrences>> callback);
void getReplaceBatchColumnMonitor(AsyncCallback<ReplaceBatchColumnMonitor> callback);
void startReplaceBatchColumn(ReplaceBatchColumnSession replaceBatchColumnSession,AsyncCallback<Void> callback);

View File

@ -121,6 +121,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnViewData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurrences;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.OccurrencesForReplaceBatchColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceEntry;
@ -603,7 +604,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
*
* {@inheritDoc}
*/
public ArrayList<ColumnData> getValidationColumns(TRId trId,
@ -616,34 +617,38 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
logger.debug("getValidationColumns():[" + trId.toString()+" columnName: "+columnName+"]");
logger.debug("getValidationColumns():[" + trId.toString()
+ " columnName: " + columnName + "]");
Table table = service.getTable(new TableId(Long.valueOf(trId
.getTableId())));
Column columnSource=table.getColumnByName(columnName);
if(columnSource==null){
Column columnSource = table.getColumnByName(columnName);
if (columnSource == null) {
logger.error("Column not present on table");
throw new TDGWTServiceException("Column not present on table");
}
logger.debug("getValidationColumns(): columnSource "+columnSource.getLocalId());
String columnSourceId=columnSource.getLocalId().getValue();
logger.debug("getValidationColumns(): columnSource "
+ columnSource.getLocalId());
String columnSourceId = columnSource.getLocalId().getValue();
ArrayList<ColumnData> columns = new ArrayList<ColumnData>();
List<Column> cols = table.getColumns();
int i = 0;
for (Column c : cols) {
if (c.getColumnType() instanceof ValidationColumnType) {
logger.debug("ValidationColumn present: "+c.getLocalId());
logger.debug("ValidationColumn present: " + c.getLocalId());
if (c.contains(ValidationReferencesMetadata.class)) {
logger.debug("ValidationReferencesMetadata present");
ValidationReferencesMetadata validationReferenceMetadata = c
.getMetadata(ValidationReferencesMetadata.class);
List<ColumnLocalId> valColumnList=validationReferenceMetadata.getValidationReferenceColumn();
for(ColumnLocalId columnLocalId:valColumnList){
if(columnLocalId.getValue().compareTo(columnSourceId)==0){
List<ColumnLocalId> valColumnList = validationReferenceMetadata
.getValidationReferenceColumn();
for (ColumnLocalId columnLocalId : valColumnList) {
if (columnLocalId.getValue().compareTo(
columnSourceId) == 0) {
ColumnData cData = new ColumnData();
cData.setId(Integer.toString(i));
cData.setColumnId(c.getLocalId().getValue());
@ -653,7 +658,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
cData.setDataTypeName(c.getDataType().getName());
NamesMetadata labelsMetadata = null;
try {
labelsMetadata = c.getMetadata(NamesMetadata.class);
labelsMetadata = c
.getMetadata(NamesMetadata.class);
} catch (NoSuchMetadataException e) {
logger.debug("labelMetadata: NoSuchMetadataException "
+ e.getLocalizedMessage());
@ -676,30 +682,32 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
cData.setTrId(trId);
cData.setValidationColumn(true);
ArrayList<String> validatedColumnReferences= new ArrayList<String>();
for(ColumnLocalId cLocalId:valColumnList){
validatedColumnReferences.add(cLocalId.getValue());
ArrayList<String> validatedColumnReferences = new ArrayList<String>();
for (ColumnLocalId cLocalId : valColumnList) {
validatedColumnReferences.add(cLocalId
.getValue());
}
cData.setValidatedColumnReferences(validatedColumnReferences);
columns.add(cData);
i++;
break;
}
}
}
}
}
}
logger.debug("Validation Column: "+columns.size());
logger.debug("Validation Column: " + columns.size());
return columns;
} catch (Throwable e) {
logger.error(
"Error retrieving Validation Columns: " + e.getLocalizedMessage(), e);
throw new TDGWTServiceException("Error retrieving Validation Columns: "
+ e.getLocalizedMessage());
"Error retrieving Validation Columns: "
+ e.getLocalizedMessage(), e);
throw new TDGWTServiceException(
"Error retrieving Validation Columns: "
+ e.getLocalizedMessage());
}
}
@ -4844,17 +4852,18 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
*/
@Override
public ArrayList<Occurrences> getOccurrencesForBatchReplace(
ColumnData column) throws TDGWTServiceException {
OccurrencesForReplaceBatchColumnSession occurrencesForReplaceBatchColumnSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("GetOccurencesForBatchReplace: " + column);
logger.debug("GetOccurencesForBatchReplace: " + occurrencesForReplaceBatchColumnSession.toString());
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
ArrayList<Occurrences> occurences = QueryService.queryOccurences(
service, column, Direction.ASC);
service, occurrencesForReplaceBatchColumnSession, Direction.ASC);
logger.debug("Retrieved Occurences");
return occurences;
@ -4893,21 +4902,22 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
templateData.setName(desc.getName());
templateData.setDescription(desc.getDescription());
templateData.setAgency(desc.getAgency());
switch (desc.getTemplate().getCategory()){
switch (desc.getTemplate().getCategory()) {
case CODELIST:
templateData.setCategory("Codelist");
templateData.setCategory("Codelist");
break;
case DATASET:
templateData.setCategory("Dataset");
templateData.setCategory("Dataset");
break;
case GENERIC:
templateData.setCategory("Generic");
templateData.setCategory("Generic");
break;
default:
break;
};
}
;
templateDataList.add(templateData);
}
logger.debug("Retrieved TemplateData List");

View File

@ -16,6 +16,7 @@ import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurrences;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.OccurrencesForReplaceBatchColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.Direction;
import org.json.JSONArray;
import org.json.JSONException;
@ -34,9 +35,10 @@ public class QueryService {
.getLogger(QueryService.class);
public static ArrayList<Occurrences> queryOccurences(
TabularDataService service, ColumnData column, Direction direction)
TabularDataService service, OccurrencesForReplaceBatchColumnSession occurrencesSession , Direction direction)
throws TDGWTServiceException {
logger.debug("QueryOccurences");
ColumnData column=occurrencesSession.getColumnData();
ArrayList<Occurrences> occurences = new ArrayList<Occurrences>();
TableId tableId = new TableId(new Long(column.getTrId().getTableId()));

View File

@ -0,0 +1,50 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.batch;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class OccurrencesForReplaceBatchColumnSession implements Serializable {
private static final long serialVersionUID = -838394991333185029L;
protected ColumnData columnData;
protected ShowOccurrencesType showType;
public OccurrencesForReplaceBatchColumnSession() {
}
public OccurrencesForReplaceBatchColumnSession(ColumnData columnData,
ShowOccurrencesType showType) {
this.columnData = columnData;
this.showType = showType;
}
public ColumnData getColumnData() {
return columnData;
}
public void setColumnData(ColumnData columnData) {
this.columnData = columnData;
}
public ShowOccurrencesType getShowType() {
return showType;
}
public void setShowType(ShowOccurrencesType showType) {
this.showType = showType;
}
@Override
public String toString() {
return "OccurencesForReplaceBatchColumnSession [columnData="
+ columnData + ", showType=" + showType + "]";
}
}

View File

@ -0,0 +1,28 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.batch;
/**
*
*
* @author "Giancarlo Panichi"
*
*/
public enum ShowOccurrencesType {
ONLYERRORS("Only Errors"),
ALL("All");
/**
* @param text
*/
private ShowOccurrencesType(final String id) {
this.id = id;
}
private final String id;
@Override
public String toString() {
return id;
}
}