Search in sources :

Example 61 with PersistenceException

use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.

the class JavaJobScriptsExportWSWizardPage method restoreWidgetValuesForESB.

protected void restoreWidgetValuesForESB() {
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
        String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
        if (directoryNames != null && directoryNames.length > 0) {
            String fileName = getDefaultFileNameWithType();
            // destination
            for (int i = 0; i < directoryNames.length; i++) {
                if (directoryNames[i].toLowerCase().endsWith(FileConstants.ESB_FILE_SUFFIX)) {
                    //$NON-NLS-1$
                    directoryNames[i] = (directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);
                    addDestinationItem(directoryNames[i]);
                }
            }
            File dest = new File(new File(directoryNames[0]).getParentFile(), fileName);
            setDestinationValue(dest.getAbsolutePath());
        } else {
            setDefaultDestination();
        }
        IDialogSettings section = getDialogSettings().getSection(DESTINATION_FILE);
        if (section == null) {
            section = getDialogSettings().addNewSection(DESTINATION_FILE);
        }
        if (jobScriptButton != null && !jobScriptButton.isDisposed()) {
            jobScriptButton.setSelection(settings.getBoolean(STORE_SOURCE_ID));
        }
        if (contextButton != null && !contextButton.isDisposed()) {
            contextButton.setSelection(settings.getBoolean(STORE_CONTEXT_ID));
        }
        if (applyToChildrenButton != null && !applyToChildrenButton.isDisposed()) {
            applyToChildrenButton.setSelection(settings.getBoolean(APPLY_TO_CHILDREN_ID));
        }
        if (jobItemButton != null && !jobItemButton.isDisposed()) {
            jobItemButton.setSelection(settings.getBoolean(STORE_JOB_ID));
        }
        if (section.get(ESB_EXPORT_TYPE) != null) {
            esbTypeCombo.setText(section.get(ESB_EXPORT_TYPE));
            if (section.get(ESB_SERVICE_NAME) != null) {
                esbServiceName.setText(section.get(ESB_SERVICE_NAME));
            }
            if (section.get(ESB_CATEGORY) != null) {
                esbCategory.setText(section.get(ESB_CATEGORY));
            }
            if (section.get(QUERY_MESSAGE_NAME) != null) {
                esbQueueMessageName.setText(section.get(QUERY_MESSAGE_NAME));
            }
        }
    }
    if (getProcessItem() != null && contextCombo != null) {
        try {
            setProcessItem((ProcessItem) ProxyRepositoryFactory.getInstance().getUptodateProperty(getProcessItem().getProperty()).getItem());
        } catch (PersistenceException e) {
            e.printStackTrace();
        }
        List<String> contextNames = ExportJobUtil.getJobContexts(getProcessItem());
        contextCombo.setItems(contextNames.toArray(new String[contextNames.size()]));
        if (contextNames.size() > 0) {
            contextCombo.select(0);
        }
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) PersistenceException(org.talend.commons.exception.PersistenceException) File(java.io.File)

Example 62 with PersistenceException

use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.

the class PurposeStatusSection method setInput.

@Override
public void setInput(IWorkbenchPart part, ISelection selection) {
    super.setInput(part, selection);
    try {
        Property property = getObject().getProperty();
        List<Status> status = property == null ? new ArrayList<Status>() : statusHelper.getStatusList(property);
        statusText.setItems(toArray(status));
    } catch (PersistenceException e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
}
Also used : Status(org.talend.core.model.properties.Status) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property)

Example 63 with PersistenceException

use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.

the class Log4jPrefsSettingManager method isLog4jPrefsExist.

public boolean isLog4jPrefsExist() {
    try {
        IProject project = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
        IFolder prefSettingFolder = ResourceUtils.getFolder(project, RepositoryConstants.SETTING_DIRECTORY, false);
        IFile presLog4jFile = prefSettingFolder.getFile(Log4jPrefsConstants.LOG4J_RESOURCES + Log4jPrefsConstants.LOG4j_PREFS_SUFFIX);
        if (presLog4jFile.exists()) {
            return true;
        }
    } catch (PersistenceException e) {
        e.printStackTrace();
    }
    return false;
}
Also used : IFile(org.eclipse.core.resources.IFile) PersistenceException(org.talend.commons.exception.PersistenceException) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 64 with PersistenceException

use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.

the class SpagicDeployWizardPage method finish.

/**
     * The Finish button was pressed. Try to do the required work now and answer a boolean indicating success. If false
     * is returned then the wizard will not close.
     * 
     * @returns boolean
     */
