use of org.talend.core.model.properties.Project in project tdi-studio-se by Talend.
the class ImportItemUtil method populateItems.
/**
* need to returns sorted items by version to correctly import them later.
*/
public List<ItemRecord> populateItems(ResourcesManager collector, boolean overwrite, IProgressMonitor progressMonitor) {
TimeMeasure.display = CommonsPlugin.isDebugMode();
TimeMeasure.displaySteps = CommonsPlugin.isDebugMode();
TimeMeasure.measureActive = CommonsPlugin.isDebugMode();
TimeMeasure.begin("populateItems");
treeBuilder.clear();
if ((!CommonsPlugin.isSameProjectLogonCommline() && CommonsPlugin.isHeadless()) || !CommonsPlugin.isHeadless() || !ProjectManager.getInstance().getCurrentProject().isLocal()) {
cache.clear();
}
projects.clear();
routineExtModulesMap.clear();
List<ItemRecord> items = new ArrayList<ItemRecord>();
int nbItems = 0;
for (IPath path : collector.getPaths()) {
if (isPropertyPath(path)) {
nbItems++;
}
}
//$NON-NLS-1$
progressMonitor.beginTask("Populate items to import", nbItems);
for (IPath path : collector.getPaths()) {
if (!progressMonitor.isCanceled()) {
if (isPropertyPath(path)) {
// IPath itemPath = getItemPath(path);
// if (collector.getPaths().contains(itemPath)) { //commet by tdq import
ItemRecord itemRecord = computeItemRecord(collector, path);
if (itemRecord.getProperty() != null) {
items.add(itemRecord);
if (checkItem(itemRecord, overwrite)) {
InternalEObject author = (InternalEObject) itemRecord.getProperty().getAuthor();
URI uri = null;
if (author != null) {
uri = author.eProxyURI();
}
IPath projectFilePath = getValidProjectFilePath(collector, path, uri);
if (projectFilePath != null) {
Project project = computeProject(collector, itemRecord, projectFilePath);
if (checkProject(project, itemRecord)) {
if (!checkHadoopSubitem(collector, itemRecord)) {
treeBuilder.addItem(project, itemRecord);
}
// set item project into record.
itemRecord.setItemProject(project);
// and we will try to resolve user
if (uri != null) {
User user = (User) project.eResource().getEObject(uri.fragment());
itemRecord.getProperty().setAuthor(user);
}
}
} else {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(itemRecord.getItem());
if (itemType.isDIItemType()) {
//$NON-NLS-1$
itemRecord.addError(Messages.getString("RepositoryUtil.ProjectNotFound"));
}
}
}
}
// }
progressMonitor.worked(1);
}
} else {
break;
}
}
Collections.sort(items, new Comparator<ItemRecord>() {
@Override
public int compare(ItemRecord o1, ItemRecord o2) {
return VersionUtils.compareTo(o1.getProperty().getVersion(), o2.getProperty().getVersion());
}
});
if (!CommonsPlugin.isHeadless() || !ProjectManager.getInstance().getCurrentProject().isLocal()) {
for (List<IRepositoryViewObject> list : cache.getItemsFromRepository().values()) {
list.clear();
}
cache.getItemsFromRepository().clear();
}
TimeMeasure.end("populateItems");
TimeMeasure.display = false;
TimeMeasure.displaySteps = false;
TimeMeasure.measureActive = false;
return items;
}
use of org.talend.core.model.properties.Project in project tdi-studio-se by Talend.
the class JobLaunchShortcutManager method renameJobLaunch.
/**
*
* cli Comment method "renameJobLaunch".
*/
public static void renameJobLaunch(IRepositoryViewObject obj, String oldLabel) {
if (obj == null) {
return;
}
Property property = obj.getProperty();
if (property == null || !(property.getItem() instanceof ProcessItem)) {
return;
}
String newLabel = property.getLabel();
if (!newLabel.equals(oldLabel)) {
Project project = ProjectManager.getInstance().getProject(property);
if (project == null) {
return;
}
final String objProjectName = project.getLabel();
final String id = property.getId();
final String version = property.getVersion();
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
if (launchManager == null) {
return;
}
try {
for (ILaunchConfiguration configuration : launchManager.getLaunchConfigurations()) {
String jobId = configuration.getAttribute(TalendDebugUIConstants.JOB_ID, (String) null);
String jobVersion = configuration.getAttribute(TalendDebugUIConstants.JOB_VERSION, (String) null);
String projectName = configuration.getAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, (String) null);
// ILaunchConfigurationType type = launchManager
// .getLaunchConfigurationType(TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE);
ILaunchConfigurationType type = configuration.getType();
if (type != null && TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE.equals(type.getIdentifier()) && objProjectName.equals(projectName) && id.equals(jobId) && version.equals(jobVersion) && type != null) {
//$NON-NLS-1$
String displayName = newLabel + " " + jobVersion;
ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
workingCopy.setAttribute(TalendDebugUIConstants.JOB_NAME, newLabel);
// workingCopy.setAttribute(TalendDebugUIConstants.JOB_ID, jobId);
// update to new version
workingCopy.setAttribute(TalendDebugUIConstants.JOB_VERSION, jobVersion);
// workingCopy.setAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, projectName);
workingCopy.rename(displayName);
workingCopy.doSave();
break;
}
}
clearUnusedLaunchs();
} catch (CoreException e) {
// nothing to do
}
}
}
use of org.talend.core.model.properties.Project in project tdi-studio-se by Talend.
the class JobLaunchShortcutManager method removeJobLaunch.
// debug not used yet, so code is disabled
// public static void debug(ISelection selection) {
// List<LaunchShortcutExtension> launchShortcuts = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
// .getLaunchShortcuts();
//
// for (LaunchShortcutExtension lse : launchShortcuts) {
// if (lse.getId().equals(TalendDebugUIConstants.TALEND_JOB_LAUNCH_SHORTCUT_ID)) {
// lse.launch(selection, ILaunchManager.DEBUG_MODE);
// return;
// }
// }
// }
//
// public static void debug(IEditorPart editor) {
// List<LaunchShortcutExtension> launchShortcuts = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
// .getLaunchShortcuts();
//
// for (LaunchShortcutExtension lse : launchShortcuts) {
// if (lse.getId().equals(TalendDebugUIConstants.TALEND_JOB_LAUNCH_SHORTCUT_ID)) {
// lse.launch(editor, ILaunchManager.DEBUG_MODE);
// return;
// }
// }
// }
/**
*
* cli Comment method "removeJobLaunch".
*/
public static void removeJobLaunch(IRepositoryViewObject objToDelete) {
if (objToDelete == null) {
return;
}
Property property = objToDelete.getProperty();
if (property == null || !(property.getItem() instanceof ProcessItem)) {
return;
}
Project project = ProjectManager.getInstance().getProject(property);
if (project == null) {
return;
}
final String objProjectName = project.getLabel();
final String objId = property.getId();
// final String objName = property.getLabel();
final String objVersion = property.getVersion();
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
if (launchManager == null) {
return;
}
try {
ILaunchConfiguration configuration = null;
for (ILaunchConfiguration config : launchManager.getLaunchConfigurations()) {
String jobId = config.getAttribute(TalendDebugUIConstants.JOB_ID, (String) null);
// String jobName = configuration.getAttribute(TalendDebugUIConstants.JOB_NAME, (String) null);
String jobVersion = config.getAttribute(TalendDebugUIConstants.JOB_VERSION, (String) null);
String projectName = config.getAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, (String) null);
ILaunchConfigurationType type = config.getType();
if (type != null && TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE.equals(type.getIdentifier()) && objProjectName.equals(projectName) && objId.equals(jobId) && objVersion.equals(jobVersion)) {
configuration = config;
break;
}
}
if (configuration == null) {
return;
}
configuration.delete();
} catch (CoreException e) {
// nothing to do
}
}
use of org.talend.core.model.properties.Project in project tdi-studio-se by Talend.
the class TalendJavaSourceViewer method getImports.
private static String getImports() {
//$NON-NLS-1$
String imports = "";
if (!GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
return imports;
}
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IProxyRepositoryFactory repositoryFactory = service.getProxyRepositoryFactory();
Project project = ProjectManager.getInstance().getProject(null);
try {
List<IRepositoryViewObject> routines = repositoryFactory.getAll(ERepositoryObjectType.ROUTINES);
for (IRepositoryViewObject routine : routines) {
if (routine.getProperty().getItem() instanceof RoutineItem && ((RoutineItem) routine.getProperty().getItem()).isBuiltIn()) {
//$NON-NLS-1$ //$NON-NLS-2$
imports += "import routines." + routine.getLabel() + ";\n";
} else {
//$NON-NLS-1$ //$NON-NLS-2$
imports += "import routines." + routine.getLabel() + ";\n";
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
//$NON-NLS-1$
return "";
}
//$NON-NLS-1$
imports += "import routines.system.*;\n";
//$NON-NLS-1$
imports += "import java.text.ParseException;\n";
//$NON-NLS-1$
imports += "import java.text.SimpleDateFormat;\n";
//$NON-NLS-1$
imports += "import java.util.Date;\n";
//$NON-NLS-1$
imports += "import java.util.List;\n";
//$NON-NLS-1$
imports += "import java.math.BigDecimal;\n";
imports += "\n";
imports += "@SuppressWarnings(\"unused\")";
imports += "\n\n";
return imports;
}
use of org.talend.core.model.properties.Project in project tmdm-studio-se by Talend.
the class SelectImportedModulesDialog2 method getProjectLocation.
private IPath getProjectLocation(IRepositoryViewObject viewObj) {
Property property = viewObj.getProperty();
Project project = ProjectManager.getInstance().getProject(property);
IProject eclipseProject = ResourcesPlugin.getWorkspace().getRoot().getProject(project.getTechnicalLabel());
IPath location = eclipseProject.getLocation().removeLastSegments(1);
return location;
}
Aggregations