Compare commits
30 Commits
patch/7.3.
...
undx/TDI-4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d23acac28 | ||
|
|
08c2082e8a | ||
|
|
8740f3b1da | ||
|
|
e08c225198 | ||
|
|
fef6605f83 | ||
|
|
af83d9d393 | ||
|
|
45a92717f9 | ||
|
|
7191b77c5c | ||
|
|
903c239444 | ||
|
|
071777f408 | ||
|
|
a5c9ecb967 | ||
|
|
18c2e53223 | ||
|
|
16fbcf34f3 | ||
|
|
495ebda155 | ||
|
|
8f36da5ee1 | ||
|
|
0828f2951a | ||
|
|
5da999c4bd | ||
|
|
39eee08210 | ||
|
|
1ab6486d9a | ||
|
|
aa7da99e0d | ||
|
|
a73f8621ed | ||
|
|
09cfc769da | ||
|
|
2a1d017208 | ||
|
|
1189973653 | ||
|
|
c80a96768e | ||
|
|
0e3957c3d7 | ||
|
|
e7399f9df5 | ||
|
|
7f67aeaf0e | ||
|
|
d12826089a | ||
|
|
2bb3e43bc6 |
@@ -111,7 +111,8 @@ public class CommonsPlugin implements BundleActivator {
|
||||
}
|
||||
|
||||
public static boolean isDebugMode() {
|
||||
return ArrayUtils.contains(Platform.getApplicationArgs(), TalendDebugHandler.TALEND_DEBUG);
|
||||
return Boolean.getBoolean("talendDebug") //$NON-NLS-1$
|
||||
|| ArrayUtils.contains(Platform.getApplicationArgs(), TalendDebugHandler.TALEND_DEBUG);
|
||||
}
|
||||
|
||||
public static boolean isJUnitTest() {
|
||||
|
||||
@@ -117,6 +117,7 @@ public class JobAndNodesParametersRelationshipHandler implements IItemRelationsh
|
||||
}
|
||||
}
|
||||
}
|
||||
relationsMap.values().removeIf(value -> value.isEmpty());
|
||||
return relationsMap;
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ package org.talend.core.repository.handlers;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.talend.core.model.properties.Item;
|
||||
@@ -43,8 +44,13 @@ public class JobRoutinesItemRelationshipHandler extends AbstractJobItemRelations
|
||||
Set<Relation> relationSet = new HashSet<Relation>();
|
||||
|
||||
if (processType.getParameters() != null && processType.getParameters().getRoutinesParameter() != null) {
|
||||
Map<String, String> currentSystemRoutinesMap = RelationshipItemBuilder.getInstance().getCurrentSystemRoutinesMap();
|
||||
for (Object o : processType.getParameters().getRoutinesParameter()) {
|
||||
RoutinesParameterType itemInfor = (RoutinesParameterType) o;
|
||||
if (currentSystemRoutinesMap.containsValue(itemInfor.getName())) {
|
||||
// exclude system routines relation
|
||||
continue;
|
||||
}
|
||||
|
||||
Relation addedRelation = new Relation();
|
||||
addedRelation.setId(itemInfor.getName());
|
||||
|
||||
@@ -108,6 +108,7 @@ import org.talend.core.model.properties.SpagoBiServer;
|
||||
import org.talend.core.model.properties.Status;
|
||||
import org.talend.core.model.properties.User;
|
||||
import org.talend.core.model.properties.impl.FolderItemImpl;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.Folder;
|
||||
import org.talend.core.model.repository.IRepositoryContentHandler;
|
||||
@@ -123,6 +124,7 @@ import org.talend.core.repository.constants.Constant;
|
||||
import org.talend.core.repository.constants.FileConstants;
|
||||
import org.talend.core.repository.i18n.Messages;
|
||||
import org.talend.core.repository.recyclebin.RecycleBinManager;
|
||||
import org.talend.core.repository.utils.ProjectDataJsonProvider;
|
||||
import org.talend.core.repository.utils.RepositoryPathProvider;
|
||||
import org.talend.core.repository.utils.XmiResourceManager;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
@@ -2063,6 +2065,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, MAX_TASKS);
|
||||
SubMonitor currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.logonInProgress"), 1); //$NON-NLS-1$
|
||||
|
||||
project.setReferenceProjectProvider(null);
|
||||
getRepositoryContext().setProject(null);
|
||||
initEmfProjectContent();
|
||||
@@ -2081,6 +2084,8 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
ProjectManager.getInstance().getBeforeLogonRecords().clear();
|
||||
ProjectManager.getInstance().getUpdatedRemoteHandlerRecords().clear();
|
||||
|
||||
ProjectDataJsonProvider.checkAndRectifyRelationShipSetting(project.getEmfProject());
|
||||
|
||||
// init dynamic distirbution after `beforeLogon`, before loading libraries.
|
||||
initDynamicDistribution(monitor);
|
||||
|
||||
@@ -2245,6 +2250,11 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
tdqRepositoryService.initProxyRepository();
|
||||
}
|
||||
}
|
||||
// regenerate relationship index
|
||||
if (project.getEmfProject().getItemsRelations().isEmpty()) {
|
||||
RelationshipItemBuilder.getInstance().buildAndSaveIndex();
|
||||
}
|
||||
|
||||
fullLogonFinished = true;
|
||||
this.repositoryFactoryFromProvider.afterLogon(monitor);
|
||||
} finally {
|
||||
|
||||
@@ -106,7 +106,8 @@ public class RecycleBinManager {
|
||||
List<IRepositoryViewObject> deletedObjects = new ArrayList<IRepositoryViewObject>();
|
||||
final EList<TalendItem> deletedItems = projectRecyclebins.get(project.getTechnicalLabel()).getDeletedItems();
|
||||
List<TalendItem> notDeletedItems = new ArrayList<TalendItem>();
|
||||
for (TalendItem deletedItem : deletedItems) {
|
||||
List<TalendItem> dup_deletedItems = new ArrayList<>(deletedItems);
|
||||
for (TalendItem deletedItem : dup_deletedItems) {
|
||||
try {
|
||||
final ERepositoryObjectType type = ERepositoryObjectType.getType(deletedItem.getType());
|
||||
// ignore the generated doc in recycle bin
|
||||
@@ -274,7 +275,8 @@ public class RecycleBinManager {
|
||||
resource = createRecycleBinResource(project);
|
||||
}
|
||||
resource.getContents().clear();
|
||||
recycleBin.setLastUpdate(new Date());
|
||||
// set date to null to avoid timezone conflict
|
||||
recycleBin.setLastUpdate(null);
|
||||
resource.getContents().add(recycleBin);
|
||||
EmfHelper.saveResource(resource);
|
||||
lastSavedRecycleBinMap.put(recycleBin, EcoreUtil.copy(recycleBin));
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Comparator;
|
||||
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;
|
||||
@@ -32,6 +33,7 @@ import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.model.properties.ImplicitContextSettings;
|
||||
@@ -43,6 +45,7 @@ import org.talend.core.model.properties.Project;
|
||||
import org.talend.core.model.properties.StatAndLogsSettings;
|
||||
import org.talend.core.model.properties.Status;
|
||||
import org.talend.core.model.properties.impl.PropertiesFactoryImpl;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.repository.constants.FileConstants;
|
||||
import org.talend.core.repository.recyclebin.RecycleBinManager;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
@@ -140,9 +143,10 @@ public class ProjectDataJsonProvider {
|
||||
ProjectDataJsonProvider.loadProjectSettings(project, input);
|
||||
}
|
||||
IPath relationShipPath = settingFolderPath.append(FileConstants.RELATIONSHIP_FILE_NAME);
|
||||
input = inputStreamProvider.getStream(relationShipPath);
|
||||
if (input != null) {
|
||||
ProjectDataJsonProvider.loadRelationShips(project, input);
|
||||
try (InputStream is = inputStreamProvider.getStream(relationShipPath)) {
|
||||
if (is != null) {
|
||||
ProjectDataJsonProvider.loadRelationShips(project, is);
|
||||
}
|
||||
}
|
||||
IPath migrationTaskPath = settingFolderPath.append(FileConstants.MIGRATION_TASK_FILE_NAME);
|
||||
input = inputStreamProvider.getStream(migrationTaskPath);
|
||||
@@ -184,10 +188,11 @@ public class ProjectDataJsonProvider {
|
||||
private static void loadRelationShips(Project project, IPath projectFolderPath) throws PersistenceException {
|
||||
File file = getLoadingConfigurationFile(projectFolderPath, FileConstants.RELATIONSHIP_FILE_NAME);
|
||||
if (file != null && file.exists()) {
|
||||
try {
|
||||
loadRelationShips(project, new FileInputStream(file));
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new PersistenceException(e);
|
||||
try (FileInputStream fis = new FileInputStream(file)) {
|
||||
loadRelationShips(project, fis);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,11 +211,72 @@ public class ProjectDataJsonProvider {
|
||||
project.getItemsRelations().add(json.toEmfObject());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkAndRectifyRelationShipSetting(Project project) throws PersistenceException {
|
||||
File file = getSavingConfigurationFile(project.getTechnicalLabel(), FileConstants.RELATIONSHIP_FILE_NAME);
|
||||
if (file == null || !file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<ItemRelationsJson> itemRelationsJsonsList = null;
|
||||
TypeReference<List<ItemRelationsJson>> typeReference = new TypeReference<List<ItemRelationsJson>>() {
|
||||
};
|
||||
FileInputStream input = null;
|
||||
try {
|
||||
input = new FileInputStream(file);
|
||||
itemRelationsJsonsList = new ObjectMapper().readValue(new FileInputStream(file), typeReference);
|
||||
} catch (Exception e) {
|
||||
throw new PersistenceException(e);
|
||||
} finally {
|
||||
closeInputStream(input);
|
||||
}
|
||||
|
||||
if (itemRelationsJsonsList == null || itemRelationsJsonsList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> idVersionSet = new HashSet<String>();
|
||||
List<ItemRelationsJson> relationJsonList = new ArrayList<ItemRelationsJson>();
|
||||
Map<String, String> currentSystemRoutinesMap = RelationshipItemBuilder.getInstance().getCurrentSystemRoutinesMap();
|
||||
boolean needModify = false;
|
||||
for (ItemRelationsJson relationJson : itemRelationsJsonsList) {
|
||||
ItemRelationJson baseItem = relationJson.getBaseItem();
|
||||
String idversion = baseItem.getId() + ";" + baseItem.getVersion();
|
||||
if (idVersionSet.contains(idversion)) {
|
||||
// in case duplicate
|
||||
needModify = true;
|
||||
continue;
|
||||
}
|
||||
// remove system routines relation
|
||||
int originalSize = relationJson.getRelatedItems().size();
|
||||
relationJson.getRelatedItems()
|
||||
.removeIf(relatedItem -> RelationshipItemBuilder.ROUTINE_RELATION.equals(relatedItem.getType())
|
||||
&& currentSystemRoutinesMap.containsValue(relatedItem.getId()));
|
||||
if (relationJson.getRelatedItems().size() != originalSize) {
|
||||
needModify = true;
|
||||
}
|
||||
if (!relationJson.getRelatedItems().isEmpty()) {
|
||||
relationJsonList.add(relationJson);
|
||||
}
|
||||
idVersionSet.add(idversion);
|
||||
}
|
||||
|
||||
if (needModify) {
|
||||
// re-load to project
|
||||
if (relationJsonList != null && !relationJsonList.isEmpty()) {
|
||||
project.getItemsRelations().clear();
|
||||
for (ItemRelationsJson json : relationJsonList) {
|
||||
project.getItemsRelations().add(json.toEmfObject());
|
||||
}
|
||||
}
|
||||
// re-save relationship setting json file
|
||||
saveRelationShips(project);
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadMigrationTaskSetting(Project project, IPath projectFolderPath) throws PersistenceException {
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<dbType type="SET" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TEXT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TIME" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TIMESTAMP" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TIMESTAMP" ignoreLen="true" ignorePre="false" />
|
||||
<dbType type="TINYBLOB" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TINYINT" ignorePre="true" />
|
||||
<dbType type="TINYINT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<dbType type="CHAR" defaultLength="50" ignorePre="true"/>
|
||||
<dbType type="CHARACTER" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="CHARACTER VARYING" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="DATE" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="DATE" ignoreLen="true" ignorePre="true" defaultPattern="dd-MM-yyyy" />
|
||||
<dbType type="DATETIME" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="DECIMAL" defaultLength="20" defaultPrecision="10" />
|
||||
<dbType type="DOUBLE PRECISION" ignoreLen="true" ignorePre="true" />
|
||||
|
||||
@@ -100,6 +100,11 @@
|
||||
<xs:restriction base="xs:short"/>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="defaultPattern">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string"/>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="default" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
@@ -214,5 +214,5 @@ public interface ITDQRepositoryService extends IService {
|
||||
/**
|
||||
* @param chooseContext the context name which want to swtich
|
||||
*/
|
||||
void popupSwitchContextFailedMessage(String chooseContext);
|
||||
boolean popupSwitchContextFailedMessage(String chooseContext);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -341,7 +341,8 @@ public class JobContextManager implements IContextManager {
|
||||
|
||||
String repositoryContextId = contextParamType.getRepositoryContextId();
|
||||
String source = IContextParameter.BUILT_IN;
|
||||
if (repositoryContextId != null && !"".equals(repositoryContextId)) { //$NON-NLS-1$
|
||||
if (repositoryContextId != null && !"".equals(repositoryContextId) //$NON-NLS-1$
|
||||
&& !IContextParameter.BUILT_IN.equals(repositoryContextId)) {
|
||||
Item item = ContextUtils.getContextItemById(contextItemList, repositoryContextId);
|
||||
if (item == null) {
|
||||
item = ContextUtils.getRepositoryContextItemById(repositoryContextId);
|
||||
@@ -585,15 +586,16 @@ public class JobContextManager implements IContextManager {
|
||||
contextParamType.setRepositoryContextId(contextId);
|
||||
}
|
||||
}
|
||||
} else if (useInternalId) {
|
||||
} else {
|
||||
contextParamType.setRepositoryContextId(contextParam.getSource());
|
||||
}
|
||||
if (useInternalId) {
|
||||
String internalId = contextParam.getInternalId();
|
||||
if (StringUtils.isEmpty(internalId)) {
|
||||
internalId = EcoreUtil.generateUUID();
|
||||
contextParamType.setInternalId(internalId);
|
||||
contextParam.setInternalId(internalId);
|
||||
} else {
|
||||
contextParamType.setInternalId(internalId);
|
||||
}
|
||||
contextParamType.setInternalId(internalId);
|
||||
}
|
||||
}
|
||||
contextTypeParamList.clear(); // remove old
|
||||
|
||||
@@ -39,7 +39,8 @@ public abstract class AbstractItemContextLinkService implements IItemContextLink
|
||||
return saveContextLink(contextTypeList, item, backupContextLink, remoteContextLink);
|
||||
}
|
||||
|
||||
private synchronized boolean saveContextLink(List<ContextType> contextTypeList, Item item, ItemContextLink backupContextLink, ItemContextLink remoteContextLink)
|
||||
public synchronized boolean saveContextLink(List<ContextType> contextTypeList, Item item,
|
||||
ItemContextLink backupContextLink, ItemContextLink remoteContextLink)
|
||||
throws PersistenceException {
|
||||
boolean hasLinkFile = false;
|
||||
String itemId = item.getProperty().getId();
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.talend.core.model.metadata;
|
||||
|
||||
public class DbDefaultDatePattern {
|
||||
private String defaultPattern;
|
||||
private String dbTypeName;
|
||||
|
||||
public DbDefaultDatePattern() {
|
||||
|
||||
}
|
||||
|
||||
public String getDefaultPattern() {
|
||||
return defaultPattern;
|
||||
}
|
||||
|
||||
public void setDefaultPattern(String defaultPattern) {
|
||||
this.defaultPattern = defaultPattern;
|
||||
}
|
||||
|
||||
public String getDbTypeName() {
|
||||
return dbTypeName;
|
||||
}
|
||||
|
||||
public void setDbTypeName(String dbTypeName) {
|
||||
this.dbTypeName = dbTypeName;
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,8 @@ public class Dbms {
|
||||
private Set<MappingType> talendToDbTypes;
|
||||
|
||||
private List<DbDefaultLengthAndPrecision> defaultLengthPrecision;
|
||||
|
||||
private List<DbDefaultDatePattern> defaultPattern;
|
||||
|
||||
private List<DbIgnoreLengthAndPrecision> ignoreLengthPrecision;
|
||||
|
||||
@@ -62,6 +64,14 @@ public class Dbms {
|
||||
List<DbDefaultLengthAndPrecision> defaultLengthPrecision) {
|
||||
this.defaultLengthPrecision = defaultLengthPrecision;
|
||||
}
|
||||
public List<DbDefaultDatePattern> getDefaultPattern() {
|
||||
return defaultPattern;
|
||||
}
|
||||
|
||||
public void setDefaultPattern(
|
||||
List<DbDefaultDatePattern> defaultLengthPrecision) {
|
||||
this.defaultPattern = defaultLengthPrecision;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC amaumont Dbms constructor comment.
|
||||
|
||||
@@ -125,10 +125,12 @@ public class MappingFileLoader {
|
||||
// search and load preBeforelen nodes
|
||||
ArrayList<String> dbTypes = new ArrayList<String>();
|
||||
ArrayList<DbDefaultLengthAndPrecision> dbDefault = new ArrayList<DbDefaultLengthAndPrecision>();
|
||||
ArrayList<DbDefaultDatePattern> dbDefaultPattern = new ArrayList<DbDefaultDatePattern>();
|
||||
ArrayList<DbIgnoreLengthAndPrecision> dbIgnore = new ArrayList<DbIgnoreLengthAndPrecision>();
|
||||
ArrayList<DbPreBeforeLength> dbPbeforeLList = new ArrayList<DbPreBeforeLength>();
|
||||
dbms.setDbmsTypes(dbTypes);
|
||||
dbms.setDefaultLengthPrecision(dbDefault);
|
||||
dbms.setDefaultPattern(dbDefaultPattern);
|
||||
dbms.setIgnoreLengthPrecision(dbIgnore);
|
||||
dbms.setPrebeforelength(dbPbeforeLList);
|
||||
List<Node> typeNodes = getChildElementNodes(dbTypesNode);
|
||||
@@ -149,19 +151,25 @@ public class MappingFileLoader {
|
||||
dbTypes.add(typeValue);
|
||||
hAllDbTypes.add(typeValue);
|
||||
DbDefaultLengthAndPrecision dbDefaultLP = new DbDefaultLengthAndPrecision();
|
||||
DbDefaultDatePattern dbDefaultPt = new DbDefaultDatePattern();
|
||||
DbIgnoreLengthAndPrecision dbIgnoreLP = new DbIgnoreLengthAndPrecision();
|
||||
DbPreBeforeLength dbPBeforeL = new DbPreBeforeLength();
|
||||
// default length and precision
|
||||
Node defaultLengthItem = typeNodeAtttributes.getNamedItem("defaultLength"); //$NON-NLS-1$
|
||||
Node defaultPrecision = typeNodeAtttributes.getNamedItem("defaultPrecision"); //$NON-NLS-1$
|
||||
Node defaultPattern = typeNodeAtttributes.getNamedItem("defaultPattern"); //$NON-NLS-1$
|
||||
|
||||
if (defaultLengthItem != null)
|
||||
dbDefaultLP.setDefaultLength(Integer.parseInt(defaultLengthItem.getNodeValue()));
|
||||
if (defaultPrecision != null)
|
||||
dbDefaultLP.setDefaultPrecision(Integer.parseInt(defaultPrecision.getNodeValue()));
|
||||
if (defaultPattern != null)
|
||||
dbDefaultPt.setDefaultPattern(defaultPattern.getNodeValue());
|
||||
|
||||
dbDefaultLP.setDbTypeName(typeValue);
|
||||
dbDefaultPt.setDbTypeName(typeValue);
|
||||
dbDefault.add(dbDefaultLP);
|
||||
dbDefaultPattern.add(dbDefaultPt);
|
||||
|
||||
// ignore Length and Precision
|
||||
Node ignoreLength = typeNodeAtttributes.getNamedItem("ignoreLen"); //$NON-NLS-1$
|
||||
|
||||
@@ -191,6 +191,24 @@ public class MappingTypeRetriever {
|
||||
}// end for
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getDefaultPattern(String dbmsId, String dbType) {
|
||||
Dbms dbms = MetadataTalendType.getDbms(dbmsId);
|
||||
List<DbDefaultDatePattern> defaultPattern = dbms.getDefaultPattern();
|
||||
String pattern = new String(""); //$NON-NLS-1$
|
||||
for (int i = 0; i < defaultPattern.size(); i++) {
|
||||
DbDefaultDatePattern dbPattern = (DbDefaultDatePattern) defaultPattern.get(i);
|
||||
if (dbPattern.getDbTypeName().equalsIgnoreCase(dbType)) {
|
||||
pattern = dbPattern.getDefaultPattern();
|
||||
if (pattern == null) {
|
||||
return "";
|
||||
} else {
|
||||
return pattern;
|
||||
}
|
||||
}// end if
|
||||
}// end for
|
||||
return pattern;
|
||||
}
|
||||
|
||||
private boolean isExtensionPrecisionIgnored(String dbmsId, String dbType) {
|
||||
Map<String, Map<String, List<DBTypeUtil>>> javaTypeMappingFromExtension = JavaTypesManager
|
||||
|
||||
@@ -240,6 +240,11 @@ public class ContextParameterJavaTypeManager {
|
||||
if (javaType == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(javaType.equals(JavaTypesManager.PASSWORD)) {
|
||||
return "Password";
|
||||
}
|
||||
|
||||
Class primitiveClass = javaType.getPrimitiveClass();
|
||||
Class nullableClass = javaType.getNullableClass();
|
||||
if (nullable) {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2020 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.model.process;
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public abstract class AbsJobletReplaceNodeHandler extends AbsReplaceNodeHandler implements IJobletReplaceNodeHandler {
|
||||
|
||||
public AbsJobletReplaceNodeHandler(String prefix) {
|
||||
super();
|
||||
this.setPrefix(prefix);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2020 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.model.process;
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public abstract class AbsReplaceNodeHandler implements IReplaceNodeHandler {
|
||||
|
||||
private String prefix;
|
||||
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -122,6 +122,8 @@ public abstract class AbstractNode implements INode {
|
||||
// for MR, tag this component is the ref(lookup) start node
|
||||
private boolean isRefNode = false;
|
||||
|
||||
private IReplaceNodeHandler replaceNodeHandler;
|
||||
|
||||
public String getComponentName() {
|
||||
return componentName;
|
||||
}
|
||||
@@ -1322,6 +1324,15 @@ public abstract class AbstractNode implements INode {
|
||||
return componentProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IReplaceNodeHandler getReplaceNodeHandler() {
|
||||
return replaceNodeHandler;
|
||||
}
|
||||
|
||||
public void setReplaceNodeHandler(IReplaceNodeHandler replaceNodeHandler) {
|
||||
this.replaceNodeHandler = replaceNodeHandler;
|
||||
}
|
||||
|
||||
public INode getRealGraphicalNode() {
|
||||
return realGraphicalNode;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2020 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.model.process;
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public interface IJobletReplaceNodeHandler extends IReplaceNodeHandler {
|
||||
|
||||
}
|
||||
@@ -312,6 +312,10 @@ public interface INode extends IElement {
|
||||
|
||||
public boolean isSubtreeStart();
|
||||
|
||||
default public IReplaceNodeHandler getReplaceNodeHandler() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setComponentProperties(ComponentProperties props);
|
||||
|
||||
public ComponentProperties getComponentProperties();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2020 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.model.process;
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public interface IReplaceNodeHandler {
|
||||
|
||||
String getPrefix();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2020 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.model.process;
|
||||
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public class JobletReplaceNodeHandler extends AbsJobletReplaceNodeHandler {
|
||||
|
||||
public JobletReplaceNodeHandler(String prefix) {
|
||||
super(prefix);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,6 +43,7 @@ import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.routines.RoutinesUtil;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.i18n.Messages;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
@@ -130,6 +131,8 @@ public class RelationshipItemBuilder {
|
||||
|
||||
private Map<Relation, Set<Relation>> referencesItemsRelations;
|
||||
|
||||
private Map<String, String> systemRoutinesMap;
|
||||
|
||||
private boolean loaded = false;
|
||||
|
||||
private boolean loading = false;
|
||||
@@ -219,6 +222,28 @@ public class RelationshipItemBuilder {
|
||||
this.proxyRepositoryFactory = proxyRepositoryFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Current System Routines Map, key: routine id, value: routine name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getCurrentSystemRoutinesMap() {
|
||||
if (systemRoutinesMap != null && !systemRoutinesMap.isEmpty()) {
|
||||
return systemRoutinesMap;
|
||||
}
|
||||
|
||||
if (systemRoutinesMap == null) {
|
||||
systemRoutinesMap = new HashMap<String, String>();
|
||||
}
|
||||
List<IRepositoryViewObject> currentSystemRoutines = RoutinesUtil.getCurrentSystemRoutines();
|
||||
for (IRepositoryViewObject object : currentSystemRoutines) {
|
||||
systemRoutinesMap.put(object.getProperty().getId(), object.getProperty().getLabel());
|
||||
}
|
||||
|
||||
return systemRoutinesMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for every linked items who use the selected id, no matter the version. Usefull when want to delete an item
|
||||
* since it will delete every versions.
|
||||
@@ -937,18 +962,26 @@ public class RelationshipItemBuilder {
|
||||
|
||||
private void buildIndex(Map<Relation, Set<Relation>> itemRelations, Project project, IProgressMonitor monitor) {
|
||||
modified = true;
|
||||
|
||||
if (!project.getEmfProject().getItemsRelations().isEmpty()) {
|
||||
loadRelations(itemRelations, project);
|
||||
if (loaded) { // check if already loaded successfully
|
||||
return;
|
||||
}
|
||||
}
|
||||
generateIndex(project, getTypes(), true, monitor);
|
||||
if (modified) {
|
||||
autoSaveRelations();
|
||||
}
|
||||
monitor.done();
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
private void generateIndex(Project project, List<ERepositoryObjectType> supportedTypes, boolean fromMigration,
|
||||
IProgressMonitor monitor) {
|
||||
IProxyRepositoryFactory factory = getProxyRepositoryFactory();
|
||||
List<IRepositoryViewObject> list = new ArrayList<IRepositoryViewObject>();
|
||||
try {
|
||||
for (ERepositoryObjectType curTyp : getTypes()) {
|
||||
for (ERepositoryObjectType curTyp : supportedTypes) {
|
||||
if (curTyp != null) {
|
||||
list.addAll(factory.getAll(project, curTyp, true, true));
|
||||
}
|
||||
@@ -962,21 +995,44 @@ public class RelationshipItemBuilder {
|
||||
for (IRepositoryViewObject object : list) {
|
||||
Item item = object.getProperty().getItem();
|
||||
monitor.subTask(Messages.getString("RelationshipItemBuilder.forItem") + item.getProperty().getLabel()); //$NON-NLS-1$
|
||||
addOrUpdateItem(item, true);
|
||||
findRelationItems(item, fromMigration);
|
||||
monitor.worked(1);
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
autoSaveRelations();
|
||||
monitor.done();
|
||||
loaded = true;
|
||||
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void buildAndSaveIndex() {
|
||||
log.info("relationship.index generating");
|
||||
currentProjectItemsRelations = new ConcurrentHashMap<Relation, Set<Relation>>();
|
||||
referencesItemsRelations = new ConcurrentHashMap<Relation, Set<Relation>>();
|
||||
generateIndex(this.aimProject, allSupportedTypes(), false, new NullProgressMonitor());
|
||||
try {
|
||||
// sync to project
|
||||
synchronizeItemRelationToProject(this.aimProject);
|
||||
// persist index
|
||||
getProxyRepositoryFactory().saveProject(this.aimProject);
|
||||
log.info("relationship.index generated");
|
||||
} catch (PersistenceException e) {
|
||||
log.error("relationship.index generating error", e);
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ERepositoryObjectType> allSupportedTypes() {
|
||||
List<ERepositoryObjectType> toReturn = new ArrayList<ERepositoryObjectType>();
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfProcess());
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfProcess2());
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfTestContainer());
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfCodes());
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfJoblet());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private List<ERepositoryObjectType> getTypes() {
|
||||
List<ERepositoryObjectType> toReturn = new ArrayList<ERepositoryObjectType>();
|
||||
toReturn.add(ERepositoryObjectType.PROCESS);
|
||||
@@ -1098,14 +1154,24 @@ public class RelationshipItemBuilder {
|
||||
}
|
||||
|
||||
public void addOrUpdateItem(Item item, boolean fromMigration) {
|
||||
if (!supportRelation(item)) {
|
||||
return;
|
||||
}
|
||||
if (!loaded) {
|
||||
loadRelations();
|
||||
}
|
||||
boolean relationsModified = findRelationItems(item, fromMigration);
|
||||
if (relationsModified && !modified) {
|
||||
modified = true;
|
||||
}
|
||||
if (!fromMigration && modified) {
|
||||
autoSaveRelations();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean findRelationItems(Item item, boolean fromMigration) {
|
||||
if (!supportRelation(item)) {
|
||||
return false;
|
||||
}
|
||||
if (item == null) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean relationsModified = true;
|
||||
@@ -1149,12 +1215,7 @@ public class RelationshipItemBuilder {
|
||||
currentProjectItemsRelations.get(relation).addAll(oldProjectRelations);
|
||||
}
|
||||
}
|
||||
if (relationsModified && !modified) {
|
||||
modified = true;
|
||||
}
|
||||
if (!fromMigration && modified) {
|
||||
autoSaveRelations();
|
||||
}
|
||||
return relationsModified;
|
||||
}
|
||||
|
||||
public Set<Relation> getItemRelations(Item item) {
|
||||
|
||||
@@ -44,6 +44,8 @@ public interface MavenConstants {
|
||||
|
||||
static final String USE_PROFILE_MODULE = "USE_PROFILE_MODULE";
|
||||
|
||||
static final String EXCLUDE_DELETED_ITEMS = "EXCLUDE_DELETED_ITEMS";
|
||||
|
||||
/*
|
||||
* for lib
|
||||
*/
|
||||
|
||||
@@ -51,6 +51,11 @@ public interface ITalendProcessJavaProject {
|
||||
*/
|
||||
IFolder getExternalResourcesFolder();
|
||||
|
||||
/**
|
||||
* src/main/tacokit-resources as external resources folder
|
||||
*/
|
||||
IFolder getTaCoKitResourcesFolder();
|
||||
|
||||
/**
|
||||
* src/main/resources as internal resources folder
|
||||
*/
|
||||
|
||||
@@ -64,6 +64,8 @@ public interface TalendProcessArgumentConstant {
|
||||
|
||||
static final String ARG_AVOID_BRANCH_NAME = "AVOID_BRANCH_NAME";
|
||||
|
||||
static final String ARG_CLEAR_PASSWORD_CONTEXT_PARAMETERS = "CLEAR_PASSWORD_CONTEXT_PARAMETERS";
|
||||
|
||||
static final String CMD_ARG_STATS_PORT_PARAM = "stat_port";
|
||||
|
||||
static final String CMD_ARG_TRACE_PORT_PARAM = "trace_port";
|
||||
|
||||
@@ -246,6 +246,8 @@ public interface IRunProcessService extends IService {
|
||||
|
||||
public boolean isCIMode();
|
||||
|
||||
public boolean isExcludeDeletedItems(Property property);
|
||||
|
||||
public static IRunProcessService get() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
return GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
|
||||
|
||||
@@ -78,6 +78,7 @@ import org.talend.core.model.components.EComponentType;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.components.IComponentsFactory;
|
||||
import org.talend.core.model.components.IComponentsService;
|
||||
import org.talend.core.model.context.ContextUtils;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
@@ -1006,6 +1007,7 @@ public class ProcessorUtilities {
|
||||
if (context.getName().equals(currentContext.getName())) {
|
||||
// override parameter value before generate current context
|
||||
IContext checkedContext = checkNeedOverrideContextParameterValue(currentContext, jobInfo);
|
||||
checkedContext = checkCleanSecureContextParameterValue(checkedContext, jobInfo);
|
||||
processor.setContext(checkedContext); // generate current context.
|
||||
} else {
|
||||
processor.setContext(context);
|
||||
@@ -1078,6 +1080,49 @@ public class ProcessorUtilities {
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
private static IContext checkCleanSecureContextParameterValue(IContext currentContext, JobInfo jobInfo) {
|
||||
|
||||
JobInfo job = null;
|
||||
|
||||
if (jobInfo.getFatherJobInfo() == null) {
|
||||
job = jobInfo;
|
||||
} else {
|
||||
job = getRootJob(jobInfo);
|
||||
if (job.getProcess() == null || "route".equalsIgnoreCase(job.getProcess().getElementName())) {
|
||||
// cleanup context only for child jobs which are referenced
|
||||
// by tRunJob component or for Joblets (see TESB-29718 for details)
|
||||
return currentContext;
|
||||
}
|
||||
}
|
||||
|
||||
if (job.getArgumentsMap() == null
|
||||
|| job.getArgumentsMap().get(TalendProcessArgumentConstant.ARG_CLEAR_PASSWORD_CONTEXT_PARAMETERS) == null
|
||||
|| !Boolean.parseBoolean((ProcessUtils.getOptionValue(job.getArgumentsMap(), TalendProcessArgumentConstant.ARG_CLEAR_PASSWORD_CONTEXT_PARAMETERS,
|
||||
(String) null)))) {
|
||||
return currentContext;
|
||||
}
|
||||
|
||||
IContext context = currentContext.clone();
|
||||
|
||||
List<IContextParameter> contextParameterList = context.getContextParameterList();
|
||||
for (IContextParameter contextParameter : contextParameterList) {
|
||||
if (PasswordEncryptUtil.isPasswordType(contextParameter.getType())
|
||||
|| ContextUtils.isSecureSensitiveParam(contextParameter.getName())) {
|
||||
contextParameter.setValue("");
|
||||
}
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
private static JobInfo getRootJob(JobInfo jobInfo) {
|
||||
|
||||
if (jobInfo != null && jobInfo.getFatherJobInfo() != null) {
|
||||
return getRootJob(jobInfo.getFatherJobInfo());
|
||||
}
|
||||
|
||||
return jobInfo;
|
||||
}
|
||||
|
||||
private static void generateDataSet(IProcess process, IProcessor processor) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
|
||||
@@ -1447,13 +1492,15 @@ public class ProcessorUtilities {
|
||||
}
|
||||
while (relativepath.hasNext()) {
|
||||
String relativePath = relativepath.next();
|
||||
Set<URL> sources = resouece.getResourcesByRelativePath(relativePath);
|
||||
for (URL sourceUrl : sources) {
|
||||
File currentResource = new File(
|
||||
org.talend.commons.utils.io.FilesUtils.getFileRealPath(sourceUrl.getPath()));
|
||||
if (currentResource.exists()) {
|
||||
FilesUtils.copyDirectory(currentResource, new File(
|
||||
targetFolder.getLocation().toPortableString() + File.separator + pathStr));
|
||||
if (!(relativePath.startsWith("MAVEN-INF") || relativePath.startsWith("TALEND-INF"))) {
|
||||
Set<URL> sources = resouece.getResourcesByRelativePath(relativePath);
|
||||
for (URL sourceUrl : sources) {
|
||||
File currentResource = new File(
|
||||
org.talend.commons.utils.io.FilesUtils.getFileRealPath(sourceUrl.getPath()));
|
||||
if (currentResource.exists()) {
|
||||
FilesUtils.copyDirectory(currentResource, new File(
|
||||
targetFolder.getLocation().toPortableString() + File.separator + pathStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1560,6 +1607,10 @@ public class ProcessorUtilities {
|
||||
List<ProcessItem> testsItems =
|
||||
testContainerService.getTestContainersByVersion(jobInfo.getProcessItem());
|
||||
for (ProcessItem testItem : testsItems) {
|
||||
if (testItem.getProperty().getItem().getState().isDeleted()
|
||||
&& IRunProcessService.get().isExcludeDeletedItems(testItem.getProperty())) {
|
||||
continue;
|
||||
}
|
||||
JobInfo subJobInfo = new JobInfo(testItem, testItem.getProcess().getDefaultContext());
|
||||
subJobInfo.setTestContainer(true);
|
||||
subJobInfo.setFatherJobInfo(jobInfo);
|
||||
@@ -2916,5 +2967,12 @@ public class ProcessorUtilities {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isJob(Property p) {
|
||||
if (p != null) {
|
||||
return ERepositoryObjectType.getType(p).equals(ERepositoryObjectType.PROCESS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@
|
||||
<version>17</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<!-- It fixes provided dependency scope to compile, because maven-dependency-plugin is setup to include
|
||||
only compile and runtime scopes, but provided is also required. It's not possible to setup plugin to
|
||||
<!-- It fixes provided dependency scope to compile, because maven-dependency-plugin is setup to include
|
||||
only compile and runtime scopes, but provided is also required. It's not possible to setup plugin to
|
||||
include all: compile, runtime and provided dependencies -->
|
||||
<dependency>
|
||||
<groupId>biz.aQute.bnd</groupId>
|
||||
@@ -161,7 +161,7 @@
|
||||
<artifactId>components-api</artifactId>
|
||||
<version>${components.version}</version>
|
||||
</dependency>
|
||||
<!-- Dependencies in provided scope should be explicitly added as dependency in this module,
|
||||
<!-- Dependencies in provided scope should be explicitly added as dependency in this module,
|
||||
because provided scope is not transitive -->
|
||||
<dependency>
|
||||
<groupId>org.osgi</groupId>
|
||||
@@ -199,6 +199,11 @@
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
<version>1.9.14-TALEND</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<version>1.9.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
@@ -12,4 +12,6 @@ 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.refModuleText=Set reference project modules in profile
|
||||
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.
|
||||
@@ -32,6 +32,7 @@ import org.talend.designer.maven.template.AbstractMavenTemplateManager;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
import org.talend.designer.maven.tools.extension.PomExtensionRegistry;
|
||||
import org.talend.designer.maven.ui.DesignerMavenUiPlugin;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
@@ -68,6 +69,7 @@ public class MavenScriptsProjectSettingInitializer extends AbstractProjectPrefer
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(stream);
|
||||
PomExtensionRegistry.getInstance().updatePomTemplate(model);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
PomUtil.sortModules(model);
|
||||
MavenPlugin.getMaven().writeModel(model, out);
|
||||
String content = out.toString(TalendMavenConstants.DEFAULT_ENCODING);
|
||||
if (content != null) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.forms.IMessage;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.PluginChecker;
|
||||
@@ -52,6 +53,8 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
|
||||
private Button useProfileModuleCheckbox;
|
||||
|
||||
private Button excludeDeletedItemsCheckbox;
|
||||
|
||||
public MavenProjectSettingPage() {
|
||||
noDefaultAndApplyButton();
|
||||
}
|
||||
@@ -89,12 +92,31 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
useProfileModuleCheckbox = new Button(parent, SWT.CHECK);
|
||||
useProfileModuleCheckbox.setText(Messages.getString("MavenProjectSettingPage.refModuleText")); //$NON-NLS-1$
|
||||
useProfileModuleCheckbox.setSelection(preferenceStore.getBoolean(MavenConstants.USE_PROFILE_MODULE));
|
||||
useProfileModuleCheckbox.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
addSyncWarning();
|
||||
}
|
||||
});
|
||||
|
||||
excludeDeletedItemsCheckbox = new Button(parent, SWT.CHECK);
|
||||
excludeDeletedItemsCheckbox.setText(Messages.getString("MavenProjectSettingPage.excludeDeletedItems")); //$NON-NLS-1$
|
||||
excludeDeletedItemsCheckbox.setSelection(preferenceStore.getBoolean(MavenConstants.EXCLUDE_DELETED_ITEMS));
|
||||
excludeDeletedItemsCheckbox.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
addSyncWarning();
|
||||
}
|
||||
});
|
||||
|
||||
filterText.setText(filter);
|
||||
filterText.addModifyListener(new ModifyListener() {
|
||||
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
addSyncWarning();
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IFilterService.class)) {
|
||||
IFilterService service = (IFilterService) GlobalServiceRegister.getDefault()
|
||||
.getService(IFilterService.class);
|
||||
@@ -122,6 +144,7 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
try {
|
||||
preferenceStore.setValue(MavenConstants.POM_FILTER, getRealVersionFilter(filter));
|
||||
preferenceStore.setValue(MavenConstants.USE_PROFILE_MODULE, useProfileModuleCheckbox.getSelection());
|
||||
preferenceStore.setValue(MavenConstants.EXCLUDE_DELETED_ITEMS, excludeDeletedItemsCheckbox.getSelection());
|
||||
new AggregatorPomsHelper().syncAllPoms();
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
@@ -135,12 +158,17 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
|
||||
}
|
||||
|
||||
private void addSyncWarning() {
|
||||
setMessage(Messages.getString("MavenProjectSettingPage.syncAllPomsWarning"), IMessage.WARNING); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
boolean ok = super.performOk();
|
||||
if (preferenceStore != null) {
|
||||
preferenceStore.setValue(MavenConstants.POM_FILTER, getRealVersionFilter(filter));
|
||||
preferenceStore.setValue(MavenConstants.USE_PROFILE_MODULE, useProfileModuleCheckbox.getSelection());
|
||||
preferenceStore.setValue(MavenConstants.EXCLUDE_DELETED_ITEMS, excludeDeletedItemsCheckbox.getSelection());
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ public class MavenSystemFolders {
|
||||
|
||||
public static final ProjectSystemFolder EXT_RESOURCES = new ProjectSystemFolder("src/main/ext-resources", "target/classes");
|
||||
|
||||
public static final ProjectSystemFolder TCK_RESOURCES = new ProjectSystemFolder("src/main/tacokit-resources", "target/classes");
|
||||
|
||||
public static final ProjectSystemFolder BUNDLE_RESOURCES = new ProjectSystemFolder("src/main/bundle-resources", "target/classes");
|
||||
|
||||
public static final ProjectSystemFolder RESOURCES_TEST = new ProjectSystemFolder("src/test/resources", "target/test-classes");
|
||||
|
||||
@@ -810,6 +810,9 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
}
|
||||
if (object.getProperty() != null && object.getProperty().getItem() != null) {
|
||||
if (object.isDeleted() && PomIdsHelper.getIfExcludeDeletedItems()) {
|
||||
continue;
|
||||
}
|
||||
Item item = object.getProperty().getItem();
|
||||
if (ProjectManager.getInstance().isInCurrentMainProject(item)) {
|
||||
monitor.subTask("Synchronize job pom: " + item.getProperty().getLabel() //$NON-NLS-1$
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.runtime.process.LastGenerationInfo;
|
||||
import org.talend.core.runtime.process.TalendProcessOptionConstants;
|
||||
import org.talend.core.service.ITaCoKitDependencyService;
|
||||
import org.talend.core.ui.ITestContainerProviderService;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.designer.maven.utils.SortableDependency;
|
||||
@@ -50,9 +51,16 @@ public class ProcessorDependenciesManager {
|
||||
|
||||
private final Property property;
|
||||
|
||||
private final ITaCoKitDependencyService tckService;
|
||||
|
||||
public ProcessorDependenciesManager(IProcessor processor) {
|
||||
this.processor = processor;
|
||||
property = processor.getProperty();
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITaCoKitDependencyService.class)) {
|
||||
tckService = GlobalServiceRegister.getDefault().getService(ITaCoKitDependencyService.class);
|
||||
} else {
|
||||
tckService = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,10 +69,30 @@ public class ProcessorDependenciesManager {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public boolean updateDependencies(IProgressMonitor progressMonitor, Model model) throws ProcessorException {
|
||||
try {
|
||||
Set<ModuleNeeded> jobModules = new HashSet<>();
|
||||
Set<ModuleNeeded> testcaseModules = new HashSet<>();
|
||||
//
|
||||
if (tckService != null && tckService
|
||||
.hasTaCoKitComponents(tckService.getJobComponents(property.getItem()))) {
|
||||
final Set<String> depsonly = tckService
|
||||
.getTaCoKitOnlyDependencies(tckService.getJobComponents(property.getItem()));
|
||||
for (ModuleNeeded module : getProcessNeededModules()) {
|
||||
if (depsonly.stream().noneMatch(dep -> dep.equals(module.getModuleName()))) {
|
||||
jobModules.add(module);
|
||||
}
|
||||
}
|
||||
for (ModuleNeeded module : getTestcaseNeededModules(property)) {
|
||||
if (depsonly.stream().noneMatch(dep -> dep.equals(module.getModuleName()))) {
|
||||
testcaseModules.add(module);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
jobModules = getProcessNeededModules();
|
||||
testcaseModules = getTestcaseNeededModules(property);
|
||||
}
|
||||
//
|
||||
Set<ModuleNeeded> neededLibraries = new HashSet<>();
|
||||
Set<String> uniqueDependencies = new HashSet<>();
|
||||
Set<ModuleNeeded> jobModules = getProcessNeededModules();
|
||||
Set<ModuleNeeded> testcaseModules = getTestcaseNeededModules(property);
|
||||
neededLibraries.addAll(jobModules);
|
||||
neededLibraries.addAll(testcaseModules);
|
||||
if (!neededLibraries.isEmpty()) {
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -49,6 +48,7 @@ import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.eclipse.m2e.core.embedder.IMaven;
|
||||
import org.talend.commons.exception.CommonExceptionHandler;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
@@ -657,8 +657,11 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
jobCoordinate.add(getJobCoordinate(currentJobProperty));
|
||||
|
||||
// children jobs without test cases
|
||||
Set<JobInfo> childrenJobInfo = !hasLoopDependency() ? processor.getBuildChildrenJobs().stream().filter(j -> !j.isTestContainer()).collect(Collectors.toSet()) : Collections.emptySet();
|
||||
childrenJobInfo.forEach(j -> jobCoordinate.add(getJobCoordinate(j.getProcessItem().getProperty())));
|
||||
Set<JobInfo> childrenJobInfo = processor.getBuildChildrenJobs().stream().filter(j -> !j.isTestContainer())
|
||||
.collect(Collectors.toSet());
|
||||
if (!hasLoopDependency()) {
|
||||
childrenJobInfo.forEach(j -> jobCoordinate.add(getJobCoordinate(j.getProcessItem().getProperty())));
|
||||
}
|
||||
|
||||
// talend libraries and codes
|
||||
String projectGroupId = PomIdsHelper.getProjectGroupId(ProjectManager.getInstance().getProject(currentJobProperty).getTechnicalLabel());
|
||||
@@ -894,6 +897,7 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
}
|
||||
IMaven maven = MavenPlugin.getMaven();
|
||||
ArtifactRepository repository = maven.getLocalRepository();
|
||||
boolean isDIJob = ERepositoryObjectType.getItemType(getJobProcessor().getProperty().getItem()) == ERepositoryObjectType.PROCESS;
|
||||
for (Dependency dependency : duplicateDependencies) {
|
||||
if (((SortableDependency) dependency).isAssemblyOptional()) {
|
||||
continue;
|
||||
@@ -902,6 +906,10 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
dependency.getVersion(), dependency.getType(), dependency.getClassifier());
|
||||
Path path = new File(repository.getBasedir()).toPath().resolve(sourceLocation);
|
||||
sourceLocation = path.toString();
|
||||
if (isDIJob && !new File(sourceLocation).exists()) {
|
||||
CommonExceptionHandler.warn("Job dependency [" + sourceLocation + "] does not exist!");
|
||||
continue;
|
||||
}
|
||||
String destName = path.getFileName().toString();
|
||||
Node fileNode = document.createElement("file");
|
||||
filesNode.appendChild(fileNode);
|
||||
|
||||
@@ -266,6 +266,18 @@ public class PomIdsHelper {
|
||||
return manager.getBoolean(MavenConstants.USE_PROFILE_MODULE);
|
||||
}
|
||||
|
||||
public static boolean getIfExcludeDeletedItems() {
|
||||
String projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
ProjectPreferenceManager manager = getPreferenceManager(projectTechName);
|
||||
return manager.getBoolean(MavenConstants.EXCLUDE_DELETED_ITEMS);
|
||||
}
|
||||
|
||||
public static boolean getIfExcludeDeletedItems(Property property) {
|
||||
String projectTechName = ProjectManager.getInstance().getProject(property).getTechnicalLabel();
|
||||
ProjectPreferenceManager manager = getPreferenceManager(projectTechName);
|
||||
return manager.getBoolean(MavenConstants.EXCLUDE_DELETED_ITEMS);
|
||||
}
|
||||
|
||||
private static String getGroupId(String projectTechName, String baseName, Property property) {
|
||||
if (projectTechName == null) {
|
||||
projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
@@ -330,6 +342,12 @@ public class PomIdsHelper {
|
||||
if (preferenceStore.getString(MavenConstants.POM_FILTER) == null) {
|
||||
preferenceStore.setValue(MavenConstants.POM_FILTER, "");
|
||||
}
|
||||
|
||||
if (!preferenceManager.exist()
|
||||
&& StringUtils.isBlank(preferenceStore.getString(MavenConstants.EXCLUDE_DELETED_ITEMS))) {
|
||||
// for new project, set EXCLUDE_DELETED_ITEMS=true as default
|
||||
preferenceStore.setValue(MavenConstants.EXCLUDE_DELETED_ITEMS, true);
|
||||
}
|
||||
preferenceManager.save();
|
||||
preferenceManagers.put(projectTechName, preferenceManager);
|
||||
return preferenceManager;
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@@ -140,6 +141,7 @@ public class PomUtil {
|
||||
* copied the codes from createMavenModel of MavenModelManager
|
||||
*/
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
sortModules(model);
|
||||
MavenPlugin.getMaven().writeModel(model, buf);
|
||||
|
||||
ByteArrayInputStream source = new ByteArrayInputStream(buf.toByteArray());
|
||||
@@ -161,6 +163,7 @@ public class PomUtil {
|
||||
properties.putAll(model.getProperties());
|
||||
model.setProperties(properties);
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
sortModules(model);
|
||||
MavenPlugin.getMaven().writeModel(model, buf);
|
||||
|
||||
ByteArrayInputStream source = new ByteArrayInputStream(buf.toByteArray());
|
||||
@@ -182,6 +185,17 @@ public class PomUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void sortModules(Model model) {
|
||||
if (model != null) {
|
||||
List<String> modules = model.getModules();
|
||||
if (modules != null && !modules.isEmpty()) {
|
||||
List<String> sortedModules = new LinkedList<>(modules);
|
||||
Collections.sort(sortedModules);
|
||||
model.setModules(sortedModules);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void safeClose(Closeable stream) {
|
||||
try {
|
||||
if (stream != null) {
|
||||
@@ -669,7 +683,9 @@ public class PomUtil {
|
||||
File pomFile = new File(baseFolder, TalendMavenConstants.POM_FILE_NAME);
|
||||
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
MavenPlugin.getMaven().writeModel(createModel(artifact), buf);
|
||||
Model model = createModel(artifact);
|
||||
sortModules(model);
|
||||
MavenPlugin.getMaven().writeModel(model, buf);
|
||||
|
||||
DocumentBuilderFactory documentBuilderFactory = XmlUtils.getSecureDocumentBuilderFactory();
|
||||
documentBuilderFactory.setNamespaceAware(false);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jaxen-1.1.6.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/dom4j-2.1.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/dom4j-2.1.3.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -5,7 +5,7 @@ Bundle-SymbolicName: org.talend.libraries.dom4j-jaxen;singleton:=true
|
||||
Bundle-Version: 7.3.1.qualifier
|
||||
Bundle-Vendor: .Talend SA.
|
||||
Bundle-ClassPath: .,
|
||||
lib/dom4j-2.1.1.jar,
|
||||
lib/dom4j-2.1.3.jar,
|
||||
lib/jaxen-1.1.6.jar
|
||||
Export-Package: org.dom4j,
|
||||
org.dom4j.bean,
|
||||
|
||||
@@ -2,7 +2,7 @@ bin.includes = META-INF/,\
|
||||
.,\
|
||||
lib/,\
|
||||
licences/,\
|
||||
lib/dom4j-2.1.1.jar,\
|
||||
lib/dom4j-2.1.3.jar,\
|
||||
lib/jaxen-1.1.6.jar,\
|
||||
plugin.xml
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
point="org.talend.core.runtime.librariesNeeded">
|
||||
<libraryNeeded
|
||||
context="plugin:org.talend.libraries.dom4j-jaxen"
|
||||
id="dom4j-2.1.1.jar"
|
||||
mvn_uri="mvn:org.dom4j/dom4j/2.1.1"
|
||||
name="dom4j-2.1.1.jar"
|
||||
id="dom4j-2.1.3.jar"
|
||||
mvn_uri="mvn:org.dom4j/dom4j/2.1.3"
|
||||
name="dom4j-2.1.3.jar"
|
||||
required="true"
|
||||
uripath="platform:/plugin/org.talend.libraries.dom4j-jaxen/lib/dom4j-2.1.1.jar">
|
||||
uripath="platform:/plugin/org.talend.libraries.dom4j-jaxen/lib/dom4j-2.1.3.jar">
|
||||
</libraryNeeded>
|
||||
<libraryNeeded
|
||||
context="plugin:org.talend.libraries.dom4j-jaxen"
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<dependency>
|
||||
<groupId>org.dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<version>2.1.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
<systemRoutine
|
||||
name="Document">
|
||||
<library
|
||||
name="dom4j-2.1.1.jar">
|
||||
name="dom4j-2.1.3.jar">
|
||||
<bundleId
|
||||
bundleId="org.apache.servicemix.bundles.dom4j">
|
||||
</bundleId>
|
||||
@@ -92,7 +92,7 @@
|
||||
<systemRoutine
|
||||
name="DocumentHelper">
|
||||
<library
|
||||
name="dom4j-2.1.1.jar">
|
||||
name="dom4j-2.1.3.jar">
|
||||
<bundleId
|
||||
bundleId="org.apache.servicemix.bundles.dom4j">
|
||||
</bundleId>
|
||||
@@ -101,7 +101,7 @@
|
||||
<systemRoutine
|
||||
name="DocumentToFlat">
|
||||
<library
|
||||
name="dom4j-2.1.1.jar">
|
||||
name="dom4j-2.1.3.jar">
|
||||
<bundleId
|
||||
bundleId="org.apache.servicemix.bundles.dom4j">
|
||||
</bundleId>
|
||||
@@ -110,7 +110,7 @@
|
||||
<systemRoutine
|
||||
name="NameSpaceTool">
|
||||
<library
|
||||
name="dom4j-2.1.1.jar">
|
||||
name="dom4j-2.1.3.jar">
|
||||
<bundleId
|
||||
bundleId="org.apache.servicemix.bundles.dom4j">
|
||||
</bundleId>
|
||||
@@ -119,7 +119,7 @@
|
||||
<systemRoutine
|
||||
name="ParserUtils">
|
||||
<library
|
||||
name="dom4j-2.1.1.jar">
|
||||
name="dom4j-2.1.3.jar">
|
||||
<bundleId
|
||||
bundleId="org.apache.servicemix.bundles.dom4j">
|
||||
</bundleId>
|
||||
@@ -128,7 +128,7 @@
|
||||
<systemRoutine
|
||||
name="TalendMDMJob">
|
||||
<library
|
||||
name="dom4j-2.1.1.jar">
|
||||
name="dom4j-2.1.3.jar">
|
||||
<bundleId
|
||||
bundleId="org.apache.servicemix.bundles.dom4j">
|
||||
</bundleId>
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.apache.log4j.Logger;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class LibraryDataJsonProvider {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
} else {
|
||||
log.error("Can't find license data file:" + dataFile.getAbsolutePath());
|
||||
log.warn("Can't find license data file:" + dataFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
return mvnToLibraryMap;
|
||||
|
||||
@@ -90,16 +90,28 @@ public class LibraryDataService {
|
||||
buildLibraryIfLicenseMissing = Boolean
|
||||
.valueOf(System.getProperty(KEY_BUILD_LIBRARY_IF_LICENSE_MISSING, Boolean.FALSE.toString()));
|
||||
buildLibraryJarFile = Boolean.valueOf(System.getProperty(KEY_LIBRARIES_BUILD_JAR, Boolean.FALSE.toString()));
|
||||
File libraryDataFile = getLibraryDataFile();
|
||||
File studioLibraryDataFile = getStudioLibraryDataFile();
|
||||
if (buildLibraryLicense) {
|
||||
if (libraryDataFile.exists()) {
|
||||
libraryDataFile.delete();
|
||||
if (studioLibraryDataFile.exists()) {
|
||||
studioLibraryDataFile.delete();
|
||||
}
|
||||
}
|
||||
unknownLicense = new LibraryLicense();
|
||||
unknownLicense.setName(UNRESOLVED_LICENSE_NAME);
|
||||
dataProvider = new LibraryDataJsonProvider(libraryDataFile);
|
||||
mvnToLibraryMap.putAll(dataProvider.loadLicenseData());
|
||||
dataProvider = new LibraryDataJsonProvider(studioLibraryDataFile);
|
||||
File currentUserDataFile = getCurrentUserLibraryDataFile();
|
||||
Map<String, Library> studioLibraryDataMap = dataProvider.loadLicenseData();
|
||||
if (!StringUtils.equals(currentUserDataFile.getAbsolutePath(), studioLibraryDataFile.getAbsolutePath())) {
|
||||
dataProvider = new LibraryDataJsonProvider(currentUserDataFile);
|
||||
Map<String, Library> userLibraryDataMap = dataProvider.loadLicenseData();
|
||||
if (userLibraryDataMap.size() == 0) {
|
||||
mvnToLibraryMap.putAll(studioLibraryDataMap);
|
||||
} else {
|
||||
mvnToLibraryMap.putAll(userLibraryDataMap);
|
||||
}
|
||||
} else {
|
||||
mvnToLibraryMap.putAll(studioLibraryDataMap);
|
||||
}
|
||||
}
|
||||
|
||||
public static LibraryDataService getInstance() {
|
||||
@@ -321,13 +333,22 @@ public class LibraryDataService {
|
||||
if (buildLibraryLicense) {
|
||||
return true;
|
||||
}
|
||||
if (buildLibraryIfFileMissing && !getLibraryDataFile().exists()) {
|
||||
if (buildLibraryIfFileMissing && !getStudioLibraryDataFile().exists()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private File getLibraryDataFile() {
|
||||
/**
|
||||
* For shared studio, user's library data file not same with studio one
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private File getCurrentUserLibraryDataFile() {
|
||||
return new File(Platform.getConfigurationLocation().getURL().getPath(), LIBRARIES_DATA_FILE_NAME);
|
||||
}
|
||||
|
||||
private File getStudioLibraryDataFile() {
|
||||
String folder = System.getProperty(KEY_LIBRARIES_DATA_FOLDER);
|
||||
if (folder == null) {
|
||||
folder = new File(Platform.getInstallLocation().getURL().getPath(), "configuration").getAbsolutePath(); //$NON-NLS-1$
|
||||
|
||||
@@ -1385,7 +1385,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
snapshotResult = customerRepHandler.search(MavenConstants.DEFAULT_LIB_GROUP_ID, null, null, false, true);
|
||||
if (snapshotResult != null) {
|
||||
for (MavenArtifact result : snapshotResult) {
|
||||
ShareLibrariesUtil.putArtifactToMap(result, releaseArtifactMap, true);
|
||||
ShareLibrariesUtil.putArtifactToMap(result, snapshotArtifactMap, true);
|
||||
}
|
||||
}
|
||||
releaseResult = customerRepHandler.search(MavenConstants.DEFAULT_LIB_GROUP_ID, null, null, true, false);
|
||||
|
||||
@@ -16,8 +16,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ITDQRepositoryService;
|
||||
import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.database.conn.DatabaseConnStrUtil;
|
||||
import org.talend.core.hadoop.IHadoopClusterService;
|
||||
@@ -100,7 +103,7 @@ public class SwitchContextGroupNameImpl implements ISwitchContext {
|
||||
newContextName = newContextType == null ? null : newContextType.getName();
|
||||
}
|
||||
|
||||
if (!isContextIsValid(newContextName, oldContextName, con)) {
|
||||
if (!isContextIsValidAndInUse(newContextName, oldContextName, connItem)) {
|
||||
return false;
|
||||
}
|
||||
con.setContextName(newContextName);
|
||||
@@ -129,8 +132,9 @@ public class SwitchContextGroupNameImpl implements ISwitchContext {
|
||||
* @param selectedContext
|
||||
* @paramconn
|
||||
*/
|
||||
private boolean isContextIsValid(String selectedContext, String oldContextName, Connection conn) {
|
||||
private boolean isContextIsValidAndInUse(String selectedContext, String oldContextName, ConnectionItem connItem) {
|
||||
boolean retCode = false;
|
||||
Connection conn = connItem.getConnection();
|
||||
if (conn instanceof DatabaseConnection) {
|
||||
EDatabaseTypeName dbType = EDatabaseTypeName.getTypeFromDbType(((DatabaseConnection) conn).getDatabaseType());
|
||||
|
||||
@@ -138,33 +142,52 @@ public class SwitchContextGroupNameImpl implements ISwitchContext {
|
||||
retCode = true;
|
||||
} else if (dbType == EDatabaseTypeName.GENERAL_JDBC) {
|
||||
retCode = true;
|
||||
} else {
|
||||
DatabaseConnection dbConn = (DatabaseConnection) conn;
|
||||
boolean hasCatalog = ConnectionHelper.hasCatalog(dbConn);
|
||||
boolean hasSchema = ConnectionHelper.hasSchema(dbConn);
|
||||
ContextType newContextType = ConnectionContextHelper.getContextTypeForContextMode(dbConn, selectedContext, false);
|
||||
ContextType oldContextType = ConnectionContextHelper.getContextTypeForContextMode(dbConn, oldContextName, false);
|
||||
String newSidOrDatabase = ConnectionContextHelper.getOriginalValue(newContextType, dbConn.getSID());
|
||||
String newUiShema = ConnectionContextHelper.getOriginalValue(newContextType, dbConn.getUiSchema());
|
||||
String oldSidOrDatabase = ConnectionContextHelper.getOriginalValue(oldContextType, dbConn.getSID());
|
||||
String oldUiShema = ConnectionContextHelper.getOriginalValue(oldContextType, dbConn.getUiSchema());
|
||||
if (hasCatalog) {// for example mysql
|
||||
retCode = !isEmptyString(oldSidOrDatabase) && !isEmptyString(newSidOrDatabase);
|
||||
if (hasSchema) {// for example mssql
|
||||
retCode &= !isEmptyString(oldUiShema) && !isEmptyString(newUiShema);
|
||||
}
|
||||
} else if (hasSchema) {// for example oracle
|
||||
retCode = !isEmptyString(oldUiShema) && !isEmptyString(newUiShema);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DatabaseConnection dbConn = (DatabaseConnection) conn;
|
||||
boolean hasCatalog = ConnectionHelper.hasCatalog(dbConn);
|
||||
boolean hasSchema = ConnectionHelper.hasSchema(dbConn);
|
||||
ContextType newContextType = ConnectionContextHelper.getContextTypeForContextMode(dbConn,
|
||||
selectedContext, false);
|
||||
ContextType oldContextType = ConnectionContextHelper.getContextTypeForContextMode(dbConn,
|
||||
oldContextName, false);
|
||||
String newSidOrDatabase = ConnectionContextHelper.getOriginalValue(newContextType, dbConn.getSID());
|
||||
String newUiShema = ConnectionContextHelper.getOriginalValue(newContextType, dbConn.getUiSchema());
|
||||
String oldSidOrDatabase = ConnectionContextHelper.getOriginalValue(oldContextType, dbConn.getSID());
|
||||
String oldUiShema = ConnectionContextHelper.getOriginalValue(oldContextType, dbConn.getUiSchema());
|
||||
if (hasCatalog) {// for example mysql
|
||||
retCode = checkEmpty(newSidOrDatabase, oldSidOrDatabase);
|
||||
if (hasSchema) {// for example mssql
|
||||
retCode &= checkEmpty(newUiShema, oldUiShema);
|
||||
}
|
||||
} else if (hasSchema) {// for example oracle
|
||||
retCode = checkEmpty(newUiShema, oldUiShema);
|
||||
}else {//some db didnot have catelog and schema
|
||||
retCode = true;
|
||||
}
|
||||
// Added TDQ-18565
|
||||
if (!retCode && GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
|
||||
ITDQRepositoryService tdqRepService = GlobalServiceRegister.getDefault()
|
||||
.getService(ITDQRepositoryService.class);
|
||||
if (!tdqRepService.hasClientDependences(connItem)) {
|
||||
retCode = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (conn instanceof FileConnection) {
|
||||
retCode = true;
|
||||
}
|
||||
|
||||
|
||||
return retCode;
|
||||
|
||||
}
|
||||
|
||||
private boolean checkEmpty(String newSidOrDatabase, String oldSidOrDatabase) {
|
||||
if (isEmptyString(oldSidOrDatabase) && isEmptyString(newSidOrDatabase)) {
|
||||
return true;
|
||||
}
|
||||
return !isEmptyString(oldSidOrDatabase) && !isEmptyString(newSidOrDatabase);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* change context Group need to synchronization name of catalog or schema
|
||||
|
||||
@@ -60,6 +60,8 @@ import org.talend.core.model.metadata.builder.database.JavaSqlFactory;
|
||||
import org.talend.core.model.metadata.builder.database.PluginConstant;
|
||||
import org.talend.core.model.metadata.builder.database.TableInfoParameters;
|
||||
import org.talend.core.model.metadata.builder.database.manager.ExtractManager;
|
||||
import org.talend.core.model.metadata.types.JavaTypesManager;
|
||||
import org.talend.core.model.metadata.types.PerlTypesManager;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.service.TalendCWMService;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
@@ -1613,6 +1615,12 @@ public class DBConnectionFillerImpl extends MetadataFillerImpl<DatabaseConnectio
|
||||
ExtractMetaDataUtils.getInstance().getIntMetaDataInfo(columns, "DECIMAL_DIGITS"));
|
||||
column.setTalendType(talendType);
|
||||
column.setSourceType(typeName);
|
||||
if (JavaTypesManager.DATE.getId().equals(talendType)
|
||||
|| PerlTypesManager.DATE.equals(talendType)) {
|
||||
String pattern1 = mappingTypeRetriever.getDefaultPattern(dbmsId, typeName);
|
||||
column.setPattern(StringUtils.isNotBlank(pattern1) ? TalendQuoteUtils.addQuotes(pattern1)
|
||||
: TalendQuoteUtils.addQuotes("dd-MM-yyyy"));//$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
@@ -1801,6 +1809,12 @@ public class DBConnectionFillerImpl extends MetadataFillerImpl<DatabaseConnectio
|
||||
column.setTalendType(talendType);
|
||||
String defaultSelectedDbType = mappingTypeRetriever.getDefaultSelectedDbType(talendType);
|
||||
column.setSourceType(defaultSelectedDbType);
|
||||
if (JavaTypesManager.DATE.getId().equals(talendType)
|
||||
|| PerlTypesManager.DATE.equals(talendType)) {
|
||||
String pattern1 = mappingTypeRetriever.getDefaultPattern(dbmsId, defaultSelectedDbType);
|
||||
column.setPattern(StringUtils.isNotBlank(pattern1) ? TalendQuoteUtils.addQuotes(pattern1)
|
||||
: TalendQuoteUtils.addQuotes("dd-MM-yyyy"));//$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
// Comment
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -907,6 +908,14 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Avoid conflicts between different timezone
|
||||
*/
|
||||
Optional.ofNullable(project).map(p -> p.getEmfProject()).ifPresent(p -> {
|
||||
p.setCreationDate(null);
|
||||
p.setDeleteDate(null);
|
||||
});
|
||||
|
||||
xmiResourceManager.saveResource(projectResource);
|
||||
project.getEmfProject().getMigrationTask().addAll(realMigrationTaskList);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.common.util.EMap;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.window.Window;
|
||||
@@ -560,8 +561,8 @@ public class DatabaseWizard extends CheckLastVersionRepositoryWizard implements
|
||||
isSuccess = SwitchContextGroupNameImpl
|
||||
.getInstance()
|
||||
.updateContextGroup(connectionItem, contextName, originalSelectedContextType.getName());
|
||||
if (!isSuccess) {
|
||||
tdqRepService.popupSwitchContextFailedMessage(contextName);
|
||||
if (!isSuccess) {
|
||||
isSuccess = tdqRepService.popupSwitchContextFailedMessage(contextName);
|
||||
}else {
|
||||
isSuccess &= handleDatabaseUpdate(metadataConnection, tdqRepService);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.language.LanguageManager;
|
||||
import org.talend.core.model.metadata.IMetadataConnection;
|
||||
import org.talend.core.model.metadata.MappingTypeRetriever;
|
||||
import org.talend.core.model.metadata.MetadataTalendType;
|
||||
import org.talend.core.model.metadata.MetadataToolHelper;
|
||||
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
|
||||
@@ -1154,7 +1155,7 @@ public class DatabaseTableForm extends AbstractForm {
|
||||
}
|
||||
|
||||
tableEditorView.getMetadataEditor().removeAll();
|
||||
|
||||
MappingTypeRetriever mappingTypeRetriever = getMappingTypeRetriever();
|
||||
List<MetadataColumn> metadataColumnsValid = new ArrayList<MetadataColumn>();
|
||||
Iterator iterate = metadataColumns.iterator();
|
||||
while (iterate.hasNext()) {
|
||||
@@ -1162,7 +1163,12 @@ public class DatabaseTableForm extends AbstractForm {
|
||||
if (metadataColumn.getTalendType().equals(JavaTypesManager.DATE.getId())
|
||||
|| metadataColumn.getTalendType().equals(PerlTypesManager.DATE)) {
|
||||
if ("".equals(metadataColumn.getPattern())) { //$NON-NLS-1$
|
||||
metadataColumn.setPattern(TalendQuoteUtils.addQuotes("dd-MM-yyyy")); //$NON-NLS-1$
|
||||
if (mappingTypeRetriever != null) {
|
||||
String pattern = getPatternFromMapping(mappingTypeRetriever, metadataColumn.getSourceType());
|
||||
metadataColumn.setPattern(pattern);// $NON-NLS-1$
|
||||
} else {
|
||||
metadataColumn.setPattern(TalendQuoteUtils.addQuotes("dd-MM-yyyy")); //$NON-NLS-1$
|
||||
}
|
||||
if (EDatabaseTypeName.MSSQL.getDisplayName().equals(metadataconnection.getDbType())) {
|
||||
if ("TIME".equals(metadataColumn.getSourceType())) {
|
||||
metadataColumn.setPattern(TalendQuoteUtils.addQuotes("HH:mm:ss")); //$NON-NLS-1$
|
||||
@@ -1214,6 +1220,7 @@ public class DatabaseTableForm extends AbstractForm {
|
||||
return;
|
||||
}
|
||||
boolean isHive = EDatabaseTypeName.HIVE.getDisplayName().equals(metadataconnection.getDbType());
|
||||
MappingTypeRetriever mappingTypeRetriever = getMappingTypeRetriever();
|
||||
int numbOfColumn = schemaContent.get(0).length;
|
||||
for (int i = 1; i <= numbOfColumn; i++) {
|
||||
MetadataColumn oneColum = columns.get(i - 1);
|
||||
@@ -1245,6 +1252,13 @@ public class DatabaseTableForm extends AbstractForm {
|
||||
dbType = TypesManager.getDBTypeFromTalendType(mappingID, oneColum.getTalendType());
|
||||
}
|
||||
oneColum.setSourceType(dbType);
|
||||
if (mappingTypeRetriever != null) {
|
||||
if (JavaTypesManager.DATE.getId().equals(talendType)
|
||||
|| PerlTypesManager.DATE.equals(talendType)) {
|
||||
String pattern1 = getPatternFromMapping(mappingTypeRetriever, dbType);
|
||||
oneColum.setPattern(pattern1);// $NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1277,6 +1291,25 @@ public class DatabaseTableForm extends AbstractForm {
|
||||
|
||||
}
|
||||
|
||||
private MappingTypeRetriever getMappingTypeRetriever() {
|
||||
String dbmsId = metadataconnection.getMapping();
|
||||
MappingTypeRetriever mappingTypeRetriever = MetadataTalendType.getMappingTypeRetriever(dbmsId);
|
||||
if (mappingTypeRetriever == null) {
|
||||
@SuppressWarnings("null")
|
||||
EDatabaseTypeName dbType = EDatabaseTypeName.getTypeFromDbType(metadataconnection.getDbType(), false);
|
||||
if (dbType != null) {
|
||||
mappingTypeRetriever = MetadataTalendType.getMappingTypeRetrieverByProduct(dbType.getProduct());
|
||||
}
|
||||
}
|
||||
return mappingTypeRetriever;
|
||||
}
|
||||
|
||||
private String getPatternFromMapping(MappingTypeRetriever mappingTypeRetriever, String dbType) {
|
||||
String pattern1 = mappingTypeRetriever.getDefaultPattern(metadataconnection.getMapping(), dbType);
|
||||
return StringUtils.isNotBlank(pattern1) ? TalendQuoteUtils.addQuotes(pattern1)
|
||||
: TalendQuoteUtils.addQuotes("dd-MM-yyyy");//$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.Set;
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
@@ -82,6 +83,8 @@ import org.talend.commons.utils.threading.TalendCustomThreadPoolExecutor;
|
||||
import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.database.conn.ConnParameterKeys;
|
||||
import org.talend.core.model.metadata.IMetadataConnection;
|
||||
import org.talend.core.model.metadata.MappingTypeRetriever;
|
||||
import org.talend.core.model.metadata.MetadataTalendType;
|
||||
import org.talend.core.model.metadata.MetadataToolHelper;
|
||||
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataColumn;
|
||||
@@ -1580,7 +1583,15 @@ public class SelectorTableForm extends AbstractForm {
|
||||
dbtable.setSourceName(tableString);
|
||||
dbtable.setId(factory.getNextId());
|
||||
dbtable.setTableType(tableNode.getItemType());
|
||||
|
||||
String dbmsId = metadataconnection.getMapping();
|
||||
MappingTypeRetriever mappingTypeRetriever = MetadataTalendType.getMappingTypeRetriever(dbmsId);
|
||||
if (mappingTypeRetriever == null) {
|
||||
@SuppressWarnings("null")
|
||||
EDatabaseTypeName dbType = EDatabaseTypeName.getTypeFromDbType(metadataconnection.getDbType(), false);
|
||||
if (dbType != null) {
|
||||
mappingTypeRetriever = MetadataTalendType.getMappingTypeRetrieverByProduct(dbType.getProduct());
|
||||
}
|
||||
}
|
||||
List<MetadataColumn> metadataColumnsValid = new ArrayList<MetadataColumn>();
|
||||
Iterator iterate = metadataColumns.iterator();
|
||||
while (iterate.hasNext()) {
|
||||
@@ -1589,7 +1600,14 @@ public class SelectorTableForm extends AbstractForm {
|
||||
if (metadataColumn.getTalendType().equals(JavaTypesManager.DATE.getId())
|
||||
|| metadataColumn.getTalendType().equals(PerlTypesManager.DATE)) {
|
||||
if ("".equals(metadataColumn.getPattern())) { //$NON-NLS-1$
|
||||
metadataColumn.setPattern(TalendQuoteUtils.addQuotes("dd-MM-yyyy")); //$NON-NLS-1$
|
||||
if (mappingTypeRetriever != null) {
|
||||
String pattern = mappingTypeRetriever.getDefaultPattern(dbmsId,
|
||||
metadataColumn.getSourceType());
|
||||
metadataColumn.setPattern(StringUtils.isNotBlank(pattern) ? TalendQuoteUtils.addQuotes(pattern)
|
||||
: TalendQuoteUtils.addQuotes("dd-MM-yyyy"));//$NON-NLS-1$
|
||||
} else {
|
||||
metadataColumn.setPattern(TalendQuoteUtils.addQuotes("dd-MM-yyyy")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,14 +13,24 @@
|
||||
package org.talend.updates.runtime.maven;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.IRepositoryArtifactHandler;
|
||||
import org.talend.core.nexus.RepositoryArtifactHandlerManager;
|
||||
import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
@@ -41,6 +51,8 @@ public class MavenRepoSynchronizer {
|
||||
|
||||
private boolean deployToRemote;
|
||||
|
||||
private static final String POM_EXT = '.' + TalendMavenConstants.PACKAGING_POM;
|
||||
|
||||
public MavenRepoSynchronizer(File sourceM2Root, boolean deployToRemote) {
|
||||
super();
|
||||
this.sourceM2Root = sourceM2Root;
|
||||
@@ -60,75 +72,200 @@ public class MavenRepoSynchronizer {
|
||||
}
|
||||
|
||||
protected void installM2RepositoryLibs(File parentFolder) {
|
||||
if (parentFolder != null && parentFolder.exists() && parentFolder.isDirectory()) {
|
||||
final File[] allFiles = parentFolder.listFiles();
|
||||
if (allFiles == null) {
|
||||
return;
|
||||
}
|
||||
List<File> pomFiles = new ArrayList<File>();
|
||||
List<File> subFiles = new ArrayList<File>();
|
||||
final String pomExt = '.' + TalendMavenConstants.PACKAGING_POM;
|
||||
for (File file : allFiles) {
|
||||
if (file.isDirectory()) {
|
||||
subFiles.add(file);
|
||||
} else if (file.isFile()) {
|
||||
if (file.getName().endsWith(pomExt)) {
|
||||
pomFiles.add(file);
|
||||
}
|
||||
|
||||
Set<File> allPomFiles = new HashSet<File>();
|
||||
|
||||
getAllPomFiles(allPomFiles, parentFolder);
|
||||
|
||||
Set<File> deployedPomFiles = getDeployedPomFiles(allPomFiles);
|
||||
|
||||
for (File pomFile : allPomFiles) {
|
||||
try {
|
||||
ExtendedMavenArtifact artifact = parseArtifact(pomFile);
|
||||
if (artifact == null || artifact.getArtifact() == null) {
|
||||
Exception e = new RuntimeException("Can not parse artifact from pomFile: " + pomFile);
|
||||
ExceptionHandler.process(e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (File pomFile : pomFiles) {
|
||||
try {
|
||||
Model model = MavenPlugin.getMaven().readModel(pomFile);
|
||||
String packaging = model.getPackaging();
|
||||
if (packaging == null) {
|
||||
packaging = TalendMavenConstants.PACKAGING_JAR;
|
||||
}
|
||||
boolean isMavenPlugin = packaging.equals("maven-plugin"); //$NON-NLS-1$
|
||||
// use jar instead
|
||||
if (packaging.equals("bundle") || isMavenPlugin) { //$NON-NLS-1$
|
||||
packaging = TalendMavenConstants.PACKAGING_JAR;
|
||||
}
|
||||
final String groupId = (model.getGroupId() != null ? model.getGroupId() : model.getParent().getGroupId());
|
||||
final String artifactId = model.getArtifactId();
|
||||
final String version = (model.getVersion() != null ? model.getVersion() : model.getParent().getVersion());
|
||||
|
||||
final String mvnUrl = MavenUrlHelper.generateMvnUrl(groupId, artifactId, version, packaging, null);
|
||||
IPath libPath = new Path(pomFile.getAbsolutePath()).removeFileExtension()
|
||||
.addFileExtension(artifact.getArtifact().getType());
|
||||
final File libFile = libPath.toFile();
|
||||
if (libFile.exists()) {
|
||||
final File tempFolder = FileUtils.createTmpFolder("generate", "pom"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
try {
|
||||
|
||||
IPath libPath = new Path(pomFile.getAbsolutePath()).removeFileExtension().addFileExtension(packaging);
|
||||
final File libFile = libPath.toFile();
|
||||
if (libFile.exists()) {
|
||||
final File tempFolder = FileUtils.createTmpFolder("generate", "pom"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
try {
|
||||
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(mvnUrl);
|
||||
final String jarPath = libFile.getAbsolutePath();
|
||||
|
||||
final String jarPath = libFile.getAbsolutePath();
|
||||
|
||||
// final String pomPath=pomFile.getAbsolutePath();
|
||||
// TUP-17785, make sure generate new one always without any dependences, so null
|
||||
String pomPath;
|
||||
if (isMavenPlugin) {
|
||||
// use original pom to keep dependencies for maven plugins
|
||||
pomPath = pomFile.getAbsolutePath();
|
||||
} else {
|
||||
pomPath = PomUtil.generatePomInFolder(tempFolder, artifact);
|
||||
}
|
||||
deployer.install(mvnUrl, jarPath, pomPath, deployToRemote);
|
||||
} finally {
|
||||
if (tempFolder.exists()) {
|
||||
FilesUtils.deleteFolder(tempFolder, true);
|
||||
}
|
||||
// final String pomPath=pomFile.getAbsolutePath();
|
||||
// TUP-17785, make sure generate new one always without any dependences, so null
|
||||
String pomPath;
|
||||
if (artifact.isMavenPlugin()) {
|
||||
// use original pom to keep dependencies for maven plugins
|
||||
pomPath = pomFile.getAbsolutePath();
|
||||
} else {
|
||||
pomPath = PomUtil.generatePomInFolder(tempFolder, artifact.getArtifact());
|
||||
}
|
||||
boolean deploy = deployToRemote;
|
||||
if (deployedPomFiles.contains(pomFile)) {
|
||||
deploy = false;
|
||||
}
|
||||
deployer.install(artifact.getMvnUrl(), jarPath, pomPath, deploy);
|
||||
} finally {
|
||||
if (tempFolder.exists()) {
|
||||
FilesUtils.deleteFolder(tempFolder, true);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
// children folders
|
||||
for (File subFolder : subFiles) {
|
||||
installM2RepositoryLibs(subFolder);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void getAllPomFiles(Set<File> allPomsFiles, File parentFolder) {
|
||||
if (parentFolder != null && parentFolder.exists() && parentFolder.isDirectory()) {
|
||||
File[] allFiles = parentFolder.listFiles();
|
||||
if (allFiles == null || allFiles.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (File file : allFiles) {
|
||||
if (file.isDirectory()) {
|
||||
getAllPomFiles(allPomsFiles, file);
|
||||
} else if (file.isFile()) {
|
||||
if (file.getName().endsWith(POM_EXT)) {
|
||||
allPomsFiles.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ExtendedMavenArtifact parseArtifact(File pomFile) {
|
||||
try {
|
||||
Model model = MavenPlugin.getMaven().readModel(pomFile);
|
||||
String packaging = model.getPackaging();
|
||||
if (packaging == null) {
|
||||
packaging = TalendMavenConstants.PACKAGING_JAR;
|
||||
}
|
||||
boolean isMavenPlugin = packaging.equals("maven-plugin"); //$NON-NLS-1$
|
||||
// use jar instead
|
||||
if (packaging.equals("bundle") || isMavenPlugin) { //$NON-NLS-1$
|
||||
packaging = TalendMavenConstants.PACKAGING_JAR;
|
||||
}
|
||||
final String groupId = (model.getGroupId() != null ? model.getGroupId() : model.getParent().getGroupId());
|
||||
final String artifactId = model.getArtifactId();
|
||||
final String version = (model.getVersion() != null ? model.getVersion() : model.getParent().getVersion());
|
||||
|
||||
final String mvnUrl = MavenUrlHelper.generateMvnUrl(groupId, artifactId, version, packaging, null);
|
||||
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(mvnUrl);
|
||||
return new ExtendedMavenArtifact(mvnUrl, artifact, isMavenPlugin);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Set<File> getDeployedPomFiles(Set<File> allPomFiles) {
|
||||
Set<File> ret = new HashSet<File>();
|
||||
|
||||
Map<MavenArtifact, File> artifact2Poms = new HashMap<MavenArtifact, File>();
|
||||
Set<String> releaseGroupIds = new HashSet<String>();
|
||||
Set<String> snapshotGroupIds = new HashSet<String>();
|
||||
for (File pomFile : allPomFiles) {
|
||||
ExtendedMavenArtifact eart = parseArtifact(pomFile);
|
||||
|
||||
if (eart != null && eart.getArtifact() != null) {
|
||||
MavenArtifact art = eart.getArtifact();
|
||||
artifact2Poms.put(art, pomFile);
|
||||
if (art.getVersion() != null && art.getVersion().toUpperCase().endsWith(MavenUrlHelper.VERSION_SNAPSHOT)) {
|
||||
if (art.getGroupId() != null) {
|
||||
snapshotGroupIds.add(art.getGroupId());
|
||||
}
|
||||
} else {
|
||||
if (art.getGroupId() != null) {
|
||||
releaseGroupIds.add(art.getGroupId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Set<MavenArtifact> deployedArts = new HashSet<MavenArtifact>();
|
||||
// search release repository of remote artifactory server
|
||||
ArtifactRepositoryBean artifactServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
|
||||
IRepositoryArtifactHandler artifactHandler = RepositoryArtifactHandlerManager.getRepositoryHandler(artifactServer);
|
||||
if (artifactHandler != null) {
|
||||
try {
|
||||
for (String gid : releaseGroupIds) {
|
||||
List<MavenArtifact> searchResults = artifactHandler.search(gid, null, null, true, false);
|
||||
if (searchResults != null && !searchResults.isEmpty()) {
|
||||
deployedArts.addAll(searchResults);
|
||||
}
|
||||
}
|
||||
for (String gid : snapshotGroupIds) {
|
||||
List<MavenArtifact> searchResults = artifactHandler.search(gid, null, null, false, true);
|
||||
if (searchResults != null && !searchResults.isEmpty()) {
|
||||
deployedArts.addAll(searchResults);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
// check sha1
|
||||
for (MavenArtifact art : deployedArts) {
|
||||
File pomFile = artifact2Poms.get(art);
|
||||
if (pomFile != null) {
|
||||
IPath libPath = new Path(pomFile.getAbsolutePath()).removeFileExtension().addFileExtension(art.getType());
|
||||
final File libFile = libPath.toFile();
|
||||
if (libFile.exists()) {
|
||||
String sha1 = getSHA1(libFile);
|
||||
if (art.getSha1() != null && art.getSha1().equals(sha1)) {
|
||||
// already deployed
|
||||
ret.add(pomFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String getSHA1(File f) {
|
||||
try (InputStream fi = new FileInputStream(f)) {
|
||||
return DigestUtils.shaHex(fi);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static class ExtendedMavenArtifact {
|
||||
|
||||
private MavenArtifact artifact;
|
||||
|
||||
private boolean isMavenPlugin;
|
||||
|
||||
private String mvnUrl;
|
||||
|
||||
public ExtendedMavenArtifact(String mvnUrl, MavenArtifact artifact, boolean isMavenPlugin) {
|
||||
this.artifact = artifact;
|
||||
this.isMavenPlugin = isMavenPlugin;
|
||||
this.mvnUrl = mvnUrl;
|
||||
}
|
||||
|
||||
public MavenArtifact getArtifact() {
|
||||
return artifact;
|
||||
}
|
||||
|
||||
public boolean isMavenPlugin() {
|
||||
return isMavenPlugin;
|
||||
}
|
||||
|
||||
public String getMvnUrl() {
|
||||
return mvnUrl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +238,8 @@ public class UpdateTools {
|
||||
validInstall.stream().filter(iu -> !extraBundles.containsKey(iu.getId()) || extraBundles.get(iu.getId()).isEmpty())
|
||||
.forEach(iu -> {
|
||||
List<String> list = plugins.stream()
|
||||
.filter(f -> f.exists() && f.getName().startsWith(iu.getId() + "_")
|
||||
.filter(f -> f.getName().startsWith(iu.getId()
|
||||
+ "_")
|
||||
&& !f.getName().contains(iu.getId() + "_" + iu.getVersion()))
|
||||
.map(File::getAbsolutePath).collect(Collectors.toList());
|
||||
dropList.addAll(list);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<!--
|
||||
Copyright (C) 2010 Talend Inc. - www.talend.com
|
||||
<!--
|
||||
Copyright (C) 2010 Talend Inc. - www.talend.com
|
||||
-->
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -12,7 +12,7 @@
|
||||
<parent>
|
||||
<groupId>org.talend</groupId>
|
||||
<artifactId>org.talend.tos</artifactId>
|
||||
<version>7.3.2-SNAPSHOT</version>
|
||||
<version>7.3.1.PATCH</version>
|
||||
<relativePath>../pom_server.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<!--
|
||||
Copyright (C) 2010 Talend Inc. - www.talend.com
|
||||
<!--
|
||||
Copyright (C) 2010 Talend Inc. - www.talend.com
|
||||
-->
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -12,7 +12,7 @@
|
||||
<parent>
|
||||
<groupId>org.talend</groupId>
|
||||
<artifactId>org.talend.tos</artifactId>
|
||||
<version>7.3.2-SNAPSHOT</version>
|
||||
<version>7.3.1.PATCH</version>
|
||||
<relativePath>../pom_server.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -297,6 +297,9 @@ public class FileDirCleaner {
|
||||
if (checkFilter(fileDirJob)) {
|
||||
if (doAction) {
|
||||
org.apache.commons.io.FileUtils.deleteDirectory(fileDirJob);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Deleted directory: " + fileDirJob);
|
||||
}
|
||||
} else {
|
||||
StringBuilder reason = new StringBuilder();
|
||||
String sep = "";
|
||||
@@ -321,6 +324,9 @@ public class FileDirCleaner {
|
||||
if (checkFilter(fileDirJob)) {
|
||||
if (doAction) {
|
||||
org.apache.commons.io.FileUtils.forceDelete(fileDirJob);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Deleted file: " + fileDirJob);
|
||||
}
|
||||
} else {
|
||||
StringBuilder reason = new StringBuilder();
|
||||
String sep = "";
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<!--
|
||||
Copyright (C) 2010 Talend Inc. - www.talend.com
|
||||
<!--
|
||||
Copyright (C) 2010 Talend Inc. - www.talend.com
|
||||
-->
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.talend</groupId>
|
||||
<artifactId>org.talend.tos</artifactId>
|
||||
<version>7.3.2-SNAPSHOT</version>
|
||||
<version>7.3.1.PATCH</version>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
@@ -62,8 +62,9 @@ public class VersionUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testGetMojoVersion() throws Exception {
|
||||
testMojoVersion(MojoType.CI_BUILDER, "-SNAPSHOT");
|
||||
testMojoVersion(MojoType.CI_BUILDER, "-M3");
|
||||
// testMojoVersion(MojoType.CI_BUILDER, "-SNAPSHOT");
|
||||
// testMojoVersion(MojoType.CI_BUILDER, "-M3");
|
||||
// only return latest version now
|
||||
testMojoVersion(MojoType.CI_BUILDER, "");
|
||||
}
|
||||
|
||||
@@ -74,7 +75,7 @@ public class VersionUtilsTest {
|
||||
File artifactIdFolder = new File(mojoType.getMojoArtifactIdFolder());
|
||||
String majorVersion = StringUtils.substringBeforeLast(talendVersion, ".");
|
||||
String minorVersion = StringUtils.substringAfterLast(talendVersion, ".");
|
||||
minorVersion = (Integer.valueOf(minorVersion) + 2) + "";
|
||||
minorVersion = (Integer.valueOf(minorVersion) + 200) + "";
|
||||
testVersion = majorVersion + "." + minorVersion + testVersion;
|
||||
File versionFolder = new File(artifactIdFolder, testVersion);
|
||||
versionFolder.mkdir();
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.repository.handlers;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -25,13 +29,14 @@ import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.relationship.Relation;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
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.core.model.utils.emf.talendfile.TalendFileFactory;
|
||||
import org.talend.designer.joblet.model.JobletFactory;
|
||||
import org.talend.designer.joblet.model.JobletProcess;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
*/
|
||||
@@ -114,16 +119,49 @@ public class JobAndNodesParametersRelationshipHandlerTest {
|
||||
|
||||
Map<Relation, Set<Relation>> relations = handler.find(item);
|
||||
Assert.assertNotNull(relations);
|
||||
Assert.assertTrue(relations.size() > 0);
|
||||
Assert.assertTrue(relations.values().isEmpty());
|
||||
|
||||
Relation processRelation = relations.keySet().iterator().next();
|
||||
Assert.assertNotNull(processRelation);
|
||||
Assert.assertEquals(AbstractProcessItemRelationshipHandlerTest.ITEM_ID, processRelation.getId());
|
||||
Assert.assertEquals("0.1", processRelation.getVersion());
|
||||
Assert.assertEquals(RelationshipItemBuilder.JOB_RELATION, processRelation.getType());
|
||||
}
|
||||
|
||||
Set<Relation> set = relations.get(processRelation);
|
||||
Assert.assertNotNull(set);
|
||||
Assert.assertTrue(set.isEmpty()); // no relations
|
||||
@Test
|
||||
public void testFindParameters() {
|
||||
ProcessItem item = PropertiesFactory.eINSTANCE.createProcessItem();
|
||||
Property property = PropertiesFactory.eINSTANCE.createProperty();
|
||||
property.setId(AbstractProcessItemRelationshipHandlerTest.ITEM_ID);
|
||||
property.setVersion("0.1");
|
||||
property.setLabel("test");
|
||||
item.setProperty(property);
|
||||
ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
|
||||
item.setProcess(process);
|
||||
|
||||
NodeType node = TalendFileFactory.eINSTANCE.createNodeType();
|
||||
node.setComponentName("tRunJob");
|
||||
ElementParameterType param = TalendFileFactory.eINSTANCE.createElementParameterType();
|
||||
param.setName("PROCESS:PROCESS_TYPE_VERSION");
|
||||
param.setValue(RelationshipItemBuilder.LATEST_VERSION);
|
||||
String relatedId = "project" + ":" + ProxyRepositoryFactory.getInstance().getNextId();
|
||||
ElementParameterType param1 = TalendFileFactory.eINSTANCE.createElementParameterType();
|
||||
param1.setName("PROCESS:PROCESS_TYPE_PROCESS");
|
||||
param1.setValue(relatedId);
|
||||
|
||||
node.getElementParameter().add(param);
|
||||
node.getElementParameter().add(param1);
|
||||
process.getNode().add(node);
|
||||
|
||||
Map<Relation, Set<Relation>> relationsMap = handler.find(item);
|
||||
Assert.assertNotNull(relationsMap);
|
||||
Assert.assertTrue(relationsMap.values().size() > 0);
|
||||
Relation baseRelation = relationsMap.keySet().iterator().next();
|
||||
Assert.assertNotNull(baseRelation);
|
||||
Assert.assertEquals(property.getId(), baseRelation.getId());
|
||||
Assert.assertEquals(property.getVersion(), baseRelation.getVersion());
|
||||
Assert.assertEquals(RelationshipItemBuilder.JOB_RELATION, baseRelation.getType());
|
||||
Set<Relation> relatedRelations = relationsMap.get(baseRelation);
|
||||
Assert.assertNotNull(relatedRelations);
|
||||
Assert.assertTrue(relatedRelations.size() > 0);
|
||||
Relation relatedRelation = relatedRelations.iterator().next();
|
||||
Assert.assertEquals(relatedId, relatedRelation.getId());
|
||||
Assert.assertEquals(RelationshipItemBuilder.LATEST_VERSION, relatedRelation.getVersion());
|
||||
Assert.assertEquals(RelationshipItemBuilder.JOB_RELATION, relatedRelation.getType());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ package org.talend.core.model.metadata;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -66,5 +69,19 @@ public class MappingTypeRetrieverTest {
|
||||
MappingTypeRetriever mappingType = MetadataTalendType.getMappingTypeRetriever(dbmsId);
|
||||
assertTrue(mappingType.isPrecisionIgnored(dbmsId, dbType));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDefaultPattern() {
|
||||
String dbmsId = "sybase_id";
|
||||
String dbType = "DATE";
|
||||
MappingTypeRetriever mappingType = MetadataTalendType.getMappingTypeRetriever(dbmsId);
|
||||
String defaultPattern1 = mappingType.getDefaultPattern(dbmsId, dbType);
|
||||
assertTrue("dd-MM-yyyy".equalsIgnoreCase(defaultPattern1));
|
||||
|
||||
dbType = "DATETIME";
|
||||
mappingType = MetadataTalendType.getMappingTypeRetriever(dbmsId);
|
||||
String defaultPattern2 = mappingType.getDefaultPattern(dbmsId, dbType);
|
||||
assertTrue(StringUtils.isBlank(defaultPattern2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -186,4 +186,29 @@ public class RelationshipItemBuilderTest {
|
||||
assert (ProjectManager.getInstance().getCurrentProject() == RelationshipItemBuilder.getInstance().getAimProject());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* For TUP-26138
|
||||
*/
|
||||
@Test
|
||||
public void testBuildAndSaveIndex() {
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
|
||||
int shouldBeSize = RelationshipItemBuilder.getInstance().getCurrentProjectItemsRelations().size();
|
||||
currentProject = RelationshipItemBuilder.getInstance().getAimProject();
|
||||
assert (shouldBeSize > 0);
|
||||
System.out.println("testBuildAndSaveIndex, shouldBeSize: " + shouldBeSize);
|
||||
|
||||
// remove all of relations from index
|
||||
RelationshipItemBuilder.getInstance().clearAllItemsRelations();
|
||||
RelationshipItemBuilder.getInstance().saveRelations();
|
||||
|
||||
assert (currentProject.getEmfProject().getItemsRelations().size() == 0);
|
||||
|
||||
// regenerate index
|
||||
RelationshipItemBuilder.getInstance().buildAndSaveIndex();
|
||||
|
||||
int currentSize = currentProject.getEmfProject().getItemsRelations().size();
|
||||
assert (shouldBeSize == currentSize);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user