Search in sources :

Example 1 with ICoreService

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

the class Log4jSettingPage method performOk.

@Override
public boolean performOk() {
    boolean ok = super.performOk();
    if (templateTxt != null && !templateTxt.isDisposed()) {
        IRunProcessService service = null;
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
            service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
        }
        if (reset) {
            if (service != null) {
                Log4jPrefsSettingManager.getInstance().saveLog4jNodeIntoPref(Log4jPrefsConstants.LOG4J_ENABLE_NODE, String.valueOf(false));
                Log4jPrefsSettingManager.getInstance().saveLog4jNodeIntoPref(Log4jPrefsConstants.LOG4J_CONTENT_NODE, service.getLogTemplate(Log4jPrefsConstants.LOG4JFILEPATH));
            }
        } else {
            if (log4jBtn != null && !log4jBtn.isDisposed()) {
                Log4jPrefsSettingManager.getInstance().saveLog4jNodeIntoPref(Log4jPrefsConstants.LOG4J_ENABLE_NODE, String.valueOf(log4jBtn.getSelection()));
            }
            Log4jPrefsSettingManager.getInstance().saveLog4jNodeIntoPref(Log4jPrefsConstants.LOG4J_CONTENT_NODE, templateTxt.getText());
        }
        reset = false;
    }
    // updat the log4j file for code project
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
        ICoreService service = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
        if (service != null) {
            service.syncLog4jSettings();
        }
    }
    return ok;
}
Also used : IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ICoreService(org.talend.core.ICoreService)

Example 2 with ICoreService

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

the class ServiceMetadataAction method isLocked.

private static boolean isLocked(IRepositoryViewObject object) {
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
        ICoreService coreService = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
        boolean isOpened = coreService.isOpenedItemInEditor(object);
        if (isOpened) {
            return true;
        }
    }
    ServiceItem serviceItem = (ServiceItem) object.getProperty().getItem();
    return serviceItem.getState().isLocked();
}
Also used : ICoreService(org.talend.core.ICoreService) ServiceItem(org.talend.repository.services.model.services.ServiceItem)

Example 3 with ICoreService

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

the class JobJavaScriptsManager method addXmlMapping.

