Fixed Edit Row
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@95848 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d0b009e63c
commit
86d7b979b9
|
@ -74,15 +74,15 @@ public class SessionUtil {
|
|||
ASLSession session;
|
||||
if (username == null) {
|
||||
logger.warn("no user found in session, using test one");
|
||||
//throw new TDGWTSessionExpiredException("Session Expired!");
|
||||
throw new TDGWTSessionExpiredException("Session Expired!");
|
||||
|
||||
username = Constants.DEFAULT_USER;
|
||||
/*username = Constants.DEFAULT_USER;
|
||||
String scope = Constants.DEFAULT_SCOPE;
|
||||
|
||||
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, username);
|
||||
session = SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username);
|
||||
session.setScope(scope);
|
||||
session.setScope(scope);*/
|
||||
|
||||
} else {
|
||||
session = SessionManager.getInstance().getASLSession(
|
||||
|
|
|
@ -3898,13 +3898,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
} else {
|
||||
logger.debug("Is a edit row");
|
||||
|
||||
|
||||
Expression exp=ExpressionGenerator.genEditRowParamaterCondition(service, editRowSession);
|
||||
|
||||
operationDefinition = OperationDefinitionMap.map(
|
||||
OperationsId.ModifyTuplesValuesByExpression.toString(),
|
||||
service);
|
||||
|
||||
|
||||
|
||||
map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE, compositeValue);
|
||||
|
||||
map.put(Constants.PARAMETER_EDIT_ROW_CONDITION, exp);
|
||||
|
||||
invocation = new OperationExecution(
|
||||
operationDefinition.getOperationId(), map);
|
||||
}
|
||||
|
|
|
@ -1,21 +1,28 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.server.trservice;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.data.analysis.tabulardata.expression.Expression;
|
||||
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.Equals;
|
||||
import org.gcube.data.analysis.tabulardata.expression.logical.And;
|
||||
import org.gcube.data.analysis.tabulardata.expression.logical.Not;
|
||||
import org.gcube.data.analysis.tabulardata.model.column.Column;
|
||||
import org.gcube.data.analysis.tabulardata.model.column.ColumnLocalId;
|
||||
import org.gcube.data.analysis.tabulardata.model.column.ColumnReference;
|
||||
import org.gcube.data.analysis.tabulardata.model.column.type.IdColumnType;
|
||||
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDInteger;
|
||||
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDTypeValue;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.Table;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.TableId;
|
||||
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.ReplaceBatchColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceEntry;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowSession;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -218,11 +225,11 @@ public class ExpressionGenerator {
|
|||
new ColumnLocalId(columnLocalId));
|
||||
listColumnReference.add(cr);
|
||||
}
|
||||
if(listColumnReference.size()<=0){
|
||||
if (listColumnReference.size() <= 0) {
|
||||
return null;
|
||||
} else {
|
||||
if(listColumnReference.size()==1){
|
||||
Not not=new Not(listColumnReference.get(0));
|
||||
if (listColumnReference.size() == 1) {
|
||||
Not not = new Not(listColumnReference.get(0));
|
||||
return not;
|
||||
} else {
|
||||
And and = new And(listColumnReference);
|
||||
|
@ -231,7 +238,6 @@ public class ExpressionGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.debug("Error in genReplaceBatchOccurrencesFilter: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
@ -243,4 +249,49 @@ public class ExpressionGenerator {
|
|||
|
||||
}
|
||||
|
||||
public static Expression genEditRowParamaterCondition(TabularDataService service,
|
||||
EditRowSession editRowSession) throws TDGWTServiceException {
|
||||
try {
|
||||
Expression exp=null;
|
||||
TRId trId = editRowSession.getTrId();
|
||||
TableId tableId;
|
||||
if (trId.isViewTable()) {
|
||||
tableId = new TableId(
|
||||
new Long(trId.getReferenceTargetTableId()));
|
||||
} else {
|
||||
tableId = new TableId(new Long(trId.getTableId()));
|
||||
}
|
||||
|
||||
Table table = service.getTable(new TableId(Long.valueOf(trId
|
||||
.getTableId())));
|
||||
|
||||
List<Column> cols = table.getColumns();
|
||||
Column idCol = null;
|
||||
for (Column c : cols) {
|
||||
if (c.getColumnType() instanceof IdColumnType) {
|
||||
idCol = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (idCol != null) {
|
||||
ColumnReference cr = new ColumnReference(tableId,
|
||||
idCol.getLocalId());
|
||||
|
||||
exp = new Equals(cr, new TDInteger(
|
||||
Integer.parseInt(editRowSession.getRowId())));
|
||||
|
||||
} else {
|
||||
logger.debug("No IdColumnType retrieved for table:"+table.getId().toString());
|
||||
}
|
||||
logger.debug("genEditRowParamaterCondition() condition:"+exp);
|
||||
return exp;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in genEditRowParamaterCondition(): "+e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error in genEditRowParamaterCondition(): "+e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public class ValueMap {
|
|||
|
||||
protected SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
|
||||
public ArrayList<Map<String,Object>> genValueMap(EditRowSession editRowSession){
|
||||
ArrayList<Map<String,Object>> composit=new ArrayList<Map<String,Object>>();
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ public class Constants {
|
|||
public static final String PARAMETER_ADD_ROW_COMPOSITE_TOSETVALUE="toSetValue";
|
||||
public static final String PARAMETER_ADD_ROW_COMPOSITE="mapping";
|
||||
|
||||
public static final String PARAMETER_EDIT_ROW_CONDITION="condition";
|
||||
|
||||
public static final String NAME_PARAMETER_ID="NAME_PARAMETER_ID";
|
||||
public static final String PARAMETER_KEY="key";
|
||||
public static final String PARAMETER_REFERENCE_COLUMN="refColumn";
|
||||
|
|
Loading…
Reference in New Issue