Search in sources :

Example 36 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class SetupProcessDependenciesRoutinesDialog method getAllReferenceProjects.

private void getAllReferenceProjects(Project currentProject, Set<Project> referenceProjects) {
    for (Project p : ProjectManager.getInstance().getReferencedProjects(currentProject)) {
        referenceProjects.add(p);
        getAllReferenceProjects(p, referenceProjects);
    }
}
Also used : Project(org.talend.core.model.general.Project)

Example 37 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class JavaProcessorUtilities method computeLibrariesPath.

/**
     * DOC nrousseau Comment method "computeLibrariesPath".
     * 
     * @param hashSet
     * @param process
     * @param alreadyRetrievedModules
     * @throws BusinessException
     */
public static void computeLibrariesPath(Set<ModuleNeeded> jobModuleList, IProcess process, Set<ModuleNeeded> alreadyRetrievedModules) throws ProcessorException {
    RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
    Project project = repositoryContext.getProject();
    if (projectSetup == null || !projectSetup.equals(project.getTechnicalLabel())) {
        projectSetup = project.getTechnicalLabel();
    }
    // use maven to update the class path.
    try {
        sortClasspath(jobModuleList, process, alreadyRetrievedModules);
    } catch (CoreException e) {
        ExceptionHandler.process(e);
    }
    if (alreadyRetrievedModules.isEmpty()) {
        // to update this only one time in one build of full job/subjobs
        checkAndUpdateLog4jFile();
    }
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) Project(org.talend.core.model.general.Project) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IProject(org.eclipse.core.resources.IProject) RepositoryContext(org.talend.core.context.RepositoryContext) CoreException(org.eclipse.core.runtime.CoreException)

Example 38 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class JavaProcessor method generateContextCode.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.runprocess.Processor#generateContextCode()
     */
@Override
public void generateContextCode() throws ProcessorException {
    RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
    Project project = repositoryContext.getProject();
    ICodeGenerator codeGen;
    ICodeGeneratorService service = RunProcessPlugin.getDefault().getCodeGeneratorService();
    //$NON-NLS-1$
    String javaInterpreter = "";
    //$NON-NLS-1$
    String javaLib = "";
    String currentJavaProject = project.getTechnicalLabel();
    String javaContext = getContextPath().toPortableString();
    codeGen = service.createCodeGenerator(process, false, false, javaInterpreter, javaLib, javaContext, currentJavaProject);
    updateContextCode(codeGen);
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) ICodeGenerator(org.talend.designer.codegen.ICodeGenerator) RepositoryContext(org.talend.core.context.RepositoryContext) ICodeGeneratorService(org.talend.designer.codegen.ICodeGeneratorService)

Example 39 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class TosTokenCollector method collectProjectDetails.

