use of org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository 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.designer.core.ui.editor.cmd.ChangeValuesFromRepository 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.designer.core.ui.editor.cmd.ChangeValuesFromRepository in project tdi-studio-se by Talend.
the class ComponentChooseDialog method createRefreshingPropertiesCommand.
/**
* DOC bqian Comment method "createRefreshingPropertiesCommand".
*
* @param selectedNode
* @param node
*/
private List<Command> createRefreshingPropertiesCommand(CompoundCommand cc, RepositoryNode selectedNode, Node node) {
// List<Command> list = new ArrayList<Command>();
if (selectedNode.getObject().getProperty().getItem() instanceof ConnectionItem) {
String propertyId = selectedNode.getObject().getProperty().getId();
ConnectionItem originalConnectionItem = (ConnectionItem) selectedNode.getObject().getProperty().getItem();
ConnectionItem connectionItem = originalConnectionItem;
Connection originalConnection = connectionItem.getConnection();
Connection connection = connectionItem.getConnection();
// if component is CDC, replace by the CDC connection.
if (node.getComponent().getName().contains("CDC")) {
// to replace by a flag CDC in component? //$NON-NLS-1$
if (selectedNode.getObject().getProperty().getItem() instanceof DatabaseConnectionItem) {
final DatabaseConnection databaseConnection = (DatabaseConnection) connection;
CDCConnection cdcConn = databaseConnection.getCdcConns();
if (cdcConn != null) {
EList cdcTypes = cdcConn.getCdcTypes();
if (cdcTypes != null && !cdcTypes.isEmpty()) {
CDCType cdcType = (CDCType) cdcTypes.get(0);
// replace property by CDC property.
propertyId = cdcType.getLinkDB();
try {
IRepositoryViewObject object = ProxyRepositoryFactory.getInstance().getLastVersion(propertyId);
if (object != null) {
if (object.getProperty().getItem() instanceof DatabaseConnectionItem) {
DatabaseConnectionItem dbConnItem = (DatabaseConnectionItem) object.getProperty().getItem();
// replace connection by CDC connection
connectionItem = dbConnItem;
connection = dbConnItem.getConnection();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// set cdc type mode.
IElementParameter logModeParam = node.getElementParameter(EParameterName.CDC_TYPE_MODE.getName());
if (logModeParam != null) {
String cdcTypeMode = ((DatabaseConnection) originalConnection).getCdcTypeMode();
Command logModeCmd = new PropertyChangeCommand(node, EParameterName.CDC_TYPE_MODE.getName(), CDCTypeMode.LOG_MODE.getName().equals(cdcTypeMode));
cc.add(logModeCmd);
}
// set lib for as400 so far.
//$NON-NLS-1$
final String name = "SOURCE_LIB";
IElementParameter libParam = node.getElementParameter(name);
if (libParam != null) {
Object propValue;
if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(databaseConnection.getSID())) {
propValue = databaseConnection.getSID();
} else {
propValue = TalendTextUtils.addQuotes(databaseConnection.getSID());
}
Command libSettingCmd = new PropertyChangeCommand(node, name, propValue);
cc.add(libSettingCmd);
}
}
}
}
}
// fore EBCDIC, by cli
if ((connectionItem instanceof EbcdicConnectionItem) && PluginChecker.isEBCDICPluginLoaded()) {
// TDI-20505:integration the drag/drop for EBCDIC connection and EBCDIC metadataTable
IRepositoryViewObject object = selectedNode.getObject();
if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_EBCDIC) {
for (MetadataTable table : ConnectionHelper.getTables(originalConnection)) {
Command ebcdicCmd = new RepositoryChangeMetadataForEBCDICCommand(node, IEbcdicConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
cc.add(ebcdicCmd);
}
}
if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE) {
MetadataTable table = null;
if (object instanceof MetadataTableRepositoryObject) {
table = ((MetadataTableRepositoryObject) object).getTable();
}
Command ebcdicCmd = new RepositoryChangeMetadataForEBCDICCommand(node, IEbcdicConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
cc.add(ebcdicCmd);
}
}
// fore HL7, by gcui
if ((selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded()) || (selectedNode.getParent() != null && selectedNode.getParent().getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded())) {
if (originalConnection instanceof HL7ConnectionImpl) {
if (((HL7ConnectionImpl) originalConnection).getRoot() != null) {
List<Map<String, String>> mapList = new ArrayList<Map<String, String>>();
for (Object obj : ((HL7ConnectionImpl) originalConnection).getRoot()) {
if (obj instanceof HL7FileNode) {
Map<String, String> newMap = new HashMap<String, String>();
newMap.put(IHL7Constant.ATTRIBUTE, ((HL7FileNode) obj).getAttribute());
newMap.put(IHL7Constant.PATH, ((HL7FileNode) obj).getFilePath());
newMap.put(IHL7Constant.COLUMN, ((HL7FileNode) obj).getRelatedColumn());
newMap.put(IHL7Constant.ORDER, String.valueOf(((HL7FileNode) obj).getOrder()));
newMap.put(IHL7Constant.VALUE, ((HL7FileNode) obj).getDefaultValue());
newMap.put(IHL7Constant.REPEATABLE, String.valueOf(((HL7FileNode) obj).isRepeatable()));
mapList.add(newMap);
}
}
IExternalNode externalNode = ExternalUtilities.getExternalNodeReadyToOpen(node);
if (externalNode != null && externalNode.getElementParameter("ROOT") != null) {
//$NON-NLS-1$
//$NON-NLS-1$
externalNode.getElementParameter("ROOT").setValue(mapList);
}
String fileName = ((HL7ConnectionImpl) originalConnection).getOutputFilePath();
if (externalNode != null && externalNode.getElementParameter("FILENAME") != null && fileName != null) {
//$NON-NLS-1$
//$NON-NLS-1$
externalNode.getElementParameter("FILENAME").setValue(TalendTextUtils.addQuotes(fileName));
}
}
}
// fore HL7, by gcui
if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded()) {
for (MetadataTable table : ConnectionHelper.getTablesWithOrders(originalConnection)) {
Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(node, IHL7Constant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
cc.add(hl7Cmd);
}
}
}
// for brms
if ((selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_BRMS && PluginChecker.isBRMSPluginLoaded()) || (selectedNode.getParent() != null && selectedNode.getParent().getObjectType() == ERepositoryObjectType.METADATA_FILE_BRMS && PluginChecker.isBRMSPluginLoaded())) {
if (originalConnection instanceof BRMSConnectionImpl) {
if (((BRMSConnectionImpl) originalConnection).getRoot() != null) {
List<Map<String, String>> rootList = new ArrayList<Map<String, String>>();
List<Map<String, String>> loopList = new ArrayList<Map<String, String>>();
List<Map<String, String>> groupList = new ArrayList<Map<String, String>>();
for (Object obj : ((BRMSConnectionImpl) originalConnection).getRoot()) {
if (obj instanceof XMLFileNode) {
Map<String, String> rootMap = new HashMap<String, String>();
//$NON-NLS-1$
rootMap.put("ATTRIBUTE", ((XMLFileNode) obj).getAttribute());
//$NON-NLS-1$
rootMap.put("PATH", ((XMLFileNode) obj).getXMLPath());
//$NON-NLS-1$
rootMap.put("COLUMN", ((XMLFileNode) obj).getRelatedColumn());
//$NON-NLS-1$
rootMap.put("ORDER", String.valueOf(((XMLFileNode) obj).getOrder()));
//$NON-NLS-1$
rootMap.put("VALUE", ((XMLFileNode) obj).getDefaultValue());
rootList.add(rootMap);
}
}
for (Object obj : ((BRMSConnectionImpl) originalConnection).getLoop()) {
if (obj instanceof XMLFileNode) {
Map<String, String> loopMap = new HashMap<String, String>();
//$NON-NLS-1$
loopMap.put("ATTRIBUTE", ((XMLFileNode) obj).getAttribute());
//$NON-NLS-1$
loopMap.put("PATH", ((XMLFileNode) obj).getXMLPath());
//$NON-NLS-1$
loopMap.put("COLUMN", ((XMLFileNode) obj).getRelatedColumn());
//$NON-NLS-1$
loopMap.put("ORDER", String.valueOf(((XMLFileNode) obj).getOrder()));
//$NON-NLS-1$
loopMap.put("VALUE", ((XMLFileNode) obj).getDefaultValue());
loopList.add(loopMap);
}
}
for (Object obj : ((BRMSConnectionImpl) originalConnection).getGroup()) {
if (obj instanceof XMLFileNode) {
Map<String, String> groupMap = new HashMap<String, String>();
//$NON-NLS-1$
groupMap.put("ATTRIBUTE", ((XMLFileNode) obj).getAttribute());
//$NON-NLS-1$
groupMap.put("PATH", ((XMLFileNode) obj).getXMLPath());
//$NON-NLS-1$
groupMap.put("COLUMN", ((XMLFileNode) obj).getRelatedColumn());
//$NON-NLS-1$
groupMap.put("ORDER", String.valueOf(((XMLFileNode) obj).getOrder()));
//$NON-NLS-1$
groupMap.put("VALUE", ((XMLFileNode) obj).getDefaultValue());
groupList.add(groupMap);
}
}
IExternalNode externalNode = ExternalUtilities.getExternalNodeReadyToOpen(node);
if (externalNode != null && externalNode.getElementParameter("ROOT") != null) {
//$NON-NLS-1$
//$NON-NLS-1$
externalNode.getElementParameter("ROOT").setValue(rootList);
}
if (externalNode != null && externalNode.getElementParameter("LOOP") != null) {
//$NON-NLS-1$
//$NON-NLS-1$
externalNode.getElementParameter("LOOP").setValue(loopList);
}
if (externalNode != null && externalNode.getElementParameter("GROUP") != null) {
//$NON-NLS-1$
//$NON-NLS-1$
externalNode.getElementParameter("GROUP").setValue(groupList);
}
}
}
}
IElementParameter propertyParam = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
if (propertyParam != null) {
propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
propertyParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).setValue(propertyId);
}
IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
Map<String, IMetadataTable> repositoryTableMap = new HashMap<String, IMetadataTable>();
if (!originalConnection.isReadOnly()) {
for (Object tableObj : ConnectionHelper.getTables(originalConnection)) {
org.talend.core.model.metadata.builder.connection.MetadataTable table;
table = (org.talend.core.model.metadata.builder.connection.MetadataTable) tableObj;
if (factory.getStatus(originalConnectionItem) != ERepositoryStatus.DELETED) {
if (!factory.isDeleted(table)) {
String value = table.getId();
IMetadataTable newTable = ConvertionHelper.convert(table);
repositoryTableMap.put(value, newTable);
}
}
}
}
// DesignerPlugin.getDefault().getProxyRepositoryFactory().getLastVersion("")
if (propertyParam != null) {
// command used to set property type
IMetadataTable metadataTable = null;
// && selectedNode.getObjectType() == ERepositoryObjectType.METADATA_CON_TABLE) {
if (selectedNode.getObject() instanceof IMetadataTable) {
metadataTable = (IMetadataTable) selectedNode.getObject();
if (metadataTable != null && repositoryTableMap.get(metadataTable.getId()) != null) {
metadataTable = repositoryTableMap.get(metadataTable.getId());
}
}
// }
ChangeValuesFromRepository command1 = new ChangeValuesFromRepository(node, connection, metadataTable, propertyParam.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), propertyId, //$NON-NLS-1$
true);
command1.setMaps(repositoryTableMap);
if (selectedNode.getProperties(EProperties.CONTENT_TYPE) != ERepositoryObjectType.METADATA_CON_QUERY) {
command1.setGuessQuery(true);
}
setSAPSpecailValueForCommand(selectedNode, command1);
// for salesForce module
SalesforceModuleRepositoryObject sfObject = null;
if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
sfObject = (SalesforceModuleRepositoryObject) selectedNode.getObject();
} else if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE) {
IRepositoryViewObject object = selectedNode.getParent().getObject();
if (object instanceof SalesforceModuleRepositoryObject) {
sfObject = (SalesforceModuleRepositoryObject) object;
}
}
if (sfObject != null) {
ModelElement modelElement = sfObject.getModelElement();
if (modelElement instanceof SalesforceModuleUnit) {
command1.setSalesForceModuleUnit((SalesforceModuleUnit) modelElement);
}
}
cc.add(command1);
}
// command used to set metadata
getChangeMetadataCommand(cc, selectedNode, node, originalConnectionItem);
// command used to set query
if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_QUERY) {
IElementParameter queryParam = node.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE);
QueryRepositoryObject object = (QueryRepositoryObject) selectedNode.getObject();
Query query = object.getQuery();
//$NON-NLS-1$
String value = originalConnectionItem.getProperty().getId() + " - " + query.getLabel();
if (queryParam != null) {
RepositoryChangeQueryCommand command3 = new RepositoryChangeQueryCommand(node, query, queryParam.getName() + ":" + EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName(), //$NON-NLS-1$
value);
cc.add(command3);
}
} else {
if (connection instanceof DatabaseConnection && hasQuery(node)) {
DatabaseConnection connection2 = (DatabaseConnection) connection;
String schema = connection2.getUiSchema();
String dbType = connection2.getDatabaseType();
QueryGuessCommand queryGuessCommand = null;
if (node.getMetadataList().size() == 0) {
queryGuessCommand = new QueryGuessCommand(node, null, schema, dbType);
} else {
// modified by hyWang for bug 7190
queryGuessCommand = new QueryGuessCommand(node, node.getMetadataList().get(0), schema, dbType, connection);
}
if (queryGuessCommand != null) {
cc.add(queryGuessCommand);
}
}
}
// context, moved to ChangeValuesFromRepository(bug 5198)
// ConnectionContextHelper.addContextForNodeParameter(node, connectionItem);
} else if (selectedNode.getObject().getProperty().getItem() instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) selectedNode.getObject().getProperty().getItem();
// command used to set job
String value = processItem.getProperty().getId();
PropertyChangeCommand command4 = new PropertyChangeCommand(node, EParameterName.PROCESS_TYPE_PROCESS.getName(), value);
cc.add(command4);
PropertyChangeCommand command5 = new PropertyChangeCommand(node, EParameterName.PROCESS_TYPE_CONTEXT.getName(), processItem.getProcess().getDefaultContext());
cc.add(command5);
} else if (selectedNode.getObject().getProperty().getItem() instanceof FileItem) {
// hywang add for 6484
if (selectedNode.getObject().getProperty().getItem() instanceof RulesItem) {
RulesItem rulesItem = (RulesItem) selectedNode.getObject().getProperty().getItem();
// String displayName = "Rules:" + rulesItem.getProperty().getLabel(); //$NON-NLS-N$
IElementParameter propertyParam = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
if (propertyParam != null) {
propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
// propertyParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName())
// .setListItemsDisplayName(new String[] { displayName });
final String showId = rulesItem.getProperty().getId();
PropertyChangeCommand command6 = new PropertyChangeCommand(node, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
cc.add(command6);
}
}
} else if (selectedNode.getObject().getProperty().getItem() instanceof LinkRulesItem) {
LinkRulesItem linkItem = (LinkRulesItem) selectedNode.getObject().getProperty().getItem();
IElementParameter propertyParam = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
if (propertyParam != null) {
propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
// propertyParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName())
// .setListItemsDisplayName(new String[] { displayName });
final String showId = linkItem.getProperty().getId();
PropertyChangeCommand command7 = new PropertyChangeCommand(node, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
cc.add(command7);
}
}
return null;
}
use of org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository 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.designer.core.ui.editor.cmd.ChangeValuesFromRepository in project tdi-studio-se by Talend.
the class ProjectSettingMultipleThreadDynamicComposite method updateConnectionFromRepository.
private void updateConnectionFromRepository() {
if (repositoryPropertyName == null || repositoryPropertyName.split(":").length != 2 || connectionUpdated) {
return;
}
String[] split = repositoryPropertyName.split(":");
String parentParamName = split[0];
Element elementParams = elem;
IElementParameter elementParameter = elementParams.getElementParameter(parentParamName);
if (elementParameter != null && elementParameter.isShow(elem.getElementParameters()) && elementParameter.getChildParameters() != null) {
if (elementParameter.getChildParameters().get("PROPERTY_TYPE") != null && !EmfComponent.BUILTIN.equals(elementParameter.getChildParameters().get("PROPERTY_TYPE").getValue())) {
DatabaseConnection connection = null;
String id = (String) elementParameter.getChildParameters().get("REPOSITORY_PROPERTY_TYPE").getValue();
// bug 0018192
String propertyType = (String) elementParameter.getChildParameters().get("PROPERTY_TYPE").getValue();
ProxyRepositoryFactory proxyRepositoryFactory = ProxyRepositoryFactory.getInstance();
IRepositoryViewObject lastVersion = null;
if (null != id && !"".equals(id)) {
try {
lastVersion = proxyRepositoryFactory.getLastVersion(id);
if (null == lastVersion && propertyType.equals(EmfComponent.REPOSITORY)) {
List<ConnectionItem> connectionItems = proxyRepositoryFactory.getMetadataConnectionsItem();
if (connectionItems.isEmpty()) {
elem.setPropertyValue("REPOSITORY_PROPERTY_TYPE", "");
ChangeValuesFromRepository changeValuesFromRepository1 = new ChangeValuesFromRepository(elem, null, parentParamName + ":" + "PROPERTY_TYPE", EmfComponent.REPOSITORY);
changeValuesFromRepository1.execute();
}
for (ConnectionItem cItem : connectionItems) {
if (cItem instanceof DatabaseConnectionItem) {
id = cItem.getProperty().getId();
lastVersion = proxyRepositoryFactory.getLastVersion(id);
elem.setPropertyValue("REPOSITORY_PROPERTY_TYPE", id);
break;
}
}
}
} catch (PersistenceException e) {
e.printStackTrace();
}
} else {
try {
List<ConnectionItem> connectionItems = proxyRepositoryFactory.getMetadataConnectionsItem();
for (ConnectionItem cItem : connectionItems) {
if (cItem instanceof DatabaseConnectionItem) {
lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(cItem.getProperty().getId());
id = cItem.getProperty().getId();
lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(id);
elem.setPropertyValue("REPOSITORY_PROPERTY_TYPE", id);
break;
}
}
} catch (PersistenceException e) {
e.printStackTrace();
}
}
if (lastVersion != null && lastVersion.getProperty() != null) {
Item item = lastVersion.getProperty().getItem();
if (item instanceof DatabaseConnectionItem) {
DatabaseConnectionItem dbItem = (DatabaseConnectionItem) item;
connection = (DatabaseConnection) dbItem.getConnection();
}
}
if (connection != null) {
boolean sameValues = true;
for (IElementParameter param : elementParams.getElementParameters()) {
String repositoryValue = param.getRepositoryValue();
if (param.isShow(elementParams.getElementParameters()) && repositoryValue != null && !param.getName().equals("PROPERTY_TYPE")) {
Object repValue = RepositoryToComponentProperty.getValue(connection, repositoryValue, null);
if (repValue == null) {
continue;
}
if (repositoryValue.equals(UpdatesConstants.TYPE)) {
// datebase type
boolean found = false;
String[] list = param.getListRepositoryItems();
for (int i = 0; (i < list.length) && (!found); i++) {
if (repValue.equals(list[i])) {
found = true;
}
}
if (!found) {
sameValues = false;
break;
}
} else {
// check the value
if (!param.getValue().equals(repValue)) {
sameValues = false;
break;
}
}
}
}
if (!sameValues) {
ChangeValuesFromRepository changeValuesFromRepository = new ChangeValuesFromRepository(elem, connection, repositoryPropertyName, id);
changeValuesFromRepository.execute();
connectionUpdated = true;
}
}
// bug 0018192
// else {
// change to build in
// ChangeValuesFromRepository changeValuesFromRepository1 = new ChangeValuesFromRepository(elem,
// null,
// parentParamName + ":" + "PROPERTY_TYPE", EmfComponent.BUILTIN);
// changeValuesFromRepository1.execute();
// }
}
}
}
Aggregations