use of org.talend.core.model.general.Project in project tbd-studio-se by Talend.
the class HadoopClusterRepositoryContentHandler method addNode.
@Override
public void addNode(ERepositoryObjectType type, RepositoryNode parentNode, IRepositoryViewObject repositoryObject, RepositoryNode node) {
if (type == HadoopClusterRepositoryNodeType.HADOOPCLUSTER) {
Project project = new Project(ProjectManager.getInstance().getProject(node.getObject().getProperty()));
for (IHadoopSubnodeRepositoryContentHandler handler : HadoopSubnodeRepositoryContentManager.getHandlers()) {
handler.addNode(project, node);
}
addHadoopDBNode(project, node);
}
}
use of org.talend.core.model.general.Project in project tbd-studio-se by Talend.
the class HadoopClusterService method getHadoopClusterItemById.
@Override
public Item getHadoopClusterItemById(String id) {
HadoopClusterConnectionItem connectionItem = HCRepositoryUtil.getRelativeHadoopClusterItem(id);
if (connectionItem == null) {
// In case it is a hadoopsubconnection.
connectionItem = HCRepositoryUtil.getHadoopClusterItemBySubitemId(id);
if (connectionItem == null) {
Item item = HCRepositoryUtil.getRelativeItem(id);
if (item != null) {
Project project = new Project(ProjectManager.getInstance().getProject(item.getProperty()));
connectionItem = HCRepositoryUtil.getHadoopClusterItemBySubitemId(project, id);
}
}
}
return connectionItem;
}
use of org.talend.core.model.general.Project in project tbd-studio-se by Talend.
the class HadoopConfsUtils method getConfsTempFolder.
private static String getConfsTempFolder(String subFolderName) {
Project project = ProjectManager.getInstance().getCurrentProject();
String tmpFolder;
try {
IProject physProject = ResourceModelUtils.getProject(project);
// $NON-NLS-1$
tmpFolder = physProject.getFolder("temp").getLocation().toPortableString();
} catch (Exception e) {
// $NON-NLS-1$
tmpFolder = System.getProperty("user.dir");
}
tmpFolder = tmpFolder + File.separator + CONFS_FOLDER;
File confFolder = new File(tmpFolder + File.separator + subFolderName);
if (!confFolder.exists()) {
confFolder.mkdirs();
} else {
FilesUtils.emptyFolder(confFolder);
}
return confFolder.getAbsolutePath();
}
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);
}
Aggregations