@Override
public boolean finish() {
    Map<ExportChoice, Object> exportChoiceMap = getExportChoiceMap();
    boolean canExport = false;
    for (ExportChoice choice : ExportChoice.values()) {
        if (exportChoiceMap.get(choice) != null && exportChoiceMap.get(choice) instanceof Boolean && (Boolean) exportChoiceMap.get(choice)) {
            canExport = true;
            break;
        }
    }
    if (!canExport) {
        MessageDialog.openInformation(getContainer().getShell(), //$NON-NLS-1$
        Messages.getString("SpagicDeployWizardPage.exportResourceError"), //$NON-NLS-1$
        Messages.getString("SpagicDeployWizardPage.chooseResource"));
        return false;
    }
    if (!ensureTargetIsValid()) {
        return false;
    }
    manager = new //$NON-NLS-1$
    SpagicJavaDeployManager(//$NON-NLS-1$
    exportChoiceMap, //$NON-NLS-1$
    contextCombo.getText(), //$NON-NLS-1$
    "all", //$NON-NLS-1$
    IProcessor.NO_STATISTICS, IProcessor.NO_TRACES);
    String topFolder = getRootFolderName();
    List<ExportFileResource> resourcesToExport = null;
    try {
        resourcesToExport = getExportResources();
    } catch (ProcessorException e) {
        MessageBoxExceptionHandler.process(e);
        return false;
    }
    setTopFolder(resourcesToExport, topFolder);
    // Save dirty editors if possible but do not stop if not all are saved
    saveDirtyEditors();
    // about to invoke the operation so save our state
    saveWidgetValues();
    // boolean ok =executeExportOperation(new ArchiveFileExportOperationFullPath(process));
    // File file = createSapgicProperty();
    ArchiveFileExportOperationFullPath exporterOperation = getExporterOperation(resourcesToExport);
    // exportResource(topFolder, "", "", 1);
    boolean ok = executeExportOperation(exporterOperation);
    // path can like name/name
    manager.deleteTempFiles();
    ProcessorUtilities.resetExportConfig();
    String projectName = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLabel();
    List<JobResource> jobResources = new ArrayList<JobResource>();
    for (ExportFileResource proces : process) {
        try {
            proces.setProcess((ProcessItem) ProxyRepositoryFactory.getInstance().getUptodateProperty(proces.getItem().getProperty()).getItem());
        } catch (PersistenceException e) {
            e.printStackTrace();
        }
        ProcessItem processItem = (ProcessItem) proces.getItem();
        JobInfo jobInfo = new JobInfo(processItem, processItem.getProcess().getDefaultContext());
        jobResources.add(new JobResource(projectName, jobInfo));
        Set<JobInfo> jobInfos = ProcessorUtilities.getChildrenJobInfo(processItem);
        for (JobInfo subjobInfo : jobInfos) {
            jobResources.add(new JobResource(projectName, subjobInfo));
        }
    }
    JobResourceManager reManager = JobResourceManager.getInstance();
    for (JobResource r : jobResources) {
        if (reManager.isProtected(r)) {
            try {
                ProcessorUtilities.generateCode(r.getJobInfo().getJobId(), r.getJobInfo().getContextName(), r.getJobInfo().getJobVersion(), false, false);
            } catch (ProcessorException e) {
                ExceptionHandler.process(e);
            }
        } else {
            reManager.deleteResource(r);
        }
    }
    return ok;
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) JobResource(org.talend.core.model.repository.job.JobResource) ArrayList(java.util.ArrayList) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) JobInfo(org.talend.core.model.process.JobInfo) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) JobResourceManager(org.talend.core.model.repository.job.JobResourceManager) ArchiveFileExportOperationFullPath(org.talend.core.ui.export.ArchiveFileExportOperationFullPath)

Example 65 with PersistenceException

use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.

the class JavaPublishOnSpagoExportWizardPage method restoreWidgetValues.

/**
     * Hook method for restoring widget values to the values that they held last time this wizard was used to
     * completion.
     */
protected void restoreWidgetValues() {
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
        // String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
        // if (directoryNames != null) {
        // // destination
        // setDestinationValue(directoryNames[0]);
        // for (int i = 0; i < directoryNames.length; i++) {
        // addDestinationItem(directoryNames[i]);
        // }
        // }
        // shellLauncherButton.setSelection(settings.getBoolean(STORE_SHELL_LAUNCHER_ID));
        // systemRoutineButton.setSelection(settings.getBoolean(STORE_SYSTEM_ROUTINE_ID));
        // userRoutineButton.setSelection(settings.getBoolean(STORE_USER_ROUTINE_ID));
        // modelButton.setSelection(settings.getBoolean(STORE_MODEL_ID));
        // jobButton.setSelection(settings.getBoolean(STORE_JOB_ID));
        // sourceButton.setSelection(settings.getBoolean(STORE_SOURCE_ID));
        contextButton.setSelection(settings.getBoolean(STORE_CONTEXT_ID));
    // genCodeButton.setSelection(settings.getBoolean(STORE_GENERATECODE_ID));
    }
    // }
    if (process.length > 0) {
        try {
            process[0].setProcess((ProcessItem) ProxyRepositoryFactory.getInstance().getUptodateProperty(process[0].getItem().getProperty()).getItem());
        } catch (PersistenceException e) {
            e.printStackTrace();
        }
        if (manager == null) {
            manager = new JobJavaScriptsManager(getExportChoiceMap(), contextCombo.getText(), //$NON-NLS-1$
            "all", //$NON-NLS-1$
            IProcessor.NO_STATISTICS, IProcessor.NO_TRACES);
        }
        List<String> contextNames = manager.getJobContextsComboValue((ProcessItem) process[0].getItem());
        contextCombo.setItems(contextNames.toArray(new String[contextNames.size()]));
        if (contextNames.size() > 0) {
            contextCombo.select(0);
        }
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) PersistenceException(org.talend.commons.exception.PersistenceException)

Aggregations

PersistenceException (org.talend.commons.exception.PersistenceException)367 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)113 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)112 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)104 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)89 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)84 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)77 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)76 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)75 Item (org.talend.core.model.properties.Item)59 ArrayList (java.util.ArrayList)58 ProcessItem (org.talend.core.model.properties.ProcessItem)54 Property (org.talend.core.model.properties.Property)51 ConnectionItem (org.talend.core.model.properties.ConnectionItem)47 Project (org.talend.core.model.general.Project)40 CoreException (org.eclipse.core.runtime.CoreException)37 List (java.util.List)36 IElementParameter (org.talend.core.model.process.IElementParameter)35 IProject (org.eclipse.core.resources.IProject)32 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)32