use of org.talend.core.IESBService in project tdi-studio-se by Talend.
the class RepositoryTypeProcessor method getType.
@Override
protected ERepositoryObjectType getType() {
final String repositoryType = getRepositoryType();
if (repositoryType == null) {
// all
return ERepositoryObjectType.METADATA;
}
if (repositoryType.equals(ERepositoryCategoryType.DELIMITED.getName())) {
return ERepositoryObjectType.METADATA_FILE_DELIMITED;
}
if (repositoryType.equals(ERepositoryCategoryType.POSITIONAL.getName())) {
return ERepositoryObjectType.METADATA_FILE_POSITIONAL;
}
if (repositoryType.equals(ERepositoryCategoryType.REGEX.getName())) {
return ERepositoryObjectType.METADATA_FILE_REGEXP;
}
if (repositoryType.equals(ERepositoryCategoryType.XML.getName()) || repositoryType.equals(ERepositoryCategoryType.XMLOUTPUT.getName())) {
return ERepositoryObjectType.METADATA_FILE_XML;
}
if (repositoryType.equals(ERepositoryCategoryType.LDIF.getName())) {
return ERepositoryObjectType.METADATA_FILE_LDIF;
}
if (repositoryType.equals(ERepositoryCategoryType.EXCEL.getName())) {
return ERepositoryObjectType.METADATA_FILE_EXCEL;
}
if (repositoryType.equals(ERepositoryCategoryType.GENERIC.getName())) {
return ERepositoryObjectType.METADATA_GENERIC_SCHEMA;
}
if (repositoryType.equals(ERepositoryCategoryType.LDAP.getName())) {
return ERepositoryObjectType.METADATA_LDAP_SCHEMA;
}
if (repositoryType.equals(ERepositoryCategoryType.WSDL.getName())) {
return ERepositoryObjectType.METADATA_WSDL_SCHEMA;
}
if (repositoryType.equals(ERepositoryCategoryType.SALESFORCE.getName())) {
return ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA;
}
if (repositoryType.startsWith(ERepositoryCategoryType.DATABASE.getName())) {
return ERepositoryObjectType.METADATA_CONNECTIONS;
}
if (repositoryType.startsWith(ERepositoryCategoryType.SAP.getName())) {
return ERepositoryObjectType.METADATA_SAPCONNECTIONS;
}
if (repositoryType.startsWith(ERepositoryCategoryType.HEADERFOOTER.getName())) {
return ERepositoryObjectType.METADATA_HEADER_FOOTER;
}
if (repositoryType.equals(ERepositoryCategoryType.EBCDIC.getName())) {
return ERepositoryObjectType.METADATA_FILE_EBCDIC;
}
if (repositoryType.equals(ERepositoryCategoryType.MDM.getName())) {
return ERepositoryObjectType.METADATA_MDMCONNECTION;
}
if (repositoryType.equals(ERepositoryCategoryType.FTP.getName())) {
return ERepositoryObjectType.METADATA_FILE_FTP;
}
if (repositoryType.equals(ERepositoryCategoryType.BRMS.getName())) {
return ERepositoryObjectType.METADATA_FILE_BRMS;
}
if (repositoryType.equals(ERepositoryCategoryType.HL7.getName())) {
return ERepositoryObjectType.METADATA_FILE_HL7;
}
// added by hyWang
if (repositoryType.equals(ERepositoryCategoryType.RULE.getName())) {
return ERepositoryObjectType.METADATA_FILE_RULES;
}
if (repositoryType.equals(ERepositoryCategoryType.VALIDATIONRULES.getName())) {
return ERepositoryObjectType.METADATA_VALIDATION_RULES;
}
if (repositoryType.equals(ERepositoryCategoryType.EDIFACT.getName())) {
return ERepositoryObjectType.METADATA_EDIFACT;
}
// http://jira.talendforge.org/browse/TESB-5218 LiXiaopeng
if (repositoryType.equals("SERVICES:OPERATION") || repositoryType.equals("WEBSERVICE")) {
//$NON-NLS-1$
if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
return service.getServicesType();
}
}
// try to use the repositoryType as a key for ERepoObjType, this avoid all the if above that are not extensible
// friendly.
ERepositoryObjectType eRepositoryObjectType = ERepositoryObjectType.getTypeFromKey(repositoryType);
if (eRepositoryObjectType != null) {
return eRepositoryObjectType;
}
return null;
}
use of org.talend.core.IESBService in project tdi-studio-se by Talend.
the class ControllerRepositoryValueHander method fastRepositoryUpdateProperty.
private void fastRepositoryUpdateProperty(IElementParameter param) {
if (param != null && param.getValue() != null) {
IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
String linkedRepository = (String) param.getValue();
// value stored is the id, so we can get this item directly
Item item;
String displayName = "";
try {
IRepositoryViewObject object = factory.getLastVersion(linkedRepository.split(" - ")[0]);
if (object == null) {
return;
}
item = object.getProperty().getItem();
// Assert.isTrue(item instanceof ConnectionItem);
IESBService service = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
}
if (service != null && ERepositoryObjectType.getItemType(item) == service.getServicesType()) {
lastItemUsed = (ConnectionItem) item;
displayName = "Service:" + service.getServiceLabel(item, linkedRepository);
} else if (item instanceof ConnectionItem) {
lastItemUsed = (ConnectionItem) item;
displayName = //$NON-NLS-1$
RepositoryObjectHelper.getRepositoryAliasName(lastItemUsed) + ":" + lastItemUsed.getProperty().getLabel();
}
if (item instanceof FileItem) {
// hywang add for 6484
lastFileItemUsed = (FileItem) item;
if (lastFileItemUsed instanceof RulesItem) {
displayName = //$NON-NLS-1$
"Rules:" + lastFileItemUsed.getProperty().getLabel();
}
}
if (item instanceof LinkRulesItem) {
lastLinkItem = (LinkRulesItem) item;
displayName = //$NON-NLS-1$
"Rules:" + lastLinkItem.getProperty().getLabel();
}
if (StringUtils.isEmpty(displayName)) {
ITDQPatternService tdqService = null;
try {
tdqService = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
if (tdqService != null) {
displayName = tdqService.getPatternDisplayName(item);
}
} catch (RuntimeException e) {
// nothing to do
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
param.setListItemsDisplayName(new String[] { displayName });
param.setListItemsValue(new String[] { (String) param.getValue() });
}
}
use of org.talend.core.IESBService 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);
}
}
}
}
}
use of org.talend.core.IESBService in project tdi-studio-se by Talend.
the class PropertyTypeController method createButtonCommand.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController#createControl(org.eclipse
* .swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
* org.eclipse.swt.widgets.Control)
*/
@Override
protected Command createButtonCommand(Button button) {
// hwang add for feature 6484
FileItem repositoryFileItem = null;
LinkRulesItem linkItem = null;
Map<String, FileItem> repositoryFileItemMap = null;
Map<String, LinkRulesItem> repositoryLinkRulesItemMap = null;
String paramName = (String) button.getData(PARAMETER_NAME);
IElementParameter param = elem.getElementParameter(paramName);
Object data = button.getData(NAME);
if (data != null && data.equals(REPOSITORY_CHOICE)) {
IElementParameter dbTypeParam = null;
if (elem instanceof org.talend.designer.core.ui.editor.process.Process || elem instanceof StatsAndLogsElement || elem instanceof ImplicitContextLoadElement) {
if (EParameterName.PROPERTY_TYPE.getName().equals(paramName)) {
dbTypeParam = elem.getElementParameter(EParameterName.DB_TYPE.getName());
} else if (JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()).equals(paramName)) {
dbTypeParam = elem.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName()));
}
}
Item item = null;
String id = null;
RepositoryNode selectNode = null;
if (id == null) {
RepositoryReviewDialog dialog = null;
if (dbTypeParam != null) {
String[] listRepositoryItems = dbTypeParam.getListRepositoryItems();
dialog = new RepositoryReviewDialog(Display.getCurrent().getActiveShell(), ERepositoryObjectType.METADATA, param.getRepositoryValue(), listRepositoryItems);
} else {
// Added TDQ-11688
ITDQPatternService service = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQPatternService.class)) {
service = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
}
if (service != null && service.isSinglePatternNode(elem)) {
return processPattern(elem);
}
// ~
dialog = new RepositoryReviewDialog(Display.getCurrent().getActiveShell(), ERepositoryObjectType.METADATA, elem, param);
}
if (dialog.open() == RepositoryReviewDialog.OK) {
selectNode = dialog.getResult();
id = selectNode.getObject().getId();
}
}
if (id != null && !"".equals(id)) {
//$NON-NLS-1$
IElementParameter repositoryParam = param.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
//$NON-NLS-1$
String fullParamName = paramName + ":" + getRepositoryChoiceParamName();
Connection repositoryConnection = null;
// Map<String, ConnectionItem> repositoryConnectionItemMap =
// dynamicProperty.getRepositoryConnectionItemMap();
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property property = repobj.getProperty();
if (property != null) {
item = property.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null) {
if (item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
}
} else {
repositoryConnection = null;
if (repositoryParam != null) {
item = selectNode.getObject().getProperty().getItem();
if (item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
}
}
}
if (repositoryConnection != null) {
CompoundCommand compoundCommand = new CompoundCommand();
ChangeValuesFromRepository changeValuesFromRepository = null;
if (selectNode.getObjectType() == ERepositoryObjectType.SERVICESOPERATION && GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
IProcess2 process = (IProcess2) RepositoryPlugin.getDefault().getDesignerCoreService().getCurrentProcess();
String currentJobId = process.getProperty().getId();
String serviceId = item.getProperty().getId();
String portId = selectNode.getParent().getObject().getId();
String operationId = selectNode.getObject().getId();
changeValuesFromRepository = new ChangeValuesFromRepository(elem, repositoryConnection, param.getName() + ":" + //$NON-NLS-1$
EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$ //$NON-NLS-2$
serviceId + " - " + portId + " - " + operationId);
service.deleteOldRelation(currentJobId);
//$NON-NLS-1$ //$NON-NLS-2$
service.updateOperation((INode) elem, serviceId + " - " + portId + " - " + operationId, selectNode);
} else {
changeValuesFromRepository = new ChangeValuesFromRepository(elem, repositoryConnection, fullParamName, id);
}
if (changeValuesFromRepository != null) {
compoundCommand.add(changeValuesFromRepository);
}
updateDBType(compoundCommand, repositoryConnection);
return compoundCommand;
}
// for ruleItem,hywang add
if (dynamicProperty instanceof MultipleThreadDynamicComposite) {
repositoryFileItemMap = ((MultipleThreadDynamicComposite) dynamicProperty).getRepositoryFileItemMap();
repositoryLinkRulesItemMap = ((MultipleThreadDynamicComposite) dynamicProperty).getRepositoryLinkRulesItemMap();
}
if (repositoryFileItemMap.containsKey(id)) {
repositoryFileItem = repositoryFileItemMap.get(id);
} else if (repositoryLinkRulesItemMap.containsKey(id)) {
linkItem = repositoryLinkRulesItemMap.get(id);
} else {
if (!repositoryFileItemMap.isEmpty()) {
repositoryFileItem = repositoryFileItemMap.values().iterator().next();
} else {
repositoryFileItem = null;
}
}
if (repositoryFileItem == null && item instanceof FileItem) {
repositoryFileItem = (FileItem) item;
}
if (repositoryFileItem != null) {
CompoundCommand compoundCommand = new CompoundCommand();
final String showId = repositoryFileItem.getProperty().getId();
Command command = new PropertyChangeCommand(elem, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
compoundCommand.add(command);
return compoundCommand;
}
if (linkItem != null) {
CompoundCommand compoundCommand = new CompoundCommand();
final String showId = linkItem.getProperty().getId();
Command command = new PropertyChangeCommand(elem, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
compoundCommand.add(command);
return compoundCommand;
}
}
} else {
// 1. open wizard
if (elem instanceof INode) {
INode node = (INode) elem;
final IRepositoryService repositoryService = CorePlugin.getDefault().getRepositoryService();
if (param != null) {
RepositoryNode realNode = null;
String repositoryValue = param.getRepositoryValue();
if (repositoryValue != null && repositoryValue.startsWith(ERepositoryCategoryType.DATABASE.getName())) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_CONNECTIONS);
} else // file delimited
if (ERepositoryCategoryType.DELIMITED.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_DELIMITED);
}
// file positional
if (ERepositoryCategoryType.POSITIONAL.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_POSITIONAL);
}
// file regexp
if (ERepositoryCategoryType.REGEX.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_REGEXP);
}
// file xml
if (ERepositoryCategoryType.XML.getName().equals(repositoryValue) || // bug 18012
repositoryValue.startsWith(ERepositoryCategoryType.XML.getName())) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_XML);
}
// file ldif
if (ERepositoryCategoryType.LDIF.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_LDIF);
}
// excel
if (ERepositoryCategoryType.EXCEL.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_EXCEL);
}
// generic schema
if (ERepositoryCategoryType.GENERIC.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_GENERIC_SCHEMA);
}
// ldap
if (ERepositoryCategoryType.LDAP.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_LDAP_SCHEMA);
}
// wsdl
if (ERepositoryCategoryType.WSDL.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_WSDL_SCHEMA);
}
if (ERepositoryCategoryType.WEBSERVICE.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_WSDL_SCHEMA);
}
// salesforce
if (ERepositoryCategoryType.SALESFORCE.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA);
}
// ebcdic
if (ERepositoryCategoryType.EBCDIC.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_EBCDIC);
}
// mdm
if (ERepositoryCategoryType.MDM.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_MDMCONNECTION);
}
// sap
if (ERepositoryCategoryType.SAP.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_SAPCONNECTIONS);
}
// sapIDoc
if (ERepositoryCategoryType.SAPIDOC.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_SAP_IDOC);
}
if (ERepositoryCategoryType.HEADERFOOTER.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_HEADER_FOOTER);
}
// brms
if (ERepositoryCategoryType.BRMS.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_BRMS);
}
// hl7
if (ERepositoryCategoryType.HL7.getName().equals(repositoryValue)) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_HL7);
}
// last resort we assume that the repository value was named after the root component type key
if (realNode == null) {
realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.getTypeFromKey(repositoryValue));
}
if (realNode != null) {
final IMetadataService metadataService = CorePlugin.getDefault().getMetadataService();
if (metadataService != null) {
ConnectionItem connItem = metadataService.openMetadataConnection(true, realNode, node);
if (connItem != null) {
IElementParameter propertyParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
// 2. commnd
Command cmd = new ChangeValuesFromRepository(node, connItem.getConnection(), //$NON-NLS-1$
propertyParam.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), connItem.getProperty().getId());
executeCommand(cmd);
// see bug in feature 5998.refresh repositoryList.
if (dynamicProperty instanceof MultipleThreadDynamicComposite) {
((MultipleThreadDynamicComposite) dynamicProperty).updateRepositoryList();
}
}
}
}
}
}
}
return null;
}
use of org.talend.core.IESBService in project tesb-studio-se by Talend.
the class LocalWSDLEditor method save.
private void save() {
try {
saveModel();
// update
RepositoryUpdateManager.updateServices(serviceItem);
ProxyRepositoryFactory.getInstance().save(serviceItem);
if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
if (service != null) {
service.refreshComponentView(serviceItem);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
// ////////// TODO: remove this ugly patch! do correct changeset
EList<ServicePort> servicePorts = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
for (ServicePort servicePort : servicePorts) {
List<IRepositoryNode> portNodes = repositoryNode.getChildren();
IRepositoryNode portNode = null;
for (IRepositoryNode node : portNodes) {
if (node.getObject().getLabel().equals(servicePort.getName())) {
portNode = node;
}
}
if (portNode == null) {
// for now, if the port has been renamed, we just lose all links (avoid an NPE for nothing)
continue;
}
EList<ServiceOperation> operations = servicePort.getServiceOperation();
for (ServiceOperation operation : operations) {
String referenceJobId = operation.getReferenceJobId();
if (referenceJobId != null) {
for (IRepositoryNode operationNode : portNode.getChildren()) {
if (operationNode.getObject().getLabel().startsWith(operation.getName() + '-')) {
IRepositoryNode jobNode = org.talend.core.repository.seeker.RepositorySeekerManager.getInstance().searchRepoViewNode(referenceJobId, false);
AssignJobAction action = new AssignJobAction((RepositoryNode) operationNode);
action.assign(jobNode);
break;
}
}
}
}
}
}
Aggregations