use of org.talend.core.model.metadata.builder.connection.SAPFunctionUnit 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);
}
}
}
}
use of org.talend.core.model.metadata.builder.connection.SAPFunctionUnit in project tdi-studio-se by Talend.
the class ComponentChooseDialog method setSAPSpecailValueForCommand.
private void setSAPSpecailValueForCommand(RepositoryNode selectedNode, ChangeValuesFromRepository command) {
// Noted by Marvin Wang on Jun. 29, 2012. The piece of code is used to judge if the selected node is SAP
// Table node, if so, set up the table name to command.
IRepositoryViewObject object = selectedNode.getObject();
if (object instanceof MetadataColumnRepositoryObject) {
object = selectedNode.getParent().getParent().getObject();
}
SAPFunctionUnit unit = null;
if (object != null) {
if (object instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject tableObject = (MetadataTableRepositoryObject) object;
MetadataTable abstractMetadataObject = (MetadataTable) tableObject.getAbstractMetadataObject();
if (abstractMetadataObject != null && abstractMetadataObject.eContainer() instanceof SAPFunctionUnit) {
unit = (SAPFunctionUnit) abstractMetadataObject.eContainer();
command.setSapFunctionLabel(unit.getLabel());
// set table name to functionName/type/tablename;
String currentTableName = //$NON-NLS-1$ //$NON-NLS-2$
unit.getLabel() + "/" + abstractMetadataObject.getTableType() + "/" + abstractMetadataObject.getLabel();
command.setCurrentTableName(currentTableName);
} else if (abstractMetadataObject instanceof SAPTable) {
command.setCurrentTableName(abstractMetadataObject.getLabel());
}
} else if (object instanceof SAPFunctionRepositoryObject) {
SAPFunctionRepositoryObject sapObj = (SAPFunctionRepositoryObject) object;
unit = sapObj.getModelElement();
command.setSapFunctionLabel(unit.getLabel());
} else if (object instanceof SAPIDocRepositoryObject) {
SAPIDocRepositoryObject sapObj = (SAPIDocRepositoryObject) object;
command.setSapIDocLabel(sapObj.getLabel());
}
}
}
use of org.talend.core.model.metadata.builder.connection.SAPFunctionUnit in project tdi-studio-se by Talend.
the class SAPParametersUtils method retrieveSAPParams.
/**
* DOC xye Comment method "retrieveSAPParams".
*
* @param param
*/
@SuppressWarnings("unchecked")
public static void retrieveSAPParams(final IElement elem, final Connection connection, final IElementParameter param, final String sapFunctionLabel) {
if (param.getRepositoryValue() == null || !(connection instanceof SAPConnection)) {
return;
}
if (param.getFieldType().equals(EParameterFieldType.TEXT) && param.getRepositoryValue().equals("SAP_FUNCTION")) {
//$NON-NLS-1$
if (connection != null && sapFunctionLabel != null) {
SAPFunctionUnit unit = null;
for (int i = 0; i < ((SAPConnection) connection).getFuntions().size(); i++) {
SAPFunctionUnit tmp = ((SAPConnection) connection).getFuntions().get(i);
if (tmp.getLabel().equals(sapFunctionLabel)) {
unit = tmp;
break;
}
}
if (unit == null) {
return;
}
param.setValue(TalendTextUtils.addQuotes(unit.getName()));
param.setRepositoryValueUsed(true);
param.setReadOnly(true);
} else {
param.setRepositoryValueUsed(false);
param.setReadOnly(false);
}
} else if (param.getFieldType().equals(EParameterFieldType.TABLE)) {
if (param.getRepositoryValue().equals("INPUT_PARAMS")) {
//$NON-NLS-1$
if (connection != null && sapFunctionLabel != null) {
List<Map<String, Object>> table = (List<Map<String, Object>>) elem.getPropertyValue(param.getName());
RepositoryToComponentProperty.getSAPInputAndOutputValue((SAPConnection) connection, table, sapFunctionLabel, true);
param.setRepositoryValueUsed(true);
param.setReadOnly(true);
} else {
param.setRepositoryValueUsed(false);
param.setReadOnly(false);
}
}
if ("SAP_PROPERTIES".equals(param.getRepositoryValue())) {
//$NON-NLS-1$
//$NON-NLS-1$
Object value = RepositoryToComponentProperty.getValue(connection, "SAP_PROPERTIES", null);
param.setValue(value);
param.setRepositoryValueUsed(true);
param.setReadOnly(true);
}
} else if (param.getFieldType().equals(EParameterFieldType.TABLE) && param.getRepositoryValue().equals("OUTPUT_PARAMS")) {
//$NON-NLS-1$
if (connection != null && sapFunctionLabel != null) {
List<Map<String, Object>> table = (List<Map<String, Object>>) elem.getPropertyValue(param.getName());
RepositoryToComponentProperty.getSAPInputAndOutputValue((SAPConnection) connection, table, sapFunctionLabel, false);
param.setRepositoryValueUsed(true);
param.setReadOnly(true);
} else {
param.setRepositoryValueUsed(false);
param.setReadOnly(false);
}
} else if (param.getRepositoryValue().equals("SAP_ITERATE_OUT_TYPE")) {
//$NON-NLS-1$
if (connection != null && sapFunctionLabel != null) {
param.setValue(RepositoryToComponentProperty.getSAPValuesForFunction((SAPConnection) connection, sapFunctionLabel, //$NON-NLS-1$
"SAP_ITERATE_OUT_TYPE"));
param.setRepositoryValueUsed(true);
param.setReadOnly(true);
} else {
param.setRepositoryValueUsed(false);
param.setReadOnly(false);
}
} else if (param.getRepositoryValue().equals("SAP_ITERATE_OUT_TABLENAME")) {
//$NON-NLS-1$
if (connection != null && sapFunctionLabel != null) {
param.setValue(RepositoryToComponentProperty.getSAPValuesForFunction((SAPConnection) connection, sapFunctionLabel, //$NON-NLS-1$
"SAP_ITERATE_OUT_TABLENAME"));
param.setRepositoryValueUsed(true);
param.setReadOnly(true);
} else {
param.setRepositoryValueUsed(false);
param.setReadOnly(false);
}
}
}
use of org.talend.core.model.metadata.builder.connection.SAPFunctionUnit in project tdi-studio-se by Talend.
the class UpdateNodeParameterCommand method updateSAPParameters.
/**
* DOC YeXiaowei Comment method "updateSAPParameters".
*/
private void updateSAPParameters() {
Object updateObject = result.getUpdateObject();
if (updateObject == null) {
return;
}
boolean builtin = true;
if (updateObject instanceof Node) {
Node node = (Node) updateObject;
if (result.getResultType() == EUpdateResult.UPDATE) {
if (result.isChecked()) {
if (result.getParameter() instanceof SAPFunctionUnit) {
SAPFunctionUnit unit = (SAPFunctionUnit) result.getParameter();
for (IElementParameter param : node.getElementParameters()) {
SAPParametersUtils.retrieveSAPParams(node, unit.getConnection(), param, unit.getLabel());
}
builtin = false;
}
}
}
if (builtin) {
// built-in
node.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
for (IElementParameter param : node.getElementParameters()) {
SAPParametersUtils.setNoRepositoryParams(param);
}
}
}
}
use of org.talend.core.model.metadata.builder.connection.SAPFunctionUnit in project tdi-studio-se by Talend.
the class BusinessAssignmentComposite method createSelectionListener.
private void createSelectionListener() {
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
BusinessAssignment businessAssignment = getBusinessAssignment(event.getSelection());
if (businessAssignment != null) {
final IRepositoryView repositoryView = getRepositoryView();
if (repositoryView != null) {
IProjectRepositoryNode rootRepositoryNode = repositoryView.getRoot();
TalendItem item = businessAssignment.getTalendItem();
//
if (item instanceof Routine && rootRepositoryNode instanceof ProjectRepositoryNode) {
RepositoryNodeUtilities.expandParentNode(getRepositoryView(), ((ProjectRepositoryNode) rootRepositoryNode).getRootRepositoryNode(ERepositoryObjectType.CODE));
}
selectChild(item, (IRepositoryNode) rootRepositoryNode);
}
}
}
private void selectChild(TalendItem item, IRepositoryNode rootRepositoryNode) {
try {
RepositoryNode curNode = null;
JobSettingsView viewer = (JobSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(JobSettingsView.ID);
IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(item.getId());
if (lastVersion != null) {
curNode = RepositoryNodeUtilities.getRepositoryNode(lastVersion);
select(viewer, curNode);
} else if (item instanceof TableMetadata) {
MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(item.getId());
if (table != null) {
//$NON-NLS-1$
String id = item.getId().split(" - ")[0];
RepositoryNode node = RepositoryNodeUtilities.getMetadataTableFromConnection(item.getId());
IRepositoryView view = getRepositoryView();
if (view != null) {
RepositoryNodeUtilities.expandParentNode(view, node);
select(viewer, node);
}
}
} else if (item instanceof Query) {
org.talend.core.model.metadata.builder.connection.Query query = MetadataToolHelper.getQueryFromRepository(item.getId());
if (query != null) {
//$NON-NLS-1$
String id = item.getId().split(" - ")[0];
IRepositoryView view = getRepositoryView();
RepositoryNode node = RepositoryNodeUtilities.getQueryFromConnection(item.getId());
RepositoryNodeUtilities.expandParentNode(view, node);
select(viewer, node);
}
} else if (item instanceof SAPFunction) {
SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(item.getId());
if (function != null) {
IRepositoryView view = getRepositoryView();
RepositoryNode node = RepositoryNodeUtilities.getSAPFunctionFromConnection(item.getId());
RepositoryNodeUtilities.expandParentNode(view, node);
select(viewer, node);
}
} else {
for (IRepositoryNode node : rootRepositoryNode.getChildren()) {
RepositoryNode rNode = (RepositoryNode) node;
if (item instanceof SQLPattern && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.SQLPATTERNS) {
if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
SQLPatternItem sqlItem = (SQLPatternItem) rNode.getObject().getProperty().getItem();
if (sqlItem.isSystem() && item.getLabel().equals(rNode.getObject().getLabel())) {
select(viewer, rNode);
}
} else {
selectChild(item, rNode);
}
} else if (item instanceof Routine && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.ROUTINES) {
if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
RoutineItem sqlItem = (RoutineItem) rNode.getObject().getProperty().getItem();
if (sqlItem.isBuiltIn() && item.getLabel().equals(rNode.getObject().getLabel())) {
select(viewer, rNode);
}
} else {
selectChild(item, rNode);
}
}
}
}
} catch (PersistenceException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
ExceptionHandler.process(e);
}
}
private void select(JobSettingsView viewer, RepositoryNode repositoryNode) {
if (viewer == null) {
return;
}
if (repositoryNode == null) {
return;
}
CorePlugin.getDefault().getRepositoryService().removeRepositoryTreeViewListener(viewer);
final IRepositoryView repositoryView = getRepositoryView();
if (repositoryView != null) {
repositoryView.getViewer().setSelection(new StructuredSelection(repositoryNode));
}
CorePlugin.getDefault().getRepositoryService().addRepositoryTreeViewListener(viewer);
}
});
}
Aggregations