use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class ComponentSearcher method search.
/**
* DOC hcw Comment method "search".
*
* @param monitor
* @param nodeName
* @param found
*/
protected void search(IProgressMonitor monitor, String nodeName, List<IRepositoryViewObject> found) {
IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
try {
List<IRepositoryViewObject> repositoryObjectList = factory.getAll(ERepositoryObjectType.PROCESS, false);
repositoryObjectList.addAll(factory.getAll(ERepositoryObjectType.PROCESS_MR, false));
repositoryObjectList.addAll(factory.getAll(ERepositoryObjectType.valueOf("PROCESS_STORM"), false));
if (ProjectManager.getInstance().getReferencedProjects(ProjectManager.getInstance().getCurrentProject()).size() > 0) {
for (Project refProject : ProjectManager.getInstance().getReferencedProjects(ProjectManager.getInstance().getCurrentProject())) {
repositoryObjectList.addAll(factory.getAll(refProject, ERepositoryObjectType.PROCESS, false));
repositoryObjectList.addAll(factory.getAll(refProject, ERepositoryObjectType.PROCESS_MR, false));
repositoryObjectList.addAll(factory.getAll(refProject, ERepositoryObjectType.valueOf("PROCESS_STORM"), false));
}
}
//$NON-NLS-1$
monitor.beginTask("Searching Component in Jobs ", repositoryObjectList.size());
for (IRepositoryViewObject rObject : repositoryObjectList) {
if (monitor.isCanceled()) {
break;
}
//$NON-NLS-1$
monitor.setTaskName("Search " + rObject.getLabel());
monitor.worked(1);
Item item = rObject.getProperty().getItem();
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
IProcess process = designerCoreService.getProcessFromProcessItem(processItem);
List<INode> nodes = (List<INode>) process.getGraphicalNodes();
for (INode node : nodes) {
if (node.getComponent().getName().equals(nodeName)) {
found.add(rObject);
break;
}
}
}
}
monitor.done();
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// JobletEditorInput fileEditorInput = new JobletEditorInput(processItem, true);
// IEditorPart editorPart = page.findEditor(fileEditorInput);
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class WSDL2JAVAController method generateJavaFile.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand()
*/
private void generateJavaFile() {
final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
RepositoryWorkUnit<Object> workUnit = new //$NON-NLS-1$
RepositoryWorkUnit<Object>(//$NON-NLS-1$
"", //$NON-NLS-1$
this) {
@Override
protected void run() throws PersistenceException {
Node node = (Node) elem;
IProcess process = node.getProcess();
String jobName = process.getName();
String nodeName = node.getUniqueName();
//$NON-NLS-1$
String wsdlfile = (String) node.getPropertyValue("ENDPOINT");
wsdlfile = wsdlfile.substring(1, wsdlfile.length() - 1);
if (wsdlfile.equals("")) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), org.talend.designer.core.i18n.Messages.getString("WSDL2JAVAController.TOS"), org.talend.designer.core.i18n.Messages.getString("WSDL2JAVAController.WSDLEquals"));
}
});
return;
}
File dir = new File(getTmpFolder());
final TalendWSDL2Java java2WSDL = new TalendWSDL2Java();
//$NON-NLS-1$ //$NON-NLS-2$
boolean hasError = java2WSDL.generateWSDL(new String[] { "-o" + dir, "-p" + PACK, wsdlfile });
// give some info about the generate stub.jar result to GUI.
final String tempWsdlfile = wsdlfile;
if (hasError) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), org.talend.designer.core.i18n.Messages.getString("WSDL2JAVAController.TOS"), //$NON-NLS-1$ //$NON-NLS-2$
org.talend.designer.core.i18n.Messages.getString(//$NON-NLS-1$ //$NON-NLS-2$
"WSDL2JAVAController.generateFileFailed", java2WSDL.getException().getClass().getCanonicalName(), java2WSDL.getException().getMessage()));
}
});
} else {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openInformation(Display.getDefault().getActiveShell(), //$NON-NLS-1$
org.talend.designer.core.i18n.Messages.getString("WSDL2JAVAController.TOS"), org.talend.designer.core.i18n.Messages.getString("WSDL2JAVAController.generateFileFailedFromWSDL", //$NON-NLS-1$
tempWsdlfile));
}
});
}
//$NON-NLS-1$
IPath path = new Path(jobName + "/" + nodeName);
//$NON-NLS-1$
String[] filter = new String[] { "java" };
Collection listFiles = FileUtils.listFiles(dir, filter, true);
Iterator iterator = listFiles.iterator();
String name = "";
for (int i = 0; i < listFiles.size(); i++) {
File javaFile = (File) listFiles.toArray()[i];
String parentFileName = javaFile.getParentFile().getName();
if (!parentFileName.equals("routines")) {
name = parentFileName;
}
}
List<RoutineItem> returnItemList = new ArrayList<RoutineItem>();
while (iterator.hasNext()) {
File javaFile = (File) iterator.next();
String fileName = javaFile.getName();
String label = fileName.substring(0, fileName.indexOf('.'));
try {
RoutineItem returnItem = createRoutine(path, label, javaFile, name);
returnItemList.add(returnItem);
syncRoutine(returnItem, true, name);
refreshProject();
} catch (IllegalArgumentException e) {
// nothing need to do for the duplicate label, there don't overwrite it.
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
Project currentProject = ProjectManager.getInstance().getCurrentProject();
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
List<IRepositoryViewObject> all;
Item item = null;
try {
all = factory.getAll(currentProject, ERepositoryObjectType.PROCESS, true, true);
for (IRepositoryViewObject repositoryViewObject : all) {
if (repositoryViewObject.getLabel().equals(jobName)) {
item = repositoryViewObject.getProperty().getItem();
}
}
} catch (PersistenceException ex) {
ExceptionHandler.process(ex);
}
try {
List<RoutinesParameterType> needList = new ArrayList<RoutinesParameterType>();
List<RoutinesParameterType> createJobRoutineDependencies = RoutinesUtil.createJobRoutineDependencies(false);
for (RoutineItem returnItem : returnItemList) {
for (RoutinesParameterType routinesParameterType : createJobRoutineDependencies) {
if (routinesParameterType.getId().equals(returnItem.getProperty().getId())) {
needList.add(routinesParameterType);
}
}
}
if (process instanceof org.talend.designer.core.ui.editor.process.Process) {
((org.talend.designer.core.ui.editor.process.Process) process).addGeneratingRoutines(needList);
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// try {
// RoutinesUtil.createJobRoutineDependencies(false);
// } catch (PersistenceException e) {
// ExceptionHandler.process(e);
// }
FilesUtils.removeFolder(dir, true);
}
};
workUnit.setAvoidUnloadResources(true);
factory.executeRepositoryWorkUnit(workUnit);
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class ReadRoutineAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
protected void doRun() {
if (repositoryNode == null && getSelection() != null) {
repositoryNode = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
}
RoutineItem routineItem = (RoutineItem) repositoryNode.getObject().getProperty().getItem();
Property updatedProperty = null;
try {
updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(routineItem)), routineItem.getProperty().getId()).getProperty();
// repositoryNode.getObject().setProperty(updatedProperty);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
routineItem = (RoutineItem) repositoryNode.getObject().getProperty().getItem();
try {
openRoutineEditor(routineItem, true);
} catch (PartInitException e) {
MessageBoxExceptionHandler.process(e);
} catch (SystemException e) {
MessageBoxExceptionHandler.process(e);
}
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class ImportProjectAsAction method clearExternalLibraries.
/**
* DOC zwang Comment method "clearExternalLibraries".
*/
private void clearExternalLibraries() {
try {
IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
Project[] projects = repositoryFactory.readProject();
for (Project project : projects) {
IProject fsProject = ResourceUtils.getProject(project);
IFolder libJavaFolder = fsProject.getFolder(ImportProjectAsAction.LIB);
if (!libJavaFolder.exists()) {
continue;
}
libJavaFolder.delete(true, null);
}
} catch (Exception e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class TOSLoginComposite method readProject.
public Project[] readProject() {
ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
Project[] projects = null;
try {
projects = repositoryFactory.readProject();
} catch (PersistenceException e1) {
e1.printStackTrace();
} catch (BusinessException e1) {
e1.printStackTrace();
}
return projects;
}
Aggregations