use of org.talend.core.model.properties.Project in project tdi-studio-se by Talend.
the class BuildJobHandler method addDQDependencies.
private void addDQDependencies(IFolder parentFolder, List<Item> items) throws Exception {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQItemService.class)) {
ITDQItemService tdqItemService = (ITDQItemService) GlobalServiceRegister.getDefault().getService(ITDQItemService.class);
for (Item item : items) {
if (tdqItemService != null && tdqItemService.hasProcessItemDependencies(Arrays.asList(new Item[] { item }))) {
setNeedItemDependencies(true);
// add .Talend.definition file
//$NON-NLS-1$
String defIdxFolderName = "TDQ_Libraries";
//$NON-NLS-1$
String defIdxFileName = ".Talend.definition";
Project pro = getProject(processItem);
IFolder itemsProjectFolder = parentFolder.getFolder(pro.getTechnicalLabel().toLowerCase());
File itemsFolderDir = new File(parentFolder.getLocation().toFile().getAbsolutePath());
IProject project = ReponsitoryContextBridge.getRootProject();
String defIdxRelativePath = defIdxFolderName + PATH_SEPARATOR + defIdxFileName;
IFile defIdxFile = project.getFile(defIdxRelativePath);
if (defIdxFile.exists()) {
File defIdxFileSource = new File(project.getLocation().makeAbsolute().append(defIdxFolderName).append(defIdxFileName).toFile().toURI());
File defIdxFileTarget = new File(itemsProjectFolder.getFile(defIdxRelativePath).getLocation().toFile().getAbsolutePath());
FilesUtils.copyFile(defIdxFileSource, defIdxFileTarget);
}
// add report header image & template files
//$NON-NLS-1$
String reportingBundlePath = PluginChecker.getBundlePath("org.talend.dataquality.reporting");
//$NON-NLS-1$
File imageFolder = new File(reportingBundlePath + PATH_SEPARATOR + "images");
if (imageFolder.exists()) {
FilesUtils.copyDirectory(imageFolder, itemsFolderDir);
}
//$NON-NLS-1$
File templateFolder = new File(reportingBundlePath + PATH_SEPARATOR + "reports");
if (templateFolder.exists() && templateFolder.isDirectory()) {
FilesUtils.copyDirectory(templateFolder, itemsFolderDir);
}
}
}
// maven command 'include-survivorship-rules' to export.
if (!isOptionChoosed(ExportChoice.needJobItem)) {
ExportFileResource resouece = new ExportFileResource();
BuildExportManager.getInstance().exportDependencies(resouece, processItem);
if (!resouece.getAllResources().isEmpty()) {
final Iterator<String> relativepath = resouece.getRelativePathList().iterator();
//$NON-NLS-1$
String pathStr = "metadata/survivorship";
IFolder targetFolder = talendProcessJavaProject.getResourcesFolder();
if (targetFolder.exists()) {
IFolder survFolder = targetFolder.getFolder(new Path(pathStr));
// only copy self job rules, clear the 'survivorship' folder before copy.
if (survFolder.exists()) {
survFolder.delete(true, null);
}
while (relativepath.hasNext()) {
String relativePath = relativepath.next();
Set<URL> sources = resouece.getResourcesByRelativePath(relativePath);
for (URL sourceUrl : sources) {
File currentResource = new File(org.talend.commons.utils.io.FilesUtils.getFileRealPath(sourceUrl.getPath()));
if (currentResource.exists()) {
FilesUtils.copyDirectory(currentResource, new File(targetFolder.getLocation().toPortableString() + File.separator + pathStr));
}
}
}
}
}
parentFolder.refreshLocal(IResource.DEPTH_INFINITE, null);
}
}
}
use of org.talend.core.model.properties.Project in project tdi-studio-se by Talend.
the class TalendWizardProjectsImportPage method createProjects.
@SuppressWarnings("restriction")
@Override
public boolean createProjects() {
// TDI-19269
final boolean created = super.createProjects();
//
final Object[] selected = getProjectsList().getCheckedElements();
XmiResourceManager xmiManager = new XmiResourceManager();
try {
for (Object element : selected) {
final ProjectRecord record = (ProjectRecord) element;
String projectName = record.getProjectName();
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProject project = workspace.getRoot().getProject(projectName);
try {
final Project loadProject = xmiManager.loadProject(project);
loadProject.setLocal(true);
loadProject.setId(0);
loadProject.setUrl(null);
loadProject.setCreationDate(null);
//loadProject.setDescription(""); //$NON-NLS-1$
loadProject.setType(null);
xmiManager.saveResource(loadProject.eResource());
// FIXME TDI-22786, migrate the project name.
if (ProjectManager.enableSpecialTechnicalProjectName()) {
ChangeProjectTechinicalNameMigrationTask migrationTask = new ChangeProjectTechinicalNameMigrationTask();
migrationTask.migrateTalendProject(project, loadProject, xmiManager);
}
} catch (PersistenceException e) {
//
}
}
} finally {
xmiManager.unloadResources();
}
return created;
//
}
use of org.talend.core.model.properties.Project in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getChildrenJobAndContextName.
protected void getChildrenJobAndContextName(ExportFileResource[] allResources, String rootName, List<JobInfo> list, ProcessItem process, String projectName, List<ProcessItem> processedJob, List<URL> allJobScripts, ExportFileResource resource, Map<ExportChoice, Object> exportChoice, String... selectedJobVersion) {
if (processedJob.contains(process)) {
// prevent circle
return;
}
processedJob.add(process);
ProjectManager projectManager = ProjectManager.getInstance();
Project project = projectManager.getProject(process);
String childProjectName = projectName;
if (project != null) {
// hywang modify for 7932
childProjectName = project.getTechnicalLabel().toLowerCase();
}
allJobScripts.addAll(getJobScripts(childProjectName, process.getProperty().getLabel(), process.getProperty().getVersion(), isOptionChoosed(ExportChoice.needJobScript)));
addContextScripts(process, process.getProperty().getLabel(), process.getProperty().getVersion(), resource, isOptionChoosed(ExportChoice.needContext));
addJobItem(allResources, process, isOptionChoosed(ExportChoice.needJobItem), resource);
addDependencies(allResources, process, isOptionChoosed(ExportChoice.needDependencies) && isOptionChoosed(ExportChoice.needJobItem), resource);
addSourceCode(allResources, process, isOptionChoosed(ExportChoice.needSourceCode), resource);
addDependenciesSourceCode(allResources, resource, isOptionChoosed(ExportChoice.needSourceCode));
Set<JobInfo> subjobInfos = ProcessorUtilities.getChildrenJobInfo(process);
for (JobInfo subjobInfo : subjobInfos) {
if (list.contains(subjobInfo)) {
continue;
}
list.add(subjobInfo);
getChildrenJobAndContextName(allResources, rootName, list, subjobInfo.getProcessItem(), projectName, processedJob, allJobScripts, resource, exportChoice);
}
}
use of org.talend.core.model.properties.Project in project tdi-studio-se by Talend.
the class MigrationTaskForIssue18419 method execute.
@Override
public ExecutionResult execute(final Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
//$NON-NLS-1$
IComponentFilter filter = new NameComponentFilter("tFileUnarchive");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
@Override
public void transform(NodeType node) {
Project pro = ProxyRepositoryFactory.getInstance().getProject(item);
String proName = pro.getLabel();
//$NON-NLS-1$
ElementParameterType zipFile = ComponentUtilities.getNodeProperty(node, "ZIPFILE");
String zipFileName = zipFile.getValue();
final String oldValues = getOldValues();
if (proName != null && !proName.equals(getDemoProjectName()) && zipFileName != null && zipFileName.equals(oldValues)) {
zipFile.setValue(oldValues.replaceFirst(getDemoProjectName(), proName));
}
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.core.model.properties.Project in project tdi-studio-se by Talend.
the class ChangeProjectTechinicalNameMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.migration.IWorkspaceMigrationTask#execute()
*/
@Override
public boolean execute() {
if (!ProjectManager.enableSpecialTechnicalProjectName()) {
// no need to do migration.
return false;
}
try {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
try {
root.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
IProject[] projects = root.getProjects();
for (IProject localProject : projects) {
try {
if (localProject.hasNature(TalendNature.ID)) {
// only for talend project
Project talendProject = xmiResManager.loadProject(localProject);
if (needCheckProject(localProject, talendProject)) {
checkTalendProject(localProject, talendProject);
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
return false;
}
}
} finally {
xmiResManager.unloadResources();
}
// always true, no need do again.
return true;
}
Aggregations