use of org.talend.core.model.metadata.builder.connection.XmlFileConnection in project tdi-studio-se by Talend.
the class RepositoryTypeProcessor method selectRepositoryNode.
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
final String repositoryType = getRepositoryType();
if (node == null) {
return false;
}
if (node.getContentType() == ERepositoryObjectType.REFERENCED_PROJECTS) {
return true;
}
// for sub folders
if (node.getType() == ENodeType.STABLE_SYSTEM_FOLDER) {
return false;
}
// for Db Connections
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
// }
IRepositoryViewObject object = node.getObject();
if (object == null || object.getProperty().getItem() == null) {
return false;
}
if (object instanceof MetadataTable) {
return false;
}
Item item = object.getProperty().getItem();
if (item instanceof FolderItem) {
return true;
}
if (item instanceof ConnectionItem) {
ConnectionItem connectionItem = (ConnectionItem) item;
Connection connection = connectionItem.getConnection();
// tAdvancedFileOutputXML
if (repositoryType != null && repositoryType.equals(ERepositoryCategoryType.XMLOUTPUT.getName())) {
if (connection instanceof XmlFileConnection && ((XmlFileConnection) connection).isInputModel()) {
return false;
}
}
if (repositoryType.startsWith(ERepositoryCategoryType.DATABASE.getName())) {
//$NON-NLS-1$
String currentDbType = (String) RepositoryToComponentProperty.getValue(connection, "TYPE", null);
if (repositoryType.contains(":")) {
// database //$NON-NLS-1$
// is
// specified
// //$NON-NLS-1$
//$NON-NLS-1$
String neededDbType = repositoryType.substring(repositoryType.indexOf(":") + 1);
if (hidenTypeSelection) {
return true;
}
if (!MetadataTalendType.sameDBProductType(neededDbType, currentDbType)) {
return false;
}
}
}
}
if (repositoryType.startsWith(ERepositoryCategoryType.HEADERFOOTER.getName())) {
if (item instanceof HeaderFooterConnectionItem) {
HeaderFooterConnectionItem connectionItem = (HeaderFooterConnectionItem) item;
HeaderFooterConnection connection = (HeaderFooterConnection) connectionItem.getConnection();
boolean isHeader = connection.isIsHeader();
if ((isHeader && isHeaderButton) || (!isHeader && !isHeaderButton)) {
return true;
} else {
return false;
}
}
}
return true;
}
use of org.talend.core.model.metadata.builder.connection.XmlFileConnection in project tdi-studio-se by Talend.
the class DynamicTabbedPropertySection method updateRepositoryListExtra.
private void updateRepositoryListExtra(IElementParameter param, String[] repositoryConnectionNameList, String[] repositoryConnectionValueList, boolean extra) {
String paramName = EParameterName.PROPERTY_TYPE.getName();
// if (extra) {
// paramName = extraPropertyTypeName;
// }
String repositoryValue = elem.getElementParameter(paramName).getRepositoryValue();
if (repositoryValue != null) {
List<String> connectionNamesList = new ArrayList<String>();
List<String> connectionValuesList = new ArrayList<String>();
for (String key : repositoryConnectionItemMap.keySet()) {
ConnectionItem connectionItem = repositoryConnectionItemMap.get(key);
Connection connection = connectionItem.getConnection();
String name = //$NON-NLS-1$
getRepositoryAliasName(connectionItem) + ":" + connectionItem.getProperty().getLabel();
if ((connection instanceof DelimitedFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.DELIMITED.getName()))) {
addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
}
if ((connection instanceof PositionalFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.POSITIONAL.getName()))) {
addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
}
if ((connection instanceof RegexpFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.REGEX.getName()))) {
addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
}
if ((connection instanceof XmlFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.XML.getName()))) {
addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
}
if ((connection instanceof FileExcelConnection) && (repositoryValue.equals(ERepositoryCategoryType.EXCEL.getName()))) {
addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
}
if ((connection instanceof GenericSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.GENERIC.getName()))) {
addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
}
if ((connection instanceof LDAPSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.LDAP.getName()))) {
addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
}
if ((connection instanceof SalesforceSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.SALESFORCE.getName()))) {
addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
}
if ((connection instanceof DatabaseConnection) && (repositoryValue.startsWith(ERepositoryCategoryType.DATABASE.getName()))) {
//$NON-NLS-1$
String currentDbType = (String) RepositoryToComponentProperty.getValue(connection, "TYPE", null);
if (repositoryValue.contains(":")) {
// database //$NON-NLS-1$
// is
// specified
// //$NON-NLS-1$
//$NON-NLS-1$
String neededDbType = repositoryValue.substring(repositoryValue.indexOf(":") + 1);
if (neededDbType.equals(currentDbType)) {
addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
}
} else {
addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
}
}
if ((connection instanceof HeaderFooterConnection) && (repositoryValue.equals(ERepositoryCategoryType.HEADERFOOTER.getName()))) {
addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
}
}
repositoryConnectionNameList = connectionNamesList.toArray(new String[0]);
repositoryConnectionValueList = connectionValuesList.toArray(new String[0]);
} else {
List<String> connectionValuesList = new ArrayList<String>();
List<String> connectionStringList = new ArrayList<String>();
for (String key : repositoryConnectionItemMap.keySet()) {
ConnectionItem connectionItem = repositoryConnectionItemMap.get(key);
String name = connectionItem.getProperty().getLabel();
addOrderDisplayNames(connectionValuesList, connectionStringList, key, name);
}
repositoryConnectionNameList = connectionStringList.toArray(new String[0]);
repositoryConnectionValueList = connectionValuesList.toArray(new String[0]);
}
param.setListItemsDisplayName(repositoryConnectionNameList);
param.setListItemsValue(repositoryConnectionValueList);
if (!repositoryConnectionItemMap.keySet().contains(param.getValue())) {
if (repositoryConnectionNameList.length > 0) {
// paramName = EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
// if (extra) {
// paramName = extraRepositoryPropertyTypeName;
// }
elem.setPropertyValue(paramName, repositoryConnectionValueList[0]);
}
}
}
use of org.talend.core.model.metadata.builder.connection.XmlFileConnection in project tdi-studio-se by Talend.
the class ChangeValuesFromRepository method undo.
@Override
public void undo() {
// Force redraw of Commponents propoerties
elem.setPropertyValue(updataComponentParamName, new Boolean(true));
if (propertyName.split(":")[1].equals(propertyTypeName) && (EmfComponent.BUILTIN.equals(value))) {
//$NON-NLS-1$
for (IElementParameter param : elem.getElementParameters()) {
String repositoryValue = param.getRepositoryValue();
if (param.isShow(elem.getElementParameters()) && (repositoryValue != null) && (!param.getName().equals(propertyTypeName))) {
boolean paramFlag = JobSettingsConstants.isExtraParameter(param.getName());
boolean extraFlag = JobSettingsConstants.isExtraParameter(propertyTypeName);
if (paramFlag == extraFlag) {
// for job settings extra.(feature 2710)
param.setRepositoryValueUsed(true);
}
}
}
} else {
for (IElementParameter param : elem.getElementParameters()) {
String repositoryValue = param.getRepositoryValue();
if (param.isShow(elem.getElementParameters()) && (repositoryValue != null)) {
Object objectValue = RepositoryToComponentProperty.getValue(connection, repositoryValue, null);
if (dragAndDropAction == true && connection instanceof XmlFileConnectionImpl) {
objectValue = RepositoryToComponentProperty.getXmlAndXSDFileValue((XmlFileConnection) connection, repositoryValue);
dragAndDropAction = false;
}
if (objectValue != null) {
elem.setPropertyValue(param.getName(), oldValues.get(param.getName()));
param.setRepositoryValueUsed(false);
}
}
}
}
IElementParameter currentParam = elem.getElementParameter(propertyName);
if (propertyName.split(":")[1].equals(propertyTypeName)) {
//$NON-NLS-1$
if (value.equals(EmfComponent.BUILTIN)) {
currentParam.setValue(EmfComponent.REPOSITORY);
} else {
currentParam.setValue(EmfComponent.BUILTIN);
IElementParameter schemaParam = elem.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE, currentParam.getCategory());
if (schemaParam == null) {
schemaParam = elem.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE, currentParam.getCategory());
}
if (schemaParam != null) {
IElementParameter schemaType = schemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName());
schemaType.setValue(EmfComponent.BUILTIN);
}
IElementParameter queryParam = elem.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE, currentParam.getCategory());
if (queryParam != null) {
IElementParameter queryStoreType = queryParam.getChildParameters().get(EParameterName.QUERYSTORE_TYPE.getName());
queryStoreType.setValue(EmfComponent.BUILTIN);
}
}
} else {
elem.setPropertyValue(propertyName, oldMetadata);
}
JobSettings.switchToCurJobSettingsView();
}
use of org.talend.core.model.metadata.builder.connection.XmlFileConnection in project tdi-studio-se by Talend.
the class RepositoryChangeMetadataCommand method execute.
@Override
public void execute() {
node.setPropertyValue(propName, newPropValue);
String mainSchemaParamName = DesignerUtilities.getMainSchemaParameterName(node);
if (mainSchemaParamName.equals(propName)) {
IElementParameter elementParameter = node.getElementParameter(propName);
if (elementParameter != null) {
IElementParameter schemaTypeParam = elementParameter.getParentParameter().getChildParameters().get(EParameterName.SCHEMA_TYPE.getName());
if (schemaTypeParam != null) {
if (newPropValue != null && !"".equals(newPropValue)) {
//$NON-NLS-1$
schemaTypeParam.setValue(EmfComponent.REPOSITORY);
} else {
schemaTypeParam.setValue(EmfComponent.BUILTIN);
}
}
}
}
if (node.isExternalNode() && !node.isELTComponent()) {
for (IElementParameter parameter : node.getElementParameters()) {
if (parameter.getFieldType() == EParameterFieldType.TABLE) {
if (!node.getMetadataList().isEmpty() && !node.getMetadataList().get(0).sameMetadataAs(newOutputMetadata)) {
parameter.setValue(new ArrayList<Map<String, Object>>());
}
}
}
}
// ELT Input/output component need add the schema conetxt in Context Mode
if (node.isELTComponent()) {
//$NON-NLS-1$
IElementParameter schemaParam = node.getElementParameter("ELT_SCHEMA_NAME");
if (schemaParam != null && schemaParam.getValue() != null && newPropValue != null && connection != null && connection.isContextMode() && ContextParameterUtils.isContainContextParam(schemaParam.getValue().toString())) {
ConnectionItem connectionItem = MetadataToolHelper.getConnectionItemFromRepository(newPropValue.toString());
ConnectionContextHelper.addContextForNodeParameter(node, connectionItem, false);
}
}
// IElementParameter schemaTypeParameter =
// node.getElementParameter(propName).getParentParameter().getChildParameters().get(
// EParameterName.SCHEMA_TYPE.getName());
// IElementParameter repositorySchemaTypeParameter = node.getElementParameter(propName).getParentParameter()
// .getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
// String schemaType = (String) schemaTypeParameter.getValue();
// bug 6028, Display the parameter of REPOSITORY_SCHEMA_TYPE
// if (schemaType != null && schemaType.equals(EmfComponent.REPOSITORY)) {
// repositorySchemaTypeParameter.setShow(true);
// if (newRepositoryIdValue != null) {
// oldRepositoryIdValue = (String) repositorySchemaTypeParameter.getValue();
// repositorySchemaTypeParameter.setValue(newRepositoryIdValue);
// }
// } else {
// repositorySchemaTypeParameter.setShow(false);
// }
// Xstream Cdc Type Mode
boolean isXstreamCdcTypeMode = false;
if (connection != null && connection instanceof DatabaseConnection) {
String cdcTypeMode = ((DatabaseConnection) connection).getCdcTypeMode();
if (CDCTypeMode.XSTREAM_MODE == CDCTypeMode.indexOf(cdcTypeMode)) {
isXstreamCdcTypeMode = true;
}
}
node.getElementParameter(EParameterName.UPDATE_COMPONENTS.getName()).setValue(true);
String componentName = node.getComponent().getName();
if (newOutputMetadata != null) {
Map<String, String> addMap = newOutputMetadata.getAdditionalProperties();
if (addMap.get(TaggedValueHelper.SYSTEMTABLENAME) != null && componentName.equals("tAS400CDC")) {
//$NON-NLS-1$
setDBTableFieldValue(node, addMap.get(TaggedValueHelper.SYSTEMTABLENAME), oldOutputMetadata.getTableName());
} else if (isXstreamCdcTypeMode) {
IElementParameter elementParameter = node.getElementParameter(propName);
if (elementParameter != null) {
if (oracleCdcComponent[0].equals(componentName) || oracleCdcComponent[1].equals(componentName)) {
IElementParameter schemaTypeParam = elementParameter.getParentParameter().getChildParameters().get(EParameterName.SCHEMA_TYPE.getName());
IElementParameter schemaParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
if (schemaTypeParam != null) {
schemaTypeParam.setValue(EmfComponent.BUILTIN);
if (schemaParam != null && schemaParam.getValue() != null && schemaParam.getValue() instanceof IMetadataTable) {
newOutputMetadata.setListColumns((((IMetadataTable) schemaParam.getValue()).clone(true)).getListColumns());
}
if (oracleCdcComponent[1].equals(componentName)) {
newOutputMetadata.setListColumns(new ArrayList<IMetadataColumn>());
}
}
}
}
setDBTableFieldValue(node, newOutputMetadata.getTableName(), oldOutputMetadata.getTableName());
} else {
setDBTableFieldValue(node, newOutputMetadata.getTableName(), oldOutputMetadata.getTableName());
}
//$NON-NLS-1$
IElementParameter parameter = node.getElementParameter("SAP_FUNCTION");
if (parameter != null) {
setSAPFunctionName(node, parameter.getValue() == null ? null : (String) parameter.getValue());
}
if (newPropValue instanceof String) {
if (orginalTable != null && orginalTable instanceof SAPBWTable) {
String innerIOType = ((SAPBWTable) orginalTable).getInnerIOType();
String sourceSysName = ((SAPBWTable) orginalTable).getSourceSystemName();
IElementParameter schemaTypeParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
IMetadataTable metadataTable = null;
if (schemaTypeParam != null) {
metadataTable = node.getMetadataFromConnector(schemaTypeParam.getContext());
}
if (metadataTable != null) {
if (innerIOType != null) {
//$NON-NLS-1$
IElementParameter param = node.getElementParameter("INFO_OBJECT_TYPE");
if (param != null) {
param.setValue(innerIOType);
metadataTable.getAdditionalProperties().put(SAPBWTableHelper.SAP_INFOOBJECT_INNER_TYPE, innerIOType);
}
}
if (sourceSysName != null) {
//$NON-NLS-1$
IElementParameter param = node.getElementParameter("SOURCE_SYSTEM_NAME");
if (param != null) {
param.setValue(TalendTextUtils.addQuotes(sourceSysName));
metadataTable.getAdditionalProperties().put(SAPBWTableHelper.SAP_DATASOURCE_SOURCESYSNAME, sourceSysName);
}
}
}
}
}
setTableRelevantParameterValues();
if (getConnection() != null) {
// for salesforce
IElementParameter param = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
if (param != null && EmfComponent.REPOSITORY.equals(param.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).getValue())) {
IElementParameter module = node.getElementParameter("module.moduleName");
if (module != null) {
String repositoryValue = module.getRepositoryValue();
if (repositoryValue == null) {
List<ComponentProperties> componentProperties = null;
IGenericWizardService wizardService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
}
if (wizardService != null && wizardService.isGenericConnection(getConnection())) {
componentProperties = wizardService.getAllComponentProperties(getConnection(), null);
}
repositoryValue = String.valueOf(RepositoryToComponentProperty.getGenericRepositoryValue(getConnection(), componentProperties, module.getName()));
}
if (repositoryValue != null) {
Object objectValue = RepositoryToComponentProperty.getValue(getConnection(), repositoryValue, newOutputMetadata, node.getComponent().getName());
if (objectValue != null) {
module.setValue(objectValue);
}
}
}
}
}
}
super.setConnection(connection);
super.execute();
String propertyType = (String) node.getPropertyValue(EParameterName.PROPERTY_TYPE.getName());
if (propertyType != null) {
if (propertyType.equals(EmfComponent.REPOSITORY)) {
String propertyValue = (String) node.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(propertyValue);
if (lastVersion == null) {
return;
}
Item item = lastVersion.getProperty().getItem();
if (item instanceof ConnectionItem) {
List<? extends IElementParameter> elementParameters = new ArrayList(node.getElementParameters());
for (IElementParameter param : elementParameters) {
if (param.getRepositoryValue() != null && !param.getRepositoryValue().equals("")) {
//$NON-NLS-1$
boolean isCustomSfConn = false;
if (item instanceof SalesforceSchemaConnectionItem) {
SalesforceSchemaConnection sfConn = (SalesforceSchemaConnection) ((SalesforceSchemaConnectionItem) item).getConnection();
isCustomSfConn = sfConn.isUseCustomModuleName();
}
if (//$NON-NLS-1$
param.getRepositoryValue().equals("TYPE") || (param.getRepositoryValue().equals("MODULENAME") && item instanceof SalesforceSchemaConnectionItem && !isCustomSfConn)) {
//$NON-NLS-1$
continue;
}
if (param.getFieldType().equals(EParameterFieldType.TABLE) && param.getRepositoryValue().equals("XML_MAPPING")) {
//$NON-NLS-1$
List<Map<String, Object>> table = (List<Map<String, Object>>) node.getPropertyValue(param.getName());
IMetadataTable metaTable = node.getMetadataList().get(0);
RepositoryToComponentProperty.getTableXmlFileValue(((ConnectionItem) item).getConnection(), //$NON-NLS-1$
"XML_MAPPING", //$NON-NLS-1$
param, table, newOutputMetadata);
param.setRepositoryValueUsed(true);
} else {
if (connection != null && (xmlComponent[0].equals(componentName) || xmlComponent[1].equals(componentName) || xmlComponent[2].equals(componentName)) && connection instanceof XmlFileConnection && XmlUtil.isXSDFile(TalendQuoteUtils.removeQuotes(((XmlFileConnection) connection).getXmlFilePath())) && param.getRepositoryValue().equals("FILE_PATH")) {
// do nothing
} else {
Object value = RepositoryToComponentProperty.getValue(((ConnectionItem) item).getConnection(), param.getRepositoryValue(), newOutputMetadata);
if (value != null) {
param.setValue(value);
}
}
}
}
}
}
}
}
node.setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE);
}
Aggregations