use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class AbstractSchemaController method createButtonCommand.
@Override
protected Command createButtonCommand(Button button) {
// see 0003766: Problems with the read only mode of the properties on repository mode.
if (checkForRepositoryShema(button)) {
return null;
}
Button inputButton = button;
IElementParameter switchParam = elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
if (inputButton.getData(NAME).equals(SCHEMA)) {
// this map wil hold the all input connection for the tUnite component
Map<INode, Map<IMetadataTable, Boolean>> inputInfos = new HashMap<INode, Map<IMetadataTable, Boolean>>();
INode node;
if (elem instanceof Node) {
node = (INode) elem;
} else {
// else instanceof Connection
node = ((IConnection) elem).getSource();
}
IMetadataTable inputMetadata = null, inputMetaCopy = null;
Connection inputConec = null;
String propertyName = (String) inputButton.getData(PARAMETER_NAME);
IElementParameter param = node.getElementParameter(propertyName);
IElementParameter connectionParam = param.getChildParameters().get(EParameterName.CONNECTION.getName());
String connectionName = null;
if (connectionParam != null) {
connectionName = (String) connectionParam.getValue();
}
Object obj = button.getData(FORCE_READ_ONLY);
boolean forceReadOnly = false;
if (obj != null) {
forceReadOnly = (Boolean) obj;
}
boolean inputReadOnly = false, outputReadOnly = false, inputReadOnlyNode = false, inputReadOnlyParam = false;
for (Connection connec : (List<Connection>) node.getIncomingConnections()) {
if (connec.isActivate() && (connec.getLineStyle().equals(EConnectionType.FLOW_MAIN) || connec.getLineStyle().equals(EConnectionType.TABLE) || connec.getLineStyle().equals(EConnectionType.FLOW_MERGE) || connec.getLineStyle() == EConnectionType.FLOW_REF)) {
if (connectionName != null && !connec.getName().equals(connectionName)) {
continue;
}
inputMetadata = connec.getMetadataTable();
inputMetaCopy = inputMetadata.clone();
inputConec = connec;
if (connec.getSource().isReadOnly()) {
inputReadOnlyNode = true;
} else {
for (IElementParameter curParam : connec.getSource().getElementParameters()) {
if (curParam.getFieldType() == EParameterFieldType.SCHEMA_TYPE || curParam.getFieldType() == EParameterFieldType.SCHEMA_REFERENCE) {
if (curParam.isReadOnly()) {
inputReadOnlyParam = true;
}
}
}
}
// check if the inputMetadata is readonly
if (inputMetadata != null) {
for (IMetadataColumn column : inputMetadata.getListColumns(true)) {
IMetadataColumn columnCopied = inputMetaCopy.getColumn(column.getLabel());
columnCopied.setCustom(column.isCustom());
columnCopied.setReadOnly(column.isReadOnly());
}
inputMetaCopy.setReadOnly(inputMetadata.isReadOnly());
inputReadOnly = prepareReadOnlyTable(inputMetaCopy, inputReadOnlyParam, inputReadOnlyNode);
}
// store the value for Dialog
Map<IMetadataTable, Boolean> oneInput = new HashMap<IMetadataTable, Boolean>();
oneInput.put(inputMetaCopy, inputReadOnly);
inputInfos.put(connec.getSource(), oneInput);
}
}
if (connectionParam != null && inputMetadata == null) {
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
button.getShell(), //$NON-NLS-1$
Messages.getString("AbstractSchemaController.inputNotSet"), //$NON-NLS-1$
Messages.getString("AbstractSchemaController.connectionNotAvaliable"));
return null;
}
IMetadataTable originaleMetadataTable = getMetadataTableFromXml(node);
// check if the outputMetadata is readonly
IMetadataTable originaleOutputTable = node.getMetadataFromConnector(param.getContext());
// when several schema_type button ,need get the right one which is opening
//$NON-NLS-1$
IElementParameter schemaParam = param.getChildParameters().get("SCHEMA_TYPE");
// need setRepository here
if (!param.getContext().equals(schemaParam.getContext())) {
//$NON-NLS-1$
schemaParam = param.getChildParameters().get("SCHEMA_TYPE");
}
if (schemaParam != null && EmfComponent.REPOSITORY.equals(schemaParam.getValue())) {
if (originaleOutputTable != null && originaleOutputTable instanceof MetadataTable) {
((MetadataTable) originaleOutputTable).setRepository(true);
}
} else if (schemaParam != null && EmfComponent.BUILTIN.equals(schemaParam.getValue())) {
if (originaleOutputTable != null && originaleOutputTable instanceof MetadataTable) {
((MetadataTable) originaleOutputTable).setRepository(false);
}
}
if ("tUniservBTGeneric".equals(node.getComponent().getName())) {
//$NON-NLS-1$
//$NON-NLS-1$
originaleOutputTable = node.getMetadataTable("OUTPUT_SCHEMA");
}
IMetadataTable outputMetaCopy = originaleOutputTable.clone(true);
for (IMetadataColumn column : originaleOutputTable.getListColumns(true)) {
IMetadataColumn columnCopied = outputMetaCopy.getColumn(column.getLabel());
columnCopied.setCustom(column.isCustom());
columnCopied.setReadOnly(column.isReadOnly());
if (//$NON-NLS-1$ //$NON-NLS-2$
("tLogCatcher".equals(node.getComponent().getName()) || "tStatCatcher".equals(node.getComponent().getName())) && !outputMetaCopy.sameMetadataAs(originaleMetadataTable, IMetadataColumn.OPTIONS_NONE)) {
columnCopied.setReadOnly(false);
}
}
outputMetaCopy.setReadOnly(originaleOutputTable.isReadOnly() || param.isReadOnly(node.getElementParametersWithChildrens()));
if (//$NON-NLS-1$ //$NON-NLS-2$
("tLogCatcher".equals(node.getComponent().getName()) || "tStatCatcher".equals(node.getComponent().getName())) && !outputMetaCopy.sameMetadataAs(originaleMetadataTable, IMetadataColumn.OPTIONS_NONE)) {
outputMetaCopy.setReadOnly(false);
}
//$NON-NLS-1$
IElementParameter schemaTypeParam = param.getChildParameters().get("SCHEMA_TYPE");
List<IElementParameterDefaultValue> defaultValues = schemaTypeParam.getDefaultValues();
for (IElementParameterDefaultValue elementParameterDefaultValue : defaultValues) {
if (elementParameterDefaultValue.getDefaultValue() instanceof MetadataTable) {
MetadataTable table = (MetadataTable) elementParameterDefaultValue.getDefaultValue();
outputMetaCopy.setReadOnlyColumnPosition(table.getReadOnlyColumnPosition());
break;
}
}
outputMetaCopy.sortCustomColumns();
if (!forceReadOnly) {
outputReadOnly = prepareReadOnlyTable(outputMetaCopy, param.isReadOnly(), node.isReadOnly());
} else {
outputReadOnly = true;
}
// create the MetadataDialog
MetadataDialog metaDialog = null;
if (inputMetadata != null) {
if (inputInfos != null && inputInfos.size() > 1 && connectionName == null) {
MetadataDialogForMerge metaDialogForMerge = new MetadataDialogForMerge(composite.getShell(), inputInfos, outputMetaCopy, node, getCommandStack());
//$NON-NLS-1$
metaDialogForMerge.setText(Messages.getString("AbstractSchemaController.schemaOf") + node.getLabel());
metaDialogForMerge.setInputReadOnly(inputReadOnly);
metaDialogForMerge.setOutputReadOnly(outputReadOnly);
if (metaDialogForMerge.open() == MetadataDialogForMerge.OK) {
// inputMetaCopy = metaDialog.getInputMetaData();
outputMetaCopy = metaDialogForMerge.getOutputMetaData();
// check if the metadata is modified
boolean modified = false;
if (!outputMetaCopy.sameMetadataAs(originaleOutputTable, IMetadataColumn.OPTIONS_NONE)) {
modified = true;
} else {
if (inputMetadata != null) {
// Notice: the Map inputInfos maybe is modified by the dialog.
Set<INode> inputNodes = inputInfos.keySet();
for (INode inputNode : inputNodes) {
Map<IMetadataTable, Boolean> oneInput = inputInfos.get(inputNode);
inputMetaCopy = (IMetadataTable) oneInput.keySet().toArray()[0];
if (!inputMetaCopy.sameMetadataAs(inputNode.getMetadataList().get(0), IMetadataColumn.OPTIONS_NONE)) {
modified = true;
}
}
}
}
// create the changeMetadataCommand
if (modified) {
if (switchParam != null) {
switchParam.setValue(Boolean.FALSE);
}
Command changeMetadataCommand = null;
// only output, no input
if (inputInfos.isEmpty()) {
changeMetadataCommand = new ChangeMetadataCommand(node, param, null, null, null, originaleOutputTable, outputMetaCopy);
} else {
Set<INode> inputNodes = inputInfos.keySet();
int count = 0;
for (INode inputNode : inputNodes) {
Map<IMetadataTable, Boolean> oneInput = inputInfos.get(inputNode);
inputMetaCopy = (IMetadataTable) oneInput.keySet().toArray()[0];
if (count == 0) {
changeMetadataCommand = new ChangeMetadataCommand(node, param, inputNode, inputNode.getMetadataList().get(0), inputMetaCopy, originaleOutputTable, outputMetaCopy);
} else {
changeMetadataCommand = changeMetadataCommand.chain(new ChangeMetadataCommand(node, param, inputNode, inputNode.getMetadataList().get(0), inputMetaCopy, originaleOutputTable, outputMetaCopy));
}
count++;
}
}
return changeMetadataCommand;
}
}
} else {
INode inputNode = (inputConec.getSource());
if (inputMetaCopy.getAttachedConnector() == null) {
INodeConnector mainConnector;
if (inputNode.isELTComponent()) {
mainConnector = inputNode.getConnectorFromType(EConnectionType.TABLE);
} else {
mainConnector = inputNode.getConnectorFromType(EConnectionType.FLOW_MAIN);
}
inputMetaCopy.setAttachedConnector(mainConnector.getName());
}
metaDialog = new MetadataDialog(composite.getShell(), inputMetaCopy, inputNode, outputMetaCopy, node, getCommandStack());
}
} else {
metaDialog = new MetadataDialog(composite.getShell(), outputMetaCopy, node, getCommandStack());
}
if (metaDialog != null) {
//$NON-NLS-1$
metaDialog.setText(Messages.getString("AbstractSchemaController.schema.title", node.getLabel()));
metaDialog.setInputReadOnly(inputReadOnly);
metaDialog.setOutputReadOnly(outputReadOnly);
setMetadataTableOriginalNameList(inputMetadata, inputMetaCopy);
setMetadataTableOriginalNameList(originaleOutputTable, outputMetaCopy);
if (metaDialog.open() == MetadataDialog.OK) {
inputMetaCopy = metaDialog.getInputMetaData();
outputMetaCopy = metaDialog.getOutputMetaData();
boolean modified = false;
if (!outputMetaCopy.sameMetadataAs(originaleOutputTable, IMetadataColumn.OPTIONS_NONE)) {
modified = true;
} else {
if (inputMetadata != null) {
if (!inputMetaCopy.sameMetadataAs(inputMetadata, IMetadataColumn.OPTIONS_NONE)) {
modified = true;
}
}
}
if (modified) {
if (switchParam != null) {
switchParam.setValue(Boolean.FALSE);
}
INode inputNode = null;
if (inputConec != null) {
inputNode = inputConec.getSource();
}
ChangeMetadataCommand changeMetadataCommand = new ChangeMetadataCommand(node, param, inputNode, inputMetadata, inputMetaCopy, originaleOutputTable, outputMetaCopy);
return changeMetadataCommand;
}
}
}
} else if (inputButton.getData(NAME).equals(RETRIEVE_SCHEMA)) {
Node node = (Node) elem;
// String propertyName = (String) inputButton.getData(PARAMETER_NAME);
final Command cmd = RetrieveSchemaHelper.retrieveSchemasCommand(node);
if (switchParam != null) {
switchParam.setValue(Boolean.FALSE);
}
return cmd;
} else if (inputButton.getData(NAME).equals(RESET_COLUMNS)) {
Node node = (Node) elem;
String propertyName = (String) inputButton.getData(PARAMETER_NAME);
IElementParameter param = node.getElementParameter(propertyName);
final Command cmd = SynchronizeSchemaHelper.createCommand(node, param);
if (switchParam != null) {
switchParam.setValue(Boolean.FALSE);
}
return cmd;
} else if (button.getData(NAME).equals(REPOSITORY_CHOICE)) {
String paramName = (String) button.getData(PARAMETER_NAME);
IElementParameter schemaParam = elem.getElementParameter(paramName);
ERepositoryObjectType type = ERepositoryObjectType.METADATA_CON_TABLE;
String filter = schemaParam.getFilter();
if (elem instanceof Node) {
Node sapNode = (Node) elem;
if (sapNode.getComponent().getName().startsWith("tESB")) {
//$NON-NLS-1$
filter = ERepositoryObjectType.SERVICESOPERATION.getType();
}
}
RepositoryReviewDialog dialog = new RepositoryReviewDialog(button.getShell(), type, filter);
if (dialog.open() == RepositoryReviewDialog.OK) {
RepositoryNode node = dialog.getResult();
while (node.getObject().getProperty().getItem() == null || (!(node.getObject().getProperty().getItem() instanceof ConnectionItem))) {
node = node.getParent();
}
IRepositoryViewObject object = dialog.getResult().getObject();
Property property = object.getProperty();
String id = property.getId();
// The name is Table Name.
String name = object.getLabel();
org.talend.core.model.metadata.builder.connection.MetadataTable table = null;
if (property.getItem() instanceof SAPConnectionItem && object instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject metadataObject = (MetadataTableRepositoryObject) object;
table = (org.talend.core.model.metadata.builder.connection.MetadataTable) metadataObject.getModelElement();
if (table.eContainer() instanceof SAPFunctionUnit) {
SAPFunctionUnit function = (SAPFunctionUnit) table.eContainer();
String tableType = table.getTableType() == null ? MetadataSchemaType.OUTPUT.name() : table.getTableType();
//$NON-NLS-1$ //$NON-NLS-2$
name = function.getLabel() + "/" + tableType + "/" + name;
}
}
if (name != null) {
if (elem instanceof Node) {
Node nodeElement = (Node) elem;
//$NON-NLS-1$
String value = id + " - " + name;
IMetadataTable repositoryMetadata = MetadataToolHelper.getMetadataFromRepository(value);
if (nodeElement.getComponent().getName().equals("tSQLTemplateMerge")) {
//$NON-NLS-1$
if (paramName.equals("SCHEMA")) {
//$NON-NLS-1$
//$NON-NLS-1$
paramName = "SOURCE_TABLE";
Command dbSelectorCommand = new PropertyChangeCommand(elem, paramName, TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
executeCommand(dbSelectorCommand);
Text labelText = (Text) hashCurControls.get(paramName);
labelText.setText(TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
//$NON-NLS-1$
paramName = "SCHEMA:REPOSITORY_SCHEMA_TYPE";
dbSelectorCommand = new PropertyChangeCommand(elem, paramName, TalendTextUtils.addQuotes(name));
executeCommand(dbSelectorCommand);
labelText = (Text) hashCurControls.get(paramName);
labelText.setText(TalendTextUtils.addQuotes(name));
//$NON-NLS-1$
paramName = "SCHEMA";
} else if (paramName.equals("SCHEMA_TARGET")) {
//$NON-NLS-1$
//$NON-NLS-1$
paramName = "TARGET_TABLE";
Command dbSelectorCommand = new PropertyChangeCommand(elem, paramName, TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
executeCommand(dbSelectorCommand);
Text labelText = (Text) hashCurControls.get(paramName);
labelText.setText(TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
//$NON-NLS-1$
paramName = "SCHEMA_TARGET:REPOSITORY_SCHEMA_TYPE";
dbSelectorCommand = new PropertyChangeCommand(elem, paramName, TalendTextUtils.addQuotes(name));
executeCommand(dbSelectorCommand);
labelText = (Text) hashCurControls.get(paramName);
labelText.setText(TalendTextUtils.addQuotes(name));
//$NON-NLS-1$
paramName = "SCHEMA_TARGET";
}
} else if (nodeElement.getComponent().getName().startsWith("tSQLTemplate")) {
//$NON-NLS-1$
if (paramName.equals("SCHEMA")) {
//$NON-NLS-1$
//$NON-NLS-1$
paramName = "TABLE_NAME";
Command dbSelectorCommand = new PropertyChangeCommand(elem, paramName, TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
executeCommand(dbSelectorCommand);
Text labelText = (Text) hashCurControls.get(paramName);
labelText.setText(TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
//$NON-NLS-1$
paramName = "SCHEMA:REPOSITORY_SCHEMA_TYPE";
dbSelectorCommand = new PropertyChangeCommand(elem, paramName, TalendTextUtils.addQuotes(name));
executeCommand(dbSelectorCommand);
labelText = (Text) hashCurControls.get(paramName);
labelText.setText(TalendTextUtils.addQuotes(name));
//$NON-NLS-1$
paramName = "SCHEMA";
} else if (paramName.equals("SCHEMA_TARGET")) {
//$NON-NLS-1$
//$NON-NLS-1$
paramName = "TABLE_NAME_TARGET";
Command dbSelectorCommand = new PropertyChangeCommand(elem, paramName, TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
executeCommand(dbSelectorCommand);
Text labelText = (Text) hashCurControls.get(paramName);
labelText.setText(TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
//$NON-NLS-1$
paramName = "SCHEMA_TARGET:REPOSITORY_SCHEMA_TYPE";
dbSelectorCommand = new PropertyChangeCommand(elem, paramName, TalendTextUtils.addQuotes(name));
executeCommand(dbSelectorCommand);
labelText = (Text) hashCurControls.get(paramName);
labelText.setText(TalendTextUtils.addQuotes(name));
//$NON-NLS-1$
paramName = "SCHEMA_TARGET";
}
} else if (nodeElement.getComponent().getName().startsWith("tSalesforce")) {
//$NON-NLS-1$
//$NON-NLS-1$
paramName = paramName + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName();
Command selectorCommand = new PropertyChangeCommand(elem, paramName, TalendTextUtils.addQuotes(value));
executeCommand(selectorCommand);
} else {
Command dbSelectorCommand = new PropertyChangeCommand(elem, paramName, TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
executeCommand(dbSelectorCommand);
Text labelText = (Text) hashCurControls.get(paramName);
if (labelText != null) {
labelText.setText(TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
}
}
}
}
//$NON-NLS-1$
String value = id + " - " + name;
//$NON-NLS-1$
String fullParamName = paramName + ":" + getRepositoryChoiceParamName();
org.talend.core.model.metadata.builder.connection.Connection connection = null;
if (elem instanceof Node) {
IMetadataTable repositoryMetadata = null;
if (table != null && table instanceof SAPBWTable) {
repositoryMetadata = ConvertionHelper.convert(table);
} else {
repositoryMetadata = MetadataToolHelper.getMetadataFromRepository(value);
connection = MetadataToolHelper.getConnectionFromRepository(value);
}
// For SAP see bug 5423
String functionId = node.getParent().getId();
if (//$NON-NLS-1$//$NON-NLS-2$
((Node) elem).getUniqueName().startsWith("tSAP") && !((Node) elem).getUniqueName().startsWith("tSAPHana") && functionId != "-1") {
//$NON-NLS-1$
Node sapNode = (Node) elem;
repositoryMetadata = getMetadataFromRepository(id, functionId, name);
String functionName = node.getParent().getObject().getLabel();
for (IElementParameter param : sapNode.getElementParameters()) {
SAPParametersUtils.retrieveSAPParams(elem, connection, param, functionName);
}
}
// For validation rule.
boolean isValRulesLost = false;
IRepositoryViewObject currentValRuleObj = ValidationRulesUtil.getCurrentValidationRuleObjs(elem);
if (currentValRuleObj != null) {
List<IRepositoryViewObject> valRuleObjs = ValidationRulesUtil.getRelatedValidationRuleObjs(value);
if (!ValidationRulesUtil.isCurrentValRuleObjInList(valRuleObjs, currentValRuleObj)) {
if (!MessageDialog.openConfirm(button.getShell(), //$NON-NLS-1$
Messages.getString("AbstractSchemaController.validationrule.title.confirm"), Messages.getString("AbstractSchemaController.validationrule.selectMetadataMsg"))) {
//$NON-NLS-1$
return null;
} else {
isValRulesLost = true;
}
}
}
if (repositoryMetadata == null) {
repositoryMetadata = new MetadataTable();
}
if (switchParam != null) {
switchParam.setValue(Boolean.FALSE);
}
CompoundCommand cc = new CompoundCommand();
RepositoryChangeMetadataCommand changeMetadataCommand = new RepositoryChangeMetadataCommand((Node) elem, fullParamName, value, repositoryMetadata, null, null, table);
changeMetadataCommand.setConnection(connection);
cc.add(changeMetadataCommand);
if (isValRulesLost) {
ValidationRulesUtil.appendRemoveValidationRuleCommands(cc, elem);
}
return cc;
}
}
} else if (button.getData(NAME).equals(COPY_CHILD_COLUMNS)) {
String paramName = (String) button.getData(PARAMETER_NAME);
IElementParameter param = elem.getElementParameter(paramName);
IElementParameter processParam = elem.getElementParameterFromField(EParameterFieldType.PROCESS_TYPE);
IElementParameter processIdParam = processParam.getChildParameters().get(EParameterName.PROCESS_TYPE_PROCESS.getName());
String id = (String) processIdParam.getValue();
Item item = ItemCacheManager.getProcessItem(id);
Node node = (Node) elem;
copySchemaFromChildJob(node, item);
// pop up the schema dialog
MetadataDialog metaDialog = new MetadataDialog(composite.getShell(), node.getMetadataList().get(0), node, getCommandStack());
//$NON-NLS-1$
metaDialog.setText(Messages.getString("AbstractSchemaController.schemaOf") + node.getLabel());
if (metaDialog.open() == MetadataDialog.OK) {
IMetadataTable outputMetaData = metaDialog.getOutputMetaData();
return new ChangeMetadataCommand(node, param, null, outputMetaData);
}
}
return null;
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class StatsAndLogsViewHelper method applySettings.
/**
* yzhang Comment method "applySettings".
*
* @param element
* @param dynamicProperty
*/
public static void applySettings(IElement element, IElement applyTo, IDynamicProperty dynamicProperty) {
List<? extends IElementParameter> elementParameters = applyTo.getElementParameters();
for (IElementParameter elementParameterType : elementParameters) {
String parameterName = elementParameterType.getName();
if (parameterName.equals(EParameterName.ON_STATCATCHER_FLAG.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.ON_STATCATCHER_FLAG.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.ON_LOGCATCHER_FLAG.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.ON_LOGCATCHER_FLAG.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.ON_METERCATCHER_FLAG.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.ON_METERCATCHER_FLAG.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.ON_FILES_FLAG.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.ON_FILES_FLAG.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.FILE_PATH.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.FILE_PATH.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.FILENAME_STATS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.FILENAME_STATS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.FILENAME_LOGS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.FILENAME_LOGS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.FILENAME_METTER.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.FILENAME_METTER.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.ON_DATABASE_FLAG.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.ON_DATABASE_FLAG.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.PROPERTY_TYPE.getName())) {
String id = (String) element.getElementParameter(//$NON-NLS-1$
EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).getValue();
String propertyType = (String) element.getElementParameter(EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.PROPERTY_TYPE.getName()).getValue();
/* 16969 */
Connection repositoryConnection = null;
// Map<String, ConnectionItem> repositoryConnectionItemMap =
// dynamicProperty.getRepositoryConnectionItemMap();
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;
}
// if (repositoryConnectionItemMap.containsKey(id)) {
// repositoryConnection = repositoryConnectionItemMap.get(id).getConnection();
// } else {
// repositoryConnection = null;
// }
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(applyTo, repositoryConnection, EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(applyTo, repositoryConnection, EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
CompoundCommand cc = new CompoundCommand();
cc.add(cmd1);
cc.add(cmd2);
boolean executed = false;
if (applyTo instanceof IGEFProcess) {
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand((IGEFProcess) applyTo, cc);
}
}
if (!executed) {
cc.execute();
}
continue;
}
if (PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.PROPERTY_TYPE.getName()).equals(EmfComponent.BUILTIN)) {
if (parameterName.equals(EParameterName.DB_TYPE.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.DB_TYPE.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.HOST.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.HOST.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.PORT.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.PORT.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.DBNAME.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.DBNAME.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.PROPERTIES.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.PROPERTIES.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.DBFILE.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.DBFILE.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.SCHEMA_DB.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.SCHEMA_DB.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.USER.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.USER.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.PASS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.PASS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.TABLE_STATS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.TABLE_STATS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.TABLE_LOGS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.TABLE_LOGS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.TABLE_METER.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.TABLE_METER.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.CATCH_RUNTIME_ERRORS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.CATCH_RUNTIME_ERRORS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.CATCH_USER_ERRORS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.CATCH_USER_ERRORS.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.CATCH_USER_WARNING.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.CATCH_USER_WARNING.getName()).getValue());
continue;
}
if (parameterName.equals(EParameterName.CATCH_REALTIME_STATS.getName())) {
elementParameterType.setValue(element.getElementParameter(EParameterName.CATCH_REALTIME_STATS.getName()).getValue());
continue;
}
}
}
}
use of org.talend.core.model.properties.Property 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.Property in project tdi-studio-se by Talend.
the class JobLaunchShortcutManager method renameJobLaunch.
/**
*
* cli Comment method "renameJobLaunch".
*/
public static void renameJobLaunch(IRepositoryViewObject obj, String oldLabel) {
if (obj == null) {
return;
}
Property property = obj.getProperty();
if (property == null || !(property.getItem() instanceof ProcessItem)) {
return;
}
String newLabel = property.getLabel();
if (!newLabel.equals(oldLabel)) {
Project project = ProjectManager.getInstance().getProject(property);
if (project == null) {
return;
}
final String objProjectName = project.getLabel();
final String id = property.getId();
final String version = property.getVersion();
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
if (launchManager == null) {
return;
}
try {
for (ILaunchConfiguration configuration : launchManager.getLaunchConfigurations()) {
String jobId = configuration.getAttribute(TalendDebugUIConstants.JOB_ID, (String) null);
String jobVersion = configuration.getAttribute(TalendDebugUIConstants.JOB_VERSION, (String) null);
String projectName = configuration.getAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, (String) null);
// ILaunchConfigurationType type = launchManager
// .getLaunchConfigurationType(TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE);
ILaunchConfigurationType type = configuration.getType();
if (type != null && TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE.equals(type.getIdentifier()) && objProjectName.equals(projectName) && id.equals(jobId) && version.equals(jobVersion) && type != null) {
//$NON-NLS-1$
String displayName = newLabel + " " + jobVersion;
ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
workingCopy.setAttribute(TalendDebugUIConstants.JOB_NAME, newLabel);
// workingCopy.setAttribute(TalendDebugUIConstants.JOB_ID, jobId);
// update to new version
workingCopy.setAttribute(TalendDebugUIConstants.JOB_VERSION, jobVersion);
// workingCopy.setAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, projectName);
workingCopy.rename(displayName);
workingCopy.doSave();
break;
}
}
clearUnusedLaunchs();
} catch (CoreException e) {
// nothing to do
}
}
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class JobLaunchShortcutManager method removeJobLaunch.
// debug not used yet, so code is disabled
// public static void debug(ISelection selection) {
// List<LaunchShortcutExtension> launchShortcuts = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
// .getLaunchShortcuts();
//
// for (LaunchShortcutExtension lse : launchShortcuts) {
// if (lse.getId().equals(TalendDebugUIConstants.TALEND_JOB_LAUNCH_SHORTCUT_ID)) {
// lse.launch(selection, ILaunchManager.DEBUG_MODE);
// return;
// }
// }
// }
//
// public static void debug(IEditorPart editor) {
// List<LaunchShortcutExtension> launchShortcuts = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
// .getLaunchShortcuts();
//
// for (LaunchShortcutExtension lse : launchShortcuts) {
// if (lse.getId().equals(TalendDebugUIConstants.TALEND_JOB_LAUNCH_SHORTCUT_ID)) {
// lse.launch(editor, ILaunchManager.DEBUG_MODE);
// return;
// }
// }
// }
/**
*
* cli Comment method "removeJobLaunch".
*/
public static void removeJobLaunch(IRepositoryViewObject objToDelete) {
if (objToDelete == null) {
return;
}
Property property = objToDelete.getProperty();
if (property == null || !(property.getItem() instanceof ProcessItem)) {
return;
}
Project project = ProjectManager.getInstance().getProject(property);
if (project == null) {
return;
}
final String objProjectName = project.getLabel();
final String objId = property.getId();
// final String objName = property.getLabel();
final String objVersion = property.getVersion();
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
if (launchManager == null) {
return;
}
try {
ILaunchConfiguration configuration = null;
for (ILaunchConfiguration config : launchManager.getLaunchConfigurations()) {
String jobId = config.getAttribute(TalendDebugUIConstants.JOB_ID, (String) null);
// String jobName = configuration.getAttribute(TalendDebugUIConstants.JOB_NAME, (String) null);
String jobVersion = config.getAttribute(TalendDebugUIConstants.JOB_VERSION, (String) null);
String projectName = config.getAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, (String) null);
ILaunchConfigurationType type = config.getType();
if (type != null && TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE.equals(type.getIdentifier()) && objProjectName.equals(projectName) && objId.equals(jobId) && objVersion.equals(jobVersion)) {
configuration = config;
break;
}
}
if (configuration == null) {
return;
}
configuration.delete();
} catch (CoreException e) {
// nothing to do
}
}
Aggregations