use of org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPCommand in project tdi-studio-se by Talend.
the class ComponentChooseDialog method getSAPCommand.
/**
* Added by Marvin Wang on July 12, 2012 for getting the command of SAP.
*
* @param object
* @param connectionItem
* @param table
* @param node
* @return
*/
private void getSAPCommand(CompoundCommand cc, IRepositoryViewObject object, ConnectionItem connectionItem, MetadataTable table, Node node) {
SAPFunctionUnit functionUnit = null;
if (object instanceof MetadataTableRepositoryObject) {
IElementParameter schemaParam = null;
List<IElementParameter> schemaTypeList = node.getElementParametersFromField(EParameterFieldType.SCHEMA_TYPE);
for (IElementParameter param : schemaTypeList) {
if (param.getName().equals("SCHEMA")) {
//$NON-NLS-1$
schemaParam = param;
break;
}
}
if (table.eContainer() instanceof SAPFunctionUnit) {
// function parameter table
functionUnit = (SAPFunctionUnit) table.eContainer();
// To judge what the current node is, tSAPOutput or tSAPInput component.
String sapComponentName = node.getComponent().getName();
if ("tSAPBapi".equals(sapComponentName)) {
//$NON-NLS-1$
RepositoryChangeMetadataForSAPBapi command = new RepositoryChangeMetadataForSAPBapi(node, (SAPFunctionUnit) table.eContainer(), ConvertionHelper.convert(table), null);
cc.add(command);
} else {
if (schemaParam != null) {
// repository id should be connectionid - sapfunctionName/type/tableName
String type = table.getTableType() == null ? MetadataSchemaType.OUTPUT.name() : table.getTableType();
String value = connectionItem.getProperty().getId() + " - " + functionUnit.getLabel() + "/" + type + "/" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
table.getLabel();
RepositoryChangeMetadataCommand changeValueCmd = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection());
cc.add(changeValueCmd);
}
IElementParameter schemasParam = node.getElementParameter(ISAPConstant.TABLE_SCHEMAS);
if (schemasParam != null) {
Command sapCmd = new RepositoryChangeMetadataForSAPCommand(node, ISAPConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table), functionUnit);
cc.add(sapCmd);
}
}
} else {
// Sap Table : keep repository id as before
if (schemaParam != null) {
//$NON-NLS-1$
String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
RepositoryChangeMetadataCommand changeValueCmd = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection(), table);
cc.add(changeValueCmd);
}
}
} else if (object instanceof SAPFunctionRepositoryObject) {
functionUnit = (SAPFunctionUnit) ((SAPFunctionRepositoryObject) object).getAbstractMetadataObject();
if (node.getComponent() != null && node.getComponent().getName().equals("tSAPBapi")) {
//$NON-NLS-1$
RepositoryChangeMetadataForSAPBapi command = new RepositoryChangeMetadataForSAPBapi(node, functionUnit, null, null);
cc.add(command);
} else {
for (MetadataTable metadataTable : functionUnit.getTables()) {
Command sapCmd = new RepositoryChangeMetadataForSAPCommand(node, ISAPConstant.TABLE_SCHEMAS, metadataTable.getLabel(), ConvertionHelper.convert(metadataTable), functionUnit);
cc.add(sapCmd);
}
}
}
}
Aggregations