Compare commits
3 Commits
release/7.
...
release/7.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97849034bc | ||
|
|
afaf4646a1 | ||
|
|
6f5ae02eed |
@@ -92,7 +92,7 @@
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<version>2.12.0</version>
|
||||
<version>2.12.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.reload4j</groupId>
|
||||
|
||||
@@ -10,10 +10,11 @@ ProjectPomProjectSettingPage_ConfirmMessage=Will apply and update for project PO
|
||||
ProjectPomProjectSettingPage_FilterPomLabel=Filter to use to generate poms:
|
||||
ProjectPomProjectSettingPage_FilterErrorMessage=Invalid filter: {0}
|
||||
ProjectPomProjectSettingPage.syncAllPomsButtonText=Force full re-synchronize poms
|
||||
ProjectPomProjectSettingPage.syncBuildTypesButtonText=Force full re-synchronize build types
|
||||
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.refModuleText=Set reference project modules in profile
|
||||
MavenProjectSettingPage.excludeDeletedItems=Exclude deleted items
|
||||
MavenProjectSettingPage.syncAllPomsWarning=Click the Force full re-synchronize poms button to apply the new settings.
|
||||
MavenProjectSettingPage.skipFolders=Skip folders
|
||||
BuildProjectSettingPage.allowRecursiveJobs=Allow recursive jobs (Not recommended)
|
||||
BuildProjectSettingPage.allowRecursiveJobs=Allow recursive jobs (Not recommended)
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.talend.core.runtime.projectsetting.AbstractProjectSettingPage;
|
||||
import org.talend.core.runtime.services.IFilterService;
|
||||
import org.talend.designer.maven.DesignerMavenPlugin;
|
||||
import org.talend.designer.maven.tools.AggregatorPomsHelper;
|
||||
import org.talend.designer.maven.tools.BuildTypeManager;
|
||||
import org.talend.designer.maven.ui.i18n.Messages;
|
||||
|
||||
/**
|
||||
@@ -169,7 +170,25 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
if (isSyncBuildTypeAllowed()) {
|
||||
Button syncBuildTypes = new Button(parent, SWT.NONE);
|
||||
syncBuildTypes.setText(Messages.getString("ProjectPomProjectSettingPage.syncBuildTypesButtonText")); //$NON-NLS-1$
|
||||
|
||||
syncBuildTypes.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
try {
|
||||
new BuildTypeManager().syncBuildTypes(getCurrentPage());
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addSyncWarning() {
|
||||
setMessage(Messages.getString("MavenProjectSettingPage.syncAllPomsWarning"), IMessage.WARNING); //$NON-NLS-1$
|
||||
@@ -203,4 +222,12 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
return displayVersion;
|
||||
}
|
||||
|
||||
private static boolean isSyncBuildTypeAllowed() {
|
||||
return Boolean.getBoolean("talend.builtype.syncallowed");
|
||||
}
|
||||
|
||||
private MavenProjectSettingPage getCurrentPage() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||
org.talend.common.ui.runtime,
|
||||
org.talend.core.runtime,
|
||||
org.eclipse.jface,
|
||||
org.talend.core.repository
|
||||
org.talend.core.repository,
|
||||
org.talend.core
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.talend.designer.maven,
|
||||
org.talend.designer.maven.launch,
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.migration.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.ui.ITestContainerCoreService;
|
||||
|
||||
/**
|
||||
* DOC jding class global comment. Detailled comment
|
||||
*/
|
||||
public class ItemReportRecorder {
|
||||
|
||||
protected Item item;
|
||||
|
||||
protected String detailMessage;
|
||||
|
||||
public String getItemType() {
|
||||
String type = "";
|
||||
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
|
||||
if (itemType != null) {
|
||||
if (ERepositoryObjectType.getAllTypesOfTestContainer().contains(itemType)) {
|
||||
Item parentJobItem = getTestCaseParentJobItem(item);
|
||||
if (parentJobItem != null) {
|
||||
ERepositoryObjectType parentJobType = ERepositoryObjectType.getItemType(parentJobItem);
|
||||
if (parentJobType != null) {
|
||||
String parentTypePath = getCompleteObjectTypePath(parentJobType);
|
||||
if (StringUtils.isNotBlank(parentTypePath)) {
|
||||
type = parentTypePath + "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
type += itemType;
|
||||
} else {
|
||||
type = getCompleteObjectTypePath(itemType);
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getItemPath() {
|
||||
String path = "";
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
|
||||
|
||||
if (ERepositoryObjectType.getAllTypesOfTestContainer().contains(itemType)) {
|
||||
StringBuffer testcaseBuffer = new StringBuffer();
|
||||
Item parentJobItem = getTestCaseParentJobItem(item);
|
||||
if (parentJobItem != null) {
|
||||
if (parentJobItem.getState() != null && StringUtils.isNotBlank(parentJobItem.getState().getPath())) {
|
||||
testcaseBuffer.append(parentJobItem.getState().getPath()).append("/");
|
||||
}
|
||||
testcaseBuffer.append(parentJobItem.getProperty() != null ? parentJobItem.getProperty().getLabel() : "");
|
||||
if (StringUtils.isNotBlank(testcaseBuffer.toString())) {
|
||||
buffer.append(testcaseBuffer.toString()).append("/");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (item.getState() != null && StringUtils.isNotBlank(item.getState().getPath())) {
|
||||
buffer.append(item.getState().getPath()).append("/");
|
||||
}
|
||||
}
|
||||
|
||||
Property property = item.getProperty();
|
||||
if (property != null) {
|
||||
buffer.append(property.getLabel() + "_" + property.getVersion());
|
||||
}
|
||||
path = buffer.toString();
|
||||
return path;
|
||||
}
|
||||
|
||||
private Item getTestCaseParentJobItem(Item testcaseItem) {
|
||||
Item parentJobItem = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerCoreService.class)) {
|
||||
ITestContainerCoreService testcaseService = GlobalServiceRegister.getDefault()
|
||||
.getService(ITestContainerCoreService.class);
|
||||
if (testcaseService != null) {
|
||||
try {
|
||||
parentJobItem = testcaseService.getParentJobItem(item);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return parentJobItem;
|
||||
}
|
||||
|
||||
private String getCompleteObjectTypePath(ERepositoryObjectType itemType) {
|
||||
ERepositoryObjectType rootItemType = itemType;
|
||||
if (ERepositoryObjectType.JDBC != null && ERepositoryObjectType.JDBC.equals(rootItemType)) {
|
||||
rootItemType = ERepositoryObjectType.METADATA_CONNECTIONS;
|
||||
}
|
||||
List<String> typeLabels = new ArrayList<String>();
|
||||
findOutCompleteTypePath(rootItemType, typeLabels);
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
if (!typeLabels.isEmpty()) {
|
||||
for (int i = 0; i < typeLabels.size(); i++) {
|
||||
if (i != 0) {
|
||||
buffer.append("/");
|
||||
}
|
||||
buffer.append(typeLabels.get(i));
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
private void findOutCompleteTypePath(ERepositoryObjectType type, List<String> typeLabels) {
|
||||
ERepositoryObjectType parentType = ERepositoryObjectType.findParentType(type);
|
||||
if (parentType != null) {
|
||||
findOutCompleteTypePath(parentType, typeLabels);
|
||||
}
|
||||
typeLabels.add(type.getLabel());
|
||||
}
|
||||
|
||||
public Item getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public void setItem(Item item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public String getDetailMessage() {
|
||||
return detailMessage;
|
||||
}
|
||||
|
||||
public void setDetailMessage(String detailMessage) {
|
||||
this.detailMessage = detailMessage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.migration.common;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
|
||||
/**
|
||||
* DOC jding class global comment. Detailled comment
|
||||
*/
|
||||
public class ItemsReportUtil {
|
||||
|
||||
|
||||
public static boolean generateReportFile(File reportFile, String header, List<String> records) throws Exception {
|
||||
boolean generateDone = false;
|
||||
BufferedWriter printWriter = null;
|
||||
try {
|
||||
File parentFolder = new Path(reportFile.getAbsolutePath()).removeLastSegments(1).toFile();
|
||||
// File parentFolder = new File(parentPath);
|
||||
if (!parentFolder.exists()) {
|
||||
parentFolder.mkdirs();
|
||||
}
|
||||
if (!reportFile.exists()) {
|
||||
reportFile.createNewFile();
|
||||
}
|
||||
FileOutputStream fos = new FileOutputStream(reportFile);
|
||||
fos.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
|
||||
OutputStreamWriter outputWriter = new OutputStreamWriter(fos, "UTF-8");
|
||||
printWriter = new BufferedWriter(outputWriter);
|
||||
printWriter.write(header);
|
||||
printWriter.newLine();
|
||||
for (String recordStr : records) {
|
||||
printWriter.write(recordStr);
|
||||
printWriter.newLine();
|
||||
}
|
||||
printWriter.flush();
|
||||
generateDone = true;
|
||||
} finally {
|
||||
if (printWriter != null) {
|
||||
printWriter.close();
|
||||
}
|
||||
}
|
||||
return generateDone;
|
||||
}
|
||||
|
||||
public static String handleColumnQuotes(String text) {
|
||||
String quoteMark = TalendQuoteUtils.QUOTATION_MARK;
|
||||
text = StringUtils.isBlank(text) ? "" : text;
|
||||
if (text.contains(quoteMark)) {
|
||||
// replace to double quote surround
|
||||
text = text.replace(quoteMark, quoteMark + quoteMark);
|
||||
}
|
||||
return quoteMark + text + quoteMark;
|
||||
}
|
||||
|
||||
public static String getCurrentTimeString() {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String time = dateFormat.format(new Date());
|
||||
return time;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.migration.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.preferences.ConfigurationScope;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.IScopeContext;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.migration.IProjectMigrationTask;
|
||||
|
||||
/**
|
||||
* DOC jding class global comment. Detailled comment
|
||||
*/
|
||||
public class MigrationReportHelper {
|
||||
|
||||
private static final String COMMA = ",";
|
||||
|
||||
private static final String PLUGIN_ID = "org.talend.designer.maven";
|
||||
|
||||
private static final String DO_NOT_SHOW_PREF_KEY = "talend.migrationReportDialog.doNotShowAgain";
|
||||
|
||||
private static final String MIGRATION_REPORT_HEAD = "Task name,Task description,Item type,Path to migrated item,Migration details";
|
||||
|
||||
private static final MigrationReportHelper instance = new MigrationReportHelper();
|
||||
|
||||
public static MigrationReportHelper getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private String reportGeneratedPath = "";
|
||||
|
||||
private Set<String> taskItemRecords = new HashSet<String>();
|
||||
|
||||
private List<MigrationReportRecorder> migrationReportRecorders = new ArrayList<MigrationReportRecorder>();
|
||||
|
||||
public void generateMigrationReport(String projectTecName) {
|
||||
if (migrationReportRecorders == null || migrationReportRecorders.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PluginChecker.isTIS()) {
|
||||
clearRecorders();
|
||||
return;
|
||||
}
|
||||
|
||||
File exportFolder = null;
|
||||
File reportFile = null;
|
||||
try {
|
||||
String currentTime = getCurrentTime();
|
||||
String filePath = getReportExportFolder(currentTime) + "/" + getReportFileName(currentTime, projectTecName);
|
||||
reportGeneratedPath = filePath;
|
||||
reportFile = new File(filePath);
|
||||
List<String> recordLines = new ArrayList<String>();
|
||||
for (MigrationReportRecorder record : migrationReportRecorders) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(ItemsReportUtil.handleColumnQuotes(record.getTaskClassName())).append(COMMA);
|
||||
buffer.append(ItemsReportUtil.handleColumnQuotes(record.getTaskDescription())).append(COMMA);
|
||||
buffer.append(ItemsReportUtil.handleColumnQuotes(record.getItemType())).append(COMMA);
|
||||
buffer.append(ItemsReportUtil.handleColumnQuotes(record.getItemPath())).append(COMMA);
|
||||
buffer.append(ItemsReportUtil.handleColumnQuotes(record.getDetailMessage()));
|
||||
recordLines.add(buffer.toString());
|
||||
}
|
||||
ItemsReportUtil.generateReportFile(reportFile, MIGRATION_REPORT_HEAD, recordLines);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
if (reportFile != null && reportFile.exists()) {
|
||||
reportFile.delete();
|
||||
}
|
||||
if (exportFolder != null && exportFolder.exists()) {
|
||||
exportFolder.delete();
|
||||
}
|
||||
} finally {
|
||||
migrationReportRecorders.clear();
|
||||
taskItemRecords.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isRequireDefaultRecord(IProjectMigrationTask task, Item item) {
|
||||
boolean require = true;
|
||||
if (task.getOrder() != null) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(task.getOrder());
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
if (year <= 2016) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (item.getProperty() != null) {
|
||||
Property property = item.getProperty();
|
||||
String key = task.getId() + "_" + property.getId() + "_" + property.getVersion();
|
||||
if (taskItemRecords.contains(key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return require;
|
||||
}
|
||||
|
||||
private String getCurrentTime() {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String time = dateFormat.format(new Date());
|
||||
return time;
|
||||
}
|
||||
|
||||
private String getReportExportFolder(String time) {
|
||||
String folderName = "migrationReport" + "_" + time;
|
||||
String path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString() + "/report/" + folderName;
|
||||
return path;
|
||||
}
|
||||
|
||||
private String getReportFileName(String time, String projectTecName) {
|
||||
String fileName = time + "_" + projectTecName + "_" + "Migration" + "_" + "Report.csv";
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public static void storeDoNotShowAgainPref(boolean selected) {
|
||||
IScopeContext scopeContext = ConfigurationScope.INSTANCE;
|
||||
IEclipsePreferences pref = scopeContext.getNode(PLUGIN_ID);
|
||||
pref.putBoolean(DO_NOT_SHOW_PREF_KEY, selected);
|
||||
try {
|
||||
pref.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isReportDialogDisable() {
|
||||
IScopeContext scopeContext = ConfigurationScope.INSTANCE;
|
||||
IEclipsePreferences pref = scopeContext.getNode(PLUGIN_ID);
|
||||
return pref.getBoolean(DO_NOT_SHOW_PREF_KEY, false);
|
||||
}
|
||||
|
||||
public void addRecorder(MigrationReportRecorder recorder) {
|
||||
if (recorder != null) {
|
||||
migrationReportRecorders.add(recorder);
|
||||
if (recorder.getItem() != null && recorder.getItem().getProperty() != null) {
|
||||
Property property = recorder.getItem().getProperty();
|
||||
taskItemRecords.add(recorder.getTask().getId() + "_" + property.getId() + "_" + property.getVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearRecorders() {
|
||||
reportGeneratedPath = "";
|
||||
migrationReportRecorders.clear();
|
||||
taskItemRecords.clear();
|
||||
}
|
||||
|
||||
public String getReportGeneratedPath() {
|
||||
return reportGeneratedPath;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.migration.common;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.talend.core.model.components.ComponentUtilities;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.migration.IProjectMigrationTask;
|
||||
|
||||
/**
|
||||
* DOC jding class global comment. Detailled comment
|
||||
*/
|
||||
public class MigrationReportRecorder extends ItemReportRecorder {
|
||||
|
||||
private IProjectMigrationTask task;
|
||||
|
||||
private MigrationOperationType operationType;
|
||||
|
||||
private NodeType node;
|
||||
|
||||
private String paramName;
|
||||
|
||||
private String oldValue;
|
||||
|
||||
private String newValue;
|
||||
|
||||
public enum MigrationOperationType {
|
||||
ADD,
|
||||
MODIFY,
|
||||
DELETE
|
||||
}
|
||||
|
||||
public MigrationReportRecorder(IProjectMigrationTask task, Item item) {
|
||||
super();
|
||||
this.task = task;
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public MigrationReportRecorder(IProjectMigrationTask task, MigrationOperationType operationType, Item item, NodeType node,
|
||||
String paramName, String oldValue, String newValue) {
|
||||
super();
|
||||
this.task = task;
|
||||
this.operationType = operationType;
|
||||
this.item = item;
|
||||
this.node = node;
|
||||
this.paramName = paramName;
|
||||
this.oldValue = oldValue;
|
||||
this.newValue = newValue;
|
||||
}
|
||||
|
||||
public MigrationReportRecorder(IProjectMigrationTask task, Item item, String detailMessage) {
|
||||
super();
|
||||
this.task = task;
|
||||
this.item = item;
|
||||
this.detailMessage = detailMessage;
|
||||
}
|
||||
|
||||
public String getTaskClassName() {
|
||||
return task.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public String getTaskDescription() {
|
||||
String description = "";
|
||||
if (StringUtils.isNotBlank(task.getDescription())) {
|
||||
description = task.getDescription();
|
||||
}
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getDetailMessage() {
|
||||
String details = detailMessage;
|
||||
if (StringUtils.isNotBlank(detailMessage)) {
|
||||
return details;
|
||||
}
|
||||
|
||||
if (operationType == null || StringUtils.isBlank(paramName)) {
|
||||
details = getTaskClassName() + " task is applied";
|
||||
return details;
|
||||
}
|
||||
|
||||
StringBuffer detailBuffer = new StringBuffer();
|
||||
if (node != null) {
|
||||
// migration for node, e.g. tRESTClient component "tRESTClient_2":
|
||||
detailBuffer.append(node.getComponentName()).append(" component ");
|
||||
ElementParameterType uniqueName = ComponentUtilities.getNodeProperty(node, "UNIQUE_NAME");
|
||||
detailBuffer.append(TalendQuoteUtils.addQuotes(uniqueName.getValue())).append(":");
|
||||
} else {
|
||||
// migration for item, e.g. context item "testContext":
|
||||
detailBuffer.append(getItemType() + " item ")
|
||||
.append(TalendQuoteUtils.addQuotes(item.getProperty().getLabel())).append(":");
|
||||
}
|
||||
|
||||
detailBuffer.append(paramName).append(" was ");
|
||||
switch (operationType) {
|
||||
case ADD:
|
||||
detailBuffer.append("added");
|
||||
if (StringUtils.isNotBlank(newValue)) {
|
||||
detailBuffer.append(" with ").append(newValue);
|
||||
}
|
||||
break;
|
||||
case MODIFY:
|
||||
detailBuffer.append("changed");
|
||||
if (StringUtils.isNotBlank(oldValue)) {
|
||||
detailBuffer.append(" from ").append(oldValue);
|
||||
}
|
||||
if (StringUtils.isNotBlank(newValue)) {
|
||||
detailBuffer.append(" to ").append(newValue);
|
||||
}
|
||||
break;
|
||||
case DELETE:
|
||||
detailBuffer.append("deleted");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
details = detailBuffer.toString();
|
||||
|
||||
return details;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for task.
|
||||
*
|
||||
* @return the task
|
||||
*/
|
||||
public IProjectMigrationTask getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the task.
|
||||
*
|
||||
* @param task the task to set
|
||||
*/
|
||||
public void setTask(IProjectMigrationTask task) {
|
||||
this.task = task;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the operationType.
|
||||
*
|
||||
* @param operationType the operationType to set
|
||||
*/
|
||||
public void setOperationType(MigrationOperationType operationType) {
|
||||
this.operationType = operationType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node.
|
||||
*
|
||||
* @param node the node to set
|
||||
*/
|
||||
public void setNode(NodeType node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the paramName.
|
||||
*
|
||||
* @param paramName the paramName to set
|
||||
*/
|
||||
public void setParamName(String paramName) {
|
||||
this.paramName = paramName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the oldValue.
|
||||
*
|
||||
* @param oldValue the oldValue to set
|
||||
*/
|
||||
public void setOldValue(String oldValue) {
|
||||
this.oldValue = oldValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the newValue.
|
||||
*
|
||||
* @param newValue the newValue to set
|
||||
*/
|
||||
public void setNewValue(String newValue) {
|
||||
this.newValue = newValue;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package org.talend.designer.maven.migration.tasks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.runtime.model.emf.EmfHelper;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.components.filters.IComponentFilter;
|
||||
import org.talend.core.model.migration.AbstractItemMigrationTask;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.utils.ConvertJobsUtil;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.designer.maven.migration.common.MigrationReportHelper;
|
||||
import org.talend.designer.maven.migration.common.MigrationReportRecorder;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
|
||||
public abstract class AbstractCorrectBuildItemMigrationTask extends AbstractItemMigrationTask implements ICorrectBuildTypeMigrationTask {
|
||||
|
||||
protected static final String BUILD_TYPE_PROPERTY = "BUILD_TYPE";
|
||||
protected static final String BUILD_TYPE_STANDALONE = "STANDALONE";
|
||||
protected static final String BUILD_TYPE_OSGI = "OSGI";
|
||||
protected static final String BUILD_TYPE_ROUTE = "ROUTE";
|
||||
protected static final String BUILD_TYPE_ROUTE_MICROSERVICE = "ROUTE_MICROSERVICE";
|
||||
protected static final String REST_MS = "REST_MS";
|
||||
|
||||
|
||||
protected static Map<String, String> migratedJobs = new HashMap<String, String>();
|
||||
|
||||
protected static void clearMigratedJobs () {
|
||||
migratedJobs.clear();
|
||||
}
|
||||
|
||||
protected static void skipMigrationForJob (String jobName, String migrationTask) {
|
||||
migratedJobs.put(jobName, migrationTask);
|
||||
}
|
||||
|
||||
protected static void storeMigratedJob (String jobName, String migrationTask) {
|
||||
migratedJobs.put(jobName, migrationTask);
|
||||
}
|
||||
|
||||
protected static boolean isJobMigrated (String jobName) {
|
||||
return migratedJobs.containsKey(jobName);
|
||||
}
|
||||
|
||||
protected static String getStoredJobMigraionTask (String jobName) {
|
||||
return migratedJobs.get(jobName);
|
||||
}
|
||||
|
||||
public void generateReportRecord(MigrationReportRecorder recorder) {
|
||||
MigrationReportHelper.getInstance().addRecorder(recorder);
|
||||
}
|
||||
|
||||
public static List<NodeType> searchComponent(ProcessType processType, IComponentFilter filter) {
|
||||
List<NodeType> list = new ArrayList<NodeType>();
|
||||
if (filter == null || processType == null) {
|
||||
return list;
|
||||
}
|
||||
|
||||
for (Object o : processType.getNode()) {
|
||||
if (filter.accept((NodeType) o)) {
|
||||
list.add((NodeType) o);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void save(Item item) throws PersistenceException {
|
||||
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault()
|
||||
.getService(IRepositoryService.class);
|
||||
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
|
||||
factory.save(item, true);
|
||||
}
|
||||
|
||||
public ProcessType getProcessType(Item item) {
|
||||
ProcessType processType = null;
|
||||
if (item instanceof ProcessItem) {
|
||||
processType = ((ProcessItem) item).getProcess();
|
||||
}
|
||||
if (item instanceof JobletProcessItem) {
|
||||
processType = ((JobletProcessItem) item).getJobletProcess();
|
||||
}
|
||||
if (processType != null) {
|
||||
EmfHelper.visitChilds(processType);
|
||||
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
|
||||
if (itemType == ERepositoryObjectType.TEST_CONTAINER
|
||||
&& !ConvertJobsUtil.JobType.STANDARD.getDisplayName().equalsIgnoreCase(processType.getJobType())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
return processType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find element parameter with a given parameter name
|
||||
*
|
||||
* @param paramName
|
||||
* @param elementParameterTypes
|
||||
* @return
|
||||
*/
|
||||
public static final ElementParameterType findElementParameterByName(String paramName, NodeType node) {
|
||||
for (Object obj : node.getElementParameter()) {
|
||||
ElementParameterType cpType = (ElementParameterType) obj;
|
||||
if (paramName.equals(cpType.getName())) {
|
||||
return cpType;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
abstract public void clear ();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.talend.designer.maven.migration.tasks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
|
||||
public abstract class AbstractDataServiceJobMigrationTask extends AbstractCorrectBuildItemMigrationTask {
|
||||
|
||||
@Override
|
||||
public List<ERepositoryObjectType> getTypes() {
|
||||
List<ERepositoryObjectType> toReturn = new ArrayList<ERepositoryObjectType>();
|
||||
toReturn.add(ERepositoryObjectType.PROCESS);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.talend.designer.maven.migration.tasks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
|
||||
public abstract class AbstractRouteMigrationTask extends AbstractCorrectBuildItemMigrationTask {
|
||||
|
||||
@Override
|
||||
public List<ERepositoryObjectType> getTypes() {
|
||||
List<ERepositoryObjectType> toReturn = new ArrayList<ERepositoryObjectType>();
|
||||
toReturn.add(ERepositoryObjectType.PROCESS_ROUTE);
|
||||
toReturn.add(ERepositoryObjectType.PROCESS_ROUTE_MICROSERVICE);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
package org.talend.designer.maven.migration.tasks;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.components.filters.IComponentFilter;
|
||||
import org.talend.core.model.components.filters.NameComponentFilter;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.designer.maven.migration.common.MigrationReportRecorder;
|
||||
import org.talend.designer.runprocess.ItemCacheManager;
|
||||
import org.talend.repository.ProjectManager;
|
||||
|
||||
/*
|
||||
* If Job does not contain any of the following components: "tRouteInput", "tRESTClient", "tESBConsumer"
|
||||
* then BUILD_TYPE must be STANDALONE
|
||||
* Else (job contains one of "tRouteInput", "tRESTClient" or "tESBConsumer")
|
||||
* If no BUILD_TYPE is set then default BUILD_TYPE must be STANDALONE
|
||||
* Manage child jobs for jobs ( parent, target BUILD_TYPE = STANDALONE )
|
||||
* If BUILD_TYPE is STANDALONE
|
||||
* Manage child jobs for jobs ( parent, target BUILD_TYPE = STANDALONE )
|
||||
* If BUILD_TYPE is ROUTE > EXCEPTION: need warning message! BUILD_TYPE was wrongly set to ROUTE from a previous migration task and has to be manually updated (all subjobs have to be checked manually). Value should be either STANDALONE (in most cases) or OSGI.
|
||||
*/
|
||||
|
||||
public class CorrectBuildTypeForDIJobMigrationTask extends AbstractDataServiceJobMigrationTask {
|
||||
|
||||
private static final String[] ESB_COMPONENTS = { "tRouteInput", "tRESTClient", "tESBConsumer" };
|
||||
|
||||
private static final String T_RUB_JOB_COMPONENT = "tRunJob";
|
||||
|
||||
boolean failure = false;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.migration.IMigrationTask#getOrder()
|
||||
*/
|
||||
@Override
|
||||
public Date getOrder() {
|
||||
GregorianCalendar gc = new GregorianCalendar(2021, 7, 25, 12, 0, 0);
|
||||
return gc.getTime();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public ExecutionResult execute(Item item) {
|
||||
|
||||
final ProcessType processType = getProcessType(item);
|
||||
String jobName = item.getProperty().getLabel();
|
||||
|
||||
/*
|
||||
* Migrating remaining jobs only (which was not migrated previously)
|
||||
*/
|
||||
if (isJobMigrated(jobName)) {
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
}
|
||||
|
||||
|
||||
Object originalBuildType = item.getProperty().getAdditionalProperties().get(BUILD_TYPE_PROPERTY);
|
||||
|
||||
/*
|
||||
* If BUILD_TYPE is ROUTE > EXCEPTION: need warning message! BUILD_TYPE was
|
||||
* wrongly set to ROUTE from a previous migration task and has to be manually
|
||||
* updated (all subjobs have to be checked manually). Value should be either
|
||||
* STANDALONE (in most cases) or OSGI.
|
||||
*/
|
||||
|
||||
if (originalBuildType != null && BUILD_TYPE_ROUTE.equalsIgnoreCase((String) originalBuildType)) {
|
||||
ExceptionHandler.process(new RuntimeException("Job [" + jobName + "] has incorrect BUILD_TYPE ["
|
||||
+ BUILD_TYPE_ROUTE
|
||||
+ "] which has to be manually updated (all subjobs have to be checked manually). Value should be either STANDALONE (in most cases) or OSGI"));
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
|
||||
for (String name : ESB_COMPONENTS) {
|
||||
|
||||
boolean modified = false;
|
||||
|
||||
IComponentFilter filter = new NameComponentFilter(name);
|
||||
|
||||
List<NodeType> c = searchComponent(processType, filter);
|
||||
|
||||
if (!c.isEmpty()) {
|
||||
|
||||
/*
|
||||
* job contains one of "tRouteInput", "tRESTClient" or "tESBConsumer") If no
|
||||
* BUILD_TYPE is set then default BUILD_TYPE must be STANDALONE
|
||||
*/
|
||||
|
||||
if (null == originalBuildType) {
|
||||
item.getProperty().getAdditionalProperties().put(BUILD_TYPE_PROPERTY, BUILD_TYPE_STANDALONE);
|
||||
try {
|
||||
save(item);
|
||||
modified |= true;
|
||||
generateReportRecord(
|
||||
new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY,
|
||||
item, null, "Build Type", null, BUILD_TYPE_STANDALONE));
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Manage child jobs for jobs ( parent, target BUILD_TYPE = STANDALONE )
|
||||
*/
|
||||
String currentParentJobBuildType = (String) item.getProperty().getAdditionalProperties()
|
||||
.get(BUILD_TYPE_PROPERTY);
|
||||
|
||||
if (BUILD_TYPE_STANDALONE.equalsIgnoreCase(currentParentJobBuildType)) {
|
||||
updateBuildTypeForSubJobs(item, currentParentJobBuildType);
|
||||
}
|
||||
|
||||
if (failure) {
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
}
|
||||
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If Job does not contain any of the following components: "tRouteInput",
|
||||
* "tRESTClient", "tESBConsumer" then BUILD_TYPE must be STANDALONE
|
||||
* Manage child jobs for jobs ( parent, target BUILD_TYPE = STANDALONE )
|
||||
*/
|
||||
|
||||
if (null == originalBuildType || !BUILD_TYPE_STANDALONE.equalsIgnoreCase(originalBuildType.toString())) {
|
||||
item.getProperty().getAdditionalProperties().put(BUILD_TYPE_PROPERTY, BUILD_TYPE_STANDALONE);
|
||||
boolean modified = false;
|
||||
try {
|
||||
save(item);
|
||||
modified |= true;
|
||||
generateReportRecord(new MigrationReportRecorder(this,
|
||||
MigrationReportRecorder.MigrationOperationType.MODIFY, item, null, "Build Type",
|
||||
(null == originalBuildType) ? null : originalBuildType.toString(), BUILD_TYPE_STANDALONE));
|
||||
updateBuildTypeForSubJobs(item, BUILD_TYPE_STANDALONE);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
|
||||
if (failure) {
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If Job does not contain any of the following components: "tRouteInput",
|
||||
* "tRESTClient", "tESBConsumer" and BUILD_TYPE is STANDALONE
|
||||
* Manage child jobs for jobs ( parent, target BUILD_TYPE = STANDALONE )
|
||||
*/
|
||||
if (BUILD_TYPE_STANDALONE.equalsIgnoreCase(originalBuildType.toString())) {
|
||||
updateBuildTypeForSubJobs(item, BUILD_TYPE_STANDALONE);
|
||||
if (failure) {
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Synchronize build types for DI jobs";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
clearMigratedJobs();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void updateBuildTypeForSubJobs(Item parentJobItem, String parentJobBuiltType) {
|
||||
IComponentFilter filter = new NameComponentFilter(T_RUB_JOB_COMPONENT);
|
||||
|
||||
ProcessType processType = getProcessType(parentJobItem);
|
||||
|
||||
List<NodeType> c = searchComponent(processType, filter);
|
||||
|
||||
if (!c.isEmpty()) {
|
||||
|
||||
for (NodeType tRunJobComponent : c) {
|
||||
String processID = findElementParameterByName("SELECTED_JOB_NAME:PROCESS_TYPE_PROCESS",
|
||||
tRunJobComponent) == null ? null
|
||||
: findElementParameterByName("SELECTED_JOB_NAME:PROCESS_TYPE_PROCESS", tRunJobComponent)
|
||||
.getValue();
|
||||
if (processID == null) {
|
||||
processID = findElementParameterByName("PROCESS:PROCESS_TYPE_PROCESS",
|
||||
tRunJobComponent) == null ? null
|
||||
: findElementParameterByName("PROCESS:PROCESS_TYPE_PROCESS", tRunJobComponent)
|
||||
.getValue();
|
||||
}
|
||||
|
||||
String processVersion = findElementParameterByName("SELECTED_JOB_NAME:PROCESS_TYPE_VERSION",
|
||||
tRunJobComponent) == null ? null
|
||||
: findElementParameterByName("SELECTED_JOB_NAME:PROCESS_TYPE_VERSION", tRunJobComponent)
|
||||
.getValue();
|
||||
|
||||
if (processVersion == null) {
|
||||
processVersion = findElementParameterByName("PROCESS:PROCESS_TYPE_VERSION",
|
||||
tRunJobComponent) == null ? null
|
||||
: findElementParameterByName("PROCESS:PROCESS_TYPE_VERSION", tRunJobComponent)
|
||||
.getValue();
|
||||
}
|
||||
|
||||
if (processID != null && processVersion != null) {
|
||||
ProcessItem childItem = ItemCacheManager.getProcessItem(processID, processVersion);
|
||||
Project childItemProject = ProjectManager.getInstance().getCurrentProject();
|
||||
|
||||
if (childItem == null) {
|
||||
for (Project refProject : ProjectManager.getInstance().getAllReferencedProjects()) {
|
||||
childItem = ItemCacheManager.getRefProcessItem(getProject(), processID);
|
||||
if (childItem != null) {
|
||||
childItemProject = refProject;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (childItem != null) {
|
||||
|
||||
Object currentChildBuildType = childItem.getProperty().getAdditionalProperties()
|
||||
.get(BUILD_TYPE_PROPERTY);
|
||||
|
||||
// String jobID = childItem.getProperty().getLabel();
|
||||
|
||||
String currentChildBuildTypeStr = (null == currentChildBuildType) ? null
|
||||
: (String) currentChildBuildType;
|
||||
|
||||
if (BUILD_TYPE_STANDALONE.equalsIgnoreCase(parentJobBuiltType)
|
||||
&& !BUILD_TYPE_STANDALONE.equalsIgnoreCase(currentChildBuildTypeStr)) {
|
||||
|
||||
childItem.getProperty().getAdditionalProperties().put(BUILD_TYPE_PROPERTY,
|
||||
BUILD_TYPE_STANDALONE);
|
||||
|
||||
try {
|
||||
save(childItem);
|
||||
generateReportRecord(new MigrationReportRecorder(this,
|
||||
MigrationReportRecorder.MigrationOperationType.MODIFY, childItem, null,
|
||||
"Build Type", currentChildBuildTypeStr, BUILD_TYPE_STANDALONE));
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
failure = true;
|
||||
}
|
||||
}
|
||||
|
||||
updateBuildTypeForSubJobs(childItem, parentJobBuiltType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package org.talend.designer.maven.migration.tasks;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.components.filters.IComponentFilter;
|
||||
import org.talend.core.model.components.filters.NameComponentFilter;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.designer.maven.migration.common.MigrationReportRecorder;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* Data service REST (process) = Job with "tRESTRequest"
|
||||
* If no BUILD_TYPE is set then default BUILD_TYPE must be OSGI
|
||||
* If Job does not contain any of the following components: "tRouteInput", "tRESTClient", "tESBConsumer" then BUILD_TYPE must be STANDALONE
|
||||
*/
|
||||
|
||||
public class CorrectBuildTypeForDsRestMigrationTask extends AbstractDataServiceJobMigrationTask {
|
||||
|
||||
private static final String T_REST_REQUEST = "tRESTRequest";
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.migration.IMigrationTask#getOrder()
|
||||
*/
|
||||
@Override
|
||||
public Date getOrder() {
|
||||
GregorianCalendar gc = new GregorianCalendar(2021, 7, 25, 12, 0, 0);
|
||||
return gc.getTime();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.core.model.migration.AbstractDataserviceMigrationTask#execute(org
|
||||
* .talend.core.model.properties.Item)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public ExecutionResult execute(Item item) {
|
||||
final ProcessType processType = getProcessType(item);
|
||||
|
||||
boolean modified = false;
|
||||
|
||||
/*
|
||||
* If no BUILD_TYPE is set then default BUILD_TYPE must be OSGI
|
||||
*/
|
||||
|
||||
IComponentFilter filter = new NameComponentFilter(T_REST_REQUEST);
|
||||
|
||||
List<NodeType> c = searchComponent(processType, filter);
|
||||
|
||||
if (!c.isEmpty()) {
|
||||
Object buildType = item.getProperty().getAdditionalProperties().get(BUILD_TYPE_PROPERTY);
|
||||
if (null == buildType) {
|
||||
item.getProperty().getAdditionalProperties().put(BUILD_TYPE_PROPERTY, BUILD_TYPE_OSGI);
|
||||
try {
|
||||
save(item);
|
||||
modified |= true;
|
||||
generateReportRecord(
|
||||
new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY,
|
||||
item, null, "Build Type", null, BUILD_TYPE_OSGI));
|
||||
storeMigratedJob(item.getProperty().getLabel(), this.getClass().getName());
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
} else if (BUILD_TYPE_OSGI.equalsIgnoreCase((String)buildType)){
|
||||
// current job has correct build type
|
||||
// skip this job during next migrations
|
||||
skipMigrationForJob(item.getProperty().getLabel(), this.getClass().getName());
|
||||
} else if (REST_MS.equalsIgnoreCase((String)buildType)){
|
||||
// current job has correct build type
|
||||
// skip this job during next migrations
|
||||
skipMigrationForJob(item.getProperty().getLabel(), this.getClass().getName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
} else {
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Synchronize build types for DS Rest jobs";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear () {
|
||||
clearMigratedJobs();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
package org.talend.designer.maven.migration.tasks;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.components.filters.IComponentFilter;
|
||||
import org.talend.core.model.components.filters.NameComponentFilter;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.process.TalendProcessArgumentConstant;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.designer.maven.migration.common.MigrationReportRecorder;
|
||||
import org.talend.designer.runprocess.ItemCacheManager;
|
||||
import org.talend.repository.ProjectManager;
|
||||
|
||||
/*
|
||||
* Routes
|
||||
* If no BUILD_TYPE is set then Default BUILD_TYPE must be ROUTE
|
||||
* - Manage child jobs for routes ( parent, target BUILD_TYPE = OSGI )
|
||||
* Else if BUILD_TYPE is ROUTE
|
||||
* - Manage child jobs for routes ( parent, target BUILD_TYPE = OSGI )
|
||||
* Else if BUILD_TYPE is ROUTE_MICROSERVICE
|
||||
* -Manage child jobs for jobs ( parent, target BUILD_TYPE = STANDALONE )
|
||||
*/
|
||||
|
||||
public class CorrectBuildTypeForRoutesMigrationTask extends AbstractRouteMigrationTask {
|
||||
|
||||
private static final String C_TALEND_JOB = "cTalendJob";
|
||||
|
||||
protected Map<String, String> migratedChildJobs = new HashMap<String, String>();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.migration.IMigrationTask#getOrder()
|
||||
*/
|
||||
@Override
|
||||
public Date getOrder() {
|
||||
GregorianCalendar gc = new GregorianCalendar(2021, 7, 25, 12, 0, 0);
|
||||
return gc.getTime();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public ExecutionResult execute(Item item) {
|
||||
|
||||
final ProcessType processType = getProcessType(item);
|
||||
|
||||
boolean modified = false;
|
||||
boolean migrationFailure = false;
|
||||
/*
|
||||
* If no BUILD_TYPE is set then default BUILD_TYPE must be ROUTE
|
||||
*/
|
||||
|
||||
Object buildType = item.getProperty().getAdditionalProperties().get(BUILD_TYPE_PROPERTY);
|
||||
if (null == buildType) {
|
||||
item.getProperty().getAdditionalProperties().put(BUILD_TYPE_PROPERTY, BUILD_TYPE_ROUTE);
|
||||
try {
|
||||
save(item);
|
||||
modified |= true;
|
||||
generateReportRecord(
|
||||
new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, item,
|
||||
null, "Build Type", "null", BUILD_TYPE_OSGI));
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If no BUILD_TYPE is set then Default BUILD_TYPE must be ROUTE - Manage child
|
||||
* jobs for routes ( parent, target BUILD_TYPE = OSGI ) Else if BUILD_TYPE is
|
||||
* ROUTE - Manage child jobs for routes ( parent, target BUILD_TYPE = OSGI )
|
||||
* Else if BUILD_TYPE is ROUTE_MICROSERVICE -Manage child jobs for jobs (
|
||||
* parent, target BUILD_TYPE = STANDALONE )
|
||||
*/
|
||||
|
||||
String currentRouteBuildType = (String) item.getProperty().getAdditionalProperties().get(BUILD_TYPE_PROPERTY);
|
||||
|
||||
String currentRouteID = item.getProperty().getLabel();
|
||||
|
||||
IComponentFilter filter = new NameComponentFilter(C_TALEND_JOB);
|
||||
|
||||
List<NodeType> c = searchComponent(processType, filter);
|
||||
|
||||
if (!c.isEmpty()) {
|
||||
|
||||
for (NodeType cTalendJobComponent : c) {
|
||||
|
||||
String processID = findElementParameterByName("SELECTED_JOB_NAME:PROCESS_TYPE_PROCESS",
|
||||
cTalendJobComponent) == null ? null
|
||||
: findElementParameterByName("SELECTED_JOB_NAME:PROCESS_TYPE_PROCESS",
|
||||
cTalendJobComponent).getValue();
|
||||
String processVersion = findElementParameterByName("SELECTED_JOB_NAME:PROCESS_TYPE_VERSION",
|
||||
cTalendJobComponent) == null ? null
|
||||
: findElementParameterByName("SELECTED_JOB_NAME:PROCESS_TYPE_VERSION",
|
||||
cTalendJobComponent).getValue();
|
||||
|
||||
if (processID != null && processVersion != null) {
|
||||
ProcessItem childItem = ItemCacheManager.getProcessItem(processID, processVersion);
|
||||
Project childItemProject = ProjectManager.getInstance().getCurrentProject();
|
||||
|
||||
if (childItem == null) {
|
||||
for (Project refProject : ProjectManager.getInstance().getAllReferencedProjects()) {
|
||||
childItem = ItemCacheManager.getRefProcessItem(getProject(), processID);
|
||||
if (childItem != null) {
|
||||
childItemProject = refProject;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (childItem != null) {
|
||||
|
||||
Object currentChildBuildType = childItem.getProperty().getAdditionalProperties()
|
||||
.get(BUILD_TYPE_PROPERTY);
|
||||
|
||||
String jobID = childItem.getProperty().getLabel();
|
||||
|
||||
String currentChildBuildTypeStr = (null == currentChildBuildType) ? null
|
||||
: (String) currentChildBuildType;
|
||||
|
||||
if (BUILD_TYPE_ROUTE.equalsIgnoreCase(currentRouteBuildType)
|
||||
&& BUILD_TYPE_OSGI.equalsIgnoreCase(currentChildBuildTypeStr)) {
|
||||
storeMigratedModel(jobID, currentRouteID);
|
||||
}
|
||||
|
||||
if (BUILD_TYPE_ROUTE.equalsIgnoreCase(currentRouteBuildType)
|
||||
&& !BUILD_TYPE_OSGI.equalsIgnoreCase(currentChildBuildTypeStr)) {
|
||||
|
||||
try {
|
||||
if (isModelMigrated(jobID)) {
|
||||
ExceptionHandler.process(new RuntimeException(
|
||||
"Child Job is called by 2 or more different Routes which have different build types. Build type for child Job ["
|
||||
+ jobID + "] was previously updated to [" + currentChildBuildTypeStr
|
||||
+ "] to be compatible with parent Route ["
|
||||
+ getStoredMigratedModelParentRoute(jobID)
|
||||
+ "] which is not compatible with current parent Route ["
|
||||
+ currentRouteID + "] with build type [" + currentRouteBuildType
|
||||
+ "]. "));
|
||||
migrationFailure = true;
|
||||
continue;
|
||||
} else {
|
||||
|
||||
childItem.getProperty().getAdditionalProperties()
|
||||
.put(TalendProcessArgumentConstant.ARG_BUILD_TYPE, BUILD_TYPE_OSGI);
|
||||
|
||||
generateReportRecord(new MigrationReportRecorder(this,
|
||||
MigrationReportRecorder.MigrationOperationType.MODIFY, childItem, null,
|
||||
"Build Type", currentChildBuildTypeStr, BUILD_TYPE_OSGI));
|
||||
|
||||
|
||||
ProxyRepositoryFactory.getInstance().save(childItemProject, childItem, true);
|
||||
}
|
||||
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (BUILD_TYPE_ROUTE_MICROSERVICE.equalsIgnoreCase(currentRouteBuildType)
|
||||
&& !BUILD_TYPE_STANDALONE.equalsIgnoreCase(currentChildBuildTypeStr)) {
|
||||
|
||||
try {
|
||||
|
||||
if (isModelMigrated(jobID)) {
|
||||
ExceptionHandler.process(new RuntimeException(
|
||||
"Child Job is called by 2 or more different Routes which have different build types. Build type for child Job ["
|
||||
+ jobID + "] was previously updated to [" + currentChildBuildTypeStr
|
||||
+ "] to be compatible with parent Route ["
|
||||
+ getStoredMigratedModelParentRoute(jobID)
|
||||
+ "] which is not compatible with current parent Route ["
|
||||
+ currentRouteID + "] with build type [" + currentRouteBuildType
|
||||
+ "]. "));
|
||||
migrationFailure = true;
|
||||
continue;
|
||||
} else {
|
||||
|
||||
childItem.getProperty().getAdditionalProperties()
|
||||
.put(TalendProcessArgumentConstant.ARG_BUILD_TYPE, BUILD_TYPE_STANDALONE);
|
||||
|
||||
generateReportRecord(new MigrationReportRecorder(this,
|
||||
MigrationReportRecorder.MigrationOperationType.MODIFY, childItem, null,
|
||||
"Build Type", currentChildBuildTypeStr, BUILD_TYPE_STANDALONE));
|
||||
|
||||
ProxyRepositoryFactory.getInstance().save(childItemProject, childItem, true);
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!isModelMigrated(jobID)) {
|
||||
storeMigratedModel(jobID, currentRouteID);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (migrationFailure) {
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
}
|
||||
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
|
||||
}
|
||||
|
||||
protected void clearMigratedChildJobs() {
|
||||
migratedChildJobs.clear();
|
||||
}
|
||||
|
||||
protected void storeMigratedModel(String jobName, String parentRouteName) {
|
||||
migratedChildJobs.put(jobName, parentRouteName);
|
||||
}
|
||||
|
||||
protected boolean isModelMigrated(String jobName) {
|
||||
return migratedChildJobs.containsKey(jobName);
|
||||
}
|
||||
|
||||
protected String getStoredMigratedModelParentRoute(String jobName) {
|
||||
return migratedChildJobs.get(jobName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Synchronize build types for Routes (incuding child jobs)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
clearMigratedChildJobs();
|
||||
clearMigratedJobs();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package org.talend.designer.maven.migration.tasks;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.components.filters.IComponentFilter;
|
||||
import org.talend.core.model.components.filters.NameComponentFilter;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.designer.maven.migration.common.MigrationReportRecorder;
|
||||
|
||||
/*
|
||||
* Data service SOAP = Job with "tESBProviderRequest"
|
||||
* Set BUILD_TYPE as OSGI
|
||||
* Manage child jobs for jobs ( parent job, target BUILD_TYPE = OSGI )
|
||||
*/
|
||||
|
||||
public class CorrectBuildTypeForSOAPServiceJobMigrationTask extends AbstractDataServiceJobMigrationTask {
|
||||
|
||||
private static final String T_ESB_PROVIDER_REQUEST = "tESBProviderRequest";
|
||||
private static final String BUILD_TYPE_PROPERTY = "BUILD_TYPE";
|
||||
|
||||
private static final String BUILD_TYPE_OSGI = "OSGI";
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.migration.IMigrationTask#getOrder()
|
||||
*/
|
||||
@Override
|
||||
public Date getOrder() {
|
||||
GregorianCalendar gc = new GregorianCalendar(2021, 7, 25, 12, 0, 0);
|
||||
return gc.getTime();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.core.model.migration.AbstractDataserviceMigrationTask#execute(org
|
||||
* .talend.core.model.properties.Item)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public ExecutionResult execute(Item item) {
|
||||
final ProcessType processType = getProcessType(item);
|
||||
|
||||
boolean modified = false;
|
||||
|
||||
/*
|
||||
* If no BUILD_TYPE is set then default BUILD_TYPE must be OSGI
|
||||
*/
|
||||
|
||||
IComponentFilter filter = new NameComponentFilter(T_ESB_PROVIDER_REQUEST);
|
||||
|
||||
List<NodeType> c = searchComponent(processType, filter);
|
||||
|
||||
if (!c.isEmpty()) {
|
||||
Object originalBuildType = item.getProperty().getAdditionalProperties().get(BUILD_TYPE_PROPERTY);
|
||||
|
||||
if (null == originalBuildType || !BUILD_TYPE_OSGI.equalsIgnoreCase(originalBuildType.toString())) {
|
||||
item.getProperty().getAdditionalProperties().put(BUILD_TYPE_PROPERTY, BUILD_TYPE_OSGI);
|
||||
try {
|
||||
save(item);
|
||||
modified |= true;
|
||||
generateReportRecord(new MigrationReportRecorder(this,
|
||||
MigrationReportRecorder.MigrationOperationType.MODIFY, item, null, "Build Type",
|
||||
(null == originalBuildType) ? null : originalBuildType.toString(), BUILD_TYPE_OSGI));
|
||||
storeMigratedJob(item.getProperty().getLabel(), this.getClass().getName());
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
} else if (BUILD_TYPE_OSGI.equalsIgnoreCase((String)originalBuildType)){
|
||||
// current job has correct build type
|
||||
// skip this job during next migrations
|
||||
skipMigrationForJob(item.getProperty().getLabel(), this.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
}
|
||||
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Synchronize build types for SOAP service Jobs";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear () {
|
||||
clearMigratedJobs();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.talend.designer.maven.migration.tasks;
|
||||
|
||||
import org.talend.migration.IProjectMigrationTask;
|
||||
|
||||
public interface ICorrectBuildTypeMigrationTask extends IProjectMigrationTask {
|
||||
public void clear ();
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package org.talend.designer.maven.tools;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.designer.maven.migration.common.MigrationReportHelper;
|
||||
import org.talend.designer.maven.migration.tasks.CorrectBuildTypeForDIJobMigrationTask;
|
||||
import org.talend.designer.maven.migration.tasks.CorrectBuildTypeForDsRestMigrationTask;
|
||||
import org.talend.designer.maven.migration.tasks.CorrectBuildTypeForRoutesMigrationTask;
|
||||
import org.talend.designer.maven.migration.tasks.CorrectBuildTypeForSOAPServiceJobMigrationTask;
|
||||
import org.talend.designer.maven.migration.tasks.ICorrectBuildTypeMigrationTask;
|
||||
import org.talend.migration.IMigrationTask;
|
||||
import org.talend.migration.IProjectMigrationTask;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.RepositoryWorkUnit;
|
||||
|
||||
public class BuildTypeManager {
|
||||
|
||||
private ICorrectBuildTypeMigrationTask[] syncBuildTypeMigrationTasks = {
|
||||
new CorrectBuildTypeForRoutesMigrationTask(), new CorrectBuildTypeForSOAPServiceJobMigrationTask(),
|
||||
new CorrectBuildTypeForDsRestMigrationTask(), new CorrectBuildTypeForDIJobMigrationTask() };
|
||||
|
||||
|
||||
private boolean hasErrors = false;
|
||||
|
||||
public void syncBuildTypes(FieldEditorPreferencePage page) throws Exception {
|
||||
|
||||
IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
|
||||
RepositoryWorkUnit<Object> workUnit = new RepositoryWorkUnit<Object>("Synchronize all build types") { //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
protected void run() {
|
||||
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(final IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
syncAllBuildTypesWithProgress(monitor, page);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
try {
|
||||
ISchedulingRule schedulingRule = workspace.getRoot();
|
||||
workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
|
||||
} catch (CoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
workUnit.setAvoidUnloadResources(true);
|
||||
ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(workUnit);
|
||||
}
|
||||
};
|
||||
|
||||
hasErrors = false;
|
||||
|
||||
new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, true, runnableWithProgress);
|
||||
|
||||
if (hasErrors) {
|
||||
page.setErrorMessage("Build types synchronization finished with errors. Check workspace logs for details.");
|
||||
} else {
|
||||
page.setErrorMessage(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void syncAllBuildTypesWithProgress(IProgressMonitor monitor, FieldEditorPreferencePage page)
|
||||
throws Exception {
|
||||
|
||||
Project project = ProjectManager.getInstance().getCurrentProject();
|
||||
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, syncBuildTypeMigrationTasks.length);
|
||||
|
||||
for (ICorrectBuildTypeMigrationTask task : syncBuildTypeMigrationTasks) {
|
||||
task.clear();
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (ICorrectBuildTypeMigrationTask task : syncBuildTypeMigrationTasks) {
|
||||
subMonitor.beginTask(task.getDescription(), syncBuildTypeMigrationTasks.length);
|
||||
IMigrationTask.ExecutionResult result = task.execute(project);
|
||||
if (IMigrationTask.ExecutionResult.FAILURE.equals(result)) {
|
||||
hasErrors = true;
|
||||
}
|
||||
subMonitor.worked(1);
|
||||
|
||||
}
|
||||
|
||||
subMonitor.beginTask("Generate migration report", syncBuildTypeMigrationTasks.length);
|
||||
MigrationReportHelper.getInstance().generateMigrationReport(project.getTechnicalLabel());
|
||||
|
||||
monitor.done();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@
|
||||
<!-- same as xercesImpl.jar-->
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<version>2.12.0</version>
|
||||
<version>2.12.2</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.apache.ws.xmlschema</groupId>
|
||||
|
||||
Reference in New Issue
Block a user