Updated ReplaceBatch
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@113724 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
56c18339da
commit
05880239a4
|
@ -556,7 +556,20 @@ public interface TDGWTService extends RemoteService {
|
||||||
*/
|
*/
|
||||||
public ArrayList<ColumnData> getColumnWithViewColumnIncluded(TRId trId)
|
public ArrayList<ColumnData> getColumnWithViewColumnIncluded(TRId trId)
|
||||||
throws TDGWTServiceException;
|
throws TDGWTServiceException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of columns in the table provided by trId
|
||||||
|
* only view columns in relationship are included.
|
||||||
|
* TimeDimensionColumn and DimensionColumn are not included.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param trId
|
||||||
|
* @return
|
||||||
|
* @throws TDGWTServiceException
|
||||||
|
*/
|
||||||
|
public ArrayList<ColumnData> getColumnWithOnlyViewColumnInRel(TRId trId)
|
||||||
|
throws TDGWTServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the list of columns in the table provided by trId for
|
* Retrieves the list of columns in the table provided by trId for
|
||||||
* statistical
|
* statistical
|
||||||
|
|
|
@ -168,7 +168,10 @@ public interface TDGWTServiceAsync {
|
||||||
|
|
||||||
void getColumnWithViewColumnIncluded(TRId trId,
|
void getColumnWithViewColumnIncluded(TRId trId,
|
||||||
AsyncCallback<ArrayList<ColumnData>> callback);
|
AsyncCallback<ArrayList<ColumnData>> callback);
|
||||||
|
|
||||||
|
void getColumnWithOnlyViewColumnInRel(TRId trId,
|
||||||
|
AsyncCallback<ArrayList<ColumnData>> callback);
|
||||||
|
|
||||||
void getColumnsForStatistical(TRId trId,
|
void getColumnsForStatistical(TRId trId,
|
||||||
AsyncCallback<ArrayList<ColumnData>> callback);
|
AsyncCallback<ArrayList<ColumnData>> callback);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
@ -335,8 +334,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
* URL.setURLStreamHandlerFactory(confStreamHandlerFactory);
|
* URL.setURLStreamHandlerFactory(confStreamHandlerFactory);
|
||||||
* logger.debug("Activated SMP Handler");
|
* logger.debug("Activated SMP Handler");
|
||||||
*/
|
*/
|
||||||
Properties props = System.getProperties();
|
/*Properties props = System.getProperties();
|
||||||
logger.debug("System Properties: " + props);
|
logger.debug("System Properties: " + props);*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1452,6 +1451,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
*
|
*
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ArrayList<ColumnData> getColumnWithViewColumnIncluded(TRId trId)
|
public ArrayList<ColumnData> getColumnWithViewColumnIncluded(TRId trId)
|
||||||
throws TDGWTServiceException {
|
throws TDGWTServiceException {
|
||||||
try {
|
try {
|
||||||
|
@ -1565,6 +1565,169 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
+ e.getLocalizedMessage());
|
+ e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns ArrayList<ColumnData> other than IdColumnType,
|
||||||
|
* ValidationColumnType, DimensionColumnType and TimeDimensionColumnType
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<ColumnData> getColumnWithOnlyViewColumnInRel(TRId trId)
|
||||||
|
throws TDGWTServiceException {
|
||||||
|
try {
|
||||||
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
|
||||||
|
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||||
|
aslSession.getUsername(), aslSession.getScope()));
|
||||||
|
TabularDataService service = TabularDataServiceFactory.getService();
|
||||||
|
|
||||||
|
logger.debug("getColumns():" + trId.toString());
|
||||||
|
|
||||||
|
Table table = service.getTable(new TableId(Long.valueOf(trId
|
||||||
|
.getTableId())));
|
||||||
|
|
||||||
|
ArrayList<ColumnData> columns = new ArrayList<ColumnData>();
|
||||||
|
ArrayList<ColumnData> dimensions = new ArrayList<ColumnData>();
|
||||||
|
|
||||||
|
|
||||||
|
List<Column> cols = table.getColumns();
|
||||||
|
int i = 0;
|
||||||
|
for (Column c : cols) {
|
||||||
|
if (c.getColumnType() instanceof IdColumnType
|
||||||
|
|| c.getColumnType() instanceof ValidationColumnType) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ColumnData cData = new ColumnData();
|
||||||
|
cData.setId(Integer.toString(i));
|
||||||
|
cData.setColumnId(c.getLocalId().getValue());
|
||||||
|
cData.setName(c.getName());
|
||||||
|
cData.setTypeCode(c.getColumnType().getCode());
|
||||||
|
cData.setTypeName(c.getColumnType().getName());
|
||||||
|
cData.setDataTypeName(c.getDataType().getName());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PeriodTypeMetadata periodTypeMetadata = null;
|
||||||
|
if (c.contains(PeriodTypeMetadata.class)) {
|
||||||
|
periodTypeMetadata = c
|
||||||
|
.getMetadata(PeriodTypeMetadata.class);
|
||||||
|
PeriodType periodType = periodTypeMetadata.getType();
|
||||||
|
cData.setPeriodDataType(PeriodTypeMap.map(periodType));
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnRelationship rel = c.getRelationship();
|
||||||
|
if (rel != null) {
|
||||||
|
RelationshipData relData = retrieveRelationship(
|
||||||
|
service, table, c, periodTypeMetadata, rel);
|
||||||
|
cData.setRelationship(relData);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NamesMetadata labelsMetadata = null;
|
||||||
|
if (c.contains(NamesMetadata.class)) {
|
||||||
|
labelsMetadata = c.getMetadata(NamesMetadata.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (labelsMetadata == null) {
|
||||||
|
cData.setLabel("nolabel");
|
||||||
|
logger.debug("LabelsMetadata no labels");
|
||||||
|
} else {
|
||||||
|
LocalizedText cl = null;
|
||||||
|
cl = labelsMetadata.getTextWithLocale("en");
|
||||||
|
if (cl == null) {
|
||||||
|
cData.setLabel("nolabel");
|
||||||
|
logger.debug("ColumnLabel no label in en");
|
||||||
|
} else {
|
||||||
|
if (cl.getValue() == null
|
||||||
|
|| cl.getValue().isEmpty()) {
|
||||||
|
cData.setLabel("nolabel");
|
||||||
|
logger.debug("ColumnLabel no label in en");
|
||||||
|
} else {
|
||||||
|
cData.setLabel(cl.getValue());
|
||||||
|
logger.debug("Column Set Label: "
|
||||||
|
+ cl.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DataLocaleMetadata dataLocaleMetadata = null;
|
||||||
|
if (c.contains(DataLocaleMetadata.class)) {
|
||||||
|
dataLocaleMetadata = c
|
||||||
|
.getMetadata(DataLocaleMetadata.class);
|
||||||
|
cData.setLocale(dataLocaleMetadata.getLocale());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c.contains(ViewColumnMetadata.class)) {
|
||||||
|
ColumnViewData columnViewData = retrieveColumnViewData(
|
||||||
|
service, table, c, periodTypeMetadata);
|
||||||
|
cData.setColumnViewData(columnViewData);
|
||||||
|
cData.setViewColumn(true);
|
||||||
|
} else {
|
||||||
|
cData.setViewColumn(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
cData.setTrId(trId);
|
||||||
|
|
||||||
|
if(cData.getTypeCode().compareTo(ColumnTypeCode.DIMENSION.toString())==0
|
||||||
|
|| cData.getTypeCode().compareTo(ColumnTypeCode.TIMEDIMENSION.toString())==0){
|
||||||
|
dimensions.add(cData);
|
||||||
|
}
|
||||||
|
|
||||||
|
columns.add(cData);
|
||||||
|
i++;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ArrayList<ColumnData> removable = new ArrayList<ColumnData>();
|
||||||
|
for (int k = 0; k < columns.size(); k++) {
|
||||||
|
ColumnData col=columns.get(k);
|
||||||
|
if (col.getColumnId() != null
|
||||||
|
&& col.isViewColumn()){
|
||||||
|
ColumnViewData colViewData=col.getColumnViewData();
|
||||||
|
String sourceTableDimensionColumnId=colViewData.getSourceTableDimensionColumnId();
|
||||||
|
|
||||||
|
for (int j = 0; j < dimensions.size(); j++) {
|
||||||
|
ColumnData dim=dimensions.get(j);
|
||||||
|
if(dim.getColumnId().compareTo(sourceTableDimensionColumnId)==0){
|
||||||
|
RelationshipData rel = dim.getRelationship();
|
||||||
|
if(rel!=null){
|
||||||
|
String cId = rel.getTargetColumnId();
|
||||||
|
if(cId==null || cId.compareTo(col.getColumnId())!=0){
|
||||||
|
removable.add(col);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
removable.add(col);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
columns.removeAll(removable);
|
||||||
|
columns.removeAll(dimensions);
|
||||||
|
return columns;
|
||||||
|
|
||||||
|
} catch (TDGWTServiceException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
logger.error(
|
||||||
|
"Error retrieving Columns: " + e.getLocalizedMessage(), e);
|
||||||
|
throw new TDGWTServiceException("Error retrieving Columns: "
|
||||||
|
+ e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns ArrayList<ColumnData> other than IdColumnType,
|
* Returns ArrayList<ColumnData> other than IdColumnType,
|
||||||
|
|
Loading…
Reference in New Issue