Compare commits
80 Commits
release/7.
...
patch/7.0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a16cf3e274 | ||
|
|
f8a2fdc438 | ||
|
|
5b4267e251 | ||
|
|
30f0f163c4 | ||
|
|
af04a91e97 | ||
|
|
85a09d324c | ||
|
|
582f8b2469 | ||
|
|
1e5157cbd2 | ||
|
|
1b682fe5bc | ||
|
|
c8e1c54aac | ||
|
|
a96615ef09 | ||
|
|
a98a976cd0 | ||
|
|
6b103fd3ac | ||
|
|
30b87e0681 | ||
|
|
838a8a6684 | ||
|
|
351b9a4b4a | ||
|
|
0dee4713dc | ||
|
|
828eb43a7b | ||
|
|
0a6bedba28 | ||
|
|
a34a0a88fd | ||
|
|
819ee6502b | ||
|
|
f35f205c3b | ||
|
|
c4fe7035b5 | ||
|
|
a2d1786ea8 | ||
|
|
051fe3e48a | ||
|
|
d31b682b28 | ||
|
|
bae2cad315 | ||
|
|
9343adeb4a | ||
|
|
6d7b654b34 | ||
|
|
e87525b0e6 | ||
|
|
29003ebd3c | ||
|
|
1e99439aba | ||
|
|
8be5155c69 | ||
|
|
73e605aa4a | ||
|
|
99be76ceed | ||
|
|
7aebd682b2 | ||
|
|
d29a0aaec8 | ||
|
|
5bc4661370 | ||
|
|
fa7893c4f4 | ||
|
|
9477f854bc | ||
|
|
b2eb124c04 | ||
|
|
2eea07a83a | ||
|
|
1ef455ed31 | ||
|
|
cb77c21385 | ||
|
|
8555dcd8ad | ||
|
|
9d6e03f249 | ||
|
|
f848b4ed2d | ||
|
|
102714f19a | ||
|
|
358d645e99 | ||
|
|
4447d4bb50 | ||
|
|
a881130b33 | ||
|
|
26059bd79c | ||
|
|
83080b21d7 | ||
|
|
cf38315b5e | ||
|
|
da5691927a | ||
|
|
c9b1ba680c | ||
|
|
cbb807dff3 | ||
|
|
69b7590e99 | ||
|
|
355a4ee886 | ||
|
|
275a642076 | ||
|
|
f1fbc5de20 | ||
|
|
8375532c95 | ||
|
|
aad98ef225 | ||
|
|
4578c50f6b | ||
|
|
be4188b258 | ||
|
|
1cf4d5386b | ||
|
|
06c055c9d2 | ||
|
|
4bc73e655a | ||
|
|
ff57acfe20 | ||
|
|
69f1e32d4d | ||
|
|
8c377775c2 | ||
|
|
46b305e505 | ||
|
|
a03ebdeffd | ||
|
|
c3d592e3f1 | ||
|
|
314cdd7303 | ||
|
|
f36c57fa9b | ||
|
|
f4c00362bb | ||
|
|
5570790394 | ||
|
|
786e647bce | ||
|
|
3592bfdc5d |
@@ -14,6 +14,7 @@ package org.talend.commons.ui.gmf.util;
|
||||
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
import org.eclipse.swt.graphics.DeviceData;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
@@ -111,23 +112,38 @@ public class DisplayUtils {
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void syncExecInNewUIThread(Runnable runnable) throws Exception {
|
||||
syncExecInNewUIThread(runnable, null);
|
||||
}
|
||||
|
||||
public static void syncExecInNewUIThread(Runnable runnable, DeviceData deviceData) throws Exception {
|
||||
final Semaphore semaphore = new Semaphore(1, true);
|
||||
semaphore.acquire();
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Display display = new Display();
|
||||
Display display = null;
|
||||
if (deviceData == null) {
|
||||
display = new Display();
|
||||
} else {
|
||||
display = new Display(deviceData);
|
||||
}
|
||||
try {
|
||||
Thread currentThread = Thread.currentThread();
|
||||
boolean releasedLock = false;
|
||||
while (!currentThread.isInterrupted()) {
|
||||
if (!display.readAndDispatch()) {
|
||||
if (!releasedLock) {
|
||||
semaphore.release();
|
||||
releasedLock = true;
|
||||
try {
|
||||
if (!display.readAndDispatch()) {
|
||||
if (!releasedLock) {
|
||||
semaphore.release();
|
||||
releasedLock = true;
|
||||
}
|
||||
Thread.sleep(50);
|
||||
}
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.eclipse.ui.IWorkbenchPart;
|
||||
* $Id: ITreeContextualAction.java 7196 2007-11-26 04:19:19Z bqian $
|
||||
*
|
||||
*/
|
||||
public interface ITreeContextualAction extends IAction {
|
||||
public interface ITreeContextualAction extends IAction, Cloneable {
|
||||
|
||||
/**
|
||||
* Initialise the action on a given tree with the actual selection.<br/>
|
||||
@@ -76,4 +76,6 @@ public interface ITreeContextualAction extends IAction {
|
||||
public void setGroupId(String groupId);
|
||||
|
||||
public String getGroupId();
|
||||
|
||||
public ITreeContextualAction clone() throws CloneNotSupportedException;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -2,20 +2,10 @@ package org.talend.core.repository.logintask;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceDescription;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.utils.time.TimeMeasure;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ICoreService;
|
||||
import org.talend.core.repository.i18n.Messages;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.login.AbstractLoginTask;
|
||||
import org.talend.repository.ProjectManager;
|
||||
|
||||
@@ -30,56 +20,7 @@ public class SyncLibrariesLoginTask extends AbstractLoginTask implements IRunnab
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
TimeMeasure.display = CommonsPlugin.isDebugMode();
|
||||
TimeMeasure.displaySteps = CommonsPlugin.isDebugMode();
|
||||
TimeMeasure.measureActive = CommonsPlugin.isDebugMode();
|
||||
|
||||
TimeMeasure.begin("SyncLibraries");
|
||||
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, 1);
|
||||
SubMonitor currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.synchronizeLibraries"), 1); //$NON-NLS-1$
|
||||
coreService.syncLibraries(currentMonitor);
|
||||
TimeMeasure.step("SyncLibraries", "sync components libraries");
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
// remove the auto-build to enhance the build speed and application's use
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IWorkspaceDescription description = workspace.getDescription();
|
||||
description.setAutoBuilding(false);
|
||||
try {
|
||||
workspace.setDescription(description);
|
||||
} catch (CoreException e) {
|
||||
// do nothing
|
||||
}
|
||||
coreService.createStatsLogAndImplicitParamter(ProjectManager.getInstance().getCurrentProject());
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
IRunProcessService runProcessService = getRunProcessService();
|
||||
if (runProcessService != null) {
|
||||
runProcessService.initializeRootPoms();
|
||||
}
|
||||
TimeMeasure.end("SyncLibraries");
|
||||
TimeMeasure.display = false;
|
||||
TimeMeasure.displaySteps = false;
|
||||
TimeMeasure.measureActive = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC nrousseau Comment method "getRunProcessService".
|
||||
* @return
|
||||
*/
|
||||
private IRunProcessService getRunProcessService() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
return (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -326,4 +326,14 @@ public abstract class AbstractRepositoryFactory implements IRepositoryFactory {
|
||||
public void setStorage(String storage) {
|
||||
this.storage = storage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepositoryBusy() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryWorkUnit getWorkUnitInProgress() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,6 +432,13 @@ public interface IRepositoryFactory {
|
||||
public List<ILockBean> getAllRemoteLocks();
|
||||
|
||||
public void loadProjectAndSetContext(IProject eclipseProject) throws PersistenceException;
|
||||
|
||||
public void loadProjectAndSetContext(Project project, IProject eclipseProject, boolean updateCurrentProject)
|
||||
throws PersistenceException;
|
||||
|
||||
public byte[] getReferenceSettingContent(Project project, String branch) throws PersistenceException;
|
||||
|
||||
public boolean isRepositoryBusy();
|
||||
|
||||
public RepositoryWorkUnit getWorkUnitInProgress();
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ import org.talend.core.ICoreService;
|
||||
import org.talend.core.IESBService;
|
||||
import org.talend.core.ITDQRepositoryService;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.context.CommandLineContext;
|
||||
import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.exception.TalendInternalPersistenceException;
|
||||
@@ -1585,6 +1586,11 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
this.repositoryFactoryFromProvider.loadProjectAndSetContext(eclipseProject);
|
||||
}
|
||||
|
||||
public void loadProjectAndSetContext(Project project, IProject eclipseProject, boolean updateCurrentProject)
|
||||
throws PersistenceException {
|
||||
this.repositoryFactoryFromProvider.loadProjectAndSetContext(project, eclipseProject, updateCurrentProject);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC smallet Comment method "emptyTempFolder".
|
||||
*
|
||||
@@ -1862,8 +1868,8 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
return this.repositoryFactoryFromProvider.getModulesNeededForJobs();
|
||||
}
|
||||
|
||||
private void initEmfProjectContent() throws PersistenceException, BusinessException {
|
||||
getRepositoryContext().setProject(null);
|
||||
@Override
|
||||
public void initEmfProjectContent() throws PersistenceException, BusinessException {
|
||||
Project[] projects = readProject();
|
||||
emfProjectContentMap.clear();
|
||||
if (projects != null && projects.length > 0) {
|
||||
@@ -1908,6 +1914,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
SubMonitor currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.logonInProgress"), 1); //$NON-NLS-1$
|
||||
project.setReferenceProjectProvider(null);
|
||||
getRepositoryContext().setProject(null);
|
||||
initEmfProjectContent();
|
||||
if (getEmfProjectContent(project.getTechnicalLabel()) != null) {
|
||||
project.setEmfProject(getEmfProjectContent(project.getTechnicalLabel()));
|
||||
@@ -1942,6 +1949,14 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
}
|
||||
}
|
||||
|
||||
ICoreService coreService = getCoreService();
|
||||
if (coreService != null) {
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.synchronizeLibraries"), 1); //$NON-NLS-1$
|
||||
coreService.syncLibraries(currentMonitor);
|
||||
TimeMeasure.step("SyncLibraries", "sync components libraries"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask("Execute before logon migrations tasks", 1); //$NON-NLS-1$
|
||||
ProjectManager.getInstance().getMigrationRecords().clear();
|
||||
@@ -1987,7 +2002,13 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
ICoreService coreService = getCoreService();
|
||||
boolean isCommandLineLocalRefProject = false;
|
||||
CommandLineContext commandLineContext = (CommandLineContext) CoreRuntimePlugin.getInstance().getContext()
|
||||
.getProperty(Context.COMMANDLINE_CONTEXT_KEY);
|
||||
if (commandLineContext != null && commandLineContext.isLogonRefProject()) {
|
||||
isCommandLineLocalRefProject = true;
|
||||
}
|
||||
|
||||
if (coreService != null) {
|
||||
// clean workspace
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.cleanWorkspace"), 1); //$NON-NLS-1$
|
||||
@@ -2016,12 +2037,14 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.synch.repo.items"), 1); //$NON-NLS-1$
|
||||
|
||||
try {
|
||||
coreService.syncAllRoutines();
|
||||
// PTODO need refactor later, this is not good, I think
|
||||
coreService.syncAllBeans();
|
||||
} catch (SystemException e1) {
|
||||
//
|
||||
if (!isCommandLineLocalRefProject) {
|
||||
try {
|
||||
coreService.syncAllRoutines();
|
||||
// PTODO need refactor later, this is not good, I think
|
||||
coreService.syncAllBeans();
|
||||
} catch (SystemException e1) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
@@ -2052,7 +2075,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
// ignore
|
||||
}
|
||||
|
||||
if (runProcessService != null) {
|
||||
if (runProcessService != null && !isCommandLineLocalRefProject) {
|
||||
runProcessService.initializeRootPoms();
|
||||
|
||||
TimeMeasure.step("logOnProject", "install / setup root poms"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
@@ -2459,4 +2482,12 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
public byte[] getReferenceSettingContent(Project project, String branch) throws PersistenceException {
|
||||
return repositoryFactoryFromProvider.getReferenceSettingContent(project, branch);
|
||||
}
|
||||
|
||||
public boolean isRepositoryBusy() {
|
||||
return repositoryFactoryFromProvider.isRepositoryBusy();
|
||||
}
|
||||
|
||||
public RepositoryWorkUnit getWorkUnitInProgress() {
|
||||
return repositoryFactoryFromProvider.getWorkUnitInProgress();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,15 @@ package org.talend.core.repository.recyclebin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
@@ -50,20 +55,22 @@ import org.talend.repository.ProjectManager;
|
||||
*/
|
||||
public class RecycleBinManager {
|
||||
|
||||
private static Map<String, RecycleBin> projectRecyclebins;
|
||||
|
||||
public static final String TALEND_RECYCLE_BIN_INDEX = "recycle_bin.index"; //$NON-NLS-1$
|
||||
|
||||
private static RecycleBinManager manager;
|
||||
|
||||
private RecycleBinManager() {
|
||||
private Map<String, RecycleBin> projectRecyclebins;
|
||||
|
||||
private Map<RecycleBin, RecycleBin> lastSavedRecycleBinMap;
|
||||
|
||||
private RecycleBinManager() {
|
||||
lastSavedRecycleBinMap = new HashMap<>();
|
||||
projectRecyclebins = new HashMap<>();
|
||||
}
|
||||
|
||||
public static RecycleBinManager getInstance() {
|
||||
if (manager == null) {
|
||||
manager = new RecycleBinManager();
|
||||
projectRecyclebins = new HashMap<String, RecycleBin>();
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
@@ -74,11 +81,15 @@ public class RecycleBinManager {
|
||||
|
||||
public void clearCache() {
|
||||
projectRecyclebins.clear();
|
||||
lastSavedRecycleBinMap.clear();
|
||||
}
|
||||
|
||||
public void clearCache(Project project) {
|
||||
String projectTechnicalLabel = project.getTechnicalLabel();
|
||||
projectRecyclebins.remove(projectTechnicalLabel);
|
||||
RecycleBin removedRecycleBin = projectRecyclebins.remove(projectTechnicalLabel);
|
||||
if (removedRecycleBin != null) {
|
||||
lastSavedRecycleBinMap.remove(removedRecycleBin);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearIndex(Project project) {
|
||||
@@ -202,6 +213,13 @@ public class RecycleBinManager {
|
||||
// if there is any exception, just set a new resource
|
||||
projectRecyclebins.put(project.getTechnicalLabel(), RecycleBinFactory.eINSTANCE.createRecycleBin());
|
||||
}
|
||||
|
||||
RecycleBin recycleBin = projectRecyclebins.get(project.getTechnicalLabel());
|
||||
if (recycleBin != null) {
|
||||
RecycleBin lastSavedRecycleBin = EcoreUtil.copy(recycleBin);
|
||||
lastSavedRecycleBinMap.put(recycleBin, lastSavedRecycleBin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public RecycleBin loadRecycleBin(IPath recycleBinIndexPath) throws Exception {
|
||||
@@ -219,14 +237,25 @@ public class RecycleBinManager {
|
||||
loadRecycleBin(project);
|
||||
}
|
||||
try {
|
||||
RecycleBin recycleBin = projectRecyclebins.get(project.getTechnicalLabel());
|
||||
boolean recycleBinChanged = true;
|
||||
if (recycleBin != null) {
|
||||
recycleBinChanged = !equals(recycleBin, lastSavedRecycleBinMap.get(recycleBin));
|
||||
}
|
||||
|
||||
if (!recycleBinChanged) {
|
||||
return;
|
||||
}
|
||||
|
||||
Resource resource = getResource(project);
|
||||
if (resource == null) {
|
||||
resource = createRecycleBinResource(project);
|
||||
}
|
||||
resource.getContents().clear();
|
||||
projectRecyclebins.get(project.getTechnicalLabel()).setLastUpdate(new Date());
|
||||
resource.getContents().add(projectRecyclebins.get(project.getTechnicalLabel()));
|
||||
recycleBin.setLastUpdate(new Date());
|
||||
resource.getContents().add(recycleBin);
|
||||
EmfHelper.saveResource(resource);
|
||||
lastSavedRecycleBinMap.put(recycleBin, EcoreUtil.copy(recycleBin));
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
@@ -267,4 +296,123 @@ public class RecycleBinManager {
|
||||
resource.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
|
||||
return resource;
|
||||
}
|
||||
|
||||
public static boolean equals(RecycleBin r1, RecycleBin r2) {
|
||||
if (r1 == null && r2 == null) {
|
||||
return true;
|
||||
}
|
||||
if (r1 == null || r2 == null) {
|
||||
return false;
|
||||
}
|
||||
boolean isEquals = false;
|
||||
Set<String> r1DeletedFolders = new HashSet<>(r1.getDeletedFolders());
|
||||
Set<String> r2DeletedFolders = new HashSet<>(r2.getDeletedFolders());
|
||||
|
||||
/**
|
||||
* 1. check deleted folders
|
||||
*/
|
||||
if (r1DeletedFolders.size() == r2DeletedFolders.size()) {
|
||||
r1DeletedFolders.removeAll(r2DeletedFolders);
|
||||
if (r1DeletedFolders.isEmpty()) {
|
||||
isEquals = true;
|
||||
} else {
|
||||
isEquals = false;
|
||||
}
|
||||
} else {
|
||||
isEquals = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 2. check deleted items
|
||||
*/
|
||||
if (isEquals) {
|
||||
EList<TalendItem> r1DeletedItems = r1.getDeletedItems();
|
||||
EList<TalendItem> r2DeletedItems = r2.getDeletedItems();
|
||||
if (r1DeletedItems.size() == r2DeletedItems.size()) {
|
||||
List<TalendItem> r1DeletedItemList = new LinkedList<>(r1DeletedItems);
|
||||
List<TalendItem> r2DeletedItemList = new LinkedList<>(r2DeletedItems);
|
||||
TalendItemComparator talendItemComparator = new TalendItemComparator();
|
||||
r1DeletedItemList.sort(talendItemComparator);
|
||||
r2DeletedItemList.sort(talendItemComparator);
|
||||
Iterator<TalendItem> iter1 = r1DeletedItemList.iterator();
|
||||
Iterator<TalendItem> iter2 = r2DeletedItemList.iterator();
|
||||
boolean differentList = false;
|
||||
while (iter1.hasNext() && iter2.hasNext()) {
|
||||
TalendItem item1 = iter1.next();
|
||||
TalendItem item2 = iter2.next();
|
||||
if (talendItemComparator.compare(item1, item2) != 0) {
|
||||
differentList = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (differentList) {
|
||||
isEquals = false;
|
||||
} else {
|
||||
isEquals = true;
|
||||
}
|
||||
} else {
|
||||
isEquals = false;
|
||||
}
|
||||
}
|
||||
return isEquals;
|
||||
}
|
||||
|
||||
public static int compare(TalendItem item1, TalendItem item2) {
|
||||
if (item1 == null && item2 == null) {
|
||||
return 0;
|
||||
}
|
||||
if (item1 == null) {
|
||||
return -1;
|
||||
}
|
||||
if (item2 == null) {
|
||||
return 1;
|
||||
}
|
||||
int result = 0;
|
||||
|
||||
String type1 = item1.getType();
|
||||
String type2 = item2.getType();
|
||||
if (type1 == null) {
|
||||
type1 = "";
|
||||
}
|
||||
if (type2 == null) {
|
||||
type2 = "";
|
||||
}
|
||||
result = type1.compareTo(type2);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
String path1 = item1.getPath();
|
||||
String path2 = item2.getPath();
|
||||
if (path1 == null) {
|
||||
path1 = "";
|
||||
}
|
||||
if (path2 == null) {
|
||||
path2 = "";
|
||||
}
|
||||
result = path1.compareTo(path2);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
String id1 = item1.getId();
|
||||
String id2 = item2.getId();
|
||||
if (id1 == null) {
|
||||
id1 = "";
|
||||
}
|
||||
if (id2 == null) {
|
||||
id2 = "";
|
||||
}
|
||||
result = id1.compareTo(id2);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static class TalendItemComparator implements Comparator<TalendItem> {
|
||||
|
||||
@Override
|
||||
public int compare(TalendItem arg0, TalendItem arg1) {
|
||||
return RecycleBinManager.compare(arg0, arg1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2018 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.core.context;
|
||||
|
||||
public class CommandLineContext {
|
||||
|
||||
private boolean isLogonRefProject;
|
||||
|
||||
public boolean isLogonRefProject() {
|
||||
return isLogonRefProject;
|
||||
}
|
||||
|
||||
public void setLogonRefProject(boolean isLogonRefProject) {
|
||||
this.isLogonRefProject = isLogonRefProject;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,6 +33,8 @@ public final class Context {
|
||||
|
||||
public static final String REPOSITORY_CONTEXT_KEY = "repositoryContext"; //$NON-NLS-1$
|
||||
|
||||
public static final String COMMANDLINE_CONTEXT_KEY = "commandlineContext"; //$NON-NLS-1$
|
||||
|
||||
private static final String BREAKPOINTS = "BREAKPOINTS"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
|
||||
@@ -80,6 +80,16 @@ public class RepositoryContext {
|
||||
&& user.getGitAuthenticationInfo() == null) {
|
||||
oldGitAuthentification = this.user.getGitAuthenticationInfo();
|
||||
}
|
||||
String oldLdapId = null;
|
||||
if (this.user != null && user != null && StringUtils.equals(this.user.getLogin(), user.getLogin())
|
||||
&& user.getLdapId() == null) {
|
||||
oldLdapId = this.user.getLdapId();
|
||||
}
|
||||
String oldLdaplogin = null;
|
||||
if (this.user != null && user != null && StringUtils.equals(this.user.getLogin(), user.getLogin())
|
||||
&& user.getLdapLogin() == null) {
|
||||
oldLdaplogin = this.user.getLdapLogin();
|
||||
}
|
||||
this.user = user;
|
||||
if (oldAuthentification != null) {
|
||||
this.user.setAuthenticationInfo(oldAuthentification);
|
||||
@@ -87,6 +97,12 @@ public class RepositoryContext {
|
||||
if (oldGitAuthentification != null) {
|
||||
this.user.setGitAuthenticationInfo(oldGitAuthentification);
|
||||
}
|
||||
if (oldLdapId != null) {
|
||||
this.user.setLdapId(oldLdapId);
|
||||
}
|
||||
if (oldLdaplogin != null) {
|
||||
this.user.setLdapLogin(oldLdaplogin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,9 +68,9 @@ public enum EDatabaseVersion4Drivers {
|
||||
INFORMIX(new DbVersion4Drivers(EDatabaseTypeName.INFORMIX, "ifxjdbc.jar")), //$NON-NLS-1$
|
||||
|
||||
SAS_9_1(new DbVersion4Drivers(EDatabaseTypeName.SAS, "SAS 9.1", "SAS_9.1", new String[] { "sas.core.jar", //$NON-NLS-1$
|
||||
"sas.intrnet.javatools.jar", "sas.svc.connection.jar" })), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"sas.intrnet.javatools.jar", "sas.svc.connection.jar", "org.apache.log4j_1.2.15.v201012070815.jar" })), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
SAS_9_2(new DbVersion4Drivers(EDatabaseTypeName.SAS,
|
||||
"SAS 9.2", "SAS_9.2", new String[] { "sas.core.jar", "sas.security.sspi.jar", "sas.svc.connection.jar" })), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"SAS 9.2", "SAS_9.2", new String[] { "sas.core.jar", "sas.security.sspi.jar", "sas.svc.connection.jar", "org.apache.log4j_1.2.15.v201012070815.jar" })), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
SAPHana(new DbVersion4Drivers(EDatabaseTypeName.SAPHana, "HDB 1.0", "HDB_1_0", "ngdbc.jar")), //$NON-NLS-1$
|
||||
// MYSQL, add for 9594
|
||||
MYSQL_5(new DbVersion4Drivers(EDatabaseTypeName.MYSQL, "MySQL 5", "MYSQL_5", "mysql-connector-java-5.1.30-bin.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
@@ -46,6 +46,8 @@ public class ModuleNeeded {
|
||||
|
||||
private boolean required;
|
||||
|
||||
private boolean excluded;
|
||||
|
||||
private boolean mrRequired = false; // That indicates if the module is
|
||||
// required by M/R job.
|
||||
|
||||
@@ -293,6 +295,14 @@ public class ModuleNeeded {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public boolean isExcluded() {
|
||||
return this.excluded;
|
||||
}
|
||||
|
||||
public void setExcluded(boolean excluded) {
|
||||
this.excluded = excluded;
|
||||
}
|
||||
|
||||
public ELibraryInstallStatus getStatus() {
|
||||
ILibraryManagerService libManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
|
||||
@@ -45,6 +45,14 @@ public interface ISAPConstant {
|
||||
|
||||
public static final String CHANGING = "CHANGING";//$NON-NLS-1$
|
||||
|
||||
public static final String PARAMETER_TYPE = "PARAMETER_TYPE";//$NON-NLS-1$
|
||||
|
||||
public static final String PARAMETER_TYPE_IMPORT = "IMPORT";//$NON-NLS-1$
|
||||
|
||||
public static final String PARAMETER_TYPE_CHANGING = "CHANGING";//$NON-NLS-1$
|
||||
|
||||
public static final String PARAMETER_TYPE_TABLES = "TABLES";//$NON-NLS-1$
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -26,8 +26,9 @@ import org.apache.avro.SchemaBuilder.FieldBuilder;
|
||||
import org.apache.avro.SchemaBuilder.PropBuilder;
|
||||
import org.apache.avro.SchemaBuilder.RecordBuilder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Level;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.talend.commons.utils.data.list.UniqueStringGenerator;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ICoreService;
|
||||
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
|
||||
@@ -158,51 +159,58 @@ public final class MetadataToolAvroHelper {
|
||||
String tt = in.getTalendType();
|
||||
|
||||
Schema type = null;
|
||||
// Numeric types.
|
||||
if (JavaTypesManager.LONG.getId().equals(tt)) {
|
||||
type = AvroUtils._long();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Long.parseLong(defaultValue.toString());
|
||||
} else if (JavaTypesManager.INTEGER.getId().equals(tt)) {
|
||||
type = AvroUtils._int();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Integer.parseInt(defaultValue.toString());
|
||||
} else if (JavaTypesManager.SHORT.getId().equals(tt)) {
|
||||
type = AvroUtils._short();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Integer.parseInt(defaultValue.toString());
|
||||
} else if (JavaTypesManager.BYTE.getId().equals(tt)) {
|
||||
type = AvroUtils._byte();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Integer.parseInt(defaultValue.toString());
|
||||
} else if (JavaTypesManager.DOUBLE.getId().equals(tt)) {
|
||||
type = AvroUtils._double();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Double.parseDouble(defaultValue.toString());
|
||||
} else if (JavaTypesManager.FLOAT.getId().equals(tt)) {
|
||||
type = AvroUtils._float();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Float.parseFloat(defaultValue.toString());
|
||||
} else if (JavaTypesManager.BIGDECIMAL.getId().equals(tt)) {
|
||||
// decimal(precision, scale) == column length and precision?
|
||||
type = AvroUtils._decimal();
|
||||
}
|
||||
|
||||
// Other primitive types that map directly to Avro.
|
||||
else if (JavaTypesManager.BOOLEAN.getId().equals(tt)) {
|
||||
type = AvroUtils._boolean();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Boolean.parseBoolean(defaultValue.toString());
|
||||
} else if (JavaTypesManager.BYTE_ARRAY.getId().equals(tt)) {
|
||||
type = AvroUtils._bytes();
|
||||
} else if (JavaTypesManager.DATE.getId().equals(tt)) {
|
||||
if (matchTag(in, DiSchemaConstants.TALEND6_COLUMN_DATE_DATE)) {
|
||||
type = AvroUtils._logicalDate();
|
||||
} else if (matchTag(in, DiSchemaConstants.TALEND6_COLUMN_DATE_TIMESTAMP)) {
|
||||
type = AvroUtils._logicalTimestamp();
|
||||
} else {
|
||||
// FIXME - this one should go away
|
||||
type = AvroUtils._date();
|
||||
}
|
||||
}
|
||||
// String-ish types.
|
||||
else if (JavaTypesManager.STRING.getId().equals(tt) || JavaTypesManager.FILE.getId().equals(tt)
|
||||
|| JavaTypesManager.DIRECTORY.getId().equals(tt) || JavaTypesManager.VALUE_LIST.getId().equals(tt)
|
||||
|| JavaTypesManager.CHARACTER.getId().equals(tt) || JavaTypesManager.PASSWORD.getId().equals(tt)) {
|
||||
type = AvroUtils._string();
|
||||
|
||||
try {
|
||||
// Numeric types.
|
||||
if (JavaTypesManager.LONG.getId().equals(tt)) {
|
||||
type = AvroUtils._long();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Long.parseLong(defaultValue.toString());
|
||||
} else if (JavaTypesManager.INTEGER.getId().equals(tt)) {
|
||||
type = AvroUtils._int();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Integer.parseInt(defaultValue.toString());
|
||||
} else if (JavaTypesManager.SHORT.getId().equals(tt)) {
|
||||
type = AvroUtils._short();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Integer.parseInt(defaultValue.toString());
|
||||
} else if (JavaTypesManager.BYTE.getId().equals(tt)) {
|
||||
type = AvroUtils._byte();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Integer.parseInt(defaultValue.toString());
|
||||
} else if (JavaTypesManager.DOUBLE.getId().equals(tt)) {
|
||||
type = AvroUtils._double();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Double.parseDouble(defaultValue.toString());
|
||||
} else if (JavaTypesManager.FLOAT.getId().equals(tt)) {
|
||||
type = AvroUtils._float();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Float.parseFloat(defaultValue.toString());
|
||||
} else if (JavaTypesManager.BIGDECIMAL.getId().equals(tt)) {
|
||||
// decimal(precision, scale) == column length and precision?
|
||||
type = AvroUtils._decimal();
|
||||
}
|
||||
|
||||
// Other primitive types that map directly to Avro.
|
||||
else if (JavaTypesManager.BOOLEAN.getId().equals(tt)) {
|
||||
type = AvroUtils._boolean();
|
||||
defaultValue = StringUtils.isEmpty((String)defaultValue) ? null : Boolean.parseBoolean(defaultValue.toString());
|
||||
} else if (JavaTypesManager.BYTE_ARRAY.getId().equals(tt)) {
|
||||
type = AvroUtils._bytes();
|
||||
} else if (JavaTypesManager.DATE.getId().equals(tt)) {
|
||||
if (matchTag(in, DiSchemaConstants.TALEND6_COLUMN_DATE_DATE)) {
|
||||
type = AvroUtils._logicalDate();
|
||||
} else if (matchTag(in, DiSchemaConstants.TALEND6_COLUMN_DATE_TIMESTAMP)) {
|
||||
type = AvroUtils._logicalTimestamp();
|
||||
} else {
|
||||
// FIXME - this one should go away
|
||||
type = AvroUtils._date();
|
||||
}
|
||||
}
|
||||
// String-ish types.
|
||||
else if (JavaTypesManager.STRING.getId().equals(tt) || JavaTypesManager.FILE.getId().equals(tt)
|
||||
|| JavaTypesManager.DIRECTORY.getId().equals(tt) || JavaTypesManager.VALUE_LIST.getId().equals(tt)
|
||||
|| JavaTypesManager.CHARACTER.getId().equals(tt) || JavaTypesManager.PASSWORD.getId().equals(tt)) {
|
||||
type = AvroUtils._string();
|
||||
}
|
||||
} catch(Exception e) {
|
||||
//ignore it now as we can't process the complex expression for the default value, and the default value is not useful for runtime like the old javajet tjdbcxxx
|
||||
//TODO support the expression calculate, not sure it's necessary and sometimes, more complex like globalMap.get(xxx) which only have meaning after running the job.
|
||||
ExceptionHandler.process(e, Level.WARN);
|
||||
}
|
||||
|
||||
// Types with Document/Unknown elements, store as binary
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.runtime.model.components.IComponentConstants;
|
||||
import org.talend.commons.runtime.model.repository.ERepositoryStatus;
|
||||
@@ -739,7 +740,7 @@ public final class MetadataToolHelper {
|
||||
}
|
||||
Set<MetadataTable> tables = null;
|
||||
IGenericWizardService wizardService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
if (!CommonsPlugin.isHeadless() && GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault()
|
||||
.getService(IGenericWizardService.class);
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ import org.talend.cwm.helper.TaggedValueHelper;
|
||||
*/
|
||||
public class RepositoryToComponentProperty {
|
||||
|
||||
public static Object getValue(Connection connection, String value, IMetadataTable table, String targetComponent) {
|
||||
|
||||
public static Object getValue(Connection connection, String value, IMetadataTable table, String targetComponent, Map<Object, Object> contextMap) {
|
||||
|
||||
if (connection instanceof HL7Connection) {
|
||||
return getHL7Value((HL7Connection) connection, value);
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class RepositoryToComponentProperty {
|
||||
|
||||
for (IDragAndDropServiceHandler handler : DragAndDropManager.getHandlers()) {
|
||||
if (handler.canHandle(connection)) {
|
||||
return handler.getComponentValue(connection, value, table, targetComponent);
|
||||
return handler.getComponentValue(connection, value, table, targetComponent, contextMap);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -163,7 +163,7 @@ public class RepositoryToComponentProperty {
|
||||
}
|
||||
|
||||
public static Object getValue(Connection connection, String value, IMetadataTable table) {
|
||||
return getValue(connection, value, table, null);
|
||||
return getValue(connection, value, table, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.model.process;
|
||||
|
||||
import org.talend.daikon.properties.property.Property;
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
@@ -20,4 +21,5 @@ public interface IGenericElementParameter extends IElementParameter {
|
||||
|
||||
public void setAskPropagate(Boolean askPropagate);
|
||||
|
||||
public Property getProperty();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -28,6 +29,7 @@ import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.general.Project;
|
||||
@@ -134,6 +136,8 @@ public class RelationshipItemBuilder {
|
||||
|
||||
private boolean modified = false;
|
||||
|
||||
private boolean autoSave = true;
|
||||
|
||||
private Project aimProject;
|
||||
|
||||
private IProxyRepositoryFactory proxyRepositoryFactory;
|
||||
@@ -471,8 +475,11 @@ public class RelationshipItemBuilder {
|
||||
itemToTest.setVersion(version);
|
||||
if (!itemsRelations.containsKey(itemToTest)) {
|
||||
try {
|
||||
Item item = proxyRepositoryFactory.getLastVersion(itemId).getProperty().getItem();
|
||||
addOrUpdateItem(item, false);
|
||||
IRepositoryViewObject object = proxyRepositoryFactory.getLastVersion(itemId);
|
||||
if (object != null) {
|
||||
Item item = object.getProperty().getItem();
|
||||
addOrUpdateItem(item, false);
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
@@ -660,6 +667,16 @@ public class RelationshipItemBuilder {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void autoSaveRelations() {
|
||||
if (!isAutoSave()) {
|
||||
return;
|
||||
}
|
||||
saveRelations();
|
||||
}
|
||||
|
||||
/**
|
||||
* <font color="red">{@link #autoSaveRelations()} is recommanded</font>
|
||||
*/
|
||||
public void saveRelations() {
|
||||
if (!loaded && !modified) {
|
||||
return;
|
||||
@@ -693,13 +710,7 @@ public class RelationshipItemBuilder {
|
||||
|
||||
// sort by type
|
||||
List<Relation> relationItemsList = new ArrayList<Relation>(currentProjectItemsRelations.get(relation));
|
||||
Collections.sort(relationItemsList, new Comparator<Relation>() {
|
||||
|
||||
@Override
|
||||
public int compare(Relation o1, Relation o2) {
|
||||
return o1.getType().compareTo(o2.getType());
|
||||
}
|
||||
});
|
||||
Collections.sort(relationItemsList, new RelationComparator());
|
||||
List<ItemRelation> usedRelationList = new ArrayList<ItemRelation>();
|
||||
List<ItemRelation> oldRelatedItems = new ArrayList<ItemRelation>(itemRelations.getRelatedItems());
|
||||
for (Relation relatedItem : relationItemsList) {
|
||||
@@ -733,16 +744,29 @@ public class RelationshipItemBuilder {
|
||||
emfRelatedItem.setVersion(relatedItem.getVersion());
|
||||
itemRelations.getRelatedItems().add(emfRelatedItem);
|
||||
}
|
||||
EList relatedItems = itemRelations.getRelatedItems();
|
||||
// get unused relation items
|
||||
oldRelatedItems.removeAll(usedRelationList);
|
||||
// remove unused relation items
|
||||
itemRelations.getRelatedItems().removeAll(oldRelatedItems);
|
||||
relatedItems.removeAll(oldRelatedItems);
|
||||
|
||||
// sort result
|
||||
List relatedItemsList = new LinkedList<>(relatedItems);
|
||||
Collections.sort(relatedItemsList, new ItemRelationComparator());
|
||||
relatedItems.clear();
|
||||
relatedItems.addAll(relatedItemsList);
|
||||
if (!exist) {
|
||||
currentProject.getEmfProject().getItemsRelations().add(itemRelations);
|
||||
}
|
||||
}
|
||||
oldRelations.removeAll(usedList);
|
||||
currentProject.getEmfProject().getItemsRelations().removeAll(oldRelations);
|
||||
EList itemsRelations = currentProject.getEmfProject().getItemsRelations();
|
||||
itemsRelations.removeAll(oldRelations);
|
||||
List itemRelationsList = new LinkedList<>(itemsRelations);
|
||||
Collections.sort(itemRelationsList, new ItemRelationsComparator());
|
||||
itemsRelations.clear();
|
||||
itemsRelations.addAll(itemRelationsList);
|
||||
|
||||
try {
|
||||
getProxyRepositoryFactory().saveProject(currentProject);
|
||||
} catch (PersistenceException e) {
|
||||
@@ -877,7 +901,7 @@ public class RelationshipItemBuilder {
|
||||
return;
|
||||
}
|
||||
}
|
||||
saveRelations();
|
||||
autoSaveRelations();
|
||||
monitor.done();
|
||||
loaded = true;
|
||||
|
||||
@@ -970,7 +994,7 @@ public class RelationshipItemBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean supportRelation(Item item) {
|
||||
public static boolean supportRelation(Item item) {
|
||||
IItemRelationshipHandler[] itemRelationshipHandlers = RelationshipRegistryReader.getInstance()
|
||||
.getItemRelationshipHandlers();
|
||||
for (IItemRelationshipHandler handler : itemRelationshipHandlers) {
|
||||
@@ -1060,11 +1084,69 @@ public class RelationshipItemBuilder {
|
||||
modified = true;
|
||||
}
|
||||
if (!fromMigration && modified) {
|
||||
saveRelations();
|
||||
autoSaveRelations();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeItemRelations(Item item) {
|
||||
public Set<Relation> getItemRelations(Item item) {
|
||||
if (!loaded) {
|
||||
loadRelations();
|
||||
}
|
||||
|
||||
ProcessType processType = null;
|
||||
if (item instanceof ProcessItem) {
|
||||
processType = ((ProcessItem) item).getProcess();
|
||||
}
|
||||
if (item instanceof JobletProcessItem) {
|
||||
processType = ((JobletProcessItem) item).getJobletProcess();
|
||||
}
|
||||
|
||||
Set<Relation> relations = Collections.EMPTY_SET;
|
||||
if (processType != null) {
|
||||
Relation relation = new Relation();
|
||||
relation.setId(item.getProperty().getId());
|
||||
relation.setType(getTypeFromItem(item));
|
||||
relation.setVersion(item.getProperty().getVersion());
|
||||
|
||||
Map<Relation, Set<Relation>> itemRelations = getRelatedRelations(item);
|
||||
|
||||
relations = itemRelations.get(relation);
|
||||
}
|
||||
return relations;
|
||||
}
|
||||
|
||||
public Set<Relation> removeItemRelations(Item item) {
|
||||
if (!loaded) {
|
||||
loadRelations();
|
||||
}
|
||||
modified = true;
|
||||
|
||||
ProcessType processType = null;
|
||||
if (item instanceof ProcessItem) {
|
||||
processType = ((ProcessItem) item).getProcess();
|
||||
}
|
||||
if (item instanceof JobletProcessItem) {
|
||||
processType = ((JobletProcessItem) item).getJobletProcess();
|
||||
}
|
||||
|
||||
Set<Relation> removedRelations = Collections.EMPTY_SET;
|
||||
if (processType != null) {
|
||||
Relation relation = new Relation();
|
||||
relation.setId(item.getProperty().getId());
|
||||
relation.setType(getTypeFromItem(item));
|
||||
relation.setVersion(item.getProperty().getVersion());
|
||||
|
||||
Map<Relation, Set<Relation>> itemRelations = getRelatedRelations(item);
|
||||
|
||||
if (itemRelations.containsKey(relation)) {
|
||||
removedRelations = itemRelations.remove(relation);
|
||||
autoSaveRelations();
|
||||
}
|
||||
}
|
||||
return removedRelations;
|
||||
}
|
||||
|
||||
public void putItemRelations(Item item, Set<Relation> relations) {
|
||||
if (!loaded) {
|
||||
loadRelations();
|
||||
}
|
||||
@@ -1086,11 +1168,8 @@ public class RelationshipItemBuilder {
|
||||
|
||||
Map<Relation, Set<Relation>> itemRelations = getRelatedRelations(item);
|
||||
|
||||
if (itemRelations.containsKey(relation)) {
|
||||
itemRelations.get(relation).clear();
|
||||
itemRelations.remove(relation);
|
||||
saveRelations();
|
||||
}
|
||||
itemRelations.put(relation, relations);
|
||||
autoSaveRelations();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1108,4 +1187,176 @@ public class RelationshipItemBuilder {
|
||||
public Map<Relation, Set<Relation>> getCurrentProjectItemsRelations() {
|
||||
return this.currentProjectItemsRelations;
|
||||
}
|
||||
|
||||
public void setAutoSave(boolean autoSave) {
|
||||
this.autoSave = autoSave;
|
||||
}
|
||||
|
||||
public boolean isAutoSave() {
|
||||
return this.autoSave;
|
||||
}
|
||||
|
||||
public boolean isSame(Set<Relation> r1, Set<Relation> r2) {
|
||||
if (r1 == null && r2 == null) {
|
||||
return true;
|
||||
}
|
||||
if (r1 == null || r2 == null) {
|
||||
return false;
|
||||
}
|
||||
if (r1.size() != r2.size()) {
|
||||
return false;
|
||||
}
|
||||
List<Relation> r1List = new LinkedList<>(r1);
|
||||
List<Relation> r2List = new LinkedList<>(r2);
|
||||
RelationComparator comparator = new RelationComparator();
|
||||
r1List.sort(comparator);
|
||||
r2List.sort(comparator);
|
||||
Iterator<Relation> r1Iter = r1List.iterator();
|
||||
Iterator<Relation> r2Iter = r2List.iterator();
|
||||
while (r1Iter.hasNext() && r2Iter.hasNext()) {
|
||||
Relation r1Relation = r1Iter.next();
|
||||
Relation r2Relation = r2Iter.next();
|
||||
if (r1Relation == null || r2Relation == null) {
|
||||
return false;
|
||||
}
|
||||
if (comparator.compare(r1Relation, r2Relation) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class RelationComparator implements Comparator<Relation> {
|
||||
|
||||
@Override
|
||||
public int compare(Relation o1, Relation o2) {
|
||||
String o1Type = o1.getType();
|
||||
String o2Type = o2.getType();
|
||||
if (o1Type == null) {
|
||||
o1Type = "";
|
||||
}
|
||||
if (o2Type == null) {
|
||||
o2Type = "";
|
||||
}
|
||||
int result = o1Type.compareTo(o2Type);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
String o1Id = o1.getId();
|
||||
String o2Id = o2.getId();
|
||||
if (o1Id == null) {
|
||||
o1Id = "";
|
||||
}
|
||||
if (o2Id == null) {
|
||||
o2Id = "";
|
||||
}
|
||||
result = o1Id.compareTo(o2Id);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
String o1Version = o1.getVersion();
|
||||
String o2Version = o2.getVersion();
|
||||
if (o1Version == null) {
|
||||
o1Version = "";
|
||||
}
|
||||
if (o2Version == null) {
|
||||
o2Version = "";
|
||||
}
|
||||
return o1Version.compareTo(o2Version);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemRelationComparator implements Comparator<Object> {
|
||||
|
||||
@Override
|
||||
public int compare(Object arg0, Object arg1) {
|
||||
if (arg0 instanceof ItemRelation && arg1 instanceof ItemRelation) {
|
||||
ItemRelation itemRelation0 = (ItemRelation) arg0;
|
||||
ItemRelation itemRelation1 = (ItemRelation) arg1;
|
||||
String type0 = itemRelation0.getType();
|
||||
String type1 = itemRelation1.getType();
|
||||
if (type0 == null) {
|
||||
type0 = "";
|
||||
}
|
||||
if (type1 == null) {
|
||||
type1 = "";
|
||||
}
|
||||
int result = type0.compareTo(type1);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
String id0 = itemRelation0.getId();
|
||||
String id1 = itemRelation1.getId();
|
||||
if (id0 == null) {
|
||||
id0 = "";
|
||||
}
|
||||
if (id1 == null) {
|
||||
id1 = "";
|
||||
}
|
||||
result = id0.compareTo(id1);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
String version0 = itemRelation0.getVersion();
|
||||
String version1 = itemRelation1.getVersion();
|
||||
if (version0 == null) {
|
||||
version0 = "";
|
||||
}
|
||||
if (version1 == null) {
|
||||
version1 = "";
|
||||
}
|
||||
return version0.compareTo(version1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemRelationsComparator implements Comparator<Object> {
|
||||
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
if (o1 instanceof ItemRelations && o2 instanceof ItemRelations) {
|
||||
ItemRelations itemRelations1 = (ItemRelations) o1;
|
||||
ItemRelations itemRelations2 = (ItemRelations) o2;
|
||||
ItemRelation baseItem1 = itemRelations1.getBaseItem();
|
||||
ItemRelation baseItem2 = itemRelations2.getBaseItem();
|
||||
if (baseItem1 != null && baseItem2 != null) {
|
||||
String type1 = baseItem1.getType();
|
||||
String type2 = baseItem2.getType();
|
||||
if (type1 == null) {
|
||||
type1 = "";
|
||||
}
|
||||
if (type2 == null) {
|
||||
type2 = "";
|
||||
}
|
||||
int result = type1.compareTo(type2);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
String id1 = baseItem1.getId();
|
||||
String id2 = baseItem2.getId();
|
||||
if (id1 == null) {
|
||||
id1 = "";
|
||||
}
|
||||
if (id2 == null) {
|
||||
id2 = "";
|
||||
}
|
||||
result = id1.compareTo(id2);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
String version1 = baseItem1.getVersion();
|
||||
String version2 = baseItem2.getVersion();
|
||||
if (version1 == null) {
|
||||
version1 = "";
|
||||
}
|
||||
if (version2 == null) {
|
||||
version2 = "";
|
||||
}
|
||||
return version1.compareTo(version2);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1480,4 +1480,20 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
|
||||
}
|
||||
return allTypes;
|
||||
}
|
||||
|
||||
public static List<ERepositoryObjectType> getAllTypesOfCodes() {
|
||||
List<ERepositoryObjectType> allTypes = new ArrayList<ERepositoryObjectType>();
|
||||
if (ERepositoryObjectType.ROUTINES != null) {
|
||||
allTypes.add(ERepositoryObjectType.ROUTINES);
|
||||
}
|
||||
ERepositoryObjectType beansType = ERepositoryObjectType.valueOf("BEANS"); //$NON-NLS-1$
|
||||
if (beansType != null) {
|
||||
allTypes.add(beansType);
|
||||
}
|
||||
if (ERepositoryObjectType.PIG_UDF != null) {
|
||||
allTypes.add(ERepositoryObjectType.PIG_UDF);
|
||||
}
|
||||
return allTypes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -159,8 +159,9 @@ public abstract class AbstractUpdateManager implements IUpdateManager {
|
||||
public void checkAllModification() {
|
||||
clearResult();
|
||||
IUpdateItemType[] allUpdateItemTypes = UpdateManagerProviderDetector.INSTANCE.getAllUpdateItemTypes();
|
||||
Map<Object, Object> contextData = new HashMap<Object, Object>();
|
||||
for (IUpdateItemType type : allUpdateItemTypes) {
|
||||
List<UpdateResult> result = getUpdatesNeeded(type);
|
||||
List<UpdateResult> result = getUpdatesNeeded(type, false, contextData);
|
||||
if (result != null) {
|
||||
getUpdatesNeeded().addAll(result);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ package org.talend.core.model.update;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ggu class global comment. Detailled comment
|
||||
@@ -58,6 +59,8 @@ public interface IUpdateManager {
|
||||
public List<UpdateResult> getUpdatesNeeded(IUpdateItemType type);
|
||||
|
||||
public List<UpdateResult> getUpdatesNeeded(IUpdateItemType type, boolean onlySimpleShow);
|
||||
|
||||
public List<UpdateResult> getUpdatesNeeded(IUpdateItemType itemType, boolean onlySimpleShow, Map<Object, Object> contextData);
|
||||
|
||||
public boolean executeUpdates(List<UpdateResult> results);
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public abstract class AbstractDragAndDropServiceHandler implements IDragAndDropS
|
||||
*/
|
||||
@Override
|
||||
public Object getComponentValue(Connection connection, String value, IMetadataTable table) {
|
||||
return getComponentValue(connection, value, table, null);
|
||||
return getComponentValue(connection, value, table, null, null);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -236,7 +236,7 @@ public final class ContextParameterUtils {
|
||||
//ignore the exception
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
return result == null ? null : result.toString();
|
||||
}
|
||||
|
||||
private static Map<String, Object> getVarMapForScriptEngine(final IContext context) {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.talend.core.model.utils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.talend.components.api.properties.ComponentProperties;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
@@ -49,7 +50,7 @@ public interface IDragAndDropServiceHandler {
|
||||
*/
|
||||
public Object getComponentValue(Connection connection, String value, IMetadataTable table);
|
||||
|
||||
public Object getComponentValue(Connection connection, String value, IMetadataTable table, String targetComponent);
|
||||
public Object getComponentValue(Connection connection, String value, IMetadataTable table, String targetComponent, Map<Object, Object> contextMap);
|
||||
|
||||
/**
|
||||
* DOC hwang Comment method "filterNeededComponents".
|
||||
|
||||
@@ -26,5 +26,7 @@ public class NexusConstants {
|
||||
|
||||
public static final String SLASH = "/";//$NON-NLS-1$
|
||||
|
||||
public static final String SNAPSHOTS = "@snapshots";
|
||||
public static final String SNAPSHOTS = "@snapshots";//$NON-NLS-1$
|
||||
|
||||
public static final String DISALLOW_RELEASES = "@noreleases";//$NON-NLS-1$
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
package org.talend.core.runtime.maven;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.talend.core.nexus.TalendMavenResolver;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
@@ -25,7 +24,15 @@ public class MavenArtifact implements Cloneable {
|
||||
private static final char ARTIFACT_SEPARATOR = '-';
|
||||
|
||||
private String repositoryUrl, groupId, artifactId, version, type, classifier, description, url, license, licenseUrl,
|
||||
distribution, username, password;
|
||||
distribution, username, password, lastUpdated;
|
||||
|
||||
public String getLastUpdated() {
|
||||
return this.lastUpdated;
|
||||
}
|
||||
|
||||
public void setLastUpdated(String lastUpdated) {
|
||||
this.lastUpdated = lastUpdated;
|
||||
}
|
||||
|
||||
public String getRepositoryUrl() {
|
||||
return repositoryUrl;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class LastGenerationInfo {
|
||||
|
||||
private HashMap<String, Set<ModuleNeeded>> modulesNeededWithSubjobPerJob;
|
||||
|
||||
private Set<ModuleNeeded> highPriorityModuleNeeded;
|
||||
private HashMap<String, Set<ModuleNeeded>> highPriorityModuleNeeded;
|
||||
|
||||
private HashMap<String, Set<String>> routinesNeededWithSubjobPerJob;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class LastGenerationInfo {
|
||||
modulesNeededPerJob = new HashMap<String, Set<ModuleNeeded>>();
|
||||
contextPerJob = new HashMap<String, Set<String>>();
|
||||
modulesNeededWithSubjobPerJob = new HashMap<String, Set<ModuleNeeded>>();
|
||||
highPriorityModuleNeeded = new LinkedHashSet<ModuleNeeded>();
|
||||
highPriorityModuleNeeded = new HashMap<>();
|
||||
lastGeneratedjobs = new HashSet<JobInfo>();
|
||||
routinesNeededPerJob = new HashMap<String, Set<String>>();
|
||||
pigudfNeededPerJob = new HashMap<String, Set<String>>();
|
||||
@@ -257,13 +257,29 @@ public class LastGenerationInfo {
|
||||
}
|
||||
return routinesNeededPerJob.get(key);
|
||||
}
|
||||
|
||||
public Set<ModuleNeeded> getHighPriorityModuleNeeded() {
|
||||
return highPriorityModuleNeeded;
|
||||
|
||||
public Set<ModuleNeeded> getHighPriorityModuleNeeded(String jobId, String jobVersion) {
|
||||
String key = getProcessKey(jobId, jobVersion);
|
||||
if (!highPriorityModuleNeeded.containsKey(key)) {
|
||||
highPriorityModuleNeeded.put(key, new LinkedHashSet<>());
|
||||
}
|
||||
return highPriorityModuleNeeded.get(key);
|
||||
}
|
||||
|
||||
public void setHighPriorityModuleNeeded(ModuleNeeded moduleNeeded) {
|
||||
highPriorityModuleNeeded.add(moduleNeeded);
|
||||
|
||||
public void setHighPriorityModuleNeeded(String jobId, String jobVersion, Set<ModuleNeeded> moduleNeeded) {
|
||||
String key = getProcessKey(jobId, jobVersion);
|
||||
if (!highPriorityModuleNeeded.containsKey(key)) {
|
||||
highPriorityModuleNeeded.put(key, new LinkedHashSet<>());
|
||||
}
|
||||
highPriorityModuleNeeded.get(key).addAll(moduleNeeded);
|
||||
}
|
||||
|
||||
public void clearHighPriorityModuleNeeded() {
|
||||
highPriorityModuleNeeded.clear();
|
||||
}
|
||||
|
||||
private String getProcessKey(String jobId, String jobVersion) {
|
||||
return jobId + "_" + jobVersion; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,4 +67,6 @@ public interface TalendProcessOptionConstants {
|
||||
|
||||
public static final int MODULES_FOR_MR = 1 << 4;
|
||||
|
||||
public static final int MODULES_EXCLUDE_SHADED = 1 << 5;
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.Map;
|
||||
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.INode;
|
||||
|
||||
/**
|
||||
* created by ycbai on 2016年3月24日 Detailled comment
|
||||
@@ -38,5 +39,7 @@ public interface IGenericService extends IService {
|
||||
*
|
||||
*/
|
||||
public List<Map<String, String>> getAllGenericComponentsInfo();
|
||||
|
||||
public void resetReferenceValue(INode curNode, String oldConnectionName, String newConnectionName);
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.talend.core.runtime.services;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
@@ -123,6 +124,11 @@ public interface IGenericWizardService extends IService {
|
||||
*/
|
||||
public List<ComponentProperties> getAllComponentProperties(Connection connection, String tableLabel);
|
||||
|
||||
public List<ComponentProperties> getAllComponentProperties(Connection connection, String tableLabel, boolean withEvaluator);
|
||||
|
||||
public List<ComponentProperties> getAllComponentProperties(Connection connection, String tableLabel, boolean withEvaluator,
|
||||
boolean forComponentValue, Map<Object, Object> contextMap);
|
||||
|
||||
/**
|
||||
* Get the new repository type (the type from component framework) by the old repository type name.
|
||||
*
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.talend.core.ui;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
@@ -23,6 +24,7 @@ import org.eclipse.ui.IEditorPart;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
@@ -125,4 +127,7 @@ public interface ITestContainerProviderService extends IService {
|
||||
public List<ProcessItem> getTestContainersByVersion(ProcessItem item);
|
||||
|
||||
boolean isTestContainerEditor(IEditorPart editor);
|
||||
|
||||
Set<ModuleNeeded> getAllJobTestcaseModules(ProcessItem item) throws PersistenceException;
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
@@ -79,6 +81,8 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
}
|
||||
|
||||
private Collection<RoutineItem> getAll(ERepositoryObjectType type, boolean syncRef) throws SystemException {
|
||||
// init code project
|
||||
getRunProcessService().getTalendCodeJavaProject(type);
|
||||
// remove routine with same name in reference project
|
||||
final Map<String, RoutineItem> beansList = new HashMap<String, RoutineItem>();
|
||||
for (IRepositoryViewObject obj : getRepositoryService().getProxyRepositoryFactory().getAll(type)) {
|
||||
@@ -95,27 +99,37 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
return (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
}
|
||||
|
||||
private void getReferencedProjectRoutine(final Map<String, RoutineItem> beansList, final Project project,
|
||||
ERepositoryObjectType routineType, boolean syncRef) throws SystemException {
|
||||
for (IRepositoryViewObject obj : getRepositoryService().getProxyRepositoryFactory().getAll(project, routineType)) {
|
||||
private Set<IRepositoryViewObject> getReferencedProjectRoutine(final Map<String, RoutineItem> beansList,
|
||||
final Project project, ERepositoryObjectType routineType, boolean syncRef) throws SystemException {
|
||||
// init ref code project
|
||||
if (syncRef) {
|
||||
getRunProcessService().getTalendCodeJavaProject(routineType, project.getTechnicalLabel());
|
||||
}
|
||||
Set<IRepositoryViewObject> routines = new HashSet<>();
|
||||
routines.addAll(getRepositoryService().getProxyRepositoryFactory().getAll(project, routineType));
|
||||
for (IRepositoryViewObject obj : routines) {
|
||||
final String key = obj.getProperty().getLabel();
|
||||
// it does not have a routine with same name
|
||||
if (!beansList.containsKey(key)) {
|
||||
beansList.put(key, (RoutineItem) obj.getProperty().getItem());
|
||||
}
|
||||
if (syncRef) {
|
||||
// sync routine
|
||||
syncRoutine((RoutineItem) obj.getProperty().getItem(), false, true, true);
|
||||
}
|
||||
}
|
||||
for (ProjectReference projectReference : project.getProjectReferenceList()) {
|
||||
routines.addAll(getReferencedProjectRoutine(beansList, new Project(projectReference.getReferencedProject()),
|
||||
routineType, syncRef));
|
||||
}
|
||||
if (syncRef) {
|
||||
routines.stream().forEach(obj -> {
|
||||
try {
|
||||
syncRoutine((RoutineItem) obj.getProperty().getItem(), project.getTechnicalLabel(), true, true);
|
||||
} catch (SystemException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
});
|
||||
// sync system routine
|
||||
syncSystemRoutine(project);
|
||||
}
|
||||
|
||||
for (ProjectReference projectReference : project.getProjectReferenceList()) {
|
||||
getReferencedProjectRoutine(beansList, new Project(projectReference.getReferencedProject()), routineType, syncRef);
|
||||
}
|
||||
return routines;
|
||||
}
|
||||
|
||||
protected void syncSystemRoutine(Project project) throws SystemException {
|
||||
@@ -128,24 +142,17 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
}
|
||||
|
||||
protected IFile getRoutineFile(RoutineItem routineItem) throws SystemException {
|
||||
return getRoutineFile(routineItem, true);
|
||||
return getRoutineFile(routineItem, ProjectManager.getInstance().getCurrentProject().getTechnicalLabel());
|
||||
}
|
||||
|
||||
protected IFile getRoutineFile(RoutineItem routineItem, boolean currentProject) throws SystemException {
|
||||
Project project;
|
||||
if (currentProject) {
|
||||
project = ProjectManager.getInstance().getCurrentProject();
|
||||
} else {
|
||||
String projectTechName = ProjectManager.getInstance().getProject(routineItem).getTechnicalLabel();
|
||||
project = ProjectManager.getInstance().getProjectFromProjectTechLabel(projectTechName);
|
||||
}
|
||||
ITalendProcessJavaProject talendProcessJavaProject = getRunProcessService().getTalendCodeJavaProject(ERepositoryObjectType.getItemType(routineItem), project);
|
||||
protected IFile getRoutineFile(RoutineItem routineItem, String projectTechName) throws SystemException {
|
||||
ITalendProcessJavaProject talendProcessJavaProject = getRunProcessService()
|
||||
.getTalendCodeJavaProject(ERepositoryObjectType.getItemType(routineItem), projectTechName);
|
||||
if (talendProcessJavaProject == null) {
|
||||
return null;
|
||||
}
|
||||
IFolder routineFolder = talendProcessJavaProject.getSrcSubFolder(null, routineItem.getPackageType());
|
||||
IFile file = routineFolder.getFile(routineItem.getProperty().getLabel() + JavaUtils.JAVA_EXTENSION);
|
||||
return file;
|
||||
return routineFolder.getFile(routineItem.getProperty().getLabel() + JavaUtils.JAVA_EXTENSION);
|
||||
}
|
||||
|
||||
private IFile getProcessFile(ProcessItem item) throws SystemException {
|
||||
@@ -193,30 +200,31 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
|
||||
@Override
|
||||
public void syncRoutine(RoutineItem routineItem, boolean copyToTemp) throws SystemException {
|
||||
syncRoutine(routineItem, true, copyToTemp, false);
|
||||
syncRoutine(routineItem, ProjectManager.getInstance().getCurrentProject().getTechnicalLabel(), copyToTemp, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncRoutine(RoutineItem routineItem, boolean copyToTemp, boolean forceUpdate) throws SystemException {
|
||||
syncRoutine(routineItem, true, copyToTemp, forceUpdate);
|
||||
syncRoutine(routineItem, ProjectManager.getInstance().getCurrentProject().getTechnicalLabel(), copyToTemp, forceUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncRoutine(RoutineItem routineItem, boolean currentProject, boolean copyToTemp, boolean forceUpdate) throws SystemException {
|
||||
public void syncRoutine(RoutineItem routineItem, String projectTechName, boolean copyToTemp, boolean forceUpdate)
|
||||
throws SystemException {
|
||||
boolean needSync = false;
|
||||
if (routineItem != null) {
|
||||
if (forceUpdate || !isRoutineUptodate(routineItem)) {
|
||||
needSync = true;
|
||||
} else {
|
||||
IFile file = getRoutineFile(routineItem, currentProject);
|
||||
IFile file = getRoutineFile(routineItem, projectTechName);
|
||||
if (file != null && !file.exists()) {
|
||||
needSync = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (needSync) {
|
||||
doSyncRoutine(routineItem, currentProject, copyToTemp);
|
||||
if (currentProject) {
|
||||
doSyncRoutine(routineItem, projectTechName, copyToTemp);
|
||||
if (ProjectManager.getInstance().getCurrentProject().getTechnicalLabel().equals(projectTechName)) {
|
||||
setRoutineAsUptodate(routineItem);
|
||||
}
|
||||
}
|
||||
@@ -224,14 +232,14 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
|
||||
public void syncRoutine(RoutineItem routineItem) throws SystemException {
|
||||
if (routineItem != null) {
|
||||
doSyncRoutine(routineItem, true, true);
|
||||
doSyncRoutine(routineItem, ProjectManager.getInstance().getCurrentProject().getTechnicalLabel(), true);
|
||||
setRoutineAsUptodate(routineItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void doSyncRoutine(RoutineItem routineItem, boolean currentProject, boolean copyToTemp) throws SystemException {
|
||||
private void doSyncRoutine(RoutineItem routineItem, String projectTechName, boolean copyToTemp) throws SystemException {
|
||||
try {
|
||||
IFile file = getRoutineFile(routineItem, currentProject);
|
||||
IFile file = getRoutineFile(routineItem, projectTechName);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -374,7 +382,7 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
@Override
|
||||
public void syncAllBeansForLogOn() throws SystemException {
|
||||
for (RoutineItem beanItem : getBeans(true)) {
|
||||
syncRoutine(beanItem, true, true, true);
|
||||
syncRoutine(beanItem, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,8 @@ public interface ITalendSynchronizer {
|
||||
|
||||
void syncRoutine(RoutineItem routineItem, boolean copyToTemp, boolean forceUpdate) throws SystemException;
|
||||
|
||||
void syncRoutine(RoutineItem routineItem, boolean currentProject, boolean copyToTemp, boolean forceUpdate) throws SystemException;
|
||||
void syncRoutine(RoutineItem routineItem, String projectTechName, boolean copyToTemp, boolean forceUpdate)
|
||||
throws SystemException;
|
||||
|
||||
IFile getFile(Item item) throws SystemException;
|
||||
|
||||
|
||||
@@ -193,4 +193,7 @@ public interface IDesignerCoreService extends IService {
|
||||
public void setTACReadTimeout(int timeout);
|
||||
|
||||
boolean isDelegateNode(INode node);
|
||||
|
||||
boolean isNeedContextInJar(IProcess process);
|
||||
|
||||
}
|
||||
|
||||
@@ -212,16 +212,20 @@ public interface IRunProcessService extends IService {
|
||||
|
||||
ITalendProcessJavaProject getTalendCodeJavaProject(ERepositoryObjectType type);
|
||||
|
||||
ITalendProcessJavaProject getTalendCodeJavaProject(ERepositoryObjectType type, Project project);
|
||||
ITalendProcessJavaProject getTalendCodeJavaProject(ERepositoryObjectType type, String projectTechName);
|
||||
|
||||
ITalendProcessJavaProject getTalendJobJavaProject(Property property);
|
||||
|
||||
IFolder getCodeSrcFolder(ERepositoryObjectType type, String projectTechName);
|
||||
|
||||
ITalendProcessJavaProject getTempJavaProject();
|
||||
|
||||
void clearProjectRelatedSettings();
|
||||
|
||||
boolean isExportConfig();
|
||||
|
||||
boolean isdebug();
|
||||
|
||||
void generatePom(Item item);
|
||||
|
||||
void initializeRootPoms();
|
||||
|
||||
@@ -131,7 +131,7 @@ public final class ProjectManager {
|
||||
if (currentProject.getTechnicalLabel().equals(label)) {
|
||||
return currentProject;
|
||||
}
|
||||
for (Project project : getAllReferencedProjects()) {
|
||||
for (Project project : getAllReferencedProjects(true)) {
|
||||
if (project.getTechnicalLabel().equals(label)) {
|
||||
return project;
|
||||
}
|
||||
@@ -153,19 +153,17 @@ public final class ProjectManager {
|
||||
}
|
||||
|
||||
private void resolveSubRefProject(org.talend.core.model.properties.Project p, List<Project> allReferencedprojects,
|
||||
Set<String> resolvedProjectLabels) {
|
||||
|
||||
Context ctx = CoreRuntimePlugin.getInstance().getContext();
|
||||
if (ctx != null && p != null) {
|
||||
Set<String> resolvedProjectLabels, boolean force) {
|
||||
if (p != null) {
|
||||
String parentBranch = ProjectManager.getInstance().getMainProjectBranch(p);
|
||||
if (parentBranch != null) {
|
||||
if (parentBranch != null || force) {
|
||||
resolvedProjectLabels.add(p.getTechnicalLabel());
|
||||
for (ProjectReference pr : new Project(p).getProjectReferenceList()) {
|
||||
if (ProjectManager.validReferenceProject(p, pr)
|
||||
&& !resolvedProjectLabels.contains(pr.getReferencedProject().getTechnicalLabel())) {
|
||||
Project project = new Project(pr.getReferencedProject(), false);
|
||||
allReferencedprojects.add(project);
|
||||
resolveSubRefProject(pr.getReferencedProject(), allReferencedprojects, resolvedProjectLabels); // only to resolve all
|
||||
resolveSubRefProject(pr.getReferencedProject(), allReferencedprojects, resolvedProjectLabels, force);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,11 +192,18 @@ public final class ProjectManager {
|
||||
return getReferencedProjects(currentProject);
|
||||
}
|
||||
|
||||
public List<Project> getAllReferencedProjects() {
|
||||
return getAllReferencedProjects(false);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* return all the referenced projects of current project.
|
||||
*/
|
||||
public List<Project> getAllReferencedProjects() {
|
||||
public List<Project> getAllReferencedProjects(boolean force) {
|
||||
return getAllReferencedProjects(getCurrentProject(), force);
|
||||
}
|
||||
|
||||
public List<Project> getAllReferencedProjects(Project targetProject, boolean force) {
|
||||
List<Project> allReferencedprojects = new ArrayList<Project>();
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
|
||||
if (this.getCurrentProject() == null) {
|
||||
@@ -211,12 +216,12 @@ public final class ProjectManager {
|
||||
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
|
||||
if (factory != null) {
|
||||
List<org.talend.core.model.properties.Project> rProjects = factory
|
||||
.getReferencedProjects(this.getCurrentProject());
|
||||
.getReferencedProjects(targetProject);
|
||||
if (rProjects != null) {
|
||||
for (org.talend.core.model.properties.Project p : rProjects) {
|
||||
Project project = new Project(p);
|
||||
allReferencedprojects.add(project);
|
||||
resolveSubRefProject(p, allReferencedprojects, new HashSet<String>());
|
||||
resolveSubRefProject(p, allReferencedprojects, new HashSet<String>(), force);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,6 +443,8 @@ public interface IProxyRepositoryFactory {
|
||||
|
||||
public List<ModuleNeeded> getModulesNeededForJobs() throws PersistenceException;
|
||||
|
||||
public void initEmfProjectContent() throws PersistenceException, BusinessException;
|
||||
|
||||
public void forceCreate(Item item, IPath path) throws PersistenceException;
|
||||
|
||||
public void forceCreate(Project project, Item item, IPath path) throws PersistenceException;
|
||||
|
||||
@@ -31,6 +31,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$
|
||||
@@ -91,6 +93,8 @@ public class RepositoryConstants {
|
||||
|
||||
public static final String REPOSITORY_CLOUD_EU_ID = "cloud_eu"; //$NON-NLS-1$
|
||||
|
||||
public static final String REPOSITORY_CLOUD_APAC_ID = "cloud_apac"; //$NON-NLS-1$
|
||||
|
||||
public static final String REPOSITORY_CLOUD_CUSTOM_ID = "cloud_custom"; //$NON-NLS-1$
|
||||
|
||||
public static final String REPOSITORY_URL = "url"; //$NON-NLS-1$
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IEditorReference;
|
||||
import org.eclipse.ui.ISaveablePart2;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IViewReference;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
@@ -56,7 +57,6 @@ import org.talend.core.model.repository.RepositoryViewObject;
|
||||
import org.talend.core.model.utils.RepositoryManagerHelper;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.i18n.Messages;
|
||||
import org.talend.core.ui.IHeaderFooterProviderService;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.RepositoryWorkUnit;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
@@ -102,6 +102,8 @@ public abstract class AContextualAction extends Action implements ITreeContextua
|
||||
|
||||
private IRepositoryNode node;
|
||||
|
||||
private ISelection selection;
|
||||
|
||||
@Override
|
||||
public boolean isEditAction() {
|
||||
return editAction;
|
||||
@@ -246,12 +248,19 @@ public abstract class AContextualAction extends Action implements ITreeContextua
|
||||
this.workbenchPart = workbenchPart;
|
||||
}
|
||||
|
||||
public ISelection getSelection() {
|
||||
if (this.selection != null) {
|
||||
return this.selection;
|
||||
}
|
||||
return initSelection();
|
||||
}
|
||||
|
||||
/**
|
||||
* The repository view selection.
|
||||
*
|
||||
* @return the selection
|
||||
*/
|
||||
public ISelection getSelection() {
|
||||
private ISelection initSelection() {
|
||||
if (specialSelectionProvider != null) {
|
||||
return specialSelectionProvider.getSelection();
|
||||
}
|
||||
@@ -283,6 +292,20 @@ public abstract class AContextualAction extends Action implements ITreeContextua
|
||||
return selection;
|
||||
}
|
||||
}
|
||||
if (activePart instanceof IViewPart) {
|
||||
workbenchPart = activePart;
|
||||
ISelectionProvider selectionProvider = ((IViewPart) activePart).getViewSite().getSelectionProvider();
|
||||
if (selectionProvider != null) {
|
||||
ISelection iselection = selectionProvider.getSelection();
|
||||
if (iselection != null && !iselection.isEmpty()) {
|
||||
return iselection;
|
||||
}
|
||||
}
|
||||
if (node != null) {
|
||||
selection = new StructuredSelection(node);
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
if (workbenchPart != null) {
|
||||
if (workbenchPart instanceof IRepositoryView) {
|
||||
@@ -371,12 +394,23 @@ public abstract class AContextualAction extends Action implements ITreeContextua
|
||||
this.isToolbar = isToolbar;
|
||||
}
|
||||
|
||||
public void setCurrentRepositoryNode(RepositoryNode node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public RepositoryNode getCurrentRepositoryNode() {
|
||||
if (this.node != null) {
|
||||
return (RepositoryNode) this.node;
|
||||
}
|
||||
return initCurrentRepositoryNode();
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC qzhang Comment method "getCurrentRepositoryNode".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected RepositoryNode getCurrentRepositoryNode() {
|
||||
protected RepositoryNode initCurrentRepositoryNode() {
|
||||
ISelection selection;
|
||||
IWorkbenchPage activePage = getActivePage();
|
||||
if (activePage == null) {
|
||||
@@ -607,6 +641,8 @@ public abstract class AContextualAction extends Action implements ITreeContextua
|
||||
|
||||
oldItem = null;
|
||||
// if (node == null) {
|
||||
// clean old node cache first
|
||||
node = null;
|
||||
node = getCurrentRepositoryNode();
|
||||
// }
|
||||
if (node != null) {
|
||||
@@ -618,19 +654,30 @@ public abstract class AContextualAction extends Action implements ITreeContextua
|
||||
}
|
||||
}
|
||||
}
|
||||
final IRepositoryNode userSelectedNode = node;
|
||||
// clean old selection cache first
|
||||
selection = null;
|
||||
final ISelection userSelection = getSelection();
|
||||
|
||||
RepositoryWorkUnit<Object> repositoryWorkUnit = new RepositoryWorkUnit<Object>(name, this) {
|
||||
|
||||
@Override
|
||||
protected void run() throws LoginException, PersistenceException {
|
||||
if (node != null && node.getObject() != null) {
|
||||
Property property = node.getObject().getProperty();
|
||||
// only avoid NPE if item has been deleted in svn
|
||||
if (property != null) {
|
||||
try {
|
||||
node = userSelectedNode;
|
||||
selection = userSelection;
|
||||
if (node != null && node.getObject() != null) {
|
||||
Property property = node.getObject().getProperty();
|
||||
// only avoid NPE if item has been deleted in svn
|
||||
if (property != null) {
|
||||
doRun();
|
||||
}
|
||||
} else {
|
||||
doRun();
|
||||
}
|
||||
} else {
|
||||
doRun();
|
||||
} finally {
|
||||
node = null;
|
||||
selection = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -747,4 +794,9 @@ public abstract class AContextualAction extends Action implements ITreeContextua
|
||||
public void setUnloadResourcesAfter(boolean unloadResourcesAfter) {
|
||||
this.unloadResourcesAfter = unloadResourcesAfter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITreeContextualAction clone() throws CloneNotSupportedException {
|
||||
return (ITreeContextualAction) super.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,15 @@ public class ActionsHelper {
|
||||
}
|
||||
Collections.sort(actionsToReturn, COMP);
|
||||
}
|
||||
return actionsToReturn;
|
||||
List<ITreeContextualAction> actions = new ArrayList<>();
|
||||
for (ITreeContextualAction action : actionsToReturn) {
|
||||
try {
|
||||
actions.add(action.clone());
|
||||
} catch (Exception e) {
|
||||
org.talend.commons.exception.ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
public static MenuManager[] getRepositoryContextualsActionGroups() {
|
||||
@@ -182,6 +190,7 @@ public class ActionsHelper {
|
||||
*
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compare(ITreeContextualAction o1, ITreeContextualAction o2) {
|
||||
Integer l1 = o1.getLevel();
|
||||
Integer l2 = o2.getLevel();
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.window.DefaultToolTip;
|
||||
import org.eclipse.nebula.widgets.nattable.NatTable;
|
||||
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
|
||||
@@ -56,8 +57,10 @@ import org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer;
|
||||
import org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer;
|
||||
import org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand;
|
||||
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
|
||||
import org.eclipse.nebula.widgets.nattable.layer.ILayerListener;
|
||||
import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator;
|
||||
import org.eclipse.nebula.widgets.nattable.layer.config.DefaultColumnHeaderStyleConfiguration;
|
||||
import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent;
|
||||
import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter;
|
||||
import org.eclipse.nebula.widgets.nattable.painter.layer.NatGridLayerPainter;
|
||||
import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
|
||||
@@ -92,6 +95,7 @@ import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.service.IMetadataManagmentUiService;
|
||||
import org.talend.core.ui.context.model.ContextTabChildModel;
|
||||
import org.talend.core.ui.context.model.table.ContextTableConstants;
|
||||
@@ -107,6 +111,7 @@ import org.talend.core.ui.context.nattableTree.ContextParaModeChangeMenuConfigur
|
||||
import org.talend.core.ui.context.nattableTree.ContextRowDataListFixture;
|
||||
import org.talend.core.ui.context.nattableTree.ExtendedContextColumnPropertyAccessor;
|
||||
import org.talend.core.ui.i18n.Messages;
|
||||
import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.IRepositoryNode.ENodeType;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
@@ -320,7 +325,7 @@ public class ContextTreeTable {
|
||||
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
|
||||
|
||||
// add selection listener for the context NatTable
|
||||
addNatTableListener(bodyDataProvider, selectionProvider);
|
||||
addNatTableListener(bodyDataProvider, selectionProvider, bodyDataLayer);
|
||||
|
||||
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
|
||||
|
||||
@@ -371,7 +376,7 @@ public class ContextTreeTable {
|
||||
}
|
||||
|
||||
private void addNatTableListener(final GlazedListsDataProvider<ContextTreeNode> bodyDataProvider,
|
||||
ISelectionProvider selectionProvider) {
|
||||
ISelectionProvider selectionProvider, DataLayer bodyDataLayer) {
|
||||
this.natTable.addMouseListener(new MouseListener() {
|
||||
|
||||
@Override
|
||||
@@ -426,6 +431,36 @@ public class ContextTreeTable {
|
||||
currentNatTabSel = (IStructuredSelection) event.getSelection();
|
||||
}
|
||||
});
|
||||
|
||||
bodyDataLayer.addLayerListener(new ILayerListener() {
|
||||
|
||||
@Override
|
||||
public void handleLayerEvent(ILayerEvent event) {
|
||||
if (event instanceof org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent) {
|
||||
StructuredSelection selection = (StructuredSelection) selectionProvider.getSelection();
|
||||
Object element = selection.getFirstElement();
|
||||
if (element instanceof ContextTreeNode && natTable.getParent().getParent().getParent().getClass().getName()
|
||||
.equals("org.talend.designer.core.ui.views.contexts.ContextViewComposite")) { //$NON-NLS-1$
|
||||
try {
|
||||
updateRelatedView();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateRelatedView() {
|
||||
IDesignerCoreService designerCoreService = CoreRuntimePlugin.getInstance().getDesignerCoreService();
|
||||
if (designerCoreService != null) {
|
||||
designerCoreService.switchToCurContextsView();
|
||||
// for tRunJob component
|
||||
designerCoreService.switchToCurComponentSettingsView();
|
||||
// for 2608
|
||||
designerCoreService.switchToCurJobSettingsView();
|
||||
}
|
||||
}
|
||||
|
||||
private List<Integer> getAllCheckPosBehaviour(IContextModelManager manager, ColumnGroupModel contextGroupModel) {
|
||||
|
||||
@@ -46,21 +46,22 @@ import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.eclipse.ui.dialogs.SelectionDialog;
|
||||
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.ProgressDialog;
|
||||
import org.talend.commons.ui.swt.formtools.Form;
|
||||
import org.talend.core.model.context.ContextUtils;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.properties.Project;
|
||||
import org.talend.core.ui.context.cmd.AddRepositoryContextGroupCommand;
|
||||
import org.talend.core.ui.editor.command.ContextRemoveParameterCommand;
|
||||
@@ -188,8 +189,8 @@ public class SelectRepositoryContextDialog extends SelectionDialog {
|
||||
return;
|
||||
}
|
||||
if (selection.getFirstElement() instanceof ContextItem) {
|
||||
ShowSelectedContextDialog showDialog = new ShowSelectedContextDialog((ContextItem) selection
|
||||
.getFirstElement(), getParentShell());
|
||||
ShowSelectedContextDialog showDialog = new ShowSelectedContextDialog(
|
||||
(ContextItem) selection.getFirstElement(), getParentShell());
|
||||
showDialog.open();
|
||||
}
|
||||
}
|
||||
@@ -330,13 +331,11 @@ public class SelectRepositoryContextDialog extends SelectionDialog {
|
||||
if (showWarning) {
|
||||
String message = null;
|
||||
if (helper.existParameterForJob(existedParam)) {
|
||||
message = Messages
|
||||
.getString(
|
||||
"SelectRepositoryContextDialog.ExistenceMessage", existedParam.getName(), selectedContextName); //$NON-NLS-1$
|
||||
message = Messages.getString("SelectRepositoryContextDialog.ExistenceMessage", existedParam.getName(), //$NON-NLS-1$
|
||||
selectedContextName);
|
||||
} else {
|
||||
message = Messages
|
||||
.getString(
|
||||
"SelectRepositoryContextDialog.DuplicationMessage", existedParam.getName(), selectedContextName); //$NON-NLS-1$
|
||||
message = Messages.getString("SelectRepositoryContextDialog.DuplicationMessage", //$NON-NLS-1$
|
||||
existedParam.getName(), selectedContextName);
|
||||
}
|
||||
MessageDialog.openWarning(getParentShell(), WARNING_TITLE, message);
|
||||
}
|
||||
@@ -370,8 +369,8 @@ public class SelectRepositoryContextDialog extends SelectionDialog {
|
||||
|
||||
for (Object sibling : siblings) {
|
||||
if (sibling instanceof ContextParameterType) {
|
||||
IContextParameter existedContextParameter = helper.getExistedContextParameter(((ContextParameterType) sibling)
|
||||
.getName());
|
||||
IContextParameter existedContextParameter = helper
|
||||
.getExistedContextParameter(((ContextParameterType) sibling).getName());
|
||||
if (existedContextParameter != null && existedContextParameter.isBuiltIn()) {
|
||||
num++;
|
||||
continue;
|
||||
@@ -509,8 +508,8 @@ public class SelectRepositoryContextDialog extends SelectionDialog {
|
||||
if (selectedItems != null && !selectedItems.isEmpty()) {
|
||||
Set<String> contextGoupNameSet = new HashSet<String>();
|
||||
if (checkShowContextGroup(manager, selectedItems)) {
|
||||
SelectRepositoryContextGroupDialog groupDialog = new SelectRepositoryContextGroupDialog(getParentShell(),
|
||||
manager, helper, selectedItems);
|
||||
SelectRepositoryContextGroupDialog groupDialog = new SelectRepositoryContextGroupDialog(getParentShell(), manager,
|
||||
helper, selectedItems);
|
||||
if (Dialog.OK == groupDialog.open()) {
|
||||
contextGoupNameSet = groupDialog.getSelectedContextGroupName();
|
||||
}
|
||||
@@ -521,11 +520,25 @@ public class SelectRepositoryContextDialog extends SelectionDialog {
|
||||
IContext defaultContext = manager.getDefaultContext();
|
||||
List<IContextParameter> existParas = new ArrayList<>(defaultContext.getContextParameterList());
|
||||
// remove the params which is unchecked
|
||||
Set<String> jobletIds = new HashSet<String>();
|
||||
Set<String> chekedIds = new HashSet<String>();
|
||||
for (IContextParameter param : existParas) {
|
||||
if (param.isBuiltIn()) {
|
||||
continue;
|
||||
}
|
||||
ContextRemoveParameterCommand cmd = new ContextRemoveParameterCommand(manager, param.getName(), param.getSource());
|
||||
String sourceId = param.getSource();
|
||||
if (!chekedIds.contains(sourceId)) {
|
||||
chekedIds.add(sourceId);
|
||||
Item repositoryContextItemById = ContextUtils.getRepositoryContextItemById(sourceId);
|
||||
if (repositoryContextItemById instanceof JobletProcessItem) {
|
||||
jobletIds.add(sourceId);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (jobletIds.contains(sourceId)) {
|
||||
continue;
|
||||
}
|
||||
ContextRemoveParameterCommand cmd = new ContextRemoveParameterCommand(manager, param.getName(), sourceId);
|
||||
execCommand(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.talend.core.ui.context.cmd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -20,12 +21,15 @@ import java.util.Set;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.gef.commands.Command;
|
||||
import org.talend.core.model.context.ContextUtils;
|
||||
import org.talend.core.model.context.JobContext;
|
||||
import org.talend.core.model.context.JobContextParameter;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.ui.context.ContextManagerHelper;
|
||||
import org.talend.core.ui.context.IContextModelManager;
|
||||
import org.talend.core.ui.editor.command.ContextRemoveParameterCommand;
|
||||
@@ -90,8 +94,9 @@ public class AddRepositoryContextGroupCommand extends Command {
|
||||
List<String> contextNames = new ArrayList<String>();
|
||||
for (ContextType context : (List<ContextType>) item.getContext()) {
|
||||
String repContextName = context.getName();
|
||||
if (repContextName != null)
|
||||
if (repContextName != null) {
|
||||
contextNames.add(repContextName.toLowerCase());
|
||||
}
|
||||
}
|
||||
Iterator<IContext> iterator = manager.getListContext().iterator();
|
||||
// TODO Remove the contexts except "default" and matched to repository without case sensitive.
|
||||
@@ -101,8 +106,8 @@ public class AddRepositoryContextGroupCommand extends Command {
|
||||
// if not select new default context, will not delete the default context for job.
|
||||
if (name != null) {
|
||||
if (contextNames.contains(name.toLowerCase())
|
||||
|| (!isJobContextExistInRepository(nameSet, item.getDefaultContext()) && name.toLowerCase().equals(
|
||||
defaultContext.getName().toLowerCase()))) {
|
||||
|| (!isJobContextExistInRepository(nameSet, item.getDefaultContext())
|
||||
&& name.toLowerCase().equals(defaultContext.getName().toLowerCase()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -176,16 +181,29 @@ public class AddRepositoryContextGroupCommand extends Command {
|
||||
}
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
//remove the params which is unchecked
|
||||
for(IContextParameter param : existParas){
|
||||
if (param.isBuiltIn()){
|
||||
|
||||
// remove the params which is unchecked
|
||||
Set<String> jobletIds = new HashSet<String>();
|
||||
Set<String> chekedIds = new HashSet<String>();
|
||||
for (IContextParameter param : existParas) {
|
||||
if (param.isBuiltIn()) {
|
||||
continue;
|
||||
}
|
||||
new ContextRemoveParameterCommand(manager, param.getName(), param.getSource())
|
||||
.execute();
|
||||
String sourceId = param.getSource();
|
||||
if (!chekedIds.contains(sourceId)) {
|
||||
chekedIds.add(sourceId);
|
||||
Item repositoryContextItemById = ContextUtils.getRepositoryContextItemById(sourceId);
|
||||
if (repositoryContextItemById instanceof JobletProcessItem) {
|
||||
jobletIds.add(sourceId);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (jobletIds.contains(sourceId)) {
|
||||
continue;
|
||||
}
|
||||
new ContextRemoveParameterCommand(manager, param.getName(), param.getSource()).execute();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,8 +214,9 @@ public class AddRepositoryContextGroupCommand extends Command {
|
||||
while (it.hasNext()) {
|
||||
String selectedName = it.next();
|
||||
if (selectedName != null && defaultContextName != null) {
|
||||
if (selectedName.toLowerCase().equals(defaultContextName.toLowerCase()))
|
||||
if (selectedName.toLowerCase().equals(defaultContextName.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -140,7 +140,7 @@ public abstract class JobEditorInput extends RepositoryEditorInput {
|
||||
// factory.createProcess(project, loadedProcess, path);
|
||||
} else {
|
||||
|
||||
RepositoryWorkUnit rwu = new RepositoryWorkUnit("save process") {
|
||||
RepositoryWorkUnit rwu = new RepositoryWorkUnit("save process : " + loadedProcess.getLabel()) {
|
||||
|
||||
@Override
|
||||
protected void run() throws LoginException, PersistenceException {
|
||||
|
||||
@@ -421,8 +421,15 @@ public class ModuleListDialog extends Dialog {
|
||||
IElementParameter componentName = param.getElement().getElementParameter("COMPONENT_NAME");
|
||||
|
||||
if(componentName !=null && "cConfig".equals(componentName.getValue())){
|
||||
String versionType = ".SNAPSHOT";
|
||||
selectedJarPath = jarPath;
|
||||
selectedJarVersion = versionLabel.getText();
|
||||
String selectedJarVersionTmp = versionLabel.getText();
|
||||
if (StringUtils.endsWithIgnoreCase(selectedJarVersionTmp, versionType)) {
|
||||
selectedJarVersionTmp = selectedJarVersionTmp.replace(versionType, "-SNAPSHOT");
|
||||
}
|
||||
|
||||
selectedJarVersion = selectedJarVersionTmp;
|
||||
|
||||
}else{
|
||||
service.deployLibrary(path.toFile().toURI().toURL());
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.common.util.EMap;
|
||||
import org.eclipse.gef.commands.Command;
|
||||
@@ -152,8 +153,8 @@ public class RepositoryChangeMetadataForSAPBapi extends Command {
|
||||
|
||||
String uinqueTableName = node.getProcess().generateUniqueConnectionName(
|
||||
MultiSchemasUtil.getConnectionBaseName(newMetadatTable.getLabel()));
|
||||
String paramType = getParamType(newMetadatTable, isInput);
|
||||
if (paramType == null) {
|
||||
String type = getType(newMetadatTable, isInput);
|
||||
if (type == null) {
|
||||
return;
|
||||
}
|
||||
if (selectionIndex != null && selectionIndex < paramValues.size()) {
|
||||
@@ -165,18 +166,19 @@ public class RepositoryChangeMetadataForSAPBapi extends Command {
|
||||
paramValues.add(valueMap);
|
||||
}
|
||||
valueMap.put(ISAPConstant.NAME, TalendQuoteUtils.addQuotes(newMetadatTable.getLabel()));
|
||||
valueMap.put(ISAPConstant.TYPE, paramType);
|
||||
valueMap.put(ISAPConstant.TYPE, type);
|
||||
valueMap.put(ISAPConstant.FIELD_SCHEMA, uinqueTableName);
|
||||
if (isInput) {
|
||||
valueMap.put(ISAPConstant.PARENT_ROW, ""); //$NON-NLS-1$
|
||||
if (functionUnit != null && functionUnit.getParamData() != null
|
||||
&& functionUnit.getParamData().getInputRoot() != null) {
|
||||
for (SAPFunctionParameter param : functionUnit.getParamData().getInputRoot().getChildren()) {
|
||||
if (param.getName().equals(newMetadatTable.getTableName())) {
|
||||
valueMap.put(ISAPConstant.CHANGING, param.isChanging());
|
||||
}
|
||||
}
|
||||
|
||||
String inputParameterType = getInputParameterType(functionUnit, newMetadatTable);
|
||||
if (StringUtils.isBlank(inputParameterType)) {
|
||||
inputParameterType = ISAPConstant.PARAMETER_TYPE_IMPORT;
|
||||
}
|
||||
valueMap.put(ISAPConstant.PARAMETER_TYPE, inputParameterType);
|
||||
|
||||
valueMap.put(ISAPConstant.CHANGING, ISAPConstant.PARAMETER_TYPE_CHANGING.equals(inputParameterType));
|
||||
|
||||
Map<String, String> properties = newMetadatTable.getAdditionalProperties();
|
||||
if (properties != null) {
|
||||
properties.put(ISINPUT, TRUE);
|
||||
@@ -195,7 +197,37 @@ public class RepositoryChangeMetadataForSAPBapi extends Command {
|
||||
}
|
||||
}
|
||||
|
||||
private String getParamType(IMetadataTable table, boolean isInput) {
|
||||
private String getInputParameterType(SAPFunctionUnit funcUnit, IMetadataTable newMetadatTable) {
|
||||
String parameterType = "";
|
||||
if (funcUnit != null && funcUnit.getParamData() != null && funcUnit.getParamData().getInputRoot() != null) {
|
||||
SAPFunctionParameter foundParam = null;
|
||||
String tableName = newMetadatTable.getTableName();
|
||||
for (SAPFunctionParameter param : funcUnit.getParamData().getInputRoot().getChildren()) {
|
||||
if (tableName.equals(param.getName())) {
|
||||
foundParam = param;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundParam != null) {
|
||||
if (foundParam.isChanging()) {
|
||||
parameterType = ISAPConstant.PARAMETER_TYPE_CHANGING;
|
||||
} else {
|
||||
if (ISAPConstant.PARAM_TABLE.equals(foundParam.getType())) {
|
||||
if (foundParam.isTableResideInTables()) {
|
||||
parameterType = ISAPConstant.PARAMETER_TYPE_TABLES;
|
||||
} else {
|
||||
parameterType = ISAPConstant.PARAMETER_TYPE_IMPORT;
|
||||
}
|
||||
} else {
|
||||
parameterType = ISAPConstant.PARAMETER_TYPE_IMPORT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return parameterType;
|
||||
}
|
||||
|
||||
private String getType(IMetadataTable table, boolean isInput) {
|
||||
if (functionUnit == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.talend.core.model.metadata.QueryUtil;
|
||||
import org.talend.core.model.metadata.builder.ConvertionHelper;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.process.ElementParameterParser;
|
||||
import org.talend.core.model.process.ProcessUtils;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
@@ -279,9 +280,10 @@ public class CoreService implements ICoreService {
|
||||
ICodeGeneratorService codeGenService = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(
|
||||
ICodeGeneratorService.class);
|
||||
codeGenService.createRoutineSynchronizer().syncAllRoutinesForLogOn();
|
||||
codeGenService.createRoutineSynchronizer().syncAllPigudfForLogOn();
|
||||
if (ProcessUtils.isRequiredPigUDFs(null)) {
|
||||
codeGenService.createRoutineSynchronizer().syncAllPigudfForLogOn();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,8 +21,10 @@ import org.talend.commons.exception.SystemException;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.updatesite.IUpdateSiteBean;
|
||||
|
||||
|
||||
/**
|
||||
* wchen class global comment. Detailled comment
|
||||
*/
|
||||
@@ -57,4 +59,6 @@ public interface ICoreTisService extends IService {
|
||||
public boolean isTheSameType(String userName, String password, String adminUrl);
|
||||
|
||||
public void clearCustomLicensePathArg();
|
||||
|
||||
public void afterImport (Property property) throws PersistenceException;
|
||||
}
|
||||
|
||||
@@ -160,6 +160,12 @@ public class ProcessorUtilities {
|
||||
|
||||
private static final Set<ModuleNeeded> retrievedJarsForCurrentBuild = new HashSet<ModuleNeeded>();
|
||||
|
||||
private static final Set<String> esbJobs = new HashSet<String>();
|
||||
|
||||
private static boolean isDebug = false;
|
||||
|
||||
private static JobInfo mainJobInfo;
|
||||
|
||||
public static void addOpenEditor(IEditorPart editor) {
|
||||
openedEditors.add(editor);
|
||||
}
|
||||
@@ -425,10 +431,11 @@ public class ProcessorUtilities {
|
||||
|
||||
isMainJob = true;
|
||||
codeModified = false;
|
||||
mainJobInfo = jobInfo;
|
||||
|
||||
// this cache only keep the last main job's generation, so clear it since we regenerate a new job.
|
||||
LastGenerationInfo.getInstance().getLastGeneratedjobs().clear();
|
||||
LastGenerationInfo.getInstance().getHighPriorityModuleNeeded().clear();
|
||||
LastGenerationInfo.getInstance().clearHighPriorityModuleNeeded();
|
||||
retrievedJarsForCurrentBuild.clear();
|
||||
|
||||
// if it's the father, reset the processMap to ensure to have a good
|
||||
@@ -538,10 +545,13 @@ public class ProcessorUtilities {
|
||||
LastGenerationInfo.getInstance().setModulesNeededWithSubjobPerJob(jobInfo.getJobId(), jobInfo.getJobVersion(),
|
||||
neededLibraries);
|
||||
LastGenerationInfo.getInstance().setModulesNeededPerJob(jobInfo.getJobId(), jobInfo.getJobVersion(), neededLibraries);
|
||||
|
||||
// get all job testcases needed modules
|
||||
neededLibraries.addAll(getAllJobTestcaseModules(selectedProcessItem));
|
||||
|
||||
// must install the needed libraries before generate codes with poms.
|
||||
CorePlugin.getDefault().getRunProcessService().updateLibraries(neededLibraries, currentProcess,
|
||||
retrievedJarsForCurrentBuild);
|
||||
|
||||
}
|
||||
resetRunJobComponentParameterForContextApply(jobInfo, currentProcess, selectedContextName);
|
||||
|
||||
@@ -577,7 +587,7 @@ public class ProcessorUtilities {
|
||||
// for testContainer dataSet
|
||||
generateDataSet(currentProcess, processor);
|
||||
|
||||
generatePigudfInfor(jobInfo, selectedProcessItem, currentProcess, processor, neededLibraries);
|
||||
generatePigudfInfor(jobInfo, selectedProcessItem, currentProcess, processor);
|
||||
|
||||
/*
|
||||
* Set classpath for current job. If current job include some child-jobs, the child job SHARE farther job
|
||||
@@ -677,7 +687,7 @@ public class ProcessorUtilities {
|
||||
}
|
||||
|
||||
private static void generatePigudfInfor(JobInfo jobInfo, ProcessItem selectedProcessItem, IProcess currentProcess,
|
||||
IProcessor processor, Set<ModuleNeeded> neededLibraries) throws ProcessorException {
|
||||
IProcessor processor) throws ProcessorException {
|
||||
// generate pigudf.jar before generate code
|
||||
// update calss path before export pigudf
|
||||
Set<ModuleNeeded> neededModules = LastGenerationInfo.getInstance().getModulesNeededWithSubjobPerJob(jobInfo.getJobId(),
|
||||
@@ -936,10 +946,11 @@ public class ProcessorUtilities {
|
||||
if (jobInfo.getFatherJobInfo() == null) {
|
||||
isMainJob = true;
|
||||
codeModified = false;
|
||||
mainJobInfo = jobInfo;
|
||||
|
||||
// this cache only keep the last main job's generation, so clear it since we regenerate a new job.
|
||||
LastGenerationInfo.getInstance().getLastGeneratedjobs().clear();
|
||||
LastGenerationInfo.getInstance().getHighPriorityModuleNeeded().clear();
|
||||
LastGenerationInfo.getInstance().clearHighPriorityModuleNeeded();
|
||||
retrievedJarsForCurrentBuild.clear();
|
||||
|
||||
// if it's the father, reset the processMap to ensure to have a good
|
||||
@@ -1063,10 +1074,13 @@ public class ProcessorUtilities {
|
||||
neededLibraries);
|
||||
LastGenerationInfo.getInstance().setModulesNeededPerJob(jobInfo.getJobId(), jobInfo.getJobVersion(),
|
||||
neededLibraries);
|
||||
|
||||
// get all job testcases needed modules
|
||||
neededLibraries.addAll(getAllJobTestcaseModules(selectedProcessItem));
|
||||
|
||||
// must install the needed libraries before generate codes with poms.
|
||||
CorePlugin.getDefault().getRunProcessService().updateLibraries(neededLibraries, currentProcess,
|
||||
retrievedJarsForCurrentBuild);
|
||||
|
||||
}
|
||||
resetRunJobComponentParameterForContextApply(jobInfo, currentProcess, selectedContextName);
|
||||
|
||||
@@ -1110,7 +1124,7 @@ public class ProcessorUtilities {
|
||||
// for testContainer dataSet
|
||||
generateDataSet(currentProcess, processor);
|
||||
|
||||
generatePigudfInfor(jobInfo, selectedProcessItem, currentProcess, processor, neededLibraries);
|
||||
generatePigudfInfor(jobInfo, selectedProcessItem, currentProcess, processor);
|
||||
|
||||
TimeMeasure.step(idTimer, "generateContextInfo");
|
||||
|
||||
@@ -1132,6 +1146,22 @@ public class ProcessorUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<ModuleNeeded> getAllJobTestcaseModules(ProcessItem selectedProcessItem) {
|
||||
Set<ModuleNeeded> neededLibraries = new HashSet<>();
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
|
||||
ITestContainerProviderService testcontainerService = (ITestContainerProviderService) GlobalServiceRegister
|
||||
.getDefault().getService(ITestContainerProviderService.class);
|
||||
if (!testcontainerService.isTestContainerItem(selectedProcessItem)) {
|
||||
try {
|
||||
neededLibraries.addAll(testcontainerService.getAllJobTestcaseModules(selectedProcessItem));
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return neededLibraries;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC nrousseau Comment method "cleanSourceFolder".
|
||||
*
|
||||
@@ -1141,14 +1171,23 @@ public class ProcessorUtilities {
|
||||
*/
|
||||
public static void cleanSourceFolder(IProgressMonitor progressMonitor, IProcess currentProcess, IProcessor processor) {
|
||||
try {
|
||||
ITalendProcessJavaProject jobProject = processor.getTalendJavaProject();
|
||||
// clean up source code
|
||||
IPath codePath = processor.getSrcCodePath().removeLastSegments(2);
|
||||
IFolder srcFolder = processor.getTalendJavaProject().getProject().getFolder(codePath);
|
||||
IFolder srcFolder = jobProject.getProject().getFolder(codePath);
|
||||
String jobPackageFolder = JavaResourcesHelper.getJobClassPackageFolder(currentProcess);
|
||||
for (IResource resource : srcFolder.members()) {
|
||||
if (resource.getProjectRelativePath().toPortableString().endsWith(jobPackageFolder)) {
|
||||
break;
|
||||
if (!resource.getProjectRelativePath().toPortableString().endsWith(jobPackageFolder)) {
|
||||
resource.delete(true, progressMonitor);
|
||||
}
|
||||
}
|
||||
// clean up resources folder if needed
|
||||
if (ProcessorUtilities.isExportConfig() && !designerCoreService.isNeedContextInJar(currentProcess)) {
|
||||
for (IResource resource : jobProject.getResourcesFolder().members()) {
|
||||
if (resource.exists()) {
|
||||
resource.delete(true, progressMonitor);
|
||||
}
|
||||
}
|
||||
resource.delete(true, progressMonitor);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
@@ -1347,6 +1386,20 @@ public class ProcessorUtilities {
|
||||
if (BitwiseOptionUtils.containOption(option, GENERATE_WITHOUT_COMPILING)) {
|
||||
subJobOption |= GENERATE_WITHOUT_COMPILING;
|
||||
}
|
||||
|
||||
Object buildType = (jobInfo.getArgumentsMap() != null)?
|
||||
jobInfo.getArgumentsMap().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE):null;
|
||||
|
||||
Map<String, Object> subjobArguments = (subJobInfo.getArgumentsMap() != null) ?
|
||||
subJobInfo.getArgumentsMap(): new HashMap<String, Object>();
|
||||
|
||||
if(componentName.equals("tRunJob") && (buildType == null || "OSGI".equals(buildType))) {
|
||||
subjobArguments.put("INCLUDE_EXT_RESOURCES", "");
|
||||
subJobInfo.setArgumentsMap(subjobArguments);
|
||||
}else if (componentName.equals("cTalendJob") && "ROUTE".equals(buildType)) {
|
||||
subjobArguments.put(TalendProcessArgumentConstant.ARG_BUILD_TYPE, "OSGI");
|
||||
subJobInfo.setArgumentsMap(subjobArguments);
|
||||
}
|
||||
// children won't have stats / traces
|
||||
generateCode(subJobInfo, selectedContextName, statistics, false, properties, isNeedLoadmodules,
|
||||
subJobOption, progressMonitor);
|
||||
@@ -1360,6 +1413,9 @@ public class ProcessorUtilities {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isEsbComponentName(componentName)) {
|
||||
addEsbJob(jobInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1422,6 +1478,11 @@ public class ProcessorUtilities {
|
||||
Set<String> subjobPigUDFModules = generationInfo.getPigudfNeededWithSubjobPerJob(subJobInfo.getJobId(),
|
||||
subJobInfo.getJobVersion());
|
||||
generationInfo.getPigudfNeededWithSubjobPerJob(jobInfo.getJobId(), jobInfo.getJobVersion()).addAll(subjobPigUDFModules);
|
||||
|
||||
// tLibraryLoad modules
|
||||
Set<ModuleNeeded> subjobHighPriorityModules = generationInfo.getHighPriorityModuleNeeded(subJobInfo.getJobId(),
|
||||
subJobInfo.getJobVersion());
|
||||
generationInfo.setHighPriorityModuleNeeded(jobInfo.getJobId(), jobInfo.getJobVersion(), subjobHighPriorityModules);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1484,11 +1545,14 @@ public class ProcessorUtilities {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
JobInfo jobInfo = new JobInfo(processName, contextName, version);
|
||||
IProcessor process = generateCode(jobInfo, contextName, statistics, trace, true, GENERATE_ALL_CHILDS, monitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return process;
|
||||
}
|
||||
|
||||
@@ -1509,10 +1573,13 @@ public class ProcessorUtilities {
|
||||
JobInfo jobInfo = new JobInfo(processId, contextName, version);
|
||||
jobInfo.setApplyContextToChildren(applyContextToChildren);
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor process = generateCode(jobInfo, contextName, statistics, trace, true, GENERATE_ALL_CHILDS, monitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return process;
|
||||
}
|
||||
|
||||
@@ -1528,10 +1595,13 @@ public class ProcessorUtilities {
|
||||
JobInfo jobInfo = new JobInfo(process, contextName);
|
||||
jobInfo.setApplyContextToChildren(applyContextToChildren);
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor result = generateCode(jobInfo, contextName, statistics, trace, true, GENERATE_ALL_CHILDS, monitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1547,10 +1617,13 @@ public class ProcessorUtilities {
|
||||
JobInfo jobInfo = new JobInfo(process, contextName, version);
|
||||
jobInfo.setApplyContextToChildren(applyContextToChildren);
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor result = generateCode(jobInfo, contextName, statistics, trace, needContext, GENERATE_ALL_CHILDS, monitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1574,10 +1647,13 @@ public class ProcessorUtilities {
|
||||
int option = ProcessUtils.getOptionValue(argumentsMap, TalendProcessArgumentConstant.ARG_GENERATE_OPTION, 0);
|
||||
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor result = generateCode(jobInfo, contextName, statistics, trace, needContext, option, monitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1596,10 +1672,13 @@ public class ProcessorUtilities {
|
||||
jobInfo.setContext(context);
|
||||
jobInfo.setApplyContextToChildren(applyContextToChildren);
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
result = generateCode(jobInfo, contextName, statistics, trace, true, GENERATE_ALL_CHILDS, monitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1607,10 +1686,13 @@ public class ProcessorUtilities {
|
||||
public static IProcessor generateCode(ProcessItem process, String contextName, boolean statistics, boolean trace)
|
||||
throws ProcessorException {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor returnValue = generateCode(process, contextName, statistics, trace, false);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@@ -1640,21 +1722,27 @@ public class ProcessorUtilities {
|
||||
}
|
||||
jobInfo.setApplyContextToChildren(applyToChildren);
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor genCode = generateCode(jobInfo, context.getName(), statistics, trace, contextProperties, GENERATE_ALL_CHILDS,
|
||||
new NullProgressMonitor());
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return genCode;
|
||||
}
|
||||
|
||||
public static IProcessor generateCode(IProcess process, IContext context, boolean statistics, boolean trace,
|
||||
boolean properties) throws ProcessorException {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor returnValue = generateCode(process, context, statistics, trace, properties, new NullProgressMonitor());
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@@ -1684,11 +1772,14 @@ public class ProcessorUtilities {
|
||||
jobInfo = new JobInfo(process, context);
|
||||
}
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor genCode = generateCode(jobInfo, context.getName(), statistics, trace, properties, GENERATE_ALL_CHILDS,
|
||||
progressMonitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return genCode;
|
||||
}
|
||||
|
||||
@@ -1732,11 +1823,14 @@ public class ProcessorUtilities {
|
||||
TimeMeasure.begin(timeMeasureGenerateCodesId);
|
||||
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor genCode = generateCode(processor, jobInfo, context.getName(), statistics, trace, properties,
|
||||
GENERATE_ALL_CHILDS, progressMonitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
|
||||
TimeMeasure.end(timeMeasureGenerateCodesId);
|
||||
// if active before, not disable and active still.
|
||||
@@ -1761,11 +1855,14 @@ public class ProcessorUtilities {
|
||||
// achen modify to fix 0006107
|
||||
JobInfo jobInfo = new JobInfo(process, context);
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor genCode = generateCode(jobInfo, context.getName(), statistics, trace, properties, option,
|
||||
new NullProgressMonitor());
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return genCode;
|
||||
}
|
||||
|
||||
@@ -2017,7 +2114,7 @@ public class ProcessorUtilities {
|
||||
EList<NodeType> nodes = ptype.getNode();
|
||||
String jobletPaletteType = null;
|
||||
String frameWork = ptype.getFramework();
|
||||
if (frameWork == null) {
|
||||
if (StringUtils.isBlank(frameWork)) {
|
||||
jobletPaletteType = ComponentCategory.CATEGORY_4_DI.getName();
|
||||
} else if (frameWork.equals(HadoopConstants.FRAMEWORK_SPARK)) {
|
||||
jobletPaletteType = ComponentCategory.CATEGORY_4_SPARK.getName();
|
||||
@@ -2037,6 +2134,11 @@ public class ProcessorUtilities {
|
||||
if (!activate) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isEsbComponentName(node.getComponentName())) {
|
||||
addEsbJob(parentJobInfo);
|
||||
}
|
||||
|
||||
boolean isCTalendJob = "cTalendJob".equalsIgnoreCase(node.getComponentName());
|
||||
boolean isRoutelet = isRouteletNode(node);
|
||||
if ("tRunJob".equalsIgnoreCase(node.getComponentName()) || isCTalendJob || isRoutelet) { //$NON-NLS-1$
|
||||
@@ -2079,7 +2181,27 @@ public class ProcessorUtilities {
|
||||
if (!firstChildOnly) {
|
||||
getAllJobInfo(jobletProcess, parentJobInfo, jobInfos, firstChildOnly);
|
||||
} else {
|
||||
Project project = null;
|
||||
String componentName = node.getComponentName();
|
||||
String[] array = componentName.split(":"); //$NON-NLS-1$
|
||||
if (array.length == 2) {
|
||||
// from ref project
|
||||
String projectTechName = array[0];
|
||||
project = ProjectManager.getInstance().getProjectFromProjectTechLabel(projectTechName);
|
||||
} else {
|
||||
project = ProjectManager.getInstance().getCurrentProject();
|
||||
}
|
||||
Property property = service.getJobletComponentItem(jobletComponent);
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
if (project != null && !project.getTechnicalLabel().equals(currentProject.getTechnicalLabel())) {
|
||||
try {
|
||||
property = ProxyRepositoryFactory.getInstance()
|
||||
.getSpecificVersion(project, property.getId(), property.getVersion(), true)
|
||||
.getProperty();
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
JobInfo jobInfo = new JobInfo(property, jobletProcess.getDefaultContext());
|
||||
if (!jobInfos.contains(jobInfo)) {
|
||||
jobInfos.add(jobInfo);
|
||||
@@ -2267,6 +2389,15 @@ public class ProcessorUtilities {
|
||||
return hasLoopDependency;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for mainJobInfo. <font color="red">Need to check null</font>
|
||||
*
|
||||
* @return the mainJobInfo
|
||||
*/
|
||||
public static JobInfo getMainJobInfo() {
|
||||
return mainJobInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* The dynamic loading of the hadoop configuration library is supported in DI, MapReduce and Spark (batch and
|
||||
* streaming).
|
||||
@@ -2298,4 +2429,71 @@ public class ProcessorUtilities {
|
||||
return doSupportDynamicHadoopConfLoading(property) && !isExportAsOSGI();
|
||||
}
|
||||
|
||||
public static boolean isEsbJob(IProcess process) {
|
||||
return isEsbJob(process, false);
|
||||
}
|
||||
|
||||
public static boolean isEsbJob(IProcess process, boolean checkCurrentProcess) {
|
||||
|
||||
if (process instanceof IProcess2) {
|
||||
|
||||
if (checkCurrentProcess) {
|
||||
for (INode n : process.getGraphicalNodes()) {
|
||||
if (isEsbComponentName(n.getComponent().getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Set<JobInfo> infos = ProcessorUtilities.getChildrenJobInfo(((IProcess2) process).getProperty().getItem(), false);
|
||||
|
||||
for (JobInfo jobInfo : infos) {
|
||||
ProcessType processType = jobInfo.getProcessItem().getProcess();
|
||||
EList<NodeType> nodes = processType.getNode();
|
||||
for (NodeType nodeType : nodes) {
|
||||
if (isEsbComponentName(nodeType.getComponentName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void addEsbJob(JobInfo jobInfo) {
|
||||
if (esbJobs.contains(esbJobKey(jobInfo.getJobId(), jobInfo.getJobVersion()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
esbJobs.add(esbJobKey(jobInfo.getJobId(), jobInfo.getJobVersion()));
|
||||
if (jobInfo.getFatherJobInfo() != null) {
|
||||
addEsbJob(jobInfo.getFatherJobInfo());
|
||||
}
|
||||
}
|
||||
|
||||
private static String esbJobKey(String processId, String version) {
|
||||
return processId + "_" + version;
|
||||
}
|
||||
|
||||
private static boolean isEsbComponentName(String componentName) {
|
||||
if (componentName.equals("tESBConsumer")
|
||||
|| componentName.equals("tESBProviderRequest")
|
||||
|| componentName.equals("tRouteInput")
|
||||
|| componentName.equals("tESBProviderRequestIn")
|
||||
|| componentName.equals("tESBProviderRequestLoop")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void setDebug(boolean debug) {
|
||||
isDebug = debug;
|
||||
}
|
||||
|
||||
public static boolean isdebug() {
|
||||
return isDebug;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ public class DynamicDistributionAetherUtils {
|
||||
|
||||
String groupId = dependencyNode.getGroupId();
|
||||
String artifactId = dependencyNode.getArtifactId();
|
||||
String extension = dependencyNode.getExtension();
|
||||
String classifier = dependencyNode.getClassifier();
|
||||
String version = dependencyNode.getVersion();
|
||||
String scope = dependencyNode.getScope();
|
||||
@@ -86,6 +87,12 @@ public class DynamicDistributionAetherUtils {
|
||||
if (scope == null) {
|
||||
scope = JavaScopes.COMPILE;
|
||||
}
|
||||
if (StringUtils.isBlank(extension)) {
|
||||
extension = null;
|
||||
}
|
||||
if (StringUtils.isBlank(classifier)) {
|
||||
classifier = null;
|
||||
}
|
||||
|
||||
String key = remoteUrl + " | " + localPath; //$NON-NLS-1$
|
||||
|
||||
@@ -102,7 +109,7 @@ public class DynamicDistributionAetherUtils {
|
||||
updateDependencySelector((DefaultRepositorySystemSession) session, monitor);
|
||||
|
||||
org.eclipse.aether.graph.Dependency dependency = new org.eclipse.aether.graph.Dependency(
|
||||
new DefaultArtifact(groupId, artifactId, classifier, null, version), scope);
|
||||
new DefaultArtifact(groupId, artifactId, classifier, extension, version), scope);
|
||||
|
||||
List<ExclusionNode> exclusionNodes = dependencyNode.getExclusions();
|
||||
if (exclusionNodes != null && !exclusionNodes.isEmpty()) {
|
||||
|
||||
@@ -399,8 +399,13 @@ public abstract class MavenCommandLauncher {
|
||||
public void waitFinish(ILaunch launch) {
|
||||
|
||||
try {
|
||||
boolean isCommandLine = CommonsPlugin.isHeadless();
|
||||
while (!launchFinished) {
|
||||
Thread.sleep(100);
|
||||
if (isCommandLine) {
|
||||
Thread.sleep(100);
|
||||
} else {
|
||||
waitStudioFinish();
|
||||
}
|
||||
// if terminated also
|
||||
if (launch.getProcesses() != null && launch.getProcesses().length > 0) {
|
||||
if (launch.getProcesses()[0].isTerminated()) {
|
||||
@@ -415,5 +420,16 @@ public abstract class MavenCommandLauncher {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void waitStudioFinish() throws InterruptedException {
|
||||
org.eclipse.swt.widgets.Display display = org.eclipse.swt.widgets.Display.getCurrent();
|
||||
if (display != null) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
} else {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,4 +48,6 @@ public class MavenSystemFolders {
|
||||
public static final ProjectSystemFolder[] TEST_DIRS = { JAVA_TEST, RESOURCES_TEST };
|
||||
|
||||
public static final ProjectSystemFolder[] ALL_DIRS = { JAVA, JAVA_TEST, RESOURCES, RESOURCES_TEST };
|
||||
|
||||
public static final ProjectSystemFolder[] ALL_DIRS_EXT = { JAVA, JAVA_TEST, RESOURCES, RESOURCES_TEST, EXT_RESOURCES };
|
||||
}
|
||||
|
||||
@@ -119,6 +119,8 @@ public interface TalendMavenConstants {
|
||||
/**
|
||||
* argments
|
||||
*/
|
||||
static final String ARG_MAIN_SKIP = "-Dmaven.main.skip=true";
|
||||
|
||||
static final String ARG_SKIPTESTS = "-Dmaven.test.skip=true";
|
||||
|
||||
static final String ARG_TEST_FAILURE_IGNORE = "-Dmaven.test.failure.ignore=true";
|
||||
|
||||
@@ -27,7 +27,6 @@ public enum ETalendMavenVariables {
|
||||
|
||||
ProjectName,
|
||||
ProjectId,
|
||||
ProjectBranch,
|
||||
|
||||
CodesGroupId,
|
||||
CodesArtifactId,
|
||||
|
||||
@@ -223,9 +223,9 @@ public class MavenTemplateManager {
|
||||
return getCodeProjectTemplateModel(null); // by default will be current project.
|
||||
}
|
||||
|
||||
public static Model addCIBuilder(Model model) {
|
||||
public static void addCIBuilder(Model model) {
|
||||
if (!PluginChecker.isTIS()) {
|
||||
return model;
|
||||
return;
|
||||
}
|
||||
if (!model.getProfiles().isEmpty()) {
|
||||
Profile toDelete = null;
|
||||
@@ -259,8 +259,46 @@ public class MavenTemplateManager {
|
||||
pe.addGoal("generate"); //$NON-NLS-1$
|
||||
executions.add(pe);
|
||||
plugin.setExecutions(executions);
|
||||
}
|
||||
|
||||
return model;
|
||||
public static void addCloudPublisher(Model model) {
|
||||
if (!PluginChecker.isTIS()) {
|
||||
return;
|
||||
}
|
||||
final String PROFILE_ID = "cloud-publisher"; //$NON-NLS-1$
|
||||
Iterator<Profile> iterator = model.getProfiles().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Profile profile = iterator.next();
|
||||
if (PROFILE_ID.equals(profile.getId())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
Profile profile = new Profile();
|
||||
profile.setId(PROFILE_ID);
|
||||
model.addProfile(profile);
|
||||
|
||||
profile.getProperties().setProperty("maven.deploy.skip", Boolean.TRUE.toString());
|
||||
|
||||
Plugin plugin = new Plugin();
|
||||
profile.setBuild(new Build());
|
||||
profile.getBuild().addPlugin(plugin);
|
||||
plugin.setGroupId(TalendMavenConstants.DEFAULT_GROUP_ID);
|
||||
plugin.setArtifactId("cloud.publisher"); //$NON-NLS-1$
|
||||
plugin.setVersion("${talend.version}"); //$NON-NLS-1$
|
||||
|
||||
// add executions
|
||||
PluginExecution execution = new PluginExecution();
|
||||
execution.setPhase("deploy"); //$NON-NLS-1$
|
||||
execution.addGoal("publish"); //$NON-NLS-1$
|
||||
plugin.getExecutions().add(execution);
|
||||
|
||||
// add configuration
|
||||
Xpp3Dom confNode = new Xpp3Dom("configuration"); //$NON-NLS-1$
|
||||
Xpp3Dom skipNode = new Xpp3Dom("skip"); //$NON-NLS-1$
|
||||
skipNode.setValue("${maven.install.skip}"); //$NON-NLS-1$
|
||||
confNode.addChild(skipNode);
|
||||
plugin.setConfiguration(confNode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -292,9 +330,11 @@ public class MavenTemplateManager {
|
||||
setJavaVersionForModel(model, variablesValuesMap);
|
||||
|
||||
addCIBuilder(model);
|
||||
addCloudPublisher(model);
|
||||
|
||||
Properties properties = model.getProperties();
|
||||
properties.put("talend.project.name", projectTechName); //$NON-NLS-1$
|
||||
properties.put("talend.version", VersionUtils.getTalendVersion()); //$NON-NLS-1$
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -31,19 +31,17 @@ import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
@@ -71,8 +69,8 @@ import org.talend.core.runtime.process.TalendProcessArgumentConstant;
|
||||
import org.talend.core.runtime.services.IFilterService;
|
||||
import org.talend.core.ui.ITestContainerProviderService;
|
||||
import org.talend.designer.core.ICamelDesignerCoreService;
|
||||
import org.talend.designer.maven.DesignerMavenPlugin;
|
||||
import org.talend.designer.maven.launch.MavenPomCommandLauncher;
|
||||
import org.talend.designer.maven.model.MavenSystemFolders;
|
||||
import org.talend.designer.maven.model.TalendJavaProjectConstants;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
@@ -98,9 +96,14 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
|
||||
public AggregatorPomsHelper(String projectTechName) {
|
||||
Assert.isNotNull(projectTechName);
|
||||
this.projectTechName = projectTechName;
|
||||
}
|
||||
|
||||
public String getProjectTechName() {
|
||||
return projectTechName;
|
||||
}
|
||||
|
||||
public void createRootPom(IFolder folder, List<String> modules, boolean force, IProgressMonitor monitor)
|
||||
throws Exception {
|
||||
IFile pomFile = folder.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
@@ -115,28 +118,28 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void createRootPom(IFolder folder, IProgressMonitor monitor) throws Exception {
|
||||
createRootPom(folder, null, false, monitor);
|
||||
}
|
||||
|
||||
public void installRootPom(boolean current) throws Exception {
|
||||
IFile pomFile = getProjectPomsFolder().getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
installPom(pomFile, current);
|
||||
}
|
||||
|
||||
public void installPom(IFile pomFile, boolean current) throws Exception {
|
||||
if (!pomFile.exists()) {
|
||||
return;
|
||||
public void createRootPom(IProgressMonitor monitor) throws Exception {
|
||||
IFile pomFile = getProjectRootPom();
|
||||
List<String> modules = null;
|
||||
if (pomFile != null && pomFile.exists()) {
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(pomFile);
|
||||
modules = model.getModules();
|
||||
}
|
||||
Model model = MavenPlugin.getMaven().readModel(pomFile.getLocation().toFile());
|
||||
if (!isPomInstalled(model.getGroupId(), model.getArtifactId(), model.getVersion())) {
|
||||
MavenPomCommandLauncher launcher = new MavenPomCommandLauncher(pomFile, TalendMavenConstants.GOAL_INSTALL);
|
||||
if (current) {
|
||||
createRootPom(getProjectPomsFolder(), modules, true, monitor);
|
||||
}
|
||||
|
||||
public void installRootPom(boolean force) throws Exception {
|
||||
IFile pomFile = getProjectRootPom();
|
||||
if (pomFile.exists()) {
|
||||
Model model = MavenPlugin.getMaven().readModel(pomFile.getLocation().toFile());
|
||||
if (force || !isPomInstalled(model.getGroupId(), model.getArtifactId(), model.getVersion())) {
|
||||
MavenPomCommandLauncher launcher = new MavenPomCommandLauncher(pomFile, TalendMavenConstants.GOAL_INSTALL);
|
||||
Map<String, Object> argumentsMap = new HashMap<>();
|
||||
// -N: install current pom without modules.
|
||||
argumentsMap.put(TalendProcessArgumentConstant.ARG_PROGRAM_ARGUMENTS, "-N"); // $NON-NLS-N$
|
||||
launcher.setArgumentsMap(argumentsMap);
|
||||
launcher.execute(new NullProgressMonitor());
|
||||
}
|
||||
launcher.execute(new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,14 +202,13 @@ public class AggregatorPomsHelper {
|
||||
try {
|
||||
ITalendProcessJavaProject codeProject = getCodesProject(codeType);
|
||||
updateCodeProjectPom(monitor, codeType, codeProject.getProjectPom());
|
||||
buildAndInstallCodesProject(monitor, codeType, true, forceBuild, true);
|
||||
buildAndInstallCodesProject(monitor, codeType, true, forceBuild);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateCodeProjectPom(IProgressMonitor monitor, ERepositoryObjectType type, IFile pomFile)
|
||||
throws Exception {
|
||||
public void updateCodeProjectPom(IProgressMonitor monitor, ERepositoryObjectType type, IFile pomFile) throws Exception {
|
||||
if (type != null) {
|
||||
if (ERepositoryObjectType.ROUTINES == type) {
|
||||
createRoutinesPom(pomFile, monitor);
|
||||
@@ -235,17 +237,15 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateCodesProjectNeededModulesByType(ERepositoryObjectType codeType,
|
||||
IProgressMonitor monitor) {
|
||||
private static void updateCodesProjectNeededModulesByType(ERepositoryObjectType codeType, IProgressMonitor monitor) {
|
||||
Set<ModuleNeeded> neededModules = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
|
||||
ILibrariesService librariesService =
|
||||
(ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
|
||||
ILibrariesService librariesService = (ILibrariesService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibrariesService.class);
|
||||
neededModules = librariesService.getCodesModuleNeededs(codeType);
|
||||
}
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
|
||||
ILibraryManagerService repositoryBundleService = (ILibraryManagerService) GlobalServiceRegister
|
||||
.getDefault()
|
||||
ILibraryManagerService repositoryBundleService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
if (neededModules != null && !neededModules.isEmpty()) {
|
||||
repositoryBundleService.installModules(neededModules, monitor);
|
||||
@@ -272,42 +272,21 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
|
||||
public static void buildAndInstallCodesProject(IProgressMonitor monitor, ERepositoryObjectType codeType) throws Exception {
|
||||
buildAndInstallCodesProject(monitor, codeType, true, false, false);
|
||||
buildAndInstallCodesProject(monitor, codeType, true, false);
|
||||
}
|
||||
|
||||
public static void buildAndInstallCodesProject(IProgressMonitor monitor, ERepositoryObjectType codeType, boolean install,
|
||||
boolean forceBuild, boolean schedule) throws Exception {
|
||||
boolean forceBuild) throws Exception {
|
||||
if (forceBuild || !BuildCacheManager.getInstance().isCodesBuild(codeType)) {
|
||||
if (!CommonsPlugin.isHeadless() && schedule) {
|
||||
Job job = new Job("Install " + codeType.getLabel()) {
|
||||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
build(codeType, install, monitor);
|
||||
return org.eclipse.core.runtime.Status.OK_STATUS;
|
||||
} catch (Exception e) {
|
||||
return new org.eclipse.core.runtime.Status(IStatus.ERROR, DesignerMavenPlugin.PLUGIN_ID, 1,
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
job.setUser(false);
|
||||
job.setPriority(Job.INTERACTIVE);
|
||||
job.schedule();
|
||||
} else {
|
||||
synchronized (codeType) {
|
||||
build(codeType, install, monitor);
|
||||
}
|
||||
synchronized (codeType) {
|
||||
build(codeType, install, monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void build(ERepositoryObjectType codeType, boolean install, IProgressMonitor monitor)
|
||||
throws Exception {
|
||||
private static void build(ERepositoryObjectType codeType, boolean install, IProgressMonitor monitor) throws Exception {
|
||||
ITalendProcessJavaProject codeProject = getCodesProject(codeType);
|
||||
codeProject.buildModules(monitor, null, null);
|
||||
codeProject.buildWholeCodeProject();
|
||||
if (install) {
|
||||
Map<String, Object> argumentsMap = new HashMap<>();
|
||||
argumentsMap.put(TalendProcessArgumentConstant.ARG_GOAL, TalendMavenConstants.GOAL_INSTALL);
|
||||
@@ -382,29 +361,28 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IFilterService.class)) {
|
||||
IFilterService filterService =
|
||||
(IFilterService) GlobalServiceRegister.getDefault().getService(IFilterService.class);
|
||||
IFilterService filterService = (IFilterService) GlobalServiceRegister.getDefault().getService(IFilterService.class);
|
||||
if (property != null && !filterService.isFilterAccepted(property.getItem(), PomIdsHelper.getPomFilter())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
IFile parentPom = getParentModulePomFile(pomFile);
|
||||
if (parentPom != null) {
|
||||
IFile parentPom = getParentModulePomFile(pomFile);
|
||||
if (parentPom != null) {
|
||||
if (!parentPom.isSynchronized(IResource.DEPTH_ZERO)) {
|
||||
parentPom.refreshLocal(IResource.DEPTH_ZERO, null);
|
||||
}
|
||||
IPath relativePath = pomFile.getParent().getLocation().makeRelativeTo(parentPom.getParent().getLocation());
|
||||
Model model = MavenPlugin.getMaven().readModel(parentPom.getContents());
|
||||
List<String> modules = model.getModules();
|
||||
if (modules == null) {
|
||||
modules = new ArrayList<>();
|
||||
model.setModules(modules);
|
||||
}
|
||||
if (!modules.contains(relativePath.toPortableString())) {
|
||||
modules.add(relativePath.toPortableString());
|
||||
PomUtil.savePom(null, model, parentPom);
|
||||
}
|
||||
}
|
||||
IPath relativePath = pomFile.getParent().getLocation().makeRelativeTo(parentPom.getParent().getLocation());
|
||||
Model model = MavenPlugin.getMaven().readModel(parentPom.getContents());
|
||||
List<String> modules = model.getModules();
|
||||
if (modules == null) {
|
||||
modules = new ArrayList<>();
|
||||
model.setModules(modules);
|
||||
}
|
||||
if (!modules.contains(relativePath.toPortableString())) {
|
||||
modules.add(relativePath.toPortableString());
|
||||
PomUtil.savePom(null, model, parentPom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeFromParentModules(IFile pomFile) throws Exception {
|
||||
@@ -549,6 +527,10 @@ public class AggregatorPomsHelper {
|
||||
return getProjectPomsFolder().getFolder(DIR_CODES);
|
||||
}
|
||||
|
||||
public IFile getProjectRootPom() {
|
||||
return getProjectPomsFolder().getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
}
|
||||
|
||||
public IFolder getCodeFolder(ERepositoryObjectType codeType) {
|
||||
IFolder codesFolder = getCodesFolder();
|
||||
if (codeType == ERepositoryObjectType.ROUTINES) {
|
||||
@@ -563,6 +545,10 @@ public class AggregatorPomsHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
public IFolder getCodeSrcFolder(ERepositoryObjectType codeType) {
|
||||
return getCodeFolder(codeType).getFolder(MavenSystemFolders.JAVA.getPath());
|
||||
}
|
||||
|
||||
public IFolder getProcessFolder(ERepositoryObjectType type) {
|
||||
return getProcessesFolder().getFolder(type.getFolder());
|
||||
}
|
||||
@@ -598,8 +584,7 @@ public class AggregatorPomsHelper {
|
||||
public static IFolder getItemPomFolder(Property property) throws Exception {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
|
||||
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister
|
||||
.getDefault()
|
||||
.getService(ITestContainerProviderService.class);
|
||||
.getDefault().getService(ITestContainerProviderService.class);
|
||||
if (testContainerService.isTestContainerItem(property.getItem())) {
|
||||
Item jobItem = testContainerService.getParentJobItem(property.getItem());
|
||||
if (jobItem != null) {
|
||||
@@ -640,9 +625,9 @@ public class AggregatorPomsHelper {
|
||||
boolean useTempPom = TalendJavaProjectConstants.TEMP_POM_ARTIFACT_ID.equals(model.getArtifactId());
|
||||
jobProject.setUseTempPom(useTempPom);
|
||||
}
|
||||
|
||||
|
||||
public void syncAllPoms() throws Exception {
|
||||
|
||||
|
||||
IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() {
|
||||
|
||||
@Override
|
||||
@@ -660,14 +645,21 @@ public class AggregatorPomsHelper {
|
||||
List<IRepositoryViewObject> objects = new ArrayList<>();
|
||||
if (runProcessService != null) {
|
||||
for (ERepositoryObjectType type : ERepositoryObjectType.getAllTypesOfProcess2()) {
|
||||
objects.addAll(
|
||||
ProxyRepositoryFactory.getInstance().getAll(type, true, true));
|
||||
objects.addAll(ProxyRepositoryFactory.getInstance().getAll(type, true, true));
|
||||
}
|
||||
}
|
||||
BuildCacheManager.getInstance().clearAllCaches();
|
||||
int size = 3 + (objects == null ? 0 : objects.size());
|
||||
monitor.setTaskName("Synchronize all poms"); //$NON-NLS-1$
|
||||
monitor.beginTask("", size); //$NON-NLS-1$
|
||||
// project pom
|
||||
monitor.subTask("Synchronize project pom"); //$NON-NLS-1$
|
||||
createRootPom(getProjectPomsFolder(), null, true, monitor);
|
||||
installRootPom(true);
|
||||
monitor.worked(1);
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
// codes pom
|
||||
monitor.subTask("Synchronize code poms"); //$NON-NLS-1$
|
||||
updateCodeProjects(monitor, true);
|
||||
@@ -678,29 +670,25 @@ public class AggregatorPomsHelper {
|
||||
// all jobs pom
|
||||
List<String> modules = new ArrayList<>();
|
||||
if (objects != null) {
|
||||
IFilterService filterService = null;
|
||||
if(GlobalServiceRegister.getDefault().isServiceRegistered(IFilterService.class)) {
|
||||
filterService = (IFilterService) GlobalServiceRegister.getDefault().getService(IFilterService.class);
|
||||
}
|
||||
IFilterService filterService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IFilterService.class)) {
|
||||
filterService = (IFilterService) GlobalServiceRegister.getDefault()
|
||||
.getService(IFilterService.class);
|
||||
}
|
||||
String pomFilter = PomIdsHelper.getPomFilter();
|
||||
List<ERepositoryObjectType> allJobletTypes =
|
||||
ERepositoryObjectType.getAllTypesOfJoblet();
|
||||
List<ERepositoryObjectType> allJobletTypes = ERepositoryObjectType.getAllTypesOfJoblet();
|
||||
for (IRepositoryViewObject object : objects) {
|
||||
if (filterService != null) {
|
||||
if (!allJobletTypes.contains(object.getRepositoryObjectType())
|
||||
&& !filterService.isFilterAccepted(
|
||||
object.getProperty().getItem(),
|
||||
pomFilter)) {
|
||||
if (!allJobletTypes.contains(object.getRepositoryObjectType()) && !filterService
|
||||
.isFilterAccepted(object.getProperty().getItem(), pomFilter)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (object.getProperty() != null
|
||||
&& object.getProperty().getItem() != null) {
|
||||
if (object.getProperty() != null && object.getProperty().getItem() != null) {
|
||||
Item item = object.getProperty().getItem();
|
||||
if (ProjectManager.getInstance().isInCurrentMainProject(item)) {
|
||||
monitor.subTask(
|
||||
"Synchronize job pom: " + item.getProperty().getLabel() //$NON-NLS-1$
|
||||
+ "_" + item.getProperty().getVersion()); //$NON-NLS-1$
|
||||
monitor.subTask("Synchronize job pom: " + item.getProperty().getLabel() //$NON-NLS-1$
|
||||
+ "_" + item.getProperty().getVersion()); //$NON-NLS-1$
|
||||
runProcessService.generatePom(item);
|
||||
IFile pomFile = getItemPomFolder(item.getProperty())
|
||||
.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
@@ -715,8 +703,8 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
// project pom
|
||||
monitor.subTask("Synchronize project pom"); //$NON-NLS-1$
|
||||
// sync project pom again with all modules.
|
||||
monitor.subTask("Synchronize project pom with modules"); //$NON-NLS-1$
|
||||
collectModules(modules);
|
||||
createRootPom(getProjectPomsFolder(), modules, true, monitor);
|
||||
monitor.worked(1);
|
||||
@@ -826,8 +814,7 @@ public class AggregatorPomsHelper {
|
||||
modules.add(getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.PIG_UDF).getProjectPom()));
|
||||
}
|
||||
if (ProcessUtils.isRequiredBeans(null)) {
|
||||
modules.add(getModulePath(service
|
||||
.getTalendCodeJavaProject(ERepositoryObjectType.valueOf("BEANS")) //$NON-NLS-1$
|
||||
modules.add(getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.valueOf("BEANS")) //$NON-NLS-1$
|
||||
.getProjectPom()));
|
||||
}
|
||||
}
|
||||
@@ -863,9 +850,7 @@ public class AggregatorPomsHelper {
|
||||
boolean isLocalProject = ProxyRepositoryFactory.getInstance().isLocalConnectionProvider();
|
||||
boolean isOffline = false;
|
||||
if (!isLocalProject) {
|
||||
RepositoryContext repositoryContext = (RepositoryContext) CoreRuntimePlugin
|
||||
.getInstance()
|
||||
.getContext()
|
||||
RepositoryContext repositoryContext = (RepositoryContext) CoreRuntimePlugin.getInstance().getContext()
|
||||
.getProperty(Context.REPOSITORY_CONTEXT_KEY);
|
||||
isOffline = repositoryContext.isOffline();
|
||||
}
|
||||
|
||||
@@ -264,6 +264,12 @@ public class BuildCacheManager {
|
||||
codesLastBuildCache.remove(codeType);
|
||||
}
|
||||
|
||||
public void clearAllCodesCache() {
|
||||
for (ERepositoryObjectType codeType : ERepositoryObjectType.getAllTypesOfCodes()) {
|
||||
codesLastBuildCache.remove(codeType);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAllCaches() {
|
||||
jobCache.clear();
|
||||
jobletCache.clear();
|
||||
@@ -328,18 +334,25 @@ public class BuildCacheManager {
|
||||
String modulePath = null;
|
||||
IPath basePath = null;
|
||||
IPath jobProjectPath = AggregatorPomsHelper.getJobProjectPath(property, null);
|
||||
if (!ProjectManager.getInstance().isInCurrentMainProject(property)) {
|
||||
ProjectManager proManager = ProjectManager.getInstance();
|
||||
if (!proManager.isInCurrentMainProject(property)) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
|
||||
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault()
|
||||
.getService(IRepositoryService.class);
|
||||
if (service.isGIT()) {
|
||||
String projectTechName = proManager.getCurrentProject().getTechnicalLabel();
|
||||
String mainProjectBranch = proManager.getMainProjectBranch(projectTechName);
|
||||
if ("master".equals(mainProjectBranch)) {
|
||||
modulePath = "../../../../"; //$NON-NLS-1$
|
||||
} else {
|
||||
modulePath = "../../../../../"; //$NON-NLS-1$
|
||||
}
|
||||
basePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().append("/.repositories"); //$NON-NLS-1$
|
||||
} else if (service.isSVN()) {
|
||||
modulePath = "../../"; //$NON-NLS-1$
|
||||
basePath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (modulePath == null || basePath == null) {
|
||||
throw new RuntimeException("modulePath or basePath can not be null!"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@@ -13,9 +13,7 @@
|
||||
package org.talend.designer.maven.tools;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -27,19 +25,14 @@ import org.apache.maven.model.Exclusion;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.process.LastGenerationInfo;
|
||||
import org.talend.core.runtime.process.TalendProcessOptionConstants;
|
||||
import org.talend.core.ui.ITestContainerProviderService;
|
||||
import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.designer.runprocess.IProcessor;
|
||||
import org.talend.designer.runprocess.ProcessorException;
|
||||
@@ -108,8 +101,8 @@ public class ProcessorDependenciesManager {
|
||||
* @param fresh if true, will remove old dependencies, else will add the new dependencies in the head.
|
||||
* @return if there are some changes, will return true
|
||||
*/
|
||||
public static boolean updateDependencies(IProgressMonitor progressMonitor, Model model, List<Dependency> neededDependencies,
|
||||
boolean fresh) throws ProcessorException {
|
||||
public static boolean updateDependencies(IProgressMonitor progressMonitor, Model model,
|
||||
List<Dependency> neededDependencies, boolean fresh) throws ProcessorException {
|
||||
boolean changed = false;
|
||||
try {
|
||||
List<Dependency> existedDependencies = model.getDependencies();
|
||||
@@ -169,83 +162,32 @@ public class ProcessorDependenciesManager {
|
||||
private Set<ModuleNeeded> getAllModuleNeededWithTestCase() throws PersistenceException {
|
||||
// add the job modules.
|
||||
Set<ModuleNeeded> neededLibraries = new HashSet<>();
|
||||
boolean needTestCase = false;
|
||||
List<ProcessItem> testContainers = null;
|
||||
ProcessItem item = null;
|
||||
if (processor.getProperty() != null && processor.getProperty().getItem() instanceof ProcessItem) {
|
||||
item = (ProcessItem) processor.getProperty().getItem();
|
||||
}
|
||||
ITestContainerProviderService testContainerService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
|
||||
testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault()
|
||||
.getService(ITestContainerProviderService.class);
|
||||
if (item != null) {
|
||||
boolean isTestCase = testContainerService.isTestContainerItem(item);
|
||||
boolean isLatestJob = false;
|
||||
if (isTestCase) {
|
||||
item = (ProcessItem) testContainerService.getParentJobItem(item);
|
||||
} else {
|
||||
IRepositoryViewObject object =
|
||||
ProxyRepositoryFactory.getInstance().getLastVersion(item.getProperty().getId());
|
||||
String latestVersion = object.getVersion();
|
||||
if (VersionUtils.compareTo(item.getProperty().getVersion(), latestVersion) == 0) {
|
||||
isLatestJob = true;
|
||||
}
|
||||
}
|
||||
if (isTestCase || isLatestJob) {
|
||||
testContainers = testContainerService.getAllTestContainers(item);
|
||||
getAllLatestTestContainers(testContainers);
|
||||
if (testContainers != null && !testContainers.isEmpty()) {
|
||||
needTestCase = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collection<ModuleNeeded> modulesNeeded = LastGenerationInfo.getInstance().getModulesNeededPerJob(
|
||||
processor.getProcess().getId(), processor.getProcess().getVersion());
|
||||
Collection<ModuleNeeded> modulesNeeded = LastGenerationInfo.getInstance()
|
||||
.getModulesNeededPerJob(processor.getProcess().getId(), processor.getProcess().getVersion());
|
||||
if (modulesNeeded.isEmpty()) {
|
||||
modulesNeeded = processor.getNeededModules(TalendProcessOptionConstants.MODULES_WITH_JOBLET);
|
||||
}
|
||||
neededLibraries.addAll(modulesNeeded);
|
||||
if (needTestCase) {
|
||||
for (ProcessItem testcaseItem : testContainers) {
|
||||
IProcess testcaseProcess = getDesignerCoreService().getProcessFromProcessItem(testcaseItem);
|
||||
neededLibraries.addAll(testcaseProcess.getNeededModules(TalendProcessOptionConstants.MODULES_DEFAULT));
|
||||
}
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
|
||||
ILibraryManagerService repositoryBundleService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
repositoryBundleService.installModules(neededLibraries, null);
|
||||
|
||||
// add testcase modules
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
|
||||
ITestContainerProviderService testcontainerService = (ITestContainerProviderService) GlobalServiceRegister
|
||||
.getDefault().getService(ITestContainerProviderService.class);
|
||||
Set<ModuleNeeded> testcaseModules = null;
|
||||
if (processor.getProperty() != null && processor.getProperty().getItem() instanceof ProcessItem) {
|
||||
ProcessItem item = (ProcessItem) processor.getProperty().getItem();
|
||||
testcaseModules = testcontainerService.getAllJobTestcaseModules(item);
|
||||
neededLibraries.addAll(testcaseModules);
|
||||
if (testcaseModules != null) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
|
||||
ILibraryManagerService repositoryBundleService = (ILibraryManagerService) GlobalServiceRegister
|
||||
.getDefault().getService(ILibraryManagerService.class);
|
||||
repositoryBundleService.installModules(neededLibraries, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return neededLibraries;
|
||||
}
|
||||
|
||||
private void getAllLatestTestContainers(List<ProcessItem> testContainers) {
|
||||
Map<String, ProcessItem> latestTestContainers = new HashMap<>();
|
||||
if (testContainers != null) {
|
||||
for (ProcessItem item : testContainers) {
|
||||
String id = item.getProperty().getId();
|
||||
ProcessItem latestItem = latestTestContainers.get(id);
|
||||
if (latestItem == null) {
|
||||
latestTestContainers.put(id, item);
|
||||
} else {
|
||||
String currentVersion = item.getProperty().getVersion();
|
||||
String latestVersion = latestItem.getProperty().getVersion();
|
||||
if (VersionUtils.compareTo(currentVersion, latestVersion) > 0) {
|
||||
latestTestContainers.put(id, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
testContainers.clear();
|
||||
testContainers.addAll(latestTestContainers.values());
|
||||
}
|
||||
}
|
||||
|
||||
private IDesignerCoreService getDesignerCoreService() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
|
||||
return (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import java.util.Set;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
|
||||
import org.talend.core.model.properties.Property;
|
||||
@@ -102,8 +104,19 @@ public abstract class AbstractMavenCodesTemplatePom extends AbstractMavenGeneral
|
||||
|
||||
for (ModuleNeeded module : needModules) {
|
||||
Dependency dependency = null;
|
||||
// TDI-37032 add dependency only if jar avialable in maven
|
||||
if (module.getDeployStatus() == ELibraryInstallStatus.DEPLOYED) {
|
||||
// TDI-37032 add dependency only if jar available in maven
|
||||
boolean isDeployed = false;
|
||||
if (module.getDeployStatus() != ELibraryInstallStatus.DEPLOYED) {
|
||||
// try to retrieve from custom Nexus
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
|
||||
ILibraryManagerService libManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
isDeployed = libManagerService.retrieve(module, null, false);
|
||||
}
|
||||
} else {
|
||||
isDeployed = true;
|
||||
}
|
||||
if (isDeployed) {
|
||||
dependency = PomUtil.createModuleDependency(module.getMavenUri());
|
||||
}
|
||||
if (dependency != null) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
import org.apache.maven.model.Resource;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
@@ -169,6 +170,14 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
|
||||
Map<String, Object> templateParameters = PomUtil.getTemplateParameters(jobProcessor.getProperty());
|
||||
PomUtil.checkParent(model, this.getPomFile(), templateParameters);
|
||||
setupShade(model);
|
||||
if(jobProcessor.getArguments()!=null && jobProcessor.getArguments().containsKey("INCLUDE_EXT_RESOURCES")) {
|
||||
Resource extRes = new Resource();
|
||||
extRes.setDirectory("src/main/ext-resources");
|
||||
model.getBuild().getResources().add(extRes);
|
||||
Resource defaultRes = new Resource();
|
||||
defaultRes.setDirectory("src/main/resources");
|
||||
model.getBuild().getResources().add(defaultRes);
|
||||
}
|
||||
addDependencies(model);
|
||||
}
|
||||
return model;
|
||||
@@ -208,11 +217,12 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
|
||||
Xpp3Dom artifactSet = new Xpp3Dom("artifactSet"); //$NON-NLS-1$
|
||||
configuration.addChild(artifactSet);
|
||||
Xpp3Dom excludes = new Xpp3Dom("excludes"); //$NON-NLS-1$
|
||||
if (!bigDataProcessor.getShadedModulesExclude().isEmpty()) {
|
||||
Set<ModuleNeeded> modules = bigDataProcessor.getShadedModulesExclude();
|
||||
if (!modules.isEmpty()) {
|
||||
artifactSet.addChild(excludes);
|
||||
}
|
||||
|
||||
for (ModuleNeeded module : bigDataProcessor.getShadedModulesExclude()) {
|
||||
for (ModuleNeeded module : modules) {
|
||||
Xpp3Dom include = new Xpp3Dom("exclude"); //$NON-NLS-1$
|
||||
excludes.addChild(include);
|
||||
MavenArtifact mvnArtifact = MavenUrlHelper.parseMvnUrl(module.getMavenUri());
|
||||
@@ -230,30 +240,7 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
|
||||
final List<Dependency> dependencies = model.getDependencies();
|
||||
|
||||
// add codes to dependencies
|
||||
String projectTechName = ProjectManager.getInstance().getProject(getJobProcessor().getProperty()).getTechnicalLabel();
|
||||
String codeVersion = PomIdsHelper.getCodesVersion(projectTechName);
|
||||
|
||||
// routines
|
||||
String routinesGroupId = PomIdsHelper.getCodesGroupId(projectTechName, TalendMavenConstants.DEFAULT_CODE);
|
||||
String routinesArtifactId = TalendMavenConstants.DEFAULT_ROUTINES_ARTIFACT_ID;
|
||||
Dependency routinesDependency = PomUtil.createDependency(routinesGroupId, routinesArtifactId, codeVersion, null);
|
||||
dependencies.add(routinesDependency);
|
||||
|
||||
// pigudfs
|
||||
if (ProcessUtils.isRequiredPigUDFs(jobProcessor.getProcess())) {
|
||||
String pigudfsGroupId = PomIdsHelper.getCodesGroupId(projectTechName, TalendMavenConstants.DEFAULT_PIGUDF);
|
||||
String pigudfsArtifactId = TalendMavenConstants.DEFAULT_PIGUDFS_ARTIFACT_ID;
|
||||
Dependency pigudfsDependency = PomUtil.createDependency(pigudfsGroupId, pigudfsArtifactId, codeVersion, null);
|
||||
dependencies.add(pigudfsDependency);
|
||||
}
|
||||
|
||||
// beans
|
||||
if (ProcessUtils.isRequiredBeans(jobProcessor.getProcess())) {
|
||||
String beansGroupId = PomIdsHelper.getCodesGroupId(projectTechName, TalendMavenConstants.DEFAULT_BEAN);
|
||||
String beansArtifactId = TalendMavenConstants.DEFAULT_BEANS_ARTIFACT_ID;
|
||||
Dependency beansDependency = PomUtil.createDependency(beansGroupId, beansArtifactId, codeVersion, null);
|
||||
dependencies.add(beansDependency);
|
||||
}
|
||||
addCodesDependencies(dependencies);
|
||||
|
||||
// add children jobs in dependencies
|
||||
addChildrenDependencies(dependencies);
|
||||
@@ -262,6 +249,33 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
|
||||
}
|
||||
}
|
||||
|
||||
protected void addCodesDependencies(final List<Dependency> dependencies) {
|
||||
String projectTechName = ProjectManager.getInstance().getProject(getJobProcessor().getProperty()).getTechnicalLabel();
|
||||
String codeVersion = PomIdsHelper.getCodesVersion(projectTechName);
|
||||
|
||||
// routines
|
||||
String routinesGroupId = PomIdsHelper.getCodesGroupId(projectTechName, TalendMavenConstants.DEFAULT_CODE);
|
||||
String routinesArtifactId = TalendMavenConstants.DEFAULT_ROUTINES_ARTIFACT_ID;
|
||||
Dependency routinesDependency = PomUtil.createDependency(routinesGroupId, routinesArtifactId, codeVersion, null);
|
||||
dependencies.add(routinesDependency);
|
||||
|
||||
// pigudfs
|
||||
if (ProcessUtils.isRequiredPigUDFs(jobProcessor.getProcess())) {
|
||||
String pigudfsGroupId = PomIdsHelper.getCodesGroupId(projectTechName, TalendMavenConstants.DEFAULT_PIGUDF);
|
||||
String pigudfsArtifactId = TalendMavenConstants.DEFAULT_PIGUDFS_ARTIFACT_ID;
|
||||
Dependency pigudfsDependency = PomUtil.createDependency(pigudfsGroupId, pigudfsArtifactId, codeVersion, null);
|
||||
dependencies.add(pigudfsDependency);
|
||||
}
|
||||
|
||||
// beans
|
||||
if (ProcessUtils.isRequiredBeans(jobProcessor.getProcess())) {
|
||||
String beansGroupId = PomIdsHelper.getCodesGroupId(projectTechName, TalendMavenConstants.DEFAULT_BEAN);
|
||||
String beansArtifactId = TalendMavenConstants.DEFAULT_BEANS_ARTIFACT_ID;
|
||||
Dependency beansDependency = PomUtil.createDependency(beansGroupId, beansArtifactId, codeVersion, null);
|
||||
dependencies.add(beansDependency);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addChildrenDependencies(final List<Dependency> dependencies) {
|
||||
String parentId = getJobProcessor().getProperty().getId();
|
||||
final Set<JobInfo> clonedChildrenJobInfors = getJobProcessor().getBuildFirstChildrenJobs();
|
||||
@@ -279,6 +293,11 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
|
||||
property = jobInfo.getProcessItem().getProperty();
|
||||
groupId = PomIdsHelper.getJobGroupId(property);
|
||||
artifactId = PomIdsHelper.getJobArtifactId(jobInfo);
|
||||
// add artifact suffix "-bundle" for child job referenced by cTalendJob in OSGI build mode
|
||||
Object buildType = (getJobProcessor().getArguments() != null)? getJobProcessor().getArguments().get("BUILD_TYPE") : null;
|
||||
if(buildType != null && buildType.equals("ROUTE") && ERepositoryObjectType.getType(property).equals(ERepositoryObjectType.PROCESS)) {
|
||||
artifactId+="-bundle";
|
||||
}
|
||||
version = PomIdsHelper.getJobVersion(property);
|
||||
// try to get the pom version of children job and load from the pom file.
|
||||
String childPomFileName = PomUtil.getPomFileName(jobInfo.getJobName(), jobInfo.getJobVersion());
|
||||
|
||||
@@ -15,6 +15,7 @@ package org.talend.designer.maven.tools.creator;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
@@ -22,7 +23,10 @@ import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.model.general.ILibrariesService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
import org.talend.designer.maven.utils.PomIdsHelper;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
@@ -56,4 +60,17 @@ public class CreateMavenBeanPom extends AbstractMavenCodesTemplatePom {
|
||||
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addDependencies(Model model) {
|
||||
String projectTechName = getProjectName();
|
||||
String codeVersion = PomIdsHelper.getCodesVersion(projectTechName);
|
||||
String routinesGroupId = PomIdsHelper.getCodesGroupId(projectTechName, TalendMavenConstants.DEFAULT_CODE);
|
||||
String routinesArtifactId = TalendMavenConstants.DEFAULT_ROUTINES_ARTIFACT_ID;
|
||||
Dependency routinesDependency = PomUtil.createDependency(routinesGroupId, routinesArtifactId, codeVersion, null);
|
||||
model.getDependencies().add(routinesDependency);
|
||||
|
||||
super.addDependencies(model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -30,9 +31,7 @@ import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
@@ -46,7 +45,6 @@ import org.talend.core.model.process.ProcessUtils;
|
||||
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.SVNConstant;
|
||||
import org.talend.core.model.utils.JavaResourcesHelper;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
@@ -55,8 +53,10 @@ import org.talend.core.runtime.process.ITalendProcessJavaProject;
|
||||
import org.talend.core.runtime.process.JobInfoProperties;
|
||||
import org.talend.core.runtime.process.LastGenerationInfo;
|
||||
import org.talend.core.runtime.process.TalendProcessArgumentConstant;
|
||||
import org.talend.core.runtime.process.TalendProcessOptionConstants;
|
||||
import org.talend.core.runtime.projectsetting.IProjectSettingPreferenceConstants;
|
||||
import org.talend.core.runtime.projectsetting.IProjectSettingTemplateConstants;
|
||||
import org.talend.core.runtime.projectsetting.ProjectPreferenceManager;
|
||||
import org.talend.core.ui.ITestContainerProviderService;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
@@ -68,6 +68,7 @@ import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.designer.runprocess.IProcessor;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.RepositoryConstants;
|
||||
import org.talend.utils.io.FilesUtils;
|
||||
|
||||
/**
|
||||
@@ -194,10 +195,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);
|
||||
|
||||
@@ -215,18 +212,15 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
isOptionChecked(TalendProcessArgumentConstant.ARG_ENABLE_APPLY_CONTEXT_TO_CHILDREN),
|
||||
isOptionChecked(TalendProcessArgumentConstant.ARG_ENABLE_STATS));
|
||||
|
||||
checkPomProperty(properties, "talend.project.name", ETalendMavenVariables.ProjectName,
|
||||
jobInfoProp.getProperty(JobInfoProperties.PROJECT_NAME, project.getTechnicalLabel()));
|
||||
checkPomProperty(properties, "talend.project.name", ETalendMavenVariables.ProjectName, project.getTechnicalLabel());
|
||||
checkPomProperty(properties, "talend.project.name.lowercase", ETalendMavenVariables.ProjectName,
|
||||
jobInfoProp.getProperty(JobInfoProperties.PROJECT_NAME, project.getTechnicalLabel()).toLowerCase());
|
||||
project.getTechnicalLabel().toLowerCase());
|
||||
checkPomProperty(properties, "talend.routine.groupid", ETalendMavenVariables.RoutineGroupId,
|
||||
PomIdsHelper.getCodesGroupId(TalendMavenConstants.DEFAULT_CODE));
|
||||
checkPomProperty(properties, "talend.pigudf.groupid", ETalendMavenVariables.PigudfGroupId,
|
||||
PomIdsHelper.getCodesGroupId(TalendMavenConstants.DEFAULT_PIGUDF));
|
||||
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()));
|
||||
@@ -399,7 +393,7 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
if (codeProject == null) {
|
||||
return;
|
||||
}
|
||||
Property property = codeProject.getPropery();
|
||||
Property property = codeProject.getPropery() != null ? codeProject.getPropery() : processor.getProperty();
|
||||
if (property == null) {
|
||||
return;
|
||||
}
|
||||
@@ -412,8 +406,12 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
StringBuffer windowsScriptAdditionValue = new StringBuffer(50);
|
||||
StringBuffer unixScriptAdditionValue = new StringBuffer(50);
|
||||
|
||||
addScriptAddition(windowsScriptAdditionValue, this.getWindowsScriptAddition());
|
||||
addScriptAddition(unixScriptAdditionValue, this.getUnixScriptAddition());
|
||||
if (StringUtils.isNotEmpty(this.getWindowsScriptAddition())) {
|
||||
windowsScriptAdditionValue.append(this.getWindowsScriptAddition());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(this.getUnixScriptAddition())) {
|
||||
unixScriptAdditionValue.append(this.getUnixScriptAddition());
|
||||
}
|
||||
|
||||
// context
|
||||
if (isOptionChecked(TalendProcessArgumentConstant.ARG_NEED_CONTEXT)) {
|
||||
@@ -524,6 +522,21 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
|
||||
String jobInfoContent = MavenTemplateManager.getProjectSettingValue(IProjectSettingPreferenceConstants.TEMPLATE_JOB_INFO,
|
||||
templateParameters);
|
||||
String projectTechName = ProjectManager.getInstance().getProject(property).getTechnicalLabel();
|
||||
org.talend.core.model.general.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", false);
|
||||
mainProjectBranch = preferenceManager.getValue(RepositoryConstants.PROJECT_BRANCH_ID);
|
||||
if (mainProjectBranch == null) {
|
||||
mainProjectBranch = "";
|
||||
}
|
||||
}
|
||||
jobInfoContent = StringUtils.replace(jobInfoContent, "${talend.project.branch}", mainProjectBranch);
|
||||
|
||||
IFolder templateFolder = codeProject.getTemplatesFolder();
|
||||
IFile shFile = templateFolder.getFile(IProjectSettingTemplateConstants.JOB_RUN_SH_TEMPLATE_FILE_NAME);
|
||||
@@ -561,76 +574,91 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
childrenCoordinate.add(coordinate);
|
||||
}
|
||||
}
|
||||
|
||||
// add parent job
|
||||
Property parentProperty = this.getJobProcessor().getProperty();
|
||||
String parentCoordinate = PomIdsHelper.getJobGroupId(parentProperty) + ":" //$NON-NLS-1$
|
||||
+ PomIdsHelper.getJobArtifactId(parentProperty);
|
||||
addItem(jobIncludes, parentCoordinate, SEPARATOR);
|
||||
|
||||
try {
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(getPomFile());
|
||||
List<Dependency> dependencies = model.getDependencies();
|
||||
|
||||
Set<JobInfo> allJobs = LastGenerationInfo.getInstance().getLastGeneratedjobs();
|
||||
Set<ModuleNeeded> fullModulesList = new HashSet<>();
|
||||
for (JobInfo jobInfo : allJobs) {
|
||||
fullModulesList.addAll(LastGenerationInfo
|
||||
.getInstance()
|
||||
.getModulesNeededWithSubjobPerJob(
|
||||
jobInfo.getJobId(), jobInfo.getJobVersion()));
|
||||
// add talend libraries and codes
|
||||
Set<String> talendLibCoordinate = new HashSet<>();
|
||||
String projectTechName = ProjectManager.getInstance().getProject(parentProperty).getTechnicalLabel();
|
||||
String projectGroupId = PomIdsHelper.getProjectGroupId(projectTechName);
|
||||
// codes
|
||||
List<Dependency> dependencies = new ArrayList<>();
|
||||
addCodesDependencies(dependencies);
|
||||
for (Dependency dependency : dependencies) {
|
||||
String dependencyGroupId = dependency.getGroupId();
|
||||
String coordinate = dependencyGroupId + ":" + dependency.getArtifactId(); //$NON-NLS-1$
|
||||
addItem(talendlibIncludes, coordinate, SEPARATOR);
|
||||
talendLibCoordinate.add(coordinate);
|
||||
}
|
||||
// libraries
|
||||
dependencies.clear();
|
||||
Set<ModuleNeeded> modules =
|
||||
getJobProcessor().getNeededModules(
|
||||
TalendProcessOptionConstants.MODULES_WITH_JOBLET | TalendProcessOptionConstants.MODULES_EXCLUDE_SHADED);
|
||||
for (ModuleNeeded module : modules) {
|
||||
String mavenUri = module.getMavenUri();
|
||||
Dependency dependency = PomUtil.createModuleDependency(mavenUri);
|
||||
dependencies.add(dependency);
|
||||
}
|
||||
for (Dependency dependency : dependencies) {
|
||||
if (MavenConstants.PACKAGING_POM.equals(dependency.getType())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// add talend libraries and codes
|
||||
Set<String> talendLibCoordinate = new HashSet<>();
|
||||
String projectTechName = ProjectManager.getInstance().getProject(parentProperty).getTechnicalLabel();
|
||||
String projectGroupId = PomIdsHelper.getProjectGroupId(projectTechName);
|
||||
for (Dependency dependency : dependencies) {
|
||||
if (MavenConstants.PACKAGING_POM.equals(dependency.getType())) {
|
||||
continue;
|
||||
}
|
||||
String dependencyGroupId = dependency.getGroupId();
|
||||
String coordinate = dependencyGroupId + ":" + dependency.getArtifactId(); //$NON-NLS-1$
|
||||
if (!childrenCoordinate.contains(coordinate)) {
|
||||
if (MavenConstants.DEFAULT_LIB_GROUP_ID.equals(dependencyGroupId)
|
||||
|| dependencyGroupId.startsWith(projectGroupId)) {
|
||||
addItem(talendlibIncludes, coordinate, SEPARATOR);
|
||||
talendLibCoordinate.add(coordinate);
|
||||
}
|
||||
String dependencyGroupId = dependency.getGroupId();
|
||||
String coordinate = dependencyGroupId + ":" + dependency.getArtifactId(); //$NON-NLS-1$
|
||||
if (!childrenCoordinate.contains(coordinate)) {
|
||||
if (MavenConstants.DEFAULT_LIB_GROUP_ID.equals(dependencyGroupId)) {
|
||||
addItem(talendlibIncludes, coordinate, SEPARATOR);
|
||||
talendLibCoordinate.add(coordinate);
|
||||
}
|
||||
}
|
||||
// add 3rd party libraries
|
||||
Set<String> _3rdDepLib = new HashSet<>();
|
||||
for (Dependency dependency : dependencies) {
|
||||
if (MavenConstants.PACKAGING_POM.equals(dependency.getType())) {
|
||||
continue;
|
||||
}
|
||||
String coordinate = dependency.getGroupId() + ":" + dependency.getArtifactId(); //$NON-NLS-1$
|
||||
if (!childrenCoordinate.contains(coordinate) && !talendLibCoordinate.contains(coordinate)) {
|
||||
_3rdDepLib.add(coordinate);
|
||||
}
|
||||
|
||||
// add 3rd party libraries
|
||||
Set<String> _3rdDepLib = new HashSet<>();
|
||||
for (Dependency dependency : dependencies) {
|
||||
if (MavenConstants.PACKAGING_POM.equals(dependency.getType())) {
|
||||
continue;
|
||||
}
|
||||
String coordinate = dependency.getGroupId() + ":" + dependency.getArtifactId(); //$NON-NLS-1$
|
||||
if (!childrenCoordinate.contains(coordinate) && !talendLibCoordinate.contains(coordinate)) {
|
||||
_3rdDepLib.add(coordinate);
|
||||
addItem(_3rdPartylibExcludes, coordinate, SEPARATOR);
|
||||
}
|
||||
}
|
||||
|
||||
// add missing modules from the job generation of children
|
||||
Set<JobInfo> allJobs = LastGenerationInfo.getInstance().getLastGeneratedjobs();
|
||||
Set<ModuleNeeded> fullModulesList = new HashSet<>();
|
||||
for (JobInfo jobInfo : allJobs) {
|
||||
fullModulesList.addAll(LastGenerationInfo.getInstance().getModulesNeededWithSubjobPerJob(jobInfo.getJobId(),
|
||||
jobInfo.getJobVersion()));
|
||||
}
|
||||
for (ModuleNeeded moduleNeeded : fullModulesList) {
|
||||
if (moduleNeeded.isExcluded()) {
|
||||
continue;
|
||||
}
|
||||
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(moduleNeeded.getMavenUri());
|
||||
String coordinate = artifact.getGroupId() + ":" + artifact.getArtifactId(); //$NON-NLS-1$
|
||||
if (!childrenCoordinate.contains(coordinate) && !talendLibCoordinate.contains(coordinate)
|
||||
&& !_3rdDepLib.contains(coordinate)) {
|
||||
if (MavenConstants.DEFAULT_LIB_GROUP_ID.equals(artifact.getGroupId())
|
||||
|| artifact.getGroupId().startsWith(projectGroupId)) {
|
||||
addItem(talendlibIncludes, coordinate, SEPARATOR);
|
||||
} else {
|
||||
addItem(_3rdPartylibExcludes, coordinate, SEPARATOR);
|
||||
}
|
||||
}
|
||||
// add missing modules from the job generation of children
|
||||
for (ModuleNeeded moduleNeeded : fullModulesList) {
|
||||
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(moduleNeeded.getMavenUri());
|
||||
String coordinate = artifact.getGroupId() + ":" + artifact.getArtifactId(); //$NON-NLS-1$
|
||||
if (!childrenCoordinate.contains(coordinate) && !talendLibCoordinate.contains(coordinate)
|
||||
&& !_3rdDepLib.contains(coordinate)) {
|
||||
if (MavenConstants.DEFAULT_LIB_GROUP_ID.equals(artifact.getGroupId())
|
||||
|| artifact.getGroupId().startsWith(projectGroupId)) {
|
||||
addItem(talendlibIncludes, coordinate, SEPARATOR);
|
||||
} else {
|
||||
addItem(_3rdPartylibExcludes, coordinate, SEPARATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_3rdPartylibExcludes.length() == 0) {
|
||||
// if removed, it might add many unwanted dependencies to the libs folder. (or we should simply remove
|
||||
// the full empty block of dependencySet)
|
||||
addItem(_3rdPartylibExcludes, "null:null", SEPARATOR); //$NON-NLS-1$
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
if (_3rdPartylibExcludes.length() == 0) {
|
||||
// if removed, it might add many unwanted dependencies to the libs folder. (or we should simply remove
|
||||
// the full empty block of dependencySet)
|
||||
addItem(_3rdPartylibExcludes, "null:null", SEPARATOR); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
String talendLibIncludesStr = StringUtils.removeEnd(talendlibIncludes.toString(), SEPARATOR);
|
||||
|
||||
@@ -15,13 +15,17 @@ package org.talend.designer.maven.tools.creator;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.general.ILibrariesService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
import org.talend.designer.maven.utils.PomIdsHelper;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
@@ -47,4 +51,17 @@ public class CreateMavenPigUDFPom extends AbstractMavenCodesTemplatePom {
|
||||
}
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addDependencies(Model model) {
|
||||
String projectTechName = getProjectName();
|
||||
String codeVersion = PomIdsHelper.getCodesVersion(projectTechName);
|
||||
String routinesGroupId = PomIdsHelper.getCodesGroupId(projectTechName, TalendMavenConstants.DEFAULT_CODE);
|
||||
String routinesArtifactId = TalendMavenConstants.DEFAULT_ROUTINES_ARTIFACT_ID;
|
||||
Dependency routinesDependency = PomUtil.createDependency(routinesGroupId, routinesArtifactId, codeVersion, null);
|
||||
model.getDependencies().add(routinesDependency);
|
||||
|
||||
super.addDependencies(model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Set;
|
||||
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
@@ -43,9 +42,11 @@ import org.eclipse.m2e.core.project.ProjectImportConfiguration;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.generation.JavaUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.designer.maven.model.MavenSystemFolders;
|
||||
import org.talend.designer.maven.model.ProjectSystemFolder;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
|
||||
/**
|
||||
* DOC zwxue class global comment. Detailled comment
|
||||
@@ -93,8 +94,17 @@ public class MavenProjectUtils {
|
||||
return;
|
||||
}
|
||||
MavenPlugin.getProjectConfigurationManager().updateProjectConfiguration(project, monitor);
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getDefault()
|
||||
.getService(IRunProcessService.class);
|
||||
|
||||
changeClasspath(monitor, project);
|
||||
if (service.isdebug()) {
|
||||
changeClasspath(monitor, project, MavenSystemFolders.ALL_DIRS_EXT);
|
||||
} else {
|
||||
|
||||
changeClasspath(monitor, project);
|
||||
}
|
||||
}
|
||||
|
||||
// only need this when pom has no parent.
|
||||
// IJavaProject javaProject = JavaCore.create(project);
|
||||
@@ -102,6 +112,10 @@ public class MavenProjectUtils {
|
||||
}
|
||||
|
||||
public static void changeClasspath(IProgressMonitor monitor, IProject p) {
|
||||
changeClasspath(monitor, p, MavenSystemFolders.ALL_DIRS);
|
||||
}
|
||||
|
||||
public static void changeClasspath(IProgressMonitor monitor, IProject p, ProjectSystemFolder[] folders) {
|
||||
try {
|
||||
if (!p.hasNature(JavaCore.NATURE_ID)) {
|
||||
JavaUtils.addJavaNature(p, monitor);
|
||||
@@ -111,7 +125,7 @@ public class MavenProjectUtils {
|
||||
|
||||
List<IClasspathEntry> list = new LinkedList<>();
|
||||
ClasspathAttribute attribute = new ClasspathAttribute("maven.pomderived", Boolean.TRUE.toString());
|
||||
for (ProjectSystemFolder psf : MavenSystemFolders.ALL_DIRS) {
|
||||
for (ProjectSystemFolder psf : folders) {
|
||||
IFolder resources = p.getFolder(psf.getPath());
|
||||
if (resources.exists()) { // add the condition mostly for routines, since the resources folder might not exist
|
||||
IFolder output = p.getFolder(psf.getOutputPath());
|
||||
@@ -142,6 +156,7 @@ public class MavenProjectUtils {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear compliance settings from project, and set them into Eclipse compliance settings
|
||||
*
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2018 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.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
|
||||
public class MavenVersionHelper {
|
||||
|
||||
/**
|
||||
* compare maven artifact version
|
||||
*/
|
||||
public static int compareTo(String versionStr, String otherVersionStr) {
|
||||
DefaultArtifactVersion version = new DefaultArtifactVersion(versionStr);
|
||||
DefaultArtifactVersion otherVersion = new DefaultArtifactVersion(otherVersionStr);
|
||||
return version.compareTo(otherVersion);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -78,8 +78,12 @@ import org.talend.core.model.process.JobInfo;
|
||||
import org.talend.core.model.process.ProcessUtils;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.relationship.Relation;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.utils.JavaResourcesHelper;
|
||||
import org.talend.core.nexus.TalendMavenResolver;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
@@ -88,6 +92,7 @@ import org.talend.core.ui.branding.IBrandingService;
|
||||
import org.talend.designer.maven.model.TalendJavaProjectConstants;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
import org.talend.designer.maven.tools.AggregatorPomsHelper;
|
||||
import org.talend.designer.maven.tools.ProcessorDependenciesManager;
|
||||
import org.talend.designer.runprocess.IProcessor;
|
||||
import org.talend.repository.ProjectManager;
|
||||
@@ -105,6 +110,12 @@ public class PomUtil {
|
||||
|
||||
private static final MavenModelManager MODEL_MANAGER = MavenPlugin.getMavenModelManager();
|
||||
|
||||
private static RelationshipItemBuilder relationshipItemBuilder = RelationshipItemBuilder.getInstance();
|
||||
|
||||
private static ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
|
||||
|
||||
private static List<IFolder> bakJobletFolderCache = new ArrayList<>();
|
||||
|
||||
public static void savePom(IProgressMonitor monitor, Model model, IFile pomFile) throws Exception {
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
@@ -242,11 +253,10 @@ public class PomUtil {
|
||||
} else {
|
||||
// TODO, if existed, maybe just replace, not overwrite
|
||||
}
|
||||
Model codeProjectTemplateModel = MavenTemplateManager.getCodeProjectTemplateModel(templateParameters);
|
||||
|
||||
parent.setGroupId(codeProjectTemplateModel.getGroupId());
|
||||
parent.setArtifactId(codeProjectTemplateModel.getArtifactId());
|
||||
parent.setVersion(codeProjectTemplateModel.getVersion());
|
||||
String projectTechName = PomUtil.getProjectNameFromTemplateParameter(templateParameters);
|
||||
parent.setGroupId(PomIdsHelper.getProjectGroupId(projectTechName));
|
||||
parent.setArtifactId(PomIdsHelper.getProjectArtifactId());
|
||||
parent.setVersion(PomIdsHelper.getProjectVersion(projectTechName));
|
||||
|
||||
String relativePath = getPomRelativePath(curPomFile.getLocation().toFile());
|
||||
parent.setRelativePath(relativePath);
|
||||
@@ -860,6 +870,77 @@ public class PomUtil {
|
||||
|
||||
}
|
||||
|
||||
public static void checkJobRelatedJobletDependencies(Property mainProperty, String itemType,
|
||||
Set<String> childJobUrls, Set<Property> itemChecked, IProgressMonitor monitor) throws Exception {
|
||||
itemChecked.add(mainProperty);
|
||||
List<Relation> childItemRelations = getAllChildItemRelations(mainProperty, itemType);
|
||||
for (Relation relation : childItemRelations) {
|
||||
IRepositoryViewObject repositoryObject = null;
|
||||
if (RelationshipItemBuilder.LATEST_VERSION.equals(relation.getVersion())) {
|
||||
repositoryObject = repositoryFactory.getLastVersion(relation.getId());
|
||||
} else {
|
||||
repositoryObject = repositoryFactory.getSpecificVersion(relation.getId(), relation.getVersion(), true);
|
||||
}
|
||||
|
||||
if (repositoryObject != null && repositoryObject.getProperty() != null) {
|
||||
// to update joblet dependencies for loop
|
||||
if (relationshipItemBuilder.JOBLET_RELATION.equals(relation.getType())) {
|
||||
updateJobletDependencies4Loop(repositoryObject.getProperty(), childJobUrls, monitor);
|
||||
}
|
||||
|
||||
// in case of loop
|
||||
if (!itemChecked.contains(repositoryObject.getProperty())) {
|
||||
// if joblet existed in subjob / joblet
|
||||
checkJobRelatedJobletDependencies(repositoryObject.getProperty(), relation.getType(),
|
||||
childJobUrls, itemChecked, monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateJobletDependencies4Loop(Property jobletProperty, Set<String> childJobUrls, IProgressMonitor monitor)
|
||||
throws Exception {
|
||||
IFolder pomFolder = AggregatorPomsHelper.getItemPomFolder(jobletProperty);
|
||||
backupPomFile(pomFolder);
|
||||
// cached the backup pom file
|
||||
bakJobletFolderCache.add(pomFolder);
|
||||
|
||||
IFile jobletPomFile = pomFolder.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
Model jobletModel = MODEL_MANAGER.readMavenModel(jobletPomFile);
|
||||
List<Dependency> dependencies = jobletModel.getDependencies();
|
||||
List<Dependency> toRemove = new ArrayList<Dependency>();
|
||||
for (Dependency dependency : dependencies) {
|
||||
String mvnUrl = generateMvnUrl(dependency);
|
||||
if (childJobUrls.contains(mvnUrl)) {
|
||||
toRemove.add(dependency);
|
||||
}
|
||||
}
|
||||
dependencies.removeAll(toRemove);
|
||||
savePom(monitor, jobletModel, jobletPomFile);
|
||||
|
||||
}
|
||||
|
||||
private static List<Relation> getAllChildItemRelations(Property property, String itemType) {
|
||||
List<Relation> itemsRelatedTo = new ArrayList<Relation>();
|
||||
itemsRelatedTo.addAll(relationshipItemBuilder.getItemsChildRelatedTo(property.getId(), property.getVersion(), itemType,
|
||||
RelationshipItemBuilder.JOBLET_RELATION));
|
||||
itemsRelatedTo.addAll(relationshipItemBuilder.getItemsChildRelatedTo(property.getId(), property.getVersion(), itemType,
|
||||
RelationshipItemBuilder.JOB_RELATION));
|
||||
return itemsRelatedTo;
|
||||
}
|
||||
|
||||
public static void restoreJobletPoms() {
|
||||
for (IFolder folder : bakJobletFolderCache) {
|
||||
IFile backFile = folder.getFile(TalendMavenConstants.POM_BACKUP_FILE_NAME);
|
||||
IFile pomFile = folder.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
restorePomFile(pomFile, backFile);
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearBakJobletCache() {
|
||||
bakJobletFolderCache.clear();
|
||||
}
|
||||
|
||||
public static void backupPomFile(ITalendProcessJavaProject talendProject) {
|
||||
final IProject project = talendProject.getProject();
|
||||
final IFile backFile = project.getFile(TalendMavenConstants.POM_BACKUP_FILE_NAME);
|
||||
@@ -898,6 +979,10 @@ public class PomUtil {
|
||||
final IProject project = talendProject.getProject();
|
||||
final IFile backFile = project.getFile(TalendMavenConstants.POM_BACKUP_FILE_NAME);
|
||||
final IFile pomFile = project.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
restorePomFile(pomFile, backFile);
|
||||
}
|
||||
|
||||
public static void restorePomFile(IFile pomFile, IFile backFile) {
|
||||
try {
|
||||
updateFilesInWorkspaceRunnable(null, new IWorkspaceRunnable() {
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -137,7 +137,6 @@ public class ImportExternalJarAction extends Action {
|
||||
LibManagerUiPlugin.getDefault().getLibrariesService().deployLibrary(file.toURL(), mvnURI, false);
|
||||
if (!modulesNeededNames.contains(moduleName)) {
|
||||
String mavenUri = MavenUrlHelper.generateMvnUrlForJarName(moduleName, true, true);
|
||||
CustomUriManager.getInstance().put(mavenUri, mavenUri);
|
||||
ModulesNeededProvider.addUnknownModules(moduleName, mavenUri, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -878,7 +878,7 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
|
||||
}
|
||||
|
||||
// change the custom uri
|
||||
if (saveCustomMap) {
|
||||
if (saveCustomMap&&ModulesNeededProvider.getAllModuleNamesFromIndex().contains(moduleName)) {
|
||||
testModule.setCustomMavenUri(customURI);
|
||||
ILibraryManagerService libManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibraryManagerService.class);
|
||||
|
||||
@@ -70,12 +70,10 @@ public class NexusDownloadHelperWithProgress extends DownloadHelperWithProgress
|
||||
mArtifact.getVersion(), mArtifact.getType(), mArtifact.getClassifier());
|
||||
progressMonitor.subTask(
|
||||
"Downloading " + toInstall.getName() + ": " + resolvedMvnUri + " from " + customNexusServer.getServer());
|
||||
ILibraryManagerService libManager = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibraryManagerService.class);
|
||||
// seems the customNexusServer is not used in resolveJar function, so still need to provide
|
||||
// user/password in the mvn uri
|
||||
String decryptedMvnUri = MavenUrlHelper.generateMvnUrl(mArtifact);
|
||||
resolved = libManager.resolveJar(customNexusServer, decryptedMvnUri);
|
||||
resolved = resolveJar(customNexusServer, decryptedMvnUri);
|
||||
if (resolved != null && resolved.exists()) {
|
||||
return;
|
||||
}
|
||||
@@ -88,9 +86,7 @@ public class NexusDownloadHelperWithProgress extends DownloadHelperWithProgress
|
||||
// String mvnUri = componentUrl.toExternalForm();
|
||||
progressMonitor.subTask("Downloading " + toInstall.getName() + ": " + mvnUri + " from "
|
||||
+ customNexusServer.getServer());
|
||||
ILibraryManagerService libManager = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibraryManagerService.class);
|
||||
resolved = libManager.resolveJar(customNexusServer, mvnUri);
|
||||
resolved = resolveJar(customNexusServer, mvnUri);
|
||||
}
|
||||
}
|
||||
if (resolved != null && resolved.exists()) {
|
||||
@@ -99,6 +95,28 @@ public class NexusDownloadHelperWithProgress extends DownloadHelperWithProgress
|
||||
super.download(componentUrl, destination, progressMonitor);
|
||||
}
|
||||
|
||||
private File resolveJar(NexusServerBean customNexusServer, String decryptedMvnUri) throws Exception {
|
||||
ILibraryManagerService libManager = (ILibraryManagerService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
File resolved = null;
|
||||
try {
|
||||
resolved = libManager.resolveJar(customNexusServer, decryptedMvnUri);
|
||||
} catch (Exception e) {
|
||||
// hide the user/password in the error
|
||||
String account = customNexusServer.getUserName() + ":" + customNexusServer.getPassword() + "@";
|
||||
String message = e.getMessage();
|
||||
message = message.replaceAll(account, "");
|
||||
Exception cause = null;
|
||||
if (e.getCause() != null) {
|
||||
String causeMessage = e.getCause().getMessage();
|
||||
causeMessage = causeMessage.replaceAll(causeMessage, "");
|
||||
cause = new Exception(causeMessage);
|
||||
}
|
||||
throw new Exception(message, cause);
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -9,6 +9,9 @@ import java.text.DateFormat;
|
||||
import java.text.FieldPosition;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.DateTimeException;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
@@ -257,6 +260,47 @@ public class TalendDate {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests string value as a date with right pattern using strict rules.
|
||||
* This validation uses Java 8 time tools such {@link DateTimeFormatter#parse }
|
||||
* and {@link DateTimeFormatter#format }
|
||||
* </br>
|
||||
* </br>
|
||||
* Examples:
|
||||
* </br>
|
||||
* <code>isDateStrict("20110327 121711", "yyyyMMdd HHmmss")</code> return <code>true</code></br>
|
||||
* <code>isDateStrict("01100327 121711", "yyyyMMdd HHmmss")</code> return <code>false</code></br>
|
||||
* <code>isDateStrict("20180229 221711", "yyyyMMdd HHmmss")</code> return <code>false</code></br>
|
||||
* <code>isDateStrict("2016-02-29 22:17:11", "yyyy-MM-dd HH:mm:ss")</code> return <code>true</code></br>
|
||||
* <code>isDateStrict("2011/03/27 22:17:11+0100", "yyyy/MM/dd HH:mm:ssZ")</code> return <code>true</code></br>
|
||||
* <code>isDateStrict("20110327 021711+1900", "yyyyMMdd HHmmssZ")</code> return <code>false</code></br>
|
||||
* </br>
|
||||
* The range of time-zone offsets is restricted to -18:00 to 18:00 inclusive.
|
||||
*
|
||||
* @param stringDate the date to judge
|
||||
* @param pattern the specified pattern, like: "yyyy-MM-dd HH:mm:ss")
|
||||
* @return whether the stringDate is a date string with a right pattern.
|
||||
* @throws IllegalArgumentException if pattern is not defined.
|
||||
*
|
||||
*/
|
||||
public static boolean isDateStrict(String stringDate, String pattern) {
|
||||
if (stringDate == null) {
|
||||
return false;
|
||||
}
|
||||
DateTimeFormatter formatter = java.util.Optional
|
||||
.ofNullable(pattern)
|
||||
.filter((entry) -> !entry.isEmpty())
|
||||
.map(DateTimeFormatter::ofPattern)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Date format is not defined"));
|
||||
try {
|
||||
TemporalAccessor testDate = formatter.parse(stringDate);
|
||||
String formattedString = formatter.format(testDate);
|
||||
return stringDate.equalsIgnoreCase(formattedString);
|
||||
} catch (DateTimeException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* compare two date
|
||||
*
|
||||
|
||||
@@ -125,6 +125,11 @@ public class ModulesNeededProvider {
|
||||
private static final List<IChangedLibrariesListener> listeners = new ArrayList<IChangedLibrariesListener>();
|
||||
|
||||
private static IRepositoryService service = null;
|
||||
|
||||
private static List<ModuleNeeded> importNeedsListForRoutes;
|
||||
|
||||
private static List<ModuleNeeded> importNeedsListForBeans;
|
||||
|
||||
static {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
|
||||
service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
@@ -301,7 +306,6 @@ public class ModulesNeededProvider {
|
||||
toAdd = new ModuleNeeded("Job " + process.getName(), "Required for the job " + process.getName() + ".", true,
|
||||
neededLibrary.getMavenUri());
|
||||
|
||||
toAdd.setCustomMavenUri(neededLibrary.getMavenUri());
|
||||
|
||||
} else {
|
||||
toAdd = new ModuleNeeded("Job " + process.getName(), neededLibrary.getModuleName(), //$NON-NLS-1$
|
||||
@@ -312,9 +316,6 @@ public class ModulesNeededProvider {
|
||||
getAllManagedModules().add(toAdd);
|
||||
}
|
||||
|
||||
ILibraryManagerService libManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
libManagerService.saveCustomMavenURIMap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -698,10 +699,19 @@ public class ModulesNeededProvider {
|
||||
EList imports = routine.getImports();
|
||||
for (Object o : imports) {
|
||||
IMPORTType currentImport = (IMPORTType) o;
|
||||
boolean isRequired = currentImport.isREQUIRED();
|
||||
// FIXME SML i18n
|
||||
ModuleNeeded toAdd = new ModuleNeeded(context, currentImport.getMODULE(), currentImport.getMESSAGE(),
|
||||
currentImport.isREQUIRED());
|
||||
isRequired);
|
||||
toAdd.setMavenUri(currentImport.getMVN());
|
||||
if (!isRequired) {
|
||||
if ("BeanItem".equals(routine.eClass().getName())) {
|
||||
toAdd.getExtraAttributes().put("IS_OSGI_EXCLUDED", Boolean.TRUE);
|
||||
}
|
||||
if ("RoutineItem".equals(routine.eClass().getName())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// toAdd.setStatus(ELibraryInstallStatus.INSTALLED);
|
||||
importNeedsList.add(toAdd);
|
||||
}
|
||||
@@ -746,22 +756,29 @@ public class ModulesNeededProvider {
|
||||
}
|
||||
|
||||
public static List<ModuleNeeded> getModulesNeededForRoutes() {
|
||||
List<ModuleNeeded> importNeedsList = new ArrayList<ModuleNeeded>();
|
||||
importNeedsList.add(getComponentModuleById("CAMEL", "camel-core"));
|
||||
importNeedsList.add(getComponentModuleById("CAMEL", "camel-spring"));
|
||||
importNeedsList.add(getComponentModuleById("CAMEL", "spring-context"));
|
||||
importNeedsList.add(getComponentModuleById("CAMEL", "spring-beans"));
|
||||
importNeedsList.add(getComponentModuleById("CAMEL", "spring-core"));
|
||||
return importNeedsList;
|
||||
if (importNeedsListForRoutes == null) {
|
||||
importNeedsListForRoutes = new ArrayList<ModuleNeeded>();
|
||||
importNeedsListForRoutes.add(getComponentModuleById("CAMEL", "camel-core"));
|
||||
importNeedsListForRoutes.add(getComponentModuleById("CAMEL", "camel-spring"));
|
||||
importNeedsListForRoutes.add(getComponentModuleById("CAMEL", "spring-context"));
|
||||
importNeedsListForRoutes.add(getComponentModuleById("CAMEL", "spring-beans"));
|
||||
importNeedsListForRoutes.add(getComponentModuleById("CAMEL", "spring-core"));
|
||||
}
|
||||
return importNeedsListForRoutes;
|
||||
}
|
||||
|
||||
public static List<ModuleNeeded> getModulesNeededForBeans() {
|
||||
List<ModuleNeeded> importNeedsList = getModulesNeededForRoutes();
|
||||
|
||||
importNeedsList.add(getComponentModuleById("CAMEL", "camel-cxf"));
|
||||
importNeedsList.add(getComponentModuleById("CAMEL", "cxf-core"));
|
||||
importNeedsList.add(getComponentModuleById("CAMEL", "javax.ws.rs-api"));
|
||||
return importNeedsList;
|
||||
if (importNeedsListForBeans == null) {
|
||||
|
||||
importNeedsListForBeans = getModulesNeededForRoutes();
|
||||
importNeedsListForBeans.add(getComponentModuleById("CAMEL", "camel-cxf"));
|
||||
importNeedsListForBeans.add(getComponentModuleById("CAMEL", "cxf-core"));
|
||||
importNeedsListForBeans.add(getComponentModuleById("CAMEL", "javax.ws.rs-api"));
|
||||
for (ModuleNeeded need : importNeedsListForBeans) {
|
||||
need.setRequired(false);
|
||||
}
|
||||
}
|
||||
return importNeedsListForBeans;
|
||||
}
|
||||
|
||||
private static void getRefRoutines(List<IRepositoryViewObject> routines, Project mainProject, ERepositoryObjectType type) {
|
||||
|
||||
@@ -65,8 +65,10 @@ import org.talend.core.model.general.ILibrariesService.IChangedLibrariesListener
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
|
||||
import org.talend.core.model.general.ModuleStatusProvider;
|
||||
import org.talend.core.nexus.IRepositoryArtifactHandler;
|
||||
import org.talend.core.nexus.NexusServerBean;
|
||||
import org.talend.core.nexus.NexusServerUtils;
|
||||
import org.talend.core.nexus.RepositoryArtifactHandlerManager;
|
||||
import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.nexus.TalendMavenResolver;
|
||||
import org.talend.core.prefs.ITalendCorePrefConstants;
|
||||
@@ -438,22 +440,19 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
|
||||
public long daysBetween(final Calendar startDate, final Calendar endDate) {
|
||||
// assert: startDate must be before endDate
|
||||
int MILLIS_IN_DAY = 1000 * 60 * 60 * 24;
|
||||
long endInstant = endDate.getTimeInMillis();
|
||||
int presumedDays = (int) ((endInstant - startDate.getTimeInMillis()) / MILLIS_IN_DAY);
|
||||
Calendar cursor = (Calendar) startDate.clone();
|
||||
cursor.add(Calendar.DAY_OF_YEAR, presumedDays);
|
||||
long instant = cursor.getTimeInMillis();
|
||||
if (instant == endInstant) {
|
||||
return presumedDays;
|
||||
}
|
||||
Calendar sd = (Calendar) startDate.clone();
|
||||
Calendar ed = (Calendar) endDate.clone();
|
||||
sd.set(Calendar.HOUR, 0);
|
||||
sd.set(Calendar.MINUTE, 0);
|
||||
sd.set(Calendar.SECOND, 0);
|
||||
sd.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
final int step = instant < endInstant ? 1 : -1;
|
||||
do {
|
||||
cursor.add(Calendar.DAY_OF_MONTH, step);
|
||||
presumedDays += step;
|
||||
} while (cursor.getTimeInMillis() <= endInstant);
|
||||
return presumedDays - 1;
|
||||
ed.set(Calendar.HOUR, 0);
|
||||
ed.set(Calendar.MINUTE, 0);
|
||||
ed.set(Calendar.SECOND, 0);
|
||||
ed.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
return Math.abs(ed.getTimeInMillis() - sd.getTimeInMillis()) / (1l * 24 * 3600 * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1185,6 +1184,28 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
|
||||
// deploy needed jars for User and Exchange component providers
|
||||
if (!needToDeploy.isEmpty()) {
|
||||
// search on nexus to avoid deploy the jar many times
|
||||
Set<File> existFiles = new HashSet<File>();
|
||||
NexusServerBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
|
||||
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager
|
||||
.getRepositoryHandler(customNexusServer);
|
||||
if (customerRepHandler != null) {
|
||||
List<MavenArtifact> searchResult = new ArrayList<>();
|
||||
try {
|
||||
searchResult = customerRepHandler.search(MavenConstants.DEFAULT_LIB_GROUP_ID, null, null, true, true);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
for (MavenArtifact artifact : searchResult) {
|
||||
for (File file : needToDeploy) {
|
||||
if (artifact.getFileName().equals(file.getName())) {
|
||||
existFiles.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
needToDeploy.removeAll(existFiles);
|
||||
for (File file : needToDeploy) {
|
||||
try {
|
||||
deploy(file.toURI());
|
||||
|
||||
@@ -80,7 +80,8 @@ public abstract class AbstractArtifactRepositoryHandler implements IRepositoryAr
|
||||
repositories = releaseUrl;
|
||||
}
|
||||
if (snapshot_rep != null) {
|
||||
String snapshotUrl = custom_server + snapshot_rep + "@id=" + snapshot_rep + NexusConstants.SNAPSHOTS;//$NON-NLS-1$
|
||||
String snapshotUrl = custom_server + snapshot_rep + "@id=" + snapshot_rep + NexusConstants.SNAPSHOTS //$NON-NLS-1$
|
||||
+ NexusConstants.DISALLOW_RELEASES;
|
||||
if (repositories != null) {
|
||||
repositories = repositories + "," + snapshotUrl;
|
||||
} else {
|
||||
|
||||
@@ -169,6 +169,7 @@ public class Nexus3RepositoryHandler extends AbstractArtifactRepositoryHandler {
|
||||
artifact.setVersion(jsonObject.getString("version"));
|
||||
artifact.setType(jsonObject.getString("extension"));
|
||||
artifact.setDescription(jsonObject.getString("description"));
|
||||
artifact.setLastUpdated(jsonObject.getString("last_updated"));
|
||||
// artifact.setLicense(jsonObject.getString("license"));
|
||||
// artifact.setLicenseUrl(jsonObject.getString("licenseUrl"));
|
||||
// artifact.setUrl(jsonObject.getString("url"));
|
||||
|
||||
@@ -1049,7 +1049,12 @@ public final class ConnectionContextHelper {
|
||||
|
||||
public static Set<String> retrieveContextVar(List<? extends IElementParameter> elementParameters, Connection connection,
|
||||
EComponentCategory category) {
|
||||
return retrieveContextVar(elementParameters, connection, category, false);
|
||||
return retrieveContextVar(elementParameters, connection, category, false, new HashMap<Object, Object>());
|
||||
}
|
||||
|
||||
public static Set<String> retrieveContextVar(List<? extends IElementParameter> elementParameters, Connection connection,
|
||||
EComponentCategory category, Map<Object, Object> contextData) {
|
||||
return retrieveContextVar(elementParameters, connection, category, false, contextData);
|
||||
}
|
||||
|
||||
public static boolean isGenericConnection(Connection connection){
|
||||
@@ -1062,9 +1067,14 @@ public final class ConnectionContextHelper {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static Set<String> retrieveContextVar(List<? extends IElementParameter> elementParameters, Connection connection,
|
||||
EComponentCategory category, boolean onlyConsiderShowedParam) {
|
||||
return retrieveContextVar(elementParameters, connection, category, onlyConsiderShowedParam, new HashMap<Object, Object>());
|
||||
}
|
||||
|
||||
public static Set<String> retrieveContextVar(List<? extends IElementParameter> elementParameters, Connection connection,
|
||||
EComponentCategory category, boolean onlyConsiderShowedParam, Map<Object, Object> contextData) {
|
||||
if (elementParameters == null || connection == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -1077,7 +1087,7 @@ public final class ConnectionContextHelper {
|
||||
if (category == null || category == param.getCategory()) {
|
||||
String repositoryValue = param.getRepositoryValue();
|
||||
if (repositoryValue != null) {
|
||||
Object objectValue = RepositoryToComponentProperty.getValue(connection, repositoryValue, null);
|
||||
Object objectValue = RepositoryToComponentProperty.getValue(connection, repositoryValue, null, null, contextData);
|
||||
|
||||
if (objectValue != null) {
|
||||
if (objectValue instanceof List) {
|
||||
|
||||
@@ -89,8 +89,7 @@ public class ExtractMetaDataFromDataBase {
|
||||
TABLETYPE_CALCULATION_VIEW("CALCULATION VIEW"), //$NON-NLS-1$
|
||||
TABLETYPE_ALL_SYNONYM("ALL_SYNONYM"), //$NON-NLS-1$
|
||||
TABLETYPE_ALIAS("ALIAS"), //$NON-NLS-1$
|
||||
TABLETYPE_EXTERNAL_TABLE("EXTERNAL TABLE"), //$NON-NLS-1$ //Added by Marvin Wang on Feb. 5, 2012 for bug TDI-24413.
|
||||
EXTERNAL_TABLE("EXTERNAL_TABLE"), //$NON-NLS-1$ // for hive
|
||||
EXTERNAL_TABLE("EXTERNAL_TABLE"), //$NON-NLS-1$
|
||||
MANAGED_TABLE("MANAGED_TABLE"), //$NON-NLS-1$ // for hive
|
||||
INDEX_TABLE("INDEX_TABLE"), //$NON-NLS-1$ // for hive
|
||||
VIRTUAL_VIEW("VIRTUAL_VIEW"), //$NON-NLS-1$ // for hive
|
||||
|
||||
@@ -1023,8 +1023,7 @@ public class DBConnectionFillerImpl extends MetadataFillerImpl<DatabaseConnectio
|
||||
|
||||
metadatatable.setName(tableName);
|
||||
// Added by Marvin Wang on Feb. 6, 2012 for bug TDI-24413, it is just for hive external table.
|
||||
if (ETableTypes.TABLETYPE_EXTERNAL_TABLE.getName().equals(temptableType)
|
||||
|| ETableTypes.EXTERNAL_TABLE.getName().equals(temptableType)
|
||||
if (ETableTypes.EXTERNAL_TABLE.getName().equals(temptableType)
|
||||
|| ETableTypes.MANAGED_TABLE.getName().equals(temptableType)
|
||||
|| ETableTypes.INDEX_TABLE.getName().equals(temptableType)
|
||||
|| ETableTypes.TABLETYPE_BASE_TABLE.getName().equals(temptableType)) {
|
||||
|
||||
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||
org.talend.commons.runtime,
|
||||
org.apache.commons.lang,
|
||||
org.talend.core.repository,
|
||||
org.talend.utils
|
||||
org.talend.utils,
|
||||
org.talend.core
|
||||
Eclipse-LazyStart: true
|
||||
Export-Package: org.talend.migrationtool.model
|
||||
Eclipse-RegisterBuddy: org.talend.testutils
|
||||
|
||||
@@ -59,6 +59,7 @@ import org.talend.core.model.utils.MigrationUtil;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.repository.utils.RoutineUtils;
|
||||
import org.talend.core.repository.utils.URIHelper;
|
||||
import org.talend.core.services.ICoreTisService;
|
||||
import org.talend.designer.codegen.ICodeGeneratorService;
|
||||
import org.talend.designer.codegen.ITalendSynchronizer;
|
||||
import org.talend.migration.IMigrationTask;
|
||||
@@ -398,7 +399,19 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
|
||||
if (object.getProperty().eResource() == null) { // In case some
|
||||
// migration task has
|
||||
// unloaded.
|
||||
object = repFactory.getSpecificVersion(object.getProperty().getId(),
|
||||
object.getProperty().getVersion(), true);
|
||||
}
|
||||
if (object != null) {
|
||||
ICoreTisService service = (ICoreTisService)GlobalServiceRegister.getDefault()
|
||||
.getService(ICoreTisService.class);
|
||||
service.afterImport(object.getProperty());
|
||||
}
|
||||
}
|
||||
if (object instanceof RepositoryObject) {
|
||||
((RepositoryObject) object).unload();
|
||||
}
|
||||
@@ -534,6 +547,11 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
ProductVersion topTaskVersion = new ProductVersion(0, 0, 0);
|
||||
ProductVersion topTaskBreaks = new ProductVersion(0, 0, 0);
|
||||
for (MigrationTask task : migrationTasks) {
|
||||
// check wrong version first to improve performance
|
||||
if (GetTasksHelper.UpdateTmatchGroupComputeGrpQualityParamTask_wrongVersion.equals(task.getBreaks())
|
||||
&& GetTasksHelper.UpdateTmatchGroupComputeGrpQualityParamTask.equals(task.getId())) {
|
||||
task.setBreaks(GetTasksHelper.UpdateTmatchGroupComputeGrpQualityParamTask_correctVersion);
|
||||
}
|
||||
IProjectMigrationTask productMigrationTask = GetTasksHelper.getInstance().getProjectTask(task.getId());
|
||||
if (productMigrationTask != null) { // If the the migration task already applyed before, ignore it.
|
||||
continue;
|
||||
|
||||
@@ -34,6 +34,12 @@ import org.talend.migration.IWorkspaceMigrationTask;
|
||||
*/
|
||||
public class GetTasksHelper {
|
||||
|
||||
public static final String UpdateTmatchGroupComputeGrpQualityParamTask = "org.talend.datacleansing.core.migration.UpdateTmatchGroupComputeGrpQualityParamTask"; //$NON-NLS-1$
|
||||
|
||||
public static final String UpdateTmatchGroupComputeGrpQualityParamTask_wrongVersion = "7.0.1"; //$NON-NLS-1$
|
||||
|
||||
public static final String UpdateTmatchGroupComputeGrpQualityParamTask_correctVersion = "6.5.1"; //$NON-NLS-1$
|
||||
|
||||
private static GetTasksHelper instance = null;
|
||||
|
||||
private Map<String, IProjectMigrationTask> migrationsInstances = null;
|
||||
@@ -86,6 +92,11 @@ public class GetTasksHelper {
|
||||
currentAction.setDescription(configurationElement.getAttribute("description")); //$NON-NLS-1$
|
||||
currentAction.setVersion(configurationElement.getAttribute("version"));
|
||||
currentAction.setBreaks(configurationElement.getAttribute("breaks"));
|
||||
if (UpdateTmatchGroupComputeGrpQualityParamTask_wrongVersion.equals(currentAction.getBreaks())
|
||||
&& UpdateTmatchGroupComputeGrpQualityParamTask.equals(currentAction.getId())) {
|
||||
// keep the breaks version same with the task configured in plugin.xml
|
||||
currentAction.setBreaks(UpdateTmatchGroupComputeGrpQualityParamTask_correctVersion);
|
||||
}
|
||||
return currentAction;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
@@ -132,6 +143,11 @@ public class GetTasksHelper {
|
||||
currentAction.setDescription(configurationElement.getAttribute("description")); //$NON-NLS-1$
|
||||
currentAction.setVersion(configurationElement.getAttribute("version"));
|
||||
currentAction.setBreaks(configurationElement.getAttribute("breaks"));
|
||||
if (UpdateTmatchGroupComputeGrpQualityParamTask_wrongVersion.equals(currentAction.getBreaks())
|
||||
&& UpdateTmatchGroupComputeGrpQualityParamTask.equals(currentAction.getId())) {
|
||||
// keep the breaks version same with the task configured in plugin.xml
|
||||
currentAction.setBreaks(UpdateTmatchGroupComputeGrpQualityParamTask_correctVersion);
|
||||
}
|
||||
return currentAction;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
|
||||
@@ -111,6 +111,7 @@ public abstract class FileItemImpl extends ItemImpl implements FileItem {
|
||||
*
|
||||
* @generated
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -120,11 +121,13 @@ public abstract class FileItemImpl extends ItemImpl implements FileItem {
|
||||
*
|
||||
* @generated
|
||||
*/
|
||||
@Override
|
||||
public void setName(String newName) {
|
||||
String oldName = name;
|
||||
name = newName;
|
||||
if (eNotificationRequired())
|
||||
if (eNotificationRequired()) {
|
||||
eNotify(new ENotificationImpl(this, Notification.SET, PropertiesPackage.FILE_ITEM__NAME, oldName, name));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,6 +135,7 @@ public abstract class FileItemImpl extends ItemImpl implements FileItem {
|
||||
*
|
||||
* @generated
|
||||
*/
|
||||
@Override
|
||||
public String getExtension() {
|
||||
return extension;
|
||||
}
|
||||
@@ -141,11 +145,14 @@ public abstract class FileItemImpl extends ItemImpl implements FileItem {
|
||||
*
|
||||
* @generated
|
||||
*/
|
||||
@Override
|
||||
public void setExtension(String newExtension) {
|
||||
String oldExtension = extension;
|
||||
extension = newExtension;
|
||||
if (eNotificationRequired())
|
||||
eNotify(new ENotificationImpl(this, Notification.SET, PropertiesPackage.FILE_ITEM__EXTENSION, oldExtension, extension));
|
||||
if (eNotificationRequired()) {
|
||||
eNotify(new ENotificationImpl(this, Notification.SET, PropertiesPackage.FILE_ITEM__EXTENSION, oldExtension,
|
||||
extension));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,14 +160,16 @@ public abstract class FileItemImpl extends ItemImpl implements FileItem {
|
||||
*
|
||||
* @generated
|
||||
*/
|
||||
@Override
|
||||
public ByteArray getContent() {
|
||||
if (content != null && content.eIsProxy()) {
|
||||
InternalEObject oldContent = (InternalEObject) content;
|
||||
content = (ByteArray) eResolveProxy(oldContent);
|
||||
if (content != oldContent) {
|
||||
if (eNotificationRequired())
|
||||
eNotify(new ENotificationImpl(this, Notification.RESOLVE, PropertiesPackage.FILE_ITEM__CONTENT, oldContent,
|
||||
content));
|
||||
if (eNotificationRequired()) {
|
||||
eNotify(new ENotificationImpl(this, Notification.RESOLVE, PropertiesPackage.FILE_ITEM__CONTENT,
|
||||
oldContent, content));
|
||||
}
|
||||
}
|
||||
}
|
||||
return content;
|
||||
@@ -180,11 +189,14 @@ public abstract class FileItemImpl extends ItemImpl implements FileItem {
|
||||
*
|
||||
* @generated
|
||||
*/
|
||||
@Override
|
||||
public void setContent(ByteArray newContent) {
|
||||
ByteArray oldContent = content;
|
||||
content = newContent;
|
||||
if (eNotificationRequired())
|
||||
eNotify(new ENotificationImpl(this, Notification.SET, PropertiesPackage.FILE_ITEM__CONTENT, oldContent, content));
|
||||
if (eNotificationRequired()) {
|
||||
eNotify(new ENotificationImpl(this, Notification.SET, PropertiesPackage.FILE_ITEM__CONTENT, oldContent,
|
||||
content));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,8 +212,9 @@ public abstract class FileItemImpl extends ItemImpl implements FileItem {
|
||||
case PropertiesPackage.FILE_ITEM__EXTENSION:
|
||||
return getExtension();
|
||||
case PropertiesPackage.FILE_ITEM__CONTENT:
|
||||
if (resolve)
|
||||
if (resolve) {
|
||||
return getContent();
|
||||
}
|
||||
return basicGetContent();
|
||||
}
|
||||
return super.eGet(featureID, resolve, coreType);
|
||||
@@ -274,8 +287,9 @@ public abstract class FileItemImpl extends ItemImpl implements FileItem {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (eIsProxy())
|
||||
if (eIsProxy()) {
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
StringBuffer result = new StringBuffer(super.toString());
|
||||
result.append(" (name: ");
|
||||
@@ -304,7 +318,8 @@ public abstract class FileItemImpl extends ItemImpl implements FileItem {
|
||||
URIConverter theURIConverter = resourceSet.getURIConverter();
|
||||
URI normalizedURI = theURIConverter.normalize(resourceUri);
|
||||
// TUP-1814:because the routine proxyUri is File type,need handle with it.
|
||||
if ((proxyUri.isPlatform() && proxyUri.segmentCount() > 1 && "resource".equals(proxyUri.segment(0))) || proxyUri.isFile()) {
|
||||
if ((proxyUri.isPlatform() && proxyUri.segmentCount() > 1 && "resource".equals(proxyUri.segment(0)))
|
||||
|| proxyUri.isFile()) {
|
||||
List<Resource> resources = resourceSet.getResources();
|
||||
synchronized (resources) {
|
||||
for (Resource resource : resources) {
|
||||
@@ -315,6 +330,12 @@ public abstract class FileItemImpl extends ItemImpl implements FileItem {
|
||||
}
|
||||
}
|
||||
|
||||
if (byteArrayResource != null && byteArrayResource.getContents().isEmpty()
|
||||
&& byteArrayResource.isLoaded()) {
|
||||
resources.remove(byteArrayResource);
|
||||
byteArrayResource = null;
|
||||
}
|
||||
|
||||
if (byteArrayResource == null) {
|
||||
byteArrayResource = new ByteArrayResource(resourceUri);
|
||||
resourceSet.getResources().add(byteArrayResource);
|
||||
|
||||
@@ -10,7 +10,9 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||
org.talend.model,
|
||||
org.talend.commons.runtime,
|
||||
org.talend.core.runtime,
|
||||
org.talend.core.repository
|
||||
org.talend.core.repository,
|
||||
org.talend.designer.maven,
|
||||
org.talend.core
|
||||
Bundle-Localization: plugin
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Eclipse-RegisterBuddy: org.talend.testutils
|
||||
|
||||
@@ -13,14 +13,15 @@
|
||||
package org.talend.repository.items.importexport.handlers.exports;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.talend.commons.runtime.utils.io.FileCopyUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.process.JobInfo;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.runtime.process.ITalendProcessJavaProject;
|
||||
import org.talend.core.runtime.repository.build.IBuildResourcesProvider;
|
||||
@@ -41,6 +42,7 @@ public class SyncChildrenContextsResourcesProvider implements IBuildResourcesPro
|
||||
* org.talend.core.runtime.repository.build.IBuildResourcesProvider#prepare(org.eclipse.core.runtime.IProgressMonitor
|
||||
* , java.util.Map)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void prepare(IProgressMonitor monitor, Map<String, Object> parameters) throws Exception {
|
||||
if (parameters == null) {
|
||||
@@ -55,7 +57,8 @@ public class SyncChildrenContextsResourcesProvider implements IBuildResourcesPro
|
||||
if (processItem == null) {
|
||||
return;
|
||||
}
|
||||
final List dependenciesItems = (List) ParametersUtil.getObject(parameters, OBJ_ITEM_DEPENDENCIES, List.class);
|
||||
final Set<JobInfo> dependenciesItems = (Set<JobInfo>) ParametersUtil.getObject(parameters, OBJ_ITEM_DEPENDENCIES,
|
||||
Set.class);
|
||||
if (dependenciesItems == null || dependenciesItems.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -67,19 +70,15 @@ public class SyncChildrenContextsResourcesProvider implements IBuildResourcesPro
|
||||
|
||||
final IFolder mainResourcesFolder = processJavaProject.getExternalResourcesFolder();
|
||||
final File targetFolder = mainResourcesFolder.getLocation().toFile();
|
||||
|
||||
for (Object item : dependenciesItems) {
|
||||
if (item instanceof ProcessItem) {
|
||||
ITalendProcessJavaProject childJavaProject = runProcessService.getTalendJobJavaProject(((ProcessItem) item)
|
||||
.getProperty());
|
||||
if (childJavaProject != null) {
|
||||
final IFolder childResourcesFolder = childJavaProject.getExternalResourcesFolder();
|
||||
if (childResourcesFolder.exists()) {
|
||||
FileCopyUtils.syncFolder(childResourcesFolder.getLocation().toFile(), targetFolder, false);
|
||||
}
|
||||
dependenciesItems.stream().filter(jobInfo -> !jobInfo.isJoblet()).map(JobInfo::getProcessItem).forEach(item -> {
|
||||
ITalendProcessJavaProject childJavaProject = runProcessService.getTalendJobJavaProject(item.getProperty());
|
||||
if (childJavaProject != null) {
|
||||
final IFolder childResourcesFolder = childJavaProject.getExternalResourcesFolder();
|
||||
if (childResourcesFolder.exists()) {
|
||||
FileCopyUtils.syncFolder(childResourcesFolder.getLocation().toFile(), targetFolder, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainResourcesFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.services.IGenericDBService;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
import org.talend.core.services.ICoreTisService;
|
||||
import org.talend.core.utils.WorkspaceUtils;
|
||||
import org.talend.designer.business.model.business.BusinessPackage;
|
||||
import org.talend.designer.business.model.business.BusinessProcess;
|
||||
@@ -372,6 +373,7 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
}
|
||||
|
||||
boolean isSameRepositoryType = true;
|
||||
boolean bothProcessType = false;
|
||||
org.talend.core.model.general.Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
Map<String, List<IRepositoryViewObject>> nameCache = repObjectcache.getNameItemChache();
|
||||
final Property property = importItem.getProperty();
|
||||
@@ -390,7 +392,13 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
if (dbService != null && dbService.getExtraTypes().contains(repType)) {
|
||||
repType = dbService.getExtraDBType(repType);
|
||||
}
|
||||
isSameRepositoryType = isSameRepType(repType, importItem.getRepositoryType());
|
||||
ERepositoryObjectType importType = importItem.getRepositoryType();
|
||||
bothProcessType = allTypesOfProcess.contains(repType) && allTypesOfProcess.contains(importType);
|
||||
isSameRepositoryType = isSameRepType(repType, importType);
|
||||
if (!isSameRepositoryType && !bothProcessType) {
|
||||
// no need to keep track of item with same name if the type is different
|
||||
itemWithSameNameObj = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -452,7 +460,9 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
importItem.addError(Messages.getString("AbstractImportHandler_nameUsed")); //$NON-NLS-1$
|
||||
}
|
||||
} else {
|
||||
importItem.addError(Messages.getString("AbstractImportHandler_nameUsed.differentRepositoryType")); //$NON-NLS-1$
|
||||
if(bothProcessType){
|
||||
importItem.addError(Messages.getString("AbstractImportHandler_nameUsed.differentRepositoryType")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1291,10 +1301,14 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
IRepositoryViewObject object;
|
||||
try {
|
||||
Property property = importItem.getProperty();
|
||||
if (property == null) {
|
||||
if (property == null || property.eResource() == null) {
|
||||
object = factory.getSpecificVersion(importItem.getItemId(), importItem.getItemVersion(), true);
|
||||
property = object.getProperty();
|
||||
}
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
|
||||
ICoreTisService service = (ICoreTisService)GlobalServiceRegister.getDefault().getService(ICoreTisService.class);
|
||||
service.afterImport(property);
|
||||
}
|
||||
RelationshipItemBuilder.getInstance().addOrUpdateItem(property.getItem(), true);
|
||||
// importItem.setProperty(null);
|
||||
// factory.unloadResources(property);
|
||||
@@ -1303,6 +1317,7 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected IPath getReferenceItemPath(IPath importItemPath, ReferenceFileItem rfItem) {
|
||||
return HandlerUtil.getReferenceItemPath(importItemPath, rfItem.getExtension());
|
||||
|
||||
@@ -3548,6 +3548,12 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadProjectAndSetContext(Project project, IProject eclipseProject, boolean updateCurrentProject)
|
||||
throws PersistenceException {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void initProjectRepository(Project project, String branchForMainProject) throws PersistenceException {
|
||||
}
|
||||
|
||||
|
||||
@@ -110,11 +110,10 @@ public class DatabaseTableFilterForm extends AbstractForm {
|
||||
public void initialize() {
|
||||
getTableInfoParameters().setSqlFiter(sqlFilter.getText());
|
||||
getTableInfoParameters().changeType(ETableTypes.TABLETYPE_TABLE, tableCheck.getSelection());
|
||||
getTableInfoParameters().changeType(ETableTypes.TABLETYPE_EXTERNAL_TABLE, tableCheck.getSelection());
|
||||
getTableInfoParameters().changeType(ETableTypes.EXTERNAL_TABLE, tableCheck.getSelection());
|
||||
getTableInfoParameters().changeType(ETableTypes.TABLETYPE_VIEW, viewCheck.getSelection());
|
||||
getTableInfoParameters().changeType(ETableTypes.TABLETYPE_SYNONYM, synonymCheck.getSelection());
|
||||
if (EDatabaseTypeName.HIVE.getDisplayName().equals(metadataconnection.getDbType())) {
|
||||
getTableInfoParameters().changeType(ETableTypes.EXTERNAL_TABLE, tableCheck.getSelection());
|
||||
getTableInfoParameters().changeType(ETableTypes.MANAGED_TABLE, tableCheck.getSelection());
|
||||
getTableInfoParameters().changeType(ETableTypes.INDEX_TABLE, tableCheck.getSelection());
|
||||
getTableInfoParameters().changeType(ETableTypes.VIRTUAL_VIEW, viewCheck.getSelection());
|
||||
@@ -423,9 +422,8 @@ public class DatabaseTableFilterForm extends AbstractForm {
|
||||
// child like "HiveTableInfoParameters" could implement "getTypes()" to return the private types. When
|
||||
// types are reqired, it could invoke like
|
||||
// "DatabaseTableWizardPage.getTableInfoParameters().getTypes()".
|
||||
getTableInfoParameters().changeType(ETableTypes.TABLETYPE_EXTERNAL_TABLE, tableCheck.getSelection());
|
||||
getTableInfoParameters().changeType(ETableTypes.EXTERNAL_TABLE, tableCheck.getSelection());
|
||||
if (EDatabaseTypeName.HIVE.getDisplayName().equals(metadataconnection.getDbType())) {
|
||||
getTableInfoParameters().changeType(ETableTypes.EXTERNAL_TABLE, tableCheck.getSelection());
|
||||
getTableInfoParameters().changeType(ETableTypes.MANAGED_TABLE, tableCheck.getSelection());
|
||||
getTableInfoParameters().changeType(ETableTypes.INDEX_TABLE, tableCheck.getSelection());
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ package org.talend.repository.example.viewer.handler.demo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
@@ -177,7 +178,7 @@ public class ExampleDemoDragAndDropHandler extends AbstractDragAndDropServiceHan
|
||||
* .connection.Connection, java.lang.String, org.talend.core.model.metadata.IMetadataTable, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Object getComponentValue(Connection connection, String value, IMetadataTable table, String targetComponent) {
|
||||
public Object getComponentValue(Connection connection, String value, IMetadataTable table, String targetComponent, Map<Object, Object> contextMap) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -17,4 +17,9 @@ 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...
|
||||
RepoViewCommonNavigator.refresh=Refreshing...
|
||||
RunInBackgroundProgressMonitorDialog.waitInBackground=Wait in background
|
||||
RepoDoubleClickAction.wait4run=[{0}]: Studio is busy with [{1}], please wait...
|
||||
RepoDoubleClickAction.unknown=unknown work
|
||||
progress.interrupted=Work is interrupted
|
||||
progress.cancelled=Work is cancelled
|
||||
@@ -12,13 +12,26 @@
|
||||
// ============================================================================
|
||||
package org.talend.repository.viewer.action;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.StructuredViewer;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.DeviceData;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.gmf.util.DisplayUtils;
|
||||
import org.talend.commons.ui.swt.actions.ITreeContextualAction;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
@@ -44,11 +57,13 @@ import org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject
|
||||
import org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.RepositoryWorkUnit;
|
||||
import org.talend.repository.i18n.Messages;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.IRepositoryNode.ENodeType;
|
||||
import org.talend.repository.model.IRepositoryNode.EProperties;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
import org.talend.repository.viewer.ui.RunInBackgroundProgressMonitorDialog;
|
||||
|
||||
/**
|
||||
* DOC smallet class global comment. Detailled comment <br/>
|
||||
@@ -115,13 +130,129 @@ public class RepoDoubleClickAction extends Action {
|
||||
// } else {
|
||||
ITreeContextualAction actionToRun = getAction(node);
|
||||
if (actionToRun != null) {
|
||||
actionToRun.init(null, (IStructuredSelection) selection);
|
||||
actionToRun.run();
|
||||
try {
|
||||
actionToRun = actionToRun.clone();
|
||||
} catch (CloneNotSupportedException e1) {
|
||||
ExceptionHandler.process(e1);
|
||||
return;
|
||||
}
|
||||
final ITreeContextualAction clonedAction = actionToRun;
|
||||
clonedAction.init(null, (IStructuredSelection) selection);
|
||||
executeAction(clonedAction);
|
||||
// showView();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private void executeAction(final ITreeContextualAction clonedAction) {
|
||||
final ProxyRepositoryFactory repoFactory = ProxyRepositoryFactory.getInstance();
|
||||
if (repoFactory.isRepositoryBusy()) {
|
||||
final DeviceData deviceData = Display.getDefault().getDeviceData();
|
||||
Shell workbenchShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
|
||||
final Point location = workbenchShell.getLocation();
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
DisplayUtils.syncExecInNewUIThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final RepositoryWorkUnit rwu = repoFactory.getWorkUnitInProgress();
|
||||
String name = null;
|
||||
if (rwu != null) {
|
||||
name = rwu.getName();
|
||||
} else {
|
||||
name = Messages.getString("RepoDoubleClickAction.unknown"); //$NON-NLS-1$
|
||||
}
|
||||
final String info = Messages.getString("RepoDoubleClickAction.wait4run", clonedAction.getText(), //$NON-NLS-1$
|
||||
name);
|
||||
Shell shell = new Shell(SWT.ON_TOP);
|
||||
// in case they are in different screen
|
||||
shell.setLocation(location);
|
||||
final Job waitForRunJob = new Job(info) {
|
||||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
while (repoFactory.isRepositoryBusy()) {
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException(
|
||||
Messages.getString("progress.interrupted") + " : " + info); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
if (monitor.isCanceled()) {
|
||||
throw new Exception(Messages.getString("progress.cancelled") + " : " + info); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
Thread.sleep(200);
|
||||
}
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
executeAction(clonedAction);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return org.eclipse.core.runtime.Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
RunInBackgroundProgressMonitorDialog dialog = new RunInBackgroundProgressMonitorDialog(shell);
|
||||
try {
|
||||
waitForRunJob.schedule();
|
||||
dialog.run(true, true, new IRunnableWithProgress() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor)
|
||||
throws InvocationTargetException, InterruptedException {
|
||||
monitor.beginTask(info, IProgressMonitor.UNKNOWN);
|
||||
try {
|
||||
while (true) {
|
||||
if (monitor.isCanceled()) {
|
||||
waitForRunJob.cancel();
|
||||
break;
|
||||
}
|
||||
if (dialog.getUserChoice() != null) {
|
||||
if (dialog
|
||||
.getUserChoice() == RunInBackgroundProgressMonitorDialog.USER_CHOICE_CANCEL) {
|
||||
waitForRunJob.cancel();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException(
|
||||
Messages.getString("progress.interrupted") + " : " + info); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
if (waitForRunJob.getResult() != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
} finally {
|
||||
shell.dispose();
|
||||
}
|
||||
}
|
||||
}, deviceData);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
|
||||
} else {
|
||||
clonedAction.run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* ggu Comment method "isLinkCDCNode".
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.eclipse.ui.navigator.CommonActionProvider;
|
||||
import org.eclipse.ui.navigator.ICommonActionConstants;
|
||||
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
|
||||
import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.swt.actions.ITreeContextualAction;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.service.ICoreUIService;
|
||||
@@ -104,10 +105,15 @@ public class RepoNodeActionProvider extends CommonActionProvider {
|
||||
Set<String> processedGroupIds) {
|
||||
ICommonViewerWorkbenchSite navWorkSite = ((ICommonViewerWorkbenchSite) getActionSite().getViewSite());
|
||||
for (ITreeContextualAction action : contextualsActions) {
|
||||
if (navWorkSite != null && navWorkSite.getSite() != null) {
|
||||
action.setWorkbenchPart(navWorkSite.getSite().getPart());
|
||||
try {
|
||||
action = action.clone();
|
||||
if (navWorkSite != null && navWorkSite.getSite() != null) {
|
||||
action.setWorkbenchPart(navWorkSite.getSite().getPart());
|
||||
}
|
||||
checkAndAddActionInMenu(action, sel, manager, menuManagerGroups, processedGroupIds);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
checkAndAddActionInMenu(action, sel, manager, menuManagerGroups, processedGroupIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2018 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.viewer.ui;
|
||||
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Cursor;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.talend.repository.i18n.Messages;
|
||||
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public class RunInBackgroundProgressMonitorDialog extends ProgressMonitorDialog {
|
||||
|
||||
public static final int USER_CHOICE_RUN_IN_BACKGROUND = 1;
|
||||
|
||||
public static final int USER_CHOICE_CANCEL = 2;
|
||||
|
||||
private Button waitInBackground = null;
|
||||
|
||||
private Integer userChoice;
|
||||
|
||||
public RunInBackgroundProgressMonitorDialog(Shell parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createButtonsForButtonBar(org.eclipse.swt.widgets.Composite parent) {
|
||||
waitInBackground = createButton(parent, IDialogConstants.OK_ID,
|
||||
Messages.getString("RunInBackgroundProgressMonitorDialog.waitInBackground"), true); //$NON-NLS-1$
|
||||
if (arrowCursor == null) {
|
||||
arrowCursor = new Cursor(waitInBackground.getDisplay(), SWT.CURSOR_ARROW);
|
||||
}
|
||||
waitInBackground.setCursor(arrowCursor);
|
||||
super.createButtonsForButtonBar(parent);
|
||||
waitInBackground.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
userChoice = USER_CHOICE_RUN_IN_BACKGROUND;
|
||||
setReturnCode(OK);
|
||||
finishedRun();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cancelPressed() {
|
||||
userChoice = USER_CHOICE_CANCEL;
|
||||
super.cancelPressed();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the user choice
|
||||
*
|
||||
* @return null: user hasn't choose yet;<br/>
|
||||
* USER_CHOICE_RUN_IN_BACKGROUND: user chooses to run in background;<br/>
|
||||
* USER_CHOICE_CANCEL: user cancels.
|
||||
*/
|
||||
public Integer getUserChoice() {
|
||||
return userChoice;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<!--
|
||||
Copyright (C) 2010 Talend Inc. - www.talend.com
|
||||
<!--
|
||||
Copyright (C) 2010 Talend Inc. - www.talend.com
|
||||
-->
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -22,6 +22,29 @@
|
||||
<module>org.talend.commons.runtime/pom_server.xml</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>tos-releases</id>
|
||||
|
||||
@@ -0,0 +1,380 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2014 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.core.ui.context.cmd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.gef.commands.CommandStack;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.ui.runtime.image.ImageUtils;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.model.components.ComponentCategory;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.components.IComponentsFactory;
|
||||
import org.talend.core.model.context.JobContext;
|
||||
import org.talend.core.model.context.JobContextManager;
|
||||
import org.talend.core.model.context.JobContextParameter;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.model.properties.ByteArray;
|
||||
import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.repository.RepositoryObject;
|
||||
import org.talend.core.model.routines.RoutinesUtil;
|
||||
import org.talend.core.repository.ui.view.RepositoryLabelProvider;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.ui.CoreUIPlugin;
|
||||
import org.talend.core.ui.component.ComponentsFactoryProvider;
|
||||
import org.talend.core.ui.context.ContextManagerHelper;
|
||||
import org.talend.core.ui.context.IContextModelManager;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ParametersType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
|
||||
import org.talend.designer.joblet.model.JobletFactory;
|
||||
import org.talend.designer.joblet.model.JobletProcess;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
|
||||
/**
|
||||
* created by wchen on Aug 1, 2018 Detailled comment
|
||||
*
|
||||
*/
|
||||
public class AddRepositoryContextGroupCommandTest {
|
||||
|
||||
IProxyRepositoryFactory factory = CoreUIPlugin.getDefault().getProxyRepositoryFactory();
|
||||
|
||||
IRepositoryViewObject jobletForTest;
|
||||
|
||||
IRepositoryViewObject contextObject;
|
||||
|
||||
@Before
|
||||
public void setup() throws PersistenceException {
|
||||
List<IRepositoryViewObject> all = factory.getAll(ERepositoryObjectType.CONTEXT);
|
||||
for (IRepositoryViewObject obj : all) {
|
||||
if ("AddRepositoryContextGroupCommandTest_joblet".equals(obj.getLabel())) {
|
||||
factory.deleteObjectPhysical(obj);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (jobletForTest != null) {
|
||||
factory.deleteObjectPhysical(jobletForTest);
|
||||
IComponentsFactory components = ComponentsFactoryProvider.getInstance();
|
||||
IComponent jobletComponent = components.get(jobletForTest.getLabel(), ComponentCategory.CATEGORY_4_DI.getName());
|
||||
components.getComponents().remove(jobletComponent);
|
||||
factory.deleteObjectPhysical(contextObject);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommand() throws PersistenceException {
|
||||
jobletForTest = createRepositoryObject("AddRepositoryContextGroupCommandTest_joblet", factory.getNextId(),
|
||||
VersionUtils.DEFAULT_VERSION);
|
||||
String jobletId = jobletForTest.getId();
|
||||
|
||||
ContextManager manager = new ContextManager();
|
||||
IContextManager contextManager = manager.getContextManager();
|
||||
// add a build-in context
|
||||
JobContextParameter buildInParam = new JobContextParameter();
|
||||
buildInParam.setName("buildIn");
|
||||
List<IContextParameter> contextParameterList = contextManager.getDefaultContext().getContextParameterList();
|
||||
contextParameterList.add(buildInParam);
|
||||
// add a joblet context
|
||||
JobContextParameter jobletParam = new JobContextParameter();
|
||||
jobletParam.setName("joblet");
|
||||
jobletParam.setSource(jobletId);
|
||||
contextParameterList.add(jobletParam);
|
||||
|
||||
ContextManagerHelper helper = new ContextManagerHelper(contextManager);
|
||||
|
||||
// add a repository context by command should not affact the existing joblet and build context param
|
||||
contextObject = createContextObject("AddRepositoryContextGroupCommandTest_context", factory.getNextId(),
|
||||
VersionUtils.DEFAULT_VERSION);
|
||||
ContextItem contextItem = (ContextItem) contextObject.getProperty().getItem();
|
||||
List<ContextItem> selectedItems = new ArrayList<ContextItem>();
|
||||
selectedItems.add(contextItem);
|
||||
Set<String> nameSet = new HashSet<String>();
|
||||
List<ContextParameterType> parameterList = new ArrayList<ContextParameterType>();
|
||||
parameterList.addAll(((ContextType) contextItem.getContext().get(0)).getContextParameter());
|
||||
AddRepositoryContextGroupCommand command = new AddRepositoryContextGroupCommand(null, manager, selectedItems, nameSet,
|
||||
helper, parameterList);
|
||||
command.execute();
|
||||
|
||||
contextParameterList = contextManager.getDefaultContext().getContextParameterList();
|
||||
Assert.assertEquals(contextParameterList.size(), 3);
|
||||
Assert.assertEquals(contextParameterList.get(0).getName(), "buildIn");
|
||||
Assert.assertEquals(contextParameterList.get(1).getName(), "joblet");
|
||||
Assert.assertEquals(contextParameterList.get(2).getName(), "repository_new1");
|
||||
|
||||
}
|
||||
|
||||
private IRepositoryViewObject createContextObject(String label, String id, String version) throws PersistenceException {
|
||||
ContextItem contextItem = PropertiesFactory.eINSTANCE.createContextItem();
|
||||
Property contextProperty = PropertiesFactory.eINSTANCE.createProperty();
|
||||
contextProperty.setAuthor(
|
||||
((RepositoryContext) CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY))
|
||||
.getUser());
|
||||
contextProperty.setVersion(VersionUtils.DEFAULT_VERSION);
|
||||
contextProperty.setStatusCode(""); //$NON-NLS-1$
|
||||
contextProperty.setId(id);
|
||||
contextProperty.setLabel(label);
|
||||
contextProperty.setDisplayName(contextProperty.getLabel());
|
||||
contextItem.setProperty(contextProperty);
|
||||
contextItem.setDefaultContext("Default");
|
||||
|
||||
ContextType contextType = TalendFileFactory.eINSTANCE.createContextType();
|
||||
contextItem.getContext().add(contextType);
|
||||
contextType.setName("Default");
|
||||
EList contextTypeParamList = contextType.getContextParameter();
|
||||
ContextParameterType contextParamType = TalendFileFactory.eINSTANCE.createContextParameterType();
|
||||
contextParamType.setName("repository_new1");
|
||||
contextParamType.setType("id_String");
|
||||
contextTypeParamList.add(contextParamType);
|
||||
factory.create(contextItem, new Path(""));
|
||||
return new RepositoryObject(contextProperty);
|
||||
|
||||
}
|
||||
|
||||
private IRepositoryViewObject createRepositoryObject(String label, String id, String version) throws PersistenceException {
|
||||
Property property = PropertiesFactory.eINSTANCE.createProperty();
|
||||
property.setAuthor(
|
||||
((RepositoryContext) CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY))
|
||||
.getUser());
|
||||
property.setVersion(version);
|
||||
property.setStatusCode(""); //$NON-NLS-1$
|
||||
|
||||
JobletProcessItem processItem = PropertiesFactory.eINSTANCE.createJobletProcessItem();
|
||||
ByteArray ba = PropertiesFactory.eINSTANCE.createByteArray();
|
||||
processItem.setIcon(ba);
|
||||
processItem.getIcon()
|
||||
.setInnerContent(ImageUtils.saveImageToData(RepositoryLabelProvider.getDefaultJobletImage(processItem)));
|
||||
|
||||
processItem.setProperty(property);
|
||||
property.setId(id);
|
||||
property.setLabel(label);
|
||||
property.setDisplayName(property.getLabel());
|
||||
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
|
||||
// add depended routines.
|
||||
List<RoutinesParameterType> dependenciesInPreference;
|
||||
dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
|
||||
|
||||
parameterType.getRoutinesParameter().addAll(dependenciesInPreference);
|
||||
JobletProcess process = JobletFactory.eINSTANCE.createJobletProcess();
|
||||
process.setParameters(parameterType);
|
||||
processItem.setJobletProcess(process);
|
||||
factory.create(processItem, new Path(""));
|
||||
return new RepositoryObject(property);
|
||||
}
|
||||
|
||||
class ContextManager implements IContextModelManager {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#getContextManager()
|
||||
*/
|
||||
@Override
|
||||
public IContextManager getContextManager() {
|
||||
JobContextManager jobContextManager = new JobContextManager();
|
||||
JobContext context = new JobContext("Default");
|
||||
jobContextManager.getListContext().add(context);
|
||||
return jobContextManager;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#getProcess()
|
||||
*/
|
||||
@Override
|
||||
public IProcess2 getProcess() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#refresh()
|
||||
*/
|
||||
@Override
|
||||
public void refresh() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#getCommandStack()
|
||||
*/
|
||||
@Override
|
||||
public CommandStack getCommandStack() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#onContextChangeDefault(org.talend.core.model.process.
|
||||
* IContextManager, org.talend.core.model.process.IContext)
|
||||
*/
|
||||
@Override
|
||||
public void onContextChangeDefault(IContextManager contextManager, IContext newDefault) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#onContextRenameParameter(org.talend.core.model.process.
|
||||
* IContextManager, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void onContextRenameParameter(IContextManager contextManager, String oldName, String newName) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#onContextRenameParameter(org.talend.core.model.process.
|
||||
* IContextManager, java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void onContextRenameParameter(IContextManager contextManager, String sourceId, String oldName, String newName) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#onContextModify(org.talend.core.model.process.
|
||||
* IContextManager, org.talend.core.model.process.IContextParameter)
|
||||
*/
|
||||
@Override
|
||||
public void onContextModify(IContextManager contextManager, IContextParameter parameter) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#onContextAddParameter(org.talend.core.model.process.
|
||||
* IContextManager, org.talend.core.model.process.IContextParameter)
|
||||
*/
|
||||
@Override
|
||||
public void onContextAddParameter(IContextManager contextManager, IContextParameter parameter) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#onContextRemoveParameter(org.talend.core.model.process.
|
||||
* IContextManager, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void onContextRemoveParameter(IContextManager contextManager, String paramName) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#onContextRemoveParameter(org.talend.core.model.process.
|
||||
* IContextManager, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void onContextRemoveParameter(IContextManager contextManager, String paramName, String sourceId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#onContextRemoveParameter(org.talend.core.model.process.
|
||||
* IContextManager, java.util.Set, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void onContextRemoveParameter(IContextManager contextManager, Set<String> paramNames, String sourceId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#onContextRemoveParameter(org.talend.core.model.process.
|
||||
* IContextManager, java.util.Set)
|
||||
*/
|
||||
@Override
|
||||
public void onContextRemoveParameter(IContextManager contextManager, Set<String> paramNames) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#isReadOnly()
|
||||
*/
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.context.IContextModelManager#isRepositoryContext()
|
||||
*/
|
||||
@Override
|
||||
public boolean isRepositoryContext() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2018 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 static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class MavenVersionHelperTest {
|
||||
|
||||
@Test
|
||||
public void testCompareTo() {
|
||||
assertTrue(MavenVersionHelper.compareTo("1.0.0", "1.0.1") < 0);
|
||||
assertTrue(MavenVersionHelper.compareTo("1.0.0", "1.1.0") < 0);
|
||||
assertTrue(MavenVersionHelper.compareTo("1.0.0", "1.1.1") < 0);
|
||||
|
||||
assertTrue(MavenVersionHelper.compareTo("1.0.0", "0.1.0") > 0);
|
||||
assertTrue(MavenVersionHelper.compareTo("1.0.0", "0.0.1") > 0);
|
||||
assertTrue(MavenVersionHelper.compareTo("1.0.0", "0.1.1") > 0);
|
||||
|
||||
assertTrue(MavenVersionHelper.compareTo("1.0.0-SNAPSHOT", "1.0.1") < 0);
|
||||
assertTrue(MavenVersionHelper.compareTo("1.0.0-SNAPSHOT", "1.0.1-SNAPSHOT") < 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,6 +35,7 @@ public class ModulesNeededProviderTest {
|
||||
public void testUpdateModulesNeededForRoutine() throws Exception {
|
||||
String jarName1 = "testUpdateModulesNeededForRoutine1.jar";
|
||||
String jarName2 = "testUpdateModulesNeededForRoutine2.jar";
|
||||
String jarName3 = "testUpdateModulesNeededForRoutine3.jar";
|
||||
|
||||
String message = ModuleNeeded.UNKNOWN;
|
||||
|
||||
@@ -43,20 +44,26 @@ public class ModulesNeededProviderTest {
|
||||
routineItem.getProperty().setLabel("routineTest");
|
||||
IMPORTType importJar1 = ComponentFactory.eINSTANCE.createIMPORTType();
|
||||
importJar1.setMODULE(jarName1);
|
||||
importJar1.setREQUIRED(true);
|
||||
importJar1.setNAME(routineItem.getProperty().getLabel());
|
||||
routineItem.getImports().add(importJar1);
|
||||
IMPORTType importJar2 = ComponentFactory.eINSTANCE.createIMPORTType();
|
||||
importJar2.setMODULE(jarName2);
|
||||
importJar2.setREQUIRED(true);
|
||||
importJar2.setNAME(routineItem.getProperty().getLabel());
|
||||
routineItem.getImports().add(importJar2);
|
||||
|
||||
IMPORTType importJar3 = ComponentFactory.eINSTANCE.createIMPORTType();
|
||||
importJar3.setMODULE(jarName3);
|
||||
importJar3.setREQUIRED(false);
|
||||
importJar3.setNAME(routineItem.getProperty().getLabel());
|
||||
routineItem.getImports().add(importJar3);
|
||||
// remove old modules from the two lists before test
|
||||
String label = ERepositoryObjectType.getItemType(routineItem).getLabel();
|
||||
String currentContext = label + " " + routineItem.getProperty().getLabel();
|
||||
Set<ModuleNeeded> oldModules = new HashSet<ModuleNeeded>();
|
||||
for (ModuleNeeded existingModule : ModulesNeededProvider.getModulesNeeded()) {
|
||||
if (currentContext.equals(existingModule.getContext()) || jarName1.equals(existingModule.getModuleName())
|
||||
|| jarName2.equals(existingModule.getModuleName())) {
|
||||
|| jarName2.equals(existingModule.getModuleName()) || jarName3.equals(existingModule.getModuleName())) {
|
||||
oldModules.add(existingModule);
|
||||
}
|
||||
}
|
||||
@@ -64,7 +71,7 @@ public class ModulesNeededProviderTest {
|
||||
oldModules = new HashSet<ModuleNeeded>();
|
||||
for (ModuleNeeded existingModule : ModulesNeededProvider.getAllManagedModules()) {
|
||||
if (currentContext.equals(existingModule.getContext()) || jarName1.equals(existingModule.getModuleName())
|
||||
|| jarName2.equals(existingModule.getModuleName())) {
|
||||
|| jarName2.equals(existingModule.getModuleName()) || jarName3.equals(existingModule.getModuleName())) {
|
||||
oldModules.add(existingModule);
|
||||
}
|
||||
}
|
||||
@@ -75,7 +82,7 @@ public class ModulesNeededProviderTest {
|
||||
int originalAllSize = ModulesNeededProvider.getAllManagedModules().size();
|
||||
|
||||
ModulesNeededProvider.updateModulesNeededForRoutine(routineItem);
|
||||
// add two modules to needed list
|
||||
// add 3 modules to needed list, but one of them is require false
|
||||
Assert.assertEquals(ModulesNeededProvider.getModulesNeeded().size(), originalNeededSize + 2);
|
||||
// add one + change one in the all list
|
||||
Assert.assertEquals(ModulesNeededProvider.getAllManagedModules().size(), originalAllSize + 1);
|
||||
|
||||
Reference in New Issue
Block a user