Search in sources :

Example 11 with Project

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

the class SynchronizeSchemaOnlyForPerlDemoMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @seeorg.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
     * ProcessItem)
     */
@Override
public ExecutionResult execute(Item item) {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    try {
        boolean modified = false;
        ECodeLanguage language = LanguageManager.getCurrentLanguage();
        if (language == ECodeLanguage.PERL) {
            Project project = ProjectManager.getInstance().getProject(item);
            if (project != null && project.getTechnicalLabel().equalsIgnoreCase("TALENDDEMOSPERL")) {
                //$NON-NLS-1$
                IProcess2 process = (IProcess2) RepositoryPlugin.getDefault().getDesignerCoreService().getProcessFromItem(item);
                modified = synchronizeSchema(process);
                if (modified) {
                    ProcessType processType = process.saveXmlFile();
                    if (item instanceof ProcessItem) {
                        ((ProcessItem) item).setProcess(processType);
                    } else if (item instanceof JobletProcessItem) {
                        ((JobletProcessItem) item).setJobletProcess((JobletProcess) processType);
                    }
                    factory.save(item, true);
                    return ExecutionResult.SUCCESS_NO_ALERT;
                }
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : Project(org.talend.core.model.properties.Project) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IProcess2(org.talend.core.model.process.IProcess2) JobletProcess(org.talend.designer.joblet.model.JobletProcess) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 12 with Project

use of org.talend.core.model.properties.Project in project tdq-studio-se by Talend.

the class PropertyHelper method extractProjectLabel.

/**
 * DOC bZhou Comment method "extractProjectLabel".
 *
 * This method is to extract the project technical label.
 *
 * @param property
 * @return
 */
public static String extractProjectLabel(Property property) {
    User author = property.getAuthor();
    if (author != null && !author.eIsProxy()) {
        InternalEObject iAuthor = (InternalEObject) property.getAuthor();
        Resource projResource = iAuthor.eResource();
        if (projResource != null) {
            URI uri = projResource.getURI();
            String pathString = uri.isPlatform() ? uri.toPlatformString(false) : uri.toFileString();
            IPath projectPath = new Path(pathString);
            Object projOBJ = EObjectHelper.retrieveEObject(projectPath, PropertiesPackage.eINSTANCE.getProject());
            if (projOBJ != null) {
                Project project = (Project) projOBJ;
                return project.getTechnicalLabel();
            }
        }
    }
    return ReponsitoryContextBridge.getProjectName();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Project(org.talend.core.model.properties.Project) User(org.talend.core.model.properties.User) IPath(org.eclipse.core.runtime.IPath) Resource(org.eclipse.emf.ecore.resource.Resource) EObject(org.eclipse.emf.ecore.EObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) URI(org.eclipse.emf.common.util.URI) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 13 with Project

use of org.talend.core.model.properties.Project in project tdq-studio-se by Talend.

the class FileSystemImportWriter method computeInput.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.imex.model.IImexWriter#computeInput(org.eclipse.core.runtime.IPath)
     */
public ItemRecord computeInput(IPath path) {
    if (path != null) {
        versionFile = path.append(EResourceConstant.LIBRARIES.getPath()).append(VERSION_FILE_NAME).toFile();
        definitionFile = path.append(EResourceConstant.LIBRARIES.getPath()).append(DEFINITION_FILE_NAME).toFile();
        if (!versionFile.exists()) {
            return null;
        }
        tempFolder = backUPWorksapce(path);
        if (tempFolder == null) {
            // the error is logged in #checkTempPath()
            return null;
        }
        IPath tempBasePath = new Path(tempFolder.getAbsolutePath());
        IPath projPath = tempBasePath.append(FileConstants.LOCAL_PROJECT_FILENAME);
        setBasePath(tempBasePath);
        if (projPath.toFile().exists()) {
            Object projOBJ = EObjectHelper.retrieveEObject(projPath, PropertiesPackage.eINSTANCE.getProject());
            if (projOBJ != null) {
                Project project = (Project) projOBJ;
                projectName = project.getTechnicalLabel();
            }
        } else {
            projectName = ReponsitoryContextBridge.getProjectName();
        }
        return new ItemRecord(tempFolder, tempBasePath);
    }
    return null;
}
Also used : Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) Project(org.talend.core.model.properties.Project) IPath(org.eclipse.core.runtime.IPath) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) EObject(org.eclipse.emf.ecore.EObject)

Example 14 with Project

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

the class CreateMavenDataServicePom method addProperties.

/*
     * @see org.talend.designer.maven.tools.creator.CreateMavenJobPom#addProperties(org.apache.maven.model.Model)
     */
@Override
protected void addProperties(Model model) {
    Properties properties = model.getProperties();
    if (properties == null) {
        properties = new Properties();
        model.setProperties(properties);
    }
    Property property = getJobProcessor().getProperty();
    Project project = ProjectManager.getInstance().getProject(property);
    if (project == null) {
        // current project
        project = ProjectManager.getInstance().getCurrentProject().getEmfProject();
    }
    String mainProjectBranch = ProjectManager.getInstance().getMainProjectBranch(project);
    if (mainProjectBranch == null) {
        mainProjectBranch = GITConstant.NAME_TRUNK;
    }
    // required by ci-builder
    checkPomProperty(properties, "talend.project.name", ETalendMavenVariables.ProjectName, project.getTechnicalLabel());
    checkPomProperty(properties, "talend.job.version", ETalendMavenVariables.TalendJobVersion, property.getVersion());
    checkPomProperty(properties, "talend.job.id", ETalendMavenVariables.JobId, property.getId());
    // add branch/git info
    org.talend.core.model.general.Project currentProject = ProjectManager.getInstance().getProjectFromProjectTechLabel(project.getTechnicalLabel());
    String branchName = ProjectManager.getInstance().getMainProjectBranch(project);
    try {
        if (branchName == null) {
            ProjectPreferenceManager preferenceManager = new ProjectPreferenceManager(currentProject, "org.talend.repository", false);
            branchName = preferenceManager.getValue(RepositoryConstants.PROJECT_BRANCH_ID);
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    if (null != branchName) {
        properties.setProperty("talend.project.branch.name", branchName);
    }
    try {
        if ((ProcessorUtilities.isCIMode() || !currentProject.isLocal()) && IGITProviderService.get() != null && IGITProviderService.get().isGITProject(currentProject) && IGitInfoService.get() != null) {
            additionalProperties.clear();
            additionalProperties.putAll(IGitInfoService.get().getGitInfo(property));
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    properties.setProperty("talend.job.git.author", additionalProperties.getOrDefault(IGitInfoService.GIT_AUTHOR, ""));
    properties.setProperty("talend.job.git.commit.id", additionalProperties.getOrDefault(IGitInfoService.GIT_COMMIT_ID, ""));
    properties.setProperty("talend.job.git.commit.date", additionalProperties.getOrDefault(IGitInfoService.GIT_COMMIT_DATE, ""));
}
Also used : Project(org.talend.core.model.properties.Project) ProjectPreferenceManager(org.talend.core.runtime.projectsetting.ProjectPreferenceManager) Properties(java.util.Properties) ActivationProperty(org.apache.maven.model.ActivationProperty) Property(org.talend.core.model.properties.Property)

Example 15 with Project

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

the class ExportItemWizardPage method performFinish.

public boolean performFinish() {
    if (!checkExportFile()) {
        return false;
    }
    ProjectManager pManager = ProjectManager.getInstance();
    Project project = pManager.getCurrentProject().getEmfProject();
    //$NON-NLS-1$
    String projectPath = lastPath + "\\" + project.getTechnicalLabel();
    if ((itemFromDirectoryRadio.getSelection() && new File(projectPath).exists()) || (itemFromArchiveRadio.getSelection() && new File(archivePathField.getText()).exists())) {
        File oldFile = new File(projectPath).exists() ? new File(projectPath) : new File(archivePathField.getText());
        if (MessageDialogWithToggle.openConfirm(null, Messages.getString("ExportItemWizardPage.waring"), Messages.getString("ExportItemWizardPage.fileAlreadyExist"))) {
            //$NON-NLS-1$ //$NON-NLS-2$
            deleteFile(oldFile);
        } else {
            return false;
        }
    }
    Collection<Item> selectedItems = getSelectedItems();
    if (exportDependencies.getSelection() && !implicitDependences.isEmpty()) {
        for (IRepositoryViewObject object : implicitDependences) {
            selectedItems.add(object.getProperty().getItem());
        }
    }
    List<String> folders = new ArrayList<String>();
    for (Object obj : filteredCheckboxTree.getViewer().getCheckedElements()) {
        if (obj instanceof RepositoryNode) {
            RepositoryNode repositoryNode = (RepositoryNode) obj;
            if (repositoryNode.getType() == ENodeType.SIMPLE_FOLDER && repositoryNode.getObject() instanceof Folder) {
                Folder folder = (Folder) repositoryNode.getObject();
                ERepositoryObjectType contentType = repositoryNode.getContentType();
                IProjectRepositoryNode root = repositoryNode.getRoot();
                if (root != null && root.getProject() != null) {
                    IPath path = new Path(root.getProject().getTechnicalLabel());
                    path = path.append(contentType.getFolder());
                    String folderPath = folder.getPath();
                    if (folderPath != null && !"".equals(folderPath)) {
                        path = path.append(folderPath);
                    }
                    path = path.append(folder.getLabel());
                    folders.add(path.toPortableString() + "/");
                }
            }
        }
    }
    try {
        ExportItemUtil exportItemUtil = new ExportItemUtil();
        if (itemFromArchiveRadio.getSelection()) {
            if (lastPath != null && !lastPath.endsWith(FileConstants.TAR_FILE_SUFFIX) && !lastPath.endsWith(FileConstants.TAR_GZ_FILE_SUFFIX) && !lastPath.endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
                // set zip as default
                lastPath = lastPath + FileConstants.ZIP_FILE_SUFFIX;
            }
        }
        // MOD sgandon 31/03/2010 bug 12229: moved getAllVersion into ExportItemUtil.exportitems() method.
        exportItemUtil.exportItems(new File(lastPath), selectedItems, folders, true, new NullProgressMonitor());
    } catch (Exception e) {
        MessageBoxExceptionHandler.process(e);
    }
    return true;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Folder(org.talend.core.model.repository.Folder) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProjectManager(org.talend.repository.ProjectManager) Project(org.talend.core.model.properties.Project) Item(org.talend.core.model.properties.Item) TreeItem(org.eclipse.swt.widgets.TreeItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) ExportItemUtil(org.talend.repository.local.ExportItemUtil) File(java.io.File) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode)

Aggregations

Project (org.talend.core.model.properties.Project)26 IProject (org.eclipse.core.resources.IProject)11 IPath (org.eclipse.core.runtime.IPath)10 Path (org.eclipse.core.runtime.Path)8 PersistenceException (org.talend.commons.exception.PersistenceException)7 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 File (java.io.File)5 Item (org.talend.core.model.properties.Item)5 ProcessItem (org.talend.core.model.properties.ProcessItem)5 ArrayList (java.util.ArrayList)4 CoreException (org.eclipse.core.runtime.CoreException)4 URI (org.eclipse.emf.common.util.URI)4 InternalEObject (org.eclipse.emf.ecore.InternalEObject)4 Property (org.talend.core.model.properties.Property)4 RoutineItem (org.talend.core.model.properties.RoutineItem)4 IOException (java.io.IOException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 EObject (org.eclipse.emf.ecore.EObject)3 Resource (org.eclipse.emf.ecore.resource.Resource)3 URL (java.net.URL)2