Search in sources :

Example 11 with Property

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

the class JobErrorsChecker method checkRoutinesCompilationError.

private static void checkRoutinesCompilationError() throws ProcessorException {
    Set<String> dependentRoutines = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(LastGenerationInfo.getInstance().getLastMainJob().getJobId(), LastGenerationInfo.getInstance().getLastMainJob().getJobVersion());
    // from Problems
    List<Problem> errors = Problems.getProblemList().getProblemsBySeverity(ProblemStatus.ERROR);
    for (Problem p : errors) {
        if (p instanceof TalendProblem) {
            TalendProblem talendProblem = (TalendProblem) p;
            if (talendProblem.getType() == ProblemType.ROUTINE && dependentRoutines.contains(talendProblem.getJavaUnitName())) {
                int line = talendProblem.getLineNumber();
                String errorMessage = talendProblem.getDescription();
                throw new ProcessorException(Messages.getString("JobErrorsChecker_routines_compile_errors", talendProblem.getJavaUnitName()) + //$NON-NLS-1$
                '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + //$NON-NLS-1$
                '\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + //$NON-NLS-1$
                errorMessage);
            }
        } else {
        // for now not to check components errors when building jobs in studio/commandline
        // throw new ProcessorException(Messages.getString("JobErrorsChecker_jobDesign_errors", p.getType().getTypeName(), //$NON-NLS-1$
        //      p.getJobInfo().getJobName(), p.getComponentName(), p.getDescription()));
        }
    }
    // if can't find the routines problem, try to check the file directly(mainly for commandline)
    try {
        final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
        IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
        List<IRepositoryViewObject> routinesObjects = factory.getAll(ERepositoryObjectType.ROUTINES, false);
        if (routinesObjects != null) {
            for (IRepositoryViewObject obj : routinesObjects) {
                Property property = obj.getProperty();
                if (!dependentRoutines.contains(property.getLabel())) {
                    continue;
                }
                Item routinesitem = property.getItem();
                IFile routinesFile = synchronizer.getFile(routinesitem);
                IMarker[] markers = routinesFile.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:
                                throw new ProcessorException(//$NON-NLS-1$
                                Messages.getString("JobErrorsChecker_routines_compile_errors", property.getLabel()) + '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + lineNr + //$NON-NLS-1$
                                '\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + //$NON-NLS-1$
                                message);
                            default:
                                break;
                        }
                    }
                }
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    } catch (SystemException e) {
        ExceptionHandler.process(e);
    } catch (CoreException e) {
        ExceptionHandler.process(e);
    }
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) IFile(org.eclipse.core.resources.IFile) TalendProblem(org.talend.core.model.process.TalendProblem) Item(org.talend.core.model.properties.Item) SystemException(org.talend.commons.exception.SystemException) CoreException(org.eclipse.core.runtime.CoreException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) TalendProblem(org.talend.core.model.process.TalendProblem) Problem(org.talend.core.model.process.Problem) IMarker(org.eclipse.core.resources.IMarker) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 12 with Property

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

the class ReplaceSpaceCharForItemNameMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    //$NON-NLS-1$
    final String space = " ";
    try {
        Property property = item.getProperty();
        String name = property.getLabel();
        if (name != null && name.contains(space)) {
            //$NON-NLS-1$
            name = name.replaceAll(space, "_");
            property.setLabel(name);
            fakeFunction(item);
            FACTORY.save(item);
            return ExecutionResult.SUCCESS_WITH_ALERT;
        }
        return ExecutionResult.NOTHING_TO_DO;
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property)

Example 13 with Property

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