protected void addXmlMapping(ExportFileResource resource, boolean needSource) {
    try {
        boolean hasDynamicMetadata = false;
        if (resource.getItem() instanceof ProcessItem) {
            List<JobInfo> list = new ArrayList<JobInfo>();
            hasDynamicMetadata = LastGenerationInfo.getInstance().isUseDynamic(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
        }
        if (hasDynamicMetadata) {
            needMappingInSystemRoutine = true;
            if (needSource) {
                IRunProcessService service = CorePlugin.getDefault().getRunProcessService();
                ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
                if (talendProcessJavaProject == null) {
                    return;
                }
                // for db mapping xml
                IFolder xmlMappingFolder = talendProcessJavaProject.getResourcesFolder().getFolder(JavaUtils.JAVA_XML_MAPPING);
                if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
                    ICoreService coreService = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
                    coreService.synchronizeMapptingXML();
                    coreService.syncLog4jSettings();
                }
                List<URL> xmlMappingFileUrls = new ArrayList<URL>();
                if (xmlMappingFolder.exists()) {
                    for (IResource fileResource : xmlMappingFolder.members()) {
                        if (XmlUtil.isXMLFile(fileResource.getName())) {
                            xmlMappingFileUrls.add(fileResource.getLocationURI().toURL());
                        }
                    }
                    resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + JavaUtils.JAVA_XML_MAPPING, xmlMappingFileUrls);
                }
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ArrayList(java.util.ArrayList) ICoreService(org.talend.core.ICoreService) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) URL(java.net.URL) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) DocumentException(org.dom4j.DocumentException) ProcessorException(org.talend.designer.runprocess.ProcessorException) MalformedURLException(java.net.MalformedURLException) PersistenceException(org.talend.commons.exception.PersistenceException) ProcessItem(org.talend.core.model.properties.ProcessItem) JobInfo(org.talend.core.model.process.JobInfo) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Example 4 with ICoreService

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

the class AbstractBuildJobHandler method getProfileArgs.

protected StringBuffer getProfileArgs() {
    StringBuffer profileBuffer = new StringBuffer();
    profileBuffer.append(TalendMavenConstants.PREFIX_THREAD);
    profileBuffer.append(SPACE);
    profileBuffer.append(TalendMavenConstants.PREFIX_THREAD_VALUE);
    profileBuffer.append(SPACE);
    profileBuffer.append(TalendMavenConstants.PREFIX_PROFILE);
    profileBuffer.append(SPACE);
    // should add the default settings always.
    addArg(profileBuffer, true, true, TalendMavenConstants.PROFILE_DEFAULT_SETTING);
    addArg(profileBuffer, isOptionChoosed(ExportChoice.needSourceCode), TalendMavenConstants.PROFILE_INCLUDE_JAVA_SOURCES);
    // if not binaries, need add maven resources
    boolean isBinaries = isOptionChoosed(ExportChoice.binaries);
    addArg(profileBuffer, !isBinaries, TalendMavenConstants.PROFILE_INCLUDE_MAVEN_RESOURCES);
    // DQ survivorship rules when items not exported.
    if (needDQSurvivorshipRules()) {
        addArg(profileBuffer, true, TalendMavenConstants.PROFILE_INCLUDE_SURVIVORSHIP_RULES);
    }
    addArg(profileBuffer, isOptionChoosed(ExportChoice.needJobItem) || itemDependencies, TalendMavenConstants.PROFILE_INCLUDE_ITEMS);
    // for binaries
    addArg(profileBuffer, isOptionChoosed(ExportChoice.includeLibs), TalendMavenConstants.PROFILE_INCLUDE_LIBS);
    addArg(profileBuffer, isBinaries, TalendMavenConstants.PROFILE_INCLUDE_BINARIES);
    // add log4j to running.
    addArg(profileBuffer, isLog4jEnable() && isBinaries, TalendMavenConstants.PROFILE_INCLUDE_RUNNING_LOG4J);
    // add log4j for resources.
    addArg(profileBuffer, isLog4jEnable() && !isBinaries, TalendMavenConstants.PROFILE_INCLUDE_LOG4J);
    // the running context is only useful, when binaries
    addArg(profileBuffer, isBinaries && isOptionChoosed(ExportChoice.needContext), TalendMavenConstants.PROFILE_INCLUDE_CONTEXTS, ProcessUtils.jarNeedsToContainContext());
    // for test
    addArg(profileBuffer, isOptionChoosed(ExportChoice.includeTestSource), TalendMavenConstants.PROFILE_INCLUDE_TEST_SOURCES);
    addArg(profileBuffer, isOptionChoosed(ExportChoice.executeTests), TalendMavenConstants.PROFILE_INCLUDE_TEST_REPORTS);
    // xmlMappings folders
    addArg(profileBuffer, needXmlMappings(), TalendMavenConstants.PROFILE_INCLUDE_XMLMAPPINGS);
    addArg(profileBuffer, needXmlMappings() && isBinaries, TalendMavenConstants.PROFILE_INCLUDE_RUNNING_XMLMAPPINGS);
    if (needXmlMappings()) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
            ICoreService coreService = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
            coreService.synchronizeMapptingXML();
            coreService.syncLog4jSettings();
        }
    }
    // If the map doesn't contain the assembly key, then take the default value activation from the POM.
    boolean isAssemblyNeeded = exportChoice.get(ExportChoice.needAssembly) == null || isOptionChoosed(ExportChoice.needAssembly);
    addArg(profileBuffer, isAssemblyNeeded, TalendMavenConstants.PROFILE_PACKAGING_AND_ASSEMBLY);
    // rules
    if (needRules()) {
        addArg(profileBuffer, true, TalendMavenConstants.PROFILE_INCLUDE_RULES);
    }
    // pigudfs
    if (needPigUDFs()) {
        addArg(profileBuffer, isBinaries, TalendMavenConstants.PROFILE_INCLUDE_PIGUDFS_BINARIES);
        addArg(profileBuffer, !isBinaries, TalendMavenConstants.PROFILE_INCLUDE_PIGUDFS_JAVA_SOURCES);
    }
    return profileBuffer;
}
Also used : ICoreService(org.talend.core.ICoreService)

Example 5 with ICoreService

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

the class ChangeMappingFileMigrationTask method execute.

@Override
public ExecutionResult execute(Project project) {
    try {
        URL s = MetadataTalendType.getSystemForderURLOfMappingsFile();
        changeSAPHanaMappingFile(s);
        //$NON-NLS-1$
        String dirPath = "/" + MetadataTalendType.INTERNAL_MAPPINGS_FOLDER;
        IProject _project = ResourceUtils.getProject(project);
        File projectMappingFolder = new ProjectScope(_project).getLocation().append(dirPath).toFile();
        if (projectMappingFolder.exists()) {
            URL p = MetadataTalendType.getProjectForderURLOfMappingsFile();
            changeSAPHanaMappingFile(p);
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
                ICoreService service = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
                service.synchronizeMapptingXML();
            }
        }
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) ICoreService(org.talend.core.ICoreService) File(java.io.File) URL(java.net.URL) IProject(org.eclipse.core.resources.IProject)

Aggregations

ICoreService (org.talend.core.ICoreService)6 File (java.io.File)2 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 DocumentException (org.dom4j.DocumentException)2 CoreException (org.eclipse.core.runtime.CoreException)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 IRunProcessService (org.talend.designer.runprocess.IRunProcessService)2 ProcessorException (org.talend.designer.runprocess.ProcessorException)2 IFile (org.eclipse.core.resources.IFile)1 IFolder (org.eclipse.core.resources.IFolder)1 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 ProjectScope (org.eclipse.core.resources.ProjectScope)1 JobInfo (org.talend.core.model.process.JobInfo)1 ProcessItem (org.talend.core.model.properties.ProcessItem)1 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)1 ServiceItem (org.talend.repository.services.model.services.ServiceItem)1