use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class DynamicTabbedPropertySection method updateRepositoryList.
/**
* ftang Comment method "updateRepositoryList".
*/
@SuppressWarnings("unchecked")
public void updateRepositoryList() {
IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
tableIdAndDbTypeMap = new HashMap<String, String>();
tableIdAndDbSchemaMap = new HashMap<String, String>();
List<ConnectionItem> metadataConnectionsItem = null;
String[] repositoryTableNameList = new String[] {};
String[] repositoryTableValueList = new String[] {};
String[] repositoryConnectionNameList = new String[] {};
String[] repositoryConnectionValueList = new String[] {};
String[] repositoryQueryNameList = new String[] {};
String[] repositoryQueryValueList = new String[] {};
try {
metadataConnectionsItem = factory.getMetadataConnectionsItem();
} catch (PersistenceException e) {
throw new RuntimeException(e);
}
if (metadataConnectionsItem != null) {
repositoryTableMap.clear();
repositoryQueryStoreMap.clear();
repositoryConnectionItemMap.clear();
tablesMap.clear();
queriesMap.clear();
List<String> tableNamesList = new ArrayList<String>();
List<String> tableValuesList = new ArrayList<String>();
List<String> queryStoreNameList = new ArrayList<String>();
List<String> queryStoreValuesList = new ArrayList<String>();
for (ConnectionItem connectionItem : metadataConnectionsItem) {
Connection connection = connectionItem.getConnection();
if (!connection.isReadOnly()) {
//$NON-NLS-1$
repositoryConnectionItemMap.put(connectionItem.getProperty().getId() + "", connectionItem);
for (Object tableObj : ConnectionHelper.getTables(connection)) {
org.talend.core.model.metadata.builder.connection.MetadataTable table;
table = (org.talend.core.model.metadata.builder.connection.MetadataTable) tableObj;
if (factory.getStatus(connectionItem) != ERepositoryStatus.DELETED) {
if (!factory.isDeleted(table)) {
String name = //$NON-NLS-1$
getRepositoryAliasName(connectionItem) + ":" + connectionItem.getProperty().getLabel() + " - " + //$NON-NLS-1$
table.getLabel();
//$NON-NLS-1$
String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
IMetadataTable newTable = ConvertionHelper.convert(table);
repositoryTableMap.put(value, newTable);
if (connection instanceof DatabaseConnection) {
String dbType = ((DatabaseConnection) connection).getDatabaseType();
String schema = ((DatabaseConnection) connection).getUiSchema();
tableIdAndDbTypeMap.put(newTable.getId(), dbType);
if (schema != null && !schema.equals("")) {
//$NON-NLS-1$
tableIdAndDbSchemaMap.put(newTable.getId(), schema);
}
}
addOrderDisplayNames(tableValuesList, tableNamesList, value, name);
// tableNamesList.add(name);
// tableValuesList.add(value);
}
}
}
}
tablesMap.put(connectionItem.getProperty().getId(), tableValuesList);
if (connection instanceof DatabaseConnection && !connection.isReadOnly()) {
DatabaseConnection dbConnection = (DatabaseConnection) connection;
QueriesConnection queriesConnection = dbConnection.getQueries();
if (queriesConnection != null) {
List<Query> qs = queriesConnection.getQuery();
for (Query query : qs) {
String name = //$NON-NLS-1$
getRepositoryAliasName(connectionItem) + ":" + connectionItem.getProperty().getLabel() + " - " + //$NON-NLS-1$
query.getLabel();
//$NON-NLS-1$
String value = connectionItem.getProperty().getId() + " - " + query.getLabel();
repositoryQueryStoreMap.put(value, query);
addOrderDisplayNames(queryStoreValuesList, queryStoreNameList, value, name);
// queryStoreNameList.add(name);
// queryStoreValuesList.add(value);
}
}
}
queriesMap.put(connectionItem.getProperty().getId(), queryStoreValuesList);
}
repositoryTableNameList = tableNamesList.toArray(new String[0]);
repositoryTableValueList = tableValuesList.toArray(new String[0]);
repositoryQueryNameList = queryStoreNameList.toArray(new String[0]);
repositoryQueryValueList = queryStoreValuesList.toArray(new String[0]);
}
initMaps();
for (int i = 0; i < elem.getElementParameters().size(); i++) {
IElementParameter param = elem.getElementParameters().get(i);
if (param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || param.getFieldType().equals(EParameterFieldType.SCHEMA_REFERENCE)) {
IElementParameter repositorySchemaType = param.getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
repositorySchemaType.setListItemsDisplayName(repositoryTableNameList);
repositorySchemaType.setListItemsValue(repositoryTableValueList);
if (!repositoryTableMap.keySet().contains(repositorySchemaType.getValue())) {
List<String> list2 = tablesMap.get(elem.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()));
boolean isNeeded = list2 != null && !list2.isEmpty();
if (repositoryTableNameList.length > 0 && repositoryConnectionValueList.length > 0 && isNeeded) {
repositorySchemaType.setValue(getDefaultRepository(param, true, repositoryConnectionValueList[0]));
// elem.setPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName(),
// getDefaultRepository(
// true, repositoryConnectionValueList[0]));
}
}
}
if (param.getName().equals(EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName())) {
param.setListItemsDisplayName(repositoryQueryNameList);
param.setListItemsValue(repositoryQueryValueList);
if (!repositoryQueryStoreMap.keySet().contains(param.getValue())) {
List<String> list2 = queriesMap.get(elem.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()));
boolean isNeeded = list2 != null && !list2.isEmpty();
if (repositoryQueryNameList.length > 0 && repositoryConnectionValueList.length > 0 && isNeeded) {
elem.setPropertyValue(EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName(), getDefaultRepository(elem.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE), false, repositoryConnectionValueList[0]));
}
}
}
if (param.getName().equals(EParameterName.REPOSITORY_PROPERTY_TYPE.getName())) {
updateRepositoryListExtra(param, repositoryConnectionNameList, repositoryConnectionValueList, false);
}
// // for job settings extra (feature 2710)
// if (param.getName().equals(extraRepositoryPropertyTypeName)) {
// updateRepositoryListExtra(param, repositoryConnectionNameList, repositoryConnectionValueList, true);
// }
}
updateQuery();
}
use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class AS400CheckController method refresh.
@Override
public void refresh(IElementParameter param, boolean check) {
// TODO Auto-generated method stub
Button checkBtn = (Button) hashCurControls.get(param.getName());
if (checkBtn == null || checkBtn.isDisposed()) {
return;
}
String propertyType = (String) elem.getPropertyValue(EParameterName.PROPERTY_TYPE.getName());
if (propertyType.equals(EmfComponent.REPOSITORY)) {
IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
List<ConnectionItem> metadataConnectionsItem = null;
try {
metadataConnectionsItem = factory.getMetadataConnectionsItem();
} catch (PersistenceException e) {
throw new RuntimeException(e);
}
if (metadataConnectionsItem != null) {
for (ConnectionItem connectionItem : metadataConnectionsItem) {
//$NON-NLS-1$
String value = connectionItem.getProperty().getId() + "";
if (value.equals(elem.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()))) {
boolean b = getConnection(connectionItem).isStandardSQL();
checkBtn.setSelection(b);
if (b) {
param.setValue(Boolean.TRUE);
} else {
param.setValue(Boolean.FALSE);
}
}
}
}
} else {
boolean b = CoreUIPlugin.getDefault().getPreferenceStore().getBoolean(ITalendCorePrefConstants.AS400_SQL_SEG);
checkBtn.setSelection(b);
if (b) {
param.setValue(Boolean.TRUE);
} else {
param.setValue(Boolean.FALSE);
}
}
}
use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class StatsAndLogsHelper method changeRepositoryConnection.
static void changeRepositoryConnection(Element process, StatsAndLogsComposite statsComposite) {
String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName());
String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
Connection repositoryConnection = null;
/* 16969 */
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
} else {
repositoryConnection = null;
}
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
}
use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class ProjectSettingManager method changeImplicitContextRepositoryItem.
static void changeImplicitContextRepositoryItem(Element process, ExtraComposite extraComposite) {
// change repository item
String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()));
String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
Connection repositoryConnection = null;
/* 16969 */
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
} else {
repositoryConnection = null;
}
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
}
use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class DetectContextVarsUtils method detectByPropertyType.
/**
*
* ggu Comment method "detectByPropertyType".
*
* type is the EParameterFieldType.PROPERTY_TYPE
*/
public static Map<String, Set<String>> detectByPropertyType(Element element, boolean show) {
Map<String, Set<String>> varsMap = new HashMap<String, Set<String>>();
// PTODO
List<IElementParameter> elementParameters = element.getElementParametersFromField(EParameterFieldType.PROPERTY_TYPE);
if (elementParameters != null) {
for (IElementParameter ptParam : elementParameters) {
IElementParameter rParam = ptParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
IElementParameter idParam = ptParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
if (rParam != null && idParam != null && EmfComponent.REPOSITORY.equals(rParam.getValue())) {
String id = (String) idParam.getValue();
ConnectionItem connItem = UpdateRepositoryUtils.getConnectionItemByItemId(id);
if (connItem != null) {
ConnectionContextHelper.checkContextMode(connItem);
Connection connection = connItem.getConnection();
if (connection.isContextMode() && (!show || (show && ptParam.isShow(element.getElementParameters())))) {
Set<String> neededVars = ConnectionContextHelper.retrieveContextVar(element.getElementParameters(), connection, null);
if (neededVars != null && !neededVars.isEmpty()) {
Set<String> varsSet = varsMap.get(id);
if (varsSet == null) {
varsMap.put(id, neededVars);
} else {
varsSet.addAll(neededVars);
}
}
}
}
}
}
}
return varsMap;
}
Aggregations