Search in sources :

Example 36 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.

the class DynamicTabbedPropertySection method updateProcessList.

/**
     * ftang Comment method "updateProcessList".
     */
private void updateProcessList() {
    List<String> processNameList = new ArrayList<String>();
    List<String> processValueList = new ArrayList<String>();
    processMap = new HashMap<String, IRepositoryViewObject>();
    IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
    try {
        RootContainer<String, IRepositoryViewObject> processContainer = factory.getMetadata(ERepositoryObjectType.PROCESS);
        ContentList<String, IRepositoryViewObject> processAbsoluteMembers = processContainer.getAbsoluteMembers();
        String currentProcess = part.getTalendEditor().getProcess().getLabel();
        for (Content<String, IRepositoryViewObject> object : processAbsoluteMembers.values()) {
            IRepositoryViewObject process = object.getContent();
            if (factory.getStatus(process) != ERepositoryStatus.DELETED && !currentProcess.equals(process.getLabel())) {
                String path = object.getParent().getPath().toString();
                String name;
                if (path.equals("")) {
                    //$NON-NLS-1$
                    name = IPath.SEPARATOR + process.getLabel();
                } else {
                    name = IPath.SEPARATOR + path + IPath.SEPARATOR + process.getLabel();
                }
                processNameList.add(name);
                processMap.put(name, process);
            }
        }
    } catch (PersistenceException e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
    List<String> tempFolderList = new ArrayList<String>();
    List<String> tempProcessNameList = new ArrayList<String>();
    tempProcessNameList.addAll(processNameList);
    for (String string : tempProcessNameList) {
        // Put jobs which in a folder into a new list.s
        if (string.lastIndexOf("/") != 0) {
            //$NON-NLS-1$
            tempFolderList.add(string);
            processNameList.remove(string);
        }
    }
    sortList(processNameList);
    sortList(tempFolderList);
    // Always put the jobs which in a folder on the top of the job list
    tempFolderList.addAll(processNameList);
    processNameList = tempFolderList;
    for (String name : processNameList) {
        IRepositoryViewObject process = processMap.get(name);
        processValueList.add(process.getLabel());
    }
    String[] processTableNameList = processNameList.toArray(new String[0]);
    String[] processTableValueList = processValueList.toArray(new String[0]);
    for (int i = 0; i < elem.getElementParameters().size(); i++) {
        IElementParameter param = elem.getElementParameters().get(i);
        if (param.getName().equals(EParameterName.PROCESS_TYPE_PROCESS.getName())) {
            param.setListItemsDisplayName(processTableNameList);
            param.setListItemsValue(processTableValueList);
            if (elem instanceof Node) {
                ((Node) elem).checkAndRefreshNode();
            }
        }
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 37 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.

the class DynamicTabbedPropertySection method updateContextList.

/**
     * ftang Comment method "updateContextList".
     */
private void updateContextList() {
    List<String> contextNameList = new ArrayList<String>();
    List<String> contextValueList = new ArrayList<String>();
    IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
    String selectedProcess = null;
    for (int i = 0; (i < elem.getElementParameters().size()) && (selectedProcess == null); i++) {
        IElementParameter param = elem.getElementParameters().get(i);
        if (param.getName().equals(EParameterName.PROCESS_TYPE_PROCESS.getName())) {
            selectedProcess = (String) param.getValue();
        }
    }
    if (selectedProcess == null) {
        return;
    }
    try {
        List<IRepositoryViewObject> list = factory.getAll(ERepositoryObjectType.PROCESS);
        for (IRepositoryViewObject process : list) {
            String id = process.getLabel();
            if (selectedProcess.equals(id)) {
                if (process.getProperty().getItem() instanceof ProcessItem) {
                    ProcessItem processItem = (ProcessItem) process.getProperty().getItem();
                    for (Object o : processItem.getProcess().getContext()) {
                        if (o instanceof ContextType) {
                            ContextType context = (ContextType) o;
                            contextNameList.add(context.getName());
                            contextValueList.add(context.getName());
                        }
                    }
                }
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    String[] contextTableNameList = contextNameList.toArray(new String[0]);
    String[] contextTableValueList = contextValueList.toArray(new String[0]);
    for (int i = 0; i < elem.getElementParameters().size(); i++) {
        IElementParameter param = elem.getElementParameters().get(i);
        if (param.getName().equals(EParameterName.PROCESS_TYPE_CONTEXT.getName())) {
            param.setListItemsDisplayName(contextTableNameList);
            param.setListItemsValue(contextTableValueList);
            if (!contextValueList.contains(param.getValue())) {
                if (contextTableNameList.length > 0) {
                    elem.setPropertyValue(EParameterName.PROCESS_TYPE_CONTEXT.getName(), contextTableValueList[0]);
                }
            } else {
                // force to store the value again to activate the code
                // generation in Node.setPropertyValue
                elem.setPropertyValue(EParameterName.PROCESS_TYPE_CONTEXT.getName(), param.getValue());
            }
        }
    }
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 38 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.

the class StatsAndLogsHelper method changeRepositoryConnection.

static void changeRepositoryConnection(Element process, StatsAndLogsComposite statsComposite) {
    String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName());
    String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
    Connection repositoryConnection = null;
    /* 16969 */
    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;
    }
    ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
    propertyType);
    ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
    id);
    AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).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);
        }
    }
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) CommandStack(org.eclipse.gef.commands.CommandStack) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ConnectionItem(org.talend.core.model.properties.ConnectionItem) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Connection(org.talend.core.model.metadata.builder.connection.Connection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 39 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.

the class ProjectSettingManager method changeImplicitContextRepositoryItem.

static void changeImplicitContextRepositoryItem(Element process, ExtraComposite extraComposite) {
    // change repository item
    String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()));
    String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
    Connection repositoryConnection = null;
    /* 16969 */
    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;
    }
    ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
    propertyType);
    ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
    id);
    AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).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);
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) CommandStack(org.eclipse.gef.commands.CommandStack) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ConnectionItem(org.talend.core.model.properties.ConnectionItem) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Connection(org.talend.core.model.metadata.builder.connection.Connection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 40 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.

the class NewProcessWizardPage method loadRepViewObjectWithOtherTypes.

@Override
protected List<IRepositoryViewObject> loadRepViewObjectWithOtherTypes() throws PersistenceException {
    List<IRepositoryViewObject> list = new ArrayList<IRepositoryViewObject>();
    // List for all other processes
    List<IRepositoryViewObject> processList = getAllProcessTypeObjectsWithoutCurrentType();
    if (processList != null && !processList.isEmpty()) {
        list.addAll(processList);
    }
    // List for routine
    if (ERepositoryObjectType.ROUTINES != null) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
            IProxyRepositoryService service = (IProxyRepositoryService) GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class);
            List<IRepositoryViewObject> mrList = service.getProxyRepositoryFactory().getAll(ERepositoryObjectType.ROUTINES, true, false);
            if (mrList != null && mrList.size() > 0) {
                list.addAll(mrList);
            }
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProxyRepositoryService(org.talend.repository.model.IProxyRepositoryService)

Aggregations

IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)222 PersistenceException (org.talend.commons.exception.PersistenceException)115 Item (org.talend.core.model.properties.Item)86 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)67 ArrayList (java.util.ArrayList)63 ConnectionItem (org.talend.core.model.properties.ConnectionItem)54 ProcessItem (org.talend.core.model.properties.ProcessItem)54 RepositoryNode (org.talend.repository.model.RepositoryNode)50 IElementParameter (org.talend.core.model.process.IElementParameter)43 Property (org.talend.core.model.properties.Property)43 IRepositoryNode (org.talend.repository.model.IRepositoryNode)33 List (java.util.List)32 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)32 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)31 INode (org.talend.core.model.process.INode)30 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)25 Node (org.talend.designer.core.ui.editor.nodes.Node)25 Connection (org.talend.core.model.metadata.builder.connection.Connection)23 CoreException (org.eclipse.core.runtime.CoreException)17 RoutineItem (org.talend.core.model.properties.RoutineItem)17