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;
}
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();
}
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;
}
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, ""));
}
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;
}
Aggregations