Compare commits
53 Commits
maintenanc
...
patch/6.3.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00abea021b | ||
|
|
891e1703a1 | ||
|
|
406e16bd90 | ||
|
|
00f918e656 | ||
|
|
14861d0e84 | ||
|
|
04298b159f | ||
|
|
e95ed1eba3 | ||
|
|
9c6e842b77 | ||
|
|
e6a3ce9c69 | ||
|
|
082d6d4e52 | ||
|
|
9f6fb80d63 | ||
|
|
56f80660f9 | ||
|
|
4b026165ab | ||
|
|
0b5b7ef363 | ||
|
|
9df239ffeb | ||
|
|
35fda7f736 | ||
|
|
6c83ca193f | ||
|
|
4db1260d96 | ||
|
|
d9e52dc759 | ||
|
|
b0538038f8 | ||
|
|
5f561125ce | ||
|
|
62ca421149 | ||
|
|
ac5150e706 | ||
|
|
3082885fd2 | ||
|
|
f1995ab2e7 | ||
|
|
22aa2b0899 | ||
|
|
e9594e0c21 | ||
|
|
582bac5bb2 | ||
|
|
c8bfa0763b | ||
|
|
86f84fcb48 | ||
|
|
59dbf4d86f | ||
|
|
1861a08174 | ||
|
|
7dbb1b9685 | ||
|
|
54679ec0b4 | ||
|
|
5f33663bc8 | ||
|
|
c7414fabb1 | ||
|
|
407db60bcf | ||
|
|
e9a9f29322 | ||
|
|
0150ae0568 | ||
|
|
1de9b7e0c2 | ||
|
|
2446863620 | ||
|
|
5c808e5235 | ||
|
|
132948c900 | ||
|
|
ca94bdab29 | ||
|
|
b0a501a866 | ||
|
|
f6105fd5d6 | ||
|
|
f0098fc16e | ||
|
|
177dfb1669 | ||
|
|
1a103677c6 | ||
|
|
ff9c4357bc | ||
|
|
358b1bb4f8 | ||
|
|
d48627b400 | ||
|
|
cfc84bfd36 |
@@ -48,11 +48,11 @@ import org.talend.commons.utils.data.map.MultiLazyValuesMap;
|
||||
public class TableEditorManager {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Event type. <br/>
|
||||
*
|
||||
*
|
||||
* $Id: TableEditorManager.java 7183 2007-11-23 11:03:36Z amaumont $
|
||||
*
|
||||
*
|
||||
*/
|
||||
public enum EVENT_TYPE implements ITableEditorManagerEventType {
|
||||
CONTROL_CREATED,
|
||||
@@ -105,7 +105,7 @@ public class TableEditorManager {
|
||||
|
||||
/**
|
||||
* DOC amaumont TableEditorManager constructor comment.
|
||||
*
|
||||
*
|
||||
* @param tableViewerCreator
|
||||
*/
|
||||
public TableEditorManager(TableViewerCreatorNotModifiable tableViewerCreator) {
|
||||
@@ -350,7 +350,7 @@ public class TableEditorManager {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void paintVisibleAreaEditor(PaintEvent event) {
|
||||
Table table = tableViewerCreator.getTable();
|
||||
if (table.isDisposed()) {
|
||||
@@ -373,10 +373,13 @@ public class TableEditorManager {
|
||||
// Set the cell editor if need
|
||||
for (int itemIndex = topIndex; itemIndex <= endIndex; itemIndex++) {
|
||||
TableItem item = table.getItem(itemIndex);
|
||||
if (item.isDisposed()) {
|
||||
continue;
|
||||
}
|
||||
for (int columnIndex = 0; columnIndex < columnsWithEditorContent.size(); columnIndex++) {
|
||||
TableViewerCreatorColumnNotModifiable column = columnsWithEditorContent.get(columnIndex);
|
||||
TableEditorContentNotModifiable tableEditorContent = column.getTableEditorContent();
|
||||
|
||||
|
||||
if (dataToMultipleDataEditor.containsKey(item.getData())) {
|
||||
Collection<TableEditor> tableEditorCollection = dataToMultipleDataEditor.getCollection(item.getData());
|
||||
for (TableEditor tableEditor : tableEditorCollection) {
|
||||
@@ -402,13 +405,13 @@ public class TableEditorManager {
|
||||
Table table = tableViewerCreator.getTable();
|
||||
if (table.isDisposed() || index >= table.getItems().length) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
int topIndex = table.getTopIndex();
|
||||
int itemCount = table.getItemCount();
|
||||
int numVisibleLines = Math.min((table.getBounds().height / table.getItemHeight()) + 2, itemCount - topIndex);
|
||||
int numVisibleLines = Math.min((table.getBounds().height / table.getItemHeight()) + 2, itemCount - topIndex);
|
||||
if (index < topIndex || index > topIndex + numVisibleLines) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int iEditorCol = 0; iEditorCol < columnsWithEditorContent.size(); iEditorCol++) {
|
||||
TableViewerCreatorColumnNotModifiable column = columnsWithEditorContent.get(iEditorCol);
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.talend.commons.ui.runtime.thread.AsynchronousThreading;
|
||||
@@ -98,22 +97,24 @@ public abstract class ProgressDialog {
|
||||
display.asyncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
final ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(parentShell);
|
||||
final ProgressMonitorDialog progressMonitorDialog = newProgressMonitorDialog(parentShell);
|
||||
if (timeBeforeShowDialog > 0) {
|
||||
progressMonitorDialog.setOpenOnRun(false);
|
||||
if (progressMonitorDialog != null) {
|
||||
progressMonitorDialog.setOpenOnRun(false);
|
||||
}
|
||||
// for bug 16801
|
||||
AsynchronousThreading asynchronousThreading = new AsynchronousThreading(timeBeforeShowDialog, true,
|
||||
display, new Runnable() {
|
||||
|
||||
public void run() {
|
||||
progressMonitorDialog.open();
|
||||
openDialog(progressMonitorDialog);
|
||||
}
|
||||
});
|
||||
asynchronousThreading.start();
|
||||
}
|
||||
|
||||
try {
|
||||
progressMonitorDialog.run(false, true, op);
|
||||
dialogRun(progressMonitorDialog, op);
|
||||
} catch (InvocationTargetException e) {
|
||||
// Pass it outside the workspace runnable
|
||||
iteHolder[0] = e;
|
||||
@@ -128,22 +129,24 @@ public abstract class ProgressDialog {
|
||||
display.syncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
final ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(parentShell);
|
||||
final ProgressMonitorDialog progressMonitorDialog = newProgressMonitorDialog(parentShell);
|
||||
if (timeBeforeShowDialog > 0) {
|
||||
progressMonitorDialog.setOpenOnRun(false);
|
||||
if (progressMonitorDialog != null) {
|
||||
progressMonitorDialog.setOpenOnRun(false);
|
||||
}
|
||||
// for bug 16801
|
||||
AsynchronousThreading asynchronousThreading = new AsynchronousThreading(timeBeforeShowDialog, true,
|
||||
display, new Runnable() {
|
||||
|
||||
public void run() {
|
||||
progressMonitorDialog.open();
|
||||
openDialog(progressMonitorDialog);
|
||||
}
|
||||
});
|
||||
asynchronousThreading.start();
|
||||
}
|
||||
|
||||
try {
|
||||
progressMonitorDialog.run(false, true, op);
|
||||
dialogRun(progressMonitorDialog, op);
|
||||
} catch (InvocationTargetException e) {
|
||||
// Pass it outside the workspace runnable
|
||||
iteHolder[0] = e;
|
||||
@@ -165,6 +168,19 @@ public abstract class ProgressDialog {
|
||||
}
|
||||
}
|
||||
|
||||
protected ProgressMonitorDialog newProgressMonitorDialog(Shell shell) {
|
||||
return new ProgressMonitorDialog(shell);
|
||||
}
|
||||
|
||||
protected void openDialog(ProgressMonitorDialog dialog) {
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
protected void dialogRun(ProgressMonitorDialog dialog, IRunnableWithProgress op)
|
||||
throws InvocationTargetException, InterruptedException {
|
||||
dialog.run(false, true, op);
|
||||
}
|
||||
|
||||
public abstract void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException;
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.talend.commons.ui.runtime.image.ImageUtils;
|
||||
import org.talend.commons.utils.system.EnvironmentUtils;
|
||||
|
||||
/**
|
||||
* <code>ImageCapture</code> provides utilities to capture images.
|
||||
@@ -53,11 +54,7 @@ public class ImageCapture {
|
||||
*
|
||||
* @param control
|
||||
*/
|
||||
public static Image capture(Control control) {
|
||||
|
||||
// First try not conclusive...
|
||||
// So I should use org.eclipse.ve.internal.swt.targetvm.win32.ImageCapture class which work perfectly
|
||||
|
||||
public static Image capture(Control control) {
|
||||
Shell shell = control.getShell();
|
||||
Rectangle boundsShell = shell.getBounds();
|
||||
|
||||
@@ -71,7 +68,13 @@ public class ImageCapture {
|
||||
GC gc = new GC(control);
|
||||
Image image = new Image(control.getDisplay(), control.getSize().x, control.getSize().y);
|
||||
|
||||
gc.copyArea(image, 0, 0);
|
||||
boolean skipCopyArea = false;
|
||||
if (EnvironmentUtils.isMacOsSytem()) {
|
||||
skipCopyArea = true;
|
||||
}
|
||||
if (!skipCopyArea) {
|
||||
gc.copyArea(image, 0, 0);
|
||||
}
|
||||
gc.dispose();
|
||||
return image;
|
||||
// return getImage(control, control.getSize().x, control.getSize().y, true);
|
||||
|
||||
@@ -22,6 +22,11 @@ public class SyncLibrariesLoginTask extends AbstractLoginTask implements IRunnab
|
||||
|
||||
private static ICoreService coreService = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
|
||||
|
||||
@Override
|
||||
public boolean isCommandlineTask() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
TimeMeasure.display = CommonsPlugin.isDebugMode();
|
||||
|
||||
@@ -71,6 +71,7 @@ import org.talend.designer.core.model.utils.emf.component.ComponentFactory;
|
||||
import org.talend.designer.core.model.utils.emf.component.IMPORTType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.RepositoryConstants;
|
||||
@@ -893,7 +894,7 @@ public abstract class AbstractEMFRepositoryFactory extends AbstractRepositoryFac
|
||||
getAllVersions(project, property, allVersion);
|
||||
for (IRepositoryViewObject repositoryObject : allVersion) {
|
||||
Property uptodateProperty = repositoryObject.getProperty();
|
||||
if (uptodateProperty!=null&&uptodateProperty.getVersion().equals(property.getVersion())) {
|
||||
if (uptodateProperty != null && uptodateProperty.getVersion().equals(property.getVersion())) {
|
||||
return uptodateProperty;
|
||||
}
|
||||
}
|
||||
@@ -1027,6 +1028,10 @@ public abstract class AbstractEMFRepositoryFactory extends AbstractRepositoryFac
|
||||
*/
|
||||
@Override
|
||||
public void afterLogon() {
|
||||
// do nothing by default
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(
|
||||
IRunProcessService.class);
|
||||
service.updateProjectPomWithTemplate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,8 +486,7 @@ public class ProjectRepositoryNode extends RepositoryNode implements IProjectRep
|
||||
return; // don't check the deleted item for ref-projects
|
||||
}
|
||||
for (ProjectReference refProject : (List<ProjectReference>) project.getReferencedProjects()) {
|
||||
String parentBranch = ProjectManager.getInstance().getMainProjectBranch(project);
|
||||
if (refProject.getBranch() == null || parentBranch.equals(refProject.getBranch())) {
|
||||
if (ProjectManager.validReferenceProject(project, refProject)) {
|
||||
Project p = refProject.getReferencedProject();
|
||||
// no need caching
|
||||
/*
|
||||
@@ -1213,8 +1212,7 @@ public class ProjectRepositoryNode extends RepositoryNode implements IProjectRep
|
||||
private void handleReferenced(RepositoryNode parent) {
|
||||
if (parent.getType().equals(ENodeType.SYSTEM_FOLDER)) {
|
||||
for (ProjectReference refProject : (List<ProjectReference>) project.getEmfProject().getReferencedProjects()) {
|
||||
String parentBranch = ProjectManager.getInstance().getMainProjectBranch(project);
|
||||
if (refProject.getBranch() == null || refProject.getBranch().equals(parentBranch)) {
|
||||
if (ProjectManager.validReferenceProject(project.getEmfProject(), refProject)) {
|
||||
Project emfProject = refProject.getReferencedProject();
|
||||
ProjectRepositoryNode referencedProjectNode = new ProjectRepositoryNode(
|
||||
new org.talend.core.model.general.Project(emfProject), null, parent, this,
|
||||
|
||||
@@ -58,12 +58,12 @@ import org.osgi.service.event.Event;
|
||||
import org.osgi.service.event.EventAdmin;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.exception.BusinessException;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.LoginException;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.exception.SystemException;
|
||||
import org.talend.commons.runtime.model.repository.ERepositoryStatus;
|
||||
import org.talend.commons.ui.runtime.CommonUIPlugin;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
|
||||
import org.talend.commons.utils.data.container.RootContainer;
|
||||
import org.talend.commons.utils.time.TimeMeasure;
|
||||
@@ -1021,6 +1021,8 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
return this.repositoryFactoryFromProvider.getAllVersion(project, id, avoidSaveProject);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IRepositoryViewObject> getAllVersion(Project project, String id, String folderPath, ERepositoryObjectType type)
|
||||
throws PersistenceException {
|
||||
return this.repositoryFactoryFromProvider.getAllVersion(project, id, folderPath, type);
|
||||
@@ -1847,7 +1849,9 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.initializeProjectConnection"), 1); //$NON-NLS-1$
|
||||
ProjectManager.getInstance().getBeforeLogonRecords().clear();
|
||||
this.repositoryFactoryFromProvider.beforeLogon(project);
|
||||
ProjectManager.getInstance().getBeforeLogonRecords().clear();
|
||||
|
||||
// monitorWrap.worked(1);
|
||||
TimeMeasure.step("logOnProject", "beforeLogon"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
@@ -1865,13 +1869,17 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask("Execute before logon migrations tasks", 1); //$NON-NLS-1$
|
||||
ProjectManager.getInstance().getMigrationRecords().clear();
|
||||
executeMigrations(project, true, currentMonitor);
|
||||
ProjectManager.getInstance().getMigrationRecords().clear();
|
||||
// monitorWrap.worked(1);
|
||||
TimeMeasure.step("logOnProject", "executeMigrations(beforeLogonTasks)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.logonInProgress"), 1); //$NON-NLS-1$
|
||||
ProjectManager.getInstance().getLogonRecords().clear();
|
||||
this.repositoryFactoryFromProvider.logOnProject(project);
|
||||
ProjectManager.getInstance().getLogonRecords().clear();
|
||||
// monitorWrap.worked(1);
|
||||
TimeMeasure.step("logOnProject", "logOnProject"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
@@ -1887,9 +1895,13 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
coreUiService.componentsReset();
|
||||
}
|
||||
|
||||
fireRepositoryPropertyChange(ERepositoryActionName.PROJECT_PREFERENCES_RELOAD.getName(), null, null);
|
||||
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.exec.migration.tasks"), 1); //$NON-NLS-1$
|
||||
ProjectManager.getInstance().getMigrationRecords().clear();
|
||||
executeMigrations(project, false, currentMonitor);
|
||||
ProjectManager.getInstance().getMigrationRecords().clear();
|
||||
TimeMeasure.step("logOnProject", "executeMigrations(afterLogonTasks)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
@@ -1898,8 +1910,20 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
if (coreService != null) {
|
||||
// clean workspace
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.cleanWorkspace"), 1); //$NON-NLS-1$
|
||||
coreService.deleteAllJobs(false);
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService runProcessService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(
|
||||
IRunProcessService.class);
|
||||
try {
|
||||
runProcessService.deleteAllJobs(false);
|
||||
runProcessService.getTalendProcessJavaProject().cleanMavenFiles(monitor);
|
||||
TimeMeasure.step("logOnProject", "clean Maven files"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
TimeMeasure.step("logOnProject", "clean Java project"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
if (workspace instanceof Workspace) {
|
||||
((Workspace) workspace).getFileSystemManager().getHistoryStore().clean(currentMonitor);
|
||||
}
|
||||
@@ -1938,24 +1962,6 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
}
|
||||
TimeMeasure.step("logOnProject", "sync log4j"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
if (CommonUIPlugin.isFullyHeadless()) {
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.synchronizeLibraries"), 1); //$NON-NLS-1$
|
||||
coreService.syncLibraries(currentMonitor);
|
||||
TimeMeasure.step("logOnProject", "sync components libraries"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
coreService.createStatsLogAndImplicitParamter(project);
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
coreService.synchronizeMapptingXML();
|
||||
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
|
||||
ITDQRepositoryService tdqRepositoryService = (ITDQRepositoryService) GlobalServiceRegister.getDefault()
|
||||
.getService(ITDQRepositoryService.class);
|
||||
|
||||
@@ -20,7 +20,9 @@ import org.eclipse.emf.common.util.BasicEList;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.common.util.EMap;
|
||||
import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.database.conn.ConnParameterKeys;
|
||||
import org.talend.core.database.conn.DatabaseConnStrUtil;
|
||||
import org.talend.core.database.conn.template.DbConnStrForHive;
|
||||
import org.talend.core.model.metadata.Dbms;
|
||||
import org.talend.core.model.metadata.IMetadataConnection;
|
||||
import org.talend.core.model.metadata.MetadataTalendType;
|
||||
@@ -33,6 +35,7 @@ import org.talend.core.model.metadata.builder.connection.FileExcelConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.HL7Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.PositionalFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.RegexpFileConnection;
|
||||
import org.talend.core.model.metadata.connection.hive.HiveServerVersionInfo;
|
||||
import org.talend.core.model.utils.CloneConnectionUtils;
|
||||
import org.talend.core.model.utils.ContextParameterUtils;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
@@ -131,12 +134,233 @@ public class StandaloneConnectionContextUtils {
|
||||
// cloneConn.setContextId(dbConn.getContextId());
|
||||
// cloneConn.setContextMode(dbConn.isContextMode()); // if use context
|
||||
|
||||
// for hive :
|
||||
if (EDatabaseTypeName.HIVE.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
|
||||
String hadoopUserName = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USERNAME);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_USERNAME,
|
||||
getOriginalValue(contextProperties, hadoopUserName));
|
||||
String jobTracker = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL,
|
||||
getOriginalValue(contextProperties, jobTracker));
|
||||
String nameNode = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL,
|
||||
getOriginalValue(contextProperties, nameNode));
|
||||
String hivePrincipal = cloneConn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_HIVEPRINCIPLA);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_HIVEPRINCIPLA,
|
||||
getOriginalValue(contextProperties, hivePrincipal));
|
||||
|
||||
String hiveMetadata = cloneConn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_METASTOREURL);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_METASTOREURL,
|
||||
getOriginalValue(contextProperties, hiveMetadata));
|
||||
|
||||
String driverPath = cloneConn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERJAR_PATH);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERJAR_PATH,
|
||||
getOriginalValue(contextProperties, driverPath));
|
||||
|
||||
String driverClass = cloneConn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERCLASS);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERCLASS,
|
||||
getOriginalValue(contextProperties, driverClass));
|
||||
|
||||
String hiveUserName = cloneConn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_USERNAME);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_USERNAME,
|
||||
getOriginalValue(contextProperties, hiveUserName));
|
||||
|
||||
String hivePassword = cloneConn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_PASSWORD);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_PASSWORD,
|
||||
getOriginalValue(contextProperties, hivePassword));
|
||||
|
||||
String ktPrincipal = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,
|
||||
getOriginalValue(contextProperties, ktPrincipal));
|
||||
|
||||
String keytab = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB, getOriginalValue(contextProperties, keytab));
|
||||
|
||||
String maprticket_Username = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USERNAME);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USERNAME,
|
||||
getOriginalValue(contextProperties, maprticket_Username));
|
||||
|
||||
String maprticket_Password = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_PASSWORD);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_PASSWORD,
|
||||
getOriginalValue(contextProperties, maprticket_Password));
|
||||
|
||||
String maprticket_Cluster = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER,
|
||||
getOriginalValue(contextProperties, maprticket_Cluster));
|
||||
|
||||
String maprticket_Duration = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION,
|
||||
getOriginalValue(contextProperties, maprticket_Duration));
|
||||
|
||||
String jdbcPropertiesString = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_JDBC_PROPERTIES);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_JDBC_PROPERTIES,
|
||||
getOriginalValue(contextProperties, jdbcPropertiesString));
|
||||
|
||||
String additionalJDBCSettings = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS,
|
||||
getOriginalValue(contextProperties, additionalJDBCSettings));
|
||||
|
||||
String propertiesString = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES,
|
||||
getOriginalValue(contextProperties, propertiesString));
|
||||
|
||||
String trustStorePath = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH);
|
||||
if (trustStorePath != null) {
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH,
|
||||
getOriginalValue(contextProperties, trustStorePath));
|
||||
}
|
||||
|
||||
String trustStorePassword = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD);
|
||||
if (trustStorePassword != null) {
|
||||
cloneConn.getParameters().put(
|
||||
ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD,
|
||||
cloneConn.getValue(cloneConn.getValue(getOriginalValue(contextProperties, trustStorePassword), false),
|
||||
true));
|
||||
}
|
||||
|
||||
String template = null;
|
||||
String hiveServerVersion = HiveServerVersionInfo.HIVE_SERVER_1.getKey();
|
||||
EMap<String, String> parameterMap = dbConn.getParameters();
|
||||
if (parameterMap != null) {
|
||||
hiveServerVersion = parameterMap.get(ConnParameterKeys.HIVE_SERVER_VERSION);
|
||||
}
|
||||
|
||||
if (HiveServerVersionInfo.HIVE_SERVER_2.getKey().equals(hiveServerVersion)) {
|
||||
template = DbConnStrForHive.URL_HIVE_2_TEMPLATE;
|
||||
} else {
|
||||
template = DbConnStrForHive.URL_HIVE_1_TEMPLATE;
|
||||
}
|
||||
// the original value is a contexted value
|
||||
String newURl = DatabaseConnStrUtil.getHiveURLString(cloneConn, server, port, sidOrDatabase, template);
|
||||
|
||||
cloneConn.setURL(newURl);
|
||||
return cloneConn;
|
||||
}
|
||||
|
||||
// for Hbase
|
||||
if (EDatabaseTypeName.HBASE.equals(EDatabaseTypeName.getTypeFromDbType(cloneConn.getDatabaseType()))) {
|
||||
String hbaseMasterPrin = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MASTERPRINCIPAL);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MASTERPRINCIPAL,
|
||||
getOriginalValue(contextProperties, hbaseMasterPrin));
|
||||
|
||||
String hbaseRegionPrin = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_REGIONSERVERPRINCIPAL);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_REGIONSERVERPRINCIPAL,
|
||||
getOriginalValue(contextProperties, hbaseRegionPrin));
|
||||
|
||||
String hbaseKeyTabPrin = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,
|
||||
getOriginalValue(contextProperties, hbaseKeyTabPrin));
|
||||
|
||||
String hbaseKeyTab = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB,
|
||||
getOriginalValue(contextProperties, hbaseKeyTab));
|
||||
|
||||
String maprticket_Username = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_USERNAME);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_USERNAME,
|
||||
getOriginalValue(contextProperties, maprticket_Username));
|
||||
|
||||
String maprticket_Password = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_PASSWORD);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_PASSWORD,
|
||||
getOriginalValue(contextProperties, maprticket_Password));
|
||||
|
||||
String maprticket_Cluster = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_CLUSTER);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_CLUSTER,
|
||||
getOriginalValue(contextProperties, maprticket_Cluster));
|
||||
|
||||
String maprticket_Duration = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_DURATION);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_DURATION,
|
||||
getOriginalValue(contextProperties, maprticket_Duration));
|
||||
|
||||
String tableNSMapping = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_TABLE_NS_MAPPING);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_TABLE_NS_MAPPING,
|
||||
getOriginalValue(contextProperties, tableNSMapping));
|
||||
}
|
||||
|
||||
// for Maprdb
|
||||
if (EDatabaseTypeName.MAPRDB.equals(EDatabaseTypeName.getTypeFromDbType(cloneConn.getDatabaseType()))) {
|
||||
String maprdbMasterPrin = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_MASTERPRINCIPAL);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_MASTERPRINCIPAL,
|
||||
getOriginalValue(contextProperties, maprdbMasterPrin));
|
||||
|
||||
String maprdbRegionPrin = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_REGIONSERVERPRINCIPAL);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_REGIONSERVERPRINCIPAL,
|
||||
getOriginalValue(contextProperties, maprdbRegionPrin));
|
||||
|
||||
String znodeParent = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_ZNODE_PARENT);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_ZNODE_PARENT,
|
||||
getOriginalValue(contextProperties, znodeParent));
|
||||
|
||||
String maprdbKeyTabPrin = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,
|
||||
getOriginalValue(contextProperties, maprdbKeyTabPrin));
|
||||
|
||||
String maprdbKeyTab = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB,
|
||||
getOriginalValue(contextProperties, maprdbKeyTab));
|
||||
|
||||
String maprticket_Username = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_USERNAME);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_USERNAME,
|
||||
getOriginalValue(contextProperties, maprticket_Username));
|
||||
|
||||
String maprticket_Password = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_MAPRTICKET_PASSWORD);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_MAPRTICKET_PASSWORD,
|
||||
getOriginalValue(contextProperties, maprticket_Password));
|
||||
|
||||
String maprticket_Cluster = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_MAPRTICKET_CLUSTER);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_MAPRTICKET_CLUSTER,
|
||||
getOriginalValue(contextProperties, maprticket_Cluster));
|
||||
|
||||
String maprticket_Duration = cloneConn.getParameters().get(
|
||||
ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_MAPRTICKET_DURATION);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_MAPRTICKET_DURATION,
|
||||
getOriginalValue(contextProperties, maprticket_Duration));
|
||||
|
||||
String tableNSMapping = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_TABLE_NS_MAPPING);
|
||||
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_TABLE_NS_MAPPING,
|
||||
getOriginalValue(contextProperties, tableNSMapping));
|
||||
}
|
||||
|
||||
// TDI-28124:tdb2input can't guess schema from join sql on system table
|
||||
if (EDatabaseTypeName.IBMDB2.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
|
||||
String cursorForDb2 = ":cursorSensitivity=2;";
|
||||
String database = sidOrDatabase + cursorForDb2;
|
||||
String newURL = DatabaseConnStrUtil.getURLString(cloneConn.getDatabaseType(), dbConn.getDbVersionString(), server,
|
||||
username, password, port, database, filePath.toLowerCase(), datasource, dbRootPath, additionParam);
|
||||
cloneConn.setURL(newURL);
|
||||
return cloneConn;
|
||||
}
|
||||
|
||||
if (EDatabaseTypeName.IMPALA.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
|
||||
String impalaAuthPrinciple = cloneConn.getParameters().get(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA);
|
||||
if (impalaAuthPrinciple != null) {
|
||||
cloneConn.getParameters().put(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA,
|
||||
getOriginalValue(contextProperties, impalaAuthPrinciple));
|
||||
}
|
||||
}
|
||||
|
||||
// Added 20130311 TDQ-7000, when it is context mode and not general
|
||||
// jdbc, reset the url.
|
||||
if (dbConn.isContextMode()
|
||||
&& !EDatabaseTypeName.GENERAL_JDBC.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
|
||||
String newURL = DatabaseConnStrUtil.getURLString(cloneConn.getDatabaseType(), dbConn.getDbVersionString(), server,
|
||||
username, password, port, sidOrDatabase, filePath.toLowerCase(), datasource, dbRootPath, additionParam);
|
||||
username, password, port, sidOrDatabase, filePath == null ? filePath : filePath.toLowerCase(), datasource,
|
||||
dbRootPath, additionParam);
|
||||
cloneConn.setURL(newURL);
|
||||
return cloneConn;
|
||||
}// ~
|
||||
|
||||
@@ -52,6 +52,8 @@ public interface ILibraryManagerService extends IService {
|
||||
*/
|
||||
public void deploy(URI jarFileUri, IProgressMonitor... monitorWrap);
|
||||
|
||||
public void deploy(URI jarFileUri, String mavenUri, IProgressMonitor... monitorWrap);
|
||||
|
||||
public void deploy(Collection<URI> jarFileUris, IProgressMonitor... monitorWrap);
|
||||
|
||||
/**
|
||||
@@ -97,6 +99,8 @@ public interface ILibraryManagerService extends IService {
|
||||
IProgressMonitor... monitorWrap);
|
||||
|
||||
public boolean retrieve(ModuleNeeded module, String pathToStore, boolean showDialog, IProgressMonitor... monitorWrap);
|
||||
|
||||
public boolean retrieve(ModuleNeeded module, String pathToStore, boolean showDialog, NexusServerBean bean, IProgressMonitor... monitorWrap);
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -184,7 +184,7 @@ public class HadoopRepositoryUtil {
|
||||
}
|
||||
ContextType contextType = null;
|
||||
if (mmUIService != null) {
|
||||
contextType = mmUIService.getContextTypeForContextMode(connection);
|
||||
contextType = mmUIService.getContextTypeForContextMode(connection, null, true);
|
||||
}
|
||||
if (useOriginalValue && contextType != null) {
|
||||
properties = getHadoopPropertiesWithOriginalValue(propertiesJsonStr, contextType, includeQuotes);
|
||||
|
||||
@@ -57,6 +57,8 @@ public interface IComponent {
|
||||
String SPARK_STREAMING_JOBLET_FAMILY = "Spark Streaming Joblets"; //$NON-NLS-1$
|
||||
|
||||
public String getName();
|
||||
|
||||
public String getOriginalName();
|
||||
|
||||
public String getLongName();
|
||||
|
||||
|
||||
@@ -78,6 +78,8 @@ public interface IComponentsFactory {
|
||||
public IComponent get(String name);
|
||||
|
||||
public IComponent get(String name, String paletteType);
|
||||
|
||||
public IComponent getJobletComponent(String name, String paletteType);
|
||||
|
||||
public List<String> getSkeletons();
|
||||
|
||||
|
||||
@@ -59,6 +59,10 @@ public interface ILibrariesService extends IService {
|
||||
|
||||
public void deployLibrary(URL source) throws IOException;
|
||||
|
||||
public void deployLibrary(URL source, String mvnURI) throws IOException;
|
||||
|
||||
public void deployLibrary(URL source, String mavenUri, boolean refresh) throws IOException;
|
||||
|
||||
public void deployLibrarys(URL[] source) throws IOException;
|
||||
|
||||
public void undeployLibrary(String jarName) throws IOException;
|
||||
@@ -100,7 +104,7 @@ public interface ILibrariesService extends IService {
|
||||
Set<ModuleNeeded> getCodesModuleNeededs(ERepositoryObjectType type);
|
||||
|
||||
List<ModuleNeeded> getModuleNeeded(String id, boolean isGroup);
|
||||
|
||||
|
||||
public void deployProjectLibrary(File source) throws IOException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -401,7 +401,7 @@ public class ModuleNeeded {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (bundleName == null) {
|
||||
if (bundleName == null || "".equals(bundleName.trim())) {
|
||||
return moduleName;
|
||||
} else if (bundleVersion == null) {
|
||||
return moduleName + "[" + bundleName + "]";
|
||||
|
||||
@@ -330,5 +330,4 @@ public class Project {
|
||||
public void setExchangeUser(ExchangeUser exchangeUser) {
|
||||
// project.setExchangeUser(exchangeUser);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.cwm.helper.SAPBWTableHelper;
|
||||
import org.talend.cwm.helper.TaggedValueHelper;
|
||||
import org.talend.model.bridge.ReponsitoryContextBridge;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
|
||||
import orgomg.cwm.objectmodel.core.TaggedValue;
|
||||
|
||||
@@ -340,6 +341,10 @@ public final class ConvertionHelper {
|
||||
public static IMetadataTable convert(MetadataTable old) {
|
||||
IMetadataTable result = new org.talend.core.model.metadata.MetadataTable();
|
||||
result.setComment(old.getComment());
|
||||
if(old.getId() == null){
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
old.setId(factory.getNextId());
|
||||
}
|
||||
result.setId(old.getId());
|
||||
result.setLabel(old.getLabel());
|
||||
result.setTableType(old.getTableType());
|
||||
|
||||
@@ -990,7 +990,8 @@ public class RepositoryToComponentProperty {
|
||||
|| EDatabaseConnTemplate.ORACLESN.getDBDisplayName().equals(databaseType)
|
||||
|| EDatabaseConnTemplate.PLUSPSQL.getDBDisplayName().equals(databaseType)
|
||||
|| EDatabaseConnTemplate.PSQL.getDBDisplayName().equals(databaseType)
|
||||
|| EDatabaseConnTemplate.SAPHana.getDBDisplayName().equals(databaseType)) {
|
||||
|| EDatabaseConnTemplate.SAPHana.getDBDisplayName().equals(databaseType)
|
||||
|| EDatabaseConnTemplate.MSSQL.getDBDisplayName().equals(databaseType)) {
|
||||
if (dbVersionString != null) {
|
||||
driverValue = dbVersionString.toUpperCase();
|
||||
}
|
||||
|
||||
@@ -174,9 +174,10 @@ public final class ElementParameterParser {
|
||||
return null;
|
||||
} else {
|
||||
String linkedNodeName = ElementParameterParser.getValue(node, parameterName);
|
||||
java.util.List<? extends INode> allGraphicNodes = ((INode) node).getProcess().getGraphicalNodes();
|
||||
if (allGraphicNodes != null && allGraphicNodes.size() > 0) {
|
||||
for (INode linkedNode : allGraphicNodes) {
|
||||
//when linked node in joblet, can be found in generating node list only
|
||||
java.util.List<? extends INode> allGeneratingNodes = ((INode) node).getProcess().getGeneratingNodes();
|
||||
if (allGeneratingNodes != null && allGeneratingNodes.size() > 0) {
|
||||
for (INode linkedNode : allGeneratingNodes) {
|
||||
if (linkedNode.getUniqueName().equals(linkedNodeName)) {
|
||||
return linkedNode;
|
||||
}
|
||||
|
||||
@@ -648,14 +648,25 @@ public class RelationshipItemBuilder {
|
||||
|
||||
if (item instanceof ProcessItem) {
|
||||
type = JOB_RELATION;
|
||||
}
|
||||
if (item instanceof JobletProcessItem) {
|
||||
} else if (item instanceof JobletProcessItem) {
|
||||
type = JOBLET_RELATION;
|
||||
} else {
|
||||
throw new RuntimeException(Messages.getString("RelationshipItemBuilder.unexpect.item", item.getClass().getName())); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public List<ERepositoryObjectType> getSupportRepObjTypes(String relationType) {
|
||||
if (JOB_RELATION.equals(relationType)) {
|
||||
return ERepositoryObjectType.getAllTypesOfProcess();
|
||||
} else if (JOBLET_RELATION.equals(relationType)) {
|
||||
return ERepositoryObjectType.getAllTypesOfJoblet();
|
||||
} else {
|
||||
throw new RuntimeException(Messages.getString("RelationshipItemBuilder.unexpect.relation", relationType)); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
private void clearItemsRelations(Item baseItem) {
|
||||
Relation relation = new Relation();
|
||||
relation.setId(baseItem.getProperty().getId());
|
||||
@@ -840,18 +851,32 @@ public class RelationshipItemBuilder {
|
||||
|
||||
public boolean supportRelation(Item item){
|
||||
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
|
||||
if (ERepositoryObjectType.getAllTypesOfProcess().contains(itemType)) {
|
||||
return true;
|
||||
}else if(ERepositoryObjectType.JOBLET!=null && itemType == ERepositoryObjectType.JOBLET){
|
||||
return true;
|
||||
}else if(ERepositoryObjectType.SPARK_JOBLET!=null && itemType == ERepositoryObjectType.SPARK_JOBLET){
|
||||
return true;
|
||||
}else if(ERepositoryObjectType.SPARK_STREAMING_JOBLET!=null && itemType == ERepositoryObjectType.SPARK_STREAMING_JOBLET){
|
||||
|
||||
List<ERepositoryObjectType> supportTypes = getSupportTypes();
|
||||
|
||||
if (supportTypes != null && supportTypes.contains(itemType)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<ERepositoryObjectType> getSupportTypes() {
|
||||
List<ERepositoryObjectType> supportTypes = new ArrayList<ERepositoryObjectType>();
|
||||
|
||||
List<ERepositoryObjectType> processTypes = getSupportRepObjTypes(JOB_RELATION);
|
||||
if (processTypes != null && !processTypes.isEmpty()) {
|
||||
supportTypes.addAll(processTypes);
|
||||
}
|
||||
|
||||
List<ERepositoryObjectType> jobletTypes = getSupportRepObjTypes(JOBLET_RELATION);
|
||||
if (jobletTypes != null && !jobletTypes.isEmpty()) {
|
||||
supportTypes.addAll(jobletTypes);
|
||||
}
|
||||
|
||||
return supportTypes;
|
||||
}
|
||||
|
||||
public void addOrUpdateItem(Item item) {
|
||||
addOrUpdateItem(item, false);
|
||||
}
|
||||
@@ -944,6 +969,17 @@ public class RelationshipItemBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public void removeItemRelations(Relation relation, boolean save) {
|
||||
Map<Relation, Set<Relation>> itemRelations = getCurrentProjectItemsRelations();
|
||||
if (itemRelations != null && itemRelations.containsKey(relation)) {
|
||||
itemRelations.get(relation).clear();
|
||||
itemRelations.remove(relation);
|
||||
if (save) {
|
||||
saveRelations();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Relation, Set<Relation>> getCurrentProjectItemsRelations() {
|
||||
return this.currentProjectItemsRelations;
|
||||
}
|
||||
|
||||
@@ -51,4 +51,5 @@ public interface IRepositoryPrefConstants {
|
||||
|
||||
public static final String ALLOW_SPECIFIC_CHARACTERS_FOR_SCHEMA_COLUMNS = "allow_specific_characters_for_schema_columns";
|
||||
|
||||
public static final String REF_PROJECT_BRANCH_SETTING = "ref_project_branch_setting";
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.model.utils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -23,6 +24,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.talend.core.model.components.ComponentCategory;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
@@ -930,18 +933,40 @@ public class NodeUtil {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String replaceCRLFInMEMO_SQL(String original) {
|
||||
return replaceCRLFInMEMO_SQL(original, true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC liuwu Comment method "replaceMEMO_SQL". aim: to resolve TDI-7487
|
||||
*
|
||||
*
|
||||
* if splitAlways is true, will split the string always to avoid the huge string constant
|
||||
* if splitAlways is false, split only when the string constant reach the limit : 60000 bytes
|
||||
*
|
||||
* @param original
|
||||
* @return
|
||||
*/
|
||||
public static String replaceCRLFInMEMO_SQL(String original) {
|
||||
public static String replaceCRLFInMEMO_SQL(String original, boolean splitAlways) {
|
||||
if (original == null || original.trim().length() == 0) {
|
||||
return original;
|
||||
}
|
||||
String result = "";
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
boolean needSplit = true;
|
||||
|
||||
if(!splitAlways) {
|
||||
try {
|
||||
//there is 64k limit for string constant, we set the limit to 60000 for code format reason like auto new line for editor
|
||||
needSplit = original.getBytes("UTF-8").length > 60000;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
}
|
||||
}
|
||||
|
||||
Pattern invalid_unicode_character_regex = Pattern.compile("^.*(\\\\u[0-9a-fA-F]{0,3})$", Pattern.DOTALL);
|
||||
//now don't process the octal case for code performance, can enable it when real need from customer
|
||||
//Pattern invalid_octal_character_regex = Pattern.compile("^.*(\\\\[0-9]{1,2})$", Pattern.DOTALL);
|
||||
|
||||
int leftQuotes = original.indexOf("\"");
|
||||
int rightQuotes = original.indexOf("\"", leftQuotes + 1);
|
||||
int fakeRightQuotes = original.indexOf("\\\"", leftQuotes + 1);
|
||||
@@ -950,14 +975,52 @@ public class NodeUtil {
|
||||
fakeRightQuotes = original.indexOf("\\\"", fakeRightQuotes + 1);
|
||||
}
|
||||
int leftPrev = 0;
|
||||
while (leftQuotes >= 0 && rightQuotes > leftQuotes) {
|
||||
if (leftQuotes > leftPrev) {
|
||||
result += original.substring(leftPrev, leftQuotes);
|
||||
}
|
||||
// System.out.println("leftQuote="+leftQuotes + ", rightQuote="+rightQuotes);
|
||||
if (leftQuotes < rightQuotes) {
|
||||
result += original.substring(leftQuotes, rightQuotes + 1).replace("\r", "").replace("\n", "\\n");
|
||||
}
|
||||
while (leftQuotes >= 0 && rightQuotes > leftQuotes) {
|
||||
if (leftQuotes > leftPrev) {//Outside of double quote
|
||||
result.append(original.substring(leftPrev, leftQuotes));
|
||||
}
|
||||
|
||||
if (leftQuotes < rightQuotes) {//Inside of double quote
|
||||
//split string for better appearance and avoid compile error when string exceed 64k
|
||||
if(needSplit) {
|
||||
int current = leftQuotes;
|
||||
int Offset = 120;
|
||||
int count = 0;
|
||||
while (rightQuotes + 1 - current > 120) {
|
||||
//[\u0000] or [\000]
|
||||
Matcher matcher = invalid_unicode_character_regex.matcher(original.substring(current, current + Offset));
|
||||
if(matcher.matches()) {
|
||||
Offset = Offset - matcher.group(1).length();
|
||||
}
|
||||
/*
|
||||
else {
|
||||
matcher = invalid_octal_character_regex.matcher(original.substring(current, current + Offset));
|
||||
if(matcher.matches()) {
|
||||
Offset = Offset - matcher.group(1).length();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
while (original.charAt(current + Offset - 1) == '\\') {//avoid split special character e.g. \"
|
||||
Offset--;
|
||||
}
|
||||
|
||||
if(count>500){//This is the code that really solve TDI-39968 others are only for good appearance.
|
||||
result.append(original.substring(current, current + Offset).replace("\r", "").replace("\n", "\\n")).append("\" + new String()\n+\"");
|
||||
count = 0;
|
||||
}else{
|
||||
result.append(original.substring(current, current + Offset).replace("\r", "").replace("\n", "\\n")).append("\"\n+\"");
|
||||
}
|
||||
|
||||
current += Offset;
|
||||
Offset = 120;
|
||||
count++;
|
||||
}
|
||||
result.append(original.substring(current, rightQuotes + 1).replace("\r", "").replace("\n", "\\n"));
|
||||
} else {
|
||||
result.append(original.substring(leftQuotes, rightQuotes + 1).replace("\r", "").replace("\n", "\\n"));
|
||||
}
|
||||
}
|
||||
|
||||
leftQuotes = original.indexOf("\"", rightQuotes + 1);
|
||||
leftPrev = rightQuotes + 1;
|
||||
@@ -968,8 +1031,8 @@ public class NodeUtil {
|
||||
fakeRightQuotes = original.indexOf("\\\"", fakeRightQuotes + 1);
|
||||
}
|
||||
}
|
||||
result += original.substring(leftPrev);
|
||||
return result;
|
||||
result.append(original.substring(leftPrev));
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -204,6 +204,11 @@ public class TalendLibsServerManager {
|
||||
return mavenResolver;
|
||||
|
||||
}
|
||||
|
||||
public void checkAndUpdateNexusServer() {
|
||||
lastConnectionValid = null;
|
||||
getCustomNexusServer();
|
||||
}
|
||||
|
||||
public NexusServerBean getCustomNexusServer() {
|
||||
if (!org.talend.core.PluginChecker.isCoreTISPluginLoaded()) {
|
||||
@@ -223,32 +228,40 @@ public class TalendLibsServerManager {
|
||||
|| Boolean.FALSE == lastConnectionValid) {
|
||||
return null;
|
||||
}
|
||||
if (repositoryContext != null && repositoryContext.getFields() != null && !factory.isLocalConnectionProvider()
|
||||
&& !repositoryContext.isOffline()) {
|
||||
String adminUrl = repositoryContext.getFields().get(RepositoryConstants.REPOSITORY_URL);
|
||||
String userName = "";
|
||||
String password = "";
|
||||
User user = repositoryContext.getUser();
|
||||
if (user != null) {
|
||||
userName = user.getLogin();
|
||||
password = repositoryContext.getClearPassword();
|
||||
}
|
||||
if (lastConnectionValid != Boolean.TRUE) {
|
||||
if (repositoryContext != null && repositoryContext.getFields() != null && !factory.isLocalConnectionProvider()
|
||||
&& !repositoryContext.isOffline()) {
|
||||
String adminUrl = repositoryContext.getFields().get(RepositoryConstants.REPOSITORY_URL);
|
||||
String userName = "";
|
||||
String password = "";
|
||||
User user = repositoryContext.getUser();
|
||||
if (user != null) {
|
||||
userName = user.getLogin();
|
||||
password = repositoryContext.getClearPassword();
|
||||
}
|
||||
|
||||
if (adminUrl != null && !"".equals(adminUrl)
|
||||
&& GlobalServiceRegister.getDefault().isServiceRegistered(IRemoteService.class)) {
|
||||
IRemoteService remoteService = (IRemoteService) GlobalServiceRegister.getDefault().getService(
|
||||
IRemoteService.class);
|
||||
JSONObject libServerObject;
|
||||
libServerObject = remoteService.getLibNexusServer(userName, password, adminUrl);
|
||||
if (libServerObject != null) {
|
||||
nexus_url = libServerObject.getString(KEY_NEXUS_RUL);
|
||||
nexus_user = libServerObject.getString(KEY_NEXUS_USER);
|
||||
nexus_pass = libServerObject.getString(KEY_NEXUS_PASS);
|
||||
repositoryId = libServerObject.getString(KEY_CUSTOM_LIB_REPOSITORY);
|
||||
snapshotRepId = libServerObject.getString(KEY_CUSTOM_LIB_SNAPSHOT_REPOSITORY);
|
||||
if (adminUrl != null && !"".equals(adminUrl)
|
||||
&& GlobalServiceRegister.getDefault().isServiceRegistered(IRemoteService.class)) {
|
||||
IRemoteService remoteService = (IRemoteService) GlobalServiceRegister.getDefault().getService(
|
||||
IRemoteService.class);
|
||||
JSONObject libServerObject;
|
||||
libServerObject = remoteService.getLibNexusServer(userName, password, adminUrl);
|
||||
if (libServerObject != null) {
|
||||
nexus_url = libServerObject.getString(KEY_NEXUS_RUL);
|
||||
nexus_user = libServerObject.getString(KEY_NEXUS_USER);
|
||||
nexus_pass = libServerObject.getString(KEY_NEXUS_PASS);
|
||||
repositoryId = libServerObject.getString(KEY_CUSTOM_LIB_REPOSITORY);
|
||||
snapshotRepId = libServerObject.getString(KEY_CUSTOM_LIB_SNAPSHOT_REPOSITORY);
|
||||
System.setProperty(NEXUS_URL, nexus_url);
|
||||
System.setProperty(NEXUS_USER, nexus_user);
|
||||
System.setProperty(NEXUS_PASSWORD, nexus_pass);
|
||||
System.setProperty(NEXUS_LIB_REPO, repositoryId);
|
||||
System.setProperty(NEXUS_LIB_SNAPSHOT_REPO, snapshotRepId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastConnectionValid == null) {
|
||||
boolean connectionOk = NexusServerUtils.checkConnectionStatus(nexus_url, repositoryId, nexus_user, nexus_pass)
|
||||
&& NexusServerUtils.checkConnectionStatus(nexus_url, snapshotRepId, nexus_user, nexus_pass);
|
||||
|
||||
@@ -82,9 +82,11 @@ public interface ITalendCorePrefConstants {
|
||||
public static final String DEACTIVE_REPOSITORY_UPDATE = "DEACTIVE_REPOSITORY_UPDATE"; //$NON-NLS-1$
|
||||
|
||||
public static final String DB_CONNECTION_TIMEOUT_ACTIVED = "db_conn_timeout_actived"; //$NON-NLS-1$
|
||||
|
||||
|
||||
public static final String DB_CONNECTION_TIMEOUT = "db_conn_timeout"; //$NON-NLS-1$
|
||||
|
||||
public static final String HBASE_OR_MAPRDB_SCAN_LIMIT = "hbase_or_maprdb_scan_limit"; //$NON-NLS-1$
|
||||
|
||||
public static final String DOC_USER_LOGO = "doc_user_logo"; //$NON-NLS-1$
|
||||
|
||||
public static final String DOC_COMPANY_NAME = "company_name"; //$NON-NLS-1$
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.eclipse.ui.PlatformUI;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.Hex;
|
||||
import org.talend.core.model.general.ConnectionBean;
|
||||
import org.talend.core.model.repository.IRepositoryPrefConstants;
|
||||
import org.talend.utils.json.JSONArray;
|
||||
import org.talend.utils.json.JSONException;
|
||||
import org.talend.utils.json.JSONObject;
|
||||
@@ -335,5 +336,25 @@ public final class PreferenceManipulator implements ITalendCorePrefConstants {
|
||||
store.setValue(hexKey, json.toString());
|
||||
save();
|
||||
}
|
||||
|
||||
public void setAllLocalRefBranchSetting(JSONObject allBranchSetting) {
|
||||
if (allBranchSetting == null) {
|
||||
allBranchSetting = new JSONObject();
|
||||
}
|
||||
this.store.setValue(IRepositoryPrefConstants.REF_PROJECT_BRANCH_SETTING, allBranchSetting.toString());
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
public JSONObject getAllLocalRefBranchSetting() {
|
||||
|
||||
String strValue = this.store.getString(IRepositoryPrefConstants.REF_PROJECT_BRANCH_SETTING);
|
||||
JSONObject allBranchSetting = null;
|
||||
try {
|
||||
allBranchSetting = new JSONObject(strValue);
|
||||
} catch (Exception e) {
|
||||
allBranchSetting = new JSONObject();
|
||||
}
|
||||
return allBranchSetting;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -17,7 +17,8 @@ package org.talend.core.runtime.maven;
|
||||
*/
|
||||
@SuppressWarnings("nls")
|
||||
public interface MavenConstants {
|
||||
|
||||
static final String NAME_GROUP_ID = "GROUP_ID";
|
||||
|
||||
static final String TYPE_JAR = "jar";
|
||||
|
||||
static final String DEFAULT_GROUP_ID = "org.talend";
|
||||
|
||||
@@ -146,4 +146,10 @@ public interface ITalendProcessJavaProject {
|
||||
*/
|
||||
void cleanMavenFiles(IProgressMonitor monitor) throws Exception;
|
||||
|
||||
/**
|
||||
*
|
||||
* Reset the main pom to empty the content of the job dependencies.
|
||||
*/
|
||||
void regenerateMainProjectPom(IProgressMonitor monitor) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.runtime.projectsetting;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
@@ -25,8 +27,11 @@ import org.eclipse.ui.preferences.ScopedPreferenceStore;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.documentation.ERepositoryActionName;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
@@ -47,10 +52,20 @@ public final class ProjectPreferenceManager {
|
||||
private ProjectScope projectScope;
|
||||
|
||||
private IPreferenceStore store;
|
||||
|
||||
private boolean isCurrentProject;
|
||||
|
||||
private static IRepositoryService repositoryService;
|
||||
|
||||
static {
|
||||
if(GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
|
||||
repositoryService = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
}
|
||||
}
|
||||
|
||||
public ProjectPreferenceManager(String fileName) {
|
||||
this(ProjectManager.getInstance().getCurrentProject(), fileName);
|
||||
|
||||
isCurrentProject = true;
|
||||
}
|
||||
|
||||
public ProjectPreferenceManager(Project p, String fileName) {
|
||||
@@ -62,12 +77,13 @@ public final class ProjectPreferenceManager {
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
addPropertyChangeListener();
|
||||
}
|
||||
|
||||
public ProjectPreferenceManager(IProject project, String fileName) {
|
||||
super();
|
||||
init(project, fileName);
|
||||
addPropertyChangeListener();
|
||||
}
|
||||
|
||||
private void init(IProject project, String fileName) {
|
||||
@@ -79,11 +95,17 @@ public final class ProjectPreferenceManager {
|
||||
this.store = new ScopedPreferenceStore(this.projectScope, this.qualifier);
|
||||
}
|
||||
|
||||
private void addPropertyChangeListener() {
|
||||
if (repositoryService != null) {
|
||||
repositoryService.getProxyRepositoryFactory().addPropertyChangeListener(new ProjectPreferenceReloadListener());
|
||||
}
|
||||
}
|
||||
|
||||
public String getQualifier() {
|
||||
return qualifier;
|
||||
}
|
||||
|
||||
private IProject getProject() {
|
||||
public IProject getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
@@ -162,5 +184,27 @@ public final class ProjectPreferenceManager {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
if (isCurrentProject) {
|
||||
try {
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
init(ResourceUtils.getProject(currentProject), qualifier);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ProjectPreferenceReloadListener implements PropertyChangeListener {
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent event) {
|
||||
if (event.getPropertyName().equals(ERepositoryActionName.PROJECT_PREFERENCES_RELOAD.getName())) {
|
||||
reload();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ public interface IMetadataManagmentUiService extends IService {
|
||||
public String getAndOpenXSDFileDialog(Path initPath);
|
||||
|
||||
public ContextType getContextTypeForContextMode(Connection connection);
|
||||
|
||||
public ContextType getContextTypeForContextMode(Connection connection, String selectedName, boolean defaultContext);
|
||||
|
||||
public String getOriginalValue(ContextType contextType, final String value);
|
||||
|
||||
|
||||
@@ -175,6 +175,8 @@ public interface IDesignerCoreService extends IService {
|
||||
|
||||
public int getDBConnectionTimeout();
|
||||
|
||||
public int getHBaseOrMaprDBScanLimit();
|
||||
|
||||
public Reader getJavadocContentAccessContentReader(IMember member) throws JavaModelException;
|
||||
|
||||
public int getTACConnectionTimeout();
|
||||
|
||||
@@ -119,7 +119,8 @@ public interface IRunProcessService extends IService {
|
||||
|
||||
public void updateLibraries(Set<ModuleNeeded> jobModuleList, IProcess process);
|
||||
|
||||
public void updateLibraries(Set<ModuleNeeded> jobModuleList, IProcess process, Set<ModuleNeeded> alreadyRetrievedModules);
|
||||
public void updateLibraries(Set<ModuleNeeded> jobModuleList, IProcess process, Set<ModuleNeeded> alreadyRetrievedModules)
|
||||
throws ProcessorException;
|
||||
|
||||
public void refreshView();
|
||||
|
||||
@@ -182,4 +183,5 @@ public interface IRunProcessService extends IService {
|
||||
|
||||
Set<String> getLibJarsForBD(IProcess process);
|
||||
|
||||
void updateProjectPomWithTemplate();
|
||||
}
|
||||
|
||||
@@ -15,13 +15,16 @@ package org.talend.repository;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
@@ -38,6 +41,7 @@ import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.repository.RepositoryManager;
|
||||
import org.talend.core.model.repository.SVNConstant;
|
||||
import org.talend.core.model.utils.TalendPropertiesUtil;
|
||||
import org.talend.core.prefs.PreferenceManipulator;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.ui.IReferencedProjectService;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
@@ -64,6 +68,10 @@ public final class ProjectManager {
|
||||
public static final String NAME_BRANCHES = SVNConstant.NAME_BRANCHES;
|
||||
|
||||
public static final String NAME_TAGS = SVNConstant.NAME_TAGS;
|
||||
|
||||
public static final String BRANCHES_PREFIX = "branches/";
|
||||
|
||||
public static final String ORIGIN_PREFIX = "origin/";
|
||||
|
||||
private static ProjectManager singleton;
|
||||
|
||||
@@ -72,8 +80,23 @@ public final class ProjectManager {
|
||||
private Map<String, String> mapProjectUrlToBranchUrl = new HashMap<String, String>();
|
||||
|
||||
private Map<String, List<FolderItem>> foldersMap = new HashMap<String, List<FolderItem>>();
|
||||
|
||||
private JSONObject allLocalRefBranchSetting = null;
|
||||
|
||||
private Map<String, List<ProjectReference>> allTACProjectProjectReferenceSetting = new HashMap<String, List<ProjectReference>>();
|
||||
|
||||
private Set<String> beforeLogonRecords;
|
||||
|
||||
private Set<String> logonRecords;
|
||||
|
||||
private Set<String> migrationRecords;
|
||||
|
||||
private ProjectManager() {
|
||||
PreferenceManipulator prefManipulator = new PreferenceManipulator();
|
||||
allLocalRefBranchSetting = prefManipulator.getAllLocalRefBranchSetting();
|
||||
beforeLogonRecords = new HashSet<String>();
|
||||
logonRecords = new HashSet<String>();
|
||||
migrationRecords = new HashSet<String>();
|
||||
initCurrentProject();
|
||||
}
|
||||
|
||||
@@ -100,6 +123,22 @@ public final class ProjectManager {
|
||||
|
||||
return null;
|
||||
}
|
||||
public Project getProjectFromProjectTechLabel(String label) {
|
||||
if (currentProject == null) {
|
||||
initCurrentProject();
|
||||
}
|
||||
|
||||
if (currentProject.getTechnicalLabel().equals(label)) {
|
||||
return currentProject;
|
||||
}
|
||||
for (Project project : getAllReferencedProjects()) {
|
||||
if (project.getTechnicalLabel().equals(label)) {
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void initCurrentProject() {
|
||||
Context ctx = CoreRuntimePlugin.getInstance().getContext();
|
||||
@@ -123,7 +162,7 @@ public final class ProjectManager {
|
||||
String parentBranch = ProjectManager.getInstance().getMainProjectBranch(p);
|
||||
if (parentBranch != null) {
|
||||
for (ProjectReference pr : (List<ProjectReference>) p.getReferencedProjects()) {
|
||||
if (pr.getBranch() == null || pr.getBranch().equals(parentBranch)) {
|
||||
if (ProjectManager.validReferenceProject(p, pr)) {
|
||||
resolveRefProject(pr.getReferencedProject()); // only to resolve all
|
||||
}
|
||||
}
|
||||
@@ -137,7 +176,7 @@ public final class ProjectManager {
|
||||
String parentBranch = ProjectManager.getInstance().getMainProjectBranch(p);
|
||||
if (parentBranch != null) {
|
||||
for (ProjectReference pr : (List<ProjectReference>) p.getReferencedProjects()) {
|
||||
if (pr.getBranch() == null || pr.getBranch().equals(parentBranch)) {
|
||||
if (ProjectManager.validReferenceProject(p, pr)) {
|
||||
Project project = new Project(pr.getReferencedProject(), false);
|
||||
allReferencedprojects.add(project);
|
||||
resolveSubRefProject(pr.getReferencedProject(), allReferencedprojects); // only to resolve all
|
||||
@@ -249,11 +288,9 @@ public final class ProjectManager {
|
||||
if (project.equals(this.currentProject)) {
|
||||
return getReferencedProjects();
|
||||
}
|
||||
String parentBranch = getMainProjectBranch(project);
|
||||
|
||||
List<Project> refProjects = new ArrayList<Project>();
|
||||
for (ProjectReference refProject : (List<ProjectReference>) project.getEmfProject().getReferencedProjects()) {
|
||||
if (refProject.getBranch() == null || refProject.getBranch().equals(parentBranch)) {
|
||||
if (ProjectManager.validReferenceProject(project.getEmfProject(), refProject)) {
|
||||
refProjects.add(new Project(refProject.getReferencedProject(), false));
|
||||
}
|
||||
}
|
||||
@@ -276,7 +313,7 @@ public final class ProjectManager {
|
||||
}
|
||||
if (object instanceof Item) {
|
||||
if (((Item) object).getParent() == null) { // may be a routelet from reference project
|
||||
org.talend.core.model.properties.Project refProject = getRouteletReferenceProject((Item)object);
|
||||
org.talend.core.model.properties.Project refProject = getProjectFromItemWithoutParent((Item)object);
|
||||
if (refProject != null) {
|
||||
return refProject;
|
||||
}
|
||||
@@ -295,12 +332,11 @@ public final class ProjectManager {
|
||||
}
|
||||
|
||||
/*
|
||||
* returns reference project where the given routelet comes from, or null
|
||||
* in case if the routelet is from the current project
|
||||
* Returns the project name found from the current path if the parent is null
|
||||
*/
|
||||
private org.talend.core.model.properties.Project getRouteletReferenceProject(Item item) {
|
||||
private org.talend.core.model.properties.Project getProjectFromItemWithoutParent(Item item) {
|
||||
|
||||
final String URI_PREFIX = "platform:/resource/";
|
||||
final String URI_PREFIX = "platform:/resource/"; //$NON-NLS-1$
|
||||
|
||||
org.talend.core.model.properties.ItemState state = item.getState();
|
||||
|
||||
@@ -312,21 +348,19 @@ public final class ProjectManager {
|
||||
}
|
||||
String eProxyUriString = eProxyUri.toString();
|
||||
if (eProxyUriString != null && eProxyUriString.startsWith(URI_PREFIX)) {
|
||||
|
||||
String tmpString = eProxyUriString.substring(URI_PREFIX.length());
|
||||
if (!tmpString.contains("/routelets/")) {
|
||||
return null;
|
||||
}
|
||||
String projectLabel = tmpString.substring(0, tmpString.indexOf("/"));
|
||||
String projectLabel = tmpString.substring(0, tmpString.indexOf("/")); //$NON-NLS-1$
|
||||
|
||||
if (currentProject == null) {
|
||||
initCurrentProject();
|
||||
}
|
||||
|
||||
if (currentProject.getLabel().equalsIgnoreCase(projectLabel)) {
|
||||
if (currentProject.getTechnicalLabel().equalsIgnoreCase(projectLabel)) {
|
||||
return currentProject.getEmfProject();
|
||||
}
|
||||
for (Project project : getAllReferencedProjects()) {
|
||||
if (project.getLabel().equalsIgnoreCase(projectLabel)) {
|
||||
if (project.getTechnicalLabel().equalsIgnoreCase(projectLabel)) {
|
||||
return project.getEmfProject();
|
||||
}
|
||||
}
|
||||
@@ -701,4 +735,211 @@ public final class ProjectManager {
|
||||
}
|
||||
return projectType;
|
||||
}
|
||||
|
||||
public void setLocalRefBranch(org.talend.core.model.properties.Project mainProject, String targetName,
|
||||
List<ProjectReference> projectReferenceList) {
|
||||
if (mainProject == null || targetName == null) {
|
||||
return;
|
||||
}
|
||||
String projectBranchId = getProjectBranchId(mainProject, targetName);
|
||||
try {
|
||||
JSONObject projectRefSetting = null;
|
||||
if (!allLocalRefBranchSetting.isNull(projectBranchId)) {
|
||||
projectRefSetting = allLocalRefBranchSetting.getJSONObject(projectBranchId);
|
||||
} else {
|
||||
projectRefSetting = new JSONObject();
|
||||
allLocalRefBranchSetting.put(projectBranchId, projectRefSetting);
|
||||
}
|
||||
for (ProjectReference projectReference : projectReferenceList) {
|
||||
projectRefSetting.put(projectReference.getReferencedProject().getTechnicalLabel(),
|
||||
projectReference.getReferencedBranch());
|
||||
projectRefSetting.put(mainProject.getTechnicalLabel(), projectReference.getBranch());
|
||||
}
|
||||
// Save to file
|
||||
PreferenceManipulator prefManipulator = new PreferenceManipulator();
|
||||
prefManipulator.setAllLocalRefBranchSetting(allLocalRefBranchSetting);
|
||||
allLocalRefBranchSetting = prefManipulator.getAllLocalRefBranchSetting();
|
||||
} catch (JSONException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void copyLocalRefBranchFromOtherBranch(org.talend.core.model.properties.Project mainProject, String targetBranch,
|
||||
String sourceBranch) {
|
||||
if (mainProject == null || targetBranch == null) {
|
||||
return;
|
||||
}
|
||||
String projectBranchId = getProjectBranchId(mainProject, sourceBranch);
|
||||
try {
|
||||
JSONObject projectRefSetting = null;
|
||||
if (!allLocalRefBranchSetting.isNull(projectBranchId)) {
|
||||
projectRefSetting = allLocalRefBranchSetting.getJSONObject(projectBranchId);
|
||||
String targetBranchId = getProjectBranchId(mainProject, targetBranch);
|
||||
allLocalRefBranchSetting.put(targetBranchId, projectRefSetting);
|
||||
// Save to file
|
||||
PreferenceManipulator prefManipulator = new PreferenceManipulator();
|
||||
prefManipulator.setAllLocalRefBranchSetting(allLocalRefBranchSetting);
|
||||
allLocalRefBranchSetting = prefManipulator.getAllLocalRefBranchSetting();
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteLocalRefBranchSetting(org.talend.core.model.properties.Project mainProject, String mainBranch) {
|
||||
if (mainProject == null || mainBranch == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String projectBranchId = getProjectBranchId(mainProject, mainBranch);
|
||||
if (!allLocalRefBranchSetting.isNull(projectBranchId)) {
|
||||
allLocalRefBranchSetting.remove(projectBranchId);
|
||||
|
||||
PreferenceManipulator prefManipulator = new PreferenceManipulator();
|
||||
prefManipulator.setAllLocalRefBranchSetting(allLocalRefBranchSetting);
|
||||
allLocalRefBranchSetting = prefManipulator.getAllLocalRefBranchSetting();
|
||||
}
|
||||
}
|
||||
|
||||
private String getProjectBranchId(org.talend.core.model.properties.Project mainProject, String mainBranch) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String branchName = getFormatedBranchName(mainBranch);
|
||||
sb.append(mainProject.getTechnicalLabel()).append("@").append(branchName);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public boolean hasLocalRefBranchSetting(org.talend.core.model.properties.Project mainProject, String mainBranch) {
|
||||
if (mainProject == null || mainBranch == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String projectBranchId = getProjectBranchId(mainProject, mainBranch);
|
||||
if (!allLocalRefBranchSetting.isNull(projectBranchId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getLocalProjectReferenceBranch(org.talend.core.model.properties.Project mainProject, String mainBranch,
|
||||
ProjectReference projectReference) {
|
||||
if (mainProject == null || mainBranch == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String projectBranchId = getProjectBranchId(mainProject, mainBranch);
|
||||
JSONObject projectRefSetting = null;
|
||||
try {
|
||||
if (!allLocalRefBranchSetting.isNull(projectBranchId)) {
|
||||
projectRefSetting = allLocalRefBranchSetting.getJSONObject(projectBranchId);
|
||||
if (projectRefSetting != null
|
||||
&& !projectRefSetting.isNull(projectReference.getReferencedProject().getTechnicalLabel())) {
|
||||
return projectRefSetting.getString(projectReference.getProject().getTechnicalLabel());
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getLocalProjectReferenceReferenceBranch(org.talend.core.model.properties.Project mainProject, String mainBranch,
|
||||
ProjectReference projectReference) {
|
||||
if (mainProject == null || mainBranch == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String projectBranchId = getProjectBranchId(mainProject, mainBranch);
|
||||
JSONObject projectRefSetting = null;
|
||||
try {
|
||||
if (!allLocalRefBranchSetting.isNull(projectBranchId)) {
|
||||
projectRefSetting = allLocalRefBranchSetting.getJSONObject(projectBranchId);
|
||||
if (projectRefSetting != null
|
||||
&& !projectRefSetting.isNull(projectReference.getReferencedProject().getTechnicalLabel())) {
|
||||
return projectRefSetting.getString(projectReference.getReferencedProject().getTechnicalLabel());
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean validReferenceProject(org.talend.core.model.properties.Project mainProject,
|
||||
ProjectReference projectReference) {
|
||||
if (mainProject == null || projectReference == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String branchForMainProject = ProjectManager.getInstance().getMainProjectBranch(mainProject);
|
||||
String rBranch4Local = ProjectManager.getInstance().getLocalProjectReferenceBranch(mainProject, branchForMainProject, projectReference);
|
||||
String rRefBranch4Local = ProjectManager.getInstance().getLocalProjectReferenceReferenceBranch(mainProject, branchForMainProject, projectReference);
|
||||
|
||||
return validReferenceProject(branchForMainProject, rBranch4Local, rRefBranch4Local, projectReference);
|
||||
}
|
||||
|
||||
public static boolean validReferenceProject(String branchForMainProject, String rBranch4Local, String refBranch4Local,
|
||||
ProjectReference projectReference) {
|
||||
if (projectReference == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (projectReference.getBranch() == null
|
||||
|| (branchForMainProject != null && (branchForMainProject.equals(projectReference.getBranch())
|
||||
|| branchForMainProject.equals(ORIGIN_PREFIX + projectReference.getBranch())))) {
|
||||
return true;
|
||||
}
|
||||
if (projectReference.getBranch() != null && projectReference.getReferencedBranch() != null) {
|
||||
if (getCleanBranchName(projectReference.getBranch()).equals(getCleanBranchName(rBranch4Local))
|
||||
&& getCleanBranchName(projectReference.getReferencedBranch()).equals(getCleanBranchName(refBranch4Local))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getCleanBranchName(String branchName) {
|
||||
if (branchName == null) {
|
||||
return null;
|
||||
}
|
||||
if (branchName.startsWith(ORIGIN_PREFIX)) {
|
||||
return branchName.substring(ORIGIN_PREFIX.length());
|
||||
}
|
||||
if (branchName.startsWith(BRANCHES_PREFIX)) {
|
||||
return branchName.substring(BRANCHES_PREFIX.length());
|
||||
}
|
||||
return branchName;
|
||||
}
|
||||
|
||||
public Map<String, List<ProjectReference>> getAllTACProjectProjectReferenceSetting() {
|
||||
return allTACProjectProjectReferenceSetting;
|
||||
}
|
||||
|
||||
public List<ProjectReference> getTACProjectReferenceList(Project mainProject, String branchName) {
|
||||
List<ProjectReference> list = new ArrayList<ProjectReference>();
|
||||
List<ProjectReference> allProjectReferenceList = allTACProjectProjectReferenceSetting.get(mainProject.getTechnicalLabel());
|
||||
if (allProjectReferenceList != null) {
|
||||
for (ProjectReference projectReference : allProjectReferenceList) {
|
||||
if (projectReference.getBranch().equals(branchName)) {
|
||||
list.add(projectReference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public Set<String> getBeforeLogonRecords() {
|
||||
return this.beforeLogonRecords;
|
||||
}
|
||||
|
||||
public Set<String> getLogonRecords() {
|
||||
return this.logonRecords;
|
||||
}
|
||||
|
||||
public Set<String> getMigrationRecords() {
|
||||
return this.migrationRecords;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,8 +41,9 @@ public enum ERepositoryActionName {
|
||||
// for joblet only
|
||||
JOBLET_FOLDER_DELETE("joblet.folder.delete"), //$NON-NLS-1$
|
||||
JOBLET_FOLDER_RENAME("joblet.folder.rename"), //$NON-NLS-1$
|
||||
JOBLET_FOLDER_MOVE("joblet.folder.move") //$NON-NLS-1$
|
||||
JOBLET_FOLDER_MOVE("joblet.folder.move"), //$NON-NLS-1$
|
||||
|
||||
PROJECT_PREFERENCES_RELOAD("reload project preferences") //$NON-NLS-1$
|
||||
;
|
||||
|
||||
private String name;
|
||||
|
||||
@@ -258,6 +258,9 @@ public interface IProxyRepositoryFactory {
|
||||
public abstract List<IRepositoryViewObject> getAllVersion(Project project, String id, boolean avoidSaveProject)
|
||||
throws PersistenceException;
|
||||
|
||||
public abstract List<IRepositoryViewObject> getAllVersion(Project project, String id, String folderPath,
|
||||
ERepositoryObjectType type) throws PersistenceException;
|
||||
|
||||
public abstract List<IRepositoryViewObject> getAllVersion(String id) throws PersistenceException;
|
||||
|
||||
public abstract IRepositoryViewObject getLastVersion(Project project, String id, String relativeFolder,
|
||||
|
||||
@@ -29,6 +29,8 @@ public class RepositoryConstants {
|
||||
|
||||
public static final String SETTING_DIRECTORY = ".settings"; //$NON-NLS-1$
|
||||
|
||||
public static final String PROJECT_BRANCH_ID = "repository.project.branch"; //$NON-NLS-1$
|
||||
|
||||
public static final String IMG_DIRECTORY = "images"; //$NON-NLS-1$
|
||||
|
||||
public static final String IMG_DIRECTORY_OF_JOB_OUTLINE = "images/job_outlines"; //$NON-NLS-1$
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.gef.commands.Command;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
||||
@@ -60,6 +61,7 @@ import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.Project;
|
||||
import org.talend.core.ui.context.cmd.AddRepositoryContextGroupCommand;
|
||||
import org.talend.core.ui.editor.command.ContextRemoveParameterCommand;
|
||||
import org.talend.core.ui.i18n.Messages;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
@@ -318,7 +320,7 @@ public class SelectRepositoryContextDialog extends SelectionDialog {
|
||||
ContextParameterType param = (ContextParameterType) obj;
|
||||
treeViewer.setGrayed(param, false);
|
||||
if (helper.existParameterForJob(param)) {
|
||||
treeViewer.setChecked(param, true); // checked always
|
||||
treeViewer.setChecked(param, checked); // checked always
|
||||
} else {
|
||||
ContextParameterType existedParam = hasSelectedParam(param);
|
||||
if (existedParam != null && selectedContextName != null) {
|
||||
@@ -475,16 +477,7 @@ public class SelectRepositoryContextDialog extends SelectionDialog {
|
||||
// modelManager,
|
||||
// helper, paramTypeList);
|
||||
|
||||
if (modelManager.getCommandStack() != null) {
|
||||
|
||||
modelManager.getCommandStack().execute(addGroupCmd);
|
||||
|
||||
// modelManager.getCommandStack().execute(addVarCmd);
|
||||
|
||||
} else {
|
||||
addGroupCmd.execute();
|
||||
// addVarCmd.execute();
|
||||
}
|
||||
execCommand(addGroupCmd);
|
||||
|
||||
monitor.done();
|
||||
|
||||
@@ -500,6 +493,14 @@ public class SelectRepositoryContextDialog extends SelectionDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private void execCommand(Command cmd) {
|
||||
if (modelManager.getCommandStack() != null) {
|
||||
modelManager.getCommandStack().execute(cmd);
|
||||
} else {
|
||||
cmd.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void okPressed() {
|
||||
List<ContextItem> selectedItems = getSelectedContextItem();
|
||||
@@ -514,9 +515,21 @@ public class SelectRepositoryContextDialog extends SelectionDialog {
|
||||
}
|
||||
progressDialog(selectedItems, contextGoupNameSet, getSelectedContextParameterType());
|
||||
|
||||
modelManager.refresh();
|
||||
} else {
|
||||
IContext defaultContext = manager.getDefaultContext();
|
||||
List<IContextParameter> existParas = new ArrayList<>(defaultContext.getContextParameterList());
|
||||
// remove the params which is unchecked
|
||||
for (IContextParameter param : existParas) {
|
||||
if (param.isBuiltIn()) {
|
||||
continue;
|
||||
}
|
||||
ContextRemoveParameterCommand cmd = new ContextRemoveParameterCommand(manager, param.getName(), param.getSource());
|
||||
execCommand(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
modelManager.refresh();
|
||||
|
||||
super.okPressed();
|
||||
|
||||
}
|
||||
|
||||
@@ -145,10 +145,11 @@ public class AddRepositoryContextGroupCommand extends Command {
|
||||
}
|
||||
|
||||
// for Parameter
|
||||
if (modelManager == null || helper == null || parameterList == null || parameterList.isEmpty() || manager == null) {
|
||||
if (modelManager == null || helper == null || parameterList == null || manager == null) {
|
||||
return;
|
||||
}
|
||||
newAddParameter.clear();
|
||||
List<IContextParameter> existParas = new ArrayList<>(defaultContext.getContextParameterList());
|
||||
for (ContextParameterType defaultContextParamType : parameterList) {
|
||||
ContextItem contextItem = (ContextItem) helper.getParentContextItem(defaultContextParamType);
|
||||
if (contextItem == null) {
|
||||
@@ -157,6 +158,7 @@ public class AddRepositoryContextGroupCommand extends Command {
|
||||
|
||||
IContextParameter paramExisted = helper.getExistedContextParameter(defaultContextParamType.getName());
|
||||
if (paramExisted != null) {
|
||||
existParas.remove(paramExisted);
|
||||
// existed.
|
||||
if (!paramExisted.isBuiltIn() && contextItem.getProperty().getId().equals(paramExisted.getSource())) {
|
||||
// update the parameter.
|
||||
@@ -174,6 +176,16 @@ public class AddRepositoryContextGroupCommand extends Command {
|
||||
}
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
//remove the params which is unchecked
|
||||
for(IContextParameter param : existParas){
|
||||
if (param.isBuiltIn()){
|
||||
continue;
|
||||
}
|
||||
new ContextRemoveParameterCommand(manager, param.getName(), param.getSource())
|
||||
.execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,6 +73,7 @@ import org.talend.core.model.repository.job.JobResource;
|
||||
import org.talend.core.model.repository.job.JobResourceManager;
|
||||
import org.talend.core.model.utils.JavaResourcesHelper;
|
||||
import org.talend.core.model.utils.PerlResourcesHelper;
|
||||
import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.runtime.process.ITalendProcessJavaProject;
|
||||
import org.talend.core.runtime.process.LastGenerationInfo;
|
||||
import org.talend.core.runtime.process.TalendProcessArgumentConstant;
|
||||
@@ -386,6 +387,7 @@ public class ProcessorUtilities {
|
||||
|
||||
isMainJob = true;
|
||||
codeModified = false;
|
||||
TalendLibsServerManager.getInstance().checkAndUpdateNexusServer();
|
||||
|
||||
// this cache only keep the last main job's generation, so clear it since we regenerate a new job.
|
||||
LastGenerationInfo.getInstance().getLastGeneratedjobs().clear();
|
||||
@@ -737,6 +739,7 @@ public class ProcessorUtilities {
|
||||
// this cache only keep the last main job's generation, so clear it since we regenerate a new job.
|
||||
LastGenerationInfo.getInstance().getLastGeneratedjobs().clear();
|
||||
retrievedJarsForCurrentBuild.clear();
|
||||
TalendLibsServerManager.getInstance().checkAndUpdateNexusServer();
|
||||
// if it's the father, reset the processMap to ensure to have a good
|
||||
// code generation
|
||||
ItemCacheManager.clearCache();
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<url>http://newbuild.talend.com:8081/nexus/content/repositories/TalendOpenSourceRelease/</url>
|
||||
<url>https://artifacts-zl.talend.com/nexus/content/repositories/TalendOpenSourceRelease/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>talend_open_snapshots</id>
|
||||
@@ -31,7 +31,7 @@
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
<url>http://newbuild.talend.com:8081/nexus/content/repositories/TalendOpenSourceSnapshot/</url>
|
||||
<url>https://artifacts-zl.talend.com/nexus/content/repositories/TalendOpenSourceSnapshot/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
@@ -54,6 +54,9 @@ public final class DefaultMavenRepositoryProvider {
|
||||
if (mavenRepoUrl != null) {
|
||||
mavenRepoUrl = FileLocator.toFileURL(mavenRepoUrl);
|
||||
}
|
||||
if (mavenRepoUrl == null) { // not existed
|
||||
return;
|
||||
}
|
||||
|
||||
File zipFile = new File(mavenRepoUrl.getFile());
|
||||
if (!zipFile.exists()) {
|
||||
|
||||
@@ -18,15 +18,21 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExecutableExtension;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.runtime.projectsetting.ProjectPreferenceManager;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.setting.project.IProjectSettingManagerProvider;
|
||||
import org.talend.repository.ProjectManager;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
@@ -78,8 +84,32 @@ public abstract class AbstractMavenTemplateManager implements IExecutableExtensi
|
||||
return templateUrl.openStream();
|
||||
}
|
||||
|
||||
public InputStream readProjectSettingStream(String projectSettingTemplateKey) throws Exception {
|
||||
protected ProjectPreferenceManager getProjectPreferenceManager(Map<String, Object> parameters) throws Exception {
|
||||
ProjectPreferenceManager projectPreferenceManager = getProjectPreferenceManager();
|
||||
|
||||
if (parameters != null && parameters.containsKey(MavenTemplateManager.KEY_PROJECT_NAME)) {
|
||||
Object pName = parameters.get(MavenTemplateManager.KEY_PROJECT_NAME);
|
||||
if (pName != null && !pName.toString().isEmpty()) {
|
||||
final IProject rProject = getProject(pName.toString());
|
||||
// from reference projects
|
||||
if (rProject != null && !rProject.getName().equals(projectPreferenceManager.getProject().getName())) {
|
||||
projectPreferenceManager = new ProjectPreferenceManager(rProject, projectPreferenceManager.getQualifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
return projectPreferenceManager;
|
||||
}
|
||||
|
||||
protected IProject getProject(String techName) throws PersistenceException {
|
||||
final Project p = ProjectManager.getInstance().getProjectFromProjectTechLabel(techName);
|
||||
final IProject rProject = ResourceUtils.getProject(p);
|
||||
return rProject;
|
||||
}
|
||||
|
||||
public InputStream readProjectSettingStream(String projectSettingTemplateKey, Map<String, Object> parameters)
|
||||
throws Exception {
|
||||
ProjectPreferenceManager projectPreferenceManager = getProjectPreferenceManager(parameters);
|
||||
|
||||
if (projectPreferenceManager == null || projectSettingTemplateKey == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ public enum ETalendMavenVariables {
|
||||
|
||||
ProjectName,
|
||||
ProjectId,
|
||||
ProjectBranch,
|
||||
|
||||
CodesGroupId,
|
||||
CodesArtifactId,
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.talend.designer.maven.DesignerMavenPlugin;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.setting.project.IProjectSettingManagerProvider;
|
||||
import org.talend.designer.maven.utils.PomIdsHelper;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.repository.ProjectManager;
|
||||
|
||||
/**
|
||||
@@ -47,6 +48,8 @@ import org.talend.repository.ProjectManager;
|
||||
*/
|
||||
public class MavenTemplateManager {
|
||||
|
||||
public static final String KEY_PROJECT_NAME = "ProjectName"; //$NON-NLS-1$
|
||||
|
||||
public static Map<String, AbstractMavenTemplateManager> getTemplateManagerMap() {
|
||||
return MavenTemplateManagerRegistry.getInstance().getTemplateManagerMap();
|
||||
}
|
||||
@@ -65,7 +68,7 @@ public class MavenTemplateManager {
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
public static InputStream getTemplateStream(File templateFile, String projectSettingKey, String bundleName,
|
||||
String bundleTemplatePath) throws Exception {
|
||||
String bundleTemplatePath, Map<String, Object> parameters) throws Exception {
|
||||
InputStream stream = null;
|
||||
// 1. from file template dirctly.
|
||||
if (templateFile != null && templateFile.exists()) {
|
||||
@@ -75,7 +78,7 @@ public class MavenTemplateManager {
|
||||
|
||||
// 2. from project setting
|
||||
if (stream == null && projectSettingKey != null) {
|
||||
stream = getProjectSettingStream(projectSettingKey);
|
||||
stream = getProjectSettingStream(projectSettingKey, parameters);
|
||||
}
|
||||
// 3. from bundle template.
|
||||
if (stream == null && bundleName != null && bundleTemplatePath != null) {
|
||||
@@ -85,8 +88,9 @@ public class MavenTemplateManager {
|
||||
}
|
||||
|
||||
public static String getTemplateContent(File templateFile, String projectSettingKey, String bundleName,
|
||||
String bundleTemplatePath) throws Exception {
|
||||
return getContentFromInputStream(getTemplateStream(templateFile, projectSettingKey, bundleName, bundleTemplatePath));
|
||||
String bundleTemplatePath, Map<String, Object> parameters) throws Exception {
|
||||
return getContentFromInputStream(getTemplateStream(templateFile, projectSettingKey, bundleName, bundleTemplatePath,
|
||||
parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,13 +116,13 @@ public class MavenTemplateManager {
|
||||
/**
|
||||
* try to find the template setting in project setting one by one.
|
||||
*/
|
||||
public static String getProjectSettingValue(String key) {
|
||||
public static String getProjectSettingValue(String key, Map<String, Object> parameters) {
|
||||
Map<String, AbstractMavenTemplateManager> templateManagerMap = MavenTemplateManager.getTemplateManagerMap();
|
||||
|
||||
for (String bundleName : templateManagerMap.keySet()) {
|
||||
AbstractMavenTemplateManager templateManager = templateManagerMap.get(bundleName);
|
||||
try {
|
||||
InputStream steam = templateManager.readProjectSettingStream(key);
|
||||
InputStream steam = templateManager.readProjectSettingStream(key, parameters);
|
||||
if (steam != null) {
|
||||
String content = MavenTemplateManager.getContentFromInputStream(steam);
|
||||
if (content != null) {
|
||||
@@ -135,13 +139,13 @@ public class MavenTemplateManager {
|
||||
/**
|
||||
* try to find the template setting in project setting one by one.
|
||||
*/
|
||||
public static InputStream getProjectSettingStream(String key) {
|
||||
public static InputStream getProjectSettingStream(String key, Map<String, Object> parameters) {
|
||||
Map<String, AbstractMavenTemplateManager> templateManagerMap = MavenTemplateManager.getTemplateManagerMap();
|
||||
|
||||
for (String bundleName : templateManagerMap.keySet()) {
|
||||
AbstractMavenTemplateManager templateManager = templateManagerMap.get(bundleName);
|
||||
try {
|
||||
InputStream steam = templateManager.readProjectSettingStream(key);
|
||||
InputStream steam = templateManager.readProjectSettingStream(key, parameters);
|
||||
if (steam != null) {
|
||||
return steam;
|
||||
}
|
||||
@@ -202,16 +206,21 @@ public class MavenTemplateManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static Model getCodeProjectTemplateModel() {
|
||||
return getCodeProjectTemplateModel(null); // by default will be current project.
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to load the project template from bundle, if load failed, use default instead.
|
||||
*/
|
||||
public static Model getCodeProjectTemplateModel() {
|
||||
Model defaultModel = getDefaultCodeProjectTemplateModel();
|
||||
public static Model getCodeProjectTemplateModel(Map<String, Object> parameters) {
|
||||
final String projectTechName = PomUtil.getProjectNameFromTemplateParameter(parameters);
|
||||
Model defaultModel = getDefaultCodeProjectTemplateModel(projectTechName);
|
||||
try {
|
||||
InputStream stream = MavenTemplateManager.getTemplateStream(null,
|
||||
IProjectSettingPreferenceConstants.TEMPLATE_PROJECT_POM, DesignerMavenPlugin.PLUGIN_ID,
|
||||
IProjectSettingTemplateConstants.PATH_GENERAL + '/'
|
||||
+ IProjectSettingTemplateConstants.PROJECT_TEMPLATE_FILE_NAME);
|
||||
+ IProjectSettingTemplateConstants.PROJECT_TEMPLATE_FILE_NAME, parameters);
|
||||
if (stream != null) {
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(stream);
|
||||
|
||||
@@ -220,9 +229,7 @@ public class MavenTemplateManager {
|
||||
variablesValuesMap.put(ETalendMavenVariables.ProjectArtifactId, defaultModel.getArtifactId());
|
||||
variablesValuesMap.put(ETalendMavenVariables.ProjectVersion, defaultModel.getVersion());
|
||||
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
variablesValuesMap.put(ETalendMavenVariables.ProjectName,
|
||||
currentProject != null ? currentProject.getTechnicalLabel() : null);
|
||||
variablesValuesMap.put(ETalendMavenVariables.ProjectName, projectTechName);
|
||||
|
||||
model.setGroupId(ETalendMavenVariables.replaceVariables(model.getGroupId(), variablesValuesMap));
|
||||
model.setArtifactId(ETalendMavenVariables.replaceVariables(model.getArtifactId(), variablesValuesMap));
|
||||
@@ -237,7 +244,7 @@ public class MavenTemplateManager {
|
||||
return defaultModel; // if error, try to use default model
|
||||
}
|
||||
|
||||
private static Model getDefaultCodeProjectTemplateModel() {
|
||||
private static Model getDefaultCodeProjectTemplateModel(String projectTechName) {
|
||||
Model templateCodeProjectMOdel = new Model();
|
||||
|
||||
templateCodeProjectMOdel.setGroupId(PomIdsHelper.getProjectGroupId());
|
||||
@@ -248,22 +255,25 @@ public class MavenTemplateManager {
|
||||
return templateCodeProjectMOdel;
|
||||
}
|
||||
|
||||
public static Model getRoutinesTempalteModel() {
|
||||
Model defaultModel = createDefaultCodesTempalteModel(PomIdsHelper.getCodesGroupId(TalendMavenConstants.DEFAULT_CODE),
|
||||
public static Model getRoutinesTempalteModel(String projectTechName) {
|
||||
Model defaultModel = createDefaultCodesTempalteModel(
|
||||
PomIdsHelper.getCodesGroupId(projectTechName, TalendMavenConstants.DEFAULT_CODE),
|
||||
TalendMavenConstants.DEFAULT_ROUTINES_ARTIFACT_ID);
|
||||
return getCodesModelFromGeneralTemplate(defaultModel, "Routines", JavaUtils.JAVA_ROUTINES_DIRECTORY); //$NON-NLS-1$
|
||||
return getCodesModelFromGeneralTemplate(defaultModel, projectTechName, "Routines", JavaUtils.JAVA_ROUTINES_DIRECTORY); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static Model getBeansTempalteModel() {
|
||||
Model defaultModel = createDefaultCodesTempalteModel(PomIdsHelper.getCodesGroupId(TalendMavenConstants.DEFAULT_BEAN),
|
||||
public static Model getBeansTempalteModel(String projectTechName) {
|
||||
Model defaultModel = createDefaultCodesTempalteModel(
|
||||
PomIdsHelper.getCodesGroupId(projectTechName, TalendMavenConstants.DEFAULT_BEAN),
|
||||
TalendMavenConstants.DEFAULT_BEANS_ARTIFACT_ID);
|
||||
return getCodesModelFromGeneralTemplate(defaultModel, "Beans", JavaUtils.JAVA_BEANS_DIRECTORY); //$NON-NLS-1$
|
||||
return getCodesModelFromGeneralTemplate(defaultModel, projectTechName, "Beans", JavaUtils.JAVA_BEANS_DIRECTORY); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static Model getPigUDFsTempalteModel() {
|
||||
Model defaultModel = createDefaultCodesTempalteModel(PomIdsHelper.getCodesGroupId(TalendMavenConstants.DEFAULT_PIGUDF),
|
||||
public static Model getPigUDFsTempalteModel(String projectTechName) {
|
||||
Model defaultModel = createDefaultCodesTempalteModel(
|
||||
PomIdsHelper.getCodesGroupId(projectTechName, TalendMavenConstants.DEFAULT_PIGUDF),
|
||||
TalendMavenConstants.DEFAULT_PIGUDFS_ARTIFACT_ID);
|
||||
return getCodesModelFromGeneralTemplate(defaultModel, "PigUDFs", JavaUtils.JAVA_PIGUDF_DIRECTORY); //$NON-NLS-1$
|
||||
return getCodesModelFromGeneralTemplate(defaultModel, projectTechName, "PigUDFs", JavaUtils.JAVA_PIGUDF_DIRECTORY); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private static Model createDefaultCodesTempalteModel(String groupId, String artifactId) {
|
||||
@@ -279,8 +289,12 @@ public class MavenTemplateManager {
|
||||
/**
|
||||
* Try to load the project template from bundle, if load failed, use default instead.
|
||||
*/
|
||||
private static Model getCodesModelFromGeneralTemplate(Model defaultModel, String codesName, String codesPackage) {
|
||||
private static Model getCodesModelFromGeneralTemplate(Model defaultModel, String projectTechName, String codesName,
|
||||
String codesPackage) {
|
||||
try {
|
||||
if (projectTechName == null) {
|
||||
projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
}
|
||||
InputStream stream = MavenTemplateManager.getBundleTemplateStream(DesignerMavenPlugin.PLUGIN_ID,
|
||||
IProjectSettingTemplateConstants.PATH_GENERAL + '/'
|
||||
+ IProjectSettingTemplateConstants.POM_CODES_TEMPLATE_FILE_NAME);
|
||||
@@ -295,8 +309,7 @@ public class MavenTemplateManager {
|
||||
variablesValuesMap.put(ETalendMavenVariables.CodesPackage, codesPackage);
|
||||
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
variablesValuesMap.put(ETalendMavenVariables.ProjectName,
|
||||
currentProject != null ? currentProject.getTechnicalLabel() : null);
|
||||
variablesValuesMap.put(ETalendMavenVariables.ProjectName, projectTechName);
|
||||
|
||||
model.setGroupId(ETalendMavenVariables.replaceVariables(model.getGroupId(), variablesValuesMap));
|
||||
model.setArtifactId(ETalendMavenVariables.replaceVariables(model.getArtifactId(), variablesValuesMap));
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
@@ -32,20 +33,23 @@ import org.eclipse.m2e.core.embedder.MavenModelManager;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.general.ILibrariesService;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.process.ProcessUtils;
|
||||
import org.talend.core.runtime.process.ITalendProcessJavaProject;
|
||||
import org.talend.core.runtime.process.TalendProcessArgumentConstant;
|
||||
import org.talend.core.runtime.projectsetting.IProjectSettingPreferenceConstants;
|
||||
import org.talend.core.runtime.projectsetting.IProjectSettingTemplateConstants;
|
||||
import org.talend.core.runtime.projectsetting.ProjectPreferenceManager;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
import org.talend.designer.maven.tools.creator.CreateMavenBeanPom;
|
||||
import org.talend.designer.maven.tools.creator.CreateMavenBundleTemplatePom;
|
||||
import org.talend.designer.maven.tools.creator.CreateMavenPigUDFPom;
|
||||
import org.talend.designer.maven.tools.creator.CreateMavenRoutinePom;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.designer.runprocess.IProcessor;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.RepositoryConstants;
|
||||
import org.talend.utils.io.FilesUtils;
|
||||
|
||||
/**
|
||||
@@ -56,49 +60,63 @@ public class MavenPomSynchronizer {
|
||||
|
||||
private final ITalendProcessJavaProject codeProject;
|
||||
|
||||
private final IProcessor processor;
|
||||
|
||||
private Map<String, Object> argumentsMap = new HashMap<String, Object>();
|
||||
|
||||
public MavenPomSynchronizer(IProcessor processor) {
|
||||
super();
|
||||
this.processor = processor;
|
||||
this.codeProject = this.processor.getTalendJavaProject();
|
||||
}
|
||||
|
||||
public MavenPomSynchronizer(ITalendProcessJavaProject codeProject) {
|
||||
super();
|
||||
this.processor = null;
|
||||
this.codeProject = codeProject;
|
||||
}
|
||||
|
||||
/**
|
||||
* generate routine pom.
|
||||
*/
|
||||
public void syncRoutinesPom(boolean overwrite) throws Exception {
|
||||
public void syncRoutinesPom(IProcessor processor,boolean overwrite) throws Exception {
|
||||
// pom_routines.xml
|
||||
IFile routinesPomFile = codeProject.getProject()
|
||||
.getFile(PomUtil.getPomFileName(TalendMavenConstants.DEFAULT_ROUTINES_ARTIFACT_ID));
|
||||
IFile routinesPomFile = codeProject.getProject().getFile(
|
||||
PomUtil.getPomFileName(TalendMavenConstants.DEFAULT_ROUTINES_ARTIFACT_ID));
|
||||
// generate new one
|
||||
CreateMavenBundleTemplatePom createTemplatePom = new CreateMavenRoutinePom(routinesPomFile);
|
||||
CreateMavenRoutinePom createTemplatePom = new CreateMavenRoutinePom(routinesPomFile);
|
||||
createTemplatePom.setProcessor(processor);
|
||||
createTemplatePom.setArgumentsMap(getArgumentsMap());
|
||||
createTemplatePom.setOverwrite(overwrite);
|
||||
createTemplatePom.create(null);
|
||||
}
|
||||
|
||||
public void syncBeansPom(boolean overwrite) throws Exception {
|
||||
public void syncBeansPom(IProcessor processor,boolean overwrite) throws Exception {
|
||||
// pom_beans.xml
|
||||
IFile beansPomFile = codeProject.getProject()
|
||||
.getFile(PomUtil.getPomFileName(TalendMavenConstants.DEFAULT_BEANS_ARTIFACT_ID));
|
||||
IFile beansPomFile = codeProject.getProject().getFile(
|
||||
PomUtil.getPomFileName(TalendMavenConstants.DEFAULT_BEANS_ARTIFACT_ID));
|
||||
// generate new one
|
||||
CreateMavenBeanPom createTemplatePom = new CreateMavenBeanPom(beansPomFile);
|
||||
createTemplatePom.setProcessor(processor);
|
||||
createTemplatePom.setArgumentsMap(getArgumentsMap());
|
||||
createTemplatePom.setOverwrite(overwrite);
|
||||
createTemplatePom.create(null);
|
||||
}
|
||||
|
||||
public void syncPigUDFsPom(boolean overwrite) throws Exception {
|
||||
public void syncPigUDFsPom(IProcessor processor,boolean overwrite) throws Exception {
|
||||
// pom_pigudfs.xml
|
||||
IFile beansPomFile = codeProject.getProject()
|
||||
.getFile(PomUtil.getPomFileName(TalendMavenConstants.DEFAULT_PIGUDFS_ARTIFACT_ID));
|
||||
IFile beansPomFile = codeProject.getProject().getFile(
|
||||
PomUtil.getPomFileName(TalendMavenConstants.DEFAULT_PIGUDFS_ARTIFACT_ID));
|
||||
// generate new one
|
||||
CreateMavenPigUDFPom createTemplatePom = new CreateMavenPigUDFPom(beansPomFile);
|
||||
createTemplatePom.setProcessor(processor);
|
||||
createTemplatePom.setArgumentsMap(getArgumentsMap());
|
||||
createTemplatePom.setOverwrite(overwrite);
|
||||
createTemplatePom.create(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* sync the bat/sh/jobInfo to resources template folder.
|
||||
@@ -110,10 +128,28 @@ public class MavenPomSynchronizer {
|
||||
IFile batFile = templateFolder.getFile(IProjectSettingTemplateConstants.JOB_RUN_BAT_TEMPLATE_FILE_NAME);
|
||||
IFile infoFile = templateFolder.getFile(IProjectSettingTemplateConstants.JOB_INFO_TEMPLATE_FILE_NAME);
|
||||
|
||||
String shContent = MavenTemplateManager.getProjectSettingValue(IProjectSettingPreferenceConstants.TEMPLATE_SH);
|
||||
String batContent = MavenTemplateManager.getProjectSettingValue(IProjectSettingPreferenceConstants.TEMPLATE_BAT);
|
||||
String jobInfoContent = MavenTemplateManager.getProjectSettingValue(IProjectSettingPreferenceConstants.TEMPLATE_JOB_INFO);
|
||||
|
||||
final Map<String, Object> templateParameters = PomUtil.getTemplateParameters(processor);
|
||||
String shContent = MavenTemplateManager.getProjectSettingValue(IProjectSettingPreferenceConstants.TEMPLATE_SH,
|
||||
templateParameters);
|
||||
String batContent = MavenTemplateManager.getProjectSettingValue(IProjectSettingPreferenceConstants.TEMPLATE_BAT,
|
||||
templateParameters);
|
||||
String jobInfoContent = MavenTemplateManager.getProjectSettingValue(IProjectSettingPreferenceConstants.TEMPLATE_JOB_INFO,
|
||||
templateParameters);
|
||||
String projectTechName = ProjectManager.getInstance().getProject(processor.getProperty()).getTechnicalLabel();
|
||||
Project project = ProjectManager.getInstance()
|
||||
.getProjectFromProjectTechLabel(projectTechName);
|
||||
if (project == null) {
|
||||
project = ProjectManager.getInstance().getCurrentProject();
|
||||
}
|
||||
String mainProjectBranch = ProjectManager.getInstance().getMainProjectBranch(project);
|
||||
if (mainProjectBranch == null) {
|
||||
ProjectPreferenceManager preferenceManager = new ProjectPreferenceManager(project, "org.talend.repository");
|
||||
mainProjectBranch = preferenceManager.getValue(RepositoryConstants.PROJECT_BRANCH_ID);
|
||||
if (mainProjectBranch == null) {
|
||||
mainProjectBranch = "";
|
||||
}
|
||||
}
|
||||
jobInfoContent = StringUtils.replace(jobInfoContent, "${talend.project.branch}", mainProjectBranch);
|
||||
MavenTemplateManager.saveContent(shFile, shContent, overwrite);
|
||||
MavenTemplateManager.saveContent(batFile, batContent, overwrite);
|
||||
MavenTemplateManager.saveContent(infoFile, jobInfoContent, overwrite);
|
||||
@@ -200,7 +236,7 @@ public class MavenPomSynchronizer {
|
||||
fullCleanupContainer(codeProject.getTestsFolder());
|
||||
|
||||
// when clean, regenerate it.
|
||||
updateCodesPomWithProject(monitor, null);
|
||||
updateCodesPomWithProject(monitor);
|
||||
|
||||
// try to compile it.
|
||||
final Map<String, Object> argumentsMap = new HashMap<String, Object>();
|
||||
@@ -209,15 +245,15 @@ public class MavenPomSynchronizer {
|
||||
|
||||
//
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
|
||||
ILibrariesService libService = (ILibrariesService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibrariesService.class);
|
||||
ILibrariesService libService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibrariesService.class);
|
||||
libService.addChangeLibrariesListener(new ILibrariesService.IChangedLibrariesListener() {
|
||||
|
||||
@Override
|
||||
public void afterChangingLibraries() {
|
||||
try {
|
||||
// update the dependencies
|
||||
updateCodesPomWithProject(null, null);
|
||||
updateCodesPomWithProject(null);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
@@ -252,21 +288,27 @@ public class MavenPomSynchronizer {
|
||||
}
|
||||
}
|
||||
|
||||
public void syncCodesPoms(IProgressMonitor monitor, IProcess process, boolean overwrite) throws Exception {
|
||||
syncRoutinesPom(overwrite);
|
||||
public void syncCodesPoms(IProgressMonitor monitor, IProcessor processor, boolean overwrite) throws Exception {
|
||||
final IProcess process =processor!=null? processor.getProcess():null;
|
||||
|
||||
syncRoutinesPom(processor,overwrite);
|
||||
// PigUDFs
|
||||
if (ProcessUtils.isRequiredPigUDFs(process)) {
|
||||
syncPigUDFsPom(overwrite);
|
||||
syncPigUDFsPom(processor,overwrite);
|
||||
}
|
||||
// Beans
|
||||
if (ProcessUtils.isRequiredBeans(process)) {
|
||||
syncBeansPom(overwrite);
|
||||
syncBeansPom(processor,overwrite);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCodesPomWithProject(IProgressMonitor monitor, IProcessor processor) throws Exception {
|
||||
syncCodesPoms(monitor, processor != null ? processor.getProcess() : null, true);
|
||||
private void updateCodesPomWithProject(IProgressMonitor monitor) throws Exception {
|
||||
syncCodesPoms(monitor,null, true);
|
||||
// finally, update project
|
||||
regenerateMainProjectPom(monitor, processor);
|
||||
}
|
||||
|
||||
public void regenerateMainProjectPom(IProgressMonitor monitor, IProcessor processor) throws Exception {
|
||||
ProjectPomManager projectManager = new ProjectPomManager(codeProject.getProject());
|
||||
projectManager.update(monitor, processor);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Parent;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
@@ -36,6 +35,7 @@ import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
import org.talend.designer.maven.utils.PomIdsHelper;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.designer.runprocess.IProcessor;
|
||||
import org.talend.repository.ProjectManager;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
@@ -52,7 +52,7 @@ public class ProjectPomManager {
|
||||
private boolean updateModules = true;
|
||||
|
||||
private boolean updateDependencies = true;
|
||||
|
||||
|
||||
private Map<String, Object> argumentsMap = new HashMap<String, Object>();
|
||||
|
||||
public ProjectPomManager(IProject project) {
|
||||
@@ -121,8 +121,9 @@ public class ProjectPomManager {
|
||||
*
|
||||
*/
|
||||
protected void updateAttributes(IProgressMonitor monitor, IProcessor processor, Model projectModel) throws Exception {
|
||||
Model templateModel = MavenTemplateManager.getCodeProjectTemplateModel();
|
||||
|
||||
final Map<String, Object> templateParameters = PomUtil.getTemplateParameters(processor);
|
||||
Model templateModel = MavenTemplateManager.getCodeProjectTemplateModel(templateParameters);
|
||||
|
||||
String deployVersion = (String) argumentsMap.get(TalendProcessArgumentConstant.ARG_DEPLOY_VERSION);
|
||||
if (deployVersion != null) {
|
||||
templateModel.setVersion(deployVersion);
|
||||
@@ -189,7 +190,8 @@ public class ProjectPomManager {
|
||||
continue; // not same
|
||||
}
|
||||
|
||||
PomUtil.checkParent(model, file, (String) argumentsMap.get(TalendProcessArgumentConstant.ARG_DEPLOY_VERSION));
|
||||
PomUtil.checkParent(model, file, processor,
|
||||
(String) argumentsMap.get(TalendProcessArgumentConstant.ARG_DEPLOY_VERSION));
|
||||
PomUtil.savePom(monitor, model, file);
|
||||
}
|
||||
}
|
||||
@@ -229,7 +231,9 @@ public class ProjectPomManager {
|
||||
processorDependenciesManager.updateDependencies(monitor, projectModel);
|
||||
} else {
|
||||
// if no processor and without base pom, just read codes dependencies.
|
||||
List<Dependency> routinesDependencies = new ArrayList<Dependency>(PomUtil.getCodesDependencies(projectPomFile));
|
||||
final String technicalLabel = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
List<Dependency> routinesDependencies = new ArrayList<Dependency>(PomUtil.getCodesDependencies(projectPomFile,
|
||||
technicalLabel));
|
||||
ProcessorDependenciesManager.updateDependencies(monitor, projectModel, routinesDependencies, true);
|
||||
}
|
||||
}
|
||||
@@ -242,7 +246,6 @@ public class ProjectPomManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void setArgumentsMap(Map<String, Object> argumentsMap) {
|
||||
this.argumentsMap = argumentsMap;
|
||||
}
|
||||
|
||||
@@ -23,16 +23,31 @@ import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
|
||||
import org.talend.core.runtime.projectsetting.IProjectSettingTemplateConstants;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.designer.runprocess.IProcessor;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
*/
|
||||
public abstract class AbstractMavenCodesTemplatePom extends AbstractMavenGeneralTemplatePom {
|
||||
|
||||
private IProcessor processor;
|
||||
|
||||
public AbstractMavenCodesTemplatePom(IFile pomFile) {
|
||||
super(pomFile, IProjectSettingTemplateConstants.POM_CODES_TEMPLATE_FILE_NAME);
|
||||
}
|
||||
|
||||
public IProcessor getProcessor() {
|
||||
return processor;
|
||||
}
|
||||
|
||||
public void setProcessor(IProcessor processor) {
|
||||
this.processor = processor;
|
||||
}
|
||||
|
||||
protected String getProjectName() {
|
||||
return PomUtil.getProjectNameFromTemplateParameter(PomUtil.getTemplateParameters(processor));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Model createModel() {
|
||||
final Model templateModel = getTemplateModel();
|
||||
@@ -45,7 +60,7 @@ public abstract class AbstractMavenCodesTemplatePom extends AbstractMavenGeneral
|
||||
setAttributes(templateModel);
|
||||
addProperties(templateModel);
|
||||
|
||||
PomUtil.checkParent(templateModel, this.getPomFile(), getDeployVersion());
|
||||
PomUtil.checkParent(templateModel, this.getPomFile(), this.processor, getDeployVersion());
|
||||
|
||||
addDependencies(templateModel);
|
||||
|
||||
|
||||
@@ -20,7 +20,11 @@ import java.util.Set;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.process.JobInfo;
|
||||
@@ -29,7 +33,6 @@ import org.talend.core.model.properties.Project;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.utils.JavaResourcesHelper;
|
||||
import org.talend.core.runtime.process.LastGenerationInfo;
|
||||
import org.talend.core.runtime.projectsetting.IProjectSettingTemplateConstants;
|
||||
import org.talend.designer.maven.template.ETalendMavenVariables;
|
||||
import org.talend.designer.maven.tools.ProcessorDependenciesManager;
|
||||
@@ -108,7 +111,7 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
|
||||
protected Model createModel() {
|
||||
Model model = super.createModel();
|
||||
if (model != null) {
|
||||
PomUtil.checkParent(model, this.getPomFile(), getDeployVersion());
|
||||
PomUtil.checkParent(model, this.getPomFile(), jobProcessor, getDeployVersion());
|
||||
|
||||
addDependencies(model);
|
||||
}
|
||||
@@ -118,23 +121,45 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
|
||||
protected void addDependencies(Model model) {
|
||||
try {
|
||||
getProcessorDependenciesManager().updateDependencies(null, model);
|
||||
|
||||
|
||||
// add children jobs in dependencies
|
||||
final List<Dependency> dependencies = model.getDependencies();
|
||||
String parentId = getJobProcessor().getProperty().getId();
|
||||
final Set<JobInfo> clonedChildrenJobInfors = getJobProcessor().getBuildChildrenJobs();
|
||||
final Set<JobInfo> clonedChildrenJobInfors = getJobProcessor().getBuildChildrenJobs();
|
||||
for (JobInfo jobInfo : clonedChildrenJobInfors) {
|
||||
if (jobInfo.getFatherJobInfo() != null && jobInfo.getFatherJobInfo().getJobId().equals(parentId)) {
|
||||
if (!validChildrenJob(jobInfo)) {
|
||||
continue;
|
||||
}
|
||||
String groupId = model.getGroupId();
|
||||
String artifactId = PomIdsHelper.getJobArtifactId(jobInfo);
|
||||
String version = PomIdsHelper.getJobVersion(jobInfo);
|
||||
if (getDeployVersion() != null) {
|
||||
version = getDeployVersion();
|
||||
}
|
||||
// same group as main job.
|
||||
Dependency d = PomUtil.createDependency(model.getGroupId(), PomIdsHelper.getJobArtifactId(jobInfo),
|
||||
version, null);
|
||||
// try to get the pom version of children job and load from the pom file.
|
||||
String childPomFileName = PomUtil.getPomFileName(jobInfo.getJobName(), jobInfo.getJobVersion());
|
||||
IProject codeProject = getJobProcessor().getCodeProject();
|
||||
try {
|
||||
codeProject.refreshLocal(IResource.DEPTH_ONE, null); // is it ok or needed here ???
|
||||
} catch (CoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
IFile childPomFile = codeProject.getFile(new Path(childPomFileName));
|
||||
if (childPomFile.exists()) {
|
||||
try {
|
||||
Model childModel = MODEL_MANAGER.readMavenModel(childPomFile);
|
||||
// try to get the real groupId, artifactId, version.
|
||||
groupId = childModel.getGroupId();
|
||||
artifactId = childModel.getArtifactId();
|
||||
version = childModel.getVersion();
|
||||
} catch (CoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
Dependency d = PomUtil.createDependency(groupId, artifactId, version, null);
|
||||
dependencies.add(d);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class CreateMavenBeanPom extends AbstractMavenCodesTemplatePom {
|
||||
|
||||
@Override
|
||||
protected Model getTemplateModel() {
|
||||
Model model = MavenTemplateManager.getBeansTempalteModel();
|
||||
Model model = MavenTemplateManager.getBeansTempalteModel(getProjectName());
|
||||
if (getDeployVersion() != null) {
|
||||
model.setVersion(getDeployVersion());
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ package org.talend.designer.maven.tools.creator;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
@@ -44,7 +43,6 @@ import org.apache.maven.model.Profile;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
@@ -61,7 +59,6 @@ import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.Project;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.repository.SVNConstant;
|
||||
import org.talend.core.model.utils.JavaResourcesHelper;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.process.JobInfoProperties;
|
||||
@@ -161,6 +158,7 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
this.itemRelativePath = itemRelativePath;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -174,8 +172,10 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
templateFile = null; // force to set null, in order to use the template from other places.
|
||||
}
|
||||
try {
|
||||
final Map<String, Object> templateParameters = PomUtil.getTemplateParameters(getJobProcessor());
|
||||
return MavenTemplateManager.getTemplateStream(templateFile,
|
||||
IProjectSettingPreferenceConstants.TEMPLATE_STANDALONE_JOB_POM, JOB_TEMPLATE_BUNDLE, getBundleTemplatePath());
|
||||
IProjectSettingPreferenceConstants.TEMPLATE_STANDALONE_JOB_POM, JOB_TEMPLATE_BUNDLE, getBundleTemplatePath(),
|
||||
templateParameters);
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
@@ -215,10 +215,6 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
if (project == null) { // current project
|
||||
project = ProjectManager.getInstance().getCurrentProject().getEmfProject();
|
||||
}
|
||||
String mainProjectBranch = ProjectManager.getInstance().getMainProjectBranch(project);
|
||||
if (mainProjectBranch == null) {
|
||||
mainProjectBranch = SVNConstant.NAME_TRUNK;
|
||||
}
|
||||
|
||||
checkPomProperty(properties, "talend.job.path", ETalendMavenVariables.JobPath, jobClassPackageFolder);
|
||||
checkPomProperty(properties, "talend.job.package", ETalendMavenVariables.JobPackage, jobClassPackage);
|
||||
@@ -243,8 +239,6 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
jobInfoProp.getProperty(JobInfoProperties.PROJECT_NAME, project.getTechnicalLabel()).toLowerCase());
|
||||
checkPomProperty(properties, "talend.project.id", ETalendMavenVariables.ProjectId,
|
||||
jobInfoProp.getProperty(JobInfoProperties.PROJECT_ID, String.valueOf(project.getId())));
|
||||
checkPomProperty(properties, "talend.project.branch", ETalendMavenVariables.ProjectBranch,
|
||||
jobInfoProp.getProperty(JobInfoProperties.BRANCH, mainProjectBranch));
|
||||
|
||||
checkPomProperty(properties, "talend.job.name", ETalendMavenVariables.JobName,
|
||||
jobInfoProp.getProperty(JobInfoProperties.JOB_NAME, property.getLabel()));
|
||||
@@ -478,9 +472,9 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
generateAssemblyFile(monitor);
|
||||
|
||||
// generate routines
|
||||
MavenPomSynchronizer pomSync = new MavenPomSynchronizer(this.getJobProcessor().getTalendJavaProject());
|
||||
MavenPomSynchronizer pomSync = new MavenPomSynchronizer(this.getJobProcessor());
|
||||
pomSync.setArgumentsMap(getArgumentsMap());
|
||||
pomSync.syncCodesPoms(monitor, process, true);
|
||||
pomSync.syncCodesPoms(monitor, getJobProcessor(), true);
|
||||
// because need update the latest content for templates.
|
||||
pomSync.syncTemplates(true);
|
||||
|
||||
@@ -537,11 +531,12 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
if (!FilesUtils.allInSameFolder(templateFile, TalendMavenConstants.POM_FILE_NAME)) {
|
||||
templateFile = null; // force to set null, in order to use the template from other places.
|
||||
}
|
||||
|
||||
|
||||
final Map<String, Object> templateParameters = PomUtil.getTemplateParameters(getJobProcessor());
|
||||
String content = MavenTemplateManager.getTemplateContent(templateFile,
|
||||
IProjectSettingPreferenceConstants.TEMPLATE_STANDALONE_JOB_ASSEMBLY, JOB_TEMPLATE_BUNDLE,
|
||||
IProjectSettingTemplateConstants.PATH_STANDALONE + '/'
|
||||
+ IProjectSettingTemplateConstants.ASSEMBLY_JOB_TEMPLATE_FILE_NAME);
|
||||
+ IProjectSettingTemplateConstants.ASSEMBLY_JOB_TEMPLATE_FILE_NAME,templateParameters);
|
||||
if (content != null) {
|
||||
ByteArrayInputStream source = new ByteArrayInputStream(content.getBytes());
|
||||
if (assemblyFile.exists()) {
|
||||
@@ -653,8 +648,15 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
TransformerFactory transFactory = TransformerFactory.newInstance();
|
||||
Transformer transFormer = transFactory.newTransformer();
|
||||
transFormer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transFormer.transform(new DOMSource(document), new StreamResult(new FileOutputStream(file)));
|
||||
|
||||
FileOutputStream output = null;
|
||||
try {
|
||||
output = new FileOutputStream(file);
|
||||
transFormer.transform(new DOMSource(document), new StreamResult(output));
|
||||
} finally {
|
||||
if (output != null) {
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
// clean for children poms
|
||||
cleanChildrenPomSettings(monitor, childrenPomsIncludes);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class CreateMavenPigUDFPom extends AbstractMavenCodesTemplatePom {
|
||||
|
||||
@Override
|
||||
protected Model getTemplateModel() {
|
||||
Model model = MavenTemplateManager.getPigUDFsTempalteModel();
|
||||
Model model = MavenTemplateManager.getPigUDFsTempalteModel(getProjectName());
|
||||
if (getDeployVersion() != null) {
|
||||
model.setVersion(getDeployVersion());
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class CreateMavenRoutinePom extends AbstractMavenCodesTemplatePom {
|
||||
|
||||
@Override
|
||||
protected Model getTemplateModel() {
|
||||
Model model = MavenTemplateManager.getRoutinesTempalteModel();
|
||||
Model model = MavenTemplateManager.getRoutinesTempalteModel(getProjectName());
|
||||
if (getDeployVersion() != null) {
|
||||
model.setVersion(getDeployVersion());
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class CreateMavenTestPom extends AbstractMavenProcessorPom {
|
||||
|
||||
protected void afterCreate(IProgressMonitor monitor) throws Exception {
|
||||
// generate routines
|
||||
MavenPomSynchronizer pomSync = new MavenPomSynchronizer(this.getJobProcessor().getTalendJavaProject());
|
||||
pomSync.syncCodesPoms(monitor, this.getJobProcessor().getProcess(), true);
|
||||
MavenPomSynchronizer pomSync = new MavenPomSynchronizer(this.getJobProcessor());
|
||||
pomSync.syncCodesPoms(monitor, this.getJobProcessor(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.process.JobInfo;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.utils.JavaResourcesHelper;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.repository.ProjectManager;
|
||||
|
||||
@@ -40,6 +41,7 @@ public class PomIdsHelper {
|
||||
return JavaResourcesHelper.getGroupName(TalendMavenConstants.DEFAULT_MASTER);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return "code".
|
||||
*
|
||||
@@ -65,9 +67,18 @@ public class PomIdsHelper {
|
||||
*/
|
||||
public static String getCodesGroupId(String baseName) {
|
||||
final Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
if (currentProject != null) {
|
||||
String technicalLabel = currentProject.getTechnicalLabel();
|
||||
return JavaResourcesHelper.getGroupName(baseName + '.' + technicalLabel);
|
||||
return getCodesGroupId(currentProject != null ? currentProject.getTechnicalLabel() : null, baseName);
|
||||
}
|
||||
|
||||
public static String getCodesGroupId(String projectTechName, String baseName) {
|
||||
if (projectTechName == null) { // try current one
|
||||
final Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
if (currentProject != null) {
|
||||
projectTechName = currentProject.getTechnicalLabel();
|
||||
}
|
||||
}
|
||||
if (projectTechName != null && !projectTechName.trim().isEmpty()) {
|
||||
return JavaResourcesHelper.getGroupName(baseName + '.' + projectTechName.trim().toLowerCase());
|
||||
}
|
||||
return JavaResourcesHelper.getGroupName(baseName);
|
||||
}
|
||||
@@ -84,23 +95,22 @@ public class PomIdsHelper {
|
||||
* @return "org.talend.job.<name>", like "org.talend.job.test"
|
||||
*/
|
||||
public static String getJobGroupId(String name) {
|
||||
if (name != null) {
|
||||
return JavaResourcesHelper.getGroupName(TalendMavenConstants.DEFAULT_JOB + '.' + name);
|
||||
if (name != null && !name.trim().isEmpty()) {
|
||||
return JavaResourcesHelper.getGroupName(TalendMavenConstants.DEFAULT_JOB + '.' + name.trim().toLowerCase());
|
||||
}
|
||||
return JavaResourcesHelper.getGroupName(TalendMavenConstants.DEFAULT_JOB);
|
||||
}
|
||||
|
||||
public static String getTestGroupId(String name) {
|
||||
if (name != null) {
|
||||
return JavaResourcesHelper.getGroupName(TalendMavenConstants.DEFAULT_TEST + '.' + name);
|
||||
if (name != null && !name.trim().isEmpty()) {
|
||||
return JavaResourcesHelper.getGroupName(TalendMavenConstants.DEFAULT_TEST + '.' + name.trim().toLowerCase());
|
||||
}
|
||||
return JavaResourcesHelper.getGroupName(TalendMavenConstants.DEFAULT_TEST);
|
||||
}
|
||||
|
||||
public static String getTestGroupId(Property property) {
|
||||
if (property != null) {
|
||||
ProjectManager pManager = ProjectManager.getInstance();
|
||||
Project currentProject = pManager.getCurrentProject();
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
if (currentProject != null) {
|
||||
return getTestGroupId(currentProject.getTechnicalLabel());
|
||||
}
|
||||
@@ -113,8 +123,13 @@ public class PomIdsHelper {
|
||||
*/
|
||||
public static String getJobGroupId(Property property) {
|
||||
if (property != null) {
|
||||
ProjectManager pManager = ProjectManager.getInstance();
|
||||
Project currentProject = pManager.getCurrentProject();
|
||||
if (property.getAdditionalProperties() != null) {
|
||||
String groupId = (String) property.getAdditionalProperties().get(MavenConstants.NAME_GROUP_ID);
|
||||
if (groupId != null) {
|
||||
return groupId;
|
||||
}
|
||||
}
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
if (currentProject != null) {
|
||||
return getJobGroupId(currentProject.getTechnicalLabel());
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.io.IOException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
@@ -175,7 +176,7 @@ public class PomUtil {
|
||||
* @param curModel
|
||||
* @param curPomFile
|
||||
*/
|
||||
public static void checkParent(Model curModel, IFile curPomFile, String specialVersion) {
|
||||
public static void checkParent(Model curModel, IFile curPomFile, IProcessor processor, String specialVersion) {
|
||||
Parent parent = curModel.getParent();
|
||||
if (parent == null) {
|
||||
parent = new Parent();
|
||||
@@ -183,8 +184,8 @@ public class PomUtil {
|
||||
} else {
|
||||
// TODO, if existed, maybe just replace, not overwrite
|
||||
}
|
||||
// always depend on current poject
|
||||
Model codeProjectTemplateModel = MavenTemplateManager.getCodeProjectTemplateModel();
|
||||
final Map<String, Object> templateParameters = PomUtil.getTemplateParameters(processor);
|
||||
Model codeProjectTemplateModel = MavenTemplateManager.getCodeProjectTemplateModel(templateParameters);
|
||||
|
||||
if (specialVersion != null) {
|
||||
codeProjectTemplateModel.setVersion(specialVersion);
|
||||
@@ -533,19 +534,19 @@ public class PomUtil {
|
||||
*
|
||||
* in order to make sure no compile error for editor, so add all needed dependencies always.
|
||||
*/
|
||||
public static Collection<Dependency> getCodesDependencies(IFile projectPomFile) throws CoreException {
|
||||
public static Collection<Dependency> getCodesDependencies(IFile projectPomFile, String projectTechName) throws CoreException {
|
||||
Map<String, Dependency> codesDependencies = new LinkedHashMap<String, Dependency>();
|
||||
|
||||
// routines
|
||||
addCodeDependencies(codesDependencies, projectPomFile, TalendMavenConstants.DEFAULT_ROUTINES_ARTIFACT_ID,
|
||||
MavenTemplateManager.getRoutinesTempalteModel());
|
||||
MavenTemplateManager.getRoutinesTempalteModel(projectTechName));
|
||||
|
||||
// beans
|
||||
addCodeDependencies(codesDependencies, projectPomFile, TalendMavenConstants.DEFAULT_BEANS_ARTIFACT_ID,
|
||||
MavenTemplateManager.getBeansTempalteModel());
|
||||
MavenTemplateManager.getBeansTempalteModel(projectTechName));
|
||||
// pigudfs
|
||||
addCodeDependencies(codesDependencies, projectPomFile, TalendMavenConstants.DEFAULT_PIGUDFS_ARTIFACT_ID,
|
||||
MavenTemplateManager.getPigUDFsTempalteModel());
|
||||
MavenTemplateManager.getPigUDFsTempalteModel(projectTechName));
|
||||
|
||||
return codesDependencies.values();
|
||||
}
|
||||
@@ -604,4 +605,37 @@ public class PomUtil {
|
||||
}
|
||||
return codesJars;
|
||||
}
|
||||
|
||||
public static Map<String, Object> getTemplateParameters(IProcessor processor) {
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
if (processor != null) {
|
||||
final Property property = processor.getProperty();
|
||||
return getTemplateParameters(property);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public static Map<String, Object> getTemplateParameters(Property property) {
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
if (property != null && property.eResource() != null) {
|
||||
final org.talend.core.model.properties.Project project = ProjectManager.getInstance().getProject(property);
|
||||
if (project != null // from reference projects
|
||||
&& !ProjectManager.getInstance().getCurrentProject().getTechnicalLabel().equals(project.getTechnicalLabel())) {
|
||||
parameters.put(MavenTemplateManager.KEY_PROJECT_NAME, project.getTechnicalLabel());
|
||||
}
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public static String getProjectNameFromTemplateParameter(Map<String, Object> parameters) {
|
||||
// get the default based one project still
|
||||
String projectName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
if (parameters != null && !parameters.isEmpty()) {
|
||||
final Object pName = parameters.get(MavenTemplateManager.KEY_PROJECT_NAME);
|
||||
if (pName != null && !pName.toString().isEmpty()) {
|
||||
projectName = pName.toString();
|
||||
}
|
||||
}
|
||||
return projectName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,14 @@
|
||||
package org.talend.librariesmanager.ui.actions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.swt.SWT;
|
||||
@@ -32,14 +33,14 @@ import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.runtime.image.ECoreImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.commons.utils.io.FilesUtils;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
|
||||
import org.talend.core.model.general.ModuleToInstall;
|
||||
import org.talend.core.runtime.process.ITalendProcessJavaProject;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.librariesmanager.model.ModulesNeededProvider;
|
||||
import org.talend.librariesmanager.ui.LibManagerUiPlugin;
|
||||
import org.talend.librariesmanager.ui.i18n.Messages;
|
||||
import org.talend.repository.ProjectManager;
|
||||
|
||||
/**
|
||||
* Imports the external jar files into talend.
|
||||
@@ -66,7 +67,6 @@ public class ImportExternalJarAction extends Action {
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
handleImportJarDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
|
||||
}
|
||||
|
||||
@@ -80,44 +80,51 @@ public class ImportExternalJarAction extends Action {
|
||||
return handleImportJarDialog(shell, null);
|
||||
}
|
||||
|
||||
public String[] handleImportJarDialog(Shell shell, String moduleName) {
|
||||
public String[] handleImportJarDialog(Shell shell, ModuleToInstall module) {
|
||||
FileDialog fileDialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
|
||||
fileDialog.setFilterExtensions(FilesUtils.getAcceptJARFilesSuffix());
|
||||
fileDialog.open();
|
||||
final String path = fileDialog.getFilterPath();
|
||||
final String[] fileNames = fileDialog.getFileNames();
|
||||
|
||||
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (int i = 0; i < fileNames.length; i++) {
|
||||
String fileName = fileNames[i];
|
||||
File file = new File(path + File.separatorChar + fileName);
|
||||
File tempFile = null;
|
||||
try {
|
||||
if (moduleName != null && fileNames.length == 1 && !file.isDirectory()
|
||||
&& !file.getName().equals(moduleName)) {
|
||||
Project project = ProjectManager.getInstance().getCurrentProject();
|
||||
IProject fsProject = ResourceUtils.getProject(project);
|
||||
IFolder tmpFolder = fsProject.getFolder("temp");
|
||||
if (!tmpFolder.exists()) {
|
||||
tmpFolder.create(true, true, null);
|
||||
List<String> modulesNeededNames = ModulesNeededProvider.getModulesNeededNames();
|
||||
if (fileNames.length > 0) {
|
||||
if (fileNames.length > 1) {
|
||||
for (int i = 0; i < fileNames.length; i++) {
|
||||
String fileName = fileNames[i];
|
||||
File file = new File(path + File.separatorChar + fileName);
|
||||
try {
|
||||
String mvnUri = null;
|
||||
if (module != null && module.getName().equals(fileName)) {
|
||||
mvnUri = module.getMavenUri();
|
||||
}
|
||||
installFile(modulesNeededNames, file, file.getName(), mvnUri);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
continue;
|
||||
}
|
||||
tempFile = new File(tmpFolder.getLocation().toPortableString(), moduleName);
|
||||
FilesUtils.copyFile(file, tempFile);
|
||||
file = tempFile;
|
||||
fileNames[i] = file.getName();
|
||||
}
|
||||
LibManagerUiPlugin.getDefault().getLibrariesService().deployLibrary(file.toURL());
|
||||
if (tempFile != null) {
|
||||
FilesUtils.deleteFile(tempFile, true);
|
||||
} else {
|
||||
File file = new File(path + File.separatorChar + fileNames[0]);
|
||||
String mvnUri = null;
|
||||
String moduleName = file.getName();
|
||||
if (module != null) {
|
||||
mvnUri = module.getMavenUri();
|
||||
// in case selected file name is not the same as module name
|
||||
moduleName = module.getName();
|
||||
fileNames[0] = moduleName;
|
||||
}
|
||||
try {
|
||||
installFile(modulesNeededNames, file, moduleName, mvnUri);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
LibManagerUiPlugin.getDefault().getLibrariesService().checkLibraries();
|
||||
// only clean the existed one
|
||||
cleanupLib(new HashSet<String>(Arrays.asList(fileNames)));
|
||||
}
|
||||
@@ -125,15 +132,13 @@ public class ImportExternalJarAction extends Action {
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
// private void emptyLibs() {
|
||||
// if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
|
||||
// ILibrariesService libService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(
|
||||
// ILibrariesService.class);
|
||||
// if (libService != null) {
|
||||
// libService.cleanLibs();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
private void installFile(List<String> modulesNeededNames, File file, String moduleName, String mvnURI)
|
||||
throws MalformedURLException, IOException {
|
||||
LibManagerUiPlugin.getDefault().getLibrariesService().deployLibrary(file.toURL(), mvnURI, false);
|
||||
if (!modulesNeededNames.contains(moduleName)) {
|
||||
ModulesNeededProvider.userAddUnusedModules(ELibraryInstallStatus.UNKNOWN.name(), moduleName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void cleanupLib(Set<String> installedModule) {
|
||||
for (String jarName : installedModule) {
|
||||
|
||||
@@ -892,7 +892,7 @@ public class ExternalModulesInstallDialog extends TitleAreaDialog implements IMo
|
||||
public void showImportJarDialog(AtomicInteger enabledButtonCount, TableItem item) {
|
||||
if (item.getData() instanceof ModuleToInstall) {
|
||||
ModuleToInstall module = (ModuleToInstall) item.getData();
|
||||
String[] importedJars = new ImportExternalJarAction().handleImportJarDialog(getShell(), module.getName());
|
||||
String[] importedJars = new ImportExternalJarAction().handleImportJarDialog(getShell(), module);
|
||||
updateManualImportedJars(enabledButtonCount, importedJars);
|
||||
if (importedJars.length > 1) {
|
||||
String message = "";
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package routines.system;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public final class BundleUtils {
|
||||
|
||||
private static final Class<?> BUNDLE_CONTEXT_CLASS;
|
||||
private static final Class<?> SERVICE_REFERENCE_CLASS;
|
||||
private static final Object BUNDLE;
|
||||
|
||||
static {
|
||||
Class<?> bundleCtxClass;
|
||||
Class<?> svcRefClass;
|
||||
Object bundle;
|
||||
try {
|
||||
ClassLoader ld = BundleUtils.class.getClassLoader();
|
||||
Class<?> util = ld.loadClass("org.osgi.framework.FrameworkUtil");
|
||||
bundleCtxClass = ld.loadClass("org.osgi.framework.BundleContext");
|
||||
svcRefClass = ld.loadClass("org.osgi.framework.ServiceReference");
|
||||
Method getBundle = util.getMethod("getBundle", Class.class);
|
||||
bundle = getBundle.invoke(null, BundleUtils.class);
|
||||
} catch (Exception e) {
|
||||
bundleCtxClass = null;
|
||||
svcRefClass = null;
|
||||
bundle = null;
|
||||
}
|
||||
BUNDLE_CONTEXT_CLASS = bundleCtxClass;
|
||||
SERVICE_REFERENCE_CLASS = svcRefClass;
|
||||
BUNDLE = bundle;
|
||||
}
|
||||
|
||||
public static <T> T getService(Class<T> svcClass) {
|
||||
if (BUNDLE == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Method getBundleContext = BUNDLE.getClass().getMethod("getBundleContext");
|
||||
Object context = getBundleContext.invoke(BUNDLE);
|
||||
Class<?> ctxClass = context.getClass();
|
||||
Method getServiceReference = ctxClass.getMethod("getServiceReference", Class.class);
|
||||
Object serviceReference = getServiceReference.invoke(context, svcClass);
|
||||
Method getService = ctxClass.getMethod("getService", SERVICE_REFERENCE_CLASS);
|
||||
return svcClass.cast(getService.invoke(context, serviceReference));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T getService(Class<T> svcClass, Object bundleContext) {
|
||||
if (BUNDLE_CONTEXT_CLASS == null || bundleContext == null) {
|
||||
return null;
|
||||
}
|
||||
if (!BUNDLE_CONTEXT_CLASS.isInstance(bundleContext)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Class<?> ctxClass = bundleContext.getClass();
|
||||
Method getServiceReference = ctxClass.getMethod("getServiceReference", Class.class);
|
||||
Object serviceReference = getServiceReference.invoke(bundleContext, svcClass);
|
||||
Method getService = ctxClass.getMethod("getService", SERVICE_REFERENCE_CLASS);
|
||||
return svcClass.cast(getService.invoke(bundleContext, serviceReference));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean inOSGi() {
|
||||
return BUNDLE != null;
|
||||
}
|
||||
|
||||
public static Class<?> getBundleContextClass() throws ClassNotFoundException {
|
||||
if (BUNDLE_CONTEXT_CLASS == null) {
|
||||
throw new ClassNotFoundException(
|
||||
"Class org.osgi.framework.BundleContext cannot be resolved. ");
|
||||
}
|
||||
return BUNDLE_CONTEXT_CLASS;
|
||||
}
|
||||
|
||||
private BundleUtils() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,11 @@ package routines.system;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class TalendDataSource {
|
||||
|
||||
private final javax.sql.DataSource ds;
|
||||
|
||||
private Set<Connection> conns = new HashSet<>();
|
||||
|
||||
/**
|
||||
* hold a data source inside
|
||||
*
|
||||
@@ -28,8 +24,8 @@ public class TalendDataSource {
|
||||
*/
|
||||
public java.sql.Connection getConnection() throws SQLException {
|
||||
Connection conn = ds.getConnection();
|
||||
if (conn != null) {
|
||||
conns.add(conn);
|
||||
if (conn == null) {
|
||||
throw new RuntimeException("Unable to get a pooled database connection from pool");
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
@@ -42,18 +38,19 @@ public class TalendDataSource {
|
||||
public javax.sql.DataSource getRawDataSource() {
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Deprecated
|
||||
*
|
||||
* This method will be removed in future release
|
||||
*
|
||||
* close all the connections which is created by the data source inside
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
|
||||
public void close() throws SQLException {
|
||||
for (Connection conn : conns) {
|
||||
if (!conn.isClosed()) {// the connection can be closed outside
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
conns.clear();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,6 +92,10 @@ public class ArtifactsDeployer {
|
||||
// change to snapshot version to deploy
|
||||
|
||||
if (parseMvnUrl != null) {
|
||||
File libFile = new File(path);
|
||||
if (!libFile.exists()) {
|
||||
return;
|
||||
}
|
||||
// install to local maven repository and create pom
|
||||
// repositoryManager.install(new File(path), parseMvnUrl);
|
||||
String artifactType = parseMvnUrl.getType();
|
||||
@@ -100,7 +104,7 @@ public class ArtifactsDeployer {
|
||||
}
|
||||
MavenResolver mvnResolver = TalendLibsServerManager.getInstance().getMavenResolver();
|
||||
mvnResolver.upload(parseMvnUrl.getGroupId(), parseMvnUrl.getArtifactId(), parseMvnUrl.getClassifier(), artifactType,
|
||||
parseMvnUrl.getVersion(), new File(path));
|
||||
parseMvnUrl.getVersion(), libFile);
|
||||
ModuleStatusProvider.getDeployStatusMap().put(mavenUri, ELibraryInstallStatus.DEPLOYED);
|
||||
String pomType = TalendMavenConstants.PACKAGING_POM;
|
||||
String generatePom = PomUtil.generatePom2(parseMvnUrl);
|
||||
@@ -111,7 +115,7 @@ public class ArtifactsDeployer {
|
||||
|
||||
if (toRemoteNexus) {
|
||||
// repositoryManager.deploy(new File(path), parseMvnUrl);
|
||||
installToRemote(new File(path), parseMvnUrl, artifactType);
|
||||
installToRemote(libFile, parseMvnUrl, artifactType);
|
||||
// deploy the pom
|
||||
if (new File(generatePom).exists()) {
|
||||
installToRemote(new File(generatePom), parseMvnUrl, pomType);
|
||||
|
||||
@@ -94,10 +94,15 @@ public abstract class AbstractLibrariesService implements ILibrariesService {
|
||||
|
||||
@Override
|
||||
public void deployLibrary(URL source) throws IOException {
|
||||
deployLibrary(source, true);
|
||||
deployLibrary(source, null, true);
|
||||
}
|
||||
|
||||
private void deployLibrary(URL source, boolean reset) throws IOException {
|
||||
@Override
|
||||
public void deployLibrary(URL source, String mavenUri) throws IOException {
|
||||
deployLibrary(source, mavenUri, true);
|
||||
}
|
||||
|
||||
public void deployLibrary(URL source, String mavenUri, boolean reset) throws IOException {
|
||||
|
||||
// fix for bug 0020953
|
||||
// if jdk is not 1.5, need decode %20 for space.
|
||||
@@ -108,7 +113,14 @@ public abstract class AbstractLibrariesService implements ILibrariesService {
|
||||
+ sourceFile.getName());
|
||||
|
||||
if (!repositoryBundleService.contains(source.getFile())) {
|
||||
repositoryBundleService.deploy(sourceFile.toURI());
|
||||
repositoryBundleService.deploy(sourceFile.toURI(), mavenUri);
|
||||
if (PluginChecker.isSVNProviderPluginLoaded()) {
|
||||
ISVNProviderServiceInCoreRuntime svnService = (ISVNProviderServiceInCoreRuntime) GlobalServiceRegister
|
||||
.getDefault().getService(ISVNProviderServiceInCoreRuntime.class);
|
||||
if (svnService != null && svnService.isSvnLibSetupOnTAC()) {
|
||||
svnService.syncLibs(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ModulesNeededProvider.userAddImportModules(targetFile.getPath(), sourceFile.getName(), ELibraryInstallStatus.INSTALLED);
|
||||
@@ -124,7 +136,7 @@ public abstract class AbstractLibrariesService implements ILibrariesService {
|
||||
for (int i = 0; i < source.length; i++) {
|
||||
URL url = source[i];
|
||||
namse[i] = new File(url.toString()).getName();
|
||||
deployLibrary(url, false);
|
||||
deployLibrary(url, null, false);
|
||||
}
|
||||
resetAndRefreshLocal(namse);
|
||||
}
|
||||
@@ -318,12 +330,12 @@ public abstract class AbstractLibrariesService implements ILibrariesService {
|
||||
public List<ModuleNeeded> getModuleNeeded(String id, boolean isGroup) {
|
||||
return ExtensionModuleManager.getInstance().getModuleNeeded(id, isGroup);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deployProjectLibrary(File source) throws IOException {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
|
||||
ILibraryManagerService librairesService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
ILibraryManagerService librairesService = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibraryManagerService.class);
|
||||
if (librairesService != null) {
|
||||
File sourceFile = new File(librairesService.getJarPath(source.getName()));
|
||||
if (sourceFile.exists()) {
|
||||
|
||||
@@ -53,6 +53,16 @@ public class LibrariesService implements ILibrariesService {
|
||||
this.getLibrariesService().deployLibrary(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deployLibrary(URL source, String mavenUri) throws IOException {
|
||||
getLibrariesService().deployLibrary(source, mavenUri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deployLibrary(URL source, String mavenUri, boolean reset) throws IOException {
|
||||
getLibrariesService().deployLibrary(source, mavenUri, reset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deployLibrarys(URL[] source) throws IOException {
|
||||
this.getLibrariesService().deployLibrarys(source);
|
||||
@@ -233,10 +243,10 @@ public class LibrariesService implements ILibrariesService {
|
||||
public List<ModuleNeeded> getModuleNeeded(String id, boolean isGroup) {
|
||||
return getLibrariesService().getModuleNeeded(id, isGroup);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deployProjectLibrary(File source) throws IOException{
|
||||
this.getLibrariesService().deployProjectLibrary(source);
|
||||
public void deployProjectLibrary(File source) throws IOException {
|
||||
this.getLibrariesService().deployProjectLibrary(source);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -147,6 +147,11 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
|
||||
@Override
|
||||
public void deploy(URI jarFileUri, IProgressMonitor... monitorWrap) {
|
||||
deploy(jarFileUri, null, monitorWrap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deploy(URI jarFileUri, String mavenUri, IProgressMonitor... monitorWrap) {
|
||||
if (jarFileUri.isOpaque()) {
|
||||
return;
|
||||
}
|
||||
@@ -154,7 +159,7 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
if (file == null || !file.exists()) {
|
||||
return;
|
||||
}
|
||||
deployFile(file, null, true, monitorWrap);
|
||||
deployFile(file, mavenUri, true, monitorWrap);
|
||||
// deploy to configuration/lib/java if tac still use the svn lib
|
||||
try {
|
||||
if (isSvnLibSetup()) {
|
||||
@@ -203,8 +208,9 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
sourceAndMavenUri.put(uri, jarFile.getAbsolutePath());
|
||||
if (deployAsDefault) {
|
||||
MavenArtifact parseMvnUrl = MavenUrlHelper.parseMvnUrl(uri);
|
||||
if (parseMvnUrl != null && jarFile.getName()
|
||||
.equals(parseMvnUrl.getArtifactId() + "." + parseMvnUrl.getType())) {
|
||||
if (parseMvnUrl != null
|
||||
&& jarFile.getName().equals(
|
||||
parseMvnUrl.getArtifactId() + "." + parseMvnUrl.getType())) {
|
||||
deployAsDefault = false;
|
||||
}
|
||||
}
|
||||
@@ -361,8 +367,9 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
public boolean retrieve(String jarNeeded, String pathToStore, boolean popUp, IProgressMonitor... monitorWrap) {
|
||||
return retrieve(jarNeeded, null, pathToStore, popUp);
|
||||
}
|
||||
|
||||
private boolean retrieve(String jarNeeded, String mavenUri, String pathToStore, boolean showDialog, NexusServerBean customNexusServer) {
|
||||
|
||||
private boolean retrieve(String jarNeeded, String mavenUri, String pathToStore, boolean showDialog) {
|
||||
String sourcePath = null, targetPath = pathToStore;
|
||||
File jarFile = null;
|
||||
try {
|
||||
@@ -372,7 +379,9 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
}
|
||||
// retrieve form custom nexus server automatically
|
||||
TalendLibsServerManager manager = TalendLibsServerManager.getInstance();
|
||||
final NexusServerBean customNexusServer = manager.getCustomNexusServer();
|
||||
if(customNexusServer == null){
|
||||
customNexusServer = manager.getCustomNexusServer();
|
||||
}
|
||||
if (customNexusServer != null) {
|
||||
Set<String> toResolve = new HashSet<String>();
|
||||
if (mavenUri != null) {
|
||||
@@ -419,8 +428,8 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
}
|
||||
// jar found > reset the modules just after install the jars
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
|
||||
ILibrariesService librariesService = (ILibrariesService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibrariesService.class);
|
||||
ILibrariesService librariesService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibrariesService.class);
|
||||
librariesService.resetModulesNeeded();
|
||||
}
|
||||
}
|
||||
@@ -445,7 +454,10 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
CommonExceptionHandler.process(new Exception("Can not copy: " + sourcePath + " to :" + targetPath, e));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean retrieve(String jarNeeded, String mavenUri, String pathToStore, boolean showDialog) {
|
||||
return retrieve(jarNeeded, mavenUri, pathToStore, showDialog, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -611,8 +623,8 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
}
|
||||
if (showDialog && !jarNotFound.isEmpty() && !CommonsPlugin.isHeadless()) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerUIService.class)) {
|
||||
ILibraryManagerUIService libUiService = (ILibraryManagerUIService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerUIService.class);
|
||||
ILibraryManagerUIService libUiService = (ILibraryManagerUIService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibraryManagerUIService.class);
|
||||
libUiService.installModules(jarNotFound.toArray(new String[jarNotFound.size()]));
|
||||
jarsNeeded = new ArrayList<String>(jarNotFound);
|
||||
jarNotFound.clear();
|
||||
@@ -628,8 +640,8 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
}
|
||||
if (needResetModulesNeeded) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
|
||||
ILibrariesService librariesService = (ILibrariesService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibrariesService.class);
|
||||
ILibrariesService librariesService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibrariesService.class);
|
||||
librariesService.resetModulesNeeded();
|
||||
}
|
||||
}
|
||||
@@ -663,18 +675,19 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
return false;
|
||||
}
|
||||
Set<ModuleNeeded> jarNotFound = new HashSet<ModuleNeeded>();
|
||||
|
||||
TalendLibsServerManager manager = TalendLibsServerManager.getInstance();
|
||||
NexusServerBean customNexusServer = manager.getCustomNexusServer();
|
||||
boolean allIsOK = true;
|
||||
for (ModuleNeeded jar : modulesNeeded) {
|
||||
if (!retrieve(jar, pathToStore, false, monitorWrap)) {
|
||||
if (!retrieve(jar, pathToStore, false, customNexusServer, monitorWrap)) {
|
||||
jarNotFound.add(jar);
|
||||
allIsOK = false;
|
||||
}
|
||||
}
|
||||
if (showDialog && !jarNotFound.isEmpty() && !CommonsPlugin.isHeadless()) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerUIService.class)) {
|
||||
ILibraryManagerUIService libUiService = (ILibraryManagerUIService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerUIService.class);
|
||||
ILibraryManagerUIService libUiService = (ILibraryManagerUIService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibraryManagerUIService.class);
|
||||
libUiService.installModules(jarNotFound);
|
||||
modulesNeeded = new HashSet<ModuleNeeded>(jarNotFound);
|
||||
jarNotFound.clear();
|
||||
@@ -690,8 +703,8 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
}
|
||||
if (needResetModulesNeeded) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
|
||||
ILibrariesService librariesService = (ILibrariesService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibrariesService.class);
|
||||
ILibrariesService librariesService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibrariesService.class);
|
||||
librariesService.resetModulesNeeded();
|
||||
}
|
||||
}
|
||||
@@ -701,6 +714,15 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
return allIsOK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retrieve(ModuleNeeded module, String pathToStore, boolean showDialog, NexusServerBean bean, IProgressMonitor... monitorWrap) {
|
||||
// retreive form custom nexus server automatically
|
||||
String mavenUri = module.getMavenUri();
|
||||
String jarNeeded = module.getModuleName();
|
||||
|
||||
return retrieve(jarNeeded, mavenUri, pathToStore, showDialog, bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retrieve(ModuleNeeded module, String pathToStore, boolean showDialog, IProgressMonitor... monitorWrap) {
|
||||
// retreive form custom nexus server automatically
|
||||
@@ -1207,8 +1229,8 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
continue;
|
||||
} else {
|
||||
if (CommonsPlugin.isDebugMode()) {
|
||||
CommonExceptionHandler
|
||||
.warn(name + " is duplicated, locations:" + path + " and:" + moduleLocation);
|
||||
CommonExceptionHandler.warn(name + " is duplicated, locations:" + path + " and:"
|
||||
+ moduleLocation);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -1343,8 +1365,8 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
boolean modified = false;
|
||||
for (String key : libsMavenUriToDeploy.keySet()) {
|
||||
String mvnUri = libsMavenUriToDeploy.get(key);
|
||||
if (!jarsToMavenuri.containsKey(key)
|
||||
|| mvnUri != null && jarsToMavenuri.containsKey(key) && !mvnUri.equals(jarsToMavenuri.get(key))) {
|
||||
if (!jarsToMavenuri.containsKey(key) || mvnUri != null && jarsToMavenuri.containsKey(key)
|
||||
&& !mvnUri.equals(jarsToMavenuri.get(key))) {
|
||||
String valueFromIndex = jarsToMavenuri.get(key);
|
||||
if (valueFromIndex == null) {
|
||||
jarsToMavenuri.put(key, mvnUri);
|
||||
@@ -1389,8 +1411,8 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
if (missingJarObservable == null) {
|
||||
BundleContext bundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
|
||||
if (bundleContext != null) {
|
||||
ServiceReference<?> serviceReference = bundleContext
|
||||
.getServiceReference(JarMissingObservable.class.getCanonicalName());
|
||||
ServiceReference<?> serviceReference = bundleContext.getServiceReference(JarMissingObservable.class
|
||||
.getCanonicalName());
|
||||
if (serviceReference != null) {
|
||||
missingJarObservable = (JarMissingObservable) bundleContext.getService(serviceReference);
|
||||
} else {// could not find the hook registry service so log it
|
||||
@@ -1521,8 +1543,7 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocalJarSameAsNexus(TalendLibsServerManager manager, final NexusServerBean customNexusServer,
|
||||
String jarUri) {
|
||||
public boolean isLocalJarSameAsNexus(TalendLibsServerManager manager, final NexusServerBean customNexusServer, String jarUri) {
|
||||
if (manager == null || customNexusServer == null || jarUri == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -1565,4 +1586,4 @@ public class LocalLibraryManager implements ILibraryManagerService {
|
||||
return isSvnLibSetup() && !isJarExistInLibFolder(jarFile) || !isLocalJarSameAsNexus(jarFile.getName());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,11 @@ public class MetadataManagmentUiService implements IMetadataManagmentUiService {
|
||||
public ContextType getContextTypeForContextMode(Connection connection) {
|
||||
return ConnectionContextHelper.getContextTypeForContextMode(connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContextType getContextTypeForContextMode(Connection connection, String selectedName, boolean defaultContext) {
|
||||
return ConnectionContextHelper.getContextTypeForContextMode(null, connection, selectedName, defaultContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOriginalValue(ContextType contextType, String value) {
|
||||
|
||||
@@ -1384,6 +1384,8 @@ public class DBConnectionFillerImpl extends MetadataFillerImpl<DatabaseConnectio
|
||||
tablePattern = tablePattern.replaceAll("/", "//");//$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
boolean isHive = MetadataConnectionUtils.isHive(dbJDBCMetadata);
|
||||
|
||||
ResultSet columns = dbJDBCMetadata.getColumns(catalogName, schemaPattern, tablePattern, columnPattern);
|
||||
if (MetadataConnectionUtils.isMysql(dbJDBCMetadata)) {
|
||||
boolean check = !Pattern.matches("^\\w+$", tablePattern);//$NON-NLS-1$
|
||||
@@ -1451,6 +1453,13 @@ public class DBConnectionFillerImpl extends MetadataFillerImpl<DatabaseConnectio
|
||||
int column_size = getIntFromResultSet(columns, GetColumn.COLUMN_SIZE.name());
|
||||
column.setLength(column_size);
|
||||
decimalDigits = getIntFromResultSet(columns, GetColumn.DECIMAL_DIGITS.name());
|
||||
|
||||
if(isHive && typeName.equalsIgnoreCase("DECIMAL") && columnPattern==null && getStringFromResultSet(columns, GetColumn.DECIMAL_DIGITS.name()) == null){
|
||||
ResultSet result = dbJDBCMetadata.getColumns(catalogName, schemaPattern, tablePattern, columnName);
|
||||
while (result.next()) {
|
||||
decimalDigits = getIntFromResultSet(result, GetColumn.DECIMAL_DIGITS.name());
|
||||
}
|
||||
}
|
||||
column.setPrecision(decimalDigits);
|
||||
// Teradata SQL Mode no need this column
|
||||
if (!MetadataConnectionUtils.isTeradataSQLMode(iMetadataConnection)) {
|
||||
|
||||
@@ -1169,6 +1169,9 @@ public class MetadataConnectionUtils {
|
||||
|
||||
public static boolean isHive(DatabaseMetaData metadata) {
|
||||
if (metadata != null) {
|
||||
if (metadata.getClass().getSimpleName().equals("HiveDatabaseMetaData")) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
String name = metadata.getDatabaseProductName();
|
||||
if (name != null && name.equals(EDatabaseTypeName.HIVE.getDisplayName())) {
|
||||
|
||||
@@ -19,8 +19,11 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
@@ -36,6 +39,7 @@ import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.talend.commons.exception.LoginException;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
|
||||
@@ -83,7 +87,9 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
|
||||
private static Logger log = Logger.getLogger(MigrationToolService.class);
|
||||
|
||||
private static final String RELATION_TASK = "org.talend.repository.model.migration.AutoUpdateRelationsMigrationTask"; //$NON-NLS-1$
|
||||
private static final String PROPERTIES_REDO_ENCRYPTION_MIGRATION_TASKS = "talend.property.migration.redoEncryption"; //$NON-NLS-1$
|
||||
|
||||
private static final String RELATION_TASK = "org.talend.repository.model.migration.AutoUpdateRelationsMigrationTask"; //$NON-NLS-1$
|
||||
|
||||
private List<IProjectMigrationTask> doneThisSession;
|
||||
|
||||
@@ -174,18 +180,29 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
|
||||
@Override
|
||||
public void executeMigrationTasksForLogon(final Project project, final boolean beforeLogon, final IProgressMonitor monitorWrap) {
|
||||
String taskDesc = "Migration tool: project [" + project.getLabel() + "] tasks"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String logonDesc = null;
|
||||
if (beforeLogon) {
|
||||
logonDesc = "before logon"; //$NON-NLS-1$
|
||||
} else {
|
||||
logonDesc = "after logon"; //$NON-NLS-1$
|
||||
}
|
||||
String taskDesc = "Migration tool: " + logonDesc + " project [" + project.getLabel() + "] tasks"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
log.trace(taskDesc);
|
||||
|
||||
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
final IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
|
||||
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
final IProject fsProject = workspace.getRoot().getProject(project.getTechnicalLabel());
|
||||
|
||||
final List<IProjectMigrationTask> toExecute = GetTasksHelper.getProjectTasks(beforeLogon);
|
||||
final List<MigrationTask> done = new ArrayList<MigrationTask>(project.getEmfProject().getMigrationTask());
|
||||
List<MigrationTask> storedMigrations = project.getEmfProject().getMigrationTask();
|
||||
|
||||
if (beforeLogon) {
|
||||
boolean isNewProject = project.getEmfProject().getProductVersion() == null ? true : false;
|
||||
setMigrationOnNewProject(beforeLogon && isNewProject && done.isEmpty());
|
||||
checkMigrationList(monitorWrap, repFactory, project, fsProject, toExecute, storedMigrations);
|
||||
}
|
||||
sortMigrationTasks(toExecute);
|
||||
|
||||
final List<MigrationTask> done = new ArrayList<MigrationTask>(storedMigrations);
|
||||
int nbMigrationsToDo = 0;
|
||||
for (IProjectMigrationTask task : toExecute) {
|
||||
MigrationTask mgTask = MigrationUtil.findMigrationTask(done, task);
|
||||
@@ -222,8 +239,6 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
MigrationUtil.removeMigrationTaskById(done, "org.talend.repository.model.migration.FixProjectResourceLink");
|
||||
|
||||
boolean haveAnyBinFolder = false; // to avoid some problems of migration, sometimes
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IProject fsProject = workspace.getRoot().getProject(project.getTechnicalLabel());
|
||||
for (ERepositoryObjectType type : (ERepositoryObjectType[]) ERepositoryObjectType.values()) {
|
||||
if (!type.hasFolder()) {
|
||||
continue;
|
||||
@@ -243,8 +258,6 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
}
|
||||
|
||||
final SubProgressMonitor subProgressMonitor = new SubProgressMonitor(monitorWrap, toExecute.size());
|
||||
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
final IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
|
||||
|
||||
RepositoryWorkUnit repositoryWorkUnit = new RepositoryWorkUnit(project, taskDesc) {
|
||||
|
||||
@@ -485,6 +498,125 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
// repositoryWorkUnit.throwPersistenceExceptionIfAny();
|
||||
}
|
||||
|
||||
private void checkMigrationList(final IProgressMonitor monitorWrap, final IProxyRepositoryFactory repFactory,
|
||||
final Project project, final IProject fsProject, final List<IProjectMigrationTask> toExecute,
|
||||
List<MigrationTask> storedMigrations) {
|
||||
boolean isProcessFolderExist = false;
|
||||
boolean isMetadataFolderExist = false;
|
||||
|
||||
String processFolderName = ERepositoryObjectType.getFolderName(ERepositoryObjectType.PROCESS);
|
||||
if (StringUtils.isNotBlank(processFolderName)) {
|
||||
IFolder processFolder = fsProject.getFolder(processFolderName);
|
||||
if (processFolder != null) {
|
||||
isProcessFolderExist = processFolder.exists();
|
||||
}
|
||||
}
|
||||
String metadataFolderName = ERepositoryObjectType.getFolderName(ERepositoryObjectType.METADATA);
|
||||
if (StringUtils.isNotBlank(metadataFolderName)) {
|
||||
IFolder metadataFolder = fsProject.getFolder(metadataFolderName);
|
||||
if (metadataFolder != null) {
|
||||
isMetadataFolderExist = metadataFolder.exists();
|
||||
}
|
||||
}
|
||||
|
||||
boolean isEmptyProject = (!isProcessFolderExist && !isMetadataFolderExist);
|
||||
setMigrationOnNewProject(isEmptyProject);
|
||||
|
||||
boolean needSave = false;
|
||||
|
||||
if (storedMigrations.isEmpty() && !isEmptyProject) {
|
||||
List<IProjectMigrationTask> allMigrations = new LinkedList<IProjectMigrationTask>();
|
||||
if (toExecute != null) {
|
||||
allMigrations.addAll(toExecute);
|
||||
}
|
||||
List<IProjectMigrationTask> afterLogonMigrations = GetTasksHelper.getProjectTasks(false);
|
||||
if (afterLogonMigrations != null) {
|
||||
allMigrations.addAll(afterLogonMigrations);
|
||||
}
|
||||
sortMigrationTasks(allMigrations);
|
||||
for (IProjectMigrationTask task : allMigrations) {
|
||||
if (RELATION_TASK.equals(task.getId())) {
|
||||
continue;
|
||||
}
|
||||
task.setStatus(ExecutionResult.NOTHING_TO_DO);
|
||||
storedMigrations.add(MigrationUtil.convertMigrationTask(task));
|
||||
}
|
||||
needSave = true;
|
||||
}
|
||||
|
||||
if (!isEmptyProject && Boolean.valueOf(System.getProperty(PROPERTIES_REDO_ENCRYPTION_MIGRATION_TASKS))) {
|
||||
List<String> encryptionTasks = Arrays.asList(new String[] {
|
||||
"org.talend.camel.designer.migration.UnifyPasswordEncryption4ParametersInRouteMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.designer.joblet.repository.migration.UnifyPasswordEncryption4ParametersInJobletMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.designer.mapreduce.repository.migration.UnifyPasswordEncryption4ParametersInMRJobMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.mdm.repository.migration.UnifyPasswordEncryption4MDMConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.EncryptDbPasswordforItemFileMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.EncryptDbPasswordMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.EncryptPasswordInComponentsMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.EncryptPasswordInJobSettingsMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.EncryptPasswordInProjectSettingsMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4ContextMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4DBConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4LdapConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4ParametersInJobMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4ProjectSettingsMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4SalesforceSchemaConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4WsdlConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.nosql.repository.migration.UnifyPasswordEncryption4NoSQLConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.sap.repository.migration.UnifyPasswordEncryption4SapConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.storm.repository.migration.UnifyPasswordEncryption4ParametersInStormJobMigrationTask", //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* These two migrations don't have the problem, re-execute anyway
|
||||
*/
|
||||
"org.talend.repository.ftp.repository.migration.UnifyPasswordEncryption4FtpConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.mdm.workbench.serverexplorer.migration.UnifyPasswordEncryption4MDMServerDefMigrationTask" //$NON-NLS-1$
|
||||
|
||||
});
|
||||
Iterator<MigrationTask> iterator = storedMigrations.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
MigrationTask migrationTask = iterator.next();
|
||||
if (encryptionTasks.contains(migrationTask.getId())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
needSave = true;
|
||||
}
|
||||
if (needSave) {
|
||||
RepositoryWorkUnit repositoryWorkUnit = new RepositoryWorkUnit(project,
|
||||
"Migration tool: update project [" + project.getLabel() + "] tasks due to lost or user specify") { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
@Override
|
||||
protected void run() throws LoginException, PersistenceException {
|
||||
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
repFactory.saveProject(project);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
try {
|
||||
IWorkspace workspace1 = ResourcesPlugin.getWorkspace();
|
||||
ISchedulingRule schedulingRule = workspace1.getRoot();
|
||||
// the update the project files need to be done in the workspace runnable to
|
||||
// avoid all notification of changes before the end of the modifications.
|
||||
workspace1.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitorWrap);
|
||||
} catch (CoreException e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
repositoryWorkUnit.setAvoidUnloadResources(true);
|
||||
repFactory.executeRepositoryWorkUnit(repositoryWorkUnit);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendToLogFile(Project sourceProject, String logTxt) {
|
||||
IProject project = ProjectManager.getInstance().getResourceProject(sourceProject.getEmfProject());
|
||||
File fullLogFile = new File(project.getFile(FULL_LOG_FILE).getLocation().toPortableString());
|
||||
|
||||
@@ -19,10 +19,14 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.PasswordEncryptUtil;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
|
||||
@@ -1083,6 +1087,70 @@ public class ConnectionHelper {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getCleanPassword(String password) {
|
||||
if (StringUtils.isBlank(password)) {
|
||||
return password;
|
||||
}
|
||||
String result = password;
|
||||
try {
|
||||
String tempValue = result;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
// normally there won't be dead loop, just in case it happens
|
||||
if (600 < i) {
|
||||
ExceptionHandler.process(new Exception("Dead loop when executing migration!"), Priority.WARN); //$NON-NLS-1$
|
||||
break;
|
||||
}
|
||||
|
||||
boolean cleanFromNewWay = false;
|
||||
String originalValue = tempValue;
|
||||
try {
|
||||
tempValue = getDecryptPassword(originalValue);
|
||||
String encryptFromTempValue = getEncryptPassword(tempValue);
|
||||
if (!StringUtils.equals(originalValue, encryptFromTempValue)) {
|
||||
cleanFromNewWay = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
cleanFromNewWay = true;
|
||||
} finally {
|
||||
if (cleanFromNewWay) {
|
||||
tempValue = originalValue;
|
||||
}
|
||||
}
|
||||
|
||||
boolean cleanFromOldWay = false;
|
||||
originalValue = tempValue;
|
||||
try {
|
||||
tempValue = PasswordEncryptUtil.decryptPassword(originalValue);
|
||||
String encryptFromTempValue = PasswordEncryptUtil.encryptPassword(tempValue);
|
||||
// original password may end with "=Encrypt", eg:
|
||||
// UnifyPasswordEncryption4ProjectSettingsMigrationTask#reencryptValueIfNeeded
|
||||
if (!StringUtils.startsWith(originalValue, encryptFromTempValue)) {
|
||||
cleanFromOldWay = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
cleanFromOldWay = true;
|
||||
} finally {
|
||||
if (cleanFromOldWay) {
|
||||
tempValue = originalValue;
|
||||
}
|
||||
}
|
||||
|
||||
result = tempValue;
|
||||
if (StringUtils.isBlank(result)) {
|
||||
break;
|
||||
}
|
||||
if (cleanFromNewWay && cleanFromOldWay) {
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC xqliu Comment method "getDecryptPassword".
|
||||
*
|
||||
|
||||
@@ -249,7 +249,7 @@ public class MissingJarBundleFileWrapper extends BundleFileWrapper {
|
||||
}// else no nothification required.
|
||||
}
|
||||
}// else //no lib folder found so return null
|
||||
} catch (URISyntaxException e) {
|
||||
} catch (URISyntaxException | RuntimeException e) {
|
||||
MissingJarServices
|
||||
.getLogService()
|
||||
.log(LogService.LOG_ERROR,
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -2056,8 +2057,27 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
@Override
|
||||
public void setMigrationTasksDone(Project project, List<MigrationTask> list) throws PersistenceException {
|
||||
List oldMigrationTasks = project.getEmfProject().getMigrationTask();
|
||||
// use LinkedHashMap to keep the order
|
||||
Map<String, MigrationTask> refreshedTaskMap = new LinkedHashMap<String, MigrationTask>();
|
||||
if (list != null) {
|
||||
Iterator<MigrationTask> iter = list.iterator();
|
||||
while (iter.hasNext()) {
|
||||
MigrationTask task = iter.next();
|
||||
refreshedTaskMap.put(task.getId(), task);
|
||||
}
|
||||
}
|
||||
if (oldMigrationTasks != null) {
|
||||
Iterator<MigrationTask> iter = oldMigrationTasks.iterator();
|
||||
while (iter.hasNext()) {
|
||||
MigrationTask task = iter.next();
|
||||
String key = task.getId();
|
||||
if (refreshedTaskMap.containsKey(key)) {
|
||||
refreshedTaskMap.put(key, task);
|
||||
}
|
||||
}
|
||||
}
|
||||
project.getEmfProject().getMigrationTask().clear();
|
||||
project.getEmfProject().getMigrationTask().addAll(list);
|
||||
project.getEmfProject().getMigrationTask().addAll(refreshedTaskMap.values());
|
||||
saveProject(project);
|
||||
}
|
||||
|
||||
@@ -2897,7 +2917,6 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
exist = true;
|
||||
}
|
||||
}
|
||||
|
||||
return exist;
|
||||
}
|
||||
|
||||
@@ -3168,12 +3187,13 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
|
||||
@Override
|
||||
public List<org.talend.core.model.properties.Project> getReferencedProjects(Project project) {
|
||||
String parentBranch = getRepositoryContext().getFields().get(
|
||||
IProxyRepositoryFactory.BRANCH_SELECTION + "_" + getRepositoryContext().getProject().getTechnicalLabel());
|
||||
|
||||
String parentBranch = getRepositoryContext().getFields()
|
||||
.get(IProxyRepositoryFactory.BRANCH_SELECTION + "_" + getRepositoryContext().getProject().getTechnicalLabel());
|
||||
List<org.talend.core.model.properties.Project> refProjectList = new ArrayList<org.talend.core.model.properties.Project>();
|
||||
for (ProjectReference refProject : (List<ProjectReference>) project.getEmfProject().getReferencedProjects()) {
|
||||
if (refProject.getBranch() == null || refProject.getBranch().equals(parentBranch)) {
|
||||
String rBranch = ProjectManager.getInstance().getLocalProjectReferenceBranch(project.getEmfProject(), parentBranch, refProject);
|
||||
String refBranch4Local = ProjectManager.getInstance().getLocalProjectReferenceReferenceBranch(project.getEmfProject(), parentBranch, refProject);
|
||||
if (ProjectManager.validReferenceProject(parentBranch, rBranch, refBranch4Local, refProject)) {
|
||||
refProjectList.add(refProject.getReferencedProject());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.MDMConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
|
||||
/**
|
||||
* created by ggu on Sep 1, 2014 Detailled comment
|
||||
@@ -55,6 +56,7 @@ public class UnifyPasswordEncryption4MDMConnectionMigrationTask extends Abstract
|
||||
try {
|
||||
if (!mdmConn.isContextMode()) {
|
||||
String pass = mdmConn.getPassword();
|
||||
pass = ConnectionHelper.getCleanPassword(pass);
|
||||
// because before, it's raw value, so encrypt it directly.
|
||||
mdmConn.setPassword(mdmConn.getValue(pass, true));
|
||||
factory.save(item, true);
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.LDAPSchemaConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
|
||||
/**
|
||||
* created by ggu on Aug 29, 2014 Detailled comment
|
||||
@@ -56,6 +57,7 @@ public class UnifyPasswordEncryption4LdapConnectionMigrationTask extends Abstrac
|
||||
if (!ldapConn.isContextMode()) {
|
||||
// before this migration ,the pass is raw, didn't encrypt.
|
||||
String pass = ldapConn.getBindPassword();
|
||||
pass = ConnectionHelper.getCleanPassword(pass);
|
||||
ldapConn.setBindPassword(ldapConn.getValue(pass, true));
|
||||
factory.save(item, true);
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.SalesforceSchemaConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
|
||||
/**
|
||||
* created by ggu on Aug 29, 2014 Detailled comment
|
||||
@@ -55,9 +56,11 @@ public class UnifyPasswordEncryption4SalesforceSchemaConnectionMigrationTask ext
|
||||
try {
|
||||
if (!ssConn.isContextMode()) {
|
||||
// before this migration ,the pass is raw, didn't encrypt.
|
||||
ssConn.setPassword(ssConn.getValue(ssConn.getPassword(), true));
|
||||
ssConn.setProxyPassword(ssConn.getValue(ssConn.getProxyPassword(), true));
|
||||
ssConn.setConsumeSecret(ssConn.getValue(ssConn.getConsumeSecret(), true));
|
||||
ssConn.setPassword(ssConn.getValue(ConnectionHelper.getCleanPassword(ssConn.getPassword()), true));
|
||||
ssConn.setProxyPassword(
|
||||
ssConn.getValue(ConnectionHelper.getCleanPassword(ssConn.getProxyPassword()), true));
|
||||
ssConn.setConsumeSecret(
|
||||
ssConn.getValue(ConnectionHelper.getCleanPassword(ssConn.getConsumeSecret()), true));
|
||||
factory.save(item, true);
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.WSDLSchemaConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
|
||||
/**
|
||||
* created by ggu on Aug 29, 2014 Detailled comment
|
||||
@@ -55,8 +56,9 @@ public class UnifyPasswordEncryption4WsdlConnectionMigrationTask extends Abstrac
|
||||
try {
|
||||
if (!wsdlConn.isContextMode()) {
|
||||
// before this migration ,the password is raw, didn't encrypt.
|
||||
wsdlConn.setPassword(wsdlConn.getValue(wsdlConn.getPassword(), true));
|
||||
wsdlConn.setProxyPassword(wsdlConn.getValue(wsdlConn.getProxyPassword(), true));
|
||||
wsdlConn.setPassword(wsdlConn.getValue(ConnectionHelper.getCleanPassword(wsdlConn.getPassword()), true));
|
||||
wsdlConn.setProxyPassword(
|
||||
wsdlConn.getValue(ConnectionHelper.getCleanPassword(wsdlConn.getProxyPassword()), true));
|
||||
factory.save(item, true);
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
}
|
||||
|
||||
@@ -1849,7 +1849,6 @@ public class DatabaseForm extends AbstractForm {
|
||||
getConnection().getParameters().put(ConnParameterKeys.CONN_PARA_KEY_USE_KRB, Boolean.TRUE.toString());
|
||||
getConnection().getParameters().put(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA,
|
||||
impalaPrincipalTxt.getText());
|
||||
urlConnectionStringText.setText(getStringConnection());
|
||||
} else {
|
||||
GridData hadoopData = (GridData) authenticationComForImpala.getLayoutData();
|
||||
hadoopData.exclude = true;
|
||||
@@ -1861,6 +1860,7 @@ public class DatabaseForm extends AbstractForm {
|
||||
getConnection().getParameters().put(ConnParameterKeys.CONN_PARA_KEY_USE_KRB, Boolean.FALSE.toString());
|
||||
}
|
||||
urlConnectionStringText.setText(getStringConnection());
|
||||
modifyFieldValue();
|
||||
}
|
||||
|
||||
});
|
||||
@@ -1873,6 +1873,7 @@ public class DatabaseForm extends AbstractForm {
|
||||
getConnection().getParameters().put(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA,
|
||||
impalaPrincipalTxt.getText());
|
||||
urlConnectionStringText.setText(getStringConnection());
|
||||
modifyFieldValue();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -164,11 +164,9 @@ public class SelectorTableForm extends AbstractForm {
|
||||
|
||||
private List<TableNode> tableNodeList = new ArrayList<TableNode>();
|
||||
|
||||
private int count = 0;
|
||||
private volatile int countSuccess = 0;
|
||||
|
||||
private int countSuccess = 0;
|
||||
|
||||
private int countPending = 0;
|
||||
private volatile int countPending = 0;
|
||||
|
||||
private final WizardPage parentWizardPage;
|
||||
|
||||
@@ -248,7 +246,6 @@ public class SelectorTableForm extends AbstractForm {
|
||||
public void initializeForm() {
|
||||
initExistingNames();
|
||||
selectAllTablesButton.setEnabled(true);
|
||||
count = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -576,7 +573,6 @@ public class SelectorTableForm extends AbstractForm {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(final SelectionEvent e) {
|
||||
count = 0;
|
||||
checkConnection(true);
|
||||
}
|
||||
});
|
||||
@@ -649,7 +645,6 @@ public class SelectorTableForm extends AbstractForm {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(final SelectionEvent e) {
|
||||
count = 0;
|
||||
countSuccess = 0;
|
||||
countPending = 0;
|
||||
for (TreeItem catalogItem : tree.getItems()) {
|
||||
@@ -765,16 +760,11 @@ public class SelectorTableForm extends AbstractForm {
|
||||
treeItem.setText(2, ""); //$NON-NLS-1$
|
||||
treeItem.setText(3, Messages.getString("SelectorTableForm.Pending")); //$NON-NLS-1$
|
||||
refreshColumnData(tableNode, treeItem);
|
||||
countPending++;
|
||||
parentWizardPage.setPageComplete(false);
|
||||
refreshTable(treeItem, -1);
|
||||
}
|
||||
} else {
|
||||
clearTableItem(treeItem);
|
||||
if (treeItem.getText() != null
|
||||
&& treeItem.getText().equals(Messages.getString("SelectorTableForm.Pending"))) { //$NON-NLS-1$
|
||||
countPending--;
|
||||
}
|
||||
clearTableItem(treeItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -805,16 +795,11 @@ public class SelectorTableForm extends AbstractForm {
|
||||
treeItem.setText(2, ""); //$NON-NLS-1$
|
||||
treeItem.setText(3, Messages.getString("SelectorTableForm.Pending")); //$NON-NLS-1$
|
||||
refreshColumnData(tableNode, treeItem);
|
||||
|
||||
countPending++;
|
||||
parentWizardPage.setPageComplete(false);
|
||||
refreshTable(treeItem, -1);
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
clearTableItem(treeItem);
|
||||
if (treeItem.getText() != null && treeItem.getText().equals(Messages.getString("SelectorTableForm.Pending"))) { //$NON-NLS-1$
|
||||
countPending--;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!treeItem.getExpanded()) {
|
||||
@@ -894,7 +879,6 @@ public class SelectorTableForm extends AbstractForm {
|
||||
} else {
|
||||
item.setText(3, Messages.getString("SelectorTableForm.Pending")); //$NON-NLS-1$
|
||||
refreshColumnData(tableNode, item);
|
||||
countPending++;
|
||||
parentWizardPage.setPageComplete(false);
|
||||
refreshTable(item, -1);
|
||||
}
|
||||
@@ -1252,7 +1236,6 @@ public class SelectorTableForm extends AbstractForm {
|
||||
tableItem.setText(2, "" + metadataColumns.size()); //$NON-NLS-1$
|
||||
tableItem.setText(3, Messages.getString("SelectorTableForm.Success")); //$NON-NLS-1$
|
||||
refreshColumnData((TableNode) tableItem.getData(), tableItem);
|
||||
countSuccess++;
|
||||
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
|
||||
@@ -1452,6 +1435,9 @@ public class SelectorTableForm extends AbstractForm {
|
||||
List<TdColumn> metadataColumns = null;
|
||||
|
||||
volatile boolean isCanceled = false;
|
||||
|
||||
volatile boolean isFinished = false;
|
||||
|
||||
|
||||
/**
|
||||
* Getter for tableItem.
|
||||
@@ -1470,6 +1456,23 @@ public class SelectorTableForm extends AbstractForm {
|
||||
|
||||
public void setCanceled(boolean cancel) {
|
||||
this.isCanceled = cancel;
|
||||
if (isCanceled) {
|
||||
if (!isFinished) {
|
||||
countPending--;
|
||||
}
|
||||
} else {
|
||||
if (!isFinished) {
|
||||
countPending++;
|
||||
}
|
||||
}
|
||||
final boolean isAllTaskFinished = isAllTaskFinished();
|
||||
final boolean pageC = pageComplete();
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
parentWizardPage.setPageComplete(isAllTaskFinished && !pageC);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1620,6 +1623,11 @@ public class SelectorTableForm extends AbstractForm {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isCanceled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
ProjectNodeHelper.addTableForTemCatalogOrSchema(catalog, schema, getConnection(), dbtable,
|
||||
metadataconnection);
|
||||
@@ -1676,7 +1684,6 @@ public class SelectorTableForm extends AbstractForm {
|
||||
} else {
|
||||
treeItem.setText(3, Messages.getString("SelectorTableForm.Failed")); //$NON-NLS-1$
|
||||
}
|
||||
countSuccess++;
|
||||
tableColumnNums.put(treeItem.getText(0), metadataColumns.size());
|
||||
} else {
|
||||
updateStatus(IStatus.WARNING, Messages.getString("DatabaseTableForm.connectionFailure")); //$NON-NLS-1$
|
||||
@@ -1685,16 +1692,19 @@ public class SelectorTableForm extends AbstractForm {
|
||||
|
||||
}
|
||||
refreshColumnData(tableNode, treeItem);
|
||||
count++;
|
||||
|
||||
|
||||
isFinished = true;
|
||||
countSuccess++;
|
||||
updateStatus(IStatus.OK, null);
|
||||
// selectNoneTablesButton.setEnabled(true);
|
||||
// checkConnectionButton.setEnabled(true);
|
||||
|
||||
parentWizardPage.setPageComplete(threadExecutor.getQueue().isEmpty()
|
||||
&& (threadExecutor.getActiveCount() == 0 || countSuccess == countPending));
|
||||
parentWizardPage.setPageComplete(isAllTaskFinished());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isAllTaskFinished() {
|
||||
return threadExecutor.getQueue().isEmpty()
|
||||
&& (threadExecutor.getActiveCount() == 0 || countSuccess == countPending);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1719,6 +1729,7 @@ public class SelectorTableForm extends AbstractForm {
|
||||
RetrieveColumnRunnable runnable = new RetrieveColumnRunnable(treeItem);
|
||||
String value = node.getValue();
|
||||
if (!(isExistingNames(value))) {
|
||||
countPending++;
|
||||
threadExecutor.execute(runnable);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
@@ -1735,6 +1746,7 @@ public class SelectorTableForm extends AbstractForm {
|
||||
RetrieveColumnRunnable runnable = new RetrieveColumnRunnable(treeItem);
|
||||
String value = node.getValue();
|
||||
if (!(isExistingNames(value))) {
|
||||
countPending++;
|
||||
threadExecutor.execute(runnable);
|
||||
}
|
||||
}
|
||||
@@ -1776,7 +1788,6 @@ public class SelectorTableForm extends AbstractForm {
|
||||
if (checkConnectionIsDone) {
|
||||
// treeItem.setText(2, "" + metadataColumns.size()); //$NON-NLS-1$
|
||||
treeItem.setText(3, Messages.getString("SelectorTableForm.Success")); //$NON-NLS-1$
|
||||
countSuccess++;
|
||||
// tableColumnNums.put(treeItem.getText(0), metadataColumns.size());
|
||||
} else {
|
||||
updateStatus(IStatus.WARNING, Messages.getString("DatabaseTableForm.connectionFailure")); //$NON-NLS-1$
|
||||
@@ -1785,20 +1796,21 @@ public class SelectorTableForm extends AbstractForm {
|
||||
managerConnection.getMessageException());
|
||||
|
||||
}
|
||||
refreshColumnData(tableNode, treeItem);
|
||||
count++;
|
||||
|
||||
refreshColumnData(tableNode, treeItem);
|
||||
isFinished = true;
|
||||
countSuccess++;
|
||||
updateStatus(IStatus.OK, null);
|
||||
// selectNoneTablesButton.setEnabled(true);
|
||||
// checkConnectionButton.setEnabled(true);
|
||||
|
||||
parentWizardPage.setPageComplete(threadExecutor.getQueue().isEmpty()
|
||||
&& (threadExecutor.getActiveCount() == 0 || countSuccess == countPending));
|
||||
parentWizardPage.setPageComplete(isAllTaskFinished());
|
||||
}
|
||||
|
||||
};
|
||||
String value = node.getValue();
|
||||
if (!(isExistingNames(value))) {
|
||||
countPending++;
|
||||
threadExecutor.execute(runnable);
|
||||
}
|
||||
}
|
||||
@@ -1937,9 +1949,9 @@ public class SelectorTableForm extends AbstractForm {
|
||||
}
|
||||
item.setText(3, Messages.getString("SelectorTableForm.Pending")); //$NON-NLS-1$
|
||||
refreshColumnData(existTableItem, item);
|
||||
countPending++;
|
||||
parentWizardPage.setPageComplete(false);
|
||||
refreshTable(item, -1);
|
||||
item.setChecked(true);
|
||||
} else {
|
||||
item.setChecked(false);
|
||||
boolean hasCheckedItem = false;
|
||||
|
||||
@@ -17,3 +17,4 @@ RepositoryFilterSettingDialog.Login=Login
|
||||
RepositoryFilterSettingDialog.PatternInfo=The patterns are separated by comma, where\n* = any string, ? = any character, ,, = ,
|
||||
RepoViewCommonNavigator.Content=locked by {0} on {1}
|
||||
RepoViewCommonNavigator.Desc=\ \ Description:
|
||||
RepoViewCommonNavigator.refresh=Refreshing...
|
||||
|
||||
@@ -25,7 +25,12 @@ import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.util.LocalSelectionTransfer;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
@@ -40,6 +45,7 @@ import org.eclipse.swt.events.PaintEvent;
|
||||
import org.eclipse.swt.events.PaintListener;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
@@ -57,6 +63,7 @@ import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.Saveable;
|
||||
import org.eclipse.ui.contexts.IContextActivation;
|
||||
import org.eclipse.ui.contexts.IContextService;
|
||||
import org.eclipse.ui.internal.progress.ProgressManager;
|
||||
import org.eclipse.ui.navigator.CommonNavigator;
|
||||
import org.eclipse.ui.navigator.CommonViewer;
|
||||
import org.eclipse.ui.navigator.CommonViewerSorter;
|
||||
@@ -68,7 +75,6 @@ import org.talend.commons.runtime.model.repository.ERepositoryStatus;
|
||||
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
|
||||
import org.talend.commons.ui.runtime.image.ECoreImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor;
|
||||
import org.talend.commons.ui.swt.dialogs.ProgressDialog;
|
||||
import org.talend.commons.ui.swt.tooltip.AbstractTreeTooltip;
|
||||
import org.talend.commons.utils.Timer;
|
||||
@@ -327,8 +333,9 @@ public class RepoViewCommonNavigator extends CommonNavigator implements IReposit
|
||||
@Override
|
||||
public void createPartControl(Composite parent) {
|
||||
service = GitContentServiceProviderManager.getGitContentService();
|
||||
if (service != null && service.isGIT())
|
||||
if (service != null && service.isGIT()) {
|
||||
service.createDropdownCombo(parent);
|
||||
}
|
||||
|
||||
super.createPartControl(parent);
|
||||
|
||||
@@ -341,8 +348,9 @@ public class RepoViewCommonNavigator extends CommonNavigator implements IReposit
|
||||
public void paintControl(PaintEvent e) {
|
||||
Point viewerPoint = viewer.getTree().getSize();
|
||||
Point point = parent.getSize();
|
||||
if (viewerPoint.x == point.x - 7 && viewerPoint.y == point.y - 40)
|
||||
if (viewerPoint.x == point.x - 7 && viewerPoint.y == point.y - 40) {
|
||||
return;
|
||||
}
|
||||
viewer.getTree().setSize(point.x - 7, point.y - 40);
|
||||
viewer.getTree().showSelection();
|
||||
}
|
||||
@@ -731,57 +739,95 @@ public class RepoViewCommonNavigator extends CommonNavigator implements IReposit
|
||||
return;
|
||||
}
|
||||
|
||||
ProgressDialog progressDialog = new ProgressDialog(shell, 1000) {
|
||||
final Job job = new Job(Messages.getString("RepoViewCommonNavigator.refresh")) { //$NON-NLS-1$
|
||||
|
||||
private IProgressMonitor monitorWrap;
|
||||
@Override
|
||||
public IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
Timer timer = Timer.getTimer("repositoryView"); //$NON-NLS-1$
|
||||
timer.start();
|
||||
if (needInitialize) {
|
||||
try {
|
||||
final ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
factory.initialize();
|
||||
} catch (Exception e) {
|
||||
throw new InvocationTargetException(e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||
} catch (CoreException e) {
|
||||
throw new InvocationTargetException(e);
|
||||
}
|
||||
// TODO Why do we need to recreate a root here ????
|
||||
// root = new ProjectRepositoryNode(null, null, ENodeType.STABLE_SYSTEM_FOLDER);
|
||||
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// unsetting the selection will prevent the propertyView from displaying dirty data
|
||||
viewer.setSelection(new TreeSelection());
|
||||
viewer.refresh();
|
||||
expandTreeRootIfOnlyOneRoot();
|
||||
}
|
||||
});
|
||||
|
||||
if (PluginChecker.isJobLetPluginLoaded()) {
|
||||
IJobletProviderService jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault()
|
||||
.getService(IJobletProviderService.class);
|
||||
if (jobletService != null) {
|
||||
jobletService.loadComponentsFromProviders();
|
||||
}
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
// timer.print();
|
||||
} catch (InvocationTargetException e) {
|
||||
ExceptionHandler.process(e);
|
||||
} catch (Exception e) {
|
||||
MessageBoxExceptionHandler.process(e);
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
job.setUser(false);
|
||||
job.setRule(null);
|
||||
job.setPriority(Job.INTERACTIVE);
|
||||
job.schedule();
|
||||
|
||||
ProgressDialog dialog = new ProgressDialog(shell, 3000) {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
Timer timer = Timer.getTimer("repositoryView"); //$NON-NLS-1$
|
||||
timer.start();
|
||||
if (needInitialize) {
|
||||
monitorWrap = new EventLoopProgressMonitor(monitor);
|
||||
try {
|
||||
final ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
factory.initialize();
|
||||
} catch (Exception e) {
|
||||
throw new InvocationTargetException(e);
|
||||
while (true) {
|
||||
if (job.getResult() != null) {
|
||||
return;
|
||||
}
|
||||
Thread.sleep(200);
|
||||
}
|
||||
try {
|
||||
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||
} catch (CoreException e) {
|
||||
throw new InvocationTargetException(e);
|
||||
}
|
||||
// TODO Why do we need to recreate a root here ????
|
||||
// root = new ProjectRepositoryNode(null, null, ENodeType.STABLE_SYSTEM_FOLDER);
|
||||
|
||||
// unsetting the selection will prevent the propertyView from displaying dirty data
|
||||
viewer.setSelection(new TreeSelection());
|
||||
viewer.refresh();
|
||||
expandTreeRootIfOnlyOneRoot();
|
||||
}
|
||||
|
||||
if (PluginChecker.isJobLetPluginLoaded()) {
|
||||
IJobletProviderService jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault()
|
||||
.getService(IJobletProviderService.class);
|
||||
if (jobletService != null) {
|
||||
jobletService.loadComponentsFromProviders();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected ProgressMonitorDialog newProgressMonitorDialog(Shell shell) {
|
||||
return null;
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
// timer.print();
|
||||
@Override
|
||||
protected void openDialog(ProgressMonitorDialog dialog) {
|
||||
ProgressManager.getInstance().showInDialog(shell, job);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dialogRun(ProgressMonitorDialog dialog, IRunnableWithProgress op)
|
||||
throws InvocationTargetException, InterruptedException {
|
||||
// nothing to do
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
progressDialog.executeProcess();
|
||||
} catch (InvocationTargetException e) {
|
||||
ExceptionHandler.process(e);
|
||||
return;
|
||||
dialog.executeProcess();
|
||||
} catch (Exception e) {
|
||||
MessageBoxExceptionHandler.process(e);
|
||||
return;
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
// ============================================================================
|
||||
package org.talend.utils.sql;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.sql.Clob;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
@@ -138,4 +142,80 @@ public final class ResultSetUtils {
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get Object by special column index
|
||||
*
|
||||
* @param set
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws SQLException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Object getBigObject(ResultSet set, int columnIndex) throws SQLException {
|
||||
Object object = null;
|
||||
try {
|
||||
object = set.getObject(columnIndex);
|
||||
if (object != null && object instanceof Clob) {
|
||||
Reader is = ((Clob) object).getCharacterStream();
|
||||
BufferedReader br = new BufferedReader(is);
|
||||
String str = br.readLine();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
while (str != null) {
|
||||
sb.append(str);
|
||||
str = br.readLine();
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
if (NULLDATE.equals(set.getString(columnIndex))) {
|
||||
object = null;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
object = null;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get Object by special column index
|
||||
*
|
||||
* @param set
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws SQLException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Object getBigObject(ResultSet set, String columnName) throws SQLException {
|
||||
Object object = null;
|
||||
try {
|
||||
object = set.getObject(columnName);
|
||||
if (object != null && object instanceof Clob) {
|
||||
Reader is = ((Clob) object).getCharacterStream();
|
||||
BufferedReader br = new BufferedReader(is);
|
||||
String str = br.readLine();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
while (str != null) {
|
||||
sb.append(str);
|
||||
str = br.readLine();
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
if (NULLDATE.equals(set.getString(columnName))) {
|
||||
object = null;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
object = null;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,11 +12,15 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.runtime.preference;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
@@ -146,4 +150,16 @@ public class ProjectPreferenceManagerTest {
|
||||
Assert.assertEquals(false, readProjectPrefManager.getBoolean("xxx"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReload() {
|
||||
String testQualifier = getTestQualifier("TEST");
|
||||
ProjectPreferenceManager projectPrefManager = new ProjectPreferenceManager(testQualifier);
|
||||
IPreferenceStore originalStore = projectPrefManager.getPreferenceStore();
|
||||
ProjectScope originalScope = projectPrefManager.getProjectScope();
|
||||
projectPrefManager.reload();
|
||||
assertNotEquals(projectPrefManager.getProjectScope(), originalScope);
|
||||
assertNotEquals(projectPrefManager.getPreferenceStore(), originalStore);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.ProjectReference;
|
||||
import org.talend.core.model.properties.impl.PropertiesFactoryImpl;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Kevin Wang
|
||||
*
|
||||
*/
|
||||
public class ProjectManagerTest {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Project project = ProjectManager.getInstance().getCurrentProject();
|
||||
String mainBranch = "branches/a2";
|
||||
List<ProjectReference> referenceList = new ArrayList<ProjectReference>();
|
||||
|
||||
ProjectReference refProject1 = PropertiesFactoryImpl.eINSTANCE.createProjectReference();
|
||||
refProject1.setBranch("projectBranch");
|
||||
refProject1.setReferencedBranch("refBranch");
|
||||
Project rProject1 = new Project(PropertiesFactoryImpl.eINSTANCE.createProject());
|
||||
rProject1.setTechnicalLabel("refProject1");
|
||||
refProject1.setProject(project.getEmfProject());
|
||||
refProject1.setReferencedProject(rProject1.getEmfProject());
|
||||
|
||||
ProjectReference refProject2 = PropertiesFactoryImpl.eINSTANCE.createProjectReference();
|
||||
refProject2.setBranch("projectBranch");
|
||||
refProject2.setReferencedBranch("refBranch");
|
||||
Project rProject2 = new Project(PropertiesFactoryImpl.eINSTANCE.createProject());
|
||||
rProject2.setTechnicalLabel("refProject2");
|
||||
refProject2.setProject(project.getEmfProject());
|
||||
refProject2.setReferencedProject(rProject2.getEmfProject());
|
||||
|
||||
referenceList.add(refProject1);
|
||||
referenceList.add(refProject2);
|
||||
|
||||
ProjectManager.getInstance().setLocalRefBranch(project.getEmfProject(), mainBranch, referenceList);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAndGetLocalRefBranch() {
|
||||
Project project = ProjectManager.getInstance().getCurrentProject();
|
||||
String mainBranch = "branches/a2";
|
||||
|
||||
List<ProjectReference> referenceList = new ArrayList<ProjectReference>();
|
||||
ProjectReference refProject1 = PropertiesFactoryImpl.eINSTANCE.createProjectReference();
|
||||
refProject1.setBranch("projectBranch");
|
||||
refProject1.setReferencedBranch("refBranch");
|
||||
Project rProject1 = new Project(PropertiesFactoryImpl.eINSTANCE.createProject());
|
||||
rProject1.setTechnicalLabel("refProject1");
|
||||
refProject1.setProject(project.getEmfProject());
|
||||
refProject1.setReferencedProject(rProject1.getEmfProject());
|
||||
|
||||
ProjectReference refProject2 = PropertiesFactoryImpl.eINSTANCE.createProjectReference();
|
||||
refProject2.setBranch("projectBranch");
|
||||
refProject2.setReferencedBranch("refBranch");
|
||||
Project rProject2 = new Project(PropertiesFactoryImpl.eINSTANCE.createProject());
|
||||
rProject2.setTechnicalLabel("refProject2");
|
||||
refProject2.setProject(project.getEmfProject());
|
||||
refProject2.setReferencedProject(rProject2.getEmfProject());
|
||||
|
||||
referenceList.add(refProject1);
|
||||
referenceList.add(refProject2);
|
||||
|
||||
ProjectManager.getInstance().setLocalRefBranch(project.getEmfProject(), mainBranch, referenceList);
|
||||
|
||||
Assert.assertEquals("projectBranch",
|
||||
ProjectManager.getInstance().getLocalProjectReferenceBranch(project.getEmfProject(), mainBranch, refProject1));
|
||||
Assert.assertEquals("refBranch", ProjectManager.getInstance()
|
||||
.getLocalProjectReferenceReferenceBranch(project.getEmfProject(), mainBranch, refProject1));
|
||||
|
||||
ProjectManager.getInstance().deleteLocalRefBranchSetting(project.getEmfProject(), mainBranch);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteLocalRefBranchSetting() {
|
||||
Project project = ProjectManager.getInstance().getCurrentProject();
|
||||
String mainBranch = "branches/a2";
|
||||
List<ProjectReference> referenceList = new ArrayList<ProjectReference>();
|
||||
|
||||
ProjectReference refProject1 = PropertiesFactoryImpl.eINSTANCE.createProjectReference();
|
||||
refProject1.setBranch("projectBranch");
|
||||
refProject1.setReferencedBranch("refBranch");
|
||||
Project rProject1 = new Project(PropertiesFactoryImpl.eINSTANCE.createProject());
|
||||
rProject1.setTechnicalLabel("refProject1");
|
||||
refProject1.setProject(project.getEmfProject());
|
||||
refProject1.setReferencedProject(rProject1.getEmfProject());
|
||||
|
||||
ProjectReference refProject2 = PropertiesFactoryImpl.eINSTANCE.createProjectReference();
|
||||
refProject2.setBranch("projectBranch");
|
||||
refProject2.setReferencedBranch("refBranch");
|
||||
Project rProject2 = new Project(PropertiesFactoryImpl.eINSTANCE.createProject());
|
||||
rProject2.setTechnicalLabel("refProject2");
|
||||
refProject2.setProject(project.getEmfProject());
|
||||
refProject2.setReferencedProject(rProject2.getEmfProject());
|
||||
|
||||
referenceList.add(refProject1);
|
||||
referenceList.add(refProject2);
|
||||
|
||||
ProjectManager.getInstance().setLocalRefBranch(project.getEmfProject(), mainBranch, referenceList);
|
||||
ProjectManager.getInstance().deleteLocalRefBranchSetting(project.getEmfProject(), mainBranch);
|
||||
|
||||
Assert.assertNull(
|
||||
ProjectManager.getInstance().getLocalProjectReferenceBranch(project.getEmfProject(), "refBranch", refProject1));
|
||||
Assert.assertNull(
|
||||
ProjectManager.getInstance().getLocalProjectReferenceBranch(project.getEmfProject(), "refBranch", refProject2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidReferenceProject() {
|
||||
Project project = ProjectManager.getInstance().getCurrentProject();
|
||||
String mainBranch = "branches/a2";
|
||||
ProjectManager.getInstance().setMainProjectBranch(project, mainBranch);
|
||||
|
||||
List<ProjectReference> referenceList = new ArrayList<ProjectReference>();
|
||||
ProjectReference refProject1 = PropertiesFactoryImpl.eINSTANCE.createProjectReference();
|
||||
refProject1.setBranch("projectBranch");
|
||||
refProject1.setReferencedBranch("refBranch");
|
||||
Project rProject1 = new Project(PropertiesFactoryImpl.eINSTANCE.createProject());
|
||||
rProject1.setTechnicalLabel("refProject1");
|
||||
refProject1.setProject(project.getEmfProject());
|
||||
refProject1.setReferencedProject(rProject1.getEmfProject());
|
||||
|
||||
ProjectReference refProject2 = PropertiesFactoryImpl.eINSTANCE.createProjectReference();
|
||||
refProject2.setBranch("projectBranch");
|
||||
refProject2.setReferencedBranch("refBranch");
|
||||
Project rProject2 = new Project(PropertiesFactoryImpl.eINSTANCE.createProject());
|
||||
rProject2.setTechnicalLabel("refProject2");
|
||||
refProject2.setProject(project.getEmfProject());
|
||||
refProject2.setReferencedProject(rProject2.getEmfProject());
|
||||
|
||||
referenceList.add(refProject1);
|
||||
referenceList.add(refProject2);
|
||||
|
||||
ProjectManager.getInstance().setLocalRefBranch(project.getEmfProject(), mainBranch, referenceList);
|
||||
|
||||
Assert.assertTrue(ProjectManager.validReferenceProject(project.getEmfProject(), refProject1));
|
||||
Assert.assertTrue(ProjectManager.validReferenceProject(project.getEmfProject(), refProject2));
|
||||
|
||||
ProjectManager.getInstance().deleteLocalRefBranchSetting(project.getEmfProject(), mainBranch);
|
||||
|
||||
}
|
||||
|
||||
public void testgetCleanBranchName() {
|
||||
String branch = "branches/a2";
|
||||
Assert.assertEquals("a2", ProjectManager.getCleanBranchName(branch));
|
||||
|
||||
String branch1 = "origin/a2";
|
||||
Assert.assertEquals("a2", ProjectManager.getCleanBranchName(branch1));
|
||||
|
||||
String branch2 = "origin/master";
|
||||
Assert.assertEquals("master", ProjectManager.getCleanBranchName(branch2));
|
||||
|
||||
String branchMaster = "master";
|
||||
Assert.assertEquals("master", ProjectManager.getCleanBranchName(branchMaster));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.template;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.runtime.projectsetting.ProjectPreferenceManager;
|
||||
import org.talend.designer.maven.DesignerMavenPlugin;
|
||||
import org.talend.repository.ProjectManager;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
*/
|
||||
public class AbstractMavenTemplateManagerTest {
|
||||
|
||||
class MavenTemplateManagerTestClass extends AbstractMavenTemplateManager {
|
||||
|
||||
MavenTemplateManagerTestClass() {
|
||||
this.bundleName = DesignerMavenPlugin.PLUGIN_ID;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getProjectPreferenceManager_empty() throws Exception {
|
||||
MavenTemplateManagerTestClass templateManager = new MavenTemplateManagerTestClass();
|
||||
final ProjectPreferenceManager defaultPreferenceManager = templateManager.getProjectPreferenceManager();
|
||||
Assert.assertNotNull(defaultPreferenceManager);
|
||||
|
||||
// null parameter
|
||||
ProjectPreferenceManager projectPreferenceManager = templateManager.getProjectPreferenceManager(null);
|
||||
Assert.assertNotNull(projectPreferenceManager);
|
||||
// still default one
|
||||
Assert.assertEquals(projectPreferenceManager.getProject().getName(), defaultPreferenceManager.getProject().getName());
|
||||
|
||||
// empty parameter
|
||||
projectPreferenceManager = templateManager.getProjectPreferenceManager(Collections.emptyMap());
|
||||
Assert.assertNotNull(projectPreferenceManager);
|
||||
// still default one
|
||||
Assert.assertEquals(projectPreferenceManager.getProject().getName(), defaultPreferenceManager.getProject().getName());
|
||||
|
||||
Map<String, Object> parameter = new HashMap<String, Object>();
|
||||
|
||||
parameter.put(MavenTemplateManager.KEY_PROJECT_NAME, null);
|
||||
projectPreferenceManager = templateManager.getProjectPreferenceManager(parameter);
|
||||
Assert.assertNotNull(projectPreferenceManager);
|
||||
// still default one
|
||||
Assert.assertEquals(projectPreferenceManager.getProject().getName(), defaultPreferenceManager.getProject().getName());
|
||||
|
||||
parameter.put(MavenTemplateManager.KEY_PROJECT_NAME, "");
|
||||
projectPreferenceManager = templateManager.getProjectPreferenceManager(parameter);
|
||||
Assert.assertNotNull(projectPreferenceManager);
|
||||
// still default one
|
||||
Assert.assertEquals(projectPreferenceManager.getProject().getName(), defaultPreferenceManager.getProject().getName());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getProjectPreferenceManager_currentProject() throws Exception {
|
||||
MavenTemplateManagerTestClass templateManager = new MavenTemplateManagerTestClass();
|
||||
final ProjectPreferenceManager defaultPreferenceManager = templateManager.getProjectPreferenceManager();
|
||||
Assert.assertNotNull(defaultPreferenceManager);
|
||||
|
||||
Map<String, Object> parameter = new HashMap<String, Object>();
|
||||
final String curTechnicalLabel = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
parameter.put(MavenTemplateManager.KEY_PROJECT_NAME, curTechnicalLabel);
|
||||
|
||||
ProjectPreferenceManager projectPreferenceManager = templateManager.getProjectPreferenceManager(parameter);
|
||||
Assert.assertNotNull(projectPreferenceManager);
|
||||
|
||||
Assert.assertEquals(defaultPreferenceManager.getProject().getName(), projectPreferenceManager.getProject().getName());
|
||||
Assert.assertEquals(curTechnicalLabel, projectPreferenceManager.getProject().getName());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getProjectPreferenceManager_referenceProject() throws Exception {
|
||||
MavenTemplateManagerTestClass templateManager = new MavenTemplateManagerTestClass() {
|
||||
|
||||
// get one fake one, and make sure no exception
|
||||
protected IProject getProject(String techName) throws PersistenceException {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IProject project = workspace.getRoot().getProject(techName);
|
||||
return project;
|
||||
}
|
||||
};
|
||||
final ProjectPreferenceManager defaultPreferenceManager = templateManager.getProjectPreferenceManager();
|
||||
Assert.assertNotNull(defaultPreferenceManager);
|
||||
|
||||
Map<String, Object> parameter = new HashMap<String, Object>();
|
||||
parameter.put(MavenTemplateManager.KEY_PROJECT_NAME, "ABC_TEST");
|
||||
|
||||
ProjectPreferenceManager projectPreferenceManager = templateManager.getProjectPreferenceManager(parameter);
|
||||
Assert.assertNotNull(projectPreferenceManager);
|
||||
|
||||
Assert.assertEquals("ABC_TEST", projectPreferenceManager.getProject().getName());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.utils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.process.JobInfo;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.repository.ProjectManager;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
*/
|
||||
public class PomIdsHelperTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void test_getProjectGroupId_empty() {
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
String expectValue = "org.talend.master";
|
||||
if (currentProject != null) {
|
||||
expectValue = expectValue + '.' + currentProject.getTechnicalLabel().toLowerCase();
|
||||
}
|
||||
String projectGroupId = PomIdsHelper.getProjectGroupId();
|
||||
Assert.assertNotNull(projectGroupId);
|
||||
Assert.assertEquals(expectValue, projectGroupId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getCodesGroupId_default() {
|
||||
final String technicalLabel = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
|
||||
String codesGroupId = PomIdsHelper.getCodesGroupId("abc");
|
||||
Assert.assertNotNull(codesGroupId);
|
||||
Assert.assertEquals("org.talend.abc." + technicalLabel.toLowerCase(), codesGroupId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getCodesGroupId() {
|
||||
String codesGroupId = PomIdsHelper.getCodesGroupId("pro", "abc");
|
||||
Assert.assertNotNull(codesGroupId);
|
||||
Assert.assertEquals("org.talend.abc.pro", codesGroupId);
|
||||
|
||||
codesGroupId = PomIdsHelper.getCodesGroupId("PRO", "abc");
|
||||
Assert.assertNotNull(codesGroupId);
|
||||
Assert.assertEquals("org.talend.abc.pro", codesGroupId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getJobGroupId_empty() {
|
||||
String jobGroupId = PomIdsHelper.getJobGroupId((String) null);
|
||||
Assert.assertNotNull(jobGroupId);
|
||||
Assert.assertEquals("org.talend.job", jobGroupId);
|
||||
|
||||
jobGroupId = PomIdsHelper.getJobGroupId("");
|
||||
Assert.assertNotNull(jobGroupId);
|
||||
Assert.assertEquals("org.talend.job", jobGroupId);
|
||||
|
||||
jobGroupId = PomIdsHelper.getJobGroupId(" ");
|
||||
Assert.assertNotNull(jobGroupId);
|
||||
Assert.assertEquals("org.talend.job", jobGroupId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getJobGroupId() {
|
||||
String jobGroupId = PomIdsHelper.getJobGroupId("abc");
|
||||
Assert.assertNotNull(jobGroupId);
|
||||
Assert.assertEquals("org.talend.job.abc", jobGroupId);
|
||||
|
||||
jobGroupId = PomIdsHelper.getJobGroupId(" abc ");
|
||||
Assert.assertNotNull(jobGroupId);
|
||||
Assert.assertEquals("org.talend.job.abc", jobGroupId);
|
||||
|
||||
jobGroupId = PomIdsHelper.getJobGroupId(" AbC ");
|
||||
Assert.assertNotNull(jobGroupId);
|
||||
Assert.assertEquals("org.talend.job.abc", jobGroupId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getTestGroupId_empty() {
|
||||
String testGroupId = PomIdsHelper.getTestGroupId((String) null);
|
||||
Assert.assertNotNull(testGroupId);
|
||||
Assert.assertEquals("org.talend.test", testGroupId);
|
||||
|
||||
testGroupId = PomIdsHelper.getTestGroupId("");
|
||||
Assert.assertNotNull(testGroupId);
|
||||
Assert.assertEquals("org.talend.test", testGroupId);
|
||||
|
||||
testGroupId = PomIdsHelper.getTestGroupId(" ");
|
||||
Assert.assertNotNull(testGroupId);
|
||||
Assert.assertEquals("org.talend.test", testGroupId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getTestGroupId() {
|
||||
String testGroupId = PomIdsHelper.getTestGroupId("abc");
|
||||
Assert.assertNotNull(testGroupId);
|
||||
Assert.assertEquals("org.talend.test.abc", testGroupId);
|
||||
|
||||
testGroupId = PomIdsHelper.getTestGroupId(" abc ");
|
||||
Assert.assertNotNull(testGroupId);
|
||||
Assert.assertEquals("org.talend.test.abc", testGroupId);
|
||||
|
||||
testGroupId = PomIdsHelper.getTestGroupId(" AbC ");
|
||||
Assert.assertNotNull(testGroupId);
|
||||
Assert.assertEquals("org.talend.test.abc", testGroupId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getJobArtifactId_Property_null() {
|
||||
String jobArtifactId = PomIdsHelper.getJobArtifactId((Property) null);
|
||||
Assert.assertNull(jobArtifactId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getJobArtifactId_Property() {
|
||||
Property property = PropertiesFactory.eINSTANCE.createProperty();
|
||||
|
||||
property.setLabel("Hello");
|
||||
String jobArtifactId = PomIdsHelper.getJobArtifactId(property);
|
||||
Assert.assertNotNull(jobArtifactId);
|
||||
Assert.assertEquals("Hello", jobArtifactId);
|
||||
|
||||
property.setLabel("Hello ");
|
||||
jobArtifactId = PomIdsHelper.getJobArtifactId(property);
|
||||
Assert.assertNotNull(jobArtifactId);
|
||||
Assert.assertEquals("Hello_", jobArtifactId);
|
||||
|
||||
property.setLabel(" H ello ");
|
||||
jobArtifactId = PomIdsHelper.getJobArtifactId(property);
|
||||
Assert.assertNotNull(jobArtifactId);
|
||||
Assert.assertEquals("_H_ello_", jobArtifactId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getJobArtifactId_JobInfo_null() {
|
||||
String jobArtifactId = PomIdsHelper.getJobArtifactId((JobInfo) null);
|
||||
Assert.assertNull(jobArtifactId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getJobArtifactId_JobInfo() {
|
||||
class JobInfoTestClss extends JobInfo {
|
||||
|
||||
String jobName;
|
||||
|
||||
public JobInfoTestClss(String jobName) {
|
||||
super("123", "Default", "1.1");
|
||||
this.jobName = jobName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJobName() {
|
||||
return jobName;
|
||||
}
|
||||
}
|
||||
|
||||
JobInfoTestClss jobInfo = new JobInfoTestClss("World");
|
||||
String jobArtifactId = PomIdsHelper.getJobArtifactId(jobInfo);
|
||||
Assert.assertNotNull(jobArtifactId);
|
||||
Assert.assertEquals("World", jobArtifactId);
|
||||
|
||||
jobInfo = new JobInfoTestClss("World ");
|
||||
jobArtifactId = PomIdsHelper.getJobArtifactId(jobInfo);
|
||||
Assert.assertNotNull(jobArtifactId);
|
||||
Assert.assertEquals("World_", jobArtifactId);
|
||||
|
||||
jobInfo = new JobInfoTestClss("Wo rld ");
|
||||
jobArtifactId = PomIdsHelper.getJobArtifactId(jobInfo);
|
||||
Assert.assertNotNull(jobArtifactId);
|
||||
Assert.assertEquals("Wo_rld_", jobArtifactId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,9 @@
|
||||
package org.talend.designer.maven.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
@@ -23,9 +26,13 @@ import org.junit.Test;
|
||||
import org.ops4j.pax.url.mvn.MavenResolver;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
import org.talend.designer.runprocess.IProcessor;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.utils.io.FilesUtils;
|
||||
|
||||
@@ -290,4 +297,61 @@ public class PomUtilTest {
|
||||
Assert.assertTrue(pomFile.exists());
|
||||
FilesUtils.deleteFolder(pomFile.getParentFile(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTemplateParameters_IProcessor_null() {
|
||||
Map<String, Object> templateParameters = PomUtil.getTemplateParameters((IProcessor) null);
|
||||
Assert.assertNotNull(templateParameters);
|
||||
Assert.assertEquals(0, templateParameters.size());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTemplateParameters_Property_null() {
|
||||
Map<String, Object> templateParameters = PomUtil.getTemplateParameters((Property) null);
|
||||
Assert.assertNotNull(templateParameters);
|
||||
Assert.assertEquals(0, templateParameters.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTemplateParameters_Property_noeResourse() {
|
||||
Property p = PropertiesFactory.eINSTANCE.createProperty();
|
||||
Map<String, Object> templateParameters = PomUtil.getTemplateParameters(p);
|
||||
Assert.assertNotNull(templateParameters);
|
||||
Assert.assertEquals(0, templateParameters.size());
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void testGetTemplateParameters_Property_reference() {
|
||||
// can't test, except use mock way, because need mock one reference project.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProjectNameFromTemplateParameter_empty() {
|
||||
final String currentProjectName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
|
||||
String projectName = PomUtil.getProjectNameFromTemplateParameter(null);
|
||||
Assert.assertNotNull(projectName);
|
||||
Assert.assertEquals(currentProjectName, projectName);
|
||||
|
||||
projectName = PomUtil.getProjectNameFromTemplateParameter(Collections.emptyMap());
|
||||
Assert.assertNotNull(projectName);
|
||||
Assert.assertEquals(currentProjectName, projectName);
|
||||
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
parameters.put(MavenTemplateManager.KEY_PROJECT_NAME, "");
|
||||
projectName = PomUtil.getProjectNameFromTemplateParameter(parameters);
|
||||
Assert.assertNotNull(projectName);
|
||||
Assert.assertEquals(currentProjectName, projectName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProjectNameFromTemplateParameter_diff() {
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
parameters.put(MavenTemplateManager.KEY_PROJECT_NAME, "ABC");
|
||||
String projectName = PomUtil.getProjectNameFromTemplateParameter(parameters);
|
||||
Assert.assertNotNull(projectName);
|
||||
Assert.assertEquals("ABC", projectName);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user