use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class VersionSection method createControls.
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
composite = getWidgetFactory().createFlatFormComposite(parent);
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
final Table table = tableViewer.getTable();
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
final String[] columnProperties = new String[] { //$NON-NLS-1$
Messages.getString("VersionSection.Version"), //$NON-NLS-1$
Messages.getString("VersionSection.CreationDate"), Messages.getString("VersionSection.ModificationDate"), //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("VersionSection.Status") };
final TableColumn column1 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column1.setText(columnProperties[0]);
final TableColumn column2 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column2.setText(columnProperties[1]);
final TableColumn column3 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column3.setText(columnProperties[2]);
final TableColumn column4 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
column4.setText(columnProperties[3]);
tableViewer.setColumnProperties(columnProperties);
Object layoutData = parent.getLayoutData();
if (layoutData instanceof GridData) {
GridData gridData = (GridData) layoutData;
gridData.grabExcessVerticalSpace = true;
gridData.verticalAlignment = SWT.FILL;
}
FormData formData = new FormData();
formData.left = new FormAttachment(0);
formData.top = new FormAttachment(0);
formData.right = new FormAttachment(100);
formData.bottom = new FormAttachment(100);
table.setLayoutData(formData);
tableViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
IRepositoryViewObject repositoryObject = ((IRepositoryViewObject) inputElement);
if (repositoryObject.getProperty() == null) {
return null;
}
RepositoryNode parentRepositoryNode = RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(repositoryObject);
try {
List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(repositoryObject.getId());
Collections.sort(allVersion, new IRepositoryObjectComparator());
Object[] objects = new Object[allVersion.size()];
for (int i = 0; i < objects.length; i++) {
IRepositoryViewObject repositoryObjectVersion = allVersion.get(i);
RepositoryNode repositoryNode = createRepositoryNode(parentRepositoryNode, repositoryObjectVersion);
objects[i] = repositoryNode;
}
return objects;
} catch (PersistenceException e) {
return null;
}
}
private RepositoryNode createRepositoryNode(RepositoryNode parentRepositoryNode, IRepositoryViewObject repositoryObjectVersion) {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(repositoryObjectVersion.getProperty().getItem());
RepositoryNode repositoryNode = new RepositoryNode(repositoryObjectVersion, parentRepositoryNode, ENodeType.REPOSITORY_ELEMENT);
repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
repositoryNode.setProperties(EProperties.LABEL, repositoryObjectVersion.getLabel());
return repositoryNode;
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tableViewer.setLabelProvider(new ITableLabelProvider() {
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
public String getColumnText(Object element, int columnIndex) {
RepositoryNode repositoryNode = (RepositoryNode) element;
switch(columnIndex) {
case 0:
return repositoryNode.getObject().getVersion();
case 1:
if (repositoryNode.getObject().getCreationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getCreationDate());
} else {
return null;
}
case 2:
if (repositoryNode.getObject().getModificationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getModificationDate());
} else {
return null;
}
case 3:
if (repositoryNode.getObject().getStatusCode() != null) {
return repositoryNode.getObject().getStatusCode();
} else {
return null;
}
default:
return null;
}
}
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopUp");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager mgr) {
ISelection selection = tableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
for (ITreeContextualAction action : contextualsActions) {
if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
action.init(null, structuredSelection);
if (action.isVisible()) {
mgr.add(action);
}
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
Listener sortListener = new Listener() {
private int direction = 1;
public void handleEvent(Event e) {
final TableColumn column = (TableColumn) e.widget;
if (column == table.getSortColumn()) {
direction = -direction;
}
if (direction == 1) {
table.setSortDirection(SWT.DOWN);
} else {
table.setSortDirection(SWT.UP);
}
table.setSortColumn(column);
tableViewer.setSorter(new ViewerSorter() {
int index = 0;
@Override
public void sort(Viewer viewer, Object[] elements) {
while (index < table.getColumns().length && table.getColumn(index) != column) {
index++;
}
super.sort(viewer, elements);
}
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
"";
String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
"";
return getComparator().compare(columnText, columnText2) * direction;
}
});
}
};
column1.addListener(SWT.Selection, sortListener);
column2.addListener(SWT.Selection, sortListener);
column3.addListener(SWT.Selection, sortListener);
column4.addListener(SWT.Selection, sortListener);
table.setSortColumn(column1);
table.setSortDirection(SWT.DOWN);
aTabbedPropertySheetPage.getSite().setSelectionProvider(this);
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getExportResources.
/*
* (non-Javadoc)
*
* @see
* org.talend.repository.ui.wizards.exportjob.JobScriptsManager#getExportResources(org.talend.core.model.properties
* .ProcessItem[], boolean, boolean, boolean, boolean, boolean, boolean, boolean, java.lang.String)
*/
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] process, String... codeOptions) throws ProcessorException {
exportFileResource = process;
for (int i = 0; i < process.length; i++) {
ProcessItem processItem = (ProcessItem) process[i].getItem();
String selectedJobVersion = processItem.getProperty().getVersion();
selectedJobVersion = preExportResource(process, i, selectedJobVersion);
IProcess jobProcess = null;
// code is just kept like this to avoid too big changes right now.
if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
if (contextName != null) {
jobProcess = generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS || isOptionChoosed(ExportChoice.addStatistics), tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
}
analysisModules(processItem.getProperty().getId(), selectedJobVersion);
} else {
LastGenerationInfo.getInstance().setModulesNeededWithSubjobPerJob(processItem.getProperty().getId(), processItem.getProperty().getVersion(), Collections.<ModuleNeeded>emptySet());
LastGenerationInfo.getInstance().setLastMainJob(null);
}
List<URL> resources = new ArrayList<URL>();
List<URL> childrenList = new ArrayList<URL>();
if (CommonsPlugin.isHeadless()) {
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, codeOptions);
} else {
String log4jOption = getLog4jLevel() != null ? TalendProcessArgumentConstant.CMD_ARG_LOG4J_LEVEL + getLog4jLevel().toLowerCase() : null;
String[] newCodeOptions = codeOptions;
if (!ArrayUtils.contains(codeOptions, log4jOption)) {
newCodeOptions = (String[]) ArrayUtils.add(codeOptions, log4jOption);
}
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, newCodeOptions);
}
resources.addAll(childrenList);
process[i].addResources(resources);
// Gets job designer resouce
// List<URL> srcList = getSource(processItem, exportChoice.get(ExportChoice.needSource));
// process[i].addResources(JOB_SOURCE_FOLDER_NAME, srcList);
}
// Exports the system libs
List<ExportFileResource> list = new ArrayList<ExportFileResource>(Arrays.asList(process));
// Add the java system libraries
ExportFileResource libResource = getCompiledLibExportFileResource(process);
list.add(libResource);
// Gets jobInfo.properties
// only addClasspathJar not check in preferences ,then export the jobInfo.properties
boolean addClasspathJar = false;
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
addClasspathJar = designerCoreUIService.getPreferenceStore().getBoolean(IRepositoryPrefConstants.ADD_CLASSPATH_JAR);
}
if (!addClasspathJar) {
if (!(process.length > 1)) {
for (ExportFileResource pro : process) {
ExportFileResource jobInfoResource = new ExportFileResource(null, PATH_SEPARATOR);
if (CommonsPlugin.isHeadless()) {
jobInfoResource = new ExportFileResource();
}
list.add(jobInfoResource);
List<URL> jobInfoList = getJobInfoFile(pro, contextName);
jobInfoResource.addResources(jobInfoList);
}
}
}
if (PluginChecker.isRulesPluginLoaded()) {
// hywang add for 6484,add final drl files or xls files to exported job script
//$NON-NLS-1$
ExportFileResource ruleFileResource = new ExportFileResource(null, "Rules/rules/final");
list.add(ruleFileResource);
try {
Map<String, List<URL>> map = initUrlForRulesFiles(process);
Object[] keys = map.keySet().toArray();
for (Object key : keys) {
List<URL> talendDrlFiles = map.get(key.toString());
ruleFileResource.addResources(key.toString(), talendDrlFiles);
}
} catch (CoreException e) {
ExceptionHandler.process(e);
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
return list;
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method collectRoutinesFromRepository.
private Collection<IRepositoryViewObject> collectRoutinesFromRepository(Set<String> allRoutinesNames, ERepositoryObjectType type) {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
List<IRepositoryViewObject> toReturn = new ArrayList<IRepositoryViewObject>();
try {
List<IRepositoryViewObject> availableRoutines = factory.getAll(ProjectManager.getInstance().getCurrentProject(), type);
for (IRepositoryViewObject object : availableRoutines) {
if (allRoutinesNames.contains(object.getLabel())) {
allRoutinesNames.remove(object.getLabel());
toReturn.add(object);
}
}
if (allRoutinesNames.isEmpty()) {
return toReturn;
}
for (org.talend.core.model.general.Project project : ProjectManager.getInstance().getAllReferencedProjects()) {
for (IRepositoryViewObject object : factory.getAll(project, type)) {
if (allRoutinesNames.contains(object.getLabel())) {
allRoutinesNames.remove(object.getLabel());
toReturn.add(object);
}
}
if (allRoutinesNames.isEmpty()) {
return toReturn;
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
toReturn.addAll(RoutinesUtil.getCurrentSystemRoutines());
}
return toReturn;
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class JobJavaScriptOSGIForESBManager method getExportResources.
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] processes, String... codeOptions) throws ProcessorException {
List<ExportFileResource> list = new ArrayList<ExportFileResource>();
//$NON-NLS-1$;
ExportFileResource osgiResource = new ExportFileResource(null, "");
//$NON-NLS-1$
ExportFileResource jobScriptResource = new ExportFileResource(null, "");
list.add(osgiResource);
list.add(jobScriptResource);
// set export config mode now only to be sure that the libraries will be
// setup for an export mode, and not
// editor mode.
//$NON-NLS-1$
ProcessorUtilities.setExportConfig(JAVA, "", "");
// set export type as osgi
ProcessorUtilities.setExportAsOSGI(true);
try {
ProcessItem processItem = null;
for (ExportFileResource process : processes) {
processItem = (ProcessItem) process.getItem();
if (processItem.eIsProxy() || processItem.getProcess().eIsProxy()) {
try {
Property property = ProxyRepositoryFactory.getInstance().getUptodateProperty(processItem.getProperty());
processItem = (ProcessItem) property.getItem();
} catch (PersistenceException e) {
throw new ProcessorException(e);
}
}
String jobVersion = processItem.getProperty().getVersion();
if (!isMultiNodes() && getSelectedJobVersion() != null) {
jobVersion = getSelectedJobVersion();
}
ProcessorUtilities.setExportConfig(process.getDirectoryName(), true);
String processId = processItem.getProperty().getId();
if (null == contextName) {
contextName = processItem.getProcess().getDefaultContext();
}
IProcess iProcess = generateJobFiles(processItem, contextName, jobVersion, statisticPort != IProcessor.NO_STATISTICS, tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
analysisModules(processId, jobVersion);
analysisMavenModule(processItem);
// generate jar file for job
getJobScriptsUncompressed(jobScriptResource, processItem);
// dynamic DB XML mapping
addXmlMapping(process, isOptionChoosed(ExportChoice.needSourceCode));
generateConfig(osgiResource, processItem, iProcess);
addResources(osgiResource, processItem);
/*
* export current item's dependencies. this used for TDM components specially and need more discussion
* about then
*/
BuildExportManager.getInstance().exportOSGIDependencies(osgiResource, processItem);
}
ExportFileResource libResource = getCompiledLibExportFileResource(processes);
list.add(libResource);
// generate the META-INFO folder
ExportFileResource metaInfoFolder = genMetaInfoFolder(libResource, processItem);
list.add(0, metaInfoFolder);
ExportFileResource providedLibResources = getProvidedLibExportFileResource(processes);
if (providedLibResources != null) {
list.add(providedLibResources);
}
} catch (ProcessorException e) {
throw e;
} catch (Exception e) {
throw new ProcessorException(e);
}
return list;
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class JavaJobScriptsExportWizardPage method restoreWidgetValues.
/**
* Hook method for restoring widget values to the values that they held last time this wizard was used to
* completion.
*/
@Override
protected void restoreWidgetValues() {
IDialogSettings settings = getDialogSettings();
if (settings != null) {
String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
if (directoryNames != null && directoryNames.length > 0) {
for (String directoryName : directoryNames) {
addDestinationItem(directoryName);
}
}
setDefaultDestination();
shellLauncherButton.setSelection(settings.getBoolean(STORE_SHELL_LAUNCHER_ID));
jobItemButton.setSelection(settings.getBoolean(STORE_JOB_ID));
jobScriptButton.setSelection(settings.getBoolean(STORE_SOURCE_ID));
contextButton.setSelection(settings.getBoolean(STORE_CONTEXT_ID));
applyToChildrenButton.setSelection(settings.getBoolean(APPLY_TO_CHILDREN_ID));
chkButton.setSelection(settings.getBoolean(EXTRACT_ZIP_FILE));
// genCodeButton.setSelection(settings.getBoolean(STORE_GENERATECODE_ID));
}
launcherCombo.setItems(JobScriptsManager.getLauncher());
if (JobScriptsManager.getLauncher().length > 0) {
launcherCombo.select(0);
}
try {
setProcessItem((ProcessItem) ProxyRepositoryFactory.getInstance().getUptodateProperty(getProcessItem().getProperty()).getItem());
} catch (PersistenceException e) {
e.printStackTrace();
}
List<String> contextNames = ExportJobUtil.getJobContexts(getProcessItem());
contextCombo.setItems(contextNames.toArray(new String[contextNames.size()]));
if (contextNames.size() > 0) {
contextCombo.select(0);
}
}
Aggregations