use of org.talend.core.model.metadata.builder.connection.Connection 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.Connection in project tdi-studio-se by Talend.
the class StatLogsAndImplicitcontextTreeViewPage method saveProcess.
private void saveProcess(RepositoryNode node, String paramName, Boolean isUseProjectSettings, boolean addContextModel, Map<String, Set<String>> contextVars, IProgressMonitor monitor) {
Property property = node.getObject().getProperty();
ProcessItem pItem = (ProcessItem) property.getItem();
ParametersType pType = pItem.getProcess().getParameters();
if (isOpenProcess(node)) {
Process process = getProcess(opendProcess, node);
LoadProjectSettingsCommand command = new LoadProjectSettingsCommand(process, paramName, isUseProjectSettings);
exeCommand(process, command);
Element elem = null;
String propertyName = "";
String propertyTypeName = "";
if (EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
elem = (Element) pro.getInitialContextLoad();
propertyName = JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()) + ':' + EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
propertyTypeName = JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()) + ':' + EParameterName.PROPERTY_TYPE.getName();
} else if (EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
elem = (Element) pro.getStatsAndLog();
propertyName = EParameterName.PROPERTY_TYPE.getName() + ':' + EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
propertyTypeName = EParameterName.PROPERTY_TYPE.getName() + ':' + EParameterName.PROPERTY_TYPE.getName();
}
IElementParameter ptParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
if (ptParam != null) {
IElementParameter propertyElem = ptParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
Object proValue = propertyElem.getValue();
if (proValue instanceof String && ((String) proValue).equalsIgnoreCase(EmfComponent.REPOSITORY)) {
IElementParameter repositoryElem = ptParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
String value = (String) repositoryElem.getValue();
ConnectionItem connectionItem = UpdateRepositoryUtils.getConnectionItemByItemId(value);
if (connectionItem != null) {
Connection connection = connectionItem.getConnection();
ChangeValuesFromRepository cmd = new ChangeValuesFromRepository(process, connection, addContextModel ? propertyName : propertyTypeName, value);
cmd.ignoreContextMode(true);
exeCommand(process, cmd);
}
}
}
monitor.worked(100);
} else {
ElementParameter2ParameterType.setParameterValue(pType, paramName, isUseProjectSettings);
if (isUseProjectSettings) {
if (EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
ProjectSettingManager.reloadImplicitValuesFromProjectSettings(pType, ProjectManager.getInstance().getCurrentProject());
} else if (EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
ProjectSettingManager.reloadStatsAndLogFromProjectSettings(pType, ProjectManager.getInstance().getCurrentProject());
}
}
if (addContextModel && contextVars != null && !contextVars.isEmpty() && ContextUtils.getAllContextItem() != null) {
ContextUtils.addInContextModelForProcessItem(pItem, contextVars, ContextUtils.getAllContextItem());
}
try {
factory.save(pItem);
monitor.worked(100);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class GenericDragAndDropHandler method isValid.
private boolean isValid(RepositoryNode seletetedNode, IComponent component) {
// TUP-4151
IRepositoryViewObject object = seletetedNode.getObject();
if (component == null || object == null) {
return false;
}
ComponentProperties currentComponentProperties = null;
if (object instanceof RepositoryViewObject) {
RepositoryViewObject repositoryViewObj = (RepositoryViewObject) object;
Connection connection = ((ConnectionItem) repositoryViewObj.getProperty().getItem()).getConnection();
if (canHandle(connection)) {
GenericConnection genericConnection = (GenericConnection) connection;
currentComponentProperties = ComponentsUtils.getComponentPropertiesFromSerialized(genericConnection.getCompProperties(), connection);
}
} else if (object instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject metaTableRepObj = (MetadataTableRepositoryObject) object;
currentComponentProperties = SchemaUtils.getCurrentComponentProperties(metaTableRepObj);
} else if (object instanceof MetadataColumnRepositoryObject) {
MetadataColumnRepositoryObject metaColumnRepObj = (MetadataColumnRepositoryObject) object;
ModelElement element = metaColumnRepObj.getTdColumn();
if (element != null && element.eContainer() instanceof MetadataTable) {
MetadataTable metadataTable = (MetadataTable) element.eContainer();
IMetadataTable newTable = MetadataToolHelper.convert(metadataTable);
currentComponentProperties = SchemaUtils.getCurrentComponentProperties(newTable);
}
}
if (currentComponentProperties != null) {
try {
List<ComponentDefinition> possibleComponents = ComponentsUtils.getComponentService().getPossibleComponents(currentComponentProperties);
if (component instanceof Component) {
ComponentDefinition componentDefinition = ((Component) component).getComponentDefinition();
return possibleComponents.contains(componentDefinition);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
return false;
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class DynamicComposite method resetParameters.
public List<ElementParameter> resetParameters() {
final List<ElementParameter> newParameters = new ArrayList<>();
List<ElementParameter> currentParameters = (List<ElementParameter>) element.getElementParameters();
List<ElementParameter> parameters = new ArrayList<>();
ComponentService componentService = internalService.getComponentService();
Connection theConnection = null;
if (connectionItem != null) {
theConnection = connectionItem.getConnection();
}
Properties properties = null;
PropertyValueEvaluator evaluator = null;
if (element instanceof FakeElement) {
properties = form.getProperties();
evaluator = new MetadataContextPropertyValueEvaluator(theConnection);
currentParameters.clear();
} else {
properties = ((INode) element).getComponentProperties();
evaluator = new ComponentContextPropertyValueEvaluator((INode) element);
}
if (properties instanceof ComponentProperties) {
if (form != null) {
properties.setValueEvaluator(evaluator);
properties.refreshLayout(form);
}
// For context display.
properties.setValueEvaluator(null);
boolean isInitializing = false;
if (element instanceof INode) {
INode node = (INode) element;
IComponent component = node.getComponent();
if (component instanceof AbstractBasicComponent) {
isInitializing = ((AbstractBasicComponent) component).isInitializing();
}
}
parameters = ComponentsUtils.getParametersFromForm(element, isInitializing, section, (ComponentProperties) properties, form);
addUpdateParameterIfNotExist(parameters);
properties.setValueEvaluator(evaluator);
}
for (ElementParameter parameter : parameters) {
if (parameter instanceof GenericElementParameter) {
GenericElementParameter genericElementParameter = (GenericElementParameter) parameter;
genericElementParameter.setComponentService(componentService);
genericElementParameter.setDrivedByForm(drivedByForm);
genericElementParameter.callBeforePresent();
genericElementParameter.removePropertyChangeListener(this);
genericElementParameter.addPropertyChangeListener(this);
if (wizardPropertyChangeListener != null && IGenericConstants.NAME_PROPERTY.equals(parameter.getName())) {
genericElementParameter.addPropertyChangeListener(wizardPropertyChangeListener);
}
if (EParameterFieldType.SCHEMA_REFERENCE.equals(genericElementParameter.getFieldType())) {
if (genericElementParameter.getChildParameters().size() == 0) {
IElementParameter schemaParameter = element.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE, section);
genericElementParameter.getChildParameters().putAll(schemaParameter.getChildParameters());
}
} else if (EParameterFieldType.NAME_SELECTION_AREA.equals(genericElementParameter.getFieldType()) && theConnection != null) {
List<NamedThing> values = new ArrayList<>();
List<MetadataTable> metadataTables = SchemaUtils.getMetadataTables(theConnection, SubContainer.class);
List<String> tableLabels = new ArrayList<>();
for (MetadataTable metaTable : metadataTables) {
tableLabels.add(metaTable.getLabel());
}
List<NamedThing> possibleValues = ComponentsUtils.getFormalPossibleValues(genericElementParameter);
for (NamedThing possibleValue : possibleValues) {
if (tableLabels.contains(possibleValue.getName())) {
values.add(possibleValue);
}
}
genericElementParameter.setValue(values);
}
if (properties != null && isRepository(element)) {
String repositoryValue = genericElementParameter.getRepositoryValue();
if (genericElementParameter.isShow(currentParameters) && (repositoryValue != null) && (!genericElementParameter.getName().equals(EParameterName.PROPERTY_TYPE.getName())) && genericElementParameter.getCategory() == section) {
org.talend.daikon.properties.property.Property property = properties.getValuedProperty(genericElementParameter.getName());
if (property != null && property.getTaggedValue(IGenericConstants.REPOSITORY_VALUE) != null) {
genericElementParameter.setRepositoryValueUsed(true);
genericElementParameter.setReadOnly(true);
}
}
}
}
}
boolean added = false;
for (ElementParameter currentParameter : currentParameters) {
if (EParameterName.UPDATE_COMPONENTS.getName().equals(currentParameter.getName())) {
currentParameter.setValue(true);
}
if (currentParameter.isSerialized() && currentParameter.getCategory().equals(section)) {
if (!added) {
newParameters.addAll(parameters);
added = true;
}
continue;
}
newParameters.add(currentParameter);
}
if (element instanceof FakeElement) {
newParameters.addAll(reverseParameters(parameters));
}
element.setElementParameters(newParameters);
return newParameters;
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class GenericConnWizardPage method updateProperty.
private void updateProperty(String newPropertyName) {
if (connectionItem == null) {
return;
}
this.nameModifiedByUser = true;
evaluateTextField();
if (isValid(newPropertyName)) {
Connection connection = connectionItem.getConnection();
Property connectionProperty = connectionItem.getProperty();
String propertyName = StringUtils.trimToNull(newPropertyName);
connectionProperty.setDisplayName(propertyName);
connectionProperty.setLabel(propertyName);
connectionProperty.setModificationDate(new Date());
connectionProperty.setLabel(propertyName);
connection.setName(propertyName);
connection.setLabel(propertyName);
}
}
Aggregations