use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class StatsAndLogsViewHelper method reloadValuesFromPreferencePage.
/**
* ftang Comment method "reloadValuesFromPreferencePage".
*
* @param preferenceStore
* @param element
*/
public static void reloadValuesFromPreferencePage(Element element, IDynamicProperty propertyComposite) {
List<? extends IElementParameter> elementParameters = element.getElementParameters();
for (IElementParameter elementParameter : elementParameters) {
String name = elementParameter.getName();
if (name.equals(EParameterName.ON_STATCATCHER_FLAG.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.ON_STATCATCHER_FLAG.getName()));
continue;
}
if (name.equals(EParameterName.ON_LOGCATCHER_FLAG.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.ON_LOGCATCHER_FLAG.getName()));
continue;
}
if (name.equals(EParameterName.ON_METERCATCHER_FLAG.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.ON_METERCATCHER_FLAG.getName()));
continue;
}
if (name.equals(EParameterName.ON_FILES_FLAG.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.ON_FILES_FLAG.getName()));
continue;
}
if (name.equals(EParameterName.FILE_PATH.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.FILE_PATH.getName())));
continue;
}
if (name.equals(EParameterName.FILENAME_STATS.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.FILENAME_STATS.getName())));
continue;
}
if (name.equals(EParameterName.FILENAME_LOGS.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.FILENAME_LOGS.getName())));
continue;
}
if (name.equals(EParameterName.FILENAME_METTER.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.FILENAME_METTER.getName())));
continue;
}
if (name.equals(EParameterName.ON_DATABASE_FLAG.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.ON_DATABASE_FLAG.getName()));
continue;
}
if (name.equals(EParameterName.PROPERTY_TYPE.getName())) {
String propertyType = PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.PROPERTY_TYPE.getName());
String id = PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
/* 16969 */
Connection repositoryConnection = null;
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;
}
// Map<String, ConnectionItem> repositoryConnectionItemMap =
// propertyComposite.getRepositoryConnectionItemMap();
//
// if (repositoryConnectionItemMap.containsKey(id)) {
// repositoryConnection = repositoryConnectionItemMap.get(id).getConnection();
// } else {
// repositoryConnection = null;
// }
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(element, repositoryConnection, EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(element, repositoryConnection, EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) element).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);
}
}
continue;
}
if (PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.PROPERTY_TYPE.getName()).equals(EmfComponent.BUILTIN)) {
if (name.equals(EParameterName.DB_TYPE.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.DB_TYPE.getName()));
continue;
}
if (name.equals(EParameterName.HOST.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.HOST.getName())));
continue;
}
if (name.equals(EParameterName.PORT.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.PORT.getName())));
continue;
}
if (name.equals(EParameterName.DBNAME.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.DBNAME.getName())));
continue;
}
if (name.equals(EParameterName.PROPERTIES.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.PROPERTIES.getName())));
continue;
}
if (name.equals(EParameterName.DBFILE.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.DBFILE.getName())));
continue;
}
if (name.equals(EParameterName.SCHEMA_DB.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.SCHEMA_DB.getName())));
continue;
}
if (name.equals(EParameterName.USER.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.USER.getName())));
continue;
}
if (name.equals(EParameterName.PASS.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.PASS.getName())));
continue;
}
}
if (name.equals(EParameterName.TABLE_STATS.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.TABLE_STATS.getName())));
continue;
}
if (name.equals(EParameterName.TABLE_LOGS.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.TABLE_LOGS.getName())));
continue;
}
if (name.equals(EParameterName.TABLE_METER.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.TABLE_METER.getName())));
continue;
}
if (name.equals(EParameterName.CATCH_RUNTIME_ERRORS.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.CATCH_RUNTIME_ERRORS.getName()));
continue;
}
if (name.equals(EParameterName.CATCH_USER_ERRORS.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.CATCH_USER_ERRORS.getName()));
continue;
}
if (name.equals(EParameterName.CATCH_USER_WARNING.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.CATCH_USER_WARNING.getName()));
continue;
}
if (name.equals(EParameterName.CATCH_REALTIME_STATS.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.CATCH_REALTIME_STATS.getName()));
continue;
}
}
}
use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class SchemaUtils method getCurrentComponentProperties.
public static ComponentProperties getCurrentComponentProperties(IMetadataTable table) {
if (table != null) {
String serializedProperties = null;
SerializerDeserializer.Deserialized<ComponentProperties> fromSerializedProperties = null;
if (table instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject metaTableRepObj = (MetadataTableRepositoryObject) table;
MetadataTable metadataTable = metaTableRepObj.getTable();
if (metadataTable != null && metadataTable.getTaggedValue() != null) {
for (TaggedValue serializedProps : metadataTable.getTaggedValue()) {
if (IComponentConstants.COMPONENT_PROPERTIES_TAG.equals(serializedProps.getTag())) {
serializedProperties = serializedProps.getValue();
break;
}
}
}
if (serializedProperties != null) {
Connection connection = ((ConnectionItem) metaTableRepObj.getViewObject().getProperty().getItem()).getConnection();
return ComponentsUtils.getComponentPropertiesFromSerialized(serializedProperties, connection);
}
} else if (table instanceof org.talend.core.model.metadata.MetadataTable) {
org.talend.core.model.metadata.MetadataTable metaTable = (org.talend.core.model.metadata.MetadataTable) table;
Map<String, String> additionalProperties = metaTable.getAdditionalProperties();
serializedProperties = additionalProperties.get(IComponentConstants.COMPONENT_PROPERTIES_TAG);
if (serializedProperties != null) {
fromSerializedProperties = Properties.Helper.fromSerializedPersistent(serializedProperties, ComponentProperties.class, null);
}
}
if (fromSerializedProperties != null) {
return fromSerializedProperties.object;
}
}
return null;
}
use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class DynamicComposite method updateRepositoryList.
/**
* ftang Comment method "updateRepositoryList".
*/
//$NON-NLS-1$
@SuppressWarnings("unchecked")
private 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 = getConnectionItems();
} 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)) {
IElementParameter repositoryType = param.getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
repositoryType.setListItemsDisplayName(repositoryTableNameList);
repositoryType.setListItemsValue(repositoryTableValueList);
if (!repositoryTableMap.keySet().contains(repositoryType.getValue())) {
IElementParameter repositoryPropertyType = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE, param.getCategory());
if (repositoryPropertyType != null) {
List<String> list2 = tablesMap.get(repositoryPropertyType.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).getValue());
boolean isNeeded = list2 != null && !list2.isEmpty();
if (repositoryTableNameList.length > 0 && repositoryConnectionValueList.length > 0 && isNeeded) {
repositoryType.setValue(getDefaultRepository(param, true, repositoryConnectionValueList[0]));
}
}
}
}
if (param.getFieldType().equals(EParameterFieldType.QUERYSTORE_TYPE)) {
IElementParameter repositoryType = param.getChildParameters().get(EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName());
repositoryType.setListItemsDisplayName(repositoryQueryNameList);
repositoryType.setListItemsValue(repositoryQueryValueList);
if (!repositoryQueryStoreMap.keySet().contains(repositoryType.getValue())) {
IElementParameter repositoryPropertyType = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE, param.getCategory());
if (repositoryPropertyType != null) {
List<String> list2 = queriesMap.get(repositoryPropertyType.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).getValue());
boolean isNeeded = list2 != null && !list2.isEmpty();
if (repositoryQueryNameList.length > 0 && repositoryConnectionValueList.length > 0 && isNeeded) {
repositoryType.setValue(getDefaultRepository(elem.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE), false, repositoryConnectionValueList[0]));
}
}
}
}
if (param.getFieldType().equals(EParameterFieldType.PROPERTY_TYPE)) {
IElementParameter repositoryType = param.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
List<String> nameList = new ArrayList<String>();
List<String> valueList = new ArrayList<String>();
updateRepositoryListExtra(repositoryType, nameList, valueList, false);
repositoryConnectionNameList = nameList.toArray(new String[0]);
repositoryConnectionValueList = valueList.toArray(new String[0]);
}
}
}
use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class AbstractJobSettingsPage method saveProcess.
protected void saveProcess(IRepositoryViewObject object, boolean addContextModel, Map<String, Set<String>> contextVars, IProgressMonitor monitor) {
Property property = object.getProperty();
ProcessItem pItem = (ProcessItem) property.getItem();
if (isOpenProcess(object)) {
Process process = getProcess(openedProcessList, object);
LoadProjectSettingsCommand command = new LoadProjectSettingsCommand(process, getParameterName().getName(), Boolean.TRUE);
exeCommand(process, command);
//
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 ? getRepositoryPropertyName() : getPropertyTypeName(), value);
cmd.ignoreContextMode(true);
exeCommand(process, cmd);
}
}
}
monitor.worked(100);
} else {
try {
reloadFromProjectSetings(pItem, addContextModel, contextVars);
factory.save(pItem);
monitor.worked(100);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class ComponentChooseDialog method createProperty.
private void createProperty(Object dragModel, EditPart targetEditPart) {
if (!(dragModel instanceof RepositoryNode && targetEditPart instanceof NodeContainerPart)) {
return;
}
RepositoryNode dragNode = (RepositoryNode) dragModel;
NodeContainerPart nodePart = (NodeContainerPart) targetEditPart;
if (dragNode.getObject().getProperty().getItem() instanceof ConnectionItem) {
ConnectionItem connectionItem = (ConnectionItem) dragNode.getObject().getProperty().getItem();
Command command = getChangePropertyCommand(dragNode, (Node) nodePart.getNodePart().getModel(), connectionItem);
if (command != null) {
execCommandStack(command);
}
}
}
Aggregations