Search in sources :

Example 6 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tdi-studio-se by Talend.

the class JavaProcessorUtilities method computeLibrariesPath.

/**
     * DOC nrousseau Comment method "computeLibrariesPath".
     * 
     * @param hashSet
     * @param process
     * @param alreadyRetrievedModules
     * @throws BusinessException
     */
public static void computeLibrariesPath(Set<ModuleNeeded> jobModuleList, IProcess process, Set<ModuleNeeded> alreadyRetrievedModules) throws ProcessorException {
    RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
    Project project = repositoryContext.getProject();
    if (projectSetup == null || !projectSetup.equals(project.getTechnicalLabel())) {
        projectSetup = project.getTechnicalLabel();
    }
    // use maven to update the class path.
    try {
        sortClasspath(jobModuleList, process, alreadyRetrievedModules);
    } catch (CoreException e) {
        ExceptionHandler.process(e);
    }
    if (alreadyRetrievedModules.isEmpty()) {
        // to update this only one time in one build of full job/subjobs
        checkAndUpdateLog4jFile();
    }
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) Project(org.talend.core.model.general.Project) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IProject(org.eclipse.core.resources.IProject) RepositoryContext(org.talend.core.context.RepositoryContext) CoreException(org.eclipse.core.runtime.CoreException)

Example 7 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tdi-studio-se by Talend.

the class JavaProcessor method generateContextCode.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.runprocess.Processor#generateContextCode()
     */
@Override
public void generateContextCode() throws ProcessorException {
    RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
    Project project = repositoryContext.getProject();
    ICodeGenerator codeGen;
    ICodeGeneratorService service = RunProcessPlugin.getDefault().getCodeGeneratorService();
    //$NON-NLS-1$
    String javaInterpreter = "";
    //$NON-NLS-1$
    String javaLib = "";
    String currentJavaProject = project.getTechnicalLabel();
    String javaContext = getContextPath().toPortableString();
    codeGen = service.createCodeGenerator(process, false, false, javaInterpreter, javaLib, javaContext, currentJavaProject);
    updateContextCode(codeGen);
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) ICodeGenerator(org.talend.designer.codegen.ICodeGenerator) RepositoryContext(org.talend.core.context.RepositoryContext) ICodeGeneratorService(org.talend.designer.codegen.ICodeGeneratorService)

Example 8 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tdi-studio-se by Talend.

the class LoginProjectPage method revertUpdateStatus.

private void revertUpdateStatus() {
    Context ctx = CoreRuntimePlugin.getInstance().getContext();
    RepositoryContext repositoryContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
    repositoryContext.setNoUpdateWhenLogon(false);
}
Also used : RepositoryContext(org.talend.core.context.RepositoryContext) Context(org.talend.core.context.Context) RepositoryContext(org.talend.core.context.RepositoryContext)

Example 9 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tesb-studio-se by Talend.

the class ProcessUtil method getCodeLanguage.

public static ECodeLanguage getCodeLanguage() {
    RepositoryContext context = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
    Project project = context.getProject();
    return project.getLanguage();
}
Also used : Project(org.talend.core.model.general.Project) RepositoryContext(org.talend.core.context.RepositoryContext)

Example 10 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tdi-studio-se by Talend.

the class TestComponentsAction method initialize.

public void initialize() {
    Job job = new //$NON-NLS-1$
    Job(//$NON-NLS-1$
    "Component Test") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                // IProgressMonitor monitorWrap = new CodeGeneratorProgressMonitor(monitor);
                //$NON-NLS-1$
                monitor.beginTask("Component Test Running", 1100);
                IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
                Set<IComponent> components = componentsFactory.getComponents();
                monitor.worked(100);
                RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
                ECodeLanguage codeLanguage = repositoryContext.getProject().getLanguage();
                String path = getPath();
                // TODO
                int taskTotal = components.size();
                for (IComponent component : components) {
                    String templateURI = path + File.separatorChar + component.getName() + File.separatorChar + TestParameter.GENERATE_TEST;
                    File templateFile = new File(templateURI);
                    // System.out.println(templateFile + " " + templateFile.exists());
                    if (templateFile.exists()) {
                        File[] fileArray = getFile(templateFile, codeLanguage);
                        //$NON-NLS-1$ //$NON-NLS-2$
                        generateCode(fileArray, templateURI.replace("\\", "/"));
                    }
                    monitor.worked(1 * 1000 / taskTotal);
                }
            } catch (Exception e) {
                //$NON-NLS-1$
                log.error("Exception during test Initialization", e);
            }
            monitor.done();
            return Status.OK_STATUS;
        }
    };
    job.schedule();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RepositoryContext(org.talend.core.context.RepositoryContext) IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) Job(org.eclipse.core.runtime.jobs.Job) File(java.io.File) ProcessorException(org.talend.designer.runprocess.ProcessorException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Aggregations

RepositoryContext (org.talend.core.context.RepositoryContext)31 Context (org.talend.core.context.Context)17 Project (org.talend.core.model.general.Project)12 PersistenceException (org.talend.commons.exception.PersistenceException)8 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)7 IProject (org.eclipse.core.resources.IProject)5 ECodeLanguage (org.talend.core.language.ECodeLanguage)5 File (java.io.File)3 CoreException (org.eclipse.core.runtime.CoreException)3 BeforeClass (org.junit.BeforeClass)3 ProcessItem (org.talend.core.model.properties.ProcessItem)3 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HashMap (java.util.HashMap)2 List (java.util.List)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2