Search in sources :

Example 91 with Project

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

the class JSONFileOutputStep1Form method initFileContent.

private void initFileContent() {
    if (getConnection().getJSONFilePath() == null || "".equals(getConnection().getJSONFilePath())) {
        return;
    }
    byte[] bytes = getConnection().getFileContent();
    Project project = ProjectManager.getInstance().getCurrentProject();
    IProject fsProject = null;
    try {
        fsProject = ResourceUtils.getProject(project);
    } catch (PersistenceException e2) {
        ExceptionHandler.process(e2);
    }
    if (fsProject == null) {
        return;
    }
    String tem = fsProject.getLocationURI().getPath() + File.separator + "temp";
    String fileName = "";
    String jsonPath = getConnection().getJSONFilePath();
    if (isContextMode()) {
        ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection());
        jsonPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, jsonPath));
    }
    if (jsonPath != null && jsonPath.contains(".zip")) {
        fileName = new Path(jsonPath).lastSegment();
    } else if (jsonPath != null) {
        fileName = JSONUtil.TMP_JSON_FILE;
    }
    File temfile = new File(tem + File.separator + fileName);
    if (!temfile.exists()) {
        try {
            temfile.createNewFile();
        } catch (IOException e) {
            ExceptionHandler.process(e);
        }
    }
    FileOutputStream outStream;
    try {
        outStream = new FileOutputStream(temfile);
        outStream.write(bytes);
        outStream.close();
    } catch (FileNotFoundException e1) {
        ExceptionHandler.process(e1);
    } catch (IOException e) {
        ExceptionHandler.process(e);
    }
    tempJSONPath = temfile.getPath();
    if (isContextMode()) {
        ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection());
        tempJSONPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, tempJSONPath));
    }
// valid = this.treePopulator.populateTree(tempJSONXsdPath, treeNode);
}
Also used : Path(org.eclipse.core.runtime.Path) Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) FileOutputStream(java.io.FileOutputStream) PersistenceException(org.talend.commons.exception.PersistenceException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) RecordFile(orgomg.cwm.resource.record.RecordFile) File(java.io.File) IProject(org.eclipse.core.resources.IProject)

Example 92 with Project

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

the class JarBuilder method getTmpFolderPath.

private String getTmpFolderPath() {
    Project project = ProjectManager.getInstance().getCurrentProject();
    String tmpFolder;
    try {
        IProject physProject = ResourceModelUtils.getProject(project);
        tmpFolder = physProject.getFolder(TEMP).getLocation().toPortableString();
    } catch (Exception e) {
        //$NON-NLS-1$
        tmpFolder = System.getProperty("user.dir");
    }
    //$NON-NLS-1$
    tmpFolder = tmpFolder + "/talendExporter";
    return tmpFolder;
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) IOException(java.io.IOException)

Example 93 with Project

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

the class JavaCamelJobScriptsExportWSAction method getJobRepositoryNode.

private static IRepositoryNode getJobRepositoryNode(String jobId, ERepositoryObjectType type) throws PersistenceException {
    List<IRepositoryViewObject> list = new ArrayList<>();
    List<Project> projects = ProjectManager.getInstance().getAllReferencedProjects();
    for (Project p : projects) {
        list.addAll(ProxyRepositoryFactory.getInstance().getAll(p, type));
    }
    list.addAll(ProxyRepositoryFactory.getInstance().getAll(type));
    for (IRepositoryViewObject job : list) {
        if (job.getId().equals(jobId)) {
            return new RepositoryNode(job, null, ENodeType.REPOSITORY_ELEMENT);
        }
    }
    return null;
}
Also used : Project(org.talend.core.model.general.Project) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 94 with Project

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

the class JavaCamelJobScriptsExportWSAction method exportAllReferenceJobs.

private void exportAllReferenceJobs(String routeName, ProcessItem routeProcess) throws InvocationTargetException, InterruptedException {
    for (NodeType cTalendJob : EmfModelUtils.getComponentsByName(routeProcess, "cTalendJob")) {
        //$NON-NLS-1$
        String jobId = null;
        String jobVersion = null;
        String jobContext = null;
        for (Object o : cTalendJob.getElementParameter()) {
            if (!(o instanceof ElementParameterType)) {
                continue;
            }
            ElementParameterType ept = (ElementParameterType) o;
            String eptName = ept.getName();
            if ("FROM_EXTERNAL_JAR".equals(eptName) && "true".equals(ept.getValue())) {
                //$NON-NLS-1$
                break;
            }
            if ("SELECTED_JOB_NAME:PROCESS_TYPE_PROCESS".equals(eptName)) {
                //$NON-NLS-1$
                jobId = ept.getValue();
            } else if ("SELECTED_JOB_NAME:PROCESS_TYPE_VERSION".equals(eptName)) {
                //$NON-NLS-1$
                jobVersion = ept.getValue();
            } else if ("SELECTED_JOB_NAME:PROCESS_TYPE_CONTEXT".equals(eptName)) {
                //$NON-NLS-1$
                jobContext = ept.getValue();
            }
        }
        if (jobId == null || jobVersion == null) {
            continue;
        }
        IRepositoryNode referencedJobNode;
        try {
            referencedJobNode = getJobRepositoryNode(jobId, ERepositoryObjectType.PROCESS);
        } catch (PersistenceException e) {
            throw new InvocationTargetException(e);
        }
        if (RelationshipItemBuilder.LATEST_VERSION.equals(jobVersion)) {
            jobVersion = referencedJobNode.getObject().getVersion();
        }
        String jobName = referencedJobNode.getObject().getProperty().getDisplayName();
        String jobBundleName = routeName + "_" + jobName;
        String jobBundleSymbolicName = jobBundleName;
        Project project = ProjectManager.getInstance().getCurrentProject();
        if (project != null) {
            String projectName = project.getLabel();
            if (projectName != null && projectName.length() > 0) {
                jobBundleSymbolicName = projectName.toLowerCase() + '.' + jobBundleSymbolicName;
            }
        }
        File jobFile;
        try {
            jobFile = File.createTempFile("job", FileConstants.JAR_FILE_SUFFIX, //$NON-NLS-1$
            new File(getTempDir()));
        } catch (IOException e) {
            throw new InvocationTargetException(e);
        }
        String jobArtifactVersion = getArtifactVersion();
        String jobBundleVersion = bundleVersion;
        BundleModel jobModel = new BundleModel(getGroupId(), jobBundleName, jobArtifactVersion, jobFile);
        if (featuresModel.addBundle(jobModel)) {
            exportRouteUsedJobBundle(referencedJobNode, jobFile, jobVersion, jobBundleName, jobBundleSymbolicName, jobBundleVersion, getArtifactId(), version, jobContext);
        }
    }
}
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) 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) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) 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