use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class StatLogsAndImplicitcontextTreeViewPage method saveProcess.
private void saveProcess(RepositoryNode node, String paramName, Boolean isUseProjectSettings, boolean addContextModel, Map<String, Set<String>> contextVars, IProgressMonitor monitor) {
Property property = node.getObject().getProperty();
ProcessItem pItem = (ProcessItem) property.getItem();
ParametersType pType = pItem.getProcess().getParameters();
if (isOpenProcess(node)) {
Process process = getProcess(opendProcess, node);
LoadProjectSettingsCommand command = new LoadProjectSettingsCommand(process, paramName, isUseProjectSettings);
exeCommand(process, command);
Element elem = null;
String propertyName = "";
String propertyTypeName = "";
if (EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
elem = (Element) pro.getInitialContextLoad();
propertyName = JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()) + ':' + EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
propertyTypeName = JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()) + ':' + EParameterName.PROPERTY_TYPE.getName();
} else if (EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
elem = (Element) pro.getStatsAndLog();
propertyName = EParameterName.PROPERTY_TYPE.getName() + ':' + EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
propertyTypeName = EParameterName.PROPERTY_TYPE.getName() + ':' + EParameterName.PROPERTY_TYPE.getName();
}
IElementParameter ptParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
if (ptParam != null) {
IElementParameter propertyElem = ptParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
Object proValue = propertyElem.getValue();
if (proValue instanceof String && ((String) proValue).equalsIgnoreCase(EmfComponent.REPOSITORY)) {
IElementParameter repositoryElem = ptParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
String value = (String) repositoryElem.getValue();
ConnectionItem connectionItem = UpdateRepositoryUtils.getConnectionItemByItemId(value);
if (connectionItem != null) {
Connection connection = connectionItem.getConnection();
ChangeValuesFromRepository cmd = new ChangeValuesFromRepository(process, connection, addContextModel ? propertyName : propertyTypeName, value);
cmd.ignoreContextMode(true);
exeCommand(process, cmd);
}
}
}
monitor.worked(100);
} else {
ElementParameter2ParameterType.setParameterValue(pType, paramName, isUseProjectSettings);
if (isUseProjectSettings) {
if (EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
ProjectSettingManager.reloadImplicitValuesFromProjectSettings(pType, ProjectManager.getInstance().getCurrentProject());
} else if (EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
ProjectSettingManager.reloadStatsAndLogFromProjectSettings(pType, ProjectManager.getInstance().getCurrentProject());
}
}
if (addContextModel && contextVars != null && !contextVars.isEmpty() && ContextUtils.getAllContextItem() != null) {
ContextUtils.addInContextModelForProcessItem(pItem, contextVars, ContextUtils.getAllContextItem());
}
try {
factory.save(pItem);
monitor.worked(100);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class ProjectSettingMultipleThreadDynamicComposite method updateConnectionFromRepository.
private void updateConnectionFromRepository() {
if (repositoryPropertyName == null || repositoryPropertyName.split(":").length != 2 || connectionUpdated) {
return;
}
String[] split = repositoryPropertyName.split(":");
String parentParamName = split[0];
Element elementParams = elem;
IElementParameter elementParameter = elementParams.getElementParameter(parentParamName);
if (elementParameter != null && elementParameter.isShow(elem.getElementParameters()) && elementParameter.getChildParameters() != null) {
if (elementParameter.getChildParameters().get("PROPERTY_TYPE") != null && !EmfComponent.BUILTIN.equals(elementParameter.getChildParameters().get("PROPERTY_TYPE").getValue())) {
DatabaseConnection connection = null;
String id = (String) elementParameter.getChildParameters().get("REPOSITORY_PROPERTY_TYPE").getValue();
// bug 0018192
String propertyType = (String) elementParameter.getChildParameters().get("PROPERTY_TYPE").getValue();
ProxyRepositoryFactory proxyRepositoryFactory = ProxyRepositoryFactory.getInstance();
IRepositoryViewObject lastVersion = null;
if (null != id && !"".equals(id)) {
try {
lastVersion = proxyRepositoryFactory.getLastVersion(id);
if (null == lastVersion && propertyType.equals(EmfComponent.REPOSITORY)) {
List<ConnectionItem> connectionItems = proxyRepositoryFactory.getMetadataConnectionsItem();
if (connectionItems.isEmpty()) {
elem.setPropertyValue("REPOSITORY_PROPERTY_TYPE", "");
ChangeValuesFromRepository changeValuesFromRepository1 = new ChangeValuesFromRepository(elem, null, parentParamName + ":" + "PROPERTY_TYPE", EmfComponent.REPOSITORY);
changeValuesFromRepository1.execute();
}
for (ConnectionItem cItem : connectionItems) {
if (cItem instanceof DatabaseConnectionItem) {
id = cItem.getProperty().getId();
lastVersion = proxyRepositoryFactory.getLastVersion(id);
elem.setPropertyValue("REPOSITORY_PROPERTY_TYPE", id);
break;
}
}
}
} catch (PersistenceException e) {
e.printStackTrace();
}
} else {
try {
List<ConnectionItem> connectionItems = proxyRepositoryFactory.getMetadataConnectionsItem();
for (ConnectionItem cItem : connectionItems) {
if (cItem instanceof DatabaseConnectionItem) {
lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(cItem.getProperty().getId());
id = cItem.getProperty().getId();
lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(id);
elem.setPropertyValue("REPOSITORY_PROPERTY_TYPE", id);
break;
}
}
} catch (PersistenceException e) {
e.printStackTrace();
}
}
if (lastVersion != null && lastVersion.getProperty() != null) {
Item item = lastVersion.getProperty().getItem();
if (item instanceof DatabaseConnectionItem) {
DatabaseConnectionItem dbItem = (DatabaseConnectionItem) item;
connection = (DatabaseConnection) dbItem.getConnection();
}
}
if (connection != null) {
boolean sameValues = true;
for (IElementParameter param : elementParams.getElementParameters()) {
String repositoryValue = param.getRepositoryValue();
if (param.isShow(elementParams.getElementParameters()) && repositoryValue != null && !param.getName().equals("PROPERTY_TYPE")) {
Object repValue = RepositoryToComponentProperty.getValue(connection, repositoryValue, null);
if (repValue == null) {
continue;
}
if (repositoryValue.equals(UpdatesConstants.TYPE)) {
// datebase type
boolean found = false;
String[] list = param.getListRepositoryItems();
for (int i = 0; (i < list.length) && (!found); i++) {
if (repValue.equals(list[i])) {
found = true;
}
}
if (!found) {
sameValues = false;
break;
}
} else {
// check the value
if (!param.getValue().equals(repValue)) {
sameValues = false;
break;
}
}
}
}
if (!sameValues) {
ChangeValuesFromRepository changeValuesFromRepository = new ChangeValuesFromRepository(elem, connection, repositoryPropertyName, id);
changeValuesFromRepository.execute();
connectionUpdated = true;
}
}
// bug 0018192
// else {
// change to build in
// ChangeValuesFromRepository changeValuesFromRepository1 = new ChangeValuesFromRepository(elem,
// null,
// parentParamName + ":" + "PROPERTY_TYPE", EmfComponent.BUILTIN);
// changeValuesFromRepository1.execute();
// }
}
}
}
use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class GenericDragAndDropHandler method isValid.
private boolean isValid(RepositoryNode seletetedNode, IComponent component) {
// TUP-4151
IRepositoryViewObject object = seletetedNode.getObject();
if (component == null || object == null) {
return false;
}
ComponentProperties currentComponentProperties = null;
if (object instanceof RepositoryViewObject) {
RepositoryViewObject repositoryViewObj = (RepositoryViewObject) object;
Connection connection = ((ConnectionItem) repositoryViewObj.getProperty().getItem()).getConnection();
if (canHandle(connection)) {
GenericConnection genericConnection = (GenericConnection) connection;
currentComponentProperties = ComponentsUtils.getComponentPropertiesFromSerialized(genericConnection.getCompProperties(), connection);
}
} else if (object instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject metaTableRepObj = (MetadataTableRepositoryObject) object;
currentComponentProperties = SchemaUtils.getCurrentComponentProperties(metaTableRepObj);
} else if (object instanceof MetadataColumnRepositoryObject) {
MetadataColumnRepositoryObject metaColumnRepObj = (MetadataColumnRepositoryObject) object;
ModelElement element = metaColumnRepObj.getTdColumn();
if (element != null && element.eContainer() instanceof MetadataTable) {
MetadataTable metadataTable = (MetadataTable) element.eContainer();
IMetadataTable newTable = MetadataToolHelper.convert(metadataTable);
currentComponentProperties = SchemaUtils.getCurrentComponentProperties(newTable);
}
}
if (currentComponentProperties != null) {
try {
List<ComponentDefinition> possibleComponents = ComponentsUtils.getComponentService().getPossibleComponents(currentComponentProperties);
if (component instanceof Component) {
ComponentDefinition componentDefinition = ((Component) component).getComponentDefinition();
return possibleComponents.contains(componentDefinition);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
return false;
}
use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class EditPropertiesAction method doRun.
@Override
protected void doRun() {
ISelection selection = getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
IRepositoryNode node = (IRepositoryNode) obj;
// try {
// ProxyRepositoryFactory.getInstance().initialize();
// } catch (PersistenceException e1) {
// ExceptionHandler.process(e1);
// }
IRepositoryViewObject object = node.getObject();
IPath path = RepositoryNodeUtilities.getPath(node);
String originalName = object.getLabel();
final PropertiesWizard wizard;
if (ERepositoryObjectType.ROUTINES == object.getRepositoryObjectType() || isInstanceofCamelBeans(object.getRepositoryObjectType())) {
wizard = new EditRoutinePropertiesWizard(object, path, true);
} else if (ERepositoryObjectType.PROCESS == object.getRepositoryObjectType()) {
wizard = new EditProcessPropertiesWizard(object, path, true);
} else {
wizard = getPropertiesWizard(object, path);
}
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
if (dlg.open() == Window.OK) {
refresh(node);
// refresh the corresponding editor's name
IEditorPart part = getCorrespondingEditor(node);
if (part != null && part instanceof IUIRefresher) {
((IUIRefresher) part).refreshName();
} else {
processRoutineRenameOperation(originalName, node, path);
}
// rename the job launch, for bug 8878
IDesignerCoreService designerCoreService = RepositoryPlugin.getDefault().getDesignerCoreService();
if (designerCoreService != null) {
designerCoreService.renameJobLaunch(node.getObject(), originalName);
// TDI-24863:reset the job problem list if rename the job item
designerCoreService.resetJobProblemList(node.getObject(), originalName);
}
// refresh ...
IViewPart jobSettingView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IJobSettingsView.ID);
if (jobSettingView != null && jobSettingView instanceof IJobSettingsView) {
((IJobSettingsView) jobSettingView).refreshCurrentViewTab();
}
if (node.getObjectType() == ERepositoryObjectType.ROUTINES) {
RepositoryManager.syncRoutineAndJoblet(ERepositoryObjectType.ROUTINES);
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
if (talendProcessJavaProject != null) {
talendProcessJavaProject.updateRoutinesPom(true, true);
}
}
}
if (node.getObjectType().getType().equals("SERVICES")) {
//$NON-NLS-1$
ConnectionItem connectionItem = (ConnectionItem) node.getObject().getProperty().getItem();
RepositoryUpdateManager.updateServices(connectionItem);
if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
if (service != null) {
service.refreshComponentView(connectionItem);
}
}
}
}
}
use of org.talend.core.model.properties.ConnectionItem in project tdi-studio-se by Talend.
the class RepositoryTypeProcessor method selectRepositoryNode.
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
final String repositoryType = getRepositoryType();
if (node == null) {
return false;
}
if (node.getContentType() == ERepositoryObjectType.REFERENCED_PROJECTS) {
return true;
}
// for sub folders
if (node.getType() == ENodeType.STABLE_SYSTEM_FOLDER) {
return false;
}
// for Db Connections
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
// }
IRepositoryViewObject object = node.getObject();
if (object == null || object.getProperty().getItem() == null) {
return false;
}
if (object instanceof MetadataTable) {
return false;
}
Item item = object.getProperty().getItem();
if (item instanceof FolderItem) {
return true;
}
if (item instanceof ConnectionItem) {
ConnectionItem connectionItem = (ConnectionItem) item;
Connection connection = connectionItem.getConnection();
// tAdvancedFileOutputXML
if (repositoryType != null && repositoryType.equals(ERepositoryCategoryType.XMLOUTPUT.getName())) {
if (connection instanceof XmlFileConnection && ((XmlFileConnection) connection).isInputModel()) {
return false;
}
}
if (repositoryType.startsWith(ERepositoryCategoryType.DATABASE.getName())) {
//$NON-NLS-1$
String currentDbType = (String) RepositoryToComponentProperty.getValue(connection, "TYPE", null);
if (repositoryType.contains(":")) {
// database //$NON-NLS-1$
// is
// specified
// //$NON-NLS-1$
//$NON-NLS-1$
String neededDbType = repositoryType.substring(repositoryType.indexOf(":") + 1);
if (hidenTypeSelection) {
return true;
}
if (!MetadataTalendType.sameDBProductType(neededDbType, currentDbType)) {
return false;
}
}
}
}
if (repositoryType.startsWith(ERepositoryCategoryType.HEADERFOOTER.getName())) {
if (item instanceof HeaderFooterConnectionItem) {
HeaderFooterConnectionItem connectionItem = (HeaderFooterConnectionItem) item;
HeaderFooterConnection connection = (HeaderFooterConnection) connectionItem.getConnection();
boolean isHeader = connection.isIsHeader();
if ((isHeader && isHeaderButton) || (!isHeader && !isHeaderButton)) {
return true;
} else {
return false;
}
}
}
return true;
}
Aggregations