use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class AbstractJobSettingsPage method isStatUseProjectSetting.
protected boolean isStatUseProjectSetting(IRepositoryViewObject object) {
Property property = object.getProperty();
ProcessItem pItem = (ProcessItem) property.getItem();
ParametersType pType = pItem.getProcess().getParameters();
String statB = ElementParameter2ParameterType.getParameterValue(pType, getParameterName().getName());
return Boolean.parseBoolean(statB);
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method init.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.MultiPageEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
*/
@Override
public void init(final IEditorSite site, IEditorInput editorInput) throws PartInitException {
setSite(site);
setInput(editorInput);
if (!(editorInput instanceof JobEditorInput)) {
return;
}
site.setSelectionProvider(new MultiPageTalendSelectionProvider(this));
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
// Lock the process :
IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
final IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
processEditorInput = (JobEditorInput) editorInput;
final IProcess2 currentProcess = processEditorInput.getLoadedProcess();
if (!currentProcess.isReadOnly()) {
try {
Property property = processEditorInput.getItem().getProperty();
propertyInformation = new ArrayList(property.getInformations());
property.eAdapters().add(dirtyListener);
repFactory.lock(currentProcess);
boolean locked = repFactory.getStatus(currentProcess) == ERepositoryStatus.LOCK_BY_USER;
if (!locked) {
setReadOnly(true);
}
revisionChanged = true;
} catch (PersistenceException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
} catch (BusinessException e) {
// Nothing to do
ExceptionHandler.process(e);
}
} else {
setReadOnly(true);
Bundle bundle = FrameworkUtil.getBundle(AbstractMultiPageTalendEditor.class);
final Display display = getSite().getShell().getDisplay();
this.lockService = bundle.getBundleContext().registerService(EventHandler.class.getName(), new EventHandler() {
@Override
public void handleEvent(Event event) {
String lockTopic = Constant.REPOSITORY_ITEM_EVENT_PREFIX + Constant.ITEM_LOCK_EVENT_SUFFIX;
if (lockTopic.equals(event.getTopic())) {
Object o = event.getProperty(Constant.ITEM_EVENT_PROPERTY_KEY);
if (o != null && o instanceof Item) {
Item item = (Item) o;
String itemId = item.getProperty().getId();
if (itemId.equals(currentProcess.getId())) {
if (currentProcess.isReadOnly()) {
boolean readOnly = currentProcess.checkReadOnly();
boolean orginalReadOnlyStatus = designerEditor.isReadOnly();
setReadOnly(readOnly);
if (!readOnly) {
display.asyncExec(new Runnable() {
@Override
public void run() {
setFocus();
}
});
if (orginalReadOnlyStatus == true) {
// refresh to the given item version, nomally it is the latest
// version,
// means the editor/process will be refreshed to the latest version
refreshProcess(item, false);
}
Property property = processEditorInput.getItem().getProperty();
propertyInformation = new ArrayList(property.getInformations());
property.eAdapters().add(dirtyListener);
}
}
}
}
}
}
}, new Hashtable<String, String>(Collections.singletonMap(EventConstants.EVENT_TOPIC, //$NON-NLS-1$
Constant.REPOSITORY_ITEM_EVENT_PREFIX + "*")));
revisionChanged = true;
}
// setTitleImage(ImageProvider.getImage(getEditorTitleImage()));
updateTitleImage(processEditorInput.getItem().getProperty());
getSite().getWorkbenchWindow().getPartService().addPartListener(partListener);
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class AbstractProcessVersionAction method init.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
* org.eclipse.jface.viewers.IStructuredSelection)
*/
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = !selection.isEmpty() && selection.size() == 1;
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (factory.isUserReadOnlyOnCurrentProject()) {
canWork = false;
}
if (canWork) {
Object o = selection.getFirstElement();
repositoryNode = (RepositoryNode) o;
switch(repositoryNode.getType()) {
case REPOSITORY_ELEMENT:
canWork = repositoryNode.getObjectType() == ERepositoryObjectType.PROCESS;
break;
default:
canWork = false;
}
if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(repositoryNode)) {
canWork = false;
}
}
setEnabled(canWork);
if (canWork) {
Property property = (Property) repositoryNode.getObject().getProperty();
ItemCacheManager.clearCache();
Assert.isTrue(property.getItem() instanceof ProcessItem);
Property updatedProperty = null;
try {
updatedProperty = ProxyRepositoryFactory.getInstance().getUptodateProperty(property);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// update the property of the node repository object
// repositoryNode.getObject().setProperty(updatedProperty);
processItem = (ProcessItem) updatedProperty.getItem();
}
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class AbstractElementPropertySectionController method openSQLBuilder.
/**
* DOC qzhang Comment method "openSQLBuilder".
*
* @param repositoryType
* @param propertyName
* @param query
*/
protected String openSQLBuilder(String repositoryType, String propertyName, String query) {
if (repositoryType.equals(EmfComponent.BUILTIN)) {
connParameters.setQuery(query);
if (connParameters.isShowConfigParamDialog()) {
if (!isUseExistingConnection()) {
initConnectionParametersWithContext(elem, part.getProcess().getContextManager().getDefaultContext());
} else {
initConnectionParametersWithContext(connectionNode, part.getProcess().getContextManager().getDefaultContext());
}
}
// add for bug TDI-20335
if (part == null) {
Shell parentShell = new Shell(composite.getShell().getDisplay());
ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
Dialog sqlBuilder = service.openSQLBuilderDialog(parentShell, "", connParameters);
sqlBuilder.open();
} else {
openSqlBuilderBuildIn(connParameters, propertyName);
}
} else if (repositoryType.equals(EmfComponent.REPOSITORY)) {
//$NON-NLS-1$
String repositoryName2 = "";
String repositoryId = null;
IElementParameter memoParam = elem.getElementParameter(propertyName);
IElementParameter repositoryParam = null;
for (IElementParameter param : elem.getElementParameters()) {
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE && param.getRepositoryValue().startsWith("DATABASE")) {
repositoryParam = param;
break;
}
}
// in case no database property found, take the first property (to keep compatibility with old code)
if (repositoryParam == null) {
for (IElementParameter param : elem.getElementParameters()) {
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
repositoryParam = param;
break;
}
}
}
if (repositoryParam != null) {
IElementParameter itemFromRepository = repositoryParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
String value = (String) itemFromRepository.getValue();
repositoryId = value;
// for (String key : this.dynamicProperty.getRepositoryConnectionItemMap().keySet()) {
// if (key.equals(value)) {
// repositoryName2 =
// this.dynamicProperty.getRepositoryConnectionItemMap().get(key).getProperty().getLabel();
// }
// }
/* get connection item dynamictly,not from cache ,see 16969 */
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
IRepositoryViewObject repobj = factory.getLastVersion(value);
if (repobj != null) {
Property property = repobj.getProperty();
if (property != null) {
repositoryName2 = property.getLabel();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
// When no repository avaiable on "Repository" mode, open a MessageDialog.
if (repositoryName2 == null || repositoryName2.length() == 0) {
MessageDialog.openError(composite.getShell(), Messages.getString("NoRepositoryDialog.Title"), //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"NoRepositoryDialog.Text"));
return null;
}
// Part maybe not exist
//$NON-NLS-1$
String processName = "";
//$NON-NLS-1$
String key = "";
if (elem instanceof Node) {
processName = ((Node) elem).getProcess().getName();
key = processName + ((Node) elem).getUniqueName();
} else if (elem instanceof IProcess) {
processName = ((IProcess) elem).getName();
key = processName;
}
key += repositoryName2;
final Dialog builderDialog = sqlbuilers.get(key);
if (!composite.isDisposed() && builderDialog != null && builderDialog.getShell() != null && !builderDialog.getShell().isDisposed()) {
builderDialog.getShell().setActive();
} else {
connParameters.setRepositoryName(repositoryName2);
if (repositoryId != null) {
connParameters.setRepositoryId(repositoryId);
}
Shell parentShell = new Shell(composite.getShell().getDisplay());
String nodeLabel = null;
if (elem instanceof Node) {
nodeLabel = (String) ((Node) elem).getElementParameter(EParameterName.LABEL.getName()).getValue();
}
TextUtil.setDialogTitle(processName, nodeLabel, elem.getElementName());
ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
connParameters.setQuery(query);
// first open Sql Builder,set true
connParameters.setFirstOpenSqlBuilder(true);
Dialog sqlBuilder = service.openSQLBuilderDialog(parentShell, processName, connParameters);
sqlbuilers.put(key, sqlBuilder);
if (Window.OK == sqlBuilder.open()) {
if (!composite.isDisposed() && !connParameters.isNodeReadOnly()) {
String sql = connParameters.getQuery();
// modified by hyWang
if (!connParameters.getIfContextButtonCheckedFromBuiltIn()) {
sql = QueryUtil.checkAndAddQuotes(sql);
}
return sql;
}
}
}
}
return null;
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class AbstractElementPropertySectionController method setAllConnectionParameters.
private void setAllConnectionParameters(String typ, IElement element) {
IElementParameter basePropertyParameter = null;
for (IElementParameter param : elem.getElementParameters()) {
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
if (param.getRepositoryValue().startsWith("DATABASE")) {
basePropertyParameter = param;
break;
}
}
}
// jobsetting view load the db info from current selected category
IElementParameter updateBasePropertyParameter = updateBasePropertyParameter();
if (updateBasePropertyParameter != null && !updateBasePropertyParameter.equals(basePropertyParameter)) {
basePropertyParameter = updateBasePropertyParameter;
}
String type = null;
ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance();
if (typ != null && !typ.equals("")) {
//$NON-NLS-1$
type = typ;
} else {
//$NON-NLS-1$
type = getValueFromRepositoryName(element, "TYPE", basePropertyParameter);
}
if (type.equals("Oracle") || type.contains("OCLE")) {
IElementParameter ele = element.getElementParameter("CONNECTION_TYPE");
if (ele != null) {
type = (String) ele.getValue();
} else {
//$NON-NLS-1$
type = "ORACLE_SID";
}
}
// Get real hsqldb type
if (type.equals(EDatabaseTypeName.HSQLDB.name()) && getValueFromRepositoryName(element, "RUNNING_MODE", basePropertyParameter).equals("HSQLDB_INPROGRESS_PERSISTENT")) {
//$NON-NLS-1$
type = EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName();
}
// If the dbtype has been setted don't reset it again unless the dbtype of connParameters is null.
if (StringUtils.trimToNull(type) == null && StringUtils.trimToNull(connParameters.getDbType()) == null) {
type = EDatabaseTypeName.GENERAL_JDBC.getXmlName();
}
if (StringUtils.trimToNull(type) != null) {
connParameters.setDbType(type);
}
//$NON-NLS-1$
String frameWorkKey = getValueFromRepositoryName(element, "FRAMEWORK_TYPE", basePropertyParameter);
connParameters.setFrameworkType(frameWorkKey);
String schema = getValueFromRepositoryName(element, EConnectionParameterName.SCHEMA.getName(), basePropertyParameter);
connParameters.setSchema(schema);
String userName = getValueFromRepositoryName(element, EConnectionParameterName.USERNAME.getName(), basePropertyParameter);
connParameters.setUserName(userName);
String password = getValueFromRepositoryName(element, EConnectionParameterName.PASSWORD.getName(), basePropertyParameter);
connParameters.setPassword(password);
String host = getValueFromRepositoryName(element, EConnectionParameterName.SERVER_NAME.getName(), basePropertyParameter);
connParameters.setHost(host);
String port = getValueFromRepositoryName(element, EConnectionParameterName.PORT.getName(), basePropertyParameter);
connParameters.setPort(port);
boolean https = Boolean.parseBoolean(getValueFromRepositoryName(element, EConnectionParameterName.HTTPS.getName(), basePropertyParameter));
connParameters.setHttps(https);
boolean isOracleOCI = type.equals(EDatabaseTypeName.ORACLE_OCI.getXmlName()) || type.equals(EDatabaseTypeName.ORACLE_OCI.getDisplayName());
if (isOracleOCI) {
String localServiceName = getValueFromRepositoryNameAndParameterName(element, EConnectionParameterName.SID.getName(), EParameterName.LOCAL_SERVICE_NAME.getName());
// sid is the repository value both for DBName and Local_service_name
connParameters.setLocalServiceName(localServiceName);
}
String datasource = getValueFromRepositoryName(element, EConnectionParameterName.DATASOURCE.getName(), basePropertyParameter);
connParameters.setDatasource(datasource);
// qli modified to fix the bug "7364".
String dbName = getValueFromRepositoryName(element, EConnectionParameterName.SID.getName(), basePropertyParameter);
if (EDatabaseTypeName.EXASOL.getDisplayName().equals(connParameters.getDbType())) {
if (dbName.contains("\\\"")) {
dbName = dbName.replace("\\\"", "");
}
dbName = TextUtil.removeQuots(dbName);
} else if (EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(connParameters.getDbType())) {
//$NON-NLS-1$
dbName = "";
}
connParameters.setDbName(dbName);
if (connParameters.getDbType().equals(EDatabaseTypeName.SQLITE.getXmlName()) || connParameters.getDbType().equals(EDatabaseTypeName.ACCESS.getXmlName()) || connParameters.getDbType().equals(EDatabaseTypeName.FIREBIRD.getXmlName())) {
String file = getValueFromRepositoryName(element, EConnectionParameterName.FILE.getName(), basePropertyParameter);
connParameters.setFilename(file);
}
String dir = getValueFromRepositoryName(element, EConnectionParameterName.DIRECTORY.getName(), basePropertyParameter);
if (type.equals(EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName())) {
dir = getValueFromRepositoryName(elem, EConnectionParameterName.DBPATH.getName(), basePropertyParameter);
}
connParameters.setDirectory(dir);
// General jdbc
String url = getValueFromRepositoryName(element, EConnectionParameterName.URL.getName(), basePropertyParameter);
if (StringUtils.isEmpty(url)) {
// to get the Oracle RAC url.
if (EDatabaseTypeName.ORACLE_CUSTOM.getXmlName().equals(type)) {
url = getValueFromRepositoryName(element, "RAC_" + EConnectionParameterName.URL.getName(), basePropertyParameter);
}
}
connParameters.setUrl(TalendTextUtils.removeQuotes(url));
String driverJar = getValueFromRepositoryName(element, EConnectionParameterName.DRIVER_JAR.getName(), basePropertyParameter);
connParameters.setDriverJar(TalendTextUtils.removeQuotes(driverJar));
String driverClass = getValueFromRepositoryName(element, EConnectionParameterName.DRIVER_CLASS.getName(), basePropertyParameter);
String dbVersion = getValueFromRepositoryName(element, "DB_VERSION", basePropertyParameter);
connParameters.setDbVersion(dbVersion);
if (EDatabaseVersion4Drivers.VERTICA_5_1.getVersionValue().equals(dbVersion) || EDatabaseVersion4Drivers.VERTICA_6.getVersionValue().equals(dbVersion) || EDatabaseVersion4Drivers.VERTICA_6_1_X.getVersionValue().equals(dbVersion) || EDatabaseVersion4Drivers.VERTICA_7.getVersionValue().equals(dbVersion)) {
driverClass = EDatabase4DriverClassName.VERTICA2.getDriverClass();
}
connParameters.setDriverClass(TalendTextUtils.removeQuotes(driverClass));
if (driverClass != null && !"".equals(driverClass) && !EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(connParameters.getDbType())) {
if (driverClass.startsWith("\"") && driverClass.endsWith("\"")) {
driverClass = TalendTextUtils.removeQuotes(driverClass);
}
String dbTypeByClassName = "";
if (driverJar != null && !"".equals(driverJar)) {
dbTypeByClassName = extractMeta.getDbTypeByClassNameAndDriverJar(driverClass, driverJar);
} else {
dbTypeByClassName = extractMeta.getDbTypeByClassName(driverClass);
}
if (dbTypeByClassName != null) {
connParameters.setDbType(dbTypeByClassName);
}
}
String jdbcProps = getValueFromRepositoryName(element, EConnectionParameterName.PROPERTIES_STRING.getName(), basePropertyParameter);
connParameters.setJdbcProperties(jdbcProps);
String realTableName = null;
if (EmfComponent.REPOSITORY.equals(elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName()))) {
final Object propertyValue = elem.getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
IMetadataTable metadataTable = null;
String connectionId = propertyValue.toString().split(" - ")[0];
String tableLabel = propertyValue.toString().split(" - ")[1];
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
if (repobj != null) {
Property property = repobj.getProperty();
if (property != null) {
item = property.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
Connection connection = ((ConnectionItem) item).getConnection();
for (org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
if (table.getLabel().equals(tableLabel)) {
metadataTable = ConvertionHelper.convert(table);
break;
}
}
}
if (metadataTable != null) {
realTableName = metadataTable.getTableName();
}
}
connParameters.setSchemaName(QueryUtil.getTableName(elem, connParameters.getMetadataTable(), TalendTextUtils.removeQuotes(schema), type, realTableName));
}
Aggregations