Compare commits
37 Commits
release/7.
...
feat/maste
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cebfe678b1 | ||
|
|
5bdc4ceef7 | ||
|
|
d2eaeb7b97 | ||
|
|
a53ffdfbf4 | ||
|
|
dc92855b54 | ||
|
|
e8d1ce17d0 | ||
|
|
ba19f14fc9 | ||
|
|
1a73160d6b | ||
|
|
6efbc76223 | ||
|
|
2aae24829a | ||
|
|
ea091c2cda | ||
|
|
ef5869370d | ||
|
|
dfc277d886 | ||
|
|
7a75fdc057 | ||
|
|
f4ecdf00c6 | ||
|
|
3ab6dc8441 | ||
|
|
f6903ae6d6 | ||
|
|
c05f0c4518 | ||
|
|
00837db7bf | ||
|
|
667fbf90ad | ||
|
|
17a34e40ac | ||
|
|
80484dc111 | ||
|
|
3cd8ee2958 | ||
|
|
5d75d89161 | ||
|
|
a518891e99 | ||
|
|
a26002f9a2 | ||
|
|
bea0b2a13b | ||
|
|
020d7af9fe | ||
|
|
12649f7a3d | ||
|
|
e9b5ce029d | ||
|
|
94f5432d89 | ||
|
|
bd26e3e912 | ||
|
|
73a2bdc6ec | ||
|
|
14b6b30d43 | ||
|
|
6e4b940576 | ||
|
|
c8ba22bde9 | ||
|
|
02d9f42f8c |
@@ -20,8 +20,10 @@
|
||||
<import plugin="org.apache.servicemix.bundles.avro" version="0.0.0" match="greaterOrEqual"/>
|
||||
<import plugin="org.junit" version="0.0.0" match="greaterOrEqual"/>
|
||||
<import plugin="org.slf4j.api" version="0.0.0" match="greaterOrEqual"/>
|
||||
<import plugin="org.apache.commons.configuration" version="2.0.0" match="greaterOrEqual"/>
|
||||
</requires>
|
||||
<plugin id="org.talend.daikon" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
|
||||
<plugin id="org.talend.daikon.exception" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
|
||||
<plugin id="org.talend.daikon.crypto.utils" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
|
||||
<plugin id="org.talend.utils" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
|
||||
</feature>
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.talend.commons.ui.runtime.i18n.Messages;
|
||||
import org.talend.commons.ui.runtime.utils.TableUtils;
|
||||
import org.talend.commons.ui.runtime.ws.WindowSystem;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.AbstractDataTableEditorView;
|
||||
import org.talend.commons.ui.swt.drawing.background.IBackgroundRefresher;
|
||||
import org.talend.commons.ui.swt.drawing.background.IBgDrawableComposite;
|
||||
import org.talend.commons.ui.swt.drawing.link.BezierHorizontalLink;
|
||||
@@ -464,4 +465,19 @@ public class TreeToTablesLinker<D1, D2> extends BgDrawableComposite implements I
|
||||
}
|
||||
}
|
||||
|
||||
protected <B> void loadItemDataForLazyLoad(AbstractDataTableEditorView<B> tableEditorView) {
|
||||
if (!tableEditorView.getTableViewerCreator().isLazyLoad()) {
|
||||
return;
|
||||
}
|
||||
List<B> beansList = tableEditorView.getExtendedTableModel().getBeansList();
|
||||
Table table = tableEditorView.getTable();
|
||||
for (TableItem tableItem : table.getItems()) {
|
||||
if (tableItem.getData() == null) {
|
||||
int index = table.indexOf(tableItem);
|
||||
B schemaTarget = beansList.get(index);
|
||||
tableItem.setData(schemaTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,26 +44,27 @@ public class SyncLibrariesLoginTask extends AbstractLoginTask implements IRunnab
|
||||
ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(
|
||||
new RepositoryWorkUnit<Void>(Messages.getString("SyncLibrariesLoginTask.createStatsLogAndImplicitParamter")) {
|
||||
|
||||
@Override
|
||||
protected void run() throws LoginException, PersistenceException {
|
||||
try {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IResourceRuleFactory ruleFactory = workspace.getRuleFactory();
|
||||
ProjectManager projectManager = ProjectManager.getInstance();
|
||||
ISchedulingRule refreshRule = ruleFactory
|
||||
.refreshRule(projectManager.getResourceProject(getProject().getEmfProject()));
|
||||
workspace.run(new IWorkspaceRunnable() {
|
||||
@Override
|
||||
protected void run() throws LoginException, PersistenceException {
|
||||
try {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IResourceRuleFactory ruleFactory = workspace.getRuleFactory();
|
||||
ProjectManager projectManager = ProjectManager.getInstance();
|
||||
ISchedulingRule refreshRule = ruleFactory.refreshRule(
|
||||
projectManager.getResourceProject(projectManager.getCurrentProject().getEmfProject()));
|
||||
workspace.run(new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
coreService.createStatsLogAndImplicitParamter(ProjectManager.getInstance().getCurrentProject());
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
coreService
|
||||
.createStatsLogAndImplicitParamter(ProjectManager.getInstance().getCurrentProject());
|
||||
}
|
||||
}, refreshRule, IWorkspace.AVOID_UPDATE, monitor);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}, refreshRule, IWorkspace.AVOID_UPDATE, monitor);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -164,9 +164,9 @@ public enum EDatabaseVersion4Drivers {
|
||||
MAPRDB(new DbVersion4Drivers(EDatabaseTypeName.MAPRDB, new String[] {})),
|
||||
|
||||
REDSHIFT(new DbVersion4Drivers(EDatabaseTypeName.REDSHIFT, "redshift", "REDSHIFT", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"redshift-jdbc42-no-awssdk-1.2.20.1043.jar")), //$NON-NLS-1$
|
||||
"redshift-jdbc42-no-awssdk-1.2.32.1056.jar")), //$NON-NLS-1$
|
||||
REDSHIFT_SSO(new DbVersion4Drivers(EDatabaseTypeName.REDSHIFT_SSO, "redshift sso", "REDSHIFT_SSO", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
new String[] { "redshift-jdbc42-no-awssdk-1.2.20.1043.jar", "aws-java-sdk-1.11.406.jar", "jackson-core-2.9.5.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
new String[] { "redshift-jdbc42-no-awssdk-1.2.32.1056.jar", "aws-java-sdk-1.11.406.jar", "jackson-core-2.9.5.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
"jackson-databind-2.9.5.jar", "jackson-annotations-2.9.0.jar", "httpcore-4.4.9.jar", "httpclient-4.5.5.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
|
||||
"joda-time-2.8.1.jar", "commons-logging-1.1.3.jar" })), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
|
||||
@@ -98,6 +98,15 @@ public class JobContext implements IContext, Cloneable {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean containsSameParameterIgnoreCase(String parameterName) {
|
||||
for (IContextParameter contextParam : contextParameterList) {
|
||||
if (contextParam.getName() != null && contextParam.getName().equalsIgnoreCase(parameterName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commented by Marvin Wang on Mar.2, 2012, the user who invokes the method should notice that if the
|
||||
* <code>JobContext</code> has more than one <code>ContextParameter</code>s which names are same, this case will
|
||||
|
||||
@@ -62,4 +62,6 @@ public interface IContext {
|
||||
public IContext clone();
|
||||
|
||||
public boolean sameAs(IContext context);
|
||||
|
||||
public boolean containsSameParameterIgnoreCase(String parameterName);
|
||||
}
|
||||
|
||||
@@ -917,9 +917,12 @@ public final class ProcessUtils {
|
||||
for (ProjectReference ref : references) {
|
||||
all.addAll(factory.getAll(new Project(ref.getReferencedProject()), beansType));
|
||||
}
|
||||
if (!all.isEmpty()) { // has bean
|
||||
return true;
|
||||
}
|
||||
// if (!all.isEmpty()) { // has bean
|
||||
// return true;
|
||||
// }
|
||||
|
||||
return true;
|
||||
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 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.nexus;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ResolverExceptionHandler {
|
||||
|
||||
public static IOException hideCredential(IOException e) {
|
||||
// hide the user/password in the error
|
||||
String regex = "\\://(.+)\\:(.+)@"; //$NON-NLS-1$
|
||||
String message = e.getMessage();
|
||||
message = message.replaceAll(regex, "://"); //$NON-NLS-1$
|
||||
Exception cause = null;
|
||||
if (e.getCause() != null) {
|
||||
String causeMessage = e.getCause().getMessage();
|
||||
causeMessage = causeMessage.replaceAll(regex, "://"); //$NON-NLS-1$
|
||||
cause = new Exception(causeMessage);
|
||||
}
|
||||
return new IOException(message, cause);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -101,8 +101,12 @@ public class TalendMavenResolver {
|
||||
|
||||
}
|
||||
|
||||
public static File resolve(String mvnUri) throws IOException, RuntimeException {
|
||||
return getMavenResolver().resolve(mvnUri);
|
||||
public static File resolve(String mvnUri) throws IOException {
|
||||
try {
|
||||
return getMavenResolver().resolve(mvnUri);
|
||||
} catch (IOException e) {
|
||||
throw ResolverExceptionHandler.hideCredential(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void upload(String groupId, String artifactId, String classifier, String extension, String version,
|
||||
@@ -110,7 +114,11 @@ public class TalendMavenResolver {
|
||||
getMavenResolver().upload(groupId, artifactId, classifier, extension, version, artifact);
|
||||
}
|
||||
|
||||
public static MavenResolver getMavenResolver() throws RuntimeException {
|
||||
public static void initMavenResovler() throws RuntimeException {
|
||||
getMavenResolver();
|
||||
}
|
||||
|
||||
private static MavenResolver getMavenResolver() throws RuntimeException {
|
||||
if (mavenResolver == null) {
|
||||
final BundleContext context = CoreRuntimePlugin.getInstance().getBundle().getBundleContext();
|
||||
ServiceReference<org.ops4j.pax.url.mvn.MavenResolver> mavenResolverService = context
|
||||
|
||||
@@ -42,6 +42,8 @@ public interface MavenConstants {
|
||||
|
||||
static final String POM_FILTER = "POM_FILTER";
|
||||
|
||||
static final String USE_PROFILE_MODULE = "USE_PROFILE_MODULE";
|
||||
|
||||
/*
|
||||
* for lib
|
||||
*/
|
||||
|
||||
@@ -12,10 +12,13 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.service;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.talend.core.IService;
|
||||
|
||||
public interface IUpdateService extends IService {
|
||||
|
||||
boolean checkComponentNexusUpdate();
|
||||
|
||||
boolean checkStudioUpdate(IProgressMonitor monitor);
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
@@ -97,17 +98,24 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
|
||||
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)) {
|
||||
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);
|
||||
List<IRepositoryViewObject> list = getRepositoryService().getProxyRepositoryFactory().getAll(project, routineType);
|
||||
|
||||
if (list.size() == 0) {
|
||||
getRunProcessService().getTalendCodeJavaProject(routineType, project.getTechnicalLabel());
|
||||
} else {
|
||||
for (IRepositoryViewObject obj : list) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (syncRef) {
|
||||
// sync system routine
|
||||
syncSystemRoutine(project);
|
||||
|
||||
@@ -195,4 +195,7 @@ public interface IDesignerCoreService extends IService {
|
||||
public void setTACReadTimeout(int timeout);
|
||||
|
||||
boolean isDelegateNode(INode node);
|
||||
|
||||
boolean isNeedContextInJar(IProcess process);
|
||||
|
||||
}
|
||||
|
||||
@@ -254,6 +254,9 @@ public interface IProcessor {
|
||||
|
||||
public String[] getCommandLine(boolean needContext, boolean externalUse, int statOption, int traceOption,
|
||||
String... codeOptions);
|
||||
|
||||
public String[] getCommandLine(boolean needContext, boolean externalUse, int statOption, int traceOption, boolean ignoreCustomJVMSetting,
|
||||
String... codeOptions);
|
||||
|
||||
public void setContext(IContext context);
|
||||
|
||||
|
||||
@@ -98,6 +98,8 @@ public class RepositoryConstants {
|
||||
|
||||
public static final String REPOSITORY_CLOUD_APAC_ID = "cloud_apac"; //$NON-NLS-1$
|
||||
|
||||
public static final String REPOSITORY_CLOUD_US_WEST_ID = "cloud_us_west"; //$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$
|
||||
|
||||
@@ -472,7 +472,7 @@ public class ContextNebulaGridComposite extends AbstractContextTabEditComposite
|
||||
paramNameFound = true;
|
||||
paramName = NEW_PARAM_NAME + numParam;
|
||||
for (int i = 0; i < listParams.size(); i++) {
|
||||
if (paramName.equals(listParams.get(i).getName())) {
|
||||
if (paramName.equalsIgnoreCase(listParams.get(i).getName())) {
|
||||
paramNameFound = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -715,6 +715,13 @@ public class SelectRepositoryContextDialog extends SelectionDialog {
|
||||
if (param != null && param.isBuiltIn()) {
|
||||
return false;
|
||||
}
|
||||
if (param == null) {
|
||||
boolean containsSameParameterIgnoreCase = manager.getDefaultContext()
|
||||
.containsSameParameterIgnoreCase(paramType.getName());
|
||||
if (containsSameParameterIgnoreCase) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -756,7 +756,7 @@ public class ProcessorUtilities {
|
||||
|
||||
public static boolean hasMetadataDynamic(IProcess currentProcess, JobInfo jobInfo) {
|
||||
boolean hasDynamicMetadata = false;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class) && !isExportConfig()) {
|
||||
IDesignerCoreService designerCoreService =
|
||||
(IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
|
||||
for (INode node : currentProcess.getGraphicalNodes()) {
|
||||
@@ -1231,14 +1231,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);
|
||||
@@ -2028,7 +2037,15 @@ public class ProcessorUtilities {
|
||||
public static String[] getCommandLine(String targetPlatform, boolean skipClasspathJar, boolean externalUse,
|
||||
String processId, String contextName, int statisticPort, int tracePort, String... codeOptions)
|
||||
throws ProcessorException {
|
||||
return getCommandLine(targetPlatform, skipClasspathJar, externalUse,
|
||||
processId, contextName, statisticPort, tracePort, false, codeOptions);
|
||||
}
|
||||
|
||||
//ignoreCustomJVMSetting mean will generate the java command without the job VM setting in studio "Run job" setting and studio preferences "Run/Debug" setting
|
||||
//only use for TDI-42443 in tRunJob
|
||||
public static String[] getCommandLine(String targetPlatform, boolean skipClasspathJar, boolean externalUse,
|
||||
String processId, String contextName, int statisticPort, int tracePort, boolean ignoreCustomJVMSetting, String... codeOptions)
|
||||
throws ProcessorException {
|
||||
IProcessor processor = findProcessorFromJobList(processId, contextName, null);
|
||||
if (processor != null && targetPlatform.equals(processor.getTargetPlatform())) {
|
||||
if (processor.isProcessUnloaded()) {
|
||||
@@ -2037,7 +2054,7 @@ public class ProcessorUtilities {
|
||||
boolean oldSkipClasspathJar = processor.isSkipClasspathJar();
|
||||
processor.setSkipClasspathJar(skipClasspathJar);
|
||||
try {
|
||||
return processor.getCommandLine(true, externalUse, statisticPort, tracePort, codeOptions);
|
||||
return processor.getCommandLine(true, externalUse, statisticPort, tracePort, ignoreCustomJVMSetting, codeOptions);
|
||||
} finally {
|
||||
processor.setSkipClasspathJar(oldSkipClasspathJar);
|
||||
}
|
||||
@@ -2055,7 +2072,7 @@ public class ProcessorUtilities {
|
||||
}
|
||||
// because all jobs are based one new way, set the flag "oldBuildJob" to false.
|
||||
return getCommandLine(false, skipClasspathJar, targetPlatform, externalUse, process,
|
||||
selectedProcessItem.getProperty(), contextName, true, statisticPort, tracePort, codeOptions);
|
||||
selectedProcessItem.getProperty(), contextName, true, statisticPort, tracePort, ignoreCustomJVMSetting, codeOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2129,6 +2146,14 @@ public class ProcessorUtilities {
|
||||
public static String[] getCommandLine(boolean oldBuildJob, boolean skipClasspathJar, String targetPlatform,
|
||||
boolean externalUse, IProcess currentProcess, Property property, String contextName, boolean needContext,
|
||||
int statisticPort, int tracePort, String... codeOptions) throws ProcessorException {
|
||||
return getCommandLine(oldBuildJob, skipClasspathJar, targetPlatform,
|
||||
externalUse, currentProcess, property, contextName, needContext,
|
||||
statisticPort, tracePort, false, codeOptions);
|
||||
}
|
||||
|
||||
private static String[] getCommandLine(boolean oldBuildJob, boolean skipClasspathJar, String targetPlatform,
|
||||
boolean externalUse, IProcess currentProcess, Property property, String contextName, boolean needContext,
|
||||
int statisticPort, int tracePort, boolean ignoreCustomJVMSetting, String... codeOptions) throws ProcessorException {
|
||||
if (currentProcess == null) {
|
||||
return new String[] {};
|
||||
}
|
||||
@@ -2141,7 +2166,7 @@ public class ProcessorUtilities {
|
||||
processor.setSkipClasspathJar(skipClasspathJar);
|
||||
processor.setTargetPlatform(targetPlatform);
|
||||
processor.setOldBuildJob(oldBuildJob);
|
||||
return processor.getCommandLine(needContext, externalUse, statisticPort, tracePort, codeOptions);
|
||||
return processor.getCommandLine(needContext, externalUse, statisticPort, tracePort, ignoreCustomJVMSetting, codeOptions);
|
||||
}
|
||||
|
||||
public static String[] getCommandLine(boolean oldBuildJob, String targetPlatform, boolean externalUse,
|
||||
|
||||
@@ -46,12 +46,6 @@
|
||||
<version>${project.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.talend.studio</groupId>
|
||||
<artifactId>features-maven-plugin-2-2-9-tos</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.talend.studio</groupId>
|
||||
<artifactId>maven-bundle-plugin-2-3-7-tos</artifactId>
|
||||
@@ -76,18 +70,30 @@
|
||||
<version>${project.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.talend.studio</groupId>
|
||||
<artifactId>studio-maven-repository-zip</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.talend.studio</groupId>
|
||||
<artifactId>build-helper-maven-plugin-3-0-0-tos</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.talend.studio</groupId>
|
||||
<artifactId>karaf-maven-plugin-4-2-4-tos</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.talend.studio</groupId>
|
||||
<artifactId>studio-maven-repository-zip</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.talend.studio</groupId>
|
||||
<artifactId>karaf-maven-plugin-4-2-4-tos</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
|
||||
@@ -7,41 +7,30 @@
|
||||
<version>7.3.1-SNAPSHOT</version>
|
||||
<relativePath>../../../</relativePath>
|
||||
</parent>
|
||||
<artifactId>features-maven-plugin-2-2-9-tos</artifactId>
|
||||
<artifactId>karaf-maven-plugin-4-2-4-tos</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.karaf.tooling</groupId>
|
||||
<artifactId>features-maven-plugin</artifactId>
|
||||
<version>2.2.9</version>
|
||||
<artifactId>karaf-maven-plugin</artifactId>
|
||||
<version>4.2.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.bundlerepository</artifactId>
|
||||
<version>1.6.4</version>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>1.7.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.osgi</groupId>
|
||||
<artifactId>org.osgi.core</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<groupId>org.apache.maven.shared</groupId>
|
||||
<artifactId>maven-dependency-tree</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<version>3.1</version>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-framework-bom</artifactId>
|
||||
<version>5.0.2.RELEASE</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
|
||||
<!-- Required by commons-lang-2.6.pom -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-parent</artifactId>
|
||||
<version>17</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
@@ -10,9 +10,9 @@
|
||||
<artifactId>studio-maven-repository-build</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>plugins/features-maven-plugin-2-2-9</module>
|
||||
<module>plugins/maven-bundle-plugin-2-3-7</module>
|
||||
<module>plugins/maven-bundle-plugin-2-5-3</module>
|
||||
<module>plugins/karaf-maven-plugin-4-2-4</module>
|
||||
<module>plugins/maven-install-plugin-2-5-1</module>
|
||||
<module>plugins/talend-compiler-plugin</module>
|
||||
<module>plugins/build-helper-maven-plugin-3-0-0</module>
|
||||
|
||||
@@ -11,4 +11,5 @@ ProjectPomProjectSettingPage_FilterPomLabel=Filter to use to generate poms:
|
||||
ProjectPomProjectSettingPage_FilterErrorMessage=Invalid filter: {0}
|
||||
ProjectPomProjectSettingPage.syncAllPomsButtonText=Force full re-synchronize poms
|
||||
AbstractPersistentProjectSettingPage.syncAllPoms=Do you want to update all poms? \n This operation might take long time depends on your project size.
|
||||
MavenProjectSettingPage.filterExampleMessage=Filter examples:\nlabel=myJob \t\t\t\t=> Generate only the job named "myJob"\n!(label=myJob) \t\t\t\t=> Generate any job except the one named "myJob"\n(path=folder1/folder2) \t\t\t=> Generate any job in the folder "folder1/folder2"\n(path=folder1/folder2)or(label=myJob)\t=> Generate any job in the folder "folder1/folder2" or named "myJob"\n(label=myJob)and(version=0.2) \t=> Generate only the job named "myJob" with version 0.2\n!((label=myJob)and(version=0.1)) \t=> Generate every jobs except the "myJob" version 0.1
|
||||
MavenProjectSettingPage.filterExampleMessage=Filter examples:\nlabel=myJob \t\t\t\t=> Generate only the job named "myJob"\n!(label=myJob) \t\t\t\t=> Generate any job except the one named "myJob"\n(path=folder1/folder2) \t\t\t=> Generate any job in the folder "folder1/folder2"\n(path=folder1/folder2)or(label=myJob)\t=> Generate any job in the folder "folder1/folder2" or named "myJob"\n(label=myJob)and(version=0.2) \t=> Generate only the job named "myJob" with version 0.2\n!((label=myJob)and(version=0.1)) \t=> Generate every jobs except the "myJob" version 0.1
|
||||
MavenProjectSettingPage.refModuleText=Set reference project modules in profile
|
||||
@@ -198,6 +198,7 @@ public class M2eUserSettingForTalendLoginTask extends AbstractLoginTask {
|
||||
// add one marker to check to sync or not.
|
||||
File repoFolder = new File(maven.getLocalRepositoryPath());
|
||||
File markerFile = new File(repoFolder, ".syncMarker"); //$NON-NLS-1$
|
||||
System.setProperty("m2.syncmarker.path", markerFile.getAbsolutePath()); //$NON-NLS-1$
|
||||
Properties prop = new Properties();
|
||||
FileInputStream inStream = null;
|
||||
FileOutputStream outputStream = null;
|
||||
|
||||
@@ -50,6 +50,8 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
|
||||
private IPreferenceStore preferenceStore;
|
||||
|
||||
private Button useProfileModuleCheckbox;
|
||||
|
||||
public MavenProjectSettingPage() {
|
||||
noDefaultAndApplyButton();
|
||||
}
|
||||
@@ -84,6 +86,10 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
filterExampleLable.setText(Messages.getString("MavenProjectSettingPage.filterExampleMessage")); //$NON-NLS-1$
|
||||
filterExampleLable.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
||||
|
||||
useProfileModuleCheckbox = new Button(parent, SWT.CHECK);
|
||||
useProfileModuleCheckbox.setText(Messages.getString("MavenProjectSettingPage.refModuleText")); //$NON-NLS-1$
|
||||
useProfileModuleCheckbox.setSelection(preferenceStore.getBoolean(MavenConstants.USE_PROFILE_MODULE));
|
||||
|
||||
filterText.setText(filter);
|
||||
filterText.addModifyListener(new ModifyListener() {
|
||||
|
||||
@@ -115,6 +121,7 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
try {
|
||||
preferenceStore.setValue(MavenConstants.POM_FILTER, getRealVersionFilter(filter));
|
||||
preferenceStore.setValue(MavenConstants.USE_PROFILE_MODULE, useProfileModuleCheckbox.getSelection());
|
||||
new AggregatorPomsHelper().syncAllPoms();
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
@@ -133,6 +140,7 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
boolean ok = super.performOk();
|
||||
if (preferenceStore != null) {
|
||||
preferenceStore.setValue(MavenConstants.POM_FILTER, getRealVersionFilter(filter));
|
||||
preferenceStore.setValue(MavenConstants.USE_PROFILE_MODULE, useProfileModuleCheckbox.getSelection());
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -12,24 +12,22 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.tools;
|
||||
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_AGGREGATORS;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_BEANS;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_CODES;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_JOBS;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_PIGUDFS;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_POMS;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_ROUTINES;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.*;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.maven.model.Activation;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
@@ -56,7 +54,6 @@ import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.model.general.ILibrariesService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.process.ProcessUtils;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.ProjectReference;
|
||||
@@ -110,27 +107,29 @@ public class AggregatorPomsHelper {
|
||||
return projectTechName;
|
||||
}
|
||||
|
||||
public void createRootPom(List<String> modules, boolean force, IProgressMonitor monitor) throws Exception {
|
||||
public void createRootPom(Model model, boolean force, IProgressMonitor monitor)
|
||||
throws Exception {
|
||||
IFile pomFile = getProjectRootPom();
|
||||
if (force || !pomFile.exists()) {
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
parameters.put(MavenTemplateManager.KEY_PROJECT_NAME, projectTechName);
|
||||
Model model = MavenTemplateManager.getCodeProjectTemplateModel(parameters);
|
||||
if (modules != null && !modules.isEmpty()) {
|
||||
model.setModules(modules);
|
||||
if (model == null) {
|
||||
model = getCodeProjectTemplateModel();
|
||||
}
|
||||
PomUtil.savePom(monitor, model, pomFile);
|
||||
}
|
||||
}
|
||||
|
||||
public void createRootPom(IProgressMonitor monitor) throws Exception {
|
||||
Model newModel = getCodeProjectTemplateModel();
|
||||
IFile pomFile = getProjectRootPom();
|
||||
List<String> modules = null;
|
||||
if (pomFile != null && pomFile.exists()) {
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(pomFile);
|
||||
modules = model.getModules();
|
||||
Model oldModel = MavenPlugin.getMavenModelManager().readMavenModel(pomFile);
|
||||
List<Profile> profiles = oldModel.getProfiles().stream()
|
||||
.filter(profile -> StringUtils.startsWithIgnoreCase(profile.getId(), projectTechName))
|
||||
.collect(Collectors.toList());
|
||||
newModel.setModules(oldModel.getModules());
|
||||
newModel.getProfiles().addAll(profiles);
|
||||
}
|
||||
createRootPom(modules, true, monitor);
|
||||
createRootPom(newModel, true, monitor);
|
||||
}
|
||||
|
||||
public void installRootPom(boolean force) throws Exception {
|
||||
@@ -290,37 +289,38 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRefProjectModules(List<ProjectReference> references) {
|
||||
public void updateRefProjectModules(List<ProjectReference> references, IProgressMonitor monitor) {
|
||||
if (!needUpdateRefProjectModules()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
List<String> modules = new ArrayList<>();
|
||||
for (ProjectReference reference : references) {
|
||||
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
|
||||
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
modules.add(modulePath);
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(getProjectRootPom());
|
||||
if (PomIdsHelper.useProfileModule()) {
|
||||
List<Profile> profiles = collectRefProjectProfiles(references);
|
||||
Iterator<Profile> iterator = model.getProfiles().listIterator();
|
||||
iterator.forEachRemaining(profile -> {
|
||||
if (StringUtils.startsWithIgnoreCase(profile.getId(), projectTechName)) {
|
||||
iterator.remove();
|
||||
}
|
||||
});
|
||||
model.getProfiles().addAll(profiles);
|
||||
} else {
|
||||
List<String> refPrjectModules = new ArrayList<>();
|
||||
references.forEach(reference -> {
|
||||
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
|
||||
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
refPrjectModules.add(modulePath);
|
||||
});
|
||||
List<String> modules = model.getModules();
|
||||
Iterator<String> iterator = modules.listIterator();
|
||||
iterator.forEachRemaining(modulePath -> {
|
||||
if (modulePath.startsWith("../../")) { //$NON-NLS-1$
|
||||
iterator.remove();
|
||||
}
|
||||
});
|
||||
modules.addAll(refPrjectModules);
|
||||
}
|
||||
|
||||
Project mainProject = ProjectManager.getInstance().getCurrentProject();
|
||||
IFolder mainPomsFolder = new AggregatorPomsHelper(mainProject.getTechnicalLabel()).getProjectPomsFolder();
|
||||
IFile mainPomFile = mainPomsFolder.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(mainPomFile);
|
||||
List<String> oldModules = model.getModules();
|
||||
if (oldModules == null) {
|
||||
oldModules = new ArrayList<>();
|
||||
}
|
||||
ListIterator<String> iterator = oldModules.listIterator();
|
||||
while (iterator.hasNext()) {
|
||||
String modulePath = iterator.next();
|
||||
if (modulePath.startsWith("../../")) { //$NON-NLS-1$
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
oldModules.addAll(modules);
|
||||
|
||||
PomUtil.savePom(null, model, mainPomFile);
|
||||
createRootPom(model, true, monitor);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
@@ -710,47 +710,48 @@ public class AggregatorPomsHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void collectModules(List<String> modules) {
|
||||
IRunProcessService service = getRunProcessService();
|
||||
if (service != null) {
|
||||
modules.add(
|
||||
getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.ROUTINES).getProjectPom()));
|
||||
if (ProcessUtils.isRequiredPigUDFs(null)) {
|
||||
modules.add(
|
||||
getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.PIG_UDF).getProjectPom()));
|
||||
}
|
||||
if (ProcessUtils.isRequiredBeans(null)) {
|
||||
modules.add(getModulePath(service
|
||||
.getTalendCodeJavaProject(ERepositoryObjectType.valueOf("BEANS")) //$NON-NLS-1$
|
||||
.getProjectPom()));
|
||||
}
|
||||
private List<Profile> collectRefProjectProfiles(List<ProjectReference> references) throws CoreException {
|
||||
if (!needUpdateRefProjectModules()) {
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(getProjectRootPom());
|
||||
List<Profile> profiles = model.getProfiles();
|
||||
return profiles.stream().filter(profile -> StringUtils.startsWithIgnoreCase(profile.getId(), projectTechName))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (needUpdateRefProjectModules()) {
|
||||
List<ProjectReference> references =
|
||||
ProjectManager.getInstance().getCurrentProject().getProjectReferenceList(true);
|
||||
for (ProjectReference reference : references) {
|
||||
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
|
||||
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
modules.add(modulePath);
|
||||
}
|
||||
} else {
|
||||
Project mainProject = ProjectManager.getInstance().getCurrentProject();
|
||||
IFolder mainPomsFolder = new AggregatorPomsHelper(mainProject.getTechnicalLabel()).getProjectPomsFolder();
|
||||
IFile mainPomFile = mainPomsFolder.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
try {
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(mainPomFile);
|
||||
List<String> oldModules = model.getModules();
|
||||
if (oldModules != null) {
|
||||
for (String modulePath : oldModules) {
|
||||
if (modulePath.startsWith("../../")) { //$NON-NLS-1$
|
||||
modules.add(modulePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
if (references == null) {
|
||||
references = ProjectManager.getInstance().getCurrentProject().getProjectReferenceList(true);
|
||||
}
|
||||
List<Profile> profiles = new ArrayList<>();
|
||||
references.forEach(reference -> {
|
||||
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
|
||||
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
Profile profile = new Profile();
|
||||
profile.setId((projectTechName + "_" + refProjectTechName).toLowerCase()); //$NON-NLS-1$
|
||||
Activation activation = new Activation();
|
||||
activation.setActiveByDefault(true);
|
||||
profile.setActivation(activation);
|
||||
profile.getModules().add(modulePath);
|
||||
profiles.add(profile);
|
||||
});
|
||||
return profiles;
|
||||
}
|
||||
|
||||
private List<String> collectRefProjectModules(List<ProjectReference> references) throws CoreException {
|
||||
if (!needUpdateRefProjectModules()) {
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(getProjectRootPom());
|
||||
return model.getModules().stream().filter(modulePath -> modulePath.startsWith("../../")) //$NON-NLS-1$
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (references == null) {
|
||||
references = ProjectManager.getInstance().getCurrentProject().getProjectReferenceList(true);
|
||||
}
|
||||
List<String> modules = new ArrayList<>();
|
||||
references.forEach(reference -> {
|
||||
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
|
||||
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
modules.add(modulePath);
|
||||
});
|
||||
return modules;
|
||||
|
||||
}
|
||||
|
||||
public boolean needUpdateRefProjectModules() {
|
||||
@@ -841,8 +842,15 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
// sync project pom again with all modules.
|
||||
monitor.subTask("Synchronize project pom with modules"); //$NON-NLS-1$
|
||||
collectModules(modules);
|
||||
createRootPom(modules, true, monitor);
|
||||
collectCodeModules(modules);
|
||||
Model model = getCodeProjectTemplateModel();
|
||||
if (PomIdsHelper.useProfileModule()) {
|
||||
model.getProfiles().addAll(collectRefProjectProfiles(null));
|
||||
} else {
|
||||
modules.addAll(collectRefProjectModules(null));
|
||||
}
|
||||
model.setModules(modules);
|
||||
createRootPom(model, true, monitor);
|
||||
installRootPom(true);
|
||||
monitor.worked(1);
|
||||
if (monitor.isCanceled()) {
|
||||
@@ -851,6 +859,21 @@ public class AggregatorPomsHelper {
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
private void collectCodeModules(List<String> modules) {
|
||||
// collect codes modules
|
||||
IRunProcessService service = getRunProcessService();
|
||||
if (service != null) {
|
||||
modules.add(getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.ROUTINES).getProjectPom()));
|
||||
if (ProcessUtils.isRequiredPigUDFs(null)) {
|
||||
modules.add(getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.PIG_UDF).getProjectPom()));
|
||||
}
|
||||
if (ProcessUtils.isRequiredBeans(null)) {
|
||||
modules.add(getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.valueOf("BEANS")) //$NON-NLS-1$
|
||||
.getProjectPom()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if is a esb data service job
|
||||
*
|
||||
@@ -879,6 +902,12 @@ public class AggregatorPomsHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Model getCodeProjectTemplateModel() {
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
parameters.put(MavenTemplateManager.KEY_PROJECT_NAME, projectTechName);
|
||||
return MavenTemplateManager.getCodeProjectTemplateModel(parameters);
|
||||
}
|
||||
|
||||
private static IRunProcessService getRunProcessService() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService runProcessService =
|
||||
|
||||
@@ -260,6 +260,12 @@ public class PomIdsHelper {
|
||||
return manager.getValue(MavenConstants.POM_FILTER);
|
||||
}
|
||||
|
||||
public static boolean useProfileModule() {
|
||||
String projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
ProjectPreferenceManager manager = getPreferenceManager(projectTechName);
|
||||
return manager.getBoolean(MavenConstants.USE_PROFILE_MODULE);
|
||||
}
|
||||
|
||||
private static String getGroupId(String projectTechName, String baseName, Property property) {
|
||||
if (projectTechName == null) {
|
||||
projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
|
||||
@@ -547,7 +547,7 @@ public class PomUtil {
|
||||
|
||||
File resolve = null;
|
||||
try {
|
||||
resolve = TalendMavenResolver.getMavenResolver().resolve(localMavenUri);
|
||||
resolve = TalendMavenResolver.resolve(localMavenUri);
|
||||
} catch (IOException | RuntimeException e) {
|
||||
resolve = null;
|
||||
}
|
||||
|
||||
@@ -45,9 +45,9 @@
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.talend.libraries</groupId>
|
||||
<groupId>org.talend.components.lib</groupId>
|
||||
<artifactId>talend-db-exasol</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<version>2.1.4</version>
|
||||
<type>jar</type>
|
||||
<overWrite>true</overWrite>
|
||||
<outputDirectory>${libs.dir}</outputDirectory>
|
||||
|
||||
@@ -121,7 +121,7 @@ public class ShareMavenArtifactsOnStartup extends ShareLibrareisHelper {
|
||||
MavenUrlHelper.MVN_PROTOCOL + MavenConstants.LOCAL_RESOLUTION_URL + MavenUrlHelper.REPO_SEPERATOR);
|
||||
File file = null;
|
||||
try {
|
||||
file = TalendMavenResolver.getMavenResolver().resolve(localMvnUrl);
|
||||
file = TalendMavenResolver.resolve(localMvnUrl);
|
||||
} catch (IOException | RuntimeException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
@@ -98,23 +98,7 @@ public class NexusDownloadHelperWithProgress extends DownloadHelperWithProgress
|
||||
private File resolveJar(ArtifactRepositoryBean 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 regex = "\\://(.+)\\:(.+)@";
|
||||
String message = e.getMessage();
|
||||
message = message.replaceAll(regex, "://");
|
||||
Exception cause = null;
|
||||
if (e.getCause() != null) {
|
||||
String causeMessage = e.getCause().getMessage();
|
||||
causeMessage = causeMessage.replaceAll(regex, "://");
|
||||
cause = new Exception(causeMessage);
|
||||
}
|
||||
throw new Exception(message, cause);
|
||||
}
|
||||
return resolved;
|
||||
return libManager.resolveJar(customNexusServer, decryptedMvnUri);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
package routines;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class Numeric {
|
||||
|
||||
private static final java.util.Map<String, Integer> seq_Hash = new java.util.HashMap<String, Integer>();
|
||||
private static final java.util.Map<String, Integer> seq_Hash = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* return an incremented numeric id
|
||||
@@ -30,13 +31,8 @@ public class Numeric {
|
||||
*
|
||||
*/
|
||||
public static Integer sequence(String seqName, int startValue, int step) {
|
||||
if (seq_Hash.containsKey(seqName)) {
|
||||
seq_Hash.put(seqName, seq_Hash.get(seqName) + step);
|
||||
return seq_Hash.get(seqName);
|
||||
} else {
|
||||
seq_Hash.put(seqName, startValue);
|
||||
return startValue;
|
||||
}
|
||||
return seq_Hash.compute(seqName,
|
||||
(String k, Integer v) -> v == null ? startValue : v + step);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,9 +64,7 @@ public class Numeric {
|
||||
*/
|
||||
|
||||
public static void removeSequence(String seqName) {
|
||||
if (seq_Hash.containsKey(seqName)) {
|
||||
seq_Hash.remove(seqName);
|
||||
}
|
||||
seq_Hash.remove(seqName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -129,7 +129,7 @@ public class JobStructureCatcherUtils {
|
||||
this.job_version = jobVersion;
|
||||
}
|
||||
|
||||
public void addMessage(String component_id, String component_name, Map<String, String> component_parameters,
|
||||
private void addMessage(String component_id, String component_name, Map<String, String> component_parameters,
|
||||
List<Map<String, String>> component_schema, String input_connectors, String output_connectors,
|
||||
Map<String, String> connector_name_2_connector_schema, boolean current_connector_as_input,
|
||||
String current_connector_type, String current_connector, String currrent_row_content, long row_count,
|
||||
@@ -149,7 +149,7 @@ public class JobStructureCatcherUtils {
|
||||
current_connector_type, current_connector, null, 0, total_row_number, start_time, end_time, null);
|
||||
}
|
||||
|
||||
public void addComponentMessage(String component_id, String component_name) {
|
||||
public void addCM(String component_id, String component_name) {
|
||||
this.addMessage(component_id, component_name, null, null, null, null, null, false, null, null,
|
||||
null, 0, 0, 0, 0, null);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class RunStat implements Runnable {
|
||||
|
||||
@@ -51,7 +52,7 @@ public class RunStat implements Runnable {
|
||||
|
||||
public static String TYPE1_CONNECTION = "1";
|
||||
|
||||
public class StatBean {
|
||||
private class StatBean {
|
||||
|
||||
private String itemId;
|
||||
|
||||
@@ -333,7 +334,7 @@ public class RunStat implements Runnable {
|
||||
|
||||
private List<String> keysList4Meter = new LinkedList<String>();
|
||||
|
||||
public synchronized StatBean logStatOnConnection(String connectionId, int mode, int nbLine) {
|
||||
public synchronized StatBean log(String connectionId, int mode, int nbLine) {
|
||||
StatBean bean;
|
||||
String key = connectionId;
|
||||
if (connectionId.contains(".")) {
|
||||
@@ -386,7 +387,178 @@ public class RunStat implements Runnable {
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
public synchronized boolean log(Map<String, Object> resourceMap, String iterateId, String connectionUniqueName, int mode, int nbLine,
|
||||
JobStructureCatcherUtils jscu, String sourceNodeId, String sourceNodeComponent, String targetNodeId, String targetNodeComponent, String lineType) {
|
||||
if(resourceMap.get("inIterateVComp") == null || !((Boolean)resourceMap.get("inIterateVComp"))) {
|
||||
StatBean bean = log(connectionUniqueName, mode, nbLine);
|
||||
jscu.addConnectionMessage(
|
||||
sourceNodeId,
|
||||
sourceNodeComponent,
|
||||
false,
|
||||
lineType,
|
||||
connectionUniqueName+iterateId,
|
||||
bean.getNbLine(),
|
||||
bean.getStartTime(),
|
||||
bean.getEndTime()
|
||||
);
|
||||
|
||||
jscu.addConnectionMessage(
|
||||
targetNodeId,
|
||||
targetNodeComponent,
|
||||
true,
|
||||
"input",
|
||||
connectionUniqueName+iterateId,
|
||||
bean.getNbLine(),
|
||||
bean.getStartTime(),
|
||||
bean.getEndTime()
|
||||
);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* work for avoiding the 65535 issue
|
||||
*/
|
||||
public synchronized void updateStat(Map<String, Object> resourceMap, String iterateId, int mode, int nbLine, String... connectionUniqueNames) {
|
||||
if(resourceMap.get("inIterateVComp") == null || !((Boolean)resourceMap.get("inIterateVComp"))){
|
||||
for(String connectionUniqueName : connectionUniqueNames) {
|
||||
updateStatOnConnection(connectionUniqueName+iterateId, mode, nbLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* work for avoiding the 65535 issue
|
||||
*/
|
||||
public synchronized boolean updateStatAndLog(boolean execStat, boolean enableLogStash, Map<String, Object> resourceMap, String iterateId, String connectionUniqueName, int mode, int nbLine,
|
||||
JobStructureCatcherUtils jscu, String sourceNodeId, String sourceNodeComponent, String targetNodeId, String targetNodeComponent, String lineType) {
|
||||
if(execStat) {
|
||||
updateStat(resourceMap, iterateId, mode, nbLine, connectionUniqueName);
|
||||
}
|
||||
|
||||
if(enableLogStash) {
|
||||
return log(resourceMap, iterateId, connectionUniqueName, mode, nbLine,
|
||||
jscu, sourceNodeId, sourceNodeComponent, targetNodeId, targetNodeComponent, lineType);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* work for avoiding the 65535 issue
|
||||
*/
|
||||
public synchronized void updateStatOnConnection(Map<String, Object> resourceMap, String iterateId, int mode, int nbLine, String... connectionUniqueNames) {
|
||||
if(resourceMap.get("inIterateVComp") == null){
|
||||
for(String connectionUniqueName : connectionUniqueNames) {
|
||||
updateStatOnConnection(connectionUniqueName+iterateId, mode, nbLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* work for avoiding the 65535 issue
|
||||
*/
|
||||
public synchronized void log(Map<String, Object> resourceMap, String iterateId, int mode, int nbLine, String... connectionUniqueNames) {
|
||||
if(resourceMap.get("inIterateVComp") == null){
|
||||
for(String connectionUniqueName : connectionUniqueNames) {
|
||||
log(connectionUniqueName+iterateId, mode, nbLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* work for avoiding the 65535 issue
|
||||
*/
|
||||
public synchronized void updateStatAndLog(boolean execStat, boolean enableLogStash, Map<String, Object> resourceMap, String iterateId, int mode, int nbLine, String... connectionUniqueNames) {
|
||||
if(execStat) {
|
||||
updateStatOnConnection(resourceMap, iterateId, mode, nbLine, connectionUniqueNames);
|
||||
}
|
||||
|
||||
if(enableLogStash) {
|
||||
log(resourceMap, iterateId, mode, nbLine, connectionUniqueNames);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* work for avoiding the 65535 issue
|
||||
*/
|
||||
public synchronized void updateStatOnConnection(String iterateId, int mode, int nbLine, String... connectionUniqueNames) {
|
||||
for(String connectionUniqueName : connectionUniqueNames) {
|
||||
updateStatOnConnection(connectionUniqueName+iterateId, mode, nbLine);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* work for avoiding the 65535 issue
|
||||
*/
|
||||
public synchronized void log(String iterateId, int mode, int nbLine, String... connectionUniqueNames) {
|
||||
for(String connectionUniqueName : connectionUniqueNames) {
|
||||
log(connectionUniqueName+iterateId, mode, nbLine);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* work for avoiding the 65535 issue
|
||||
*/
|
||||
public synchronized void updateStatAndLog(boolean execStat, boolean enableLogStash, String iterateId, int mode, int nbLine, String... connectionUniqueNames) {
|
||||
if(execStat) {
|
||||
updateStatOnConnection(iterateId, mode, nbLine, connectionUniqueNames);
|
||||
}
|
||||
|
||||
if(enableLogStash) {
|
||||
log(iterateId, mode, nbLine, connectionUniqueNames);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* work for avoiding the 65535 issue
|
||||
*/
|
||||
public synchronized void updateStatOnConnectionAndLog(Map<String, Object> globalMap, int iterateLoop, String iterateId, boolean execStat, boolean enableLogStash, int nbLine, String... connectionUniqueNames) {
|
||||
for(String connectionUniqueName : connectionUniqueNames) {
|
||||
ConcurrentHashMap<Object, Object> concurrentHashMap = (ConcurrentHashMap) globalMap.get("concurrentHashMap");
|
||||
concurrentHashMap.putIfAbsent(connectionUniqueName + iterateLoop,new java.util.concurrent.atomic.AtomicInteger(0));
|
||||
java.util.concurrent.atomic.AtomicInteger stats = (java.util.concurrent.atomic.AtomicInteger) concurrentHashMap.get(connectionUniqueName + iterateLoop);
|
||||
|
||||
int step = stats.incrementAndGet()<=1?0:1;
|
||||
|
||||
if(execStat) {
|
||||
updateStatOnConnection(connectionUniqueName+iterateId, step, nbLine);
|
||||
}
|
||||
|
||||
if(enableLogStash) {
|
||||
log(connectionUniqueName+iterateId, step, nbLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* work for avoiding the 65535 issue
|
||||
*/
|
||||
public synchronized void updateStatOnConnectionAndLog(Map<String, Object> resourceMap, Map<String, Object> globalMap, int iterateLoop, String iterateId, boolean execStat, boolean enableLogStash, int nbLine, String... connectionUniqueNames) {
|
||||
for(String connectionUniqueName : connectionUniqueNames) {
|
||||
if(resourceMap.get("inIterateVComp") == null) {
|
||||
ConcurrentHashMap<Object, Object> concurrentHashMap = (ConcurrentHashMap) globalMap.get("concurrentHashMap");
|
||||
concurrentHashMap.putIfAbsent(connectionUniqueName + iterateLoop,new java.util.concurrent.atomic.AtomicInteger(0));
|
||||
java.util.concurrent.atomic.AtomicInteger stats = (java.util.concurrent.atomic.AtomicInteger) concurrentHashMap.get(connectionUniqueName + iterateLoop);
|
||||
|
||||
int step = stats.incrementAndGet()<=1?0:1;
|
||||
|
||||
if(execStat) {
|
||||
updateStatOnConnection(connectionUniqueName+iterateId, step, nbLine);
|
||||
}
|
||||
|
||||
if(enableLogStash) {
|
||||
log(connectionUniqueName+iterateId, step, nbLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void updateStatOnConnection(String connectionId, int mode, int nbLine) {
|
||||
StatBean bean;
|
||||
String key = connectionId;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<%
|
||||
EXTRACT(__SCHEMA__);
|
||||
String fieldsCreated = "";
|
||||
boolean flagCreated=false;
|
||||
|
||||
for(int i=0; i < __SCHEMA__.length; i++){
|
||||
if(flagCreated){
|
||||
fieldsCreated += ",";
|
||||
}else{
|
||||
flagCreated=true;
|
||||
}
|
||||
if( __SCHEMA_DBTYPE__[i].equals("VARCHAR") || __SCHEMA_DBTYPE__[i].equals("VARCHAR2") || __SCHEMA_DBTYPE__[i].equals("CHAR") || __SCHEMA_DBTYPE__[i].equals("BYTE") || __SCHEMA_DBTYPE__[i].equals("VARBYTE")){
|
||||
fieldsCreated += (__SCHEMA_NAME__[i] + " " + __SCHEMA_DBTYPE__[i] +" ("+ __SCHEMA_LENGTH__[i] +") ");
|
||||
} else if(__SCHEMA_DBTYPE__[i].equals("NUMBER") || __SCHEMA_DBTYPE__[i].equals("DECIMAL")){
|
||||
fieldsCreated += (__SCHEMA_NAME__[i] + " " + __SCHEMA_DBTYPE__[i] +" ("+ __SCHEMA_LENGTH__[i] +","+ __SCHEMA_PRECISION__[i] +") ");
|
||||
} else {
|
||||
fieldsCreated += (__SCHEMA_NAME__[i] + " " + __SCHEMA_DBTYPE__[i]);
|
||||
}
|
||||
if(__SCHEMA_NULLABLE__[i].equals("false")){
|
||||
fieldsCreated += " NOT NULL";
|
||||
}
|
||||
}
|
||||
String primary = "";
|
||||
for(int j=0; j < __SCHEMA__.length; j++){
|
||||
if(__SCHEMA_ISKEY__[j].equals("true") && __SCHEMA_NULLABLE__[j].equals("false")){
|
||||
if(primary.startsWith(" , PRIMARY KEY")) {
|
||||
primary += ","+__SCHEMA_NAME__[j];
|
||||
} else {
|
||||
primary += " , PRIMARY KEY ("+__SCHEMA_NAME__[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!primary.equals("")){
|
||||
fieldsCreated += primary+")";
|
||||
}
|
||||
%>
|
||||
|
||||
CREATE TABLE <%= __TABLE_NAME__ %>
|
||||
(
|
||||
<%= fieldsCreated %>
|
||||
);
|
||||
@@ -0,0 +1,41 @@
|
||||
<%
|
||||
EXTRACT(__SCHEMA_TARGET__);
|
||||
String fieldsCreated = "";
|
||||
boolean flagCreated=false;
|
||||
|
||||
for(int i=0; i < __SCHEMA_TARGET__.length; i++){
|
||||
if(flagCreated){
|
||||
fieldsCreated += ",";
|
||||
}else{
|
||||
flagCreated=true;
|
||||
}
|
||||
if( __SCHEMA_TARGET_DBTYPE__[i].equals("VARCHAR") || __SCHEMA_TARGET_DBTYPE__[i].equals("VARCHAR2") || __SCHEMA_TARGET_DBTYPE__[i].equals("CHAR") || __SCHEMA_TARGET_DBTYPE__[i].equals("BYTE") || __SCHEMA_TARGET_DBTYPE__[i].equals("VARBYTE")){
|
||||
fieldsCreated += (__SCHEMA_TARGET_NAME__[i] + " " + __SCHEMA_TARGET_DBTYPE__[i] +" ("+ __SCHEMA_TARGET_LENGTH__[i] +") ");
|
||||
} else if(__SCHEMA_TARGET_DBTYPE__[i].equals("NUMBER") || __SCHEMA_TARGET_DBTYPE__[i].equals("DECIMAL")){
|
||||
fieldsCreated += (__SCHEMA_TARGET_NAME__[i] + " " + __SCHEMA_TARGET_DBTYPE__[i] +" ("+ __SCHEMA_TARGET_LENGTH__[i] +","+ __SCHEMA_TARGET_PRECISION__[i] +") ");
|
||||
} else {
|
||||
fieldsCreated += (__SCHEMA_TARGET_NAME__[i] + " " + __SCHEMA_TARGET_DBTYPE__[i]);
|
||||
}
|
||||
if(__SCHEMA_TARGET_NULLABLE__[i].equals("false")){
|
||||
fieldsCreated += " NOT NULL";
|
||||
}
|
||||
}
|
||||
String primary = "";
|
||||
for(int j=0; j < __SCHEMA_TARGET__.length; j++){
|
||||
if(__SCHEMA_TARGET_ISKEY__[j].equals("true") && __SCHEMA_TARGET_NULLABLE__[j].equals("false")){
|
||||
if(primary.startsWith(" , PRIMARY KEY")) {
|
||||
primary += ","+__SCHEMA_TARGET_NAME__[j];
|
||||
} else {
|
||||
primary += " , PRIMARY KEY ("+__SCHEMA_TARGET_NAME__[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!primary.equals("")){
|
||||
fieldsCreated += primary+")";
|
||||
}
|
||||
%>
|
||||
|
||||
CREATE TABLE <%= __TABLE_NAME_TARGET__ %>
|
||||
(
|
||||
<%= fieldsCreated %>
|
||||
);
|
||||
@@ -0,0 +1,2 @@
|
||||
-- DROP SOURCE TABLE
|
||||
DROP TABLE <%= __TABLE_NAME__ %>;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- DROP TARGET TABLE
|
||||
DROP TABLE <%=__TABLE_NAME_TARGET__%>;
|
||||
@@ -0,0 +1,101 @@
|
||||
-- This pattern generates a merge statement for Snowflake
|
||||
--(c) 2019 Talend Inc.
|
||||
<%
|
||||
EXTRACT(__MERGE_ON__);
|
||||
EXTRACT(__UPDATE_MAPPING__);
|
||||
EXTRACT(__ADDITIONAL_UPDATE_COLUMNS__);
|
||||
EXTRACT(__INSERT_MAPPING__);
|
||||
EXTRACT(__ADDITIONAL_INSERT_COLUMNS__);
|
||||
String dbType = "__DBTYPE__";
|
||||
boolean hasUpdateClause = __USE_UPDATE__;
|
||||
boolean hasAddtionalUpdateColumns = __SPECIFY_ADDITIONAL_UPDATE_COLUMNS__;
|
||||
boolean hasUpdateWhereClause = __SPECIFY_UPDATE_WHERE_CLAUSE__;
|
||||
boolean hasInsertClause = __USE_INSERT__;
|
||||
boolean hasAdditionalInsertColumns = __SPECIFY_ADDITIONAL_INSERT_COLUMNS__;
|
||||
boolean hasInsertWhereClause = __SPECIFY_INSERT_WHERE_CLAUSE__;
|
||||
|
||||
boolean flag = false;
|
||||
String mergeOnStr = "";
|
||||
for(int i=0; i < __MERGE_ON_SRC_COLUMN__.length; i++){
|
||||
if (flag) {
|
||||
mergeOnStr += " AND ";
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
mergeOnStr += (__TARGET_TABLE__ + "." + __MERGE_ON_TRG_COLUMN__[i] + " = " + __SOURCE_TABLE__ + "." + __MERGE_ON_SRC_COLUMN__[i]);
|
||||
}
|
||||
|
||||
String updateStr = "";
|
||||
String updateWhereStr = "";
|
||||
flag = false;
|
||||
if (hasUpdateClause) {
|
||||
for(int i=0; i < __UPDATE_MAPPING_SRC_COLUMN__.length; i++) {
|
||||
if (flag) {
|
||||
updateStr += ",";
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
updateStr += (__TARGET_TABLE__ + "." + __UPDATE_MAPPING_TRG_COLUMN__[i] + " = " + __SOURCE_TABLE__ + "." + __UPDATE_MAPPING_SRC_COLUMN__[i]);
|
||||
}
|
||||
if (hasAddtionalUpdateColumns) {
|
||||
for(int i=0; i < __ADDITIONAL_UPDATE_COLUMNS_TRG_COLUMN_VALUE__.length; i++) {
|
||||
if (flag) {
|
||||
updateStr += ",";
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
updateStr += (__TARGET_TABLE__ + "." + __ADDITIONAL_UPDATE_COLUMNS_TRG_COLUMN_NAME__[i] + " = " + __ADDITIONAL_UPDATE_COLUMNS_TRG_COLUMN_VALUE__[i]);
|
||||
}
|
||||
}
|
||||
if (hasUpdateWhereClause) {
|
||||
updateWhereStr = " " + __UPDATE_WHERE_CLAUSE__ + " ";
|
||||
}
|
||||
}
|
||||
|
||||
String insertColumnsStr = "";
|
||||
String insertValuesStr = "";
|
||||
String insertWhereStr = "";
|
||||
String insertStr = "";
|
||||
flag = false;
|
||||
if (hasInsertClause) {
|
||||
for(int i=0; i < __INSERT_MAPPING_TRG_COLUMN__.length; i++) {
|
||||
if (flag) {
|
||||
insertColumnsStr += ",";
|
||||
insertValuesStr += ",";
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
insertColumnsStr += (__TARGET_TABLE__ + "." + __INSERT_MAPPING_TRG_COLUMN__[i]);
|
||||
insertValuesStr += (__SOURCE_TABLE__ + "." + __INSERT_MAPPING_SRC_COLUMN__[i]);
|
||||
}
|
||||
if (hasAdditionalInsertColumns) {
|
||||
for(int i=0; i < __ADDITIONAL_INSERT_COLUMNS_TRG_COLUMN_NAME__.length; i++) {
|
||||
if (flag) {
|
||||
insertColumnsStr += ",";
|
||||
insertValuesStr += ",";
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
insertColumnsStr += (__TARGET_TABLE__ + "." + __ADDITIONAL_INSERT_COLUMNS_TRG_COLUMN_NAME__[i]);
|
||||
insertValuesStr += (__ADDITIONAL_INSERT_COLUMNS_TRG_COLUMN_VALUE__[i]);
|
||||
}
|
||||
}
|
||||
if (hasInsertWhereClause) {
|
||||
insertWhereStr = " " + __INSERT_WHERE_CLAUSE__ + " ";
|
||||
}
|
||||
|
||||
insertStr = "(" + insertColumnsStr + ") VALUES (" + insertValuesStr + ")";
|
||||
}
|
||||
|
||||
String mergeString = "";
|
||||
|
||||
if (hasInsertClause || hasUpdateClause) {
|
||||
mergeString = "MERGE INTO " + __TARGET_TABLE__ + " USING " + __SOURCE_TABLE__ +
|
||||
" ON (" + mergeOnStr + ")" +
|
||||
(hasUpdateClause ? (" WHEN MATCHED " + (hasUpdateWhereClause ? ("AND " + updateWhereStr) : "") + " THEN UPDATE SET " + updateStr) : "") +
|
||||
(hasInsertClause ? (" WHEN NOT MATCHED " + (hasInsertWhereClause ? ("AND " + insertWhereStr) : "") + " THEN INSERT " + insertStr) : "");
|
||||
} else {
|
||||
mergeString = "DELETE FROM " + __TARGET_TABLE__ + " WHERE 1=0";
|
||||
}
|
||||
%>
|
||||
<%=mergeString%>;
|
||||
@@ -46,7 +46,6 @@ import org.eclipse.core.runtime.preferences.ConfigurationScope;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.emf.common.util.EMap;
|
||||
import org.ops4j.pax.url.mvn.MavenResolver;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
@@ -971,7 +970,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
localMavenUri = mvnUriStatusKey.replace("mvn:", "mvn:" + MavenConstants.LOCAL_RESOLUTION_URL + "!"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
try {
|
||||
File resolvedJar = TalendMavenResolver.getMavenResolver().resolve(localMavenUri);
|
||||
File resolvedJar = TalendMavenResolver.resolve(localMavenUri);
|
||||
if (resolvedJar != null) {
|
||||
try {
|
||||
updatePomFileForJar(mvnUriStatusKey);
|
||||
@@ -993,7 +992,6 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
|
||||
private void updatePomFileForJar(String mvnUri) throws Exception {
|
||||
try {
|
||||
MavenResolver mavenResolver = TalendMavenResolver.getMavenResolver();
|
||||
MavenArtifact ma = MavenUrlHelper.parseMvnUrl(mvnUri);
|
||||
if (ma != null) {
|
||||
String repositoryUrl = ma.getRepositoryUrl();
|
||||
@@ -1015,14 +1013,14 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
File pomFile = null;
|
||||
Exception pomEx = null;
|
||||
try {
|
||||
pomFile = mavenResolver.resolve(MavenUrlHelper.generateMvnUrl(pomMa));
|
||||
pomFile = TalendMavenResolver.resolve(MavenUrlHelper.generateMvnUrl(pomMa));
|
||||
} catch (Exception e) {
|
||||
pomEx = e;
|
||||
}
|
||||
if (pomFile == null && classifier != null && !classifier.trim().isEmpty()) {
|
||||
pomMa.setClassifier(classifier);
|
||||
try {
|
||||
pomFile = mavenResolver.resolve(MavenUrlHelper.generateMvnUrl(pomMa));
|
||||
pomFile = TalendMavenResolver.resolve(MavenUrlHelper.generateMvnUrl(pomMa));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
@@ -1672,7 +1672,7 @@ public final class ConnectionContextHelper {
|
||||
}
|
||||
}
|
||||
for (String var : neededVars) {
|
||||
if (context.getContextParameter(var) != null) {
|
||||
if (context.containsSameParameterIgnoreCase(var)) {
|
||||
continue;
|
||||
}
|
||||
ContextParameterType param = ContextUtils.getContextParameterTypeByName(type, var);
|
||||
|
||||
@@ -1042,6 +1042,9 @@ public class ExtractMetaDataUtils {
|
||||
}
|
||||
}else{
|
||||
String jarName = librairesManagerService.getJarNameFromMavenuri(driverJarPathArg);
|
||||
if (jarName == null) {
|
||||
jarName = driverJarPathArg.split("/")[1] + ".jar";
|
||||
}
|
||||
if (!new File(getJavaLibPath() + jarName).exists()) {
|
||||
librairesManagerService.retrieve(jarName, getJavaLibPath(), new NullProgressMonitor());
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public class ExtractManager {
|
||||
tablesToFilter = new ArrayList<String>();
|
||||
}
|
||||
try {
|
||||
Set<String> availableTableTypes = getAvailableTableTypes(dbMetaData);
|
||||
Set<String> availableTableTypes = getTableTypes(dbMetaData);
|
||||
retrieveTables(dbMetaData, schema, medataTables, availableTableTypes, tablesToFilter, limit);
|
||||
} catch (SQLException e) {
|
||||
ExceptionHandler.process(e);
|
||||
@@ -193,7 +193,7 @@ public class ExtractManager {
|
||||
ResultSet rsTableTypes = dbMetaData.getTableTypes();
|
||||
Set<String> availableTableTypes = new HashSet<String>();
|
||||
String[] neededTableTypes = { ETableTypes.TABLETYPE_TABLE.getName(), ETableTypes.TABLETYPE_VIEW.getName(),
|
||||
ETableTypes.TABLETYPE_SYNONYM.getName() };
|
||||
ETableTypes.TABLETYPE_SYNONYM.getName(), ETableTypes.EXTERNAL_TABLE.getName()};
|
||||
|
||||
try {
|
||||
while (rsTableTypes.next()) {
|
||||
@@ -213,6 +213,48 @@ public class ExtractManager {
|
||||
}
|
||||
return availableTableTypes;
|
||||
}
|
||||
|
||||
public Set<String> getTableTypes(DatabaseMetaData dbMetaData) throws SQLException{
|
||||
ResultSet rsTableTypes = dbMetaData.getTableTypes();
|
||||
Set<String> availableTableTypes = new HashSet<String>();
|
||||
String[] neededTableTypes = { ETableTypes.TABLETYPE_TABLE.getName(), ETableTypes.TABLETYPE_VIEW.getName(),
|
||||
ETableTypes.TABLETYPE_SYNONYM.getName(), ETableTypes.EXTERNAL_TABLE.getName()};
|
||||
try {
|
||||
while (rsTableTypes.next()) {
|
||||
// StringUtils.trimToEmpty(name) is because bug 4547
|
||||
String currentTableType = StringUtils.trimToEmpty(rsTableTypes.getString(ExtractManager.TABLE_TYPE));
|
||||
// Because BASE TABLE which UniJDBCClientResultSet gets is not the support type of
|
||||
// UniJDBCDatabaseMetaData, do this so as to dispose bug 17281.
|
||||
if ("BASE TABLE".equalsIgnoreCase(currentTableType)) { //$NON-NLS-1$
|
||||
currentTableType = ETableTypes.TABLETYPE_TABLE.getName();
|
||||
}
|
||||
if (ArrayUtils.contains(neededTableTypes, currentTableType)) {
|
||||
availableTableTypes.add(currentTableType);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
rsTableTypes.close();// See bug 5029 Avoid "Invalid cursor exception"
|
||||
}
|
||||
|
||||
if (EDatabaseTypeName.HIVE.getDisplayName().equals(dbType.getDbType())) {
|
||||
availableTableTypes.add(ETableTypes.MANAGED_TABLE.getName());
|
||||
availableTableTypes.add(ETableTypes.INDEX_TABLE.getName());
|
||||
availableTableTypes.add(ETableTypes.VIRTUAL_VIEW.getName());
|
||||
} else if (EDatabaseTypeName.SAPHana.getDisplayName().equals(dbType.getDbType())) {
|
||||
availableTableTypes.add(ETableTypes.TABLETYPE_CALCULATION_VIEW.getName());
|
||||
} else if (EDatabaseTypeName.MYSQL.getDisplayName().equals(dbType.getDbType())) {
|
||||
availableTableTypes.add(ETableTypes.SYSTEM_TABLE.getName());
|
||||
availableTableTypes.add(ETableTypes.SYSTEM_VIEW.getName());
|
||||
}else if (EDatabaseTypeName.AS400.getDisplayName().equals(dbType.getDbType())) {
|
||||
availableTableTypes.add(ETableTypes.TABLETYPE_TABLE.getName());
|
||||
availableTableTypes.add(ETableTypes.EXTERNAL_TABLE.getName());
|
||||
availableTableTypes.add(ETableTypes.TABLETYPE_VIEW.getName());
|
||||
availableTableTypes.add(ETableTypes.TABLETYPE_SYNONYM.getName());
|
||||
}else if (MetadataConnectionUtils.isOracle(dbMetaData)) {
|
||||
availableTableTypes.add(ETableTypes.TABLETYPE_ALL_SYNONYM.getName());
|
||||
}
|
||||
return availableTableTypes;
|
||||
}
|
||||
|
||||
public String getSchema(IMetadataConnection metadataConnection) {
|
||||
return metadataConnection != null ? metadataConnection.getSchema() : null;
|
||||
|
||||
@@ -55,6 +55,7 @@ import org.talend.core.model.migration.IMigrationToolService;
|
||||
import org.talend.core.model.utils.TalendPropertiesUtil;
|
||||
import org.talend.core.repository.CoreRepositoryPlugin;
|
||||
import org.talend.core.runtime.services.IMavenUIService;
|
||||
import org.talend.core.service.IUpdateService;
|
||||
import org.talend.core.services.ICoreTisService;
|
||||
import org.talend.core.ui.branding.IBrandingService;
|
||||
import org.talend.core.ui.workspace.ChooseWorkspaceData;
|
||||
@@ -156,8 +157,15 @@ public class Application implements IApplication {
|
||||
(IMigrationToolService) GlobalServiceRegister.getDefault().getService(IMigrationToolService.class);
|
||||
service.executeWorspaceTasks();
|
||||
// saveConnectionBean(email);
|
||||
|
||||
boolean needRelaunch = false;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUpdateService.class)) {
|
||||
IUpdateService updateService = GlobalServiceRegister.getDefault().getService(IUpdateService.class);
|
||||
needRelaunch = updateService.checkStudioUpdate(new NullProgressMonitor());
|
||||
}
|
||||
if (needRelaunch) {
|
||||
setRelaunchData();
|
||||
return IApplication.EXIT_RELAUNCH;
|
||||
}
|
||||
final PatchComponent patchComponent = PatchComponentHelper.getPatchComponent();
|
||||
if (patchComponent != null) {
|
||||
final boolean installed = patchComponent.install();
|
||||
|
||||
@@ -24,6 +24,9 @@ ImportItemsWizardPage_sameIdProblemMessage=The 2 following items haves the same
|
||||
ImportItemsWizardPage_TarImport_badFormat = Source file is not a valid tar file.
|
||||
ImportItemsWizardPage_ZipImport_badFormat = Source file is not a valid Zip file.
|
||||
ImportItemsWizardPage_ErrorsMessage=The item '{0}' with different version {1} exists. Check the Recycle bin and empty it if needed.
|
||||
ImportItemsWizardPage_internalIdGroup=Internal id
|
||||
ImportItemsWizardPage_internalIdGroup_alwaysRegenId=Always regenerate id when import
|
||||
ImportItemsWizardPage_internalIdGroup_keepOrigId=Keep original internal id
|
||||
|
||||
ImportItemsAction_title=Import items
|
||||
|
||||
|
||||
@@ -50,6 +50,9 @@ import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.TraverseEvent;
|
||||
import org.eclipse.swt.events.TraverseListener;
|
||||
import org.eclipse.swt.layout.FormAttachment;
|
||||
import org.eclipse.swt.layout.FormData;
|
||||
import org.eclipse.swt.layout.FormLayout;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
@@ -57,6 +60,7 @@ import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.DirectoryDialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
@@ -141,6 +145,8 @@ public class ImportItemsWizardPage extends WizardPage {
|
||||
|
||||
private final ImportExportHandlersManager importManager = new ImportExportHandlersManager();
|
||||
|
||||
private Button regenIdBtn;
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC ggu ImportItemsWizardPage constructor comment.
|
||||
@@ -498,8 +504,29 @@ public class ImportItemsWizardPage extends WizardPage {
|
||||
* @param workArea
|
||||
*/
|
||||
private void createAdditionArea(Composite workArea) {
|
||||
Composite optionsArea = new Composite(workArea, SWT.NONE);
|
||||
FormLayout optAreaLayout = new FormLayout();
|
||||
optionsArea.setLayout(optAreaLayout);
|
||||
GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
|
||||
optionsArea.setLayoutData(gridData);
|
||||
|
||||
Group internalIdGroup = new Group(optionsArea, SWT.NONE);
|
||||
internalIdGroup.setText(Messages.getString("ImportItemsWizardPage_internalIdGroup"));
|
||||
internalIdGroup.setLayout(new GridLayout(1, true));
|
||||
FormData internalIdGroupLayoutData = new FormData();
|
||||
internalIdGroupLayoutData.top = new FormAttachment(0);
|
||||
internalIdGroupLayoutData.left = new FormAttachment(0);
|
||||
internalIdGroup.setLayoutData(internalIdGroupLayoutData);
|
||||
|
||||
regenIdBtn = new Button(internalIdGroup, SWT.RADIO);
|
||||
regenIdBtn.setText(Messages.getString("ImportItemsWizardPage_internalIdGroup_alwaysRegenId"));
|
||||
regenIdBtn.setSelection(true);
|
||||
|
||||
Button keepOrigIdBtn = new Button(internalIdGroup, SWT.RADIO);
|
||||
keepOrigIdBtn.setText(Messages.getString("ImportItemsWizardPage_internalIdGroup_keepOrigId"));
|
||||
|
||||
// see feature 3949
|
||||
this.overwriteButton = new Button(workArea, SWT.CHECK);
|
||||
this.overwriteButton = new Button(optionsArea, SWT.CHECK);
|
||||
this.overwriteButton.setText(Messages.getString("ImportItemsWizardPage_overwriteItemsText")); //$NON-NLS-1$
|
||||
this.overwriteButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@@ -511,6 +538,11 @@ public class ImportItemsWizardPage extends WizardPage {
|
||||
}
|
||||
|
||||
});
|
||||
FormData overwriteLayoutData = new FormData();
|
||||
overwriteLayoutData.top = new FormAttachment(internalIdGroup, 5, SWT.BOTTOM);
|
||||
overwriteLayoutData.left = new FormAttachment(internalIdGroup, 0, SWT.LEFT);
|
||||
this.overwriteButton.setLayoutData(overwriteLayoutData);
|
||||
|
||||
}
|
||||
|
||||
protected boolean isEnableForExchange() {
|
||||
@@ -982,6 +1014,7 @@ public class ImportItemsWizardPage extends WizardPage {
|
||||
}
|
||||
|
||||
final boolean overwrite = overwriteButton.getSelection();
|
||||
final boolean alwaysRegenId = regenIdBtn.getSelection();
|
||||
try {
|
||||
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
|
||||
|
||||
@@ -1008,7 +1041,7 @@ public class ImportItemsWizardPage extends WizardPage {
|
||||
EmfResourcesFactoryReader.INSTANCE.addOption(importOption, false);
|
||||
|
||||
importManager.importItemRecords(monitor, resManager, checkedItemRecords, overwrite,
|
||||
nodesBuilder.getAllImportItemRecords(), destinationPath);
|
||||
nodesBuilder.getAllImportItemRecords(), destinationPath, alwaysRegenId);
|
||||
} finally {
|
||||
EmfResourcesFactoryReader.INSTANCE.removOption(importOption, false);
|
||||
}
|
||||
|
||||
@@ -165,6 +165,13 @@ public final class HandlerUtil {
|
||||
public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException {
|
||||
InputStream inputStream = null;
|
||||
EPackage ePackage = resourceSet.getPackageRegistry().getEPackage(uri.toString());
|
||||
if (ePackage == null && uri.path().contains("CamelProperties")) { //$NON-NLS-1$
|
||||
// org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(String)
|
||||
// after createInputStream still create resource and load while ePackage is null
|
||||
// throw IOexception skip process, XMLHandler.getPackageForURI will judge EPackage
|
||||
// then to throw PackageNotFoundException
|
||||
throw new IOException();
|
||||
}
|
||||
if (ePackage != null || !"http".equals(uri.scheme())) { //$NON-NLS-1$
|
||||
inputStream = super.createInputStream(uri, options);
|
||||
} else {
|
||||
|
||||
@@ -417,6 +417,16 @@ public class ImportExportHandlersManager {
|
||||
public void importItemRecords(final IProgressMonitor progressMonitor, final ResourcesManager resManager,
|
||||
final List<ImportItem> checkedItemRecords, final boolean overwrite, final ImportItem[] allImportItemRecords,
|
||||
final IPath destinationPath) throws InvocationTargetException {
|
||||
importItemRecords(progressMonitor, resManager, checkedItemRecords, overwrite, allImportItemRecords, destinationPath,
|
||||
/*
|
||||
* disable by default, but provide possibility to enable it
|
||||
*/
|
||||
Boolean.getBoolean("studio.import.option.alwaysRegenId"));
|
||||
}
|
||||
|
||||
public void importItemRecords(final IProgressMonitor progressMonitor, final ResourcesManager resManager,
|
||||
final List<ImportItem> checkedItemRecords, final boolean overwrite, final ImportItem[] allImportItemRecords,
|
||||
final IPath destinationPath, final boolean alwaysRegenId) throws InvocationTargetException {
|
||||
TimeMeasure.display = CommonsPlugin.isDebugMode();
|
||||
TimeMeasure.displaySteps = CommonsPlugin.isDebugMode();
|
||||
TimeMeasure.measureActive = CommonsPlugin.isDebugMode();
|
||||
@@ -536,15 +546,31 @@ public class ImportExportHandlersManager {
|
||||
return;
|
||||
}
|
||||
if (itemRecord.isValid()) {
|
||||
if (itemRecord.getState() == State.ID_EXISTED
|
||||
|| itemRecord.getState() == State.NAME_AND_ID_EXISTED_BOTH) {
|
||||
if (alwaysRegenId || itemRecord.getState() == State.ID_EXISTED
|
||||
|| itemRecord.getState() == State.NAME_AND_ID_EXISTED_BOTH
|
||||
|| itemRecord.getState() == State.NAME_EXISTED) {
|
||||
String id = nameToIdMap.get(itemRecord.getProperty().getLabel()
|
||||
+ ERepositoryObjectType.getItemType(itemRecord.getProperty().getItem())
|
||||
.toString());
|
||||
if (id == null) {
|
||||
try {
|
||||
if (overwrite && itemRecord.getState() == State.NAME_AND_ID_EXISTED_BOTH) {
|
||||
boolean reuseExistingId = false;
|
||||
if (overwrite && (itemRecord.getState() == State.NAME_AND_ID_EXISTED_BOTH
|
||||
|| itemRecord.getState() == State.NAME_EXISTED)) {
|
||||
// just try to reuse the id of the item which will be overwrited
|
||||
reuseExistingId = true;
|
||||
} else if (alwaysRegenId) {
|
||||
switch (itemRecord.getState()) {
|
||||
case NAME_EXISTED:
|
||||
case NAME_AND_ID_EXISTED:
|
||||
case NAME_AND_ID_EXISTED_BOTH:
|
||||
reuseExistingId = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (reuseExistingId) {
|
||||
IRepositoryViewObject object = itemRecord.getExistingItemWithSameName();
|
||||
if (object != null) {
|
||||
if (ProjectManager.getInstance().isInCurrentMainProject(
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
@@ -123,68 +124,101 @@ public class ChangeIdManager {
|
||||
|
||||
public void changeIds() throws Exception {
|
||||
buildRefIds2ItemIdsMap();
|
||||
for (Map.Entry<String, String> entry : oldId2NewIdMap.entrySet()) {
|
||||
changeId(entry.getValue(), entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
private void changeId(String newId, String oldId) throws Exception {
|
||||
Map<String, Set<String>> changeIdMap = buildChangeIdMap();
|
||||
|
||||
if (newId == null || StringUtils.equals(newId, oldId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> relationIds = new HashSet<String>();
|
||||
Collection<String> itemIds = refIds2ItemIdsMap.get(oldId);
|
||||
if (itemIds != null && !itemIds.isEmpty()) {
|
||||
relationIds.addAll(itemIds);
|
||||
}
|
||||
|
||||
List<Relation> relations = getRelations(oldId);
|
||||
for (Relation relation : relations) {
|
||||
String projectLabel = ProcessUtils.getProjectLabelFromItemId(relation.getId());
|
||||
if (projectLabel != null
|
||||
&& !projectLabel.equals(ProjectManager.getInstance().getCurrentProject().getTechnicalLabel())) {
|
||||
continue;
|
||||
}
|
||||
relationIds.add(ProcessUtils.getPureItemId(relation.getId()));
|
||||
}
|
||||
|
||||
if (relationIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> changedIds = new HashSet<String>();
|
||||
for (String relationId : relationIds) {
|
||||
String id = relationId;
|
||||
if (!oldId2NewIdMap.containsKey(id)) {
|
||||
for (Map.Entry<String, Set<String>> entry : changeIdMap.entrySet()) {
|
||||
String oldEffectedId = entry.getKey();
|
||||
if (!oldId2NewIdMap.containsKey(oldEffectedId)) {
|
||||
// means didn't import this item
|
||||
continue;
|
||||
}
|
||||
|
||||
if (changedIds.contains(id)) {
|
||||
String newEffectedId = oldId2NewIdMap.get(oldEffectedId);
|
||||
if (StringUtils.equals(oldEffectedId, newEffectedId)) {
|
||||
continue;
|
||||
} else {
|
||||
changedIds.add(id);
|
||||
}
|
||||
|
||||
List<ImportItem> importItems = id2ImportItemsMap.get(id);
|
||||
ERepositoryObjectType repType = importItems.get(0).getRepositoryType();
|
||||
String newRelatedId = oldId2NewIdMap.get(id);
|
||||
if (newRelatedId == null) {
|
||||
if (StringUtils.isBlank(newEffectedId)) {
|
||||
// means the id didn't be changed
|
||||
newRelatedId = id;
|
||||
newEffectedId = oldEffectedId;
|
||||
}
|
||||
List<IRepositoryViewObject> repViewObjs = getAllVersion(newRelatedId, repType);
|
||||
List<ImportItem> importItems = id2ImportItemsMap.get(oldEffectedId);
|
||||
ERepositoryObjectType repType = importItems.get(0).getRepositoryType();
|
||||
List<IRepositoryViewObject> repViewObjs = getAllVersion(newEffectedId, repType);
|
||||
if (repViewObjs != null && !repViewObjs.isEmpty()) {
|
||||
for (IRepositoryViewObject repViewObj : repViewObjs) {
|
||||
Map<String, String> old2NewMap = new HashMap<>();
|
||||
for (String oldId : entry.getValue()) {
|
||||
String newId = oldId2NewIdMap.get(oldId);
|
||||
if (StringUtils.equals(newId, oldId)) {
|
||||
continue;
|
||||
}
|
||||
old2NewMap.put(oldId, newId);
|
||||
}
|
||||
Property property = repViewObj.getProperty();
|
||||
changeRelated(newId, oldId, property, getCurrentProject());
|
||||
changeRelated(old2NewMap, property, getCurrentProject());
|
||||
String version = property.getVersion();
|
||||
for (ImportItem importItem : importItems) {
|
||||
if (StringUtils.equals(version, importItem.getItemVersion())) {
|
||||
// update property, it will be used in following steps
|
||||
importItem.setProperty(property);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Set<String>> buildChangeIdMap() {
|
||||
Map<String, Set<String>> effectedIdsMap = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, String> entry : oldId2NewIdMap.entrySet()) {
|
||||
String oldId = entry.getKey();
|
||||
String newId = entry.getValue();
|
||||
if (newId == null || StringUtils.equals(newId, oldId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Set<String> relationIds = new HashSet<String>();
|
||||
Collection<String> itemIds = refIds2ItemIdsMap.get(oldId);
|
||||
if (itemIds != null && !itemIds.isEmpty()) {
|
||||
relationIds.addAll(itemIds);
|
||||
}
|
||||
|
||||
List<Relation> relations = getRelations(oldId);
|
||||
for (Relation relation : relations) {
|
||||
relationIds.add(ProcessUtils.getPureItemId(relation.getId()));
|
||||
}
|
||||
|
||||
if (relationIds.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Set<String> idSet = effectedIdsMap.get(oldId);
|
||||
if (idSet == null) {
|
||||
idSet = new HashSet<>();
|
||||
effectedIdsMap.put(oldId, idSet);
|
||||
}
|
||||
idSet.addAll(relationIds);
|
||||
}
|
||||
|
||||
Map<String, Set<String>> changeIdMap = new HashMap<>();
|
||||
for (Map.Entry<String, Set<String>> entry : effectedIdsMap.entrySet()) {
|
||||
String oldId = entry.getKey();
|
||||
Set<String> effectedIds = entry.getValue();
|
||||
|
||||
for (String effectedId : effectedIds) {
|
||||
Set<String> changeSet = changeIdMap.get(effectedId);
|
||||
if (changeSet == null) {
|
||||
changeSet = new HashSet<>();
|
||||
changeIdMap.put(effectedId, changeSet);
|
||||
}
|
||||
changeSet.add(oldId);
|
||||
}
|
||||
}
|
||||
return changeIdMap;
|
||||
}
|
||||
|
||||
private List<IRepositoryViewObject> getAllVersion(String id, ERepositoryObjectType repType) throws Exception {
|
||||
List<IRepositoryViewObject> repViewObjs = null;
|
||||
if (repType != null) {
|
||||
@@ -253,16 +287,16 @@ public class ChangeIdManager {
|
||||
return relations;
|
||||
}
|
||||
|
||||
private void changeRelated(String newId, String oldId, Property property, org.talend.core.model.general.Project project)
|
||||
throws Exception {
|
||||
private void changeRelated(Map<String, String> old2NewMap, Property property,
|
||||
org.talend.core.model.general.Project project) throws Exception {
|
||||
Item item = property.getItem();
|
||||
boolean modified = false;
|
||||
if (item instanceof ProcessItem) {
|
||||
modified = changeRelatedProcess(newId, oldId, item);
|
||||
modified = changeRelatedProcess(old2NewMap, item);
|
||||
} else if (item instanceof JobletProcessItem) {
|
||||
modified = changeRelatedProcess(newId, oldId, item);
|
||||
modified = changeRelatedProcess(old2NewMap, item);
|
||||
} else if (item instanceof ConnectionItem) {
|
||||
modified = changeRelatedConnection(newId, oldId, (ConnectionItem) item);
|
||||
modified = changeRelatedConnection(old2NewMap, (ConnectionItem) item);
|
||||
} else {
|
||||
throw new Exception("Unsupported id change: id[" + property.getId() + "], name[" + property.getLabel() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
@@ -272,22 +306,41 @@ public class ChangeIdManager {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean changeRelatedConnection(String newId, String oldId, ConnectionItem item) throws Exception {
|
||||
private boolean changeRelatedConnection(Map<String, String> old2NewMap, ConnectionItem item) throws Exception {
|
||||
boolean modified = false;
|
||||
Connection conn = item.getConnection();
|
||||
String ctxId = conn.getContextId();
|
||||
if (StringUtils.equals(oldId, ctxId)) {
|
||||
conn.setContextId(newId);
|
||||
modified = true;
|
||||
} else {
|
||||
for (Map.Entry<String, String> entry : old2NewMap.entrySet()) {
|
||||
if (StringUtils.equals(entry.getKey(), ctxId)) {
|
||||
conn.setContextId(entry.getValue());
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
if (!modified) {
|
||||
throw new Exception("Unhandled case for import: " + item.toString()); //$NON-NLS-1$
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean changeRelatedProcess(String newId, String oldId, Item item) throws Exception {
|
||||
private boolean changeRelatedProcess(Map<String, String> old2NewMap, Item item) throws Exception {
|
||||
boolean modified = false;
|
||||
|
||||
ProcessItem processItem = (ProcessItem) item;
|
||||
ProcessType processType = processItem.getProcess();
|
||||
|
||||
/**
|
||||
* change context repository id
|
||||
*/
|
||||
if (processType != null) {
|
||||
EList context = processType.getContext();
|
||||
if (context != null) {
|
||||
for (Map.Entry<String, String> entry : old2NewMap.entrySet()) {
|
||||
changeValue(context, entry.getKey(), entry.getValue());
|
||||
}
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* designerCoreService must not be null
|
||||
*/
|
||||
@@ -310,14 +363,18 @@ public class ChangeIdManager {
|
||||
// }
|
||||
IContextManager contextManager = process.getContextManager();
|
||||
if (contextManager != null) {
|
||||
changeValue(contextManager.getListContext(), oldId, newId);
|
||||
for (Map.Entry<String, String> entry : old2NewMap.entrySet()) {
|
||||
changeValue(contextManager.getListContext(), entry.getKey(), entry.getValue());
|
||||
}
|
||||
modified = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 2. change elementParameters
|
||||
*/
|
||||
changeValue(process.getElementParameters(), oldId, newId);
|
||||
for (Map.Entry<String, String> entry : old2NewMap.entrySet()) {
|
||||
changeValue(process.getElementParameters(), entry.getKey(), entry.getValue());
|
||||
}
|
||||
modified = true;
|
||||
|
||||
/**
|
||||
@@ -329,7 +386,9 @@ public class ChangeIdManager {
|
||||
while (nodeIter.hasNext()) {
|
||||
INode node = nodeIter.next();
|
||||
if (node != null) {
|
||||
changeParamValueOfNode(node, oldId, newId);
|
||||
for (Map.Entry<String, String> entry : old2NewMap.entrySet()) {
|
||||
changeParamValueOfNode(node, entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
modified = true;
|
||||
@@ -337,7 +396,7 @@ public class ChangeIdManager {
|
||||
|
||||
if (modified) {
|
||||
if (process instanceof IProcess2) {
|
||||
ProcessType processType = ((IProcess2) process).saveXmlFile();
|
||||
processType = ((IProcess2) process).saveXmlFile();
|
||||
if (item instanceof ProcessItem) {
|
||||
((ProcessItem) item).setProcess(processType);
|
||||
} else if (item instanceof JobletProcessItem) {
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<xsd:element maxOccurs="1" minOccurs="0" name="DataModel" nillable="true" type="xsd:string"/>
|
||||
<xsd:element maxOccurs="1" minOccurs="1" name="Concept" nillable="false" type="xsd:string"/>
|
||||
<xsd:element maxOccurs="1" minOccurs="1" name="Key" nillable="false" type="xsd:string"/>
|
||||
<xsd:element maxOccurs="1" minOccurs="0" name="PrimaryKeyInfo" nillable="true" type="xsd:string"/>
|
||||
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Item" nillable="false">
|
||||
<xsd:complexType mixed="false">
|
||||
<xsd:sequence maxOccurs="1" minOccurs="1">
|
||||
|
||||
@@ -210,20 +210,23 @@ public class RetrieveMDMSchemaAction extends AbstractCreateAction {
|
||||
wizardDialog.setBlockOnOpen(true);
|
||||
wizardDialog.setPageSize(WIZARD_WIDTH, WIZARD_HEIGHT);
|
||||
wizardDialog.create();
|
||||
if (wizardDialog.open() == wizardDialog.OK) {
|
||||
IRepositoryView viewPart = getViewPart();
|
||||
if (viewPart != null) {
|
||||
viewPart.expand(node, true);
|
||||
}
|
||||
refresh(node);
|
||||
} else {
|
||||
IRepositoryView viewPart = getViewPart();
|
||||
if (viewPart != null) {
|
||||
RepositoryNode rootNode = ProjectRepositoryNode.getInstance().getRootRepositoryNode(node, false);
|
||||
if (rootNode != null) {
|
||||
rootNode.getChildren().clear();
|
||||
rootNode.setInitialized(false);
|
||||
viewPart.refresh(rootNode);
|
||||
int returnCode = wizardDialog.open();
|
||||
if (!forceReadOnly) {
|
||||
if (returnCode == wizardDialog.OK) {
|
||||
IRepositoryView viewPart = getViewPart();
|
||||
if (viewPart != null) {
|
||||
viewPart.expand(node, true);
|
||||
}
|
||||
refresh(node);
|
||||
} else {
|
||||
IRepositoryView viewPart = getViewPart();
|
||||
if (viewPart != null) {
|
||||
RepositoryNode rootNode = ProjectRepositoryNode.getInstance().getRootRepositoryNode(node, false);
|
||||
if (rootNode != null) {
|
||||
rootNode.getChildren().clear();
|
||||
rootNode.setInitialized(false);
|
||||
viewPart.refresh(rootNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.wizard.IWizardPage;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
@@ -231,35 +230,29 @@ public class CreateConceptWizard extends RepositoryWizard implements INewWizard
|
||||
*/
|
||||
@Override
|
||||
public boolean performFinish() {
|
||||
boolean success = false;
|
||||
boolean success = readonly;
|
||||
|
||||
if (creation && schemaPage.isPageComplete()) {
|
||||
// RepositoryUpdateManager.updateMultiSchema(connectionItem, oldMetadataTable, oldTableMap);
|
||||
schemaPage.createMetadataTable();
|
||||
updateRelation();
|
||||
success = true;
|
||||
} else if (!creation && tablePage.isPageComplete()) {
|
||||
// applyCopy();
|
||||
EObject eObject = metadataTable.eContainer();
|
||||
RepositoryUpdateManager.updateMultiSchema(connectionItem, oldMetadataTable, oldTableMap);
|
||||
updateRelation();
|
||||
success = true;
|
||||
}
|
||||
if (!readonly) {
|
||||
if (creation && schemaPage.isPageComplete()) {
|
||||
schemaPage.createMetadataTable();
|
||||
updateRelation();
|
||||
success = true;
|
||||
} else if (!creation && tablePage.isPageComplete()) {
|
||||
RepositoryUpdateManager.updateMultiSchema(connectionItem, oldMetadataTable, oldTableMap);
|
||||
updateRelation();
|
||||
success = true;
|
||||
}
|
||||
|
||||
IPath sasPath = new Path(System.getProperty("user.dir")).append("temp");//$NON-NLS-1$ //$NON-NLS-2$
|
||||
File sasDir = sasPath.toFile();
|
||||
if (sasDir.exists()) {
|
||||
delete(sasDir);
|
||||
IPath sasPath = new Path(System.getProperty("user.dir")).append("temp");//$NON-NLS-1$ //$NON-NLS-2$
|
||||
File sasDir = sasPath.toFile();
|
||||
if (sasDir.exists()) {
|
||||
delete(sasDir);
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
// protected void applyCopy() {
|
||||
// metadataTable = metadataTableCopy;
|
||||
// connectionItem.setConnection(connectionCopy);
|
||||
// }
|
||||
|
||||
private void updateRelation() {
|
||||
saveMetaData();
|
||||
closeLockStrategy();
|
||||
|
||||
@@ -157,6 +157,14 @@ public class MDMOutputSchemaForm extends AbstractMDMFileStepForm {
|
||||
*/
|
||||
private MetadataTable tempMetadataTable;
|
||||
|
||||
private AddTreeNodeButton addTreeNodeBtn;
|
||||
|
||||
private RemoveTreeNodeButton removeNodeBtn;
|
||||
|
||||
private MoveUpTreeNodeButton moveUpBtn;
|
||||
|
||||
private MoveDownTreeNodeButton moveDown;
|
||||
|
||||
public MDMOutputSchemaForm(Composite parent, ConnectionItem connectionItem, MetadataTable metadataTable, Concept concept,
|
||||
WizardPage wizardPage, boolean creation) {
|
||||
super(parent, connectionItem);
|
||||
@@ -169,7 +177,13 @@ public class MDMOutputSchemaForm extends AbstractMDMFileStepForm {
|
||||
|
||||
@Override
|
||||
protected void adaptFormToReadOnly() {
|
||||
|
||||
boolean enabled = !isReadOnly();
|
||||
schemaButton.setEnabled(enabled);
|
||||
addTreeNodeBtn.removeTreeListeners();
|
||||
removeNodeBtn.removeTreeListeners();
|
||||
moveUpBtn.removeTreeListeners();
|
||||
moveDown.removeTreeListeners();
|
||||
linker.setReadOnly(isReadOnly());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -399,17 +413,16 @@ public class MDMOutputSchemaForm extends AbstractMDMFileStepForm {
|
||||
}
|
||||
|
||||
private void initToolBar(Composite parent) {
|
||||
// tool buttons
|
||||
Composite toolBarComp = new Composite(parent, SWT.NONE);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 4;
|
||||
GridData data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
toolBarComp.setLayout(layout);
|
||||
toolBarComp.setLayoutData(data);
|
||||
AddTreeNodeButton addTreeNodeBtn = new AddTreeNodeButton(toolBarComp, this);
|
||||
RemoveTreeNodeButton removeNodeBtn = new RemoveTreeNodeButton(toolBarComp, this);
|
||||
MoveUpTreeNodeButton moveUpBtn = new MoveUpTreeNodeButton(toolBarComp, this);
|
||||
MoveDownTreeNodeButton moveDown = new MoveDownTreeNodeButton(toolBarComp, this);
|
||||
addTreeNodeBtn = new AddTreeNodeButton(toolBarComp, this);
|
||||
removeNodeBtn = new RemoveTreeNodeButton(toolBarComp, this);
|
||||
moveUpBtn = new MoveUpTreeNodeButton(toolBarComp, this);
|
||||
moveDown = new MoveDownTreeNodeButton(toolBarComp, this);
|
||||
}
|
||||
|
||||
private void createAction() {
|
||||
|
||||
@@ -154,6 +154,12 @@ public class MDMXSDFileForm extends AbstractMDMFileStepForm {
|
||||
setupForm();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adaptFormToReadOnly() {
|
||||
loopTableEditorView.setReadOnly(isReadOnly());
|
||||
fieldsTableEditorView.setReadOnly(isReadOnly());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Initialize value, forceFocus first field.
|
||||
|
||||
@@ -83,6 +83,11 @@ public class MdmConceptWizardPage2 extends AbstractRetrieveConceptPage {
|
||||
return form.getSelectedEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPageComplete() {
|
||||
return super.isPageComplete() || !isRepositoryObjectEditable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
super.setVisible(visible);
|
||||
|
||||
@@ -144,6 +144,11 @@ public class MdmConceptWizardPage3 extends AbstractRetrieveConceptPage {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPageComplete() {
|
||||
return super.isPageComplete() || !isRepositoryObjectEditable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWizardPage getNextPage() {
|
||||
if (!creation) {
|
||||
|
||||
@@ -39,6 +39,8 @@ import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.VerifyEvent;
|
||||
import org.eclipse.swt.events.VerifyListener;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
@@ -156,6 +158,21 @@ public class MdmReceiveForm extends AbstractMDMFileStepForm {
|
||||
setupForm();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adaptFormToReadOnly() {
|
||||
prefixCombo.addVerifyListener(new VerifyListener() {
|
||||
|
||||
@Override
|
||||
public void verifyText(VerifyEvent e) {
|
||||
e.doit = false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
loopTableEditorView.setReadOnly(isReadOnly());
|
||||
fieldsTableEditorView.setReadOnly(isReadOnly());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Initialize value, forceFocus first field.
|
||||
|
||||
@@ -161,6 +161,11 @@ public class MDMOutputDragAndDropHandler {
|
||||
|
||||
public void dragOver(DropTargetEvent event) {
|
||||
Item targetItem = (Item) event.item;
|
||||
if (linker.isReadOnly()) {
|
||||
event.detail = DND.DROP_NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetItem == null) {
|
||||
event.detail = DND.DROP_NONE;
|
||||
return;
|
||||
|
||||
@@ -72,6 +72,8 @@ public class MDMSchema2TreeLinker extends TableToTreeLinker<Object, Object> {
|
||||
|
||||
private Comparator<LinkDescriptor<Item, Object, Tree, Object>> drawingLinksComparator;
|
||||
|
||||
private boolean readOnly = false;
|
||||
|
||||
public MDMSchema2TreeLinker(Composite commonParent) {
|
||||
super(commonParent);
|
||||
}
|
||||
@@ -398,4 +400,12 @@ public class MDMSchema2TreeLinker extends TableToTreeLinker<Object, Object> {
|
||||
}
|
||||
return this.drawingLinksComparator;
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
this.readOnly = readOnly;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return readOnly;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
// ============================================================================
|
||||
package org.talend.repository.ui.wizards.metadata.connection.files.json;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.talend.core.model.utils.RepositoryManagerHelper;
|
||||
import org.talend.datatools.xml.utils.ATreeNode;
|
||||
@@ -27,6 +31,8 @@ public abstract class AbstractTreePopulator {
|
||||
protected String filePath;
|
||||
|
||||
protected static int limit;
|
||||
|
||||
protected TreeViewer treeViewer;
|
||||
|
||||
abstract public boolean populateTree(String filePath, ATreeNode treeNode);
|
||||
|
||||
@@ -80,5 +86,44 @@ public abstract class AbstractTreePopulator {
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public List<ATreeNode> getAllNodes() {
|
||||
List<ATreeNode> nodes = new ArrayList<ATreeNode>();
|
||||
Object input = treeViewer.getInput();
|
||||
if(input instanceof List) {
|
||||
for(Object obj : (List)input) {
|
||||
if(obj instanceof ATreeNode) {
|
||||
addNode(((ATreeNode)obj), nodes);
|
||||
}
|
||||
}
|
||||
}else if(input instanceof Object[]) {
|
||||
for(Object obj : (Object[])input) {
|
||||
if(obj instanceof ATreeNode) {
|
||||
addNode(((ATreeNode)obj), nodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
private void addNode(ATreeNode node, List<ATreeNode> nodes){
|
||||
nodes.add(node);
|
||||
if(node.getChildren() != null && node.getChildren().length > 0) {
|
||||
nodes.addAll(getChildren(node));
|
||||
}
|
||||
}
|
||||
|
||||
private List<ATreeNode> getChildren(ATreeNode node){
|
||||
List<ATreeNode> nodes = new ArrayList<ATreeNode>();
|
||||
for(Object obj : node.getChildren()) {
|
||||
if(obj instanceof ATreeNode){
|
||||
nodes.add((ATreeNode)obj);
|
||||
if(((ATreeNode)obj).getChildren() != null && ((ATreeNode)obj).getChildren().length > 0) {
|
||||
nodes.addAll(getChildren((ATreeNode)obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ import org.talend.datatools.xml.utils.ATreeNode;
|
||||
*/
|
||||
public class JsonTreePopulator extends AbstractTreePopulator {
|
||||
|
||||
private TreeViewer treeViewer;
|
||||
|
||||
private String jsonValue;
|
||||
|
||||
public JsonTreePopulator(TreeViewer treeViewer) {
|
||||
@@ -175,11 +173,16 @@ public class JsonTreePopulator extends AbstractTreePopulator {
|
||||
}
|
||||
|
||||
private TreeItem getTreeItem(TreeItem[] treeItems, String absolutePath) {
|
||||
TreeItem item = null;
|
||||
if (treeItems == null || treeItems.length == 0) {
|
||||
return null;
|
||||
}
|
||||
for (TreeItem treeItem : treeItems) {
|
||||
item = treeItem;
|
||||
Object obj = treeItem.getData();
|
||||
if (obj == null) {
|
||||
return treeItem;
|
||||
}
|
||||
if (obj instanceof JsonTreeNode) {
|
||||
String jsonPath = SchemaPopulationUtil.getFilteredJsonPath(((JsonTreeNode) obj).getJsonPath());
|
||||
if (absolutePath.equals(jsonPath)) {
|
||||
@@ -191,7 +194,7 @@ public class JsonTreePopulator extends AbstractTreePopulator {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,8 +47,6 @@ import org.talend.repository.ui.wizards.metadata.connection.files.json.AbstractT
|
||||
*/
|
||||
public class TreePopulator extends AbstractTreePopulator {
|
||||
|
||||
private final TreeViewer availableXmlTree;
|
||||
|
||||
private final BidiMap xPathToTreeItem = new DualHashBidiMap();
|
||||
|
||||
/**
|
||||
@@ -61,10 +59,10 @@ public class TreePopulator extends AbstractTreePopulator {
|
||||
public TreePopulator(Tree tree) {
|
||||
super();
|
||||
// no virtual mode on this case.
|
||||
availableXmlTree = new TreeViewer(tree);
|
||||
availableXmlTree.setContentProvider(new ATreeNodeContentProvider());
|
||||
availableXmlTree.setLabelProvider(new VirtualXmlTreeLabelProvider());
|
||||
availableXmlTree.setUseHashlookup(true);
|
||||
treeViewer = new TreeViewer(tree);
|
||||
treeViewer.setContentProvider(new ATreeNodeContentProvider());
|
||||
treeViewer.setLabelProvider(new VirtualXmlTreeLabelProvider());
|
||||
treeViewer.setUseHashlookup(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +72,7 @@ public class TreePopulator extends AbstractTreePopulator {
|
||||
*/
|
||||
public TreePopulator(TreeViewer availableXmlTree) {
|
||||
super();
|
||||
this.availableXmlTree = availableXmlTree;
|
||||
this.treeViewer = availableXmlTree;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,11 +158,11 @@ public class TreePopulator extends AbstractTreePopulator {
|
||||
if (selected == null && childs.length > 0) {
|
||||
selected = childs[0];
|
||||
}
|
||||
availableXmlTree.setInput(new Object[] { selected });
|
||||
availableXmlTree.expandToLevel(3);
|
||||
treeViewer.setInput(new Object[] { selected });
|
||||
treeViewer.expandToLevel(3);
|
||||
} else {
|
||||
availableXmlTree.setInput(childs);
|
||||
availableXmlTree.expandToLevel(3);
|
||||
treeViewer.setInput(childs);
|
||||
treeViewer.expandToLevel(3);
|
||||
}
|
||||
this.filePath = filePath;
|
||||
return true;
|
||||
@@ -200,8 +198,8 @@ public class TreePopulator extends AbstractTreePopulator {
|
||||
return false;
|
||||
} else {
|
||||
Object[] childs = treeNode.getChildren();
|
||||
availableXmlTree.setInput(childs);
|
||||
availableXmlTree.expandToLevel(3);
|
||||
treeViewer.setInput(childs);
|
||||
treeViewer.expandToLevel(3);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -238,8 +236,8 @@ public class TreePopulator extends AbstractTreePopulator {
|
||||
if (treeNode == null || treeNode.getChildren().length == 0) {
|
||||
return false;
|
||||
} else {
|
||||
availableXmlTree.setInput(new Object[] { treeNode });
|
||||
availableXmlTree.expandToLevel(3);
|
||||
treeViewer.setInput(new Object[] { treeNode });
|
||||
treeViewer.expandToLevel(3);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -248,7 +246,7 @@ public class TreePopulator extends AbstractTreePopulator {
|
||||
|
||||
@Override
|
||||
public TreeItem getTreeItem(String absoluteXPath) {
|
||||
TreeItem[] items = availableXmlTree.getTree().getItems();
|
||||
TreeItem[] items = treeViewer.getTree().getItems();
|
||||
String path = absoluteXPath;
|
||||
String targetName = absoluteXPath;
|
||||
if (targetName.contains(UtilConstants.XPATH_SLASH)) {
|
||||
@@ -310,10 +308,11 @@ public class TreePopulator extends AbstractTreePopulator {
|
||||
|
||||
@Override
|
||||
public void configureDefaultTreeViewer() {
|
||||
if (availableXmlTree.getContentProvider() != null) {
|
||||
availableXmlTree.setInput(null);
|
||||
if (treeViewer.getContentProvider() != null) {
|
||||
treeViewer.setInput(null);
|
||||
}
|
||||
availableXmlTree.setContentProvider(new ATreeNodeContentProvider());
|
||||
availableXmlTree.setLabelProvider(new VirtualXmlTreeLabelProvider());
|
||||
treeViewer.setContentProvider(new ATreeNodeContentProvider());
|
||||
treeViewer.setLabelProvider(new VirtualXmlTreeLabelProvider());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,6 +72,12 @@ public abstract class AbstractTreeNodeButton implements ISelectionChangedListene
|
||||
}
|
||||
}
|
||||
|
||||
public void removeTreeListeners() {
|
||||
if (treeViewer != null && !treeViewer.getTree().isDisposed()) {
|
||||
treeViewer.removeSelectionChangedListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Button getButton() {
|
||||
return this.button;
|
||||
}
|
||||
|
||||
@@ -268,6 +268,7 @@ public class XmlToXPathLinker extends TreeToTablesLinker<Object, Object> {
|
||||
originalValue = TalendQuoteUtils.removeQuotes(originalValue);
|
||||
}
|
||||
if (originalValue != null) {
|
||||
loadItemDataForLazyLoad(loopTableEditorView);
|
||||
createLoopLinks(originalValue, tableItem, monitorWrap);
|
||||
}
|
||||
|
||||
@@ -307,7 +308,7 @@ public class XmlToXPathLinker extends TreeToTablesLinker<Object, Object> {
|
||||
List<SchemaTarget> schemaTargetList, int startTableItem, int tableItemLength) {
|
||||
monitorWrap.beginTask(Messages.getString("XmlToXPathLinker.beginTask.fieldLinksCreation"), totalWork); //$NON-NLS-1$
|
||||
|
||||
loadItemDataForLazyLoad();
|
||||
loadItemDataForLazyLoad(fieldsTableEditorView);
|
||||
TableItem[] fieldsTableItems = fieldsTableEditorView.getTable().getItems();
|
||||
for (int i = startTableItem, indexShemaTarget = 0; i < startTableItem + tableItemLength; i++, indexShemaTarget++) {
|
||||
|
||||
@@ -327,25 +328,11 @@ public class XmlToXPathLinker extends TreeToTablesLinker<Object, Object> {
|
||||
createFieldLinks(relativeXpathQuery, tableItem, monitorWrap, schemaTarget);
|
||||
monitorWrap.worked(1);
|
||||
}
|
||||
fieldsTableEditorView.getTableViewerCreator().getTableViewer().refresh();
|
||||
getLinksManager().sortLinks(getDrawingLinksComparator());
|
||||
getBackgroundRefresher().refreshBackground();
|
||||
}
|
||||
|
||||
private void loadItemDataForLazyLoad() {
|
||||
if (!fieldsTableEditorView.getTableViewerCreator().isLazyLoad()) {
|
||||
return;
|
||||
}
|
||||
List<SchemaTarget> beansList = fieldsTableEditorView.getExtendedTableModel().getBeansList();
|
||||
Table table = fieldsTableEditorView.getTable();
|
||||
for (TableItem tableItem : table.getItems()) {
|
||||
if (tableItem.getData() == null) {
|
||||
int index = table.indexOf(tableItem);
|
||||
SchemaTarget schemaTarget = beansList.get(index);
|
||||
tableItem.setData(schemaTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC amaumont Comment method "initListeners".
|
||||
*/
|
||||
|
||||
@@ -182,4 +182,12 @@ FeaturesManager.Type.p2.studioPatch=Studio Patch
|
||||
FeaturesManager.Type.plainZip=Plain ZIP
|
||||
FeaturesManager.Category.all=All Categories
|
||||
|
||||
P2UpdateManager.update.product=Updating talend product...
|
||||
P2UpdateManager.p2.uri.null=P2 repository URI is null.
|
||||
P2UpdateManager.p2.feature.null=Feature list is empty.
|
||||
P2UpdateManager.no.iu.available=Could not find any available IU in current profile.
|
||||
P2UpdateManager.user.cancel=User canceled the upgrade of product.
|
||||
P2UpdateManager.update.error=error updating product : {0}
|
||||
P2UpdateManager.update.sucess=Update talend product successfully.
|
||||
|
||||
UIUtils.exception.interrupt=User cancelled.
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 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.updates.runtime;
|
||||
|
||||
public interface P2UpdateConstants {
|
||||
|
||||
public static final String STUDIO_CORE_FEATURE_ID = "org.talend.tup.feature.feature.group"; //$NON-NLS-1$
|
||||
|
||||
public static final String KEY_UPDATESITE_PATH = "updatesite.path"; //$NON-NLS-1$
|
||||
|
||||
public static final String KEY_FEATURES_TO_INSTALL = "features.to.install"; //$NON-NLS-1$
|
||||
|
||||
public static final String KEY_FEATURES_TO_UPDATE = "features.to.update"; //$NON-NLS-1$
|
||||
|
||||
}
|
||||
@@ -12,6 +12,8 @@
|
||||
// ============================================================================
|
||||
package org.talend.updates.runtime;
|
||||
|
||||
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
|
||||
import org.eclipse.equinox.p2.core.IProvisioningAgent;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
@@ -25,10 +27,14 @@ public class UpdatesRuntimePlugin extends AbstractUIPlugin {
|
||||
|
||||
private static UpdatesRuntimePlugin plugin;
|
||||
|
||||
private IProvisioningAgent agent;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
agent = ServiceHelper.getService(context, IProvisioningAgent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,4 +46,9 @@ public class UpdatesRuntimePlugin extends AbstractUIPlugin {
|
||||
public static UpdatesRuntimePlugin getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public IProvisioningAgent getProvisioningAgent() {
|
||||
return agent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.eclipse.equinox.p2.engine.IProfile;
|
||||
import org.eclipse.equinox.p2.engine.IProfileRegistry;
|
||||
import org.eclipse.equinox.p2.engine.PhaseSetFactory;
|
||||
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
|
||||
import org.eclipse.equinox.p2.metadata.Version;
|
||||
import org.eclipse.equinox.p2.operations.InstallOperation;
|
||||
import org.eclipse.equinox.p2.operations.ProfileModificationJob;
|
||||
import org.eclipse.equinox.p2.operations.ProvisioningSession;
|
||||
@@ -175,7 +176,20 @@ public class P2Installer {
|
||||
// show the installation unit
|
||||
log.debug("ius to be installed:" + toInstall);
|
||||
if (!toInstall.isEmpty()) {
|
||||
newProductVersion = toInstall.iterator().next().getVersion().toString();
|
||||
Version toInstallLatestVersion = null;
|
||||
for (IInstallableUnit install : toInstall) {
|
||||
Version installedVersion = install.getVersion();
|
||||
if (installedVersion != null) {
|
||||
if (toInstallLatestVersion == null) {
|
||||
toInstallLatestVersion = installedVersion;
|
||||
} else {
|
||||
if (toInstallLatestVersion.compareTo(installedVersion) < 0) {
|
||||
toInstallLatestVersion = installedVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newProductVersion = toInstallLatestVersion.toString();
|
||||
}
|
||||
|
||||
setIuSingletonToFalse(toInstall);
|
||||
|
||||
@@ -32,13 +32,11 @@ import org.eclipse.equinox.p2.query.QueryUtil;
|
||||
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
|
||||
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
|
||||
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.runtime.update.PreferenceKeys;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.commons.utils.io.FilesUtils;
|
||||
import org.talend.updates.runtime.i18n.Messages;
|
||||
@@ -60,8 +58,6 @@ public class P2Manager {
|
||||
|
||||
private final Object p2ProfileLock = new Object();
|
||||
|
||||
private final Object clearOsgiLock = new Object();
|
||||
|
||||
private P2Manager() {
|
||||
reset();
|
||||
}
|
||||
@@ -243,9 +239,4 @@ public class P2Manager {
|
||||
}
|
||||
}
|
||||
|
||||
public void clearOsgiCache() {
|
||||
synchronized (clearOsgiLock) {
|
||||
PlatformUI.getPreferenceStore().setValue(PreferenceKeys.NEED_OSGI_CLEAN, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 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.updates.runtime.engine;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.equinox.p2.core.IProvisioningAgent;
|
||||
import org.eclipse.equinox.p2.core.ProvisionException;
|
||||
import org.eclipse.equinox.p2.engine.IPhaseSet;
|
||||
import org.eclipse.equinox.p2.engine.IProfile;
|
||||
import org.eclipse.equinox.p2.engine.IProfileRegistry;
|
||||
import org.eclipse.equinox.p2.engine.PhaseSetFactory;
|
||||
import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery;
|
||||
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
|
||||
import org.eclipse.equinox.p2.operations.InstallOperation;
|
||||
import org.eclipse.equinox.p2.operations.ProfileModificationJob;
|
||||
import org.eclipse.equinox.p2.operations.ProvisioningSession;
|
||||
import org.eclipse.equinox.p2.operations.UpdateOperation;
|
||||
import org.eclipse.equinox.p2.query.QueryUtil;
|
||||
import org.eclipse.equinox.p2.repository.IRepositoryManager;
|
||||
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
|
||||
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.updates.runtime.P2UpdateConstants;
|
||||
import org.talend.updates.runtime.UpdatesRuntimePlugin;
|
||||
import org.talend.updates.runtime.i18n.Messages;
|
||||
import org.talend.updates.runtime.model.ExtraFeatureException;
|
||||
import org.talend.updates.runtime.model.P2ExtraFeatureException;
|
||||
import org.talend.updates.runtime.utils.P2UpdateHelper;
|
||||
|
||||
public class P2UpdateManager {
|
||||
|
||||
private Logger logger = Logger.getLogger(P2UpdateManager.class);
|
||||
|
||||
private static P2UpdateManager instance;
|
||||
|
||||
private IProvisioningAgent agent;
|
||||
|
||||
private ProvisioningSession session;
|
||||
|
||||
private IPhaseSet talendPhaseSet;
|
||||
|
||||
private P2UpdateManager() {
|
||||
agent = UpdatesRuntimePlugin.getDefault().getProvisioningAgent();
|
||||
agent.registerService(IProvisioningAgent.INSTALLER_AGENT, agent);
|
||||
// DirectorApplication.PROP_P2_PROFILE
|
||||
agent.registerService("eclipse.p2.profile", IProfileRegistry.SELF);//$NON-NLS-1$
|
||||
talendPhaseSet = PhaseSetFactory.createDefaultPhaseSetExcluding(new String[] { PhaseSetFactory.PHASE_CHECK_TRUST });
|
||||
}
|
||||
|
||||
public static P2UpdateManager getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (P2UpdateManager.class) {
|
||||
if (instance == null) {
|
||||
instance = new P2UpdateManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public IStatus execute(final IProgressMonitor monitor) throws ExtraFeatureException { // check p2 repository url
|
||||
if (P2UpdateHelper.getP2RepositoryURI() == null) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.p2.uri.null"); //$NON-NLS-1$
|
||||
}
|
||||
// check features to install/update or TODO filter available features in license
|
||||
List<String> featuresToInstall = P2UpdateHelper.getConfigFeatures(P2UpdateConstants.KEY_FEATURES_TO_INSTALL);
|
||||
List<String> featuresToUpdate = P2UpdateHelper.getConfigFeatures(P2UpdateConstants.KEY_FEATURES_TO_UPDATE);
|
||||
if (featuresToInstall.isEmpty() && featuresToUpdate.isEmpty()) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.p2.feature.null"); //$NON-NLS-1$
|
||||
}
|
||||
IStatus result = null;
|
||||
File configIniBackupFile = null;
|
||||
try {
|
||||
// backup the config.ini
|
||||
configIniBackupFile = P2UpdateHelper.backupConfigFile();
|
||||
if (!featuresToInstall.isEmpty()) {
|
||||
result = doInstall(monitor, featuresToInstall);
|
||||
return result;
|
||||
}
|
||||
result = doUpdate(monitor, featuresToUpdate);
|
||||
} catch (IOException e) {
|
||||
throw new ExtraFeatureException(
|
||||
new ProvisionException(Messages.createErrorStatus(e, "ExtraFeaturesFactory.restore.config.error"))); //$NON-NLS-1$
|
||||
} finally {
|
||||
boolean success = false;
|
||||
if (result != null) {
|
||||
switch (result.getSeverity()) {
|
||||
case IStatus.OK:
|
||||
case IStatus.INFO:
|
||||
case IStatus.WARNING:
|
||||
success = true;
|
||||
break;
|
||||
default:
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
P2UpdateHelper.clearOsgiCache();
|
||||
if (success) {
|
||||
// restore the config.ini
|
||||
if (configIniBackupFile != null) {
|
||||
try {
|
||||
P2UpdateHelper.restoreConfigFile(configIniBackupFile);
|
||||
} catch (IOException e) {
|
||||
throw new P2ExtraFeatureException(
|
||||
new ProvisionException(Messages.createErrorStatus(e, "ExtraFeaturesFactory.back.config.error"))); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
if (!featuresToInstall.isEmpty()) {
|
||||
P2UpdateHelper.clearConfigFeatures(P2UpdateConstants.KEY_FEATURES_TO_INSTALL);
|
||||
} else if (!featuresToUpdate.isEmpty()) {
|
||||
P2UpdateHelper.clearConfigFeatures(P2UpdateConstants.KEY_FEATURES_TO_UPDATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private IStatus doInstall(IProgressMonitor monitor, List<String> featuresToInstall) throws P2ExtraFeatureException {
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, 4);
|
||||
subMonitor.setTaskName(Messages.getString("P2UpdateManager.update.product")); //$NON-NLS-1$
|
||||
// reset isInstalled to make is compute the next time is it used
|
||||
List<URI> allRepoUris = new ArrayList<>();
|
||||
allRepoUris.add(P2UpdateHelper.getP2RepositoryURI());
|
||||
subMonitor.setTaskName(Messages.getString("ExtraFeature.searching.talend.features.label")); //$NON-NLS-1$
|
||||
Set<IInstallableUnit> availableIUs = queryFromP2Repository(subMonitor.newChild(1), allRepoUris);
|
||||
// show the installation unit
|
||||
List<IInstallableUnit> toInstall = availableIUs.stream().filter(iu -> featuresToInstall.contains(iu.getId()))
|
||||
.collect(Collectors.toList());
|
||||
logger.debug("IUs to install:" + toInstall); //$NON-NLS-1$
|
||||
if (toInstall.isEmpty()) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.no.iu.available");
|
||||
}
|
||||
if (subMonitor.isCanceled()) {
|
||||
return Messages.createCancelStatus("P2UpdateManager.user.cancel"); //$NON-NLS-1$
|
||||
}
|
||||
InstallOperation installOperation = new InstallOperation(getProvisioningSession(), toInstall);
|
||||
IStatus installResolvedStatus = installOperation.resolveModal(subMonitor.newChild(1));
|
||||
if (installResolvedStatus.getSeverity() == IStatus.ERROR) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.update.error", //$NON-NLS-1$
|
||||
installOperation.getResolutionDetails());
|
||||
}
|
||||
ProfileModificationJob provisioningJob = (ProfileModificationJob) installOperation
|
||||
.getProvisioningJob(subMonitor.newChild(1));
|
||||
if (subMonitor.isCanceled()) {
|
||||
return Messages.createCancelStatus("P2UpdateManager.user.cancel"); //$NON-NLS-1$
|
||||
}
|
||||
provisioningJob.setPhaseSet(talendPhaseSet);
|
||||
IStatus status = provisioningJob.run(subMonitor.newChild(1));
|
||||
logger.debug("installed features with status :" + status); //$NON-NLS-1$
|
||||
return Messages.createOkStatus("P2UpdateManager.update.sucess"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private IStatus doUpdate(IProgressMonitor monitor, List<String> featuresToUpdate) throws P2ExtraFeatureException {
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, 5);
|
||||
subMonitor.setTaskName(Messages.getString("P2UpdateManager.update.product")); //$NON-NLS-1$
|
||||
// reset isInstalled to make is compute the next time is it used
|
||||
IProfile p2Profile = getProfile(IProfileRegistry.SELF);
|
||||
List<URI> allRepoUris = new ArrayList<>();
|
||||
allRepoUris.add(P2UpdateHelper.getP2RepositoryURI());
|
||||
Set<IInstallableUnit> currentIUs = p2Profile.query(new UserVisibleRootQuery(), subMonitor.newChild(1))
|
||||
.toUnmodifiableSet();
|
||||
// show the installation unit
|
||||
List<IInstallableUnit> iusToUpdate = currentIUs.stream().filter(iu -> featuresToUpdate.contains(iu.getId()))
|
||||
.collect(Collectors.toList());
|
||||
logger.debug("IUs to update:" + iusToUpdate); //$NON-NLS-1$
|
||||
if (iusToUpdate.isEmpty()) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.no.iu.available"); //$NON-NLS-1$
|
||||
}
|
||||
// update
|
||||
UpdateOperation updateOperation = new UpdateOperation(getProvisioningSession(), iusToUpdate);
|
||||
updateOperation.getProvisioningContext().setArtifactRepositories(allRepoUris.toArray(new URI[allRepoUris.size()]));
|
||||
updateOperation.getProvisioningContext().setMetadataRepositories(allRepoUris.toArray(new URI[allRepoUris.size()]));
|
||||
updateOperation.setProfileId(IProfileRegistry.SELF);
|
||||
IStatus result = updateOperation.resolveModal(subMonitor.newChild(1));
|
||||
if (subMonitor.isCanceled()) {
|
||||
return Messages.createCancelStatus("P2UpdateManager.user.cancel"); //$NON-NLS-1$
|
||||
}
|
||||
if (result.getSeverity() == IStatus.ERROR) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.update.error", //$NON-NLS-1$
|
||||
updateOperation.getResolutionDetails());
|
||||
}
|
||||
ProfileModificationJob provisioningJob = (ProfileModificationJob) updateOperation
|
||||
.getProvisioningJob(subMonitor.newChild(1));
|
||||
if (subMonitor.isCanceled()) {
|
||||
return Messages.createCancelStatus("P2UpdateManager.user.cancel"); //$NON-NLS-1$
|
||||
}
|
||||
if (provisioningJob == null) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.update.error", //$NON-NLS-1$
|
||||
updateOperation.getResolutionDetails());
|
||||
}
|
||||
provisioningJob.setPhaseSet(talendPhaseSet);
|
||||
IStatus status = provisioningJob.run(subMonitor.newChild(1));
|
||||
if (subMonitor.isCanceled()) {
|
||||
return Messages.createCancelStatus("P2UpdateManager.user.cancel"); //$NON-NLS-1$
|
||||
}
|
||||
logger.debug("Updated product with status: " + status); //$NON-NLS-1$
|
||||
if (featuresToUpdate.contains(P2UpdateConstants.STUDIO_CORE_FEATURE_ID)) {
|
||||
// TODO change to the new studio.core feature.
|
||||
try {
|
||||
P2UpdateHelper.updateProductVersion(subMonitor.newChild(1), getProfile(IProfileRegistry.SELF));
|
||||
// remove .syncMarker to force to sync maven repository
|
||||
String filePath = System.getProperty("m2.syncmarker.path"); //$NON-NLS-1$
|
||||
if (filePath != null) {
|
||||
File markerFile = new File(filePath);
|
||||
if (markerFile.exists()) {
|
||||
markerFile.delete();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
return Messages.createOkStatus("P2UpdateManager.update.sucess"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public Set<IInstallableUnit> queryFromP2Repository(IProgressMonitor monitor, List<URI> allRepoUris) {
|
||||
// get the repository managers and add our repository
|
||||
IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) agent
|
||||
.getService(IMetadataRepositoryManager.SERVICE_NAME);
|
||||
IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent
|
||||
.getService(IArtifactRepositoryManager.SERVICE_NAME);
|
||||
// remove existing repositories
|
||||
for (URI existingRepUri : metadataManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)) {
|
||||
metadataManager.removeRepository(existingRepUri);
|
||||
}
|
||||
for (URI existingRepUri : artifactManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)) {
|
||||
metadataManager.removeRepository(existingRepUri);
|
||||
}
|
||||
for (URI repoUri : allRepoUris) {
|
||||
metadataManager.addRepository(repoUri);
|
||||
artifactManager.addRepository(repoUri);
|
||||
}
|
||||
return metadataManager.query(QueryUtil.createLatestQuery(QueryUtil.createIUGroupQuery()), monitor).toUnmodifiableSet();
|
||||
}
|
||||
|
||||
public ProvisioningSession getProvisioningSession() {
|
||||
if (session == null) {
|
||||
session = new ProvisioningSession(agent);
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
public IProfileRegistry getProfileRegistry() {
|
||||
return (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
|
||||
}
|
||||
|
||||
public IProfile getProfile(String profilId) {
|
||||
return getProfileRegistry().getProfile(profilId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,11 +32,13 @@ import org.eclipse.equinox.p2.core.IProvisioningAgent;
|
||||
import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
|
||||
import org.eclipse.equinox.p2.core.ProvisionException;
|
||||
import org.eclipse.equinox.p2.engine.IPhaseSet;
|
||||
import org.eclipse.equinox.p2.engine.IProfile;
|
||||
import org.eclipse.equinox.p2.engine.PhaseSetFactory;
|
||||
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
|
||||
import org.eclipse.equinox.p2.operations.InstallOperation;
|
||||
import org.eclipse.equinox.p2.operations.ProfileModificationJob;
|
||||
import org.eclipse.equinox.p2.operations.ProvisioningSession;
|
||||
import org.eclipse.equinox.p2.operations.UninstallOperation;
|
||||
import org.eclipse.equinox.p2.query.IQuery;
|
||||
import org.eclipse.equinox.p2.query.QueryUtil;
|
||||
import org.osgi.framework.Bundle;
|
||||
@@ -137,7 +139,8 @@ public class ComponentP2ExtraFeature extends P2ExtraFeature implements IP2Compon
|
||||
|
||||
IProvisioningAgent agent = null;
|
||||
try {
|
||||
agent = agentProvider.createAgent(getP2AgentUri());
|
||||
IProfile profile = getProfile(agentProvider, progress);
|
||||
agent = profile.getProvisioningAgent();
|
||||
|
||||
updateRoamingProp(agent, agentProvider);
|
||||
|
||||
@@ -153,27 +156,50 @@ public class ComponentP2ExtraFeature extends P2ExtraFeature implements IP2Compon
|
||||
getVersion(), Arrays.toString(allRepoUris.toArray(new URI[allRepoUris.size()])));
|
||||
}
|
||||
|
||||
IPhaseSet talendPhaseSet = PhaseSetFactory
|
||||
.createDefaultPhaseSetExcluding(new String[] { PhaseSetFactory.PHASE_CHECK_TRUST });
|
||||
// uninstall first
|
||||
Collection<IInstallableUnit> installedP2Feature = getInstalledP2Feature(profile, toInstall, subMonitor);
|
||||
ProvisioningSession session = new ProvisioningSession(agent);
|
||||
if (installedP2Feature != null && !installedP2Feature.isEmpty()) {
|
||||
UninstallOperation uninstallOperation = new UninstallOperation(session, installedP2Feature);
|
||||
uninstallOperation.setProfileId(getP2ProfileId());
|
||||
IStatus resolveModal = uninstallOperation.resolveModal(subMonitor);
|
||||
if (resolveModal.getSeverity() == IStatus.ERROR) {
|
||||
return Messages.createErrorStatus(null, "ComponentP2ExtraFeature.error.installing.new.components", //$NON-NLS-1$
|
||||
uninstallOperation.getResolutionDetails());
|
||||
}
|
||||
ProfileModificationJob provisioningJob = (ProfileModificationJob) uninstallOperation
|
||||
.getProvisioningJob(subMonitor.newChild(1));
|
||||
if (subMonitor.isCanceled()) {
|
||||
return Messages.createCancelStatus("ComponentP2ExtraFeature.user.cancel.installation.of.components", //$NON-NLS-1$
|
||||
getP2IuId(), getVersion());
|
||||
}
|
||||
if (provisioningJob == null) {
|
||||
return Messages.createErrorStatus(null, "ComponentP2ExtraFeature.error.installing.new.components", //$NON-NLS-1$
|
||||
getP2IuId(), getVersion(), uninstallOperation.getResolutionDetails());
|
||||
}
|
||||
provisioningJob.setPhaseSet(talendPhaseSet);
|
||||
provisioningJob.run(subMonitor.newChild(1));
|
||||
agent.stop();
|
||||
// update profile
|
||||
profile = getProfile(agentProvider, subMonitor);
|
||||
agent = profile.getProvisioningAgent();
|
||||
updateRoamingProp(agent, agentProvider);
|
||||
session = new ProvisioningSession(agent);
|
||||
}
|
||||
|
||||
// install
|
||||
InstallOperation installOperation = new InstallOperation(new ProvisioningSession(agent), toInstall);
|
||||
InstallOperation installOperation = new InstallOperation(session, toInstall);
|
||||
installOperation.setProfileId(getP2ProfileId());
|
||||
IStatus installResolvedStatus = installOperation.resolveModal(subMonitor.newChild(1));
|
||||
if (subMonitor.isCanceled()) {
|
||||
return Messages.createCancelStatus("ComponentP2ExtraFeature.user.cancel.installation.of.components", //$NON-NLS-1$
|
||||
getP2IuId(), getVersion());
|
||||
}
|
||||
if (installResolvedStatus.getSeverity() == IStatus.ERROR) {
|
||||
return Messages.createErrorStatus(null, "ComponentP2ExtraFeature.error.installing.new.components", getP2IuId(), //$NON-NLS-1$
|
||||
getVersion(), installOperation.getResolutionDetails());
|
||||
} // else perform the installlation
|
||||
IPhaseSet talendPhaseSet = PhaseSetFactory
|
||||
.createDefaultPhaseSetExcluding(new String[] { PhaseSetFactory.PHASE_CHECK_TRUST });
|
||||
|
||||
ProfileModificationJob provisioningJob = (ProfileModificationJob) installOperation.getProvisioningJob(subMonitor
|
||||
.newChild(1));
|
||||
if (subMonitor.isCanceled()) {
|
||||
return Messages.createCancelStatus("ComponentP2ExtraFeature.user.cancel.installation.of.components", //$NON-NLS-1$
|
||||
getP2IuId(), getVersion());
|
||||
}
|
||||
if (provisioningJob == null) {
|
||||
return Messages.createErrorStatus(null, "ComponentP2ExtraFeature.error.installing.new.components", //$NON-NLS-1$
|
||||
getP2IuId(), getVersion(), installOperation.getResolutionDetails());
|
||||
@@ -196,6 +222,9 @@ public class ComponentP2ExtraFeature extends P2ExtraFeature implements IP2Compon
|
||||
return Messages.createErrorStatus(e,
|
||||
"ComponentP2ExtraFeature.error.installing.components.uri.exception", getP2IuId(), //$NON-NLS-1$
|
||||
getVersion());
|
||||
} catch (Exception e) {
|
||||
return Messages.createErrorStatus(e, "ComponentP2ExtraFeature.error.installing.components.uri.exception", getP2IuId(), //$NON-NLS-1$
|
||||
getVersion());
|
||||
} finally {
|
||||
if (agent != null) {// agent creation did not fail
|
||||
removeAllRepositories(agent, allRepoUris);
|
||||
|
||||
@@ -90,6 +90,7 @@ public abstract class AbstractExtraFeature implements ExtraFeature {
|
||||
this.degradable = degradable;
|
||||
this.types = types;
|
||||
this.categories = categories;
|
||||
this.share = getRepositoryService().getProxyRepositoryFactory().isFullLogonFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,8 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
import org.talend.updates.runtime.feature.model.Category;
|
||||
import org.talend.updates.runtime.feature.model.Type;
|
||||
import org.talend.updates.runtime.model.InstallationStatus.Status;
|
||||
@@ -242,4 +244,7 @@ public interface ExtraFeature extends Comparable<Object> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
default IRepositoryService getRepositoryService() {
|
||||
return (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
package org.talend.updates.runtime.model;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -24,6 +23,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -61,9 +61,6 @@ import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.runtime.utils.io.IOUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.services.ICoreTisService;
|
||||
import org.talend.updates.runtime.engine.P2Manager;
|
||||
import org.talend.updates.runtime.feature.model.Category;
|
||||
import org.talend.updates.runtime.feature.model.Type;
|
||||
@@ -76,6 +73,7 @@ import org.talend.updates.runtime.service.ITaCoKitUpdateService;
|
||||
import org.talend.updates.runtime.service.ITaCoKitUpdateService.ICarInstallationResult;
|
||||
import org.talend.updates.runtime.storage.AbstractFeatureStorage;
|
||||
import org.talend.updates.runtime.storage.IFeatureStorage;
|
||||
import org.talend.updates.runtime.utils.P2UpdateHelper;
|
||||
import org.talend.updates.runtime.utils.PathUtils;
|
||||
import org.talend.updates.runtime.utils.TaCoKitCarUtils;
|
||||
import org.talend.utils.files.FileUtils;
|
||||
@@ -161,28 +159,8 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
|
||||
try {
|
||||
|
||||
IQuery<IInstallableUnit> iuQuery = QueryUtil.createIUQuery(p2IuId2);
|
||||
boolean interrupted = false;
|
||||
IProfile profile = null;
|
||||
// there seems to be a bug because if the agent is created too quickly then the profile is empty.
|
||||
// so we loop until we get a proper profile
|
||||
final String p2ProfileId = getP2ProfileId();
|
||||
do {
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
interrupted = true;
|
||||
}
|
||||
if (agent != null) {
|
||||
agent.stop();
|
||||
}
|
||||
agent = agentProvider.createAgent(getP2AgentUri());
|
||||
IProfileRegistry profRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
|
||||
profile = profRegistry.getProfile(p2ProfileId);
|
||||
} while (profile != null && profile.getTimestamp() == 0 && !interrupted && !subMonitor.isCanceled());
|
||||
|
||||
if (profile == null || subMonitor.isCanceled()) {
|
||||
throw new ProvisionException("Could not find the p2 profile named " + p2ProfileId); //$NON-NLS-1$
|
||||
}
|
||||
IProfile profile = getProfile(agentProvider, subMonitor);
|
||||
agent = profile.getProvisioningAgent();
|
||||
subMonitor.worked(1);
|
||||
IQueryResult<IInstallableUnit> iuQueryResult = profile.available(iuQuery, subMonitor.newChild(1));
|
||||
if (subMonitor.isCanceled()) {
|
||||
@@ -196,6 +174,33 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
|
||||
}
|
||||
}
|
||||
|
||||
protected IProfile getProfile(IProvisioningAgentProvider agentProvider, IProgressMonitor progress) throws ProvisionException {
|
||||
IProvisioningAgent agent = null;
|
||||
IProfile profile = null;
|
||||
boolean interrupted = false;
|
||||
// there seems to be a bug because if the agent is created too quickly then the profile is empty.
|
||||
// so we loop until we get a proper profile
|
||||
final String p2ProfileId = getP2ProfileId();
|
||||
do {
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
interrupted = true;
|
||||
}
|
||||
if (agent != null) {
|
||||
agent.stop();
|
||||
}
|
||||
agent = agentProvider.createAgent(getP2AgentUri());
|
||||
IProfileRegistry profRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
|
||||
profile = profRegistry.getProfile(p2ProfileId);
|
||||
} while (profile != null && profile.getTimestamp() == 0 && !interrupted && !progress.isCanceled());
|
||||
|
||||
if (profile == null || progress.isCanceled()) {
|
||||
throw new ProvisionException("Could not find the p2 profile named " + p2ProfileId); //$NON-NLS-1$
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* created for JUnit test so that profile Id can be changed by overriding
|
||||
*
|
||||
@@ -276,7 +281,7 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
|
||||
try {
|
||||
if (!isUseLegacyP2Install()) {
|
||||
// backup the config.ini
|
||||
configIniBackupFile = backupConfigFile();
|
||||
configIniBackupFile = P2UpdateHelper.backupConfigFile();
|
||||
} // else legacy p2 install will update the config.ini
|
||||
doInstallStatus = installP2(progress, allRepoUris);
|
||||
if (doInstallStatus == null || !doInstallStatus.isOK()) {
|
||||
@@ -326,9 +331,9 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
|
||||
}
|
||||
}
|
||||
// restore the config.ini
|
||||
if (configIniBackupFile != null) { // must existed backup file.
|
||||
if (isInstalled && configIniBackupFile != null) { // must existed backup file.
|
||||
try {
|
||||
restoreConfigFile(configIniBackupFile, isInstalled);
|
||||
P2UpdateHelper.restoreConfigFile(configIniBackupFile);
|
||||
} catch (IOException e) {
|
||||
throw new P2ExtraFeatureException(
|
||||
new ProvisionException(Messages.createErrorStatus(e, "ExtraFeaturesFactory.back.config.error"))); //$NON-NLS-1$
|
||||
@@ -351,7 +356,7 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
|
||||
}
|
||||
|
||||
protected void afterInstallP2(IProgressMonitor progress, Map<File, File> unzippedPatchMap) throws P2ExtraFeatureException {
|
||||
P2Manager.getInstance().clearOsgiCache();
|
||||
P2UpdateHelper.clearOsgiCache();
|
||||
}
|
||||
|
||||
protected void afterRestoreConfigFile(IProgressMonitor progress, Map<File, File> unzippedPatchMap)
|
||||
@@ -538,6 +543,7 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
|
||||
protected void updateRoamingProp(IProvisioningAgent agent, IProvisioningAgentProvider agentProvider)
|
||||
throws ProvisionException {
|
||||
agent.registerService(IProvisioningAgent.INSTALLER_AGENT, agentProvider.createAgent(null));
|
||||
// DirectorApplication.PROP_P2_PROFILE
|
||||
agent.registerService("eclipse.p2.profile", getP2ProfileId());//$NON-NLS-1$
|
||||
}
|
||||
|
||||
@@ -651,39 +657,6 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
|
||||
}
|
||||
}
|
||||
|
||||
protected File backupConfigFile() throws IOException {
|
||||
try {
|
||||
File configurationFile = PathUtils.getStudioConfigFile();
|
||||
File tempFile = File.createTempFile("config.ini", null); //$NON-NLS-1$
|
||||
FilesUtils.copyFile(new FileInputStream(configurationFile), tempFile);
|
||||
return tempFile;
|
||||
} catch (Exception e) {
|
||||
if (e instanceof IOException) {
|
||||
throw (IOException) e;
|
||||
}
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreConfigFile(File toResore, boolean isInstalled) throws IOException {
|
||||
try {
|
||||
File configurationFile = PathUtils.getStudioConfigFile();
|
||||
if (isInstalled && !IOUtils.contentEquals(new FileInputStream(configurationFile), new FileInputStream(toResore))) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
|
||||
ICoreTisService coreTisService = (ICoreTisService) GlobalServiceRegister.getDefault()
|
||||
.getService(ICoreTisService.class);
|
||||
coreTisService.updateConfiguratorBundles(configurationFile, toResore);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e);
|
||||
} finally {
|
||||
if (toResore != null && toResore.exists()) {
|
||||
toResore.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtraFeature getInstalledFeature(IProgressMonitor progress) throws ExtraFeatureException {
|
||||
ExtraFeature extraFeature = null;
|
||||
@@ -815,4 +788,14 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
|
||||
public boolean useP2Cache() {
|
||||
return this.useP2Cache;
|
||||
}
|
||||
|
||||
protected Collection<IInstallableUnit> getInstalledP2Feature(IProfile profile, Collection<IInstallableUnit> toInstalls,
|
||||
IProgressMonitor monitor) throws Exception {
|
||||
Collection<IQuery<IInstallableUnit>> queries = new LinkedList<>();
|
||||
for (IInstallableUnit toInst : toInstalls) {
|
||||
queries.add(QueryUtil.createIUQuery(toInst.getId()));
|
||||
}
|
||||
return profile.available(QueryUtil.createCompoundQuery(queries, false), monitor).toSet();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,14 +19,18 @@ import java.util.Set;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.service.IUpdateService;
|
||||
import org.talend.updates.runtime.engine.P2UpdateManager;
|
||||
import org.talend.updates.runtime.engine.component.InstallComponentMessages;
|
||||
import org.talend.updates.runtime.engine.factory.ComponentsNexusInstallFactory;
|
||||
import org.talend.updates.runtime.model.ExtraFeature;
|
||||
import org.talend.updates.runtime.model.ExtraFeatureException;
|
||||
import org.talend.updates.runtime.model.FeatureCategory;
|
||||
import org.talend.updates.runtime.nexus.component.NexusServerManager;
|
||||
|
||||
@@ -100,4 +104,30 @@ public class UpdateService implements IUpdateService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkStudioUpdate(IProgressMonitor monitor) {
|
||||
if (Platform.inDevelopmentMode()) {
|
||||
return false;
|
||||
}
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
try {
|
||||
IStatus status = P2UpdateManager.getInstance().execute(monitor);
|
||||
if (status != null) {
|
||||
switch (status.getSeverity()) {
|
||||
case IStatus.OK:
|
||||
case IStatus.INFO:
|
||||
case IStatus.WARNING:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (ExtraFeatureException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 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.updates.runtime.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.equinox.p2.engine.IProfile;
|
||||
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
|
||||
import org.eclipse.equinox.p2.query.QueryUtil;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.runtime.utils.io.IOUtils;
|
||||
import org.talend.commons.ui.runtime.update.PreferenceKeys;
|
||||
import org.talend.commons.utils.resource.UpdatesHelper;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
import org.talend.core.services.ICoreTisService;
|
||||
import org.talend.updates.runtime.P2UpdateConstants;
|
||||
import org.talend.utils.io.FilesUtils;
|
||||
|
||||
public class P2UpdateHelper {
|
||||
|
||||
private static Object clearOsgiLock = new Object();
|
||||
|
||||
public static File backupConfigFile() throws IOException {
|
||||
try {
|
||||
File configurationFile = PathUtils.getStudioConfigFile();
|
||||
File tempFile = File.createTempFile(UpdatesHelper.FILE_CONFIG_INI, null);
|
||||
FilesUtils.copyFile(new FileInputStream(configurationFile), tempFile);
|
||||
return tempFile;
|
||||
} catch (Exception e) {
|
||||
if (e instanceof IOException) {
|
||||
throw (IOException) e;
|
||||
}
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void restoreConfigFile(File toResore) throws IOException {
|
||||
try {
|
||||
File configurationFile = PathUtils.getStudioConfigFile();
|
||||
if (!IOUtils.contentEquals(new FileInputStream(configurationFile), new FileInputStream(toResore))) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
|
||||
ICoreTisService coreTisService = (ICoreTisService) GlobalServiceRegister.getDefault()
|
||||
.getService(ICoreTisService.class);
|
||||
coreTisService.updateConfiguratorBundles(configurationFile, toResore);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e);
|
||||
} finally {
|
||||
if (toResore != null && toResore.exists()) {
|
||||
toResore.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static URI getP2RepositoryURI() {
|
||||
String updatesite = null;
|
||||
try (InputStream fis = new FileInputStream(PathUtils.getStudioConfigFile())) {
|
||||
Properties properties = new Properties();
|
||||
properties.load(fis);
|
||||
updatesite = properties.getProperty(P2UpdateConstants.KEY_UPDATESITE_PATH);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
if (updatesite == null) {
|
||||
return null;
|
||||
}
|
||||
File file = new File(updatesite);
|
||||
if (file.isFile() || file.isDirectory()) {
|
||||
return file.toURI();
|
||||
}
|
||||
return URI.create(updatesite);
|
||||
}
|
||||
|
||||
public static List<String> getConfigFeatures(String type) {
|
||||
String targetFeatures = null;
|
||||
try (InputStream fis = new FileInputStream(PathUtils.getStudioConfigFile())) {
|
||||
Properties properties = new Properties();
|
||||
properties.load(fis);
|
||||
targetFeatures = properties.getProperty(type);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
if (StringUtils.isBlank(targetFeatures)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Arrays.asList(targetFeatures.trim().split(",")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static void clearConfigFeatures(String type) {
|
||||
Properties properties = new Properties();
|
||||
try (InputStream fis = new FileInputStream(PathUtils.getStudioConfigFile())) {
|
||||
properties.load(fis);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
try (OutputStream fos = new FileOutputStream(PathUtils.getStudioConfigFile())) {
|
||||
properties.setProperty(type, StringUtils.EMPTY);
|
||||
properties.store(fos, "Configuration File"); //$NON-NLS-1$
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateProductVersion(IProgressMonitor monitor, IProfile profile) throws IOException {
|
||||
Properties properties = new Properties();
|
||||
File eclipseProductFile = new File(
|
||||
Platform.getInstallLocation().getDataArea(UpdatesHelper.FILE_ECLIPSE_PRODUCT).getPath());
|
||||
try (InputStream in = new FileInputStream(eclipseProductFile)) {
|
||||
properties.load(in);
|
||||
}
|
||||
String oldVersion = properties.getProperty("version"); //$NON-NLS-1$
|
||||
Set<IInstallableUnit> queryResult = profile.query(QueryUtil.createIUQuery(P2UpdateConstants.STUDIO_CORE_FEATURE_ID), monitor)
|
||||
.toUnmodifiableSet();
|
||||
IInstallableUnit newCoreFeature = queryResult.stream().findFirst().get();
|
||||
String newVersion = newCoreFeature.getVersion().toString();
|
||||
if (oldVersion.endsWith(MavenConstants.SNAPSHOT)) {
|
||||
// for nightly build only.
|
||||
newVersion += MavenConstants.SNAPSHOT;
|
||||
}
|
||||
properties.setProperty("version", newVersion); //$NON-NLS-1$
|
||||
try (OutputStream out = new FileOutputStream(eclipseProductFile)) {
|
||||
properties.store(out, "Configuration File"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearOsgiCache() {
|
||||
synchronized (clearOsgiLock) {
|
||||
PlatformUI.getPreferenceStore().setValue(PreferenceKeys.NEED_OSGI_CLEAN, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="lib" path="lib/crypto-utils.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
|
||||
@@ -28,13 +28,13 @@ Export-Package:
|
||||
org.talend.utils.time;uses:="org.apache.log4j",
|
||||
org.talend.utils.wsdl,
|
||||
org.talend.utils.xml
|
||||
Bundle-ClassPath: .,
|
||||
lib/crypto-utils.jar
|
||||
Bundle-ClassPath: .
|
||||
Require-Bundle: org.apache.commons.lang,
|
||||
org.talend.libraries.apache;visibility:=reexport,
|
||||
org.apache.log4j,
|
||||
org.apache.commons.io,
|
||||
org.talend.daikon;visibility:=reexport,
|
||||
org.talend.daikon.crypto.utils;visibility:=reexport,
|
||||
org.bouncycastle.bcprov,
|
||||
org.apache.httpcomponents.httpclient,
|
||||
org.slf4j.api
|
||||
|
||||
@@ -4,7 +4,6 @@ source.dist/org.talend.utils.jar = src/main/java/
|
||||
output.dist/org.talend.utils.jar = class/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
dist/,\
|
||||
lib/crypto-utils.jar
|
||||
dist/
|
||||
jars.compile.order = .,\
|
||||
dist/org.talend.utils.jar
|
||||
|
||||
Binary file not shown.
@@ -60,28 +60,12 @@
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.8</version>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- same as org.talend.libraries.excel -->
|
||||
<id>copy-maven-repository</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<stripVersion>true</stripVersion>
|
||||
<outputDirectory>${project.basedir}/lib</outputDirectory>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.talend.daikon</groupId>
|
||||
<artifactId>crypto-utils</artifactId>
|
||||
<version>${org.talend.daikon.crypto-utils.version}</version>
|
||||
<overWrite>true</overWrite>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
<id>default-deploy</id>
|
||||
<phase>deploy</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
@@ -57,6 +57,11 @@
|
||||
<artifactId>daikon</artifactId>
|
||||
<version>0.2.0.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.talend.daikon</groupId>
|
||||
<artifactId>crypto-utils</artifactId>
|
||||
<version>${org.talend.daikon.crypto-utils.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-text</artifactId>
|
||||
@@ -101,33 +106,6 @@
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.8</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- same as org.talend.libraries.excel -->
|
||||
<id>copy-maven-repository</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<stripVersion>true</stripVersion>
|
||||
<outputDirectory>${project.basedir}/lib</outputDirectory>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.talend.daikon</groupId>
|
||||
<artifactId>crypto-utils</artifactId>
|
||||
<version>${org.talend.daikon.crypto-utils.version}</version>
|
||||
<overWrite>true</overWrite>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
// ============================================================================
|
||||
package org.talend.utils.string;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.talend.utils.sugars.ReturnCode;
|
||||
@@ -90,7 +92,14 @@ public final class StringUtilities {
|
||||
* @return
|
||||
*/
|
||||
public static String getRandomString(int length) {
|
||||
return java.util.UUID.randomUUID().toString().replace("-", "").substring(8, 8 + length); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String str = "abcdefghigklmnopkrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789"; //$NON-NLS-1$
|
||||
Random random = new SecureRandom();
|
||||
StringBuilder sf = new StringBuilder();
|
||||
for (int i = 0; i < length; i++) {
|
||||
int number = random.nextInt(str.length());// str.length() is 62, so 0~61
|
||||
sf.append(str.charAt(number));
|
||||
}
|
||||
return sf.toString();
|
||||
}
|
||||
|
||||
public static String removeEndingString(String fullStr, String endingStr) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 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.nexus;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class ResolverExceptionHandlerTest {
|
||||
|
||||
@Test
|
||||
public void testHideCredential() {
|
||||
String credencialStr1 = "talend-custom-libs-admin:talend-custom-libs-admin@";
|
||||
String credencialStr2 = "studio-dl-client:studio-dl-client@";
|
||||
String message = "Error resolving artifact org.slf4j:jcl-over-slf4j:pom:1.7.25: [Could not find artifact org.slf4j:jcl-over-slf4j:pom:1.7.25 in talend-custom-libs-release (http://talend-custom-libs-admin:talend-custom-libs-admin@localhost:8083/repository/talend-custom-libs-release/), Could not transfer artifact org.slf4j:jcl-over-slf4j:pom:1.7.25 from/to repo_-1349825302 (https://studio-dl-client:studio-dl-client@talend-update.talend.com/nexus/content/groups/dynamicdistribution/): No such host is known (talend-update.talend.com)]";
|
||||
IOException cause = new IOException(message);
|
||||
IOException e = new IOException(message, cause);
|
||||
IOException cleanException = ResolverExceptionHandler.hideCredential(e);
|
||||
|
||||
assertFalse(cleanException.getMessage().contains(credencialStr1));
|
||||
assertFalse(cleanException.getCause().getMessage().contains(credencialStr1));
|
||||
assertFalse(cleanException.getMessage().contains(credencialStr2));
|
||||
assertFalse(cleanException.getCause().getMessage().contains(credencialStr2));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,8 +21,11 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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.resources.IProject;
|
||||
@@ -280,9 +283,43 @@ public class AggregatorPomsHelperTest {
|
||||
}
|
||||
|
||||
};
|
||||
_helper.updateRefProjectModules(references);
|
||||
validatePomContent(helper.getProjectRootPom().getLocation().toFile(), defaultProjectGroupId, defaultProjectVersion,
|
||||
modules);
|
||||
_helper.updateRefProjectModules(references, new NullProgressMonitor());
|
||||
validatePomContent(helper.getProjectRootPom().getLocation().toFile(), defaultProjectGroupId, null, defaultProjectVersion,
|
||||
null, model.getModules(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateRefProjectProfile() throws Exception {
|
||||
needResetPom = true;
|
||||
List<ProjectReference> references = new ArrayList<>();
|
||||
{
|
||||
ProjectReference reference = PropertiesFactory.eINSTANCE.createProjectReference();
|
||||
Project project = PropertiesFactory.eINSTANCE.createProject();
|
||||
project.setTechnicalLabel("TESTPROJECT1");
|
||||
reference.setReferencedProject(project);
|
||||
references.add(reference);
|
||||
}
|
||||
{
|
||||
ProjectReference reference = PropertiesFactory.eINSTANCE.createProjectReference();
|
||||
Project project = PropertiesFactory.eINSTANCE.createProject();
|
||||
project.setTechnicalLabel("TESTPROJECT2");
|
||||
reference.setReferencedProject(project);
|
||||
references.add(reference);
|
||||
}
|
||||
AggregatorPomsHelper _helper = new AggregatorPomsHelper() {
|
||||
|
||||
@Override
|
||||
public boolean needUpdateRefProjectModules() {
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
ProjectPreferenceManager preferenceManager = new ProjectPreferenceManager(
|
||||
ProjectManager.getInstance().getCurrentProject(), DesignerMavenPlugin.PLUGIN_ID, false);
|
||||
preferenceManager.setValue(MavenConstants.USE_PROFILE_MODULE, true);
|
||||
_helper.updateRefProjectModules(references, new NullProgressMonitor());
|
||||
validatePomContent(helper.getProjectRootPom().getLocation().toFile(), defaultProjectGroupId, null, defaultProjectVersion,
|
||||
null, null, references);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,17 +347,17 @@ public class AggregatorPomsHelperTest {
|
||||
|
||||
// check project pom.
|
||||
IFile projectPomFile = new AggregatorPomsHelper().getProjectRootPom();
|
||||
validatePomContent(projectPomFile.getLocation().toFile(), projectGroupId, projectVersion, modules);
|
||||
validatePomContent(projectPomFile.getLocation().toFile(), projectGroupId, null, projectVersion, null, modules, null);
|
||||
// check project pom install result.
|
||||
File installedProjectPom = getInstalledFileFromLocalRepo(projectGroupId,
|
||||
TalendMavenConstants.DEFAULT_CODE_PROJECT_ARTIFACT_ID, projectVersion, MavenConstants.PACKAGING_POM);
|
||||
validatePomContent(installedProjectPom, projectGroupId, projectVersion, modules);
|
||||
validatePomContent(installedProjectPom, projectGroupId, null, projectVersion, null, modules, null);
|
||||
|
||||
// check routine pom.
|
||||
IFile routinePomFile = runProcessService.getTalendCodeJavaProject(ERepositoryObjectType.ROUTINES).getProjectPom();
|
||||
String routineGroupId = PomIdsHelper.getCodesGroupId("code");
|
||||
String routineVersion = PomIdsHelper.getCodesVersion();
|
||||
validatePomContent(routinePomFile.getLocation().toFile(), routineGroupId, routineVersion);
|
||||
validatePomContent(routinePomFile.getLocation().toFile(), routineGroupId, null, routineVersion, null, null, null);
|
||||
|
||||
// check routine install result.
|
||||
File installedRoutinePom = getInstalledFileFromLocalRepo(routineGroupId,
|
||||
@@ -329,7 +366,7 @@ public class AggregatorPomsHelperTest {
|
||||
|
||||
// check job pom.
|
||||
IFile jobPomFile = runProcessService.getTalendJobJavaProject(jobProperty).getProjectPom();
|
||||
validatePomContent(jobPomFile.getLocation().toFile(), jobGroupId, projectGroupId, jobVersion, projectVersion, null);
|
||||
validatePomContent(jobPomFile.getLocation().toFile(), jobGroupId, projectGroupId, jobVersion, projectVersion, null, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -347,19 +384,11 @@ public class AggregatorPomsHelperTest {
|
||||
|
||||
IFile jobPomFile = runProcessService.getTalendJobJavaProject(jobProperty).getProjectPom();
|
||||
validatePomContent(jobPomFile.getLocation().toFile(), customJobGroupId, defaultProjectGroupId, customJobVersion,
|
||||
defaultProjectVersion, null);
|
||||
}
|
||||
|
||||
private void validatePomContent(File pomFile, String groupId, String version) throws CoreException {
|
||||
validatePomContent(pomFile, groupId, null, version, null, null);
|
||||
}
|
||||
|
||||
private void validatePomContent(File pomFile, String groupId, String version, List<String> modules) throws CoreException {
|
||||
validatePomContent(pomFile, groupId, null, version, null, modules);
|
||||
defaultProjectVersion, null, null);
|
||||
}
|
||||
|
||||
private void validatePomContent(File pomFile, String groupId, String parentGroupId, String version, String parentVersion,
|
||||
List<String> modules)
|
||||
List<String> modules, List<ProjectReference> references)
|
||||
throws CoreException {
|
||||
Model model = MavenPlugin.getMaven().readModel(pomFile);
|
||||
assertEquals(groupId, model.getGroupId());
|
||||
@@ -376,6 +405,24 @@ public class AggregatorPomsHelperTest {
|
||||
for (String module : modules) {
|
||||
assertTrue(currentModules.contains(module));
|
||||
}
|
||||
} else {
|
||||
assertEquals(0, model.getModules().stream().filter(module -> module.startsWith("../../")).count());
|
||||
}
|
||||
|
||||
if (references != null) {
|
||||
if (PomIdsHelper.useProfileModule()) {
|
||||
List<Profile> refProjectProfiles = model.getProfiles().stream()
|
||||
.filter(profile -> StringUtils.startsWithIgnoreCase(profile.getId(), projectTechName))
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(references.size(), refProjectProfiles.size());
|
||||
references.forEach(reference -> {
|
||||
String profileId = (projectTechName + "_" + reference.getReferencedProject().getTechnicalLabel())
|
||||
.toLowerCase();
|
||||
assertTrue(refProjectProfiles.stream().anyMatch(profile -> profile.getId().equals(profileId)));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
assertEquals(0, model.getProfiles().stream().filter(profile -> profile.getId().startsWith(projectTechName)).count());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,7 +453,7 @@ public class AggregatorPomsHelperTest {
|
||||
throws IOException {
|
||||
String projectMvnUrl = MavenUrlHelper.generateMvnUrl(groupId, artifactId, version, packaging, null);
|
||||
String projectLocalMavenUri = projectMvnUrl.replace("mvn:", "mvn:" + MavenConstants.LOCAL_RESOLUTION_URL + "!");
|
||||
File installedFile = TalendMavenResolver.getMavenResolver().resolve(projectLocalMavenUri);
|
||||
File installedFile = TalendMavenResolver.resolve(projectLocalMavenUri);
|
||||
return installedFile;
|
||||
}
|
||||
|
||||
@@ -428,6 +475,7 @@ public class AggregatorPomsHelperTest {
|
||||
projectPreferenceManager.setValue(MavenConstants.PROJECT_VERSION, defaultProjectVersion);
|
||||
projectPreferenceManager.setValue(MavenConstants.NAME_PUBLISH_AS_SNAPSHOT, defaultUseSnapshot);
|
||||
projectPreferenceManager.setValue(MavenConstants.POM_FILTER, "");
|
||||
projectPreferenceManager.setValue(MavenConstants.USE_PROFILE_MODULE, false);
|
||||
// reset all poms.
|
||||
if (needResetPom) {
|
||||
helper.syncAllPomsWithoutProgress(new NullProgressMonitor());
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.ops4j.pax.url.mvn.MavenResolver;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
@@ -278,9 +277,8 @@ public class PomUtilTest {
|
||||
File test2 = new File(baseFile, "test2.jar");
|
||||
test2.createNewFile();
|
||||
|
||||
MavenResolver mvnResolver = TalendMavenResolver.getMavenResolver();
|
||||
mvnResolver.upload("org.talend.libraries", "test1", null, "txt", "6.0.0", test1);
|
||||
mvnResolver.upload("org.talend.studio", "test2", null, "jar", "6.0.0", test1);
|
||||
TalendMavenResolver.upload("org.talend.libraries", "test1", null, "txt", "6.0.0", test1);
|
||||
TalendMavenResolver.upload("org.talend.studio", "test2", null, "jar", "6.0.0", test1);
|
||||
|
||||
Assert.assertTrue(PomUtil.isAvailable("mvn:org.talend.libraries/test1/6.0.0/txt"));
|
||||
Assert.assertTrue(PomUtil.isAvailable("mvn:org.talend.studio/test2/6.0.0/jar"));
|
||||
|
||||
Reference in New Issue
Block a user