use of org.talend.core.ui.ICDCProviderService in project tdi-studio-se by Talend.
the class ComponentChooseDialog method isEnabled.
@Override
public boolean isEnabled(DropTargetEvent e) {
Object obj = getSelection().getFirstElement();
if (obj instanceof RepositoryNode) {
RepositoryNode sourceNode = (RepositoryNode) obj;
if (PluginChecker.isCDCPluginLoaded()) {
ICDCProviderService service = (ICDCProviderService) GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
if (service != null && (service.isSubscriberTableNode(sourceNode) || service.isSystemSubscriberTable(sourceNode))) {
return false;
}
}
IHadoopClusterService hadoopClusterService = HadoopRepositoryUtil.getHadoopClusterService();
if (hadoopClusterService != null && hadoopClusterService.isHadoopClusterNode(sourceNode)) {
return false;
}
IOozieService oozieService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IOozieService.class)) {
oozieService = (IOozieService) GlobalServiceRegister.getDefault().getService(IOozieService.class);
}
if (oozieService != null && oozieService.isOozieNode(sourceNode)) {
return false;
}
ISAPProviderService sapService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISAPProviderService.class)) {
sapService = (ISAPProviderService) GlobalServiceRegister.getDefault().getService(ISAPProviderService.class);
}
if (sapService != null && sapService.isSAPNode(sourceNode)) {
return false;
}
}
return !this.editor.getProcess().isReadOnly();
}
use of org.talend.core.ui.ICDCProviderService in project tdi-studio-se by Talend.
the class SchemaTypeProcessor method selectRepositoryNode.
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
if (super.selectRepositoryNode(viewer, parentNode, node)) {
IRepositoryViewObject object = node.getObject();
if (object != null) {
// query
if (object instanceof Query) {
return false;
}
}
// cdc
ICDCProviderService cdcService = null;
if (PluginChecker.isCDCPluginLoaded()) {
cdcService = (ICDCProviderService) GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
}
String repositoryType = getRepositoryType();
if (ERepositoryCategoryType.CDC.getName().equals(repositoryType) && (object != null)) {
if (object.getRepositoryObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
DatabaseConnectionItem item = (DatabaseConnectionItem) object.getProperty().getItem();
DatabaseConnection connection = (DatabaseConnection) item.getConnection();
if (cdcService != null && cdcService.canCreateCDCConnection(connection)) {
return true;
}
return false;
}
if (object instanceof MetadataTable) {
return ((MetadataTableRepositoryObject) object).getTable().isActivatedCDC();
}
}
return true;
}
return false;
}
use of org.talend.core.ui.ICDCProviderService in project tdi-studio-se by Talend.
the class EditQueriesAction method init.
@Override
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:
if (repositoryNode.getObject().getRepositoryStatus() == ERepositoryStatus.DELETED || repositoryNode.getObject().getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER) {
canWork = false;
}
// Studio does not support this action for impala, TBD-3827.
if (!isUnderDBConnection(repositoryNode)) {
canWork = false;
}
if (repositoryNode.getObjectType() != ERepositoryObjectType.METADATA_CONNECTIONS && repositoryNode.getObjectType() != ERepositoryObjectType.METADATA_CON_QUERY && repositoryNode.getObjectType() != ERepositoryObjectType.METADATA_CON_TABLE) {
canWork = false;
} else {
// for cdc
if (PluginChecker.isCDCPluginLoaded()) {
ICDCProviderService cdcService = (ICDCProviderService) GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
if (cdcService != null && cdcService.isSubscriberTableNode(repositoryNode)) {
canWork = false;
break;
}
}
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
if (!repFactory.isPotentiallyEditable(repositoryNode.getObject())) {
canWork = false;
break;
}
}
if (canWork) {
Item item = repositoryNode.getObject().getProperty().getItem();
if (item instanceof DatabaseConnectionItem) {
DatabaseConnectionItem dbItem = (DatabaseConnectionItem) item;
DatabaseConnection dbConn = (DatabaseConnection) dbItem.getConnection();
String dbType = dbConn.getDatabaseType();
if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType) || EDatabaseTypeName.HBASE.getXmlName().equalsIgnoreCase(dbType) || EDatabaseTypeName.MAPRDB.getXmlName().equalsIgnoreCase(dbType) || EDatabaseTypeName.IMPALA.getXmlName().equalsIgnoreCase(dbType)) {
canWork = false;
break;
}
}
}
break;
default:
canWork = false;
}
if (canWork && (!ProjectManager.getInstance().isInCurrentMainProject(repositoryNode) || !isLastVersion(repositoryNode))) {
canWork = false;
}
}
setEnabled(canWork);
}
use of org.talend.core.ui.ICDCProviderService in project tdi-studio-se by Talend.
the class MultiTypesProcessor method selectRepositoryNode.
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
if (node == null) {
return false;
}
IRepositoryViewObject object = node.getObject();
if (object != null) {
// column
if (object instanceof MetadataColumnRepositoryObject) {
return false;
}
}
// hide the column folder
if (object == null && node.getParent() != null && node.getParent().getObject() != null && node.getParent().getObjectType() == ERepositoryObjectType.METADATA_CON_TABLE) {
return false;
}
// cdc
ICDCProviderService cdcService = null;
if (node.getObjectType() == ERepositoryObjectType.METADATA_CON_CDC) {
return false;
}
if (isCDCConnection(node)) {
return false;
}
if (PluginChecker.isCDCPluginLoaded()) {
cdcService = (ICDCProviderService) GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
if (cdcService != null && cdcService.isSubscriberTableNode(node)) {
return false;
}
}
return true;
}
use of org.talend.core.ui.ICDCProviderService in project tdi-studio-se by Talend.
the class UpdateNodeParameterCommand method updateProperty.
@SuppressWarnings("unchecked")
private void updateProperty() {
Object updateObject = result.getUpdateObject();
if (updateObject == null) {
return;
}
if (updateObject instanceof Node) {
// opened job
Node node = (Node) updateObject;
boolean update = false;
// added by wzhang for bug 9302
boolean isXsdPath = false;
Object parameter = result.getParameter();
IElementParameter curPropertyParam = null;
//$NON-NLS-1$
String parentParamName = "PROPERTY";
ConnectionItem connectionItem = null;
if (parameter instanceof ConnectionItem) {
if (parameter instanceof XmlFileConnectionItem) {
String filePath = ((XmlFileConnection) ((XmlFileConnectionItem) parameter).getConnection()).getXmlFilePath();
if (filePath != null) {
if (XmlUtil.isXSDFile(filePath)) {
isXsdPath = true;
}
}
}
connectionItem = (ConnectionItem) result.getParameter();
for (IElementParameter param : node.getElementParameters()) {
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE && param.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).getValue().equals(connectionItem.getProperty().getId())) {
curPropertyParam = param;
parentParamName = curPropertyParam.getName();
if (connectionItem != null) {
ConnectionContextHelper.addContextForNodeParameter(node, connectionItem, false);
}
break;
}
}
}
if (result.getResultType() == EUpdateResult.UPDATE) {
// upgrade from repository
if (result.isChecked() && connectionItem != null) {
List<? extends IElementParameter> elemParameters = new ArrayList<>(node.getElementParameters());
for (IElementParameter param : elemParameters) {
String repositoryValue = param.getRepositoryValue();
if (param.getRepositoryValue() == null || (curPropertyParam != null && param.getRepositoryProperty() != null && !param.getRepositoryProperty().equals(curPropertyParam.getName()))) {
continue;
}
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
continue;
}
if ((repositoryValue != null) && (param.isShow(node.getElementParameters()) || node.getComponentProperties() != null || (node instanceof INode && ((INode) node).getComponent().getName().equals("tAdvancedFileOutputXML")) || (node instanceof INode && ((INode) node).getComponent().getName().equals("tESBProviderRequest")))) {
//$NON-NLS-1$
if (param.getName().equals(EParameterName.PROPERTY_TYPE.getName()) || param.getFieldType() == EParameterFieldType.MEMO_SQL) {
continue;
}
if (param.getFieldType().equals(EParameterFieldType.FILE) && isXsdPath) {
continue;
}
IMetadataTable table = null;
if (!node.getMetadataList().isEmpty()) {
table = node.getMetadataList().get(0);
}
Object objectValue = RepositoryToComponentProperty.getValue(connectionItem.getConnection(), repositoryValue, table);
if (objectValue == null || "".equals(objectValue)) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
if (service != null) {
String propertyValue = (String) node.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
if (node.getComponent().getName().startsWith("tESB")) {
if (propertyValue.contains(" - ")) {
propertyValue = propertyValue.split(" - ")[0];
}
}
IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(propertyValue);
if (lastVersion != null) {
Item item = lastVersion.getProperty().getItem();
if (item != null) {
Object objectValueFromESB = service.getValue(item, repositoryValue, node);
if (objectValueFromESB != null) {
objectValue = objectValueFromESB;
}
}
}
}
}
}
if (param.getName().equals(EParameterName.CDC_TYPE_MODE.getName())) {
//
String propertyValue = (String) node.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
Item item = null;
IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(propertyValue);
if (lastVersion != null) {
item = lastVersion.getProperty().getItem();
}
if (item != null && PluginChecker.isCDCPluginLoaded()) {
ICDCProviderService service = (ICDCProviderService) GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
if (service != null) {
try {
List<IRepositoryViewObject> all;
all = CorePlugin.getDefault().getProxyRepositoryFactory().getAll(ERepositoryObjectType.METADATA_CONNECTIONS);
for (IRepositoryViewObject obj : all) {
Item tempItem = obj.getProperty().getItem();
if (tempItem instanceof DatabaseConnectionItem) {
String cdcLinkId = service.getCDCConnectionLinkId((DatabaseConnectionItem) tempItem);
if (cdcLinkId != null && item.getProperty().getId().equals(cdcLinkId)) {
objectValue = RepositoryToComponentProperty.getValue(((DatabaseConnectionItem) tempItem).getConnection(), repositoryValue, node.getMetadataList().get(0));
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IJsonFileService.class)) {
IJsonFileService jsonService = (IJsonFileService) GlobalServiceRegister.getDefault().getService(IJsonFileService.class);
boolean paramChanged = jsonService.changeFilePathFromRepository(connectionItem.getConnection(), param, node, objectValue);
if (paramChanged) {
continue;
}
}
if (objectValue != null) {
if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && repositoryValue.equals(UpdatesConstants.TYPE)) {
boolean found = false;
String[] items = param.getListRepositoryItems();
for (int i = 0; (i < items.length) && (!found); i++) {
if (objectValue.equals(items[i])) {
found = true;
node.setPropertyValue(param.getName(), param.getListItemsValue()[i]);
}
}
} else {
// update tFileInputExcel job
if (param.getFieldType().equals(EParameterFieldType.TABLE)) {
String name = param.getName();
if (name.equals("ROOT") || name.equals("LOOP") || name.equals("GROUP") && objectValue instanceof List) {
param.setValue(objectValue);
} else if (param.getName().equals("SHEETLIST") && objectValue instanceof List) {
List<Map<String, Object>> paramMaps = (List<Map<String, Object>>) param.getValue();
if (paramMaps == null) {
paramMaps = new ArrayList<Map<String, Object>>();
node.setPropertyValue(param.getName(), paramMaps);
} else {
// hywang add for 9537
List<Map<String, Object>> objectValueList = (List<Map<String, Object>>) objectValue;
if (paramMaps.size() < objectValueList.size()) {
paramMaps.clear();
for (int i = 0; i < objectValueList.size(); i++) {
Map<String, Object> map = objectValueList.get(i);
paramMaps.add(map);
}
} else {
String value = null;
List<String> repNames = new ArrayList<String>();
for (int i = 0; i < objectValueList.size(); i++) {
repNames.add(objectValueList.get(i).get("SHEETNAME").toString());
}
for (int j = 0; j < paramMaps.size(); j++) {
Map<String, Object> map = paramMaps.get(j);
value = map.get("SHEETNAME").toString();
if (!repNames.contains(value)) {
paramMaps.remove(j);
}
}
}
}
} else if ((name.equals("HADOOP_ADVANCED_PROPERTIES") || name.equals("ADVANCED_PROPERTIES") || name.equals("HBASE_PARAMETERS") || name.equals("SAP_PROPERTIES") && objectValue instanceof List)) {
List<HashMap<String, Object>> oldValue = (List<HashMap<String, Object>>) param.getValue();
for (HashMap<String, Object> map : oldValue) {
if (map.get("BUILDIN") != null && !map.get("BUILDIN").equals("") && Boolean.valueOf(String.valueOf(map.get("BUILDIN")))) {
((List<HashMap<String, Object>>) objectValue).add(map);
}
}
param.setValue(objectValue);
} else // it in jobs
if (param.getName().equals("DRIVER_JAR") && objectValue instanceof List) {
param.setValue(objectValue);
}
} else {
node.setPropertyValue(param.getName(), objectValue);
}
}
} else if (param.getFieldType().equals(EParameterFieldType.TABLE) && UpdatesConstants.XML_MAPPING.equals(repositoryValue)) {
RepositoryToComponentProperty.getTableXMLMappingValue(connectionItem.getConnection(), (List<Map<String, Object>>) param.getValue(), node);
} else if (param.getFieldType().equals(EParameterFieldType.TABLE) && param.getName().equals("PARAMS")) {
objectValue = RepositoryToComponentProperty.getValue(connectionItem.getConnection(), "PARAMS", node.getMetadataList().get(0));
List<Map<String, Object>> paramMaps = (List<Map<String, Object>>) param.getValue();
if (paramMaps == null) {
paramMaps = new ArrayList<Map<String, Object>>();
} else {
paramMaps.clear();
}
if (objectValue != null) {
List<String> objectValueList = (List<String>) objectValue;
for (int i = 0; i < objectValueList.size(); i++) {
Map<String, Object> map = new HashedMap();
map.put("VALUE", TalendTextUtils.addQuotes(objectValueList.get(i)));
paramMaps.add(map);
}
}
} else if (node.getComponentProperties() != null && objectValue == null) {
// for new framework, still save the null value in component
node.setPropertyValue(param.getName(), objectValue);
}
if (!("tMDMReceive".equals(node.getComponent().getName()) && "XPATH_PREFIX".equals(//$NON-NLS-1$ //$NON-NLS-2$
param.getRepositoryValue()))) {
param.setRepositoryValueUsed(true);
param.setReadOnly(true);
update = true;
}
}
}
} else {
// Added TDQ-11688 20170309 yyin
ITDQPatternService service = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQPatternService.class)) {
service = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
}
if (service != null && (service.isSinglePatternNode(node) || service.isMultiPatternNode(node)) && parameter != null && parameter instanceof IElementParameter) {
IElementParameter elementParameter = node.getElementParameter(((IElementParameter) parameter).getName());
if (elementParameter != null && !elementParameter.getValue().equals(((IElementParameter) parameter).getValue())) {
elementParameter.setValue(((IElementParameter) parameter).getValue());
}
update = true;
Object regexValue = null;
Object parameterValue = ((IElementParameter) parameter).getValue();
if ("PATTERN_REGEX".equals(((IElementParameter) parameter).getName())) {
regexValue = parameterValue;
} else if ("SCHEMA_PATTERN_CHECK".equals(((IElementParameter) parameter).getName())) {
List<Map<String, String>> multiPatternList = ((List<Map<String, String>>) parameterValue);
for (Map<String, String> patternMap : multiPatternList) {
regexValue = patternMap.get("PATTERN_REGEX");
if (regexValue == null) {
patternMap.put("PATTERN_PROPERTY", EmfComponent.BUILTIN);
}
}
}
if (regexValue == null || regexValue.toString().isEmpty()) {
update = false;
}
}
}
}
if (!update) {
// bult-in
String propertyName = parentParamName + ":" + EParameterName.PROPERTY_TYPE.getName();
if (this.result.getParameter() instanceof IElementParameter) {
IElementParameter parentParam = ((IElementParameter) this.result.getParameter()).getParentParameter();
if (parentParam != null) {
parentParamName = parentParam.getName();
propertyName = parentParam.getName() + ":" + parentParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).getName();
}
}
node.setPropertyValue(propertyName, EmfComponent.BUILTIN);
for (IElementParameter param : node.getElementParameters()) {
if (param.getRepositoryValue() == null || param.getRepositoryProperty() != null && !param.getRepositoryProperty().equals(parentParamName)) {
continue;
}
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
continue;
}
if (param.isShow(node.getElementParameters())) {
if (param.getName().equals(EParameterName.PROPERTY_TYPE.getName()) || param.getFieldType() == EParameterFieldType.MEMO_SQL) {
continue;
}
param.setRepositoryValueUsed(false);
param.setReadOnly(false);
}
}
}
}
}
Aggregations