Search in sources :

Example 21 with RoutineItem

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

the class DemosImportTest method getUserRoutineSize.

protected int getUserRoutineSize() throws PersistenceException {
    List<IRepositoryViewObject> all = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.ROUTINES);
    int currentRoutineItemsSize = 0;
    for (IRepositoryViewObject obj : all) {
        Property property = obj.getProperty();
        Item item = property.getItem();
        if (item instanceof RoutineItem && !((RoutineItem) item).isBuiltIn()) {
            // only check for user routine.
            currentRoutineItemsSize++;
        }
    }
    return currentRoutineItemsSize;
}
Also used : RoutineItem(org.talend.core.model.properties.RoutineItem) Item(org.talend.core.model.properties.Item) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RoutineItem(org.talend.core.model.properties.RoutineItem) Property(org.talend.core.model.properties.Property)

Example 22 with RoutineItem

use of org.talend.core.model.properties.RoutineItem 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 23 with RoutineItem

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

the class JavaRoutineSynchronizer method syncRoutineItems.

private void syncRoutineItems(Collection<RoutineItem> routineObjects, boolean forceUpdate) throws SystemException {
    for (RoutineItem routineItem : routineObjects) {
        syncRoutine(routineItem, true, forceUpdate);
    }
    try {
        ILibrariesService jms = CorePlugin.getDefault().getLibrariesService();
        List<URL> urls = jms.getTalendRoutinesFolder();
        for (URL systemModuleURL : urls) {
            if (systemModuleURL != null) {
                String fileName = systemModuleURL.getPath();
                if (fileName.startsWith("/")) {
                    //$NON-NLS-1$
                    fileName = fileName.substring(1);
                }
                File f = new File(systemModuleURL.getPath());
                if (f.isDirectory()) {
                    syncModule(f.listFiles());
                }
            }
        }
    } catch (IOException e) {
        throw new SystemException(e);
    }
}
Also used : ILibrariesService(org.talend.core.model.general.ILibrariesService) SystemException(org.talend.commons.exception.SystemException) RoutineItem(org.talend.core.model.properties.RoutineItem) IOException(java.io.IOException) IFile(org.eclipse.core.resources.IFile) File(java.io.File) URL(java.net.URL)

Example 24 with RoutineItem

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

the class ProblemsView method propertyChange.

/*
     * (non-Javadoc)
     * 
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (!(evt.getNewValue() instanceof IRepositoryObject)) {
        return;
    }
    IRepositoryObject object = (IRepositoryObject) evt.getNewValue();
    if (object.getRepositoryObjectType() != ERepositoryObjectType.ROUTINES) {
        return;
    }
    if (evt.getPropertyName().equals(ERepositoryActionName.DELETE_TO_RECYCLE_BIN.getName()) || evt.getPropertyName().equals(ERepositoryActionName.DELETE_FOREVER.getName())) {
        String routineLabel = object.getProperty().getLabel();
        Problems.removeProblemsByRoutine(routineLabel);
    }
    if (evt.getPropertyName().equals(ERepositoryActionName.RESTORE.getName())) {
        RoutineItem item = (RoutineItem) object.getProperty().getItem();
        restoreProblem(item);
    }
}
Also used : RoutineItem(org.talend.core.model.properties.RoutineItem) IRepositoryObject(org.talend.core.model.repository.IRepositoryObject)

Example 25 with RoutineItem

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

the class Problems method addRoutineFile.

public static List<Information> addRoutineFile(IFile file, final Property property, boolean... fromJob) {
    if (file == null) {
        return Collections.emptyList();
    }
    String routineFileName = null;
    String version = null;
    if (property == null) {
        routineFileName = getFileName(file);
    } else {
        routineFileName = property.getLabel();
        version = property.getVersion();
    }
    ProblemType type = ProblemType.NONE;
    if (property.getItem() instanceof RoutineItem) {
        type = ProblemType.ROUTINE;
    } else if (property.getItem() instanceof ProcessItem) {
        type = ProblemType.JOB;
    }
    List<Information> listInfos = addRoutineFile(file, type, routineFileName, version, fromJob);
    if (property == null || listInfos == null) {
        return Collections.emptyList();
    }
    return listInfos;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) ProblemType(org.talend.core.model.process.Problem.ProblemType) RoutineItem(org.talend.core.model.properties.RoutineItem) Information(org.talend.core.model.properties.Information)

Aggregations

RoutineItem (org.talend.core.model.properties.RoutineItem)39 PersistenceException (org.talend.commons.exception.PersistenceException)15 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)15 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)13 Item (org.talend.core.model.properties.Item)12 Property (org.talend.core.model.properties.Property)12 ArrayList (java.util.ArrayList)11 IOException (java.io.IOException)9 CoreException (org.eclipse.core.runtime.CoreException)8 ProcessItem (org.talend.core.model.properties.ProcessItem)8 SQLPatternItem (org.talend.core.model.properties.SQLPatternItem)8 File (java.io.File)7 IFile (org.eclipse.core.resources.IFile)7 IMPORTType (org.talend.designer.core.model.utils.emf.component.IMPORTType)7 Project (org.talend.core.model.general.Project)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 HashSet (java.util.HashSet)5 PartInitException (org.eclipse.ui.PartInitException)5 SystemException (org.talend.commons.exception.SystemException)5 List (java.util.List)4