Search in sources :

Example 16 with IRepositoryNode

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

the class GenerateSelectSQLAction method init.

//$NON-NLS-1$
@SuppressWarnings("unchecked")
public void init() {
    selectedNodes.clear();
    IStructuredSelection structuredSelection = (IStructuredSelection) provider.getSelection();
    for (int i = 0; i < structuredSelection.toList().size(); i++) {
        RepositoryNode repositoryNode = (RepositoryNode) structuredSelection.toList().get(i);
        if (SQLBuilderRepositoryNodeManager.getRepositoryType(repositoryNode) == RepositoryNodeType.FOLDER) {
            this.setEnabled(false);
            return;
        }
        RepositoryNode rootNode = SQLBuilderRepositoryNodeManager.getRoot(repositoryNode);
        if (!selectedNodes.isEmpty() && selectedNodes.get(0) != null && !rootNode.equals(SQLBuilderRepositoryNodeManager.getRoot((RepositoryNode) selectedNodes.get(0)))) {
            setEnabled(false);
            return;
        }
        selectedNodes.add(repositoryNode);
    }
    if (selectedNodes.isEmpty()) {
        this.setEnabled(false);
        return;
    }
    this.setEnabled(true);
    for (IRepositoryNode node : selectedNodes) {
        Object type = node.getProperties(EProperties.CONTENT_TYPE);
        if (type != RepositoryNodeType.COLUMN && type != RepositoryNodeType.TABLE && type != RepositoryNodeType.DATABASE) {
            setEnabled(false);
            break;
        }
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) MetadataTableRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject) SqlBuilderRepositoryObject(org.talend.sqlbuilder.dbstructure.SqlBuilderRepositoryObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 17 with IRepositoryNode

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

the class GenerateSelectSQLAction method getTablePrefix.

private String getTablePrefix(IRepositoryNode node) {
    RepositoryNode root = SQLBuilderRepositoryNodeManager.getRoot((RepositoryNode) node);
    DatabaseConnection connection = (DatabaseConnection) ((ConnectionItem) root.getObject().getProperty().getItem()).getConnection();
    if (connection.getUiSchema() != null && !connection.getUiSchema().trim().equals("")) {
        //$NON-NLS-1$
        return connection.getUiSchema();
    } else {
        //$NON-NLS-1$
        return "";
    }
}
Also used : DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 18 with IRepositoryNode

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

the class GenerateSelectSQLAction method getPrePostfix.

/**
     * Get Prepostfix.
     * 
     * @param node the selected node
     * @return PrePostfix
     */
private String getPrePostfix(IRepositoryNode node) {
    RepositoryNode root = SQLBuilderRepositoryNodeManager.getRoot((RepositoryNode) node);
    DatabaseConnection connection = (DatabaseConnection) ((ConnectionItem) root.getObject().getProperty().getItem()).getConnection();
    if (TextUtil.isDoubleQuotesNeededDbType(connection.getDatabaseType())) {
        //$NON-NLS-1$
        return "\"";
    }
    //$NON-NLS-1$
    return "";
}
Also used : DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 19 with IRepositoryNode

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

the class JobVersionUtilsTest method testGetCurrentVersion.

/**
     * Test method for
     * {@link org.talend.repository.utils.JobVersionUtils#getCurrentVersion(org.talend.repository.model.RepositoryNode)}
     * .
     * 
     * @throws PersistenceException
     */
@Test
public void testGetCurrentVersion() throws PersistenceException {
    repositoryObject = createRepositoryObject("job1");
    RepositoryNode childrenNode = mock(RepositoryNode.class);
    when(childrenNode.getObject()).thenReturn(repositoryObject);
    when(childrenNode.getId()).thenReturn(repositoryObject.getProperty().getId());
    List<IRepositoryNode> children = new ArrayList<IRepositoryNode>();
    children.add(childrenNode);
    RepositoryNode folderNode = mock(RepositoryNode.class);
    when(folderNode.getObject()).thenReturn(folder);
    when(folderNode.getId()).thenReturn(folder.getId());
    when(folderNode.getChildren()).thenReturn(children);
    // test,one situation
    String vesion = JobVersionUtils.getCurrentVersion(folderNode);
    assertEquals(vesion, "0.1");
    // test,two situation
    repositoryObject.getProperty().setVersion("0.2");
    String vesion2 = JobVersionUtils.getCurrentVersion(folderNode);
    assertEquals(vesion2, "0.2");
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Test(org.junit.Test)

Example 20 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.

the class JavaCamelJobScriptsExportWSAction method exportAllReferenceRoutelets.

@SuppressWarnings("unchecked")
protected final void exportAllReferenceRoutelets(String routeName, ProcessItem routeProcess, Set<String> routelets) throws InvocationTargetException, InterruptedException {
    for (NodeType node : (Collection<NodeType>) routeProcess.getProcess().getNode()) {
        if (!EmfModelUtils.isComponentActive(node)) {
            continue;
        }
        final ElementParameterType routeletId = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_PROCESS.getName(), node);
        if (null != routeletId) {
            final IRepositoryNode referencedRouteletNode;
            try {
                referencedRouteletNode = getJobRepositoryNode(routeletId.getValue(), CamelRepositoryNodeType.repositoryRouteletType);
            // getRouteletRepositoryNode(routeletId);
            } catch (PersistenceException e) {
                throw new InvocationTargetException(e);
            }
            final ProcessItem routeletProcess = (ProcessItem) referencedRouteletNode.getObject().getProperty().getItem();
            final String className = RouteJavaScriptOSGIForESBManager.getClassName(routeletProcess);
            String idSuffix = "-" + routeName;
            if (!routelets.add(className + idSuffix)) {
                continue;
            }
            String routeletVersion = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_VERSION.getName(), node).getValue();
            if (RelationshipItemBuilder.LATEST_VERSION.equals(routeletVersion)) {
                routeletVersion = referencedRouteletNode.getObject().getVersion();
            }
            final File routeletFile;
            try {
                routeletFile = File.createTempFile("routelet", FileConstants.JAR_FILE_SUFFIX, //$NON-NLS-1$
                new File(getTempDir()));
            } catch (IOException e) {
                throw new InvocationTargetException(e);
            }
            String routeletName = referencedRouteletNode.getObject().getLabel();
            String routeletBundleName = routeName + "_" + routeletName;
            String routeletBundleSymbolicName = routeletBundleName;
            Project project = ProjectManager.getInstance().getCurrentProject();
            if (project != null) {
                String projectName = project.getLabel();
                if (projectName != null && projectName.length() > 0) {
                    routeletBundleSymbolicName = projectName.toLowerCase() + '.' + routeletBundleSymbolicName;
                }
            }
            BundleModel routeletModel = new BundleModel(getGroupId(), routeletBundleName, getArtifactVersion(), routeletFile);
            if (featuresModel.addBundle(routeletModel)) {
                exportRouteBundle(referencedRouteletNode, routeletFile, routeletVersion, routeletBundleName, routeletBundleSymbolicName, bundleVersion, idSuffix, null, EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_CONTEXT.getName(), node).getValue());
                CamelFeatureUtil.addFeatureAndBundles(routeletProcess, featuresModel);
                exportAllReferenceRoutelets(routeName, routeletProcess, routelets);
            }
        }
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) Project(org.talend.core.model.general.Project) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ProcessItem(org.talend.core.model.properties.ProcessItem) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) CamelRepositoryNodeType(org.talend.camel.model.CamelRepositoryNodeType) PersistenceException(org.talend.commons.exception.PersistenceException) BundleModel(org.talend.designer.publish.core.models.BundleModel) Collection(java.util.Collection) IOException(java.io.IOException) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

IRepositoryNode (org.talend.repository.model.IRepositoryNode)73 RepositoryNode (org.talend.repository.model.RepositoryNode)24 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)21 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)13 PersistenceException (org.talend.commons.exception.PersistenceException)13 ArrayList (java.util.ArrayList)12 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 WizardDialog (org.eclipse.jface.wizard.WizardDialog)10 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 IEditorPart (org.eclipse.ui.IEditorPart)8 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)8 ISelection (org.eclipse.jface.viewers.ISelection)6 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)6 ProcessItem (org.talend.core.model.properties.ProcessItem)6 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)6 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)6 IRepositoryView (org.talend.repository.ui.views.IRepositoryView)6 IPath (org.eclipse.core.runtime.IPath)5 PartInitException (org.eclipse.ui.PartInitException)5 Item (org.talend.core.model.properties.Item)5