use of org.talend.designer.filemultischemas.data.MultiSchemasMetadataColumn in project tdi-studio-se by Talend.
the class MultiSchemasManager method createRowData.
/**
*
* cLi Comment method "createRowData".
*
* @param line
* @return
*/
public MultiSchemaRowData createRowData(String[] line, int selectColumnIndex) {
if (line == null || line.length < 1) {
return null;
}
boolean isEndEmpty = true;
List<String> newDatas = new ArrayList<String>();
for (int i = line.length - 1; i > -1; i--) {
String data = line[i];
// find the last un-empty data.
if (!"".equals(data) && isEndEmpty) {
//$NON-NLS-1$
isEndEmpty = false;
}
if (!isEndEmpty) {
newDatas.add(data);
}
}
MultiSchemaRowData rowData = new MultiSchemaRowData(precessString(line[selectColumnIndex]));
for (int i = newDatas.size() - 1; i > -1; i--) {
final String data = newDatas.get(i);
MultiSchemasMetadataColumn metadataColumn = guessDataProperties(data);
metadataColumn.setData(data);
UniqueStringGenerator<MultiSchemasMetadataColumn> generator = getUniqueStringGenerator(rowData.getColumnsData());
metadataColumn.setLabel(generator.getUniqueString());
rowData.addColumnData(metadataColumn);
}
return rowData;
}
use of org.talend.designer.filemultischemas.data.MultiSchemasMetadataColumn in project tdi-studio-se by Talend.
the class MultiSchemasManager method guessDataProperties.
private MultiSchemasMetadataColumn guessDataProperties(String data) {
if (data == null) {
//$NON-NLS-1$
data = "";
}
String talendType = null;
int lengthValue = 0;
int precisionValue = 0;
// type
if (getLanguage() == ECodeLanguage.JAVA) {
talendType = JavaDataTypeHelper.getTalendTypeOfValue(data);
} else {
// perl
talendType = PerlDataTypeHelper.getNewTalendTypeOfValue(data);
}
// length
if (lengthValue < data.length()) {
lengthValue = data.length();
}
// precision
if (!data.equals("")) {
//$NON-NLS-1$
int positionDecimal = 0;
if (data.indexOf(',') > -1) {
positionDecimal = data.lastIndexOf(',');
precisionValue = lengthValue - positionDecimal;
} else if (data.indexOf('.') > -1) {
positionDecimal = data.lastIndexOf('.');
precisionValue = lengthValue - positionDecimal;
}
} else {
talendType = getValueDefaultType();
lengthValue = getValueDefaultLength();
}
//
MultiSchemasMetadataColumn metadataColumn = new MultiSchemasMetadataColumn();
if (getLanguage() == ECodeLanguage.JAVA) {
if (talendType.equals(JavaTypesManager.FLOAT.getId()) || talendType.equals(JavaTypesManager.DOUBLE.getId())) {
metadataColumn.setPrecision(precisionValue);
} else {
metadataColumn.setPrecision(0);
}
} else {
if (talendType.equals(PerlTypesManager.DECIMAL)) {
metadataColumn.setPrecision(precisionValue);
} else {
metadataColumn.setPrecision(0);
}
}
metadataColumn.setTalendType(talendType);
metadataColumn.setLength(lengthValue);
return metadataColumn;
}
use of org.talend.designer.filemultischemas.data.MultiSchemasMetadataColumn in project tdi-studio-se by Talend.
the class SchemaDetailsColumnsProvider method getColumnText.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
public String getColumnText(Object element, int columnIndex) {
if (element instanceof ColumnLineData) {
ColumnLineData lineData = (ColumnLineData) element;
final EPropertyName property = lineData.getProperty();
if (columnIndex == 0) {
if (UIManager.isFirstForColumnModel(property)) {
//$NON-NLS-1$
return EPropertyName.NAME.getName();
} else if (property == EPropertyName.NAME) {
//$NON-NLS-1$
return "";
}
return property.getName();
}
List<MultiMetadataColumn> columnsData = lineData.getKeyData().getMetadataColumnsInModel();
if (columnsData.size() >= columnIndex) {
MultiMetadataColumn columnData = columnsData.get(columnIndex - 1);
if (columnData != null) {
if (UIManager.isFirstForColumnModel(property)) {
return columnData.getLabel();
}
switch(property) {
case NAME:
List<MultiSchemasMetadataColumn> dataColumns = columnData.getDataColumns();
if (dataColumns.size() > 0) {
// only use the first line
MultiSchemasMetadataColumn c = dataColumns.get(0);
return c.getData();
}
return columnData.getData();
case TAGLEVEL:
if (columnIndex == 1) {
// only the first data column display the level.
return validateValue(columnData.getContainerTagLevel());
}
break;
case KEY:
if (columnIndex == uiManager.getSelectedColumnIndex() + 1) {
// record type column.
return null;
}
return validateValue(columnData.isKey());
case TYPE:
return getTypeLabel(columnData.getTalendType());
// return validateValue(columnData.isNullable());
case LENGTH:
return validateValue(columnData.getLength());
// return columnData.getCard();
case PATTERN:
return columnData.getPattern();
default:
}
}
}
}
return null;
}
use of org.talend.designer.filemultischemas.data.MultiSchemasMetadataColumn in project tdi-studio-se by Talend.
the class SchemaDetailsPropertiesProvider method getColumnText.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
public String getColumnText(Object element, int columnIndex) {
if (columnIndex == 0) {
// column name
if (element instanceof MultiMetadataColumn) {
return ((MultiMetadataColumn) element).getLabel();
}
if (element instanceof MultiSchemasMetadataColumn) {
return ((MultiSchemasMetadataColumn) element).getData();
}
} else if (columnIndex == 1) {
// level
if (element instanceof MultiMetadataColumn) {
MultiMetadataColumn multiMetadataColumn = (MultiMetadataColumn) element;
return validateValue(multiMetadataColumn.getContainerTagLevel());
}
} else if (columnIndex == 2) {
// key
if (element instanceof MultiMetadataColumn) {
MultiMetadataColumn multiMetadataColumn = (MultiMetadataColumn) element;
// first column(record type)
SchemasKeyData container = multiMetadataColumn.getContainer();
if (container != null && container.getMetadataColumnsInModel().indexOf(multiMetadataColumn) == uiManager.getSelectedColumnIndex()) {
return null;
}
return validateValue(multiMetadataColumn.isKey());
}
} else {
if (element instanceof MultiSchemasMetadataColumn) {
MultiSchemasMetadataColumn column = (MultiSchemasMetadataColumn) element;
switch(columnIndex) {
case // type
3:
return getTypeLabel(column.getTalendType());
case // length
4:
return validateValue(column.getLength());
// return column.getCard();
case // pattern
5:
return column.getPattern();
}
}
}
return null;
}
use of org.talend.designer.filemultischemas.data.MultiSchemasMetadataColumn in project tdi-studio-se by Talend.
the class MultiSchemasManager method createPropertiesColumns.
public List<MultiMetadataColumn> createPropertiesColumns(SchemasKeyData keyData) {
List<MultiMetadataColumn> columns = new ArrayList<MultiMetadataColumn>();
if (keyData != null) {
final int tagLevel = keyData.getTagLevel();
//
final List<MultiSchemaRowData> rowsData = keyData.getRowsData();
for (MultiSchemaRowData row : rowsData) {
final List<MultiSchemasMetadataColumn> columnsData = row.getColumnsData();
for (int i = 0; i < columnsData.size(); i++) {
final MultiSchemasMetadataColumn metadataColumn = columnsData.get(i);
MultiMetadataColumn column = null;
if (columns.size() - 1 < i) {
// not contain
column = new MultiMetadataColumn(row.getKeyName());
column.setLabel(metadataColumn.getLabel());
column.setContainer(keyData);
columns.add(column);
} else {
column = columns.get(i);
}
column.addDataColumns(metadataColumn);
}
}
keyData.setMetadataColumns(columns);
}
return columns;
}
Aggregations