Search in sources :

Example 26 with IRepositoryService

use of org.talend.repository.model.IRepositoryService in project tdi-studio-se by Talend.

the class TalendJavaSourceViewer method getImports.

private static String getImports() {
    //$NON-NLS-1$
    String imports = "";
    if (!GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
        return imports;
    }
    IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
    IProxyRepositoryFactory repositoryFactory = service.getProxyRepositoryFactory();
    Project project = ProjectManager.getInstance().getProject(null);
    try {
        List<IRepositoryViewObject> routines = repositoryFactory.getAll(ERepositoryObjectType.ROUTINES);
        for (IRepositoryViewObject routine : routines) {
            if (routine.getProperty().getItem() instanceof RoutineItem && ((RoutineItem) routine.getProperty().getItem()).isBuiltIn()) {
                //$NON-NLS-1$ //$NON-NLS-2$
                imports += "import routines." + routine.getLabel() + ";\n";
            } else {
                //$NON-NLS-1$ //$NON-NLS-2$ 
                imports += "import routines." + routine.getLabel() + ";\n";
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        //$NON-NLS-1$
        return "";
    }
    //$NON-NLS-1$
    imports += "import routines.system.*;\n";
    //$NON-NLS-1$
    imports += "import java.text.ParseException;\n";
    //$NON-NLS-1$
    imports += "import java.text.SimpleDateFormat;\n";
    //$NON-NLS-1$
    imports += "import java.util.Date;\n";
    //$NON-NLS-1$
    imports += "import java.util.List;\n";
    //$NON-NLS-1$
    imports += "import java.math.BigDecimal;\n";
    imports += "\n";
    imports += "@SuppressWarnings(\"unused\")";
    imports += "\n\n";
    return imports;
}
Also used : Project(org.talend.core.model.properties.Project) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) RoutineItem(org.talend.core.model.properties.RoutineItem) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IRepositoryService(org.talend.repository.model.IRepositoryService)

Example 27 with IRepositoryService

use of org.talend.repository.model.IRepositoryService 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

IRepositoryService (org.talend.repository.model.IRepositoryService)27 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)21 PersistenceException (org.talend.commons.exception.PersistenceException)19 Item (org.talend.core.model.properties.Item)11 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 PartInitException (org.eclipse.ui.PartInitException)8 CoreException (org.eclipse.core.runtime.CoreException)7 Property (org.talend.core.model.properties.Property)7 LoginException (org.talend.commons.exception.LoginException)6 ProcessItem (org.talend.core.model.properties.ProcessItem)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 IPath (org.eclipse.core.runtime.IPath)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 ERepositoryStatus (org.talend.commons.runtime.model.repository.ERepositoryStatus)5 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)5 IFile (org.eclipse.core.resources.IFile)4 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 IProject (org.eclipse.core.resources.IProject)3