Search in sources :

Example 51 with Project

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

the class ESBService method editJobName.

@Override
public void editJobName(String originaleObjectLabel, String newLabel) {
    IProxyRepositoryFactory proxyRepositoryFactory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    Project project = ProjectManager.getInstance().getCurrentProject();
    List<IRepositoryViewObject> service = null;
    try {
        service = proxyRepositoryFactory.getAll(project, ESBRepositoryNodeType.SERVICES, true);
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    if (service != null && service.size() > 0) {
        for (IRepositoryViewObject Object : service) {
            boolean flag = false;
            ServiceItem item = (ServiceItem) Object.getProperty().getItem();
            ServiceConnection serviceConnection = (ServiceConnection) item.getConnection();
            List<ServicePort> servicePorts = serviceConnection.getServicePort();
            for (ServicePort port : servicePorts) {
                List<ServiceOperation> serviceOperations = port.getServiceOperation();
                for (ServiceOperation operation : serviceOperations) {
                    String originaleItemLabel = operation.getLabel();
                    if (originaleItemLabel.contains("-")) {
                        String[] array = originaleItemLabel.split("-");
                        if (originaleObjectLabel.equals(array[1])) {
                            operation.setLabel(array[0] + "-" + newLabel);
                            flag = true;
                        }
                    }
                }
            }
            if (flag) {
                try {
                    proxyRepositoryFactory.save(item);
                } catch (PersistenceException e) {
                    ExceptionHandler.process(e);
                }
            }
        }
    }
// RepositoryManager.refresh(ESBRepositoryNodeType.SERVICES);
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) Project(org.talend.core.model.general.Project) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 52 with Project

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

the class DemosImportTest method createTempDemoProject.

protected void createTempDemoProject(String demoName) throws CoreException, PersistenceException {
    Project projectInfor = new Project();
    projectInfor.setLabel(demoName);
    projectInfor.setDescription("no desc");
    projectInfor.setLanguage(ECodeLanguage.JAVA);
    User user = PropertiesFactory.eINSTANCE.createUser();
    user.setLogin("testauto@talend.com");
    projectInfor.setAuthor(user);
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    String technicalLabel = Project.createTechnicalName(projectInfor.getLabel());
    IProject prj = root.getProject(technicalLabel);
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    try {
        IProjectDescription desc = null;
        if (prj.exists()) {
            // always delete to avoid conflicts between 2 tests
            prj.delete(true, null);
        }
        desc = workspace.newProjectDescription(technicalLabel);
        desc.setNatureIds(new String[] { TalendNature.ID });
        desc.setComment(projectInfor.getDescription());
        prj.create(desc, null);
        prj.open(IResource.DEPTH_INFINITE, null);
        prj.setDefaultCharset("UTF-8", null);
    } catch (CoreException e) {
        throw new PersistenceException(e);
    }
    tempDemoProject = new Project();
    // Fill project object
    tempDemoProject.setLabel(projectInfor.getLabel());
    tempDemoProject.setDescription(projectInfor.getDescription());
    tempDemoProject.setLanguage(projectInfor.getLanguage());
    tempDemoProject.setAuthor(projectInfor.getAuthor());
    tempDemoProject.setLocal(true);
    tempDemoProject.setTechnicalLabel(technicalLabel);
    XmiResourceManager xmiResourceManager = new XmiResourceManager();
    Resource projectResource = xmiResourceManager.createProjectResource(prj);
    projectResource.getContents().add(tempDemoProject.getEmfProject());
    projectResource.getContents().add(tempDemoProject.getAuthor());
    xmiResourceManager.saveResource(projectResource);
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) User(org.talend.core.model.properties.User) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) IProjectDescription(org.eclipse.core.resources.IProjectDescription) PersistenceException(org.talend.commons.exception.PersistenceException) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) XmiResourceManager(org.talend.core.repository.utils.XmiResourceManager) IProject(org.eclipse.core.resources.IProject)

Example 53 with Project

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

the class AddContextCommentValueMigrationTaskTest method createTempProject.

