Search in sources :

Example 81 with Property

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

the class ImplicitContextLoadHelper method loadPropertyTypeFromPreference.

/**
     * DOC hcw Comment method "reloadPropertyType".
     * 
     * @param element
     * @param extraComposite
     * @param languagePrefix
     * @param elementParameter
     */
private static void loadPropertyTypeFromPreference(Element element, ExtraComposite extraComposite, String languagePrefix, IElementParameter elementParameter) {
    String propertyType = (String) getPreferenceValue(languagePrefix, EParameterName.PROPERTY_TYPE, String.class);
    String id = (String) getPreferenceValue(languagePrefix, EParameterName.REPOSITORY_PROPERTY_TYPE, String.class);
    Connection repositoryConnection = null;
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    Item item = null;
    try {
        IRepositoryViewObject repobj = factory.getLastVersion(id);
        if (repobj != null) {
            Property tmpproperty = repobj.getProperty();
            if (tmpproperty != null) {
                item = tmpproperty.getItem();
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    if (item != null && item instanceof ConnectionItem) {
        repositoryConnection = ((ConnectionItem) item).getConnection();
    } else {
        repositoryConnection = null;
    }
    ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(element, repositoryConnection, getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
    propertyType);
    ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(element, repositoryConnection, getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
    id);
    AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) element).getEditor();
    if (part instanceof AbstractMultiPageTalendEditor) {
        Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
        if (adapter != null) {
            CommandStack commandStack = ((CommandStack) adapter);
            commandStack.execute(cmd1);
            commandStack.execute(cmd2);
        }
    }
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) CommandStack(org.eclipse.gef.commands.CommandStack) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ConnectionItem(org.talend.core.model.properties.ConnectionItem) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) RepositoryToComponentProperty(org.talend.core.model.metadata.designerproperties.RepositoryToComponentProperty) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 82 with Property

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

the class JobSettingsView method onPropertiesChanged.

