Updated ValidationColumn retrieve
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@113678 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
133aac7d17
commit
604e4b8468
|
@ -407,6 +407,18 @@ public interface TDGWTService extends RemoteService {
|
|||
public ArrayList<ColumnData> getValidationColumns(TRId trId,
|
||||
String columnName) throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Returns ArrayList<ColumnData> that contains all the validation columns of
|
||||
* columnLocalId
|
||||
*
|
||||
* @param columnLocalId
|
||||
* @param trId
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public ArrayList<ColumnData> getValidationColumns(String columnLocalId,
|
||||
TRId trId) throws TDGWTServiceException;
|
||||
|
||||
// RollBack
|
||||
/**
|
||||
* Call rollback on tabular resource
|
||||
|
@ -833,7 +845,8 @@ public interface TDGWTService extends RemoteService {
|
|||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public void startChangeColumnsPosition(ChangeColumnsPositionSession changeColumnsPositionSession)
|
||||
public void startChangeColumnsPosition(
|
||||
ChangeColumnsPositionSession changeColumnsPositionSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
|
@ -1095,7 +1108,6 @@ public interface TDGWTService extends RemoteService {
|
|||
OperationMonitorSession operationMonitorSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
// File Upload Monitor
|
||||
/**
|
||||
* Get File Upload Monitor during the file upload operation in Import CSV
|
||||
|
@ -1204,7 +1216,6 @@ public interface TDGWTService extends RemoteService {
|
|||
GeospatialDownscaleCSquareSession geospatialDownscaleCSquareSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
// Geometry
|
||||
/**
|
||||
* Point Creation
|
||||
|
|
|
@ -209,6 +209,9 @@ public interface TDGWTServiceAsync {
|
|||
void getValidationColumns(TRId trId, String columnName,
|
||||
AsyncCallback<ArrayList<ColumnData>> callback);
|
||||
|
||||
void getValidationColumns(String columnLocalId, TRId trId,
|
||||
AsyncCallback<ArrayList<ColumnData>> callback);
|
||||
|
||||
// RollBack
|
||||
void startRollBack(RollBackSession rollBackSession,
|
||||
AsyncCallback<String> callback);
|
||||
|
|
|
@ -323,21 +323,20 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
private static SimpleDateFormat sdfPerformance = new SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss.SSS");
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws ServletException {
|
||||
super.init();
|
||||
//Handler.activateProtocol();
|
||||
//logger.debug("Activated SMP Handler");
|
||||
// Handler.activateProtocol();
|
||||
// logger.debug("Activated SMP Handler");
|
||||
/*
|
||||
ConfigurableStreamHandlerFactory confStreamHandlerFactory = new ConfigurableStreamHandlerFactory(
|
||||
"smp", new Handler());
|
||||
|
||||
URL.setURLStreamHandlerFactory(confStreamHandlerFactory);
|
||||
logger.debug("Activated SMP Handler");
|
||||
*/
|
||||
Properties props=System.getProperties();
|
||||
logger.debug("System Properties: "+props);
|
||||
* ConfigurableStreamHandlerFactory confStreamHandlerFactory = new
|
||||
* ConfigurableStreamHandlerFactory( "smp", new Handler());
|
||||
*
|
||||
* URL.setURLStreamHandlerFactory(confStreamHandlerFactory);
|
||||
* logger.debug("Activated SMP Handler");
|
||||
*/
|
||||
Properties props = System.getProperties();
|
||||
logger.debug("System Properties: " + props);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2017,6 +2016,126 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<ColumnData> getValidationColumns(String columnId, 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("getValidationColumns():[" + trId.toString()
|
||||
+ " columnLocalId: " + columnId + "]");
|
||||
|
||||
Table table = service.getTable(new TableId(Long.valueOf(trId
|
||||
.getTableId())));
|
||||
logger.debug("getValidationColumns() on Table: " + table.toString());
|
||||
|
||||
ColumnLocalId id = new ColumnLocalId(columnId);
|
||||
|
||||
Column columnSource = table.getColumnById(id);
|
||||
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();
|
||||
|
||||
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.getColumnType() + " " + 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) {
|
||||
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());
|
||||
NamesMetadata labelsMetadata = null;
|
||||
try {
|
||||
labelsMetadata = c
|
||||
.getMetadata(NamesMetadata.class);
|
||||
} catch (NoSuchMetadataException e) {
|
||||
logger.debug("labelMetadata: NoSuchMetadataException "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
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 {
|
||||
cData.setLabel(cl.getValue());
|
||||
logger.debug("Column Set Label: "
|
||||
+ cl.getValue());
|
||||
}
|
||||
}
|
||||
cData.setTrId(trId);
|
||||
cData.setValidationColumn(true);
|
||||
ArrayList<String> validatedColumnReferences = new ArrayList<String>();
|
||||
for (ColumnLocalId cLocalId : valColumnList) {
|
||||
validatedColumnReferences.add(cLocalId
|
||||
.getValue());
|
||||
}
|
||||
cData.setValidatedColumns(validatedColumnReferences);
|
||||
columns.add(cData);
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
logger.debug("Validation Column: " + columns.size());
|
||||
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 Validation Columns: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException(
|
||||
"Error retrieving Validation Columns: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<ColumnData> getValidationColumns(TRId trId,
|
||||
String columnName) throws TDGWTServiceException {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue