Search in sources :

Example 61 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class JavaProcessorUtilitiesTest method testComputeLibrariesPath.

@Test
public void testComputeLibrariesPath() {
    boolean headless = CommonsPlugin.isHeadless();
    try {
        CommonsPlugin.setHeadless(true);
        IComponent tFixedFlowComponent = ComponentsFactoryProvider.getInstance().get("tFixedFlowInput", ComponentCategory.CATEGORY_4_DI.getName());
        IComponent tLogRowComponent = ComponentsFactoryProvider.getInstance().get("tLogRow", ComponentCategory.CATEGORY_4_DI.getName());
        Property property = PropertiesFactory.eINSTANCE.createProperty();
        //$NON-NLS-1$
        property.setId("property");
        //$NON-NLS-1$
        property.setVersion("0.1");
        //$NON-NLS-1$
        property.setLabel("test");
        Process process = new Process(property);
        Node tFixedFlowInput_1 = new Node(tFixedFlowComponent, process);
        createMetadataColumns(tFixedFlowInput_1.getMetadataList().get(0), 1);
        Node tLogRow_1 = new Node(tLogRowComponent, process);
        createMetadataColumns(tLogRow_1.getMetadataList().get(0), 1);
        process.addNodeContainer(new NodeContainer(tFixedFlowInput_1));
        process.addNodeContainer(new NodeContainer(tLogRow_1));
        new Connection(tFixedFlowInput_1, tLogRow_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tFixedFlowInput_1", "row1", "row1", false);
        Set<ModuleNeeded> neededLibraries = CorePlugin.getDefault().getDesignerCoreService().getNeededLibrariesForProcess(process, false);
        try {
            JavaProcessorUtilities.computeLibrariesPath(neededLibraries, process, new HashSet<ModuleNeeded>());
        } catch (ProcessorException e) {
            fail("computeLibrariesPath failed for process test{tFixedFlowInput->tLogRow}");
        }
    } finally {
        CommonsPlugin.setHeadless(headless);
    }
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) Connection(org.talend.designer.core.ui.editor.connections.Connection) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Property(org.talend.core.model.properties.Property) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Test(org.junit.Test)

Example 62 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class RunProcessContextTest method testLoadLog4jContextFromProcess.

@Test
public void testLoadLog4jContextFromProcess() {
    Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    //$NON-NLS-1$
    property1.setId("property1");
    //$NON-NLS-1$
    property1.setVersion("0.1");
    //$NON-NLS-1$
    property1.setLabel("job1");
    Process process = new Process(property1);
    IComponent tMysqlInputComponent = //$NON-NLS-1$
    ComponentsFactoryProvider.getInstance().get(//$NON-NLS-1$
    "tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
    Node tMysqlInput_1 = new Node(tMysqlInputComponent, process);
    process.addNodeContainer(new NodeContainer(tMysqlInput_1));
    RunProcessContext context = new RunProcessContext(process);
    Assert.assertFalse(context.isUseCustomLevel());
    //$NON-NLS-1$
    Assert.assertEquals("", context.getLog4jLevel());
    //
    process.getElementParameter(EParameterName.LOG4J_RUN_ACTIVATE.getName()).setValue(true);
    //$NON-NLS-1$
    process.getElementParameter(EParameterName.LOG4J_RUN_LEVEL.getName()).setValue("Info");
    context.loadLog4jContextFromProcess();
    Assert.assertTrue(context.isUseCustomLevel());
    //$NON-NLS-1$
    Assert.assertEquals("Info", context.getLog4jLevel());
}
Also used : RunProcessContext(org.talend.designer.runprocess.RunProcessContext) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 63 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class RepositoryUpdateTest method createBasicConnection.

/**
     * DOC nrousseau Comment method "createBasicConnection".
     * 
     * @param id
     * @return
     * @throws PersistenceException
     */
private GenericConnectionItem createBasicConnection(String id) throws PersistenceException {
    GenericConnection connection = GenericMetadataFactory.eINSTANCE.createGenericConnection();
    Property connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
    // ses the id to be used for persistence lookup
    connectionProperty.setId(id);
    connectionProperty.setAuthor(((RepositoryContext) CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
    connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
    //$NON-NLS-1$
    connectionProperty.setStatusCode("");
    connectionProperty.setLabel("test");
    GenericConnectionItem connectionItem = GenericMetadataFactory.eINSTANCE.createGenericConnectionItem();
    connectionItem.setProperty(connectionProperty);
    connectionItem.setConnection(connection);
    connectionItem.setTypeName("salesforce");
    ProxyRepositoryFactory.getInstance().create(connectionItem, new Path(""));
    return connectionItem;
}
Also used : Path(org.eclipse.core.runtime.Path) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem) Property(org.talend.core.model.properties.Property)

Example 64 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method getProcessItemPath.

protected IPath getProcessItemPath(ProcessItem processItem, String path, boolean flag, String... selectedJobVersion) throws Exception {
    String processPath = processItem.getState().getPath();
    if (path != null) {
        processPath = path;
    }
    //$NON-NLS-1$ //$NON-NLS-2$
    processPath = processPath == null || processPath.equals("") ? "" : processPath;
    IPath emfFileRootPath = getEmfFileRootPath(processItem);
    String jobName = processItem.getProperty().getLabel();
    String jobVersion = processItem.getProperty().getVersion();
    if (!isMultiNodes() && selectedJobVersion != null && selectedJobVersion.length == 1) {
        jobVersion = selectedJobVersion[0];
    }
    IPath itemPath = emfFileRootPath.append(processPath).append(jobName + '_' + jobVersion + '.' + FileConstants.ITEM_EXTENSION);
    File itemFile = itemPath.toFile();
    if (!flag && !itemFile.exists()) {
        IRepositoryViewObject specificVersion = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().getSpecificVersion(processItem.getProperty().getId(), jobVersion, true);
        if (specificVersion != null) {
            Property property = specificVersion.getProperty();
            URI uri = property.eResource().getURI();
            IPath fullPath = URIHelper.convert(uri);
            IPath relativePath = fullPath.makeRelativeTo(emfFileRootPath);
            String realProcessPath = relativePath.removeLastSegments(1).removeFirstSegments(2).toString();
            return getProcessItemPath(processItem, realProcessPath, true, selectedJobVersion);
        }
    }
    return itemPath;
}
Also used : IPath(org.eclipse.core.runtime.IPath) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IFile(org.eclipse.core.resources.IFile) File(java.io.File) Property(org.talend.core.model.properties.Property) URI(org.eclipse.emf.common.util.URI)

Example 65 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class TestUtils method createDefaultProperty.

public static Property createDefaultProperty() {
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
    property.setVersion(VersionUtils.DEFAULT_VERSION);
    return property;
}
Also used : Property(org.talend.core.model.properties.Property)

Aggregations

Property (org.talend.core.model.properties.Property)147 PersistenceException (org.talend.commons.exception.PersistenceException)56 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)48 Item (org.talend.core.model.properties.Item)46 ProcessItem (org.talend.core.model.properties.ProcessItem)39 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)36 Node (org.talend.designer.core.ui.editor.nodes.Node)28 Process (org.talend.designer.core.ui.editor.process.Process)23 RepositoryNode (org.talend.repository.model.RepositoryNode)22 IElementParameter (org.talend.core.model.process.IElementParameter)21 ConnectionItem (org.talend.core.model.properties.ConnectionItem)21 IDynamicProperty (org.talend.core.ui.properties.tab.IDynamicProperty)21 ArrayList (java.util.ArrayList)20 Test (org.junit.Test)19 INode (org.talend.core.model.process.INode)19 IComponent (org.talend.core.model.components.IComponent)15 Connection (org.talend.core.model.metadata.builder.connection.Connection)14 IProcess2 (org.talend.core.model.process.IProcess2)14 List (java.util.List)12 IFile (org.eclipse.core.resources.IFile)12