private JSONObject collectProjectDetails() throws PersistenceException, JSONException {
    JSONObject jObject = new JSONObject();
    Project currentProject = ProjectManager.getInstance().getCurrentProject();
    final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    JSONObject repoStats = new JSONObject();
    // metadata
    for (DynaEnum type : ERepositoryObjectType.values()) {
        if (type instanceof ERepositoryObjectType && ((ERepositoryObjectType) type).isResourceItem()) {
            try {
                List<IRepositoryViewObject> all = factory.getAll(currentProject, (ERepositoryObjectType) type);
                int nb = all.size();
                if (ERepositoryObjectType.TDQ_INDICATOR_ELEMENT.equals(type) || ERepositoryObjectType.TDQ_PATTERN_ELEMENT.equals(type) || ERepositoryObjectType.TDQ_RULES.equals(type) || "TDQ_SOURCE_FILE_ELEMENT".equals(type.getType())) {
                    //$NON-NLS-1$
                    continue;
                }
                if (ERepositoryObjectType.ROUTINES.equals(type)) {
                    nb = 0;
                    List<IRepositoryViewObject> newList = new ArrayList<IRepositoryViewObject>();
                    for (IRepositoryViewObject object : all) {
                        RoutineItem rItem = (RoutineItem) object.getProperty().getItem();
                        if (!rItem.isBuiltIn()) {
                            nb++;
                            newList.add(object);
                        }
                    }
                    all = newList;
                }
                if (ERepositoryObjectType.SQLPATTERNS.equals(type)) {
                    nb = 0;
                    for (IRepositoryViewObject object : all) {
                        SQLPatternItem spItem = (SQLPatternItem) object.getProperty().getItem();
                        if (!spItem.isSystem()) {
                            nb++;
                        }
                    }
                }
                if ("MDM.DataModel".equals(type.getType())) {
                    //$NON-NLS-1$
                    nb = 0;
                    for (IRepositoryViewObject object : all) {
                        String path = object.getProperty().getItem().getState().getPath();
                        if (!"System".equals(path)) {
                            //$NON-NLS-1$
                            nb++;
                        }
                    }
                }
                if (nb > 0) {
                    JSONObject typeStats = new JSONObject();
                    //$NON-NLS-1$
                    typeStats.put("nb", nb);
                    if (ERepositoryObjectType.getAllTypesOfProcess().contains(type)) {
                        JSONObject jobDetails = new JSONObject();
                        collectJobDetails(all, jobDetails);
                        //$NON-NLS-1$
                        typeStats.put("details", jobDetails);
                    }
                    if (ERepositoryObjectType.ROUTINES.equals(type) || //$NON-NLS-1$
                    ((ERepositoryObjectType) type).getFolder().startsWith("metadata/") || ERepositoryObjectType.CONTEXT.equals(type) || type.equals(ERepositoryObjectType.JOBLET)) {
                        int nbUsed = 0;
                        for (IRepositoryViewObject object : all) {
                            List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(object.getId());
                            relations.addAll(RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(object.getLabel()));
                            if (relations.size() > 0) {
                                nbUsed++;
                            }
                        }
                        //$NON-NLS-1$
                        typeStats.put("nb.used", nbUsed);
                    }
                    if (ERepositoryObjectType.METADATA_CONNECTIONS.equals(type)) {
                        JSONObject objects = new JSONObject();
                        for (IRepositoryViewObject object : all) {
                            DatabaseConnectionItem item = (DatabaseConnectionItem) object.getProperty().getItem();
                            String dbType = ((DatabaseConnection) item.getConnection()).getDatabaseType();
                            int nbDbTypes = 1;
                            if (objects.has(dbType)) {
                                nbDbTypes = objects.getInt(dbType);
                                nbDbTypes++;
                            }
                            objects.put(dbType, nbDbTypes);
                        }
                        //$NON-NLS-1$
                        typeStats.put("types", objects);
                    }
                    repoStats.put(type.getType(), typeStats);
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
            }
        }
    }
    //$NON-NLS-1$
    jObject.put(PROJECTS.getKey(), repoStats);
    jObject.put(TYPE.getKey(), ProjectManager.getInstance().getProjectType(currentProject));
    int nbRef = ProjectManager.getInstance().getAllReferencedProjects().size();
    if (nbRef > 0) {
        jObject.put("nb.refProjects", nbRef);
    }
    return jObject;
}
Also used : DynaEnum(org.talend.core.model.repository.DynaEnum) ArrayList(java.util.ArrayList) RoutineItem(org.talend.core.model.properties.RoutineItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) JSONException(us.monoid.json.JSONException) PersistenceException(org.talend.commons.exception.PersistenceException) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) Project(org.talend.core.model.general.Project) Relation(org.talend.core.model.relationship.Relation) JSONObject(us.monoid.json.JSONObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 40 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class AbstractConextAction method updateNodeToLastVersion.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.ui.actions.AContextualAction#updateNodeToLastVersion()
     */
@Override
protected void updateNodeToLastVersion() {
    if (repositoryNode == null || repositoryNode.getObject() == null || !(repositoryNode.getObject() instanceof RepositoryObject)) {
        return;
    }
    Property property = repositoryNode.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
// repositoryNode.getObject().setProperty(updatedProperty);
}
Also used : Project(org.talend.core.model.general.Project) RepositoryObject(org.talend.core.model.repository.RepositoryObject) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property)

Aggregations

Project (org.talend.core.model.general.Project)160 IProject (org.eclipse.core.resources.IProject)77 PersistenceException (org.talend.commons.exception.PersistenceException)73 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)34 ArrayList (java.util.ArrayList)24 IFolder (org.eclipse.core.resources.IFolder)23 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)23 Property (org.talend.core.model.properties.Property)21 File (java.io.File)20 Path (org.eclipse.core.runtime.Path)19 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)19 IPath (org.eclipse.core.runtime.IPath)18 IOException (java.io.IOException)17 RepositoryContext (org.talend.core.context.RepositoryContext)16 CoreException (org.eclipse.core.runtime.CoreException)14 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)14 IFile (org.eclipse.core.resources.IFile)13 Item (org.talend.core.model.properties.Item)13 User (org.talend.core.model.properties.User)13 Test (org.junit.Test)12