private static void createTempProject() throws CoreException, PersistenceException, LoginException {
    Project projectInfor = new Project();
    projectInfor.setLabel("testauto");
    projectInfor.setDescription("no desc");
    projectInfor.setLanguage(ECodeLanguage.JAVA);
    User user = PropertiesFactory.eINSTANCE.createUser();
    user.setLogin("testauto@talend.com");
    projectInfor.setAuthor(user);
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    String technicalLabel = Project.createTechnicalName(projectInfor.getLabel());
    IProject prj = root.getProject(technicalLabel);
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    try {
        IProjectDescription desc = null;
        if (prj.exists()) {
            // always delete to avoid conflicts between 2 tests
            prj.delete(true, null);
        }
        desc = workspace.newProjectDescription(technicalLabel);
        desc.setNatureIds(new String[] { TalendNature.ID });
        desc.setComment(projectInfor.getDescription());
        prj.create(desc, null);
        prj.open(IResource.DEPTH_INFINITE, null);
        prj.setDefaultCharset("UTF-8", null);
    } catch (CoreException e) {
        throw new PersistenceException(e);
    }
    sampleProject = new Project();
    // Fill project object
    sampleProject.setLabel(projectInfor.getLabel());
    sampleProject.setDescription(projectInfor.getDescription());
    sampleProject.setLanguage(projectInfor.getLanguage());
    sampleProject.setAuthor(projectInfor.getAuthor());
    sampleProject.setLocal(true);
    sampleProject.setTechnicalLabel(technicalLabel);
    XmiResourceManager xmiResourceManager = new XmiResourceManager();
    Resource projectResource = xmiResourceManager.createProjectResource(prj);
    projectResource.getContents().add(sampleProject.getEmfProject());
    projectResource.getContents().add(sampleProject.getAuthor());
    xmiResourceManager.saveResource(projectResource);
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) User(org.talend.core.model.properties.User) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) IProjectDescription(org.eclipse.core.resources.IProjectDescription) PersistenceException(org.talend.commons.exception.PersistenceException) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) XmiResourceManager(org.talend.core.repository.utils.XmiResourceManager) IProject(org.eclipse.core.resources.IProject)

Example 54 with Project

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

the class FixUnevenItemContextParametersMigrationTaskTest method createTempProject.

private static void createTempProject() throws CoreException, PersistenceException, LoginException {
    Project projectInfor = new Project();
    projectInfor.setLabel("testauto");
    projectInfor.setDescription("no desc");
    projectInfor.setLanguage(ECodeLanguage.JAVA);
    User user = PropertiesFactory.eINSTANCE.createUser();
    user.setLogin("testauto@talend.com");
    projectInfor.setAuthor(user);
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    String technicalLabel = Project.createTechnicalName(projectInfor.getLabel());
    IProject prj = root.getProject(technicalLabel);
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    try {
        IProjectDescription desc = null;
        if (prj.exists()) {
            // always delete to avoid conflicts between 2 tests
            prj.delete(true, null);
        }
        desc = workspace.newProjectDescription(technicalLabel);
        desc.setNatureIds(new String[] { TalendNature.ID });
        desc.setComment(projectInfor.getDescription());
        prj.create(desc, null);
        prj.open(IResource.DEPTH_INFINITE, null);
        prj.setDefaultCharset("UTF-8", null);
    } catch (CoreException e) {
        throw new PersistenceException(e);
    }
    sampleProject = new Project();
    // Fill project object
    sampleProject.setLabel(projectInfor.getLabel());
    sampleProject.setDescription(projectInfor.getDescription());
    sampleProject.setLanguage(projectInfor.getLanguage());
    sampleProject.setAuthor(projectInfor.getAuthor());
    sampleProject.setLocal(true);
    sampleProject.setTechnicalLabel(technicalLabel);
    XmiResourceManager xmiResourceManager = new XmiResourceManager();
    Resource projectResource = xmiResourceManager.createProjectResource(prj);
    projectResource.getContents().add(sampleProject.getEmfProject());
    projectResource.getContents().add(sampleProject.getAuthor());
    xmiResourceManager.saveResource(projectResource);
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) User(org.talend.core.model.properties.User) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) IProjectDescription(org.eclipse.core.resources.IProjectDescription) PersistenceException(org.talend.commons.exception.PersistenceException) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) XmiResourceManager(org.talend.core.repository.utils.XmiResourceManager) IProject(org.eclipse.core.resources.IProject)

