use of org.talend.core.model.general.Project in project tesb-studio-se by Talend.
the class RouteResourceUtil method getSourceFile.
/**
* Get source file of Item.
*
* @param item
* @return
*/
public static IFile getSourceFile(RouteResourceItem item) {
// the file may come from a reference project
IFolder rrfolder = null;
Resource eResource = item.eResource();
if (eResource != null) {
URI uri = eResource.getURI();
if (uri != null && uri.isPlatformResource()) {
String platformString = uri.toPlatformString(true);
IContainer parentContainer = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformString)).getParent();
if (parentContainer instanceof IFolder) {
rrfolder = (IFolder) parentContainer;
}
}
}
if (rrfolder == null) {
Project talendProject = ProjectManager.getInstance().getCurrentProject();
String technicalLabel = talendProject.getTechnicalLabel();
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(technicalLabel);
String folderPath = item.getState().getPath();
rrfolder = project.getFolder(RouteResourceItem.ROUTE_RESOURCES_FOLDER);
if (folderPath != null && !folderPath.isEmpty()) {
rrfolder = rrfolder.getFolder(folderPath);
}
}
String itemName = item.getProperty().getLabel();
String version = item.getProperty().getVersion();
String fileExtension = item.getBindingExtension();
String fileName = itemName + "_" + version + "." + fileExtension;
IFile file = rrfolder.getFile(fileName);
return file;
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class ExpressionBuilderDialog method getExpressionStorePath.
/**
* yzhang Comment method "getExpressionStorePath".
*
* @return
*/
protected String getExpressionStorePath() {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
Project project = repositoryContext.getProject();
IProject p = root.getProject(project.getTechnicalLabel());
// put to the temp folder
String projectPath = p.getLocation().toPortableString() + File.separator + RepositoryConstants.TEMP_DIRECTORY;
String configurationPath = projectPath + File.separator + ExpressionPersistance.CONFIGURATION_FOLDER_NAME;
configurationPath = getValidFolderPath(configurationPath, 1);
File configurationFolder = new File(configurationPath);
if (!configurationFolder.exists()) {
configurationFolder.mkdir();
}
String expressionPath = configurationPath + File.separator + ExpressionPersistance.EXPRESSION_FOLDER_NAME;
expressionPath = getValidFolderPath(expressionPath, 1);
File expressionFolder = new File(expressionPath);
if (!expressionFolder.exists()) {
expressionFolder.mkdir();
}
String jobName = "";
if (component != null) {
jobName = component.getProcess().getName();
} else {
jobName = "tXMLMap";
}
expressionPath = expressionPath + File.separator + jobName + XmlUtil.FILE_XML_SUFFIX;
return expressionPath;
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class ChangeModelForRoutineParameterMigrationTask2 method execute.
@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
try {
List<String> possibleRoutines = new ArrayList<String>();
List<String> routinesToAdd = new ArrayList<String>();
String additionalString = LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA ? "." : "";
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<IRepositoryViewObject> routines = factory.getAll(ProjectManager.getInstance().getCurrentProject(), ERepositoryObjectType.ROUTINES);
// always add the system, others must be checked
for (IRepositoryViewObject object : routines) {
if (((RoutineItem) object.getProperty().getItem()).isBuiltIn()) {
routinesToAdd.add(object.getLabel());
} else {
possibleRoutines.add(object.getLabel());
}
}
for (Project project : ProjectManager.getInstance().getAllReferencedProjects()) {
List<IRepositoryViewObject> refRoutines = factory.getAll(project, ERepositoryObjectType.ROUTINES);
for (IRepositoryViewObject object : refRoutines) {
if (!((RoutineItem) object.getProperty().getItem()).isBuiltIn()) {
if (!possibleRoutines.contains(object.getLabel())) {
possibleRoutines.add(object.getLabel());
routines.add(object);
}
}
}
}
List<RoutinesParameterType> oldList = Collections.EMPTY_LIST;
ProcessType processType = getProcessType(item);
if (null != processType) {
if (processType.getParameters() != null && processType.getParameters().getRoutinesParameter() == null) {
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
processType.setParameters(parameterType);
if (item instanceof ProcessItem) {
routinesToAdd.addAll(possibleRoutines);
possibleRoutines.clear();
}
} else {
if (processType.getParameters() == null) {
processType.setParameters(TalendFileFactory.eINSTANCE.createParametersType());
}
oldList = new ArrayList<RoutinesParameterType>(processType.getParameters().getRoutinesParameter());
if (oldList.isEmpty() && item instanceof ProcessItem) {
routinesToAdd.addAll(possibleRoutines);
possibleRoutines.clear();
}
processType.getParameters().getRoutinesParameter().clear();
}
if (processType.getRoutinesDependencies() != null && !processType.getRoutinesDependencies().isEmpty()) {
processType.getRoutinesDependencies().clear();
}
List<RoutinesParameterType> routinesDependencies = (List<RoutinesParameterType>) processType.getParameters().getRoutinesParameter();
if (!possibleRoutines.isEmpty()) {
// check possible routines to setup in process
for (ElementParameterType param : (List<ElementParameterType>) processType.getParameters().getElementParameter()) {
for (String routine : possibleRoutines) {
if (!routinesToAdd.contains(routine) && param.getValue() != null && param.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
for (ElementValueType elementValue : (List<ElementValueType>) param.getElementValue()) {
if (!routinesToAdd.contains(routine) && elementValue.getValue() != null && elementValue.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
// check possible routines to setup in nodes
for (NodeType node : ((List<NodeType>) processType.getNode())) {
for (ElementParameterType param : (List<ElementParameterType>) node.getElementParameter()) {
for (String routine : possibleRoutines) {
if (!routinesToAdd.contains(routine) && param.getValue() != null && param.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
for (ElementValueType elementValue : (List<ElementValueType>) param.getElementValue()) {
if (!routinesToAdd.contains(routine) && elementValue.getValue() != null && elementValue.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
}
// check possible routines to setup in connections
for (ConnectionType connection : ((List<ConnectionType>) processType.getConnection())) {
for (ElementParameterType param : (List<ElementParameterType>) connection.getElementParameter()) {
for (String routine : possibleRoutines) {
if (!routinesToAdd.contains(routine) && param.getValue() != null && param.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
for (ElementValueType elementValue : (List<ElementValueType>) param.getElementValue()) {
if (!routinesToAdd.contains(routine) && elementValue.getValue() != null && elementValue.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
}
}
// just in case some routine dependencies exist before but are lost... (migration from 4.1.1 or 4.1.2)
for (RoutinesParameterType routine : oldList) {
if (!routinesToAdd.contains(routine.getName())) {
routinesDependencies.add(routine);
}
}
for (IRepositoryViewObject object : routines) {
if (routinesToAdd.contains(object.getLabel())) {
RoutinesParameterType routinesParameterType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
routinesParameterType.setId(object.getId());
routinesParameterType.setName(object.getLabel());
routinesDependencies.add(routinesParameterType);
}
}
factory.save(item, true);
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class SelectDeleteProjectDialog method createTreeViewer.
private void createTreeViewer(Composite parent) {
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
layout.makeColumnsEqualWidth = false;
parent.setLayout(layout);
parent.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
GridData listData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
treeViewer = new ContainerCheckedTreeViewer(parent);
treeViewer.getControl().setLayoutData(listData);
// treeViewer.setContentProvider(getResourceProvider(IResource.FOLDER | IResource.PROJECT));
treeViewer.setContentProvider(getResourceProvider(IResource.PROJECT));
// treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
treeViewer.setLabelProvider(new LabelProvider() {
@Override
public final String getText(Object element) {
// query the element for its label
//$NON-NLS-1$
String label = "";
if (element instanceof IProject) {
IProject project = (IProject) element;
label = getLabel(project.getName());
} else if (element instanceof IFolder) {
IFolder folder = (IFolder) element;
label = getLabel(folder.getName());
}
return label;
}
private String getLabel(String name) {
List<Project> proItem = getProjectItem();
for (int i = 0; i < proItem.size(); i++) {
Project p = proItem.get(i);
String proName = p.getTechnicalLabel();
if (proName.equals(name)) {
return ProjectManager.getProjectDisplayLabel(p.getEmfProject());
}
}
return name;
}
@Override
public final Image getImage(Object element) {
if (element instanceof IProject) {
return ImageProvider.getImage(ERepositoryImages.PROJECT_ICON);
} else if (element instanceof IFolder) {
return ImageProvider.getImage(ERepositoryImages.FOLDER_ICON);
}
return null;
}
});
treeViewer.setInput(projectItemList);
treeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
addTreeListener();
createButtons(parent);
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class ExportProjectsAsAction method getProjectAndRelatedLinks.
/**
* DOC bqian Comment method "getProjectAndRelatedLinks".
*
* @return
*/
private Map<Project, List<LinkTargetStore>> getProjectAndRelatedLinks() {
Map<Project, List<LinkTargetStore>> map = new HashMap<Project, List<LinkTargetStore>>();
IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
try {
// fix for bug 15454
Project[] projects = repositoryFactory.readProject(true);
for (Project project : projects) {
IProject fsProject = ResourceModelUtils.getProject(project);
// IFolder libJavaFolder = fsProject.getFolder(ExportProjectsAsAction.CODE);
// if (libJavaFolder.exists()) {
// List<LinkTargetStore> links = getLinksFromProject(project);
// map.put(project, links);
// }
}
} catch (Exception e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
return map;
}
Aggregations