the class ResetItemLabelMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    IProxyRepositoryFactory repositoryFactory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    ImportBasicHandler handler = new ImportBasicHandler();
    Property property = item.getProperty();
    if (property == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    String label = property.getLabel();
    if (label == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        boolean isAvailable = WorkspaceUtils.checkNameIsOK(label);
        if (!isAvailable) {
            property.setLabel(handler.getPropertyLabel(StringUtils.trimToNull(label)));
            property.setDisplayName(StringUtils.trimToNull(label));
            repositoryFactory.save(item, true);
        }
    } catch (PersistenceException e) {
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.SUCCESS_WITH_ALERT;
}
Also used : PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ImportBasicHandler(org.talend.repository.items.importexport.handlers.imports.ImportBasicHandler)

Example 14 with Property

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

the class ContextRepositoryReviewDialog method okPressed.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.ui.dialog.RepositoryReviewDialog#okPressed()
     */
@SuppressWarnings("unchecked")
@Override
protected void okPressed() {
    if (params == null || params.isEmpty()) {
        super.okPressed();
    }
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (createNewButton.getSelection()) {
        if (nameInvalid(contextNameText)) {
            //$NON-NLS-1$
            MessageDialog.openError(getShell(), "Context", msg);
            return;
        } else {
            item = PropertiesFactory.eINSTANCE.createContextItem();
            if (item == null) {
                return;
            }
            Property createProperty = PropertiesFactory.eINSTANCE.createProperty();
            createProperty.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
            createProperty.setVersion(VersionUtils.DEFAULT_VERSION);
            //$NON-NLS-1$
            createProperty.setStatusCode("");
            try {
                String nextId = factory.getNextId();
                createProperty.setId(nextId);
                item.setProperty(createProperty);
                for (IContext context : contextManager.getListContext()) {
                    ContextType contextType = TalendFileFactory.eINSTANCE.createContextType();
                    contextType.setName(context.getName());
                    item.getContext().add(contextType);
                }
                item.setDefaultContext(contextManager.getDefaultContext().getName());
                item.getProperty().setLabel(contextNameText.getText().trim());
                IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
                IProxyRepositoryFactory repositoryFactory = service.getProxyRepositoryFactory();
                try {
                    boolean nameAvaliabe = repositoryFactory.isNameAvailable(createProperty.getItem(), contextNameText.getText());
                    if (!nameAvaliabe) {
                        MessageDialog.openError(getShell(), "Context", //$NON-NLS-1$
                        Messages.getString(//$NON-NLS-1$
                        "PropertiesWizardPage.ItemExistsError"));
                        return;
                    }
                } catch (PersistenceException e) {
                    ExceptionHandler.process(e);
                    super.okPressed();
                }
                //$NON-NLS-1$
                factory.create(item, new Path(""));
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
                super.okPressed();
            }
        }
    } else {
        IStructuredSelection selection = (IStructuredSelection) getRepositoryTreeViewer().getSelection();
        RepositoryNode context = (RepositoryNode) selection.getFirstElement();
        try {
            // get the item from file
            IRepositoryViewObject contextObj = factory.getLastVersion(context.getObject().getProperty().getId());
            item = (ContextItem) contextObj.getProperty().getItem();
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            super.okPressed();
        }
    }
    super.okPressed();
}
Also used : Path(org.eclipse.core.runtime.Path) ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) IContext(org.talend.core.model.process.IContext) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryService(org.talend.repository.model.IRepositoryService) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 15 with Property

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

the class EditSqlpatternAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
    Property property = node.getObject().getProperty();
    Property updatedProperty = null;
    try {
        updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(property.getItem())), property.getId()).getProperty();
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    // update the property of the node repository object
    // node.getObject().setProperty(updatedProperty);
    SQLPatternItem sqlPatternItem = (SQLPatternItem) node.getObject().getProperty().getItem();
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean readonly = factory.getStatus(sqlPatternItem) == ERepositoryStatus.LOCK_BY_OTHER;
    try {
        openSQLPatternEditor(sqlPatternItem, readonly);
    // TDI-21143 : Studio repository view : remove all refresh call to repo view
    // IRepositoryView view = getViewPart();
    // if (view != null) {
    // view.refresh(node);
    // }
    } catch (PartInitException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (SystemException e) {
        MessageBoxExceptionHandler.process(e);
    }
}
Also used : Project(org.talend.core.model.general.Project) SystemException(org.talend.commons.exception.SystemException) PersistenceException(org.talend.commons.exception.PersistenceException) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) PartInitException(org.eclipse.ui.PartInitException) RepositoryNode(org.talend.repository.model.RepositoryNode) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

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