use of org.talend.designer.filemultischemas.data.SchemasKeyData in project tdi-studio-se by Talend.
the class MultiSchemasManager method retrievePropertiesFromNode.
/**
*
* cLi Comment method "retrievePropertiesFromNode".
*
*/
@SuppressWarnings("unchecked")
public SchemasKeyData retrievePropertiesFromNode() {
//$NON-NLS-1$
SchemasKeyData rootData = new SchemasKeyData("");
IElementParameter elementParameter = getMultiSchemasComponent().getElementParameter(EParameterName.SCHEMAS.getName());
final Object value = elementParameter.getValue();
if (value == null) {
return null;
}
List<Map<String, String>> schemasValues = (List<Map<String, String>>) value;
createSimpleDatas(rootData, schemasValues);
retrieveRelativeParent(rootData, schemasValues);
return rootData;
}
use of org.talend.designer.filemultischemas.data.SchemasKeyData in project tdi-studio-se by Talend.
the class ChangeMultiSchemasCommand method addSchemasMap.
private void addSchemasMap(List<Map<String, String>> newValueList, List<IMetadataTable> newTables, SchemasKeyData keyData) {
if (keyData == null) {
return;
}
if (keyData.getParent() != null) {
// not root
//
Map<String, String> map = new HashMap<String, String>();
final String uniqueRecord = keyData.getUniqueRecord();
final String recordType = keyData.getRecordType();
map.put(IMultiSchemaConstant.SCHEMA, uniqueRecord);
map.put(IMultiSchemaConstant.RECORD, TalendTextUtils.addQuotes(recordType));
map.put(IMultiSchemaConstant.PARENT_RECORD, TalendTextUtils.addQuotes(keyData.getParent().getRecordType()));
map.put(IMultiSchemaConstant.CARDINALITY, keyData.getCard());
map.put(IMultiSchemaConstant.FIELDDELIMITED, TalendTextUtils.addQuotes(keyData.getSeparator()));
newValueList.add(map);
//
String connectionBaseName = MetadataToolHelper.validateColumnName(MultiSchemasUtil.getConnectionBaseName(uniqueRecord), 0);
String uniqueConnName = node.getProcess().generateUniqueConnectionName(connectionBaseName);
MetadataTable table = new MetadataTable();
table.setLabel(uniqueRecord);
table.setTableName(uniqueConnName);
//$NON-NLS-1$
String keyIndex = "";
boolean first = true;
List<MultiMetadataColumn> metadataColumnsInModel = keyData.getMetadataColumnsInModel();
for (int i = 0; i < metadataColumnsInModel.size(); i++) {
MultiMetadataColumn column = metadataColumnsInModel.get(i);
table.getListColumns().add(column.clone(true));
if (column.isKey()) {
if (first) {
keyIndex += i;
} else {
//$NON-NLS-1$
keyIndex += "," + i;
}
first = false;
}
}
map.put(IMultiSchemaConstant.KEY_COLUMN_INDEX, TalendTextUtils.addQuotes(keyIndex));
newTables.add(table);
}
for (SchemasKeyData child : keyData.getChildren()) {
addSchemasMap(newValueList, newTables, child);
}
}
use of org.talend.designer.filemultischemas.data.SchemasKeyData in project tdi-studio-se by Talend.
the class MultiSchemasManager method findSchemasKeyData.
private SchemasKeyData findSchemasKeyData(SchemasKeyData schemaKeyData, String key) {
key = key.trim();
if (schemaKeyData != null || !"".equals(key)) {
//$NON-NLS-1$
if (schemaKeyData.getRecordType().equals(key)) {
return schemaKeyData;
}
for (SchemasKeyData child : schemaKeyData.getChildren()) {
String dataKey = child.getRecordType() + child.getSeparator();
if (dataKey.equals(key)) {
return child;
}
SchemasKeyData foundData = findSchemasKeyData(child, key);
if (foundData != null) {
return foundData;
}
}
}
return null;
}
use of org.talend.designer.filemultischemas.data.SchemasKeyData in project tdi-studio-se by Talend.
the class UIManager method moveRecord.
public void moveRecord(TreeViewer schemaTreeViewer, boolean left) {
if (schemaTreeViewer == null) {
return;
}
ISelection selection = schemaTreeViewer.getSelection();
if (selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof SchemasKeyData) {
SchemasKeyData data = (SchemasKeyData) element;
SchemasKeyData parent = data.getParent();
if (left) {
SchemasKeyData grandfather = parent.getParent();
if (grandfather != null) {
// not in root.
List<SchemasKeyData> children = grandfather.getChildren();
int index = -1;
for (int i = 0; i < children.size(); i++) {
if (children.get(i) == parent) {
index = i;
break;
}
}
if (index > -1) {
int index2 = index + 1;
if (index2 > children.size()) {
grandfather.addChild(data);
} else {
grandfather.addChild(index2, data);
}
}
}
} else {
SchemasKeyData sibling = null;
for (SchemasKeyData skd : parent.getChildren()) {
if (skd == data) {
break;
} else {
sibling = skd;
}
}
if (sibling != null) {
sibling.addChild(data);
}
}
schemaTreeViewer.refresh();
}
}
}
use of org.talend.designer.filemultischemas.data.SchemasKeyData in project tdi-studio-se by Talend.
the class SchemaDetailsPropertiesCellModifier method canModify.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
*/
public boolean canModify(Object element, String property) {
if (element instanceof MultiMetadataColumn) {
MultiMetadataColumn column = (MultiMetadataColumn) element;
SchemasKeyData container = column.getContainer();
if (container == null) {
return false;
}
List<MultiMetadataColumn> metadataColumnsInModel = container.getMetadataColumnsInModel();
/*
* ingore record type(first column);
*
* if existed key column, should not edit other key.
*/
if (EPropertyName.KEY.name().equals(property) && (metadataColumnsInModel.indexOf(column) == uiManager.getSelectedColumnIndex() || UIManager.existedKeyColumn(metadataColumnsInModel, column))) {
return false;
}
if (!EPropertyName.TAGLEVEL.name().equals(property)) {
return true;
}
}
return false;
}
Aggregations