fix(TUP-24625):implement lazy migration. (#2863)
* fix(TUP-24625):When/If lazy migration will be done following fix won't be needed anymore on TUP-21055 . * fix(TUP-24625):remove migration code when start-up if implement lazy migration. * fix(TUP-24625):improve to implement lazy migration.
This commit is contained in:
@@ -15,6 +15,7 @@ package org.talend.commons.runtime.service;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.osgi.framework.BundleContext;
|
||||
@@ -39,9 +40,7 @@ public interface ITaCoKitService {
|
||||
|
||||
boolean isTaCoKitCar(File file, IProgressMonitor monitor) throws Exception;
|
||||
|
||||
boolean isNeedMigration(String projectLabel) throws Exception;
|
||||
|
||||
void checkMigration(final IProgressMonitor monitor) throws Exception;
|
||||
boolean isNeedMigration(String componentName, Map<String, String> properties);
|
||||
|
||||
public static ITaCoKitService getInstance() throws Exception {
|
||||
BundleContext bc = FrameworkUtil.getBundle(ITaCoKitService.class).getBundleContext();
|
||||
|
||||
@@ -29,8 +29,6 @@ public interface FileConstants {
|
||||
|
||||
String RELATIONSHIP_FILE_NAME = "relationship.index"; //$NON-NLS-1$
|
||||
|
||||
String COMPONENT_FILE_NAME = "component.index"; //$NON-NLS-1$
|
||||
|
||||
String TALEND_RECYCLE_BIN_INDEX = "recycle_bin.index"; //$NON-NLS-1$
|
||||
|
||||
String MIGRATION_TASK_FILE_NAME = "migration_task.index"; //$NON-NLS-1$
|
||||
|
||||
@@ -2228,18 +2228,6 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
tdqRepositoryService.initProxyRepository();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute TaCoKit migration before fullLogonFinished
|
||||
*/
|
||||
try {
|
||||
ITaCoKitService tacokitService = ITaCoKitService.getInstance();
|
||||
if (tacokitService != null && tacokitService.isNeedMigration(project.getTechnicalLabel())) {
|
||||
tacokitService.checkMigration(monitor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
fullLogonFinished = true;
|
||||
this.repositoryFactoryFromProvider.afterLogon(monitor);
|
||||
} finally {
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.repository.utils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* DOC jding class global comment. Detailled comment
|
||||
*/
|
||||
public class ComponentsJsonModel {
|
||||
|
||||
@JsonProperty("id")
|
||||
private String id;
|
||||
|
||||
@JsonProperty("version")
|
||||
private String version;
|
||||
|
||||
@JsonProperty("parentId")
|
||||
private String parentId;
|
||||
|
||||
@JsonProperty("configurationType")
|
||||
private String configurationType;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@JsonProperty("displayName")
|
||||
private String displayName;
|
||||
|
||||
@JsonProperty("edges")
|
||||
private Set edges;
|
||||
|
||||
@JsonProperty("properties")
|
||||
private List properties;
|
||||
|
||||
@JsonProperty("actions")
|
||||
private Object actions;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getConfigurationType() {
|
||||
return configurationType;
|
||||
}
|
||||
|
||||
public void setConfigurationType(String configurationType) {
|
||||
this.configurationType = configurationType;
|
||||
}
|
||||
|
||||
public Set getEdges() {
|
||||
return edges;
|
||||
}
|
||||
|
||||
public void setEdges(Set edges) {
|
||||
this.edges = edges;
|
||||
}
|
||||
|
||||
public List getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(List properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public Object getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public void setActions(Object actions) {
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,13 +18,10 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -106,54 +103,6 @@ public class ProjectDataJsonProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveConfigComponent(String projectLabel, List<ComponentsJsonModel> componentJsons)
|
||||
throws PersistenceException {
|
||||
Collections.sort(componentJsons, new Comparator<ComponentsJsonModel>() {
|
||||
|
||||
@Override
|
||||
public int compare(ComponentsJsonModel configTypeNode1, ComponentsJsonModel configTypeNode2) {
|
||||
return configTypeNode1.getId().compareTo(configTypeNode2.getId());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
File file = getSavingConfigurationFile(projectLabel, FileConstants.COMPONENT_FILE_NAME);
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.writerWithDefaultPrettyPrinter().writeValue(file, componentJsons);
|
||||
ResourceUtils.getProject(projectLabel).getFolder(FileConstants.SETTINGS_FOLDER_NAME).refreshLocal(1, null);
|
||||
} catch (Exception e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String[]> getLastConfigComponent(String projectLabel) throws PersistenceException {
|
||||
Map<String, String[]> componentMap = new HashMap<>();
|
||||
File file = getSavingConfigurationFile(projectLabel, FileConstants.COMPONENT_FILE_NAME);
|
||||
TypeReference<List<ComponentsJsonModel>> typeReference = new TypeReference<List<ComponentsJsonModel>>() {
|
||||
};
|
||||
List<ComponentsJsonModel> componentsJsons = null;
|
||||
if (file != null && file.exists()) {
|
||||
try {
|
||||
FileInputStream input = new FileInputStream(file);
|
||||
componentsJsons = new ObjectMapper().readValue(input, typeReference);
|
||||
} catch (IOException e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
if (componentsJsons != null && componentsJsons.size() > 0) {
|
||||
for (ComponentsJsonModel component : componentsJsons) {
|
||||
String[] content = new String[] { component.getName(), component.getVersion(), component.getDisplayName() };
|
||||
componentMap.put(component.getId(), content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return componentMap;
|
||||
}
|
||||
|
||||
public static void loadProjectData(Project project, IPath projectFolderPath, int loadContent) throws PersistenceException {
|
||||
if ((loadContent & CONTENT_PROJECTSETTING) > 0) {
|
||||
loadProjectSettings(project, projectFolderPath);
|
||||
@@ -166,8 +115,8 @@ public class ProjectDataJsonProvider {
|
||||
RecycleBinManager.getInstance().clearCache(project);
|
||||
RecycleBin recycleBin = RecycleBinManager.getInstance().getRecycleBin(project);
|
||||
project.getDeletedFolders().clear();
|
||||
for (int i = 0; i < recycleBin.getDeletedFolders().size(); i++) {
|
||||
project.getDeletedFolders().add(recycleBin.getDeletedFolders().get(i));
|
||||
for (String element : recycleBin.getDeletedFolders()) {
|
||||
project.getDeletedFolders().add(element);
|
||||
}
|
||||
}
|
||||
if ((loadContent & CONTENT_MIGRATIONTASK) > 0) {
|
||||
@@ -285,8 +234,8 @@ public class ProjectDataJsonProvider {
|
||||
if (migrationTaskSetting != null) {
|
||||
MigrationTask fakeTask = createFakeMigrationTask();
|
||||
MigrationTask existingFakeTask = null;
|
||||
for (int i = 0; i < project.getMigrationTask().size(); i++) {
|
||||
MigrationTask task = (MigrationTask) project.getMigrationTask().get(i);
|
||||
for (Object element : project.getMigrationTask()) {
|
||||
MigrationTask task = (MigrationTask) element;
|
||||
if (StringUtils.equals(fakeTask.getId(), task.getId())) {
|
||||
existingFakeTask = task;
|
||||
break;
|
||||
@@ -471,8 +420,8 @@ public class ProjectDataJsonProvider {
|
||||
protected static List<StatusJson> getTechnicalStatusJson(List technicalStatus) {
|
||||
if (technicalStatus != null && technicalStatus.size() > 0) {
|
||||
List<StatusJson> list = new ArrayList<StatusJson>(technicalStatus.size());
|
||||
for (int i = 0; i < technicalStatus.size(); i++) {
|
||||
StatusJson json = new StatusJson((Status) technicalStatus.get(i));
|
||||
for (Object technicalStatu : technicalStatus) {
|
||||
StatusJson json = new StatusJson((Status) technicalStatu);
|
||||
list.add(json);
|
||||
}
|
||||
return list;
|
||||
@@ -492,8 +441,8 @@ public class ProjectDataJsonProvider {
|
||||
protected static List<StatusJson> getDocumentationJson(List documentationStatus) {
|
||||
if (documentationStatus != null && documentationStatus.size() > 0) {
|
||||
List<StatusJson> list = new ArrayList<StatusJson>(documentationStatus.size());
|
||||
for (int i = 0; i < documentationStatus.size(); i++) {
|
||||
StatusJson json = new StatusJson((Status) documentationStatus.get(i));
|
||||
for (Object documentationStatu : documentationStatus) {
|
||||
StatusJson json = new StatusJson((Status) documentationStatu);
|
||||
list.add(json);
|
||||
}
|
||||
return list;
|
||||
@@ -513,8 +462,8 @@ public class ProjectDataJsonProvider {
|
||||
protected static List<ItemRelationsJson> getItemRelationsJson(List itemsRelations) {
|
||||
if (itemsRelations.size() > 0) {
|
||||
List<ItemRelationsJson> list = new ArrayList<ItemRelationsJson>(itemsRelations.size());
|
||||
for (int i = 0; i < itemsRelations.size(); i++) {
|
||||
ItemRelations relations = (ItemRelations) itemsRelations.get(i);
|
||||
for (Object itemsRelation : itemsRelations) {
|
||||
ItemRelations relations = (ItemRelations) itemsRelation;
|
||||
ItemRelationsJson json = new ItemRelationsJson(relations);
|
||||
list.add(json);
|
||||
}
|
||||
@@ -639,16 +588,16 @@ class ParametersTypeJson {
|
||||
public ParametersTypeJson(ParametersType parametersType) {
|
||||
if (parametersType.getElementParameter().size() > 0) {
|
||||
elementParameters = new ArrayList<ElementParameterTypeJson>();
|
||||
for (int i = 0; i < parametersType.getElementParameter().size(); i++) {
|
||||
ElementParameterType type = (ElementParameterType) parametersType.getElementParameter().get(i);
|
||||
for (Object element : parametersType.getElementParameter()) {
|
||||
ElementParameterType type = (ElementParameterType) element;
|
||||
ElementParameterTypeJson typeJson = new ElementParameterTypeJson(type);
|
||||
elementParameters.add(typeJson);
|
||||
}
|
||||
}
|
||||
if (parametersType.getRoutinesParameter().size() > 0) {
|
||||
routinesParameters = new ArrayList<RoutinesParameterTypeJson>();
|
||||
for (int i = 0; i < parametersType.getRoutinesParameter().size(); i++) {
|
||||
RoutinesParameterType type = (RoutinesParameterType) parametersType.getRoutinesParameter().get(i);
|
||||
for (Object element : parametersType.getRoutinesParameter()) {
|
||||
RoutinesParameterType type = (RoutinesParameterType) element;
|
||||
RoutinesParameterTypeJson typeJson = new RoutinesParameterTypeJson(type);
|
||||
routinesParameters.add(typeJson);
|
||||
}
|
||||
@@ -722,8 +671,8 @@ class ElementParameterTypeJson {
|
||||
this.isShow = type.isShow();
|
||||
if (type.getElementValue().size() > 0) {
|
||||
elementValues = new ArrayList<ElementValueTypeJson>();
|
||||
for (int i = 0; i < type.getElementValue().size(); i++) {
|
||||
ElementValueType value = (ElementValueType) type.getElementValue().get(i);
|
||||
for (Object element : type.getElementValue()) {
|
||||
ElementValueType value = (ElementValueType) element;
|
||||
ElementValueTypeJson valueJson = new ElementValueTypeJson(value);
|
||||
elementValues.add(valueJson);
|
||||
}
|
||||
@@ -953,8 +902,8 @@ class ItemRelationsJson {
|
||||
}
|
||||
if (relations.getRelatedItems().size() > 0) {
|
||||
relatedItems = new ArrayList<ItemRelationJson>(relations.getRelatedItems().size());
|
||||
for (int i = 0; i < relations.getRelatedItems().size(); i++) {
|
||||
relatedItems.add(new ItemRelationJson((ItemRelation) relations.getRelatedItems().get(i)));
|
||||
for (Object element : relations.getRelatedItems()) {
|
||||
relatedItems.add(new ItemRelationJson((ItemRelation) element));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1101,8 +1050,8 @@ class MigrationTaskSetting {
|
||||
if (project != null) {
|
||||
if (project.getMigrationTask().size() > 0) {
|
||||
migrationTaskList = new ArrayList<MigrationTaskJson>();
|
||||
for (int i = 0; i < project.getMigrationTask().size(); i++) {
|
||||
MigrationTask task = (MigrationTask) project.getMigrationTask().get(i);
|
||||
for (Object element : project.getMigrationTask()) {
|
||||
MigrationTask task = (MigrationTask) element;
|
||||
migrationTaskList.add(new MigrationTaskJson(task));
|
||||
}
|
||||
migrationTaskList.sort(new Comparator<MigrationTaskJson>() {
|
||||
@@ -1119,8 +1068,8 @@ class MigrationTaskSetting {
|
||||
}
|
||||
if (project.getMigrationTasks().size() > 0) {
|
||||
migrationTasksList = new ArrayList<String>();
|
||||
for (int i = 0; i < project.getMigrationTasks().size(); i++) {
|
||||
String task = (String) project.getMigrationTasks().get(i);
|
||||
for (Object element : project.getMigrationTasks()) {
|
||||
String task = (String) element;
|
||||
migrationTasksList.add(task);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user