Example 55 with Project

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

the class JavaCamelJobScriptsExportWSAction method exportAllReferenceRoutelets.

@SuppressWarnings("unchecked")
protected final void exportAllReferenceRoutelets(String routeName, ProcessItem routeProcess, Set<String> routelets) throws InvocationTargetException, InterruptedException {
    for (NodeType node : (Collection<NodeType>) routeProcess.getProcess().getNode()) {
        if (!EmfModelUtils.isComponentActive(node)) {
            continue;
        }
        final ElementParameterType routeletId = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_PROCESS.getName(), node);
        if (null != routeletId) {
            final IRepositoryNode referencedRouteletNode;
            try {
                referencedRouteletNode = getJobRepositoryNode(routeletId.getValue(), CamelRepositoryNodeType.repositoryRouteletType);
            // getRouteletRepositoryNode(routeletId);
            } catch (PersistenceException e) {
                throw new InvocationTargetException(e);
            }
            final ProcessItem routeletProcess = (ProcessItem) referencedRouteletNode.getObject().getProperty().getItem();
            final String className = RouteJavaScriptOSGIForESBManager.getClassName(routeletProcess);
            String idSuffix = "-" + routeName;
            if (!routelets.add(className + idSuffix)) {
                continue;
            }
            String routeletVersion = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_VERSION.getName(), node).getValue();
            if (RelationshipItemBuilder.LATEST_VERSION.equals(routeletVersion)) {
                routeletVersion = referencedRouteletNode.getObject().getVersion();
            }
            final File routeletFile;
            try {
                routeletFile = File.createTempFile("routelet", FileConstants.JAR_FILE_SUFFIX, //$NON-NLS-1$
                new File(getTempDir()));
            } catch (IOException e) {
                throw new InvocationTargetException(e);
            }
            String routeletName = referencedRouteletNode.getObject().getLabel();
            String routeletBundleName = routeName + "_" + routeletName;
            String routeletBundleSymbolicName = routeletBundleName;
            Project project = ProjectManager.getInstance().getCurrentProject();
            if (project != null) {
                String projectName = project.getLabel();
                if (projectName != null && projectName.length() > 0) {
                    routeletBundleSymbolicName = projectName.toLowerCase() + '.' + routeletBundleSymbolicName;
                }
            }
            BundleModel routeletModel = new BundleModel(getGroupId(), routeletBundleName, getArtifactVersion(), routeletFile);
            if (featuresModel.addBundle(routeletModel)) {
                exportRouteBundle(referencedRouteletNode, routeletFile, routeletVersion, routeletBundleName, routeletBundleSymbolicName, bundleVersion, idSuffix, null, EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_CONTEXT.getName(), node).getValue());
                CamelFeatureUtil.addFeatureAndBundles(routeletProcess, featuresModel);
                exportAllReferenceRoutelets(routeName, routeletProcess, routelets);
            }
        }
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) Project(org.talend.core.model.general.Project) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ProcessItem(org.talend.core.model.properties.ProcessItem) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) CamelRepositoryNodeType(org.talend.camel.model.CamelRepositoryNodeType) PersistenceException(org.talend.commons.exception.PersistenceException) BundleModel(org.talend.designer.publish.core.models.BundleModel) Collection(java.util.Collection) IOException(java.io.IOException) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

Project (org.talend.core.model.general.Project)94 PersistenceException (org.talend.commons.exception.PersistenceException)47 IProject (org.eclipse.core.resources.IProject)38 File (java.io.File)18 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)18 ArrayList (java.util.ArrayList)17 IOException (java.io.IOException)13 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 RepositoryContext (org.talend.core.context.RepositoryContext)12 Property (org.talend.core.model.properties.Property)12 CoreException (org.eclipse.core.runtime.CoreException)10 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)10 List (java.util.List)9 IFolder (org.eclipse.core.resources.IFolder)8 Path (org.eclipse.core.runtime.Path)8 SystemException (org.talend.commons.exception.SystemException)8 JSONException (org.talend.utils.json.JSONException)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)7 ConnectionBean (org.talend.core.model.general.ConnectionBean)7 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)7