@Override
public void onPropertiesChanged(Map<String, Object> maps) {
    if (maps == null || maps.isEmpty()) {
        return;
    }
    Object obj = maps.get(IJobSettingsView.JOBTYPE_CHANGED);
    if (obj instanceof IRepositoryViewObject) {
        String type = null;
        IRepositoryViewObject repositoryObject = (IRepositoryViewObject) obj;
        // opened job needn't to change the title
        if (!(obj instanceof IProcess2)) {
            Property property = repositoryObject.getProperty();
            if (property != null) {
                Item item = property.getItem();
                if (item != null) {
                    ERepositoryObjectType repositoryObjectType = ERepositoryObjectType.getItemType(item);
                    if (repositoryObjectType == ERepositoryObjectType.PROCESS) {
                        type = getViewNameLable();
                    } else if (repositoryObjectType != null) {
                        type = repositoryObjectType.getLabel();
                    }
                }
            }
        }
        Image image = getImage(repositoryObject);
        if (image != null && image.isDisposed()) {
            image = null;
        }
        if (type == null) {
            super.setTitleImage(image);
            tabFactory.setTitleImage(image);
        } else {
            String title = repositoryObject.getLabel();
            if (allowVerchange) {
                if (repositoryObject.getVersion() != null) {
                    //$NON-NLS-1$
                    title = repositoryObject.getLabel() + " " + repositoryObject.getVersion();
                }
            }
            setPartName(type + SEPARATOR + title, image);
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProcess2(org.talend.core.model.process.IProcess2) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IImage(org.talend.commons.ui.runtime.image.IImage) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) Image(org.eclipse.swt.graphics.Image) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property)

Example 83 with Property

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

the class RowGenProcessMain method getProcess.

private void getProcess() {
    initPerlArray();
    this.component.setNumber(number);
    if (component.getProcess() instanceof IProcess2) {
        // get current job context manager.
        jobContextManager = component.getProcess().getContextManager();
    }
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    //$NON-NLS-1$
    property.setLabel(PREVIEW + "_RowGenerator2");
    //$NON-NLS-1$
    property.setId(PREVIEW + "_RowGenerator2");
    proc = new RowGenProcess(property, component);
}
Also used : IProcess2(org.talend.core.model.process.IProcess2) Property(org.talend.core.model.properties.Property)

Example 84 with Property

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

the class JobErrorsChecker method checkLastGenerationHasCompilationError.

public static void checkLastGenerationHasCompilationError(boolean updateProblemsView) throws ProcessorException {
    if (updateProblemsView && CommonsPlugin.isHeadless()) {
        updateProblemsView = false;
    }
    boolean hasError = false;
    boolean isJob = true;
    Item item = null;
    final IProxyRepositoryFactory proxyRepositoryFactory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
    final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
    Integer line = null;
    String errorMessage = null;
    try {
        for (JobInfo jobInfo : LastGenerationInfo.getInstance().getLastGeneratedjobs()) {
            if (jobInfo.isTestContainer()) {
                continue;
            }
            item = null;
            List<IRepositoryViewObject> allVersions = proxyRepositoryFactory.getAllVersion(jobInfo.getJobId());
            for (IRepositoryViewObject repositoryObject2 : allVersions) {
                Property property2 = repositoryObject2.getProperty();
                if (jobInfo.getJobVersion().equals(property2.getVersion())) {
                    item = property2.getItem();
                    break;
                }
            }
            if (item == null) {
                continue;
            }
            IFile file = synchronizer.getFile(item);
            if (file == null) {
                return;
            }
            // check other java files related to the job . example : spark job will generate several java file for
            // one job
            final IResource[] members = file.getParent().members();
            for (IResource member : members) {
                if (member instanceof IFile && "java".equals(member.getFileExtension())) {
                    IMarker[] markers = ((IFile) member).findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
                    for (IMarker marker : markers) {
                        Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
                        String message = (String) marker.getAttribute(IMarker.MESSAGE);
                        Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
                        Integer start = (Integer) marker.getAttribute(IMarker.CHAR_START);
                        Integer end = (Integer) marker.getAttribute(IMarker.CHAR_END);
                        if (lineNr != null && message != null && severity != null && start != null && end != null) {
                            switch(severity) {
                                case IMarker.SEVERITY_ERROR:
                                    hasError = true;
                                    line = lineNr;
                                    errorMessage = message;
                                    break;
                                default:
                                    break;
                            }
                        }
                    }
                }
            }
            if (updateProblemsView) {
                Problems.addRoutineFile(file, ProblemType.JOB, item.getProperty().getLabel(), item.getProperty().getVersion(), true);
            }
            if (hasError) {
                break;
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    if (hasError && item != null) {
        if (isJob) {
            throw new ProcessorException(//$NON-NLS-1$
            Messages.getString("JobErrorsChecker_compile_errors") + " " + '\n' + Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + //$NON-NLS-1$
            '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + //$NON-NLS-1$
            '\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + //$NON-NLS-1$
            '\n' + //$NON-NLS-1$
            Messages.getString("JobErrorsChecker_compile_error_jvmmessage"));
        } else {
            throw new ProcessorException(//$NON-NLS-1$
            Messages.getString("CamelJobErrorsChecker_compile_errors") + " " + '\n' + Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + //$NON-NLS-1$
            '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + //$NON-NLS-1$
            '\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + //$NON-NLS-1$
            '\n' + //$NON-NLS-1$
            Messages.getString("JobErrorsChecker_compile_error_jvmmessage"));
        }
    }
    // if no error for job, check codes.
    checkRoutinesCompilationError();
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) SystemException(org.talend.commons.exception.SystemException) PersistenceException(org.talend.commons.exception.PersistenceException) Item(org.talend.core.model.properties.Item) JobInfo(org.talend.core.model.process.JobInfo) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IMarker(org.eclipse.core.resources.IMarker) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IResource(org.eclipse.core.resources.IResource)

Example 85 with Property

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

the class StandAloneTalendJavaEditor method resetItem.

public void resetItem() throws PersistenceException {
    if (item.getProperty().eResource() == null || item.eResource() == null) {
        IRepositoryService service = CoreRuntimePlugin.getInstance().getRepositoryService();
        IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
        //
        // Property updated = factory.getUptodateProperty(getItem().getProperty());
        Property updatedProperty = null;
        try {
            factory.initialize();
            IRepositoryViewObject repositoryViewObject = factory.getLastVersion(new Project(ProjectManager.getInstance().getProject(item.getProperty().getItem())), item.getProperty().getId());
            if (repositoryViewObject != null) {
                updatedProperty = repositoryViewObject.getProperty();
                item = (FileItem) updatedProperty.getItem();
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : Project(org.talend.core.model.general.Project) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IProject(org.eclipse.core.resources.IProject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IRepositoryService(org.talend.repository.model.IRepositoryService)

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