Added getValidationColumns()
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@94356 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7db2e84d78
commit
1ae219d7e1
|
@ -86,6 +86,8 @@ public interface TDGWTService extends RemoteService {
|
|||
*/
|
||||
public String hello() throws TDGWTServiceException;
|
||||
|
||||
|
||||
//TabularResource
|
||||
/**
|
||||
* Get informations on the current tabular resource
|
||||
*
|
||||
|
@ -112,6 +114,18 @@ public interface TDGWTService extends RemoteService {
|
|||
public TabResource getTabResourceInformation(TRId trId)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Return true if is a valid tabular resource
|
||||
*
|
||||
* @param trId
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public Boolean isTabularResourceValid(TRId trId)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get creation date on tabular resource
|
||||
*
|
||||
|
@ -177,16 +191,21 @@ public interface TDGWTService extends RemoteService {
|
|||
public ArrayList<TRMetadata> getTRMetadata(TRId trId)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return true if is a valid tabular resource
|
||||
* Returns ArrayList<ColumnData> that contains all the validation columns of columnName
|
||||
*
|
||||
* @param trId
|
||||
* @param columnName
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public Boolean isTabularResourceValid(TRId trId)
|
||||
public ArrayList<ColumnData> getValidationColumns(TRId trId, String columnName)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
|
||||
// Share
|
||||
/**
|
||||
* Retrieves information sharing on the tabular resource
|
||||
|
|
|
@ -71,41 +71,26 @@ public interface TDGWTServiceAsync {
|
|||
|
||||
void hello(AsyncCallback<String> callback);
|
||||
|
||||
//TabularResource
|
||||
void createTabularResource(TabResource tabResource,AsyncCallback<TabResource> callback);
|
||||
|
||||
void getTabResourceInformation(AsyncCallback<TabResource> callback);
|
||||
|
||||
void getTabResourceInformation(TRId trId,AsyncCallback<TabResource> callback);
|
||||
|
||||
void setTabResourceInformation(TabResource tabResource, AsyncCallback<Void> callback);
|
||||
|
||||
void getTRCreationDate(TRId trId,AsyncCallback<String> callback);
|
||||
|
||||
void setTabResource(TabResource tabResource, AsyncCallback<Void> callback);
|
||||
|
||||
void getTabularResources(AsyncCallback<ArrayList<TabResource>> callback);
|
||||
|
||||
void getTabularResourcesAndLastTables(AsyncCallback<ArrayList<TabResource>> callback);
|
||||
|
||||
void getLastTable(TRId trId, AsyncCallback<TableData> callback);
|
||||
|
||||
void getTable(TRId trId, AsyncCallback<TableData> callback);
|
||||
|
||||
void getTableMetadata(TRId trId, AsyncCallback<ArrayList<TabMetadata>> callback);
|
||||
|
||||
void getTRMetadata(TRId trId, AsyncCallback<ArrayList<TRMetadata>> callback);
|
||||
|
||||
void getColumns(AsyncCallback<ArrayList<ColumnData>> callback);
|
||||
|
||||
void getColumns(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
|
||||
|
||||
void getColumnsForDimension(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
|
||||
|
||||
void getColumn(TRId trId, String columnName, AsyncCallback<ColumnData> callback);
|
||||
|
||||
void removeTabularResource(TRId trId, AsyncCallback<Void> callback);
|
||||
|
||||
void isTabularResourceValid(TRId trId,AsyncCallback<Boolean> callback);
|
||||
void getTabResourceInformation(AsyncCallback<TabResource> callback);
|
||||
void getTabResourceInformation(TRId trId,AsyncCallback<TabResource> callback);
|
||||
void setTabResourceInformation(TabResource tabResource, AsyncCallback<Void> callback);
|
||||
void getTRCreationDate(TRId trId,AsyncCallback<String> callback);
|
||||
void setTabResource(TabResource tabResource, AsyncCallback<Void> callback);
|
||||
void getTabularResources(AsyncCallback<ArrayList<TabResource>> callback);
|
||||
void getTabularResourcesAndLastTables(AsyncCallback<ArrayList<TabResource>> callback);
|
||||
void getLastTable(TRId trId, AsyncCallback<TableData> callback);
|
||||
void getTable(TRId trId, AsyncCallback<TableData> callback);
|
||||
void getTableMetadata(TRId trId, AsyncCallback<ArrayList<TabMetadata>> callback);
|
||||
void getTRMetadata(TRId trId, AsyncCallback<ArrayList<TRMetadata>> callback);
|
||||
void getColumns(AsyncCallback<ArrayList<ColumnData>> callback);
|
||||
void getColumns(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
|
||||
void getColumnsForDimension(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
|
||||
void getColumn(TRId trId, String columnName, AsyncCallback<ColumnData> callback);
|
||||
void getValidationColumns(TRId trId, String columnName, AsyncCallback<ArrayList<ColumnData>> callback);
|
||||
|
||||
//Share
|
||||
void getShareInfo(TRId trId, AsyncCallback<ShareInfo> callback);
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.gcube.data.analysis.tabulardata.model.column.type.DimensionColumnType
|
|||
import org.gcube.data.analysis.tabulardata.model.column.type.IdColumnType;
|
||||
import org.gcube.data.analysis.tabulardata.model.column.type.TimeDimensionColumnType;
|
||||
import org.gcube.data.analysis.tabulardata.model.column.type.ValidationColumnType;
|
||||
import org.gcube.data.analysis.tabulardata.model.metadata.column.ValidationReferencesMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.model.metadata.column.ViewColumnMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.model.metadata.common.DescriptionsMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.model.metadata.common.ImmutableLocalizedText;
|
||||
|
@ -601,6 +602,105 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ArrayList<ColumnData> getValidationColumns(TRId trId,
|
||||
String columnName) throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
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){
|
||||
logger.error("Column not present on table");
|
||||
throw new TDGWTServiceException("Column not present on table");
|
||||
}
|
||||
|
||||
logger.debug("getValidationColumns(): columnSource ColumnLocalId "+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) {
|
||||
if (c.contains(ValidationReferencesMetadata.class)) {
|
||||
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.setValidatedColumnReferences(validatedColumnReferences);
|
||||
columns.add(cData);
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
|
@ -4741,8 +4841,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<Occurrences> getOccurrencesForBatchReplace(ColumnData column)
|
||||
throws TDGWTServiceException {
|
||||
public ArrayList<Occurrences> getOccurrencesForBatchReplace(
|
||||
ColumnData column) throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
@ -5154,7 +5254,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
Long.valueOf(replaceBatchColumnSession.getTrId().getId()));
|
||||
logger.debug("OperationInvocation: \n" + invocations.toString());
|
||||
Task trTask = service.executeBatch(invocations, serviceTRId);
|
||||
if(trTask==null){
|
||||
if (trTask == null) {
|
||||
logger.error("Error on service Task null");
|
||||
throw new TDGWTServiceException("Task not started");
|
||||
}
|
||||
|
@ -5208,18 +5308,20 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
if (task.getResult() != null) {
|
||||
logger.debug("Task exception:"
|
||||
+ task.getErrorCause());
|
||||
replaceBatchColumnMonitor.setError(new Throwable(task
|
||||
.getErrorCause()));
|
||||
replaceBatchColumnMonitor.setError(new Throwable(
|
||||
task.getErrorCause()));
|
||||
} else {
|
||||
logger.debug("Task exception: Error In ReplaceBatchColumnMonitor");
|
||||
replaceBatchColumnMonitor.setError(new Throwable(
|
||||
"Error replacing the Column value"));
|
||||
}
|
||||
replaceBatchColumnMonitor.setProgress(task.getProgress());
|
||||
replaceBatchColumnMonitor.setProgress(task
|
||||
.getProgress());
|
||||
break;
|
||||
case SUCCEDED:
|
||||
logger.debug("Task Result:" + task.getResult());
|
||||
replaceBatchColumnMonitor.setProgress(task.getProgress());
|
||||
replaceBatchColumnMonitor.setProgress(task
|
||||
.getProgress());
|
||||
trId = new TRId();
|
||||
trId.setId(replaceBatchColumnSession.getTrId().getId());
|
||||
|
||||
|
@ -5232,16 +5334,19 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
SessionUtil.setTRId(session, trId);
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
replaceBatchColumnMonitor.setProgress(task.getProgress());
|
||||
replaceBatchColumnMonitor.setProgress(task
|
||||
.getProgress());
|
||||
break;
|
||||
case VALIDATING_RULES:
|
||||
replaceBatchColumnMonitor.setProgress(task.getProgress());
|
||||
replaceBatchColumnMonitor.setProgress(task
|
||||
.getProgress());
|
||||
break;
|
||||
case ABORTED:
|
||||
break;
|
||||
case STOPPED:
|
||||
logger.debug("Task Result:" + task.getResult());
|
||||
replaceBatchColumnMonitor.setProgress(task.getProgress());
|
||||
replaceBatchColumnMonitor.setProgress(task
|
||||
.getProgress());
|
||||
trId = new TRId();
|
||||
trId.setId(replaceBatchColumnSession.getColumnData()
|
||||
.getTrId().getId());
|
||||
|
@ -5263,14 +5368,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
SessionUtil.setReplaceBatchColumnTask(session, task);
|
||||
}
|
||||
|
||||
logger.info("ReplaceBatchColumnMonitor(): " + replaceBatchColumnMonitor);
|
||||
logger.info("ReplaceBatchColumnMonitor(): "
|
||||
+ replaceBatchColumnMonitor);
|
||||
return replaceBatchColumnMonitor;
|
||||
} catch (Throwable e) {
|
||||
logger.debug("Error in ReplaceBatchColumnMonitor: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
"Error in replace batch: "
|
||||
throw new TDGWTServiceException("Error in replace batch: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.tr;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
|
@ -15,7 +16,7 @@ public class ColumnData implements Serializable {
|
|||
private static final long serialVersionUID = 7614033455605898209L;
|
||||
|
||||
protected String id; // For insert in table only
|
||||
protected String columnId; //Id of column on server
|
||||
protected String columnId; // Id of column on server
|
||||
protected String name;
|
||||
protected String typeName;
|
||||
protected String typeCode;
|
||||
|
@ -25,6 +26,14 @@ public class ColumnData implements Serializable {
|
|||
protected boolean viewColumn;
|
||||
protected ColumnViewData columnViewData;
|
||||
|
||||
// validation columns that validate this column
|
||||
protected ArrayList<String> validationColumnReferences;
|
||||
|
||||
// true if this is a validation column
|
||||
protected boolean validationColumn;
|
||||
// if this is a validation column then contains the columns validated
|
||||
protected ArrayList<String> validatedColumnReferences;
|
||||
|
||||
public String getColumnId() {
|
||||
return columnId;
|
||||
}
|
||||
|
@ -105,18 +114,43 @@ public class ColumnData implements Serializable {
|
|||
this.viewColumn = viewColumn;
|
||||
}
|
||||
|
||||
public boolean isValidationColumn() {
|
||||
return validationColumn;
|
||||
}
|
||||
|
||||
public void setValidationColumn(boolean validationColumn) {
|
||||
this.validationColumn = validationColumn;
|
||||
}
|
||||
|
||||
public ArrayList<String> getValidatedColumnReferences() {
|
||||
return validatedColumnReferences;
|
||||
}
|
||||
|
||||
public void setValidatedColumnReferences(
|
||||
ArrayList<String> validatedColumnReferences) {
|
||||
this.validatedColumnReferences = validatedColumnReferences;
|
||||
}
|
||||
|
||||
public ArrayList<String> getValidationColumnReferences() {
|
||||
return validationColumnReferences;
|
||||
}
|
||||
|
||||
public void setValidationColumnReferences(
|
||||
ArrayList<String> validationColumnReferences) {
|
||||
this.validationColumnReferences = validationColumnReferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ColumnData [id=" + id + ", columnId=" + columnId + ", name="
|
||||
+ name + ", typeName=" + typeName + ", typeCode=" + typeCode
|
||||
+ ", dataTypeName=" + dataTypeName + ", label=" + label
|
||||
+ ", trId=" + trId + ", viewColumn=" + viewColumn
|
||||
+ ", columnViewData=" + columnViewData + "]";
|
||||
+ ", columnViewData=" + columnViewData
|
||||
+ ", validationColumnReferences=" + validationColumnReferences
|
||||
+ ", validationColumn=" + validationColumn
|
||||
+ ", validatedColumnReferences=" + validatedColumnReferences
|
||||
+ "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue