use of org.talend.designer.filemultischemas.data.MultiSchemaRowData 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.MultiSchemaRowData 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;
}
use of org.talend.designer.filemultischemas.data.MultiSchemaRowData in project tdi-studio-se by Talend.
the class MultiSchemasManager method createSchemasTree.
/**
*
* cLi Comment method "createSchemasTree".
*
* @param csvArray
* @return tree of data.
*/
public SchemasKeyData createSchemasTree(CSVArrayAndSeparator csvArrayBean, int selectColumnIndex) {
if (csvArrayBean == null) {
return null;
}
// final int columnIndex = 2;
//$NON-NLS-1$
final SchemasKeyData rootSchemasKeyData = new SchemasKeyData("");
List<String[]> rows = csvArrayBean.getCsvArray().getRows();
for (int i = 0; i < rows.size(); i++) {
// if (line.length < columnIndex) { // must contain 2 columns
// continue;
// }
String[] line = rows.get(i);
final String key = precessString(line[selectColumnIndex]);
if (key == null) {
continue;
}
String newKey = key + csvArrayBean.getSeparators().get(i);
//
SchemasKeyData schemaData = findSchemasKeyData(rootSchemasKeyData, newKey);
if (schemaData == null) {
schemaData = new SchemasKeyData(key);
// TDI-6803
String separator = csvArrayBean.getSeparators().get(i);
if (separator != null && separator.equals("\\")) {
schemaData.setSeparator("\\\\");
} else {
schemaData.setSeparator(separator);
}
schemaData.setUniqueRecord(generateUniqueRecordName(null, rootSchemasKeyData));
rootSchemasKeyData.addChild(schemaData);
}
//
MultiSchemaRowData rowData = createRowData(line, selectColumnIndex);
if (rowData != null) {
schemaData.addRowsData(rowData);
}
}
for (SchemasKeyData schemaData : rootSchemasKeyData.getChildren()) {
createPropertiesColumns(schemaData);
}
return rootSchemasKeyData;
}
Aggregations