Search in sources :

Example 61 with Project

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

the class TosTokenCollector method priorCollect.

@Override
public void priorCollect() throws Exception {
    // for all projects
    JSONObject allProjectRecords = null;
    IPreferenceStore preferenceStore = RepositoryPlugin.getDefault().getPreferenceStore();
    String records = preferenceStore.getString(PREF_TOS_JOBS_RECORDS);
    try {
        // reset
        allProjectRecords = new JSONObject(records);
    } catch (Exception e) {
        // the value is not set, or is empty
        allProjectRecords = new JSONObject();
    }
    JSONObject currentProjectObject = collectProjectDetails();
    Project currentProject = ProjectManager.getInstance().getCurrentProject();
    allProjectRecords.put(currentProject.getTechnicalLabel(), currentProjectObject);
    //
    preferenceStore.setValue(PREF_TOS_JOBS_RECORDS, allProjectRecords.toString());
}
Also used : Project(org.talend.core.model.general.Project) JSONObject(us.monoid.json.JSONObject) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) JSONException(us.monoid.json.JSONException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 62 with Project

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

the class NewProjectWizard method performFinish.

/**
     * @see org.eclipse.jface.wizard.Wizard#performFinish()
     */
@Override
public boolean performFinish() {
    IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
    Context ctx = CorePlugin.getContext();
    RepositoryContext repositoryContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
    try {
        Project projectInfor = ProjectHelper.createProject(mainPage.getName().trim().replace(' ', '_'), mainPage.getDescription(), mainPage.getLanguage(), repositoryContext.getUser());
        project = repositoryFactory.createProject(projectInfor);
        return true;
    } catch (PersistenceException e) {
        MessageDialog.openError(getShell(), Messages.getString("NewProjectWizard.failureTitle"), //$NON-NLS-1$
        Messages.getString(//$NON-NLS-1$ //$NON-NLS-2$
        "NewProjectWizard.failureText"));
        MessageBoxExceptionHandler.process(e);
        return false;
    }
}
Also used : Context(org.talend.core.context.Context) RepositoryContext(org.talend.core.context.RepositoryContext) Project(org.talend.core.model.general.Project) RepositoryContext(org.talend.core.context.RepositoryContext) PersistenceException(org.talend.commons.exception.PersistenceException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 63 with Project

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

the class UserComponentsProviderTest method cleanComponentsInProject.

private void cleanComponentsInProject() throws Exception {
    final Project currentProject = ProjectManager.getInstance().getCurrentProject();
    final IProject project = ResourceUtils.getProject(currentProject);
    final IFolder projectComponentsFolder = project.getFolder(ERepositoryObjectType.getFolderName(ERepositoryObjectType.COMPONENTS));
    if (projectComponentsFolder.exists()) {
        FilesUtils.deleteFolder(projectComponentsFolder.getLocation().toFile(), false);
    }
    projectComponentsFolder.refreshLocal(IResource.DEPTH_INFINITE, null);
}
Also used : Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 64 with Project

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

the class UserComponentsProviderTest method test_preComponentsLoad_contain_newComponentsInProject.

@Test
public void test_preComponentsLoad_contain_newComponentsInProject() throws Exception {
    File testDataFile = getTestDataFile(PATH_NEW_COMPONENT);
    Assert.assertTrue(testDataFile.exists());
    final Project currentProject = ProjectManager.getInstance().getCurrentProject();
    final IProject project = ResourceUtils.getProject(currentProject);
    final IFolder projectComponentsFolder = project.getFolder(ERepositoryObjectType.getFolderName(ERepositoryObjectType.COMPONENTS));
    Assert.assertTrue(projectComponentsFolder.exists());
    final File target = new File(projectComponentsFolder.getLocation().toFile(), testDataFile.getName());
    FilesUtils.copyFile(testDataFile, target);
    UserComponentsProviderTestClass provider = new UserComponentsProviderTestClass() {

        protected File getExternalComponentsLocation() {
            return workFolder;
        }
    };
    provider.preComponentsLoad();
    testEmpty(provider);
    FilesUtils.deleteFolder(target.getParentFile(), false);
}
Also used : Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) File(java.io.File) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 65 with Project

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

the class ConvertJSONString method changeJsonToXml.

public static String changeJsonToXml(String jsonPath) {
    Project project = ProjectManager.getInstance().getCurrentProject();
    IProject fsProject = null;
    try {
        fsProject = ResourceUtils.getProject(project);
    } catch (PersistenceException e2) {
        ExceptionHandler.process(e2);
    }
    if (fsProject == null) {
        return jsonPath;
    }
    String temPath = fsProject.getLocationURI().getPath() + File.separator + "temp" + File.separator + "jsonwizard" + File.separator;
    try {
        File file = new File(jsonPath);
        String filename = file.getName().replaceAll("\\.", "_");
        FileInputStream input = new FileInputStream(file);
        String jsonData = IOUtils.toString(input);
        XMLSerializer serializer = new XMLSerializer();
        JSON json = JSONSerializer.toJSON(jsonData);
        serializer.setRootName("JSONRoot");
        serializer.setTypeHintsEnabled(false);
        String xml = serializer.write(json);
        File xmlFolder = new File(temPath);
        if (!xmlFolder.exists()) {
            xmlFolder.mkdirs();
        }
        temPath = temPath + filename + ".xml";
        FileWriter writer = new FileWriter(temPath);
        writer.write(xml);
        writer.flush();
        writer.close();
    } catch (IOException e) {
        ExceptionHandler.process(e);
        return jsonPath;
    }
    return temPath;
}
Also used : Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) XMLSerializer(net.sf.json.xml.XMLSerializer) FileWriter(java.io.FileWriter) PersistenceException(org.talend.commons.exception.PersistenceException) JSON(net.sf.json.JSON) IOException(java.io.IOException) File(java.io.File) IProject(org.eclipse.core.resources.IProject) FileInputStream(java.io.FileInputStream)

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