Compare commits
36 Commits
master
...
patch/5.6.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5732167659 | ||
|
|
132ba66da2 | ||
|
|
15ee866667 | ||
|
|
7901098008 | ||
|
|
7c4b904341 | ||
|
|
f4a5efb0e7 | ||
|
|
33cc7afb69 | ||
|
|
dd40b5e197 | ||
|
|
dc1ab69b0b | ||
|
|
c9ad89a40e | ||
|
|
0a57579b4c | ||
|
|
eef96df710 | ||
|
|
96c8aba7e7 | ||
|
|
fc07712ba0 | ||
|
|
0814b6788d | ||
|
|
05f50981c7 | ||
|
|
acb60f82f9 | ||
|
|
a5dea96768 | ||
|
|
c3682b24de | ||
|
|
b94ec129c2 | ||
|
|
e2992b0c84 | ||
|
|
11cd449a87 | ||
|
|
8055121b2b | ||
|
|
bcfffbf803 | ||
|
|
1d5d61aeff | ||
|
|
064700ee55 | ||
|
|
19d3eba229 | ||
|
|
e00e41f316 | ||
|
|
254895372b | ||
|
|
7f8caad2f4 | ||
|
|
f2126a53e2 | ||
|
|
4cde6cfcb0 | ||
|
|
a0f5761bb9 | ||
|
|
c61fe42ef8 | ||
|
|
e078a0e6b5 | ||
|
|
b3e6fcda1d |
@@ -361,7 +361,18 @@ public class XmiResourceManager {
|
||||
return getItemResource(item, true);
|
||||
}
|
||||
|
||||
public Resource getItemResource(ResourceSet resourceSet, Item item) {
|
||||
return getItemResource(resourceSet, item, true);
|
||||
}
|
||||
|
||||
public Resource getItemResource(Item item, boolean forceLoad) {
|
||||
return getItemResource(getResourceSet(), item, forceLoad);
|
||||
}
|
||||
|
||||
public Resource getItemResource(ResourceSet resourceSet, Item item, boolean forceLoad) {
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
URI itemResourceURI = null;
|
||||
if (item.getFileExtension() != null) {
|
||||
itemResourceURI = getItemResourceURI(getItemURI(item), item.getFileExtension());
|
||||
@@ -371,13 +382,13 @@ public class XmiResourceManager {
|
||||
} else {
|
||||
itemResourceURI = getItemResourceURI(getItemURI(item));
|
||||
}
|
||||
Resource itemResource = getResourceSet().getResource(itemResourceURI, false);
|
||||
Resource itemResource = resourceSet.getResource(itemResourceURI, false);
|
||||
if (forceLoad && itemResource == null) {
|
||||
if (item instanceof FileItem) {
|
||||
itemResource = new ByteArrayResource(itemResourceURI);
|
||||
getResourceSet().getResources().add(itemResource);
|
||||
resourceSet.getResources().add(itemResource);
|
||||
}
|
||||
itemResource = getResourceSet().getResource(itemResourceURI, true);
|
||||
itemResource = resourceSet.getResource(itemResourceURI, true);
|
||||
}
|
||||
return itemResource;
|
||||
}
|
||||
@@ -390,10 +401,14 @@ public class XmiResourceManager {
|
||||
* Get a resource obj from Item resource file. if the resouce file does not exist ,will create it first.
|
||||
*/
|
||||
public Resource getScreenshotResource(Item item, boolean createIfNotExist) {
|
||||
return getScreenshotResource(item, createIfNotExist, false);
|
||||
return getScreenshotResource(getResourceSet(), item, createIfNotExist, false);
|
||||
}
|
||||
|
||||
public Resource getScreenshotResource(Item item, boolean createIfNotExist, boolean forceReload) {
|
||||
return getScreenshotResource(getResourceSet(), item, createIfNotExist, forceReload);
|
||||
}
|
||||
|
||||
public Resource getScreenshotResource(ResourceSet resourceSet, Item item, boolean createIfNotExist, boolean forceReload) {
|
||||
URI itemResourceURI = null;
|
||||
itemResourceURI = getScreenshotResourceURI(getItemURI(item));
|
||||
boolean fileExist = false;
|
||||
@@ -516,6 +531,10 @@ public class XmiResourceManager {
|
||||
// }
|
||||
|
||||
public List<Resource> getAffectedResources(Property property) {
|
||||
return getAffectedResources(getResourceSet(), property);
|
||||
}
|
||||
|
||||
public List<Resource> getAffectedResources(ResourceSet resourceSet, Property property) {
|
||||
List<Resource> resources = new ArrayList<Resource>();
|
||||
List<Resource> allRes = resourceSet.getResources();
|
||||
synchronized (allRes) {
|
||||
@@ -537,8 +556,8 @@ public class XmiResourceManager {
|
||||
if (!currentResource.getURI().lastSegment().equals(getProjectFilename())) {
|
||||
resources.add(currentResource);
|
||||
}
|
||||
if (!getResourceSet().getResources().contains(currentResource)) {
|
||||
getResourceSet().getResources().add(currentResource);
|
||||
if (!resourceSet.getResources().contains(currentResource)) {
|
||||
resourceSet.getResources().add(currentResource);
|
||||
}
|
||||
}
|
||||
if (object instanceof ReferenceFileItem) {
|
||||
@@ -574,14 +593,14 @@ public class XmiResourceManager {
|
||||
resources.add(currentResource);
|
||||
}
|
||||
}
|
||||
if (!getResourceSet().getResources().contains(currentResource)) {
|
||||
getResourceSet().getResources().add(currentResource);
|
||||
if (!resourceSet.getResources().contains(currentResource)) {
|
||||
resourceSet.getResources().add(currentResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (property.getItem() instanceof ProcessItem || property.getItem() instanceof JobletProcessItem) {
|
||||
if (property.eResource() != null) {
|
||||
Resource screenshotResource = getScreenshotResource(property.getItem());
|
||||
Resource screenshotResource = getScreenshotResource(resourceSet, property.getItem(), false, false);
|
||||
if (screenshotResource != null) {
|
||||
resources.add(screenshotResource);
|
||||
}
|
||||
@@ -823,10 +842,14 @@ public class XmiResourceManager {
|
||||
}
|
||||
|
||||
public void unloadResources(Property property) {
|
||||
for (Resource resource : getAffectedResources(property)) {
|
||||
unloadResources(getResourceSet(), property);
|
||||
}
|
||||
|
||||
public void unloadResources(ResourceSet resourceSet, Property property) {
|
||||
for (Resource resource : getAffectedResources(resourceSet, property)) {
|
||||
if (resource != null) {
|
||||
resource.unload();
|
||||
getResourceSet().getResources().remove(resource);
|
||||
resourceSet.getResources().remove(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,11 @@
|
||||
<dbType type="BIGINT" ignorePre="true" />
|
||||
<dbType type="BLOB" ignorePre="true" />
|
||||
<dbType type="BOOLEAN" ignorePre="true" />
|
||||
<dbType type="TEXT" ignorePre="true" />
|
||||
<dbType type="UUID" ignorePre="true" />
|
||||
<dbType type="TIMEUUID" ignorePre="true" />
|
||||
<dbType type="VARINT" ignorePre="true" />
|
||||
<dbType type="INT" ignorePre="true" />
|
||||
<dbType type="FLOAT" defaultLength="20" defaultPrecision="10" />
|
||||
<dbType type="DOUBLE" defaultLength="20" defaultPrecision="10" />
|
||||
<dbType type="DECIMAL" defaultLength="20" defaultPrecision="10" />
|
||||
@@ -60,7 +62,9 @@
|
||||
</talendType>
|
||||
<talendType type="id_Integer">
|
||||
<dbType type="Int32Type" default="true" />
|
||||
<dbType type="IntegerType"/>
|
||||
<dbType type="VARINT" />
|
||||
<dbType type="INT" />
|
||||
</talendType>
|
||||
<talendType type="id_Long">
|
||||
<dbType type="LongType" default="true" />
|
||||
@@ -70,7 +74,6 @@
|
||||
</talendType>
|
||||
<talendType type="id_Object">
|
||||
<dbType type="ObjectType" default="true" />
|
||||
<dbType type="IntegerType" />
|
||||
<dbType type="BLOB" />
|
||||
</talendType>
|
||||
<talendType type="id_Short" />
|
||||
@@ -80,6 +83,7 @@
|
||||
<dbType type="UUIDType" />
|
||||
<dbType type="TimeUUIDType" />
|
||||
<dbType type="ASCII" />
|
||||
<dbType type="TEXT" />
|
||||
<dbType type="UUID" />
|
||||
<dbType type="TIMEUUID" />
|
||||
</talendType>
|
||||
@@ -91,11 +95,14 @@
|
||||
<dbType type="AsciiType">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="TEXT">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="UTF8Type">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="IntegerType">
|
||||
<talendType type="id_Object" default="true" />
|
||||
<talendType type="id_Integer" default="true" />
|
||||
</dbType>
|
||||
<dbType type="Int32Type">
|
||||
<talendType type="id_Integer" default="true" />
|
||||
@@ -152,6 +159,9 @@
|
||||
<dbType type="VARINT">
|
||||
<talendType type="id_Integer" default="true" />
|
||||
</dbType>
|
||||
<dbType type="INT">
|
||||
<talendType type="id_Integer" default="true" />
|
||||
</dbType>
|
||||
<dbType type="FLOAT">
|
||||
<talendType type="id_Float" default="true" />
|
||||
</dbType>
|
||||
|
||||
@@ -90,7 +90,7 @@ public class FilesUtils {
|
||||
if (name != null) {
|
||||
name = name.toLowerCase();
|
||||
for (String element : SVN_FOLDER_NAMES) {
|
||||
if (element.equals(name) || name.endsWith(element)) {
|
||||
if (element.equals(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -484,7 +484,7 @@ public class FilesUtils {
|
||||
}
|
||||
|
||||
public static List<File> getJarFilesFromFolder(File file, String fileName) throws MalformedURLException {
|
||||
return getFilesFromFolderByName(file, fileName, new String[] { ANY_FILE_EXT }, null, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
return getFilesFromFolderByName(file, fileName, new String[] { ANY_FILE_EXT }, null, true);
|
||||
}
|
||||
|
||||
public static List<File> getDllFilesFromFolder(File file, String fileName) throws MalformedURLException {
|
||||
|
||||
@@ -52,7 +52,7 @@ import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
*/
|
||||
public class ContextUtils {
|
||||
|
||||
|
||||
private static final Set<String> JAVA_KEYWORDS = new HashSet<String>(Arrays.asList("abstract", "continue", "for", "new", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
"switch", "assert", "default", "goto", "package", "synchronized", "boolean", "do", "if", "private", "this", "break", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$
|
||||
"double", "implements", "protected", "throw", "byte", "else", "import", "public", "throws", "case", "enum", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$
|
||||
@@ -144,9 +144,10 @@ public class ContextUtils {
|
||||
ContextType defaultContextType = null;
|
||||
for (ContextType type : contextTypeList) {
|
||||
// Modified by Marvin Wang on Jun. 21, 2012 for bug TDI-21009. To avoid case sensitive.
|
||||
if (contextName != null && type.getName().toLowerCase().equals(contextName.toLowerCase())) {
|
||||
if (contextName != null && type.getName() != null && type.getName().toLowerCase().equals(contextName.toLowerCase())) {
|
||||
contextType = type;
|
||||
} else if (defaultContextName != null && type.getName().toLowerCase().equals(defaultContextName.toLowerCase())) {
|
||||
} else if (defaultContextName != null && type.getName() != null
|
||||
&& type.getName().toLowerCase().equals(defaultContextName.toLowerCase())) {
|
||||
defaultContextType = type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,6 +274,11 @@ public class JobContextManager implements IContextManager {
|
||||
Item item = ContextUtils.getRepositoryContextItemById(contextParam.getSource());
|
||||
if (item != null) {
|
||||
contextParamType.setRepositoryContextId(item.getProperty().getId());
|
||||
} else {
|
||||
String contextId = contextParam.getSource();
|
||||
if (!IContextParameter.BUILT_IN.equals(contextId)) {
|
||||
contextParamType.setRepositoryContextId(contextId);
|
||||
}
|
||||
}
|
||||
}
|
||||
contextTypeParamList.add(contextParamType);
|
||||
|
||||
@@ -70,6 +70,11 @@ public class Project {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public Project(org.talend.core.model.properties.Project project, boolean isMainProject) {
|
||||
this.project = project;
|
||||
mainProject = isMainProject;
|
||||
}
|
||||
|
||||
public Project(String label) {
|
||||
this.project = PropertiesFactory.eINSTANCE.createProject();
|
||||
project.setLabel(label);
|
||||
|
||||
@@ -92,6 +92,11 @@ public abstract class AbstractNode implements INode {
|
||||
|
||||
private List<ModuleNeeded> modulesNeeded = new ArrayList<ModuleNeeded>();
|
||||
|
||||
// for DI job, and indicate if the component after the iterator
|
||||
// connection which enable parallel, even this component after
|
||||
// onComponentOk
|
||||
private String parallelIterator = null;
|
||||
|
||||
// as the talend job contains multiple mapreduce jobs, use this to indicate
|
||||
// which mapreduce job contains this
|
||||
// graphic node
|
||||
@@ -530,7 +535,7 @@ public abstract class AbstractNode implements INode {
|
||||
return;
|
||||
}
|
||||
|
||||
for (IElementParameter param : this.getElementParameters()) {
|
||||
for (IElementParameter param : this.getElementParametersWithChildrens()) {
|
||||
if (param.getName().equals("UNIQUE_NAME") || isSQLQueryParameter(param) || isTDMParameter(param)) { //$NON-NLS-1$
|
||||
continue;
|
||||
}
|
||||
@@ -572,7 +577,7 @@ public abstract class AbstractNode implements INode {
|
||||
@Override
|
||||
public boolean useData(String name) {
|
||||
|
||||
for (IElementParameter param : this.getElementParameters()) {
|
||||
for (IElementParameter param : this.getElementParametersWithChildrens()) {
|
||||
if (param.getFieldType() == EParameterFieldType.IMAGE) {
|
||||
continue;
|
||||
}
|
||||
@@ -1201,4 +1206,22 @@ public abstract class AbstractNode implements INode {
|
||||
public void setRefNode(boolean isRefNode) {
|
||||
this.isRefNode = isRefNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for parallelIterator.
|
||||
*
|
||||
* @return the parallelIterator
|
||||
*/
|
||||
public String getParallelIterator() {
|
||||
return parallelIterator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parallelIterator.
|
||||
*
|
||||
* @param parallelIterator the parallelIterator to set
|
||||
*/
|
||||
public void setParallelIterator(String parallelIterator) {
|
||||
this.parallelIterator = parallelIterator;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.ItemRelation;
|
||||
@@ -45,7 +44,6 @@ import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
|
||||
/**
|
||||
* This class store all relationships between jobs/joblets and other items from the repository. Be sure to update the
|
||||
@@ -126,6 +124,10 @@ public class RelationshipItemBuilder {
|
||||
|
||||
private boolean modified = false;
|
||||
|
||||
private Project aimProject;
|
||||
|
||||
private IProxyRepositoryFactory proxyRepositoryFactory;
|
||||
|
||||
public static final String COMMA = ";"; //$NON-NLS-1$
|
||||
|
||||
private static Map<String, RelationshipItemBuilder> projectToInstanceMap = new HashMap<String, RelationshipItemBuilder>();
|
||||
@@ -135,16 +137,78 @@ public class RelationshipItemBuilder {
|
||||
}
|
||||
|
||||
public static RelationshipItemBuilder getInstance() {
|
||||
String currentProject = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
RelationshipItemBuilder relationshipBuilder = getInstance(currentProject, true);
|
||||
return relationshipBuilder;
|
||||
}
|
||||
|
||||
if (projectToInstanceMap.containsKey(currentProject)) {
|
||||
return projectToInstanceMap.get(currentProject);
|
||||
public static RelationshipItemBuilder getInstance(String projectTechnicalName) {
|
||||
synchronized (projectToInstanceMap) {
|
||||
return projectToInstanceMap.get(projectTechnicalName);
|
||||
}
|
||||
}
|
||||
|
||||
public static RelationshipItemBuilder getInstance(Project project, boolean createIfNotExist) {
|
||||
String projectName = project.getTechnicalLabel();
|
||||
|
||||
synchronized (projectToInstanceMap) {
|
||||
if (projectToInstanceMap.containsKey(projectName)) {
|
||||
RelationshipItemBuilder relationshipBuilder = projectToInstanceMap.get(projectName);
|
||||
// refresh current project realtime, in case studio switched project
|
||||
relationshipBuilder.setAimProject(project);
|
||||
return relationshipBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
if (!createIfNotExist) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IProxyRepositoryFactory proxyRepositoryFactory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
RelationshipItemBuilder instance = createInstance(proxyRepositoryFactory, project);
|
||||
synchronized (projectToInstanceMap) {
|
||||
projectToInstanceMap.put(projectName, instance);
|
||||
}
|
||||
RelationshipItemBuilder instance = new RelationshipItemBuilder();
|
||||
projectToInstanceMap.put(currentProject, instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static RelationshipItemBuilder createInstance(IProxyRepositoryFactory repositoryFactory, Project project) {
|
||||
RelationshipItemBuilder instance = new RelationshipItemBuilder();
|
||||
instance.setAimProject(project);
|
||||
instance.setProxyRepositoryFactory(repositoryFactory);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static boolean isExist(Project project) {
|
||||
String projectName = project.getTechnicalLabel();
|
||||
|
||||
if (projectToInstanceMap.containsKey(projectName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Project getAimProject() {
|
||||
return this.aimProject;
|
||||
}
|
||||
|
||||
private void setAimProject(Project aimProject) {
|
||||
this.aimProject = aimProject;
|
||||
}
|
||||
|
||||
private IProxyRepositoryFactory getProxyRepositoryFactory() {
|
||||
return this.proxyRepositoryFactory;
|
||||
}
|
||||
|
||||
public void setProxyRepositoryFactory(IProxyRepositoryFactory proxyRepositoryFactory) {
|
||||
this.proxyRepositoryFactory = proxyRepositoryFactory;
|
||||
}
|
||||
|
||||
public List<Relation> getItemsHaveRelationWith(String itemId) {
|
||||
return getItemsHaveRelationWith(itemId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -154,16 +218,16 @@ public class RelationshipItemBuilder {
|
||||
* @param relationType
|
||||
* @return
|
||||
*/
|
||||
public List<Relation> getItemsHaveRelationWith(String itemId) {
|
||||
public List<Relation> getItemsHaveRelationWith(String itemId, String version) {
|
||||
if (!loaded) {
|
||||
loadRelations();
|
||||
}
|
||||
Set<Relation> relations = new HashSet<Relation>();
|
||||
Set<Relation> itemsRelations = getItemsHaveRelationWith(currentProjectItemsRelations, itemId);
|
||||
Set<Relation> itemsRelations = getItemsHaveRelationWith(currentProjectItemsRelations, itemId, version);
|
||||
if (itemsRelations != null) {
|
||||
relations.addAll(itemsRelations);
|
||||
}
|
||||
itemsRelations = getItemsHaveRelationWith(referencesItemsRelations, itemId);
|
||||
itemsRelations = getItemsHaveRelationWith(referencesItemsRelations, itemId, version);
|
||||
if (itemsRelations != null) {
|
||||
relations.addAll(itemsRelations);
|
||||
}
|
||||
@@ -186,7 +250,20 @@ public class RelationshipItemBuilder {
|
||||
return new ArrayList<Relation>(relations);
|
||||
}
|
||||
|
||||
private Set<Relation> getItemsHaveRelationWith(Map<Relation, Set<Relation>> itemsRelations, String itemId) {
|
||||
/**
|
||||
*
|
||||
* DOC cmeng Comment method "getItemsHaveRelationWith".
|
||||
*
|
||||
* @param itemsRelations
|
||||
* @param itemId
|
||||
* @param version if null, then won't check
|
||||
* @return
|
||||
*/
|
||||
private Set<Relation> getItemsHaveRelationWith(Map<Relation, Set<Relation>> itemsRelations, String itemId, String version) {
|
||||
|
||||
/**
|
||||
* if verison is null, then won't check
|
||||
*/
|
||||
|
||||
Set<Relation> relations = new HashSet<Relation>();
|
||||
|
||||
@@ -206,8 +283,36 @@ public class RelationshipItemBuilder {
|
||||
tmpRelatedItem = relatedItem;
|
||||
}
|
||||
if (tmpRelatedItem != null && itemId.equals(id)) {
|
||||
relations.add(baseItem);
|
||||
break;
|
||||
boolean isEqual = true;
|
||||
|
||||
if (version != null) {
|
||||
/**
|
||||
* if verison is null, then won't check
|
||||
*/
|
||||
String curVersion = tmpRelatedItem.getVersion();
|
||||
|
||||
if (!LATEST_VERSION.equals(version) && LATEST_VERSION.equals(curVersion)) {
|
||||
try {
|
||||
IRepositoryViewObject latest = getProxyRepositoryFactory().getLastVersion(getAimProject(),
|
||||
id);
|
||||
if (latest != null) {
|
||||
curVersion = latest.getVersion();
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
if (version.equals(curVersion)) {
|
||||
isEqual = true;
|
||||
} else {
|
||||
isEqual = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isEqual) {
|
||||
relations.add(baseItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -297,8 +402,16 @@ public class RelationshipItemBuilder {
|
||||
|
||||
public void unloadRelations() {
|
||||
loaded = false;
|
||||
currentProjectItemsRelations = new HashMap<Relation, Set<Relation>>();
|
||||
referencesItemsRelations = new HashMap<Relation, Set<Relation>>();
|
||||
clearAllItemsRelations();
|
||||
}
|
||||
|
||||
public void clearAllItemsRelations() {
|
||||
if (currentProjectItemsRelations != null) {
|
||||
currentProjectItemsRelations.clear();
|
||||
}
|
||||
if (referencesItemsRelations != null) {
|
||||
referencesItemsRelations.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadRelations() {
|
||||
@@ -309,10 +422,10 @@ public class RelationshipItemBuilder {
|
||||
currentProjectItemsRelations = new HashMap<Relation, Set<Relation>>();
|
||||
referencesItemsRelations = new HashMap<Relation, Set<Relation>>();
|
||||
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
loadRelations(currentProjectItemsRelations, currentProject);
|
||||
loadRelations(currentProjectItemsRelations, getAimProject());
|
||||
|
||||
List<Project> referencedProjects = ProjectManager.getInstance().getReferencedProjects();
|
||||
List<Project> referencedProjects = ProjectManager.getInstance().getReferencedProjects(getProxyRepositoryFactory(),
|
||||
getAimProject());
|
||||
for (Project p : referencedProjects) {
|
||||
loadRelations(referencesItemsRelations, p);
|
||||
}
|
||||
@@ -366,7 +479,7 @@ public class RelationshipItemBuilder {
|
||||
if (!loaded && !modified) {
|
||||
return;
|
||||
}
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
Project currentProject = getAimProject();
|
||||
currentProject.getEmfProject().getItemsRelations().clear();
|
||||
|
||||
for (Relation relation : currentProjectItemsRelations.keySet()) {
|
||||
@@ -397,10 +510,7 @@ public class RelationshipItemBuilder {
|
||||
currentProject.getEmfProject().getItemsRelations().add(itemRelations);
|
||||
}
|
||||
try {
|
||||
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(
|
||||
IRepositoryService.class);
|
||||
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
|
||||
factory.saveProject(currentProject);
|
||||
getProxyRepositoryFactory().saveProject(currentProject);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
@@ -465,7 +575,7 @@ public class RelationshipItemBuilder {
|
||||
|
||||
private Map<Relation, Set<Relation>> getRelatedRelations(Item baseItem) {
|
||||
Map<Relation, Set<Relation>> itemRelations = currentProjectItemsRelations;
|
||||
if (!ProjectManager.getInstance().isInCurrentMainProject(baseItem)) {
|
||||
if (!ProjectManager.getInstance().isInMainProject(getAimProject(), baseItem)) {
|
||||
itemRelations = referencesItemsRelations;
|
||||
}
|
||||
return itemRelations;
|
||||
@@ -486,13 +596,12 @@ public class RelationshipItemBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
|
||||
IProxyRepositoryFactory factory = getProxyRepositoryFactory();
|
||||
List<IRepositoryViewObject> list = new ArrayList<IRepositoryViewObject>();
|
||||
try {
|
||||
for (ERepositoryObjectType curTyp : getTypes()) {
|
||||
if (curTyp != null) {
|
||||
list.addAll(factory.getAll(curTyp, true, true));
|
||||
list.addAll(factory.getAll(project, curTyp, true, true));
|
||||
}
|
||||
}
|
||||
monitor.beginTask(Messages.getString("RelationshipItemBuilder.buildingIndex"), list.size()); //$NON-NLS-1$
|
||||
@@ -533,12 +642,12 @@ public class RelationshipItemBuilder {
|
||||
|
||||
public void updateItemVersion(Item baseItem, String oldVersion, String id, Map<String, String> versions,
|
||||
boolean avoidSaveProject) throws PersistenceException {
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
IProxyRepositoryFactory factory = getProxyRepositoryFactory();
|
||||
IRepositoryViewObject obj = factory.getSpecificVersion(id, oldVersion, avoidSaveProject);
|
||||
Item item = obj.getProperty().getItem();
|
||||
// String itemVersion = item.getProperty().getVersion();
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
Project project = new Project(ProjectManager.getInstance().getProject(item));
|
||||
Project currentProject = getAimProject();
|
||||
Project project = new Project(ProjectManager.getInstance().getProject(currentProject, item));
|
||||
if (!loaded) {
|
||||
loadRelations();
|
||||
}
|
||||
|
||||
@@ -167,6 +167,10 @@ public final class ContextParameterUtils {
|
||||
String paraName = getContextString(code);
|
||||
IContextParameter param = context.getContextParameter(paraName);
|
||||
if (param != null) {
|
||||
String value = param.getValue();
|
||||
if (value == null || code.equals(value.trim())) {
|
||||
return value;
|
||||
}
|
||||
return parseScriptContextCode(param.getValue(), context);// Multi-layer
|
||||
// context
|
||||
// refrence
|
||||
|
||||
@@ -691,14 +691,34 @@ public class NodeUtil {
|
||||
*/
|
||||
public static INode getNodeByUniqueName(final IProcess process, String uniqueName) {
|
||||
|
||||
return getNodeByUniqueName(process,uniqueName,false);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC jzhao
|
||||
* <p>
|
||||
* function:get the node(maybe include virtual node) from generating nodes by unique name. aim:to get the property value from any node.
|
||||
* </p>
|
||||
* Notice: It is used to get property values from the pointed node we can also get the virtual node.
|
||||
*
|
||||
* @param process: a job process
|
||||
* @param uniqueName:the unique name of the pointed node.
|
||||
* @param isReturnVirtualNode: specify whether return the virtual node.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static INode getNodeByUniqueName(final IProcess process, String uniqueName ,boolean isReturnVirtualNode) {
|
||||
|
||||
List<INode> nodes = (List<INode>) process.getGeneratingNodes();
|
||||
INode return_node = null;
|
||||
for (INode current_node : nodes) {
|
||||
if(isReturnVirtualNode && current_node.isVirtualGenerateNode()){
|
||||
current_node = getVirtualNode(current_node);
|
||||
}
|
||||
if (uniqueName.equals(current_node.getUniqueName())) {
|
||||
return_node = current_node;
|
||||
return current_node;
|
||||
}
|
||||
}
|
||||
return return_node;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -852,7 +872,7 @@ public class NodeUtil {
|
||||
if (!linesIter.hasNext()) {
|
||||
return "\"[]\"";
|
||||
}
|
||||
value.append("new StringBuilder().append(\"[");
|
||||
value.append("\"[");
|
||||
for (;;) {
|
||||
Map<String, String> columns = linesIter.next();
|
||||
Iterator<Entry<String, String>> columnsIter = columns.entrySet().iterator();
|
||||
@@ -868,9 +888,9 @@ public class NodeUtil {
|
||||
printedColumnExist = true;
|
||||
|
||||
value.append(column.getKey());
|
||||
value.append("=\").append(");
|
||||
value.append("=\"+(");
|
||||
value.append(getNormalizeParameterValue(column.getValue(), types.get(column.getKey()), true));
|
||||
value.append(").append(\"");
|
||||
value.append(")+\"");
|
||||
|
||||
if (columnsIter.hasNext()) {
|
||||
value.append(", ");
|
||||
@@ -882,7 +902,7 @@ public class NodeUtil {
|
||||
value.append("}");
|
||||
|
||||
if (!linesIter.hasNext()) {
|
||||
return value.append("]\").toString()").toString();
|
||||
return value.append("]\"").toString();
|
||||
}
|
||||
value.append(",").append(" ");
|
||||
}
|
||||
|
||||
@@ -507,7 +507,7 @@ public final class ParameterValueUtil {
|
||||
replacedStrings.put(s, s);
|
||||
}
|
||||
}
|
||||
if (split.length == 1) {
|
||||
if (split.length == 1 && split[0].length() == value.length()) {
|
||||
returnValue.append(replacedStrings.get(split[0]));
|
||||
}
|
||||
// obtain consts & concat the consts with the variables
|
||||
|
||||
@@ -156,4 +156,8 @@ public interface ITalendCorePrefConstants {
|
||||
public static final String CoreUIPlugin_ID = "org.talend.core.ui"; //$NON-NLS-1$
|
||||
|
||||
public static final String TOP_INSTALL_DONE = "top.install.done"; //$NON-NLS-1$
|
||||
|
||||
public static final String SVN_UPDATE_INFO_AUTO_CHECK = "PerformancePreferencePage.svn_update_info_auto_check"; //$NON-NLS-1$
|
||||
|
||||
public static final String SVN_UPDATE_INFO_AUTO_CHECK_TIME_INTERVAL = "PerformancePreferencePage.svn_update_info_auto_check_time_interval"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public final class ProjectManager {
|
||||
if (parentBranch != null) {
|
||||
for (ProjectReference pr : (List<ProjectReference>) p.getReferencedProjects()) {
|
||||
if (pr.getBranch() == null || parentBranch.equals(pr.getBranch())) {
|
||||
Project project = new Project(pr.getReferencedProject());
|
||||
Project project = new Project(pr.getReferencedProject(), false);
|
||||
allReferencedprojects.add(project);
|
||||
resolveSubRefProject(pr.getReferencedProject(), allReferencedprojects); // only to resolve all
|
||||
}
|
||||
@@ -151,14 +151,21 @@ public final class ProjectManager {
|
||||
IProxyRepositoryService.class);
|
||||
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
|
||||
if (factory != null) {
|
||||
List<org.talend.core.model.properties.Project> rProjects = factory
|
||||
.getReferencedProjects(this.getCurrentProject());
|
||||
if (rProjects != null) {
|
||||
for (org.talend.core.model.properties.Project p : rProjects) {
|
||||
Project project = new Project(p);
|
||||
resolveRefProject(p);
|
||||
referencedprojects.add(project);
|
||||
}
|
||||
retrieveReferencedProjects(factory, this.getCurrentProject(), referencedprojects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void retrieveReferencedProjects(IProxyRepositoryFactory proxyRepositoryFactory, Project mainProject,
|
||||
List<Project> referencedprojects) {
|
||||
referencedprojects.clear();
|
||||
if (proxyRepositoryFactory != null) {
|
||||
List<org.talend.core.model.properties.Project> rProjects = proxyRepositoryFactory.getReferencedProjects(mainProject);
|
||||
if (rProjects != null) {
|
||||
for (org.talend.core.model.properties.Project p : rProjects) {
|
||||
Project project = new Project(p);
|
||||
resolveRefProject(p);
|
||||
referencedprojects.add(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,6 +195,12 @@ public final class ProjectManager {
|
||||
return referencedprojects;
|
||||
}
|
||||
|
||||
public List<Project> getReferencedProjects(IProxyRepositoryFactory proxyRepositoryFactory, Project project) {
|
||||
List<Project> referencedprojects = new ArrayList<Project>();
|
||||
retrieveReferencedProjects(proxyRepositoryFactory, project, referencedprojects);
|
||||
return referencedprojects;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* return all the referenced projects of current project.
|
||||
@@ -208,7 +221,7 @@ public final class ProjectManager {
|
||||
.getReferencedProjects(this.getCurrentProject());
|
||||
if (rProjects != null) {
|
||||
for (org.talend.core.model.properties.Project p : rProjects) {
|
||||
Project project = new Project(p);
|
||||
Project project = new Project(p, false);
|
||||
allReferencedprojects.add(project);
|
||||
resolveSubRefProject(p, allReferencedprojects);
|
||||
}
|
||||
@@ -234,7 +247,7 @@ public final class ProjectManager {
|
||||
List<Project> refProjects = new ArrayList<Project>();
|
||||
for (ProjectReference refProject : (List<ProjectReference>) project.getEmfProject().getReferencedProjects()) {
|
||||
if (refProject.getBranch() == null || parentBranch.equals(refProject.getBranch())) {
|
||||
refProjects.add(new Project(refProject.getReferencedProject()));
|
||||
refProjects.add(new Project(refProject.getReferencedProject(), false));
|
||||
}
|
||||
}
|
||||
return refProjects;
|
||||
@@ -267,6 +280,26 @@ public final class ProjectManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public org.talend.core.model.properties.Project getProject(Project project, EObject object) {
|
||||
if (object != null) {
|
||||
if (object instanceof org.talend.core.model.properties.Project) {
|
||||
return (org.talend.core.model.properties.Project) object;
|
||||
}
|
||||
if (object instanceof Property) {
|
||||
return getProject(project, ((Property) object).getItem());
|
||||
}
|
||||
if (object instanceof Item) {
|
||||
return getProject(project, ((Item) object).getParent());
|
||||
}
|
||||
}
|
||||
|
||||
// default
|
||||
if (project != null) {
|
||||
return project.getEmfProject();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IProject getResourceProject(org.talend.core.model.properties.Project project) {
|
||||
if (project != null) {
|
||||
try {
|
||||
@@ -293,11 +326,14 @@ public final class ProjectManager {
|
||||
* check the EObject in current main project.
|
||||
*/
|
||||
public boolean isInCurrentMainProject(EObject object) {
|
||||
return isInMainProject(getCurrentProject(), object);
|
||||
}
|
||||
|
||||
public boolean isInMainProject(Project mainProject, EObject object) {
|
||||
if (object != null) {
|
||||
org.talend.core.model.properties.Project project = getProject(object);
|
||||
Project p = getCurrentProject();
|
||||
if (project != null && p != null) {
|
||||
return project.getTechnicalLabel().equals(p.getEmfProject().getTechnicalLabel());
|
||||
org.talend.core.model.properties.Project project = getProject(mainProject, object);
|
||||
if (project != null && mainProject != null) {
|
||||
return project.getTechnicalLabel().equals(mainProject.getEmfProject().getTechnicalLabel());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -300,9 +300,14 @@ public class RepositoryNodeUtilities {
|
||||
|
||||
for (IRepositoryNode childNode : children) {
|
||||
RepositoryNode node = (RepositoryNode) childNode;
|
||||
if (isRepositoryFolder(node) || node.getType() == ENodeType.REFERENCED_PROJECT
|
||||
|| (hadoopClusterService != null && hadoopClusterService.isHadoopClusterNode(node))) {
|
||||
if (isRepositoryFolder(node) || node.getType() == ENodeType.REFERENCED_PROJECT) {
|
||||
folderChild.add(node);
|
||||
} else if (hadoopClusterService != null && hadoopClusterService.isHadoopClusterNode(node)) {
|
||||
if (node.getId().equals(curNode.getId()) && node.getObjectType() == curNode.getRepositoryObjectType()) {
|
||||
return node;
|
||||
} else {
|
||||
folderChild.add(node);
|
||||
}
|
||||
} else if (node.getId().equals(curNode.getId()) && node.getObjectType() == curNode.getRepositoryObjectType()) {
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -60,10 +60,10 @@ public class ContextValuesNatText extends Composite {
|
||||
|
||||
private NatTableCellEditorFactory cellFactory;
|
||||
|
||||
/**
|
||||
* Flag to determine whether the text is on focus or lost.
|
||||
*/
|
||||
private boolean focusLostActive = false;
|
||||
// /**
|
||||
// * Flag to determine whether the text is on focus or lost.
|
||||
// */
|
||||
// private boolean focusLostActive = false;
|
||||
|
||||
private List<FocusListener> focusListener = new ArrayList<FocusListener>();
|
||||
|
||||
@@ -203,24 +203,24 @@ public class ContextValuesNatText extends Composite {
|
||||
*
|
||||
* @see org.eclipse.swt.widgets.Control#removeFocusListener(org.eclipse.swt.events.FocusListener)
|
||||
*/
|
||||
@Override
|
||||
public void removeFocusListener(final FocusListener listener) {
|
||||
if (focusLostActive) {
|
||||
try {
|
||||
new Thread() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
focusListener.remove(listener);
|
||||
};
|
||||
}.join();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
focusListener.remove(listener);
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// public void removeFocusListener(final FocusListener listener) {
|
||||
// if (focusLostActive) {
|
||||
// try {
|
||||
// new Thread() {
|
||||
//
|
||||
// @Override
|
||||
// public void run() {
|
||||
// focusListener.remove(listener);
|
||||
// };
|
||||
// }.join();
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// } else {
|
||||
// focusListener.remove(listener);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Transforms the subDialog's result.
|
||||
@@ -248,4 +248,22 @@ public class ContextValuesNatText extends Composite {
|
||||
result = getTransformedSelection(focusOnText);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for text.
|
||||
*
|
||||
* @return the text
|
||||
*/
|
||||
public Text getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for button.
|
||||
*
|
||||
* @return the button
|
||||
*/
|
||||
public Button getButton() {
|
||||
return this.button;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,11 @@ import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectio
|
||||
import org.eclipse.nebula.widgets.nattable.style.IStyle;
|
||||
import org.eclipse.nebula.widgets.nattable.widget.EditModeEnum;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.FocusAdapter;
|
||||
import org.eclipse.swt.events.FocusEvent;
|
||||
import org.eclipse.swt.events.KeyAdapter;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.graphics.Cursor;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.talend.commons.utils.PasswordEncryptUtil;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
|
||||
@@ -78,8 +75,6 @@ public class CustomTextCellEditor extends AbstractCellEditor {
|
||||
}
|
||||
final ContextValuesNatText text = new ContextValuesNatText(parentComp, cellStyle, realPara, style);
|
||||
|
||||
text.setCursor(new Cursor(Display.getDefault(), SWT.CURSOR_IBEAM));
|
||||
|
||||
addTextListener(text);
|
||||
return text;
|
||||
|
||||
@@ -114,13 +109,13 @@ public class CustomTextCellEditor extends AbstractCellEditor {
|
||||
|
||||
});
|
||||
|
||||
text.addFocusListener(new FocusAdapter() {
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
commit(MoveDirectionEnum.NONE, editMode == EditModeEnum.INLINE);
|
||||
}
|
||||
});
|
||||
// text.addFocusListener(new FocusAdapter() {
|
||||
//
|
||||
// @Override
|
||||
// public void focusLost(FocusEvent e) {
|
||||
// commit(MoveDirectionEnum.NONE, editMode == EditModeEnum.INLINE);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -172,6 +167,12 @@ public class CustomTextCellEditor extends AbstractCellEditor {
|
||||
// use the real value.
|
||||
setCanonicalValue(this.recordOriginalCanonicalValue);
|
||||
|
||||
Text text = buttonText.getText();
|
||||
if (buttonText.getButton() == null) {
|
||||
text.forceFocus();
|
||||
}
|
||||
text.setSelection(0, text.getText().length());
|
||||
|
||||
return this.buttonText;
|
||||
}
|
||||
|
||||
|
||||
@@ -347,7 +347,7 @@ public class ExtendedContextColumnPropertyAccessor<R> implements IColumnProperty
|
||||
param.setPromptNeeded((Boolean) newValue);
|
||||
modified = true;
|
||||
} else if (property.equals(ContextTableConstants.COLUMN_PROMPT_PROPERTY)) {
|
||||
if (param.getPrompt().equals(newValue)) {
|
||||
if (param.getPrompt() != null && param.getPrompt().equals(newValue)) {
|
||||
return;
|
||||
}
|
||||
oldValue = param.getPrompt();
|
||||
@@ -358,10 +358,10 @@ public class ExtendedContextColumnPropertyAccessor<R> implements IColumnProperty
|
||||
return;
|
||||
}
|
||||
oldValue = param.getValue();
|
||||
if (newValue != null) {
|
||||
param.setValue((String) newValue);
|
||||
modified = true;
|
||||
}
|
||||
// if (newValue != null) {
|
||||
param.setValue(newValue == null ? "" : (String) newValue);
|
||||
modified = true;
|
||||
// }
|
||||
}
|
||||
if (modified) {
|
||||
updateRelation();
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.eclipse.nebula.widgets.nattable.edit.editor.ComboBoxCellEditor;
|
||||
import org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor;
|
||||
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsDataProvider;
|
||||
import org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel;
|
||||
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
@@ -144,4 +145,19 @@ public class ProxyDynamicCellEditor extends AbstractCellEditor {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor#commit(org.eclipse.nebula.widgets.nattable
|
||||
* .selection.SelectionLayer.MoveDirectionEnum, boolean, boolean)
|
||||
*/
|
||||
@Override
|
||||
public boolean commit(MoveDirectionEnum direction, boolean closeAfterCommit, boolean skipValidation) {
|
||||
if (dynamicEditor != null) {
|
||||
return dynamicEditor.commit(direction, closeAfterCommit, skipValidation);
|
||||
}
|
||||
return super.commit(direction, closeAfterCommit, skipValidation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -506,8 +506,9 @@ public class SchemaCellEditor extends DialogCellEditor {
|
||||
if (tableToEdit != null) {
|
||||
if (isHL7OutputNode(node) && node.getIncomingConnections().size() > 0) {
|
||||
copyHL7OutputMetadata(node, tableToEdit);
|
||||
} else if (isSAPNode(node) && type.toString().equals(TABLE) && node.getIncomingConnections().size() > 0
|
||||
&& hasParentRow && (parent_row != null && !parent_row.equals("") && !(parent_row instanceof Integer))) {
|
||||
} else if (isSAPNode(node) && type != null && type.toString().equals(TABLE)
|
||||
&& node.getIncomingConnections().size() > 0 && hasParentRow
|
||||
&& (parent_row != null && !parent_row.equals("") && !(parent_row instanceof Integer))) {
|
||||
copySAPOutputMetadata(node, tableToEdit);
|
||||
} else {
|
||||
MetadataDialog dialog = new MetadataDialog(cellEditorWindow.getShell(), tableToEdit.clone(), node, null);
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -61,6 +60,7 @@ public class FileSystemExporterFullPath implements IFileExporterFullPath {
|
||||
*
|
||||
* @exception java.io.IOException
|
||||
*/
|
||||
@Override
|
||||
public void finished() throws IOException {
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ public class FileSystemExporterFullPath implements IFileExporterFullPath {
|
||||
* @exception java.io.IOException
|
||||
* @exception org.eclipse.core.runtime.CoreException
|
||||
*/
|
||||
@Override
|
||||
public void write(String resource, String destinationPath) throws IOException, CoreException {
|
||||
Path path = new Path(destinationPath);
|
||||
if (path.segmentCount() == 1) {
|
||||
@@ -127,8 +128,8 @@ public class FileSystemExporterFullPath implements IFileExporterFullPath {
|
||||
String rootName = fileResource.getDirectoryName();
|
||||
|
||||
Set<String> paths = fileResource.getRelativePathList();
|
||||
for (Iterator iter = paths.iterator(); iter.hasNext();) {
|
||||
String relativePath = (String) iter.next();
|
||||
for (Object element : paths) {
|
||||
String relativePath = (String) element;
|
||||
Set<URL> resource = fileResource.getResourcesByRelativePath(relativePath);
|
||||
for (URL url : resource) {
|
||||
String currentResource = url.getPath();
|
||||
@@ -172,6 +173,7 @@ public class FileSystemExporterFullPath implements IFileExporterFullPath {
|
||||
try {
|
||||
children = file.listFiles(new FileFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
|
||||
boolean result = true;
|
||||
@@ -189,10 +191,20 @@ public class FileSystemExporterFullPath implements IFileExporterFullPath {
|
||||
} catch (Exception e) {
|
||||
// this should never happen because an #isAccessible check is done before #members is invoked
|
||||
}
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
exportResource(rootName, directory + file.getName() + separator, children[i].getPath(), leadupDepth + 1);
|
||||
for (File element : children) {
|
||||
exportResource(rootName, directory + file.getName() + separator, element.getPath(), leadupDepth + 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.export.IFileExporterFullPath#writeFolder(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void writeFolder(String destinationPath) throws IOException, CoreException {
|
||||
createFolder(destinationPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,27 +12,24 @@
|
||||
// ============================================================================
|
||||
package org.talend.repository.documentation;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Interface for file exporters of different file formats. Used by the
|
||||
* zip and tar.gz exporters.
|
||||
* Interface for file exporters of different file formats. Used by the zip and tar.gz exporters.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
public interface IFileExporterFullPath {
|
||||
|
||||
/**
|
||||
* Do all required cleanup now that we are finished with the
|
||||
* currently-open file.
|
||||
* Do all required cleanup now that we are finished with the currently-open file.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void finished() throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Write the passed resource to the current archive
|
||||
*
|
||||
@@ -41,7 +38,7 @@ public interface IFileExporterFullPath {
|
||||
* @throws IOException
|
||||
* @throws CoreException
|
||||
*/
|
||||
public void write(String resource, String destinationPath)
|
||||
throws IOException, CoreException;
|
||||
public void write(String resource, String destinationPath) throws IOException, CoreException;
|
||||
|
||||
public void writeFolder(String destinationPath) throws IOException, CoreException;
|
||||
}
|
||||
@@ -21,9 +21,9 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.apache.tools.tar.TarOutputStream;
|
||||
import org.apache.tools.tar.TarEntry;
|
||||
import org.apache.tools.tar.TarOutputStream;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Exports resources to a .tar.gz file.
|
||||
@@ -57,6 +57,7 @@ public class TarFileExporterFullPath implements IFileExporterFullPath {
|
||||
*
|
||||
* @exception java.io.IOException
|
||||
*/
|
||||
@Override
|
||||
public void finished() throws IOException {
|
||||
outputStream.close();
|
||||
if (gzipOutputStream != null) {
|
||||
@@ -107,9 +108,25 @@ public class TarFileExporterFullPath implements IFileExporterFullPath {
|
||||
* @exception java.io.IOException
|
||||
* @exception org.eclipse.core.runtime.CoreException
|
||||
*/
|
||||
@Override
|
||||
public void write(String resource, String destinationPath) throws IOException, CoreException {
|
||||
|
||||
TarEntry newEntry = new TarEntry(destinationPath);
|
||||
write(newEntry, resource);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.export.IFileExporterFullPath#writeFolder(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void writeFolder(String destinationPath) throws IOException, CoreException {
|
||||
TarEntry newEntry = new TarEntry(destinationPath);
|
||||
if (!newEntry.isDirectory()) {
|
||||
newEntry = new TarEntry(destinationPath + "/");
|
||||
}
|
||||
outputStream.putNextEntry(newEntry);
|
||||
outputStream.closeEntry();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,9 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.zip.CRC32;
|
||||
import org.apache.tools.zip.ZipEntry;
|
||||
import org.apache.tools.zip.ZipFile;
|
||||
import org.apache.tools.zip.ZipOutputStream;
|
||||
|
||||
import org.apache.tools.zip.ZipEntry;
|
||||
import org.apache.tools.zip.ZipOutputStream;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
@@ -49,6 +48,7 @@ public class ZipFileExporterFullPath implements IFileExporterFullPath {
|
||||
*
|
||||
* @exception java.io.IOException
|
||||
*/
|
||||
@Override
|
||||
public void finished() throws IOException {
|
||||
outputStream.close();
|
||||
}
|
||||
@@ -110,8 +110,24 @@ public class ZipFileExporterFullPath implements IFileExporterFullPath {
|
||||
* @exception java.io.IOException
|
||||
* @exception org.eclipse.core.runtime.CoreException
|
||||
*/
|
||||
@Override
|
||||
public void write(String resource, String destinationPath) throws IOException, CoreException {
|
||||
ZipEntry newEntry = new ZipEntry(destinationPath);
|
||||
write(newEntry, resource);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.ui.export.IFileExporterFullPath#writeFolder(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void writeFolder(String destinationPath) throws IOException, CoreException {
|
||||
ZipEntry newEntry = new ZipEntry(destinationPath);
|
||||
if (!newEntry.isDirectory()) {
|
||||
newEntry = new ZipEntry(destinationPath + "/");
|
||||
}
|
||||
outputStream.putNextEntry(newEntry);
|
||||
outputStream.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,5 +319,4 @@ ActionBarBuildHelper.CloseAllAction_toolTip=Close All
|
||||
ActionBarBuildHelper.SaveAll_text=Sav&e All
|
||||
ActionBarBuildHelper.SaveAll_toolTip=Save All
|
||||
ContextOrderProperty.BuiltInComment=Build-in context variables
|
||||
ContextOrderProperty.RepositoryComment=Context variables from repository context:
|
||||
ContextOrderProperty.contextEncoding=file.encoding
|
||||
ContextOrderProperty.RepositoryComment=Context variables from repository context:
|
||||
@@ -219,8 +219,11 @@ public final class ProcessUtils {
|
||||
private static void updateRepositoryObjects(List<IRepositoryViewObject> repositoryObjects, IRepositoryViewObject obj) {
|
||||
if (!repositoryObjects.contains(obj)) {
|
||||
repositoryObjects.add(obj);
|
||||
checkAllVerSionLatest(repositoryObjects, obj);
|
||||
// TDQ-12162,should call 'checkItemDependencies(...)' first. for
|
||||
// example,"sub job C->sub job B->main job A->Rule"
|
||||
// export script C,if call 'checkAllVerSionLatest(...)' first,the dependency X won't be added.
|
||||
checkItemDependencies(obj.getProperty().getItem(), repositoryObjects);
|
||||
checkAllVerSionLatest(repositoryObjects, obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ public class ContextOrderProperties extends Properties {
|
||||
|
||||
private final static String REPOSITORY_COMMENT = Messages.getString("ContextOrderProperty.RepositoryComment"); //$NON-NLS-1$
|
||||
|
||||
private final static String DEFAULT_PROPERTY_ENCODING = "8859_1";
|
||||
|
||||
/**
|
||||
* Version ID
|
||||
*/
|
||||
@@ -175,11 +177,10 @@ public class ContextOrderProperties extends Properties {
|
||||
|
||||
@Override
|
||||
public void store(OutputStream out, String comments) throws IOException {
|
||||
String defaultEncoding = System.getProperty(Messages.getString("ContextOrderProperty.contextEncoding")); //$NON-NLS-1$
|
||||
orderStore(new BufferedWriter(new OutputStreamWriter(out, defaultEncoding)), comments);
|
||||
orderStore(new BufferedWriter(new OutputStreamWriter(out, DEFAULT_PROPERTY_ENCODING)), comments, true);
|
||||
}
|
||||
|
||||
public void orderStore(Writer writer, String comments) throws IOException {
|
||||
public void orderStore(Writer writer, String comments, boolean escUnicode) throws IOException {
|
||||
BufferedWriter bufferedWriter = (writer instanceof BufferedWriter) ? (BufferedWriter) writer : new BufferedWriter(writer);
|
||||
if (comments != null) {
|
||||
writeComments(bufferedWriter, comments);
|
||||
@@ -193,8 +194,8 @@ public class ContextOrderProperties extends Properties {
|
||||
String key = iterator.next();
|
||||
String value = this.getProperty(key);
|
||||
String comment = this.commentMap.get(key);
|
||||
key = saveConvert(key, true, false);
|
||||
value = saveConvert(value, false, false);
|
||||
key = saveConvert(key, true, escUnicode);
|
||||
value = saveConvert(value, false, escUnicode);
|
||||
if (comment != null && !comment.equals("")) {
|
||||
bufferedWriter.newLine();
|
||||
writeComments(bufferedWriter, comment);
|
||||
|
||||
@@ -410,7 +410,8 @@ public class TalendTextUtils {
|
||||
}
|
||||
int length = value.length();
|
||||
String result = removeQuotes(value);
|
||||
if (length > 1 && ((value.startsWith("\"") && value.endsWith("\""))) || (value.startsWith("\'") && value.endsWith("\'"))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
if (length > 1
|
||||
&& (((value.startsWith("\"") && value.endsWith("\""))) || (value.startsWith("\'") && value.endsWith("\'")))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
result = value.substring(1, length - 1);
|
||||
|
||||
if (result.contains("\\")) { //$NON-NLS-1$
|
||||
|
||||
@@ -21,13 +21,7 @@ import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||
import org.eclipse.core.runtime.preferences.DefaultScope;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.preferences.ScopedPreferenceStore;
|
||||
import org.eclipse.update.core.SiteManager;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.prefs.GeneralParametersProvider.GeneralParameters;
|
||||
|
||||
@@ -99,27 +93,6 @@ public class CorePreferenceInitializer extends AbstractPreferenceInitializer {
|
||||
|
||||
initializeUpdatePreference();
|
||||
|
||||
// Initialize editors properties : line number shown
|
||||
final String perlEditorBundleName = "org.epic.perleditor"; // NON-NLS-1$ //$NON-NLS-1$
|
||||
final String editorsBundleName = "org.eclipse.ui.editors"; // NON-NLS-1$ //$NON-NLS-1$
|
||||
// AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER = "lineNumberRuler"
|
||||
final String editorLineNumberRuler = "lineNumberRuler"; //$NON-NLS-1$
|
||||
|
||||
if (!CommonsPlugin.isHeadless()) {
|
||||
Display display = getDisplay();
|
||||
if (display != null) {
|
||||
display.syncExec(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
initPreference(perlEditorBundleName, editorsBundleName, editorLineNumberRuler);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
initPreference(perlEditorBundleName, editorsBundleName, editorLineNumberRuler);
|
||||
}
|
||||
|
||||
}
|
||||
String languageType = Locale.getDefault().getLanguage();
|
||||
if (Locale.getDefault().equals(Locale.CHINA)) {
|
||||
languageType = Locale.SIMPLIFIED_CHINESE.toString();
|
||||
@@ -147,21 +120,6 @@ public class CorePreferenceInitializer extends AbstractPreferenceInitializer {
|
||||
|
||||
}
|
||||
|
||||
private Display getDisplay() {
|
||||
Display display = Display.getCurrent();
|
||||
if (display == null && PlatformUI.isWorkbenchRunning()) {
|
||||
display = PlatformUI.getWorkbench().getDisplay();
|
||||
}
|
||||
return display != null ? display : Display.getDefault();
|
||||
}
|
||||
|
||||
private void initPreference(String perlEditorBundleName, String editorsBundleName, String editorLineNumberRuler) {
|
||||
IPreferenceStore store = new ScopedPreferenceStore(new InstanceScope(), perlEditorBundleName);
|
||||
store.setValue(editorLineNumberRuler, true);
|
||||
store = new ScopedPreferenceStore(new InstanceScope(), editorsBundleName);
|
||||
store.setValue(editorLineNumberRuler, true);
|
||||
}
|
||||
|
||||
// unused method : call remove for 2.3
|
||||
public void initializeUpdatePreference() {
|
||||
IEclipsePreferences nodeScheduler = new DefaultScope().getNode("org.eclipse.update.scheduler"); // NON-NLS-1$ //$NON-NLS-1$
|
||||
|
||||
@@ -106,6 +106,8 @@ public class ProcessorUtilities {
|
||||
|
||||
private static Map<String, Integer> lastGeneratedWithStatsOrTrace = new HashMap<String, Integer>();
|
||||
|
||||
private static Date exportTimeStamp;// time stamp create when exporting a job and reset when export ends.
|
||||
|
||||
private static final int GENERATED_WITH_STATS = 1;
|
||||
|
||||
private static final int GENERATED_WITH_TRACES = 2;
|
||||
@@ -145,6 +147,11 @@ public class ProcessorUtilities {
|
||||
codeLocation = exportCodeLocation;
|
||||
libraryPath = exportLibraryPath;
|
||||
exportConfig = true;
|
||||
exportTimeStamp = new Date();
|
||||
}
|
||||
|
||||
public static Date getExportTimestamp() {
|
||||
return exportTimeStamp;
|
||||
}
|
||||
|
||||
public static boolean isExportConfig() {
|
||||
@@ -156,6 +163,7 @@ public class ProcessorUtilities {
|
||||
codeLocation = null;
|
||||
libraryPath = null;
|
||||
exportConfig = false;
|
||||
exportTimeStamp = null;
|
||||
}
|
||||
|
||||
public static String getInterpreter() {
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
<classpathentry exported="true" kind="lib" path="lib/ezmorph-1.0.6.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/json-lib-2.4-jdk15.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jackson-0.9.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jackson-annotations-2.1.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jackson-core-2.2.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jackson-databind-2.2.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jackson-annotations-2.1.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jackson-core-2.2.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jackson-databind-2.2.2.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
||||
@@ -14,12 +14,6 @@ package routines.system;
|
||||
|
||||
public class TalendThread extends Thread {
|
||||
|
||||
protected Object[] lockWrite;
|
||||
|
||||
public void assignLock(Object[] lockWrite) {
|
||||
this.lockWrite = lockWrite;
|
||||
}
|
||||
|
||||
public TalendThreadPool talendThreadPool = null;
|
||||
|
||||
public Integer errorCode = null;
|
||||
|
||||
@@ -440,7 +440,7 @@ public class TreeUtil {
|
||||
|
||||
public static List<FOXTreeNode> getFoxTreeNodes(String filePath) {
|
||||
List<FOXTreeNode> list = new ArrayList<FOXTreeNode>();
|
||||
if (filePath == null) {
|
||||
if (filePath == null || filePath.length() <= 0) {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -631,8 +631,8 @@ public class DBConnectionFillerImpl extends MetadataFillerImpl<DatabaseConnectio
|
||||
filterList.addAll(postFillCatalog(metaConnection, catalogList, filterList,
|
||||
TalendCWMService.getReadableName(dbConn, catalogName), dbConn));
|
||||
List<Catalog> newCatalogList = new ArrayList<Catalog>();
|
||||
List<Schema> schemaList = new ArrayList<Schema>();
|
||||
for (Catalog catalog : catalogList) {
|
||||
List<Schema> schemaList = new ArrayList<Schema>();
|
||||
try {
|
||||
schemaList = fillSchemaToCatalog(dbConn, dbJDBCMetadata, catalog, filterList);
|
||||
if (!schemaList.isEmpty() && schemaList.size() > 0) {
|
||||
@@ -642,9 +642,83 @@ public class DBConnectionFillerImpl extends MetadataFillerImpl<DatabaseConnectio
|
||||
log.info(e);
|
||||
}
|
||||
newCatalogList.add(catalog);
|
||||
// ConnectionHelper.addCatalog(catalog, dbConn);
|
||||
}
|
||||
ConnectionHelper.addCatalogs(newCatalogList, dbConn);
|
||||
|
||||
Set<MetadataTable> tableSet = ConnectionHelper.getTables(dbConn);
|
||||
// replaceCatalogs is use for record tables when click finish, then set to current connection.
|
||||
List<Catalog> replaceCatalogs = new ArrayList<Catalog>();
|
||||
List<String> catalogNames = new ArrayList<String>();
|
||||
for (MetadataTable table : tableSet) {
|
||||
EObject eContainer = table.eContainer();
|
||||
if (eContainer != null) {
|
||||
if (eContainer instanceof Catalog) {
|
||||
Catalog c = (Catalog) eContainer;
|
||||
String name = c.getName();
|
||||
if (!catalogNames.contains(name)) {
|
||||
replaceCatalogs.add(c);
|
||||
catalogNames.add(name);
|
||||
}
|
||||
} else if (eContainer instanceof Schema) {
|
||||
EObject parent = eContainer.eContainer();
|
||||
if (parent != null && parent instanceof Catalog) {
|
||||
Catalog c = (Catalog) parent;
|
||||
String name = c.getName();
|
||||
if (!catalogNames.contains(name)) {
|
||||
List<Schema> filterSchemas = new ArrayList<Schema>();
|
||||
List<String> schemaName = new ArrayList<String>();
|
||||
List<Schema> schemas = CatalogHelper.getSchemas(c);
|
||||
for (Schema schema : schemas) {
|
||||
if (filterList != null) {
|
||||
if (filterList.contains(schema.getName())) {
|
||||
filterSchemas.add(schema);
|
||||
schemaName.add(schema.getName());
|
||||
} else if (schema.getOwnedElement() != null && !schema.getOwnedElement().isEmpty()) {
|
||||
filterSchemas.add(schema);
|
||||
schemaName.add(schema.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
// get schema in current connection
|
||||
for (Catalog catalog : catalogList) {
|
||||
if (catalog.getName().equals(name)) {
|
||||
boolean added = false;
|
||||
for (Schema schema : CatalogHelper.getSchemas(catalog)) {
|
||||
if (!schemaName.contains(schema.getName())) {
|
||||
filterSchemas.add(schema);
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
if (added) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c.getOwnedElement().clear();
|
||||
CatalogHelper.addSchemas(filterSchemas, c);
|
||||
replaceCatalogs.add(c);
|
||||
catalogNames.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.isLinked() && !catalogList.isEmpty()) {
|
||||
ConnectionHelper.addCatalogs(catalogList, dbConn);
|
||||
}
|
||||
// if have same schema in current connection,need to fill tables.
|
||||
for (Catalog catalog : replaceCatalogs) {
|
||||
List<Catalog> list = new ArrayList<Catalog>();
|
||||
String name = catalog.getName();
|
||||
Catalog c = (Catalog) ConnectionHelper.getPackage(name, dbConn, Catalog.class);
|
||||
if (c != null) {
|
||||
list.add(c);
|
||||
ConnectionHelper.removeCatalogs(list, dbConn);
|
||||
ConnectionHelper.addCatalog(catalog, dbConn);
|
||||
} else {
|
||||
ConnectionHelper.addCatalog(catalog, dbConn);
|
||||
}
|
||||
}
|
||||
}
|
||||
return catalogList;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@ import java.nio.charset.Charset;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Driver;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.collections.map.MultiKeyMap;
|
||||
@@ -34,6 +37,8 @@ public class JDBCDriverLoader {
|
||||
|
||||
private static MultiKeyMap classLoadersMap = new MultiKeyMap();
|
||||
|
||||
private static Map<String, HotClassLoader> classLoadersMapBasedOnLibraries = new HashMap<String, HotClassLoader>();
|
||||
|
||||
/**
|
||||
* Loads the jars for hive embedded mode required, I do not think it is the better method to do this here. Due to
|
||||
* the limitation on code structure, I have to write this method to load the jar required by Hive. If metadata
|
||||
@@ -84,6 +89,32 @@ public class JDBCDriverLoader {
|
||||
return loader;
|
||||
}
|
||||
|
||||
private HotClassLoader getHotClassLoaderFromCacheBasedOnLibraries(String[] librariesPaths) {
|
||||
if (librariesPaths == null || librariesPaths.length <= 0) {
|
||||
return new HotClassLoader();
|
||||
}
|
||||
String[] sortedLibrariesPaths = Arrays.copyOf(librariesPaths, librariesPaths.length);
|
||||
Arrays.sort(sortedLibrariesPaths);
|
||||
HotClassLoader cLoader = null;
|
||||
String key = ""; //$NON-NLS-1$
|
||||
for (String library : sortedLibrariesPaths) {
|
||||
if (library == null || (library = library.trim()).isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
key = key + ";" + library; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
cLoader = classLoadersMapBasedOnLibraries.get(key);
|
||||
|
||||
if (cLoader == null) {
|
||||
cLoader = new HotClassLoader();
|
||||
classLoadersMapBasedOnLibraries.put(key, cLoader);
|
||||
addPathsForClassLoader(librariesPaths, cLoader);
|
||||
}
|
||||
|
||||
return cLoader;
|
||||
}
|
||||
|
||||
public Driver getDriver(HotClassLoader loader, String[] jarPath, String driverClassName, String dbType, String dbVersion)
|
||||
throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||
Driver driver;
|
||||
@@ -175,6 +206,11 @@ public class JDBCDriverLoader {
|
||||
* @return
|
||||
*/
|
||||
public HotClassLoader getHotClassLoader(String[] jarPath, String dbType, String dbVersion) {
|
||||
|
||||
if (EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(dbType)) {
|
||||
return getHotClassLoaderFromCacheBasedOnLibraries(jarPath);
|
||||
}
|
||||
|
||||
HotClassLoader loader;
|
||||
boolean flog = EDatabaseVersion4Drivers.containTypeAndVersion(dbType, dbVersion);
|
||||
if (flog) {
|
||||
@@ -186,6 +222,11 @@ public class JDBCDriverLoader {
|
||||
} else {
|
||||
loader = new HotClassLoader();
|
||||
}
|
||||
addPathsForClassLoader(jarPath, loader);
|
||||
return loader;
|
||||
}
|
||||
|
||||
private void addPathsForClassLoader(String[] jarPath, HotClassLoader loader) {
|
||||
for (String element : jarPath) {
|
||||
// bug 17800 fixed: fix a problem of jdbc drivers used in the wizard.
|
||||
if (element.contains(";")) {
|
||||
@@ -197,6 +238,5 @@ public class JDBCDriverLoader {
|
||||
loader.addPath(element);
|
||||
}
|
||||
}
|
||||
return loader;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,11 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
@@ -36,6 +39,7 @@ import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.talend.commons.exception.LoginException;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
|
||||
@@ -44,7 +48,6 @@ import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ICoreService;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.migration.IMigrationToolService;
|
||||
import org.talend.core.model.properties.FolderItem;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.MigrationStatus;
|
||||
import org.talend.core.model.properties.MigrationTask;
|
||||
@@ -85,7 +88,9 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
|
||||
private static Logger log = Logger.getLogger(MigrationToolService.class);
|
||||
|
||||
private static final String RELATION_TASK = "org.talend.repository.model.migration.AutoUpdateRelationsMigrationTask"; //$NON-NLS-1$
|
||||
private static final String PROPERTIES_REDO_ENCRYPTION_MIGRATION_TASKS = "talend.property.migration.redoEncryption"; //$NON-NLS-1$
|
||||
|
||||
private static final String RELATION_TASK = "org.talend.repository.model.migration.AutoUpdateRelationsMigrationTask"; //$NON-NLS-1$
|
||||
|
||||
private List<IProjectMigrationTask> doneThisSession;
|
||||
|
||||
@@ -155,13 +160,6 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
routineSynchronizer.syncRoutine(routineItem, true);
|
||||
routineSynchronizer.getFile(routineItem);
|
||||
}
|
||||
if (item.getProperty().eResource() != null) {
|
||||
factory.unloadResources(item.getProperty());
|
||||
if (item.getParent() != null && item.getParent() instanceof FolderItem) {
|
||||
((FolderItem) item.getParent()).getChildren().remove(item);
|
||||
item.setParent(null);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
@@ -169,18 +167,29 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
|
||||
@Override
|
||||
public void executeMigrationTasksForLogon(final Project project, final boolean beforeLogon, final IProgressMonitor monitorWrap) {
|
||||
String taskDesc = "Migration tool: project [" + project.getLabel() + "] tasks"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String logonDesc = null;
|
||||
if (beforeLogon) {
|
||||
logonDesc = "before logon"; //$NON-NLS-1$
|
||||
} else {
|
||||
logonDesc = "after logon"; //$NON-NLS-1$
|
||||
}
|
||||
String taskDesc = "Migration tool: " + logonDesc + " project [" + project.getLabel() + "] tasks"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
log.trace(taskDesc);
|
||||
|
||||
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
final IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
|
||||
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
final IProject fsProject = workspace.getRoot().getProject(project.getTechnicalLabel());
|
||||
|
||||
final List<IProjectMigrationTask> toExecute = GetTasksHelper.getProjectTasks(beforeLogon);
|
||||
final List<MigrationTask> done = new ArrayList<MigrationTask>(project.getEmfProject().getMigrationTask());
|
||||
List<MigrationTask> storedMigrations = project.getEmfProject().getMigrationTask();
|
||||
|
||||
if (beforeLogon) {
|
||||
boolean isNewProject = project.getEmfProject().getProductVersion() == null ? true : false;
|
||||
setMigrationOnNewProject(beforeLogon && isNewProject && done.isEmpty());
|
||||
checkMigrationList(monitorWrap, repFactory, project, fsProject, toExecute, storedMigrations);
|
||||
}
|
||||
sortMigrationTasks(toExecute);
|
||||
|
||||
final List<MigrationTask> done = new ArrayList<MigrationTask>(storedMigrations);
|
||||
int nbMigrationsToDo = 0;
|
||||
for (IProjectMigrationTask task : toExecute) {
|
||||
MigrationTask mgTask = MigrationUtil.findMigrationTask(done, task);
|
||||
@@ -208,8 +217,6 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
MigrationUtil.removeMigrationTaskById(done, "org.talend.repository.model.migration.FixProjectResourceLink");
|
||||
|
||||
boolean haveAnyBinFolder = false; // to avoid some problems of migration, sometimes
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IProject fsProject = workspace.getRoot().getProject(project.getTechnicalLabel());
|
||||
for (ERepositoryObjectType type : (ERepositoryObjectType[]) ERepositoryObjectType.values()) {
|
||||
if (!type.hasFolder()) {
|
||||
continue;
|
||||
@@ -229,8 +236,6 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
}
|
||||
|
||||
final SubProgressMonitor subProgressMonitor = new SubProgressMonitor(monitorWrap, toExecute.size());
|
||||
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
final IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
|
||||
|
||||
RepositoryWorkUnit repositoryWorkUnit = new RepositoryWorkUnit(project, taskDesc) {
|
||||
|
||||
@@ -471,6 +476,125 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
// repositoryWorkUnit.throwPersistenceExceptionIfAny();
|
||||
}
|
||||
|
||||
private void checkMigrationList(final IProgressMonitor monitorWrap, final IProxyRepositoryFactory repFactory,
|
||||
final Project project, final IProject fsProject, final List<IProjectMigrationTask> toExecute,
|
||||
List<MigrationTask> storedMigrations) {
|
||||
boolean isProcessFolderExist = false;
|
||||
boolean isMetadataFolderExist = false;
|
||||
|
||||
String processFolderName = ERepositoryObjectType.getFolderName(ERepositoryObjectType.PROCESS);
|
||||
if (StringUtils.isNotBlank(processFolderName)) {
|
||||
IFolder processFolder = fsProject.getFolder(processFolderName);
|
||||
if (processFolder != null) {
|
||||
isProcessFolderExist = processFolder.exists();
|
||||
}
|
||||
}
|
||||
String metadataFolderName = ERepositoryObjectType.getFolderName(ERepositoryObjectType.METADATA);
|
||||
if (StringUtils.isNotBlank(metadataFolderName)) {
|
||||
IFolder metadataFolder = fsProject.getFolder(metadataFolderName);
|
||||
if (metadataFolder != null) {
|
||||
isMetadataFolderExist = metadataFolder.exists();
|
||||
}
|
||||
}
|
||||
|
||||
boolean isEmptyProject = (!isProcessFolderExist && !isMetadataFolderExist);
|
||||
setMigrationOnNewProject(isEmptyProject);
|
||||
|
||||
boolean needSave = false;
|
||||
|
||||
if (storedMigrations.isEmpty() && !isEmptyProject) {
|
||||
List<IProjectMigrationTask> allMigrations = new LinkedList<IProjectMigrationTask>();
|
||||
if (toExecute != null) {
|
||||
allMigrations.addAll(toExecute);
|
||||
}
|
||||
List<IProjectMigrationTask> afterLogonMigrations = GetTasksHelper.getProjectTasks(false);
|
||||
if (afterLogonMigrations != null) {
|
||||
allMigrations.addAll(afterLogonMigrations);
|
||||
}
|
||||
sortMigrationTasks(allMigrations);
|
||||
for (IProjectMigrationTask task : allMigrations) {
|
||||
if (RELATION_TASK.equals(task.getId())) {
|
||||
continue;
|
||||
}
|
||||
task.setStatus(ExecutionResult.NOTHING_TO_DO);
|
||||
storedMigrations.add(MigrationUtil.convertMigrationTask(task));
|
||||
}
|
||||
needSave = true;
|
||||
}
|
||||
|
||||
if (!isEmptyProject && Boolean.valueOf(System.getProperty(PROPERTIES_REDO_ENCRYPTION_MIGRATION_TASKS))) {
|
||||
List<String> encryptionTasks = Arrays.asList(new String[] {
|
||||
"org.talend.camel.designer.migration.UnifyPasswordEncryption4ParametersInRouteMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.designer.joblet.repository.migration.UnifyPasswordEncryption4ParametersInJobletMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.designer.mapreduce.repository.migration.UnifyPasswordEncryption4ParametersInMRJobMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.mdm.repository.migration.UnifyPasswordEncryption4MDMConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.EncryptDbPasswordforItemFileMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.EncryptDbPasswordMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.EncryptPasswordInComponentsMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.EncryptPasswordInJobSettingsMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.EncryptPasswordInProjectSettingsMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4ContextMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4DBConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4LdapConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4ParametersInJobMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4ProjectSettingsMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4SalesforceSchemaConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.model.migration.UnifyPasswordEncryption4WsdlConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.nosql.repository.migration.UnifyPasswordEncryption4NoSQLConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.sap.repository.migration.UnifyPasswordEncryption4SapConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.repository.storm.repository.migration.UnifyPasswordEncryption4ParametersInStormJobMigrationTask", //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* These two migrations don't have the problem, re-execute anyway
|
||||
*/
|
||||
"org.talend.repository.ftp.repository.migration.UnifyPasswordEncryption4FtpConnectionMigrationTask", //$NON-NLS-1$
|
||||
"org.talend.mdm.workbench.serverexplorer.migration.UnifyPasswordEncryption4MDMServerDefMigrationTask" //$NON-NLS-1$
|
||||
|
||||
});
|
||||
Iterator<MigrationTask> iterator = storedMigrations.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
MigrationTask migrationTask = iterator.next();
|
||||
if (encryptionTasks.contains(migrationTask.getId())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
needSave = true;
|
||||
}
|
||||
if (needSave) {
|
||||
RepositoryWorkUnit repositoryWorkUnit = new RepositoryWorkUnit(project,
|
||||
"Migration tool: update project [" + project.getLabel() + "] tasks due to lost or user specify") { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
@Override
|
||||
protected void run() throws LoginException, PersistenceException {
|
||||
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
repFactory.saveProject(project);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
try {
|
||||
IWorkspace workspace1 = ResourcesPlugin.getWorkspace();
|
||||
ISchedulingRule schedulingRule = workspace1.getRoot();
|
||||
// the update the project files need to be done in the workspace runnable to
|
||||
// avoid all notification of changes before the end of the modifications.
|
||||
workspace1.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitorWrap);
|
||||
} catch (CoreException e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
repositoryWorkUnit.setAvoidUnloadResources(true);
|
||||
repFactory.executeRepositoryWorkUnit(repositoryWorkUnit);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendToLogFile(Project sourceProject, String logTxt) {
|
||||
IProject project = ProjectManager.getInstance().getResourceProject(sourceProject.getEmfProject());
|
||||
File fullLogFile = new File(project.getFile(FULL_LOG_FILE).getLocation().toPortableString());
|
||||
|
||||
@@ -19,10 +19,14 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.PasswordEncryptUtil;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
|
||||
@@ -1062,6 +1066,70 @@ public class ConnectionHelper {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getCleanPassword(String password) {
|
||||
if (StringUtils.isBlank(password)) {
|
||||
return password;
|
||||
}
|
||||
String result = password;
|
||||
try {
|
||||
String tempValue = result;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
// normally there won't be dead loop, just in case it happens
|
||||
if (600 < i) {
|
||||
ExceptionHandler.process(new Exception("Dead loop when executing migration!"), Priority.WARN); //$NON-NLS-1$
|
||||
break;
|
||||
}
|
||||
|
||||
boolean cleanFromNewWay = false;
|
||||
String originalValue = tempValue;
|
||||
try {
|
||||
tempValue = getDecryptPassword(originalValue);
|
||||
String encryptFromTempValue = getEncryptPassword(tempValue);
|
||||
if (!StringUtils.equals(originalValue, encryptFromTempValue)) {
|
||||
cleanFromNewWay = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
cleanFromNewWay = true;
|
||||
} finally {
|
||||
if (cleanFromNewWay) {
|
||||
tempValue = originalValue;
|
||||
}
|
||||
}
|
||||
|
||||
boolean cleanFromOldWay = false;
|
||||
originalValue = tempValue;
|
||||
try {
|
||||
tempValue = PasswordEncryptUtil.decryptPassword(originalValue);
|
||||
String encryptFromTempValue = PasswordEncryptUtil.encryptPassword(tempValue);
|
||||
// original password may end with "=Encrypt", eg:
|
||||
// UnifyPasswordEncryption4ProjectSettingsMigrationTask#reencryptValueIfNeeded
|
||||
if (!StringUtils.startsWith(originalValue, encryptFromTempValue)) {
|
||||
cleanFromOldWay = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
cleanFromOldWay = true;
|
||||
} finally {
|
||||
if (cleanFromOldWay) {
|
||||
tempValue = originalValue;
|
||||
}
|
||||
}
|
||||
|
||||
result = tempValue;
|
||||
if (StringUtils.isBlank(result)) {
|
||||
break;
|
||||
}
|
||||
if (cleanFromNewWay && cleanFromOldWay) {
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC xqliu Comment method "getDecryptPassword".
|
||||
*
|
||||
|
||||
@@ -138,8 +138,10 @@ public class FileResourcesUnityManager extends FilesManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.getEmptyFolders().addAll(archiveProviderManager.getEmptyFolders());
|
||||
}
|
||||
collectPath2Object(tmpWorkFolder);
|
||||
|
||||
collectPath2Object(originalFile, tmpWorkFolder, tmpWorkFolder);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,12 +14,15 @@ package org.talend.repository.items.importexport.ui.managers;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
|
||||
import org.talend.core.repository.constants.FileConstants;
|
||||
import org.talend.utils.io.FilesUtils;
|
||||
|
||||
/**
|
||||
@@ -33,10 +36,14 @@ public class FilesManager extends AbstractImportResourcesManager {
|
||||
|
||||
@Override
|
||||
public boolean collectPath2Object(Object root) {
|
||||
return doCollectItemFiles((File) root);
|
||||
return doCollectItemFiles((File) root, (File) root, (File) root);
|
||||
}
|
||||
|
||||
private boolean doCollectItemFiles(File directory) {
|
||||
public boolean collectPath2Object(File original, File root, File current) {
|
||||
return doCollectItemFiles(original, root, current);
|
||||
}
|
||||
|
||||
private boolean doCollectItemFiles(File original, File root, File directory) {
|
||||
File[] contents = directory.listFiles();
|
||||
|
||||
if (contents != null) {
|
||||
@@ -48,7 +55,11 @@ public class FilesManager extends AbstractImportResourcesManager {
|
||||
}
|
||||
if (file.isDirectory()) {
|
||||
if ((!FilesUtils.isSVNFolder(file))) {
|
||||
collectPath2Object(content);
|
||||
doCollectItemFiles(original, root, content);
|
||||
IPath folderPath = getFolderPath(original, root, file);
|
||||
if (folderPath != null) {
|
||||
addFolder(folderPath.toPortableString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,6 +67,41 @@ public class FilesManager extends AbstractImportResourcesManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
private IPath getFolderPath(File original, File tempDirectoryRoot, File directory) {
|
||||
File projectFile = findProjectFile(directory);
|
||||
if (projectFile != null) {
|
||||
String projectName = "";
|
||||
if (tempDirectoryRoot.getAbsolutePath().equals(projectFile.getParentFile().getAbsolutePath())) {
|
||||
projectName = original.getName();
|
||||
}
|
||||
IPath currentPath = new Path(directory.getAbsolutePath());
|
||||
IPath basePath = new Path(tempDirectoryRoot.getAbsolutePath());
|
||||
IPath absPath = currentPath.makeRelativeTo(basePath);
|
||||
|
||||
IPath folderPath = new Path(projectName);
|
||||
folderPath = folderPath.append(absPath);
|
||||
return folderPath;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private File findProjectFile(File directory) {
|
||||
File parentFile = directory.getParentFile();
|
||||
File[] listFiles = parentFile.listFiles(new FileFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
return FileConstants.LOCAL_PROJECT_FILENAME.equals(pathname.getName());
|
||||
}
|
||||
});
|
||||
if (listFiles.length == 1) {
|
||||
return listFiles[0];
|
||||
} else if (parentFile.getParentFile() != null) {
|
||||
return findProjectFile(parentFile);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -65,6 +65,7 @@ public class ProviderManager extends AbstractImportResourcesManager {
|
||||
Object child = childrenEnum.next();
|
||||
if (provider.isFolder(child)) {
|
||||
doCollectItemFiles(child, level + 1);
|
||||
addFolder(provider.getFullPath(child));
|
||||
} else {
|
||||
add(provider.getFullPath(child), child);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ import org.talend.core.service.IExchangeService;
|
||||
import org.talend.core.ui.advanced.composite.FilteredCheckboxTree;
|
||||
import org.talend.repository.items.importexport.handlers.ImportExportHandlersManager;
|
||||
import org.talend.repository.items.importexport.handlers.imports.ImportCacheHelper;
|
||||
import org.talend.repository.items.importexport.handlers.model.EmptyFolderImportItem;
|
||||
import org.talend.repository.items.importexport.handlers.model.ImportItem;
|
||||
import org.talend.repository.items.importexport.manager.ResourcesManager;
|
||||
import org.talend.repository.items.importexport.ui.dialog.ShowErrorsDuringImportItemsDialog;
|
||||
@@ -86,6 +87,8 @@ import org.talend.repository.items.importexport.ui.wizard.imports.providers.Impo
|
||||
import org.talend.repository.items.importexport.ui.wizard.imports.providers.ImportItemsViewerFilter;
|
||||
import org.talend.repository.items.importexport.ui.wizard.imports.providers.ImportItemsViewerLabelProvider;
|
||||
import org.talend.repository.items.importexport.ui.wizard.imports.providers.ImportItemsViewerSorter;
|
||||
import org.talend.repository.items.importexport.wizard.models.FolderImportNode;
|
||||
import org.talend.repository.items.importexport.wizard.models.ImportNode;
|
||||
import org.talend.repository.items.importexport.wizard.models.ImportNodesBuilder;
|
||||
import org.talend.repository.items.importexport.wizard.models.ItemImportNode;
|
||||
import org.talend.repository.model.ERepositoryStatus;
|
||||
@@ -801,29 +804,47 @@ public class ImportItemsWizardPage extends WizardPage {
|
||||
|
||||
private List<ImportItem> getCheckedElements() {
|
||||
// add this if user use filter
|
||||
Set<ItemImportNode> checkedElements = new HashSet<ItemImportNode>();
|
||||
Set<ImportNode> checkedElements = new HashSet<ImportNode>();
|
||||
for (Object obj : filteredCheckboxTree.getCheckedLeafNodes()) {
|
||||
if (obj instanceof ItemImportNode) {
|
||||
checkedElements.add((ItemImportNode) obj);
|
||||
if (obj instanceof ImportNode) {
|
||||
checkedElements.add((ImportNode) obj);
|
||||
}
|
||||
}
|
||||
// add this if user does not use filter
|
||||
for (Object obj : filteredCheckboxTree.getViewer().getCheckedElements()) {
|
||||
if (obj instanceof ItemImportNode) {
|
||||
checkedElements.add((ItemImportNode) obj);
|
||||
if (obj instanceof ImportNode) {
|
||||
checkedElements.add((ImportNode) obj);
|
||||
}
|
||||
}
|
||||
// sort the item
|
||||
List<ItemImportNode> list = new ArrayList<ItemImportNode>(checkedElements);
|
||||
List<ImportNode> list = new ArrayList<ImportNode>(checkedElements);
|
||||
Collections.sort(list);
|
||||
|
||||
List<ImportItem> items = new ArrayList<ImportItem>(list.size());
|
||||
for (ItemImportNode node : list) {
|
||||
items.add(node.getItemRecord());
|
||||
for (ImportNode node : list) {
|
||||
if (node.getItemRecord() != null) {
|
||||
items.add(node.getItemRecord());
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private List<EmptyFolderImportItem> getCheckedFolders() {
|
||||
List<EmptyFolderImportItem> checkedEmptyFolder = new ArrayList<EmptyFolderImportItem>();
|
||||
|
||||
// add this if user does not use filter
|
||||
for (Object obj : filteredCheckboxTree.getViewer().getCheckedElements()) {
|
||||
if (obj instanceof FolderImportNode) {
|
||||
ImportItem itemRecord = ((FolderImportNode) obj).getItemRecord();
|
||||
if (itemRecord instanceof EmptyFolderImportItem) {
|
||||
checkedEmptyFolder.add((EmptyFolderImportItem) itemRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return checkedEmptyFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for consistency in selected elements and report an error message. in case of error or null the message
|
||||
* error.
|
||||
@@ -846,6 +867,9 @@ public class ImportItemsWizardPage extends WizardPage {
|
||||
String errorMessage = null;
|
||||
HashMap<String, ImportItem> duplicateCheckMap = new HashMap<String, ImportItem>();
|
||||
for (ImportItem itRecord : checkedElements) {
|
||||
if (itRecord instanceof EmptyFolderImportItem) {
|
||||
continue;
|
||||
}
|
||||
ImportItem otherRecord = duplicateCheckMap.put(itRecord.getProperty().getId() + itRecord.getProperty().getVersion(),
|
||||
itRecord);
|
||||
if (otherRecord != null) {
|
||||
@@ -892,13 +916,13 @@ public class ImportItemsWizardPage extends WizardPage {
|
||||
|
||||
public boolean performFinish() {
|
||||
final List<ImportItem> checkedItemRecords = getCheckedElements();
|
||||
final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
|
||||
/*
|
||||
* ?? prepare to do import, unlock the existed one, and make sure the overwrite to work well.
|
||||
*/
|
||||
for (ImportItem itemRecord : checkedItemRecords) {
|
||||
Item item = itemRecord.getProperty().getItem();
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
if (item.getState().isLocked()) {
|
||||
try {
|
||||
factory.unlock(item);
|
||||
@@ -945,6 +969,7 @@ public class ImportItemsWizardPage extends WizardPage {
|
||||
|
||||
importManager.importItemRecords(monitor, resManager, checkedItemRecords, overwrite,
|
||||
nodesBuilder.getAllImportItemRecords(), destinationPath);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -19,10 +19,12 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Priority;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
@@ -31,9 +33,12 @@ import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
@@ -42,8 +47,17 @@ import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.time.TimeMeasure;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.model.properties.FolderItem;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.ItemState;
|
||||
import org.talend.core.model.properties.Project;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.properties.helper.ByteArrayResource;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.model.repository.DynaEnum;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.ui.IJobletProviderService;
|
||||
@@ -54,11 +68,14 @@ import org.talend.repository.items.importexport.handlers.imports.IImportResource
|
||||
import org.talend.repository.items.importexport.handlers.imports.ImportBasicHandler;
|
||||
import org.talend.repository.items.importexport.handlers.imports.ImportCacheHelper;
|
||||
import org.talend.repository.items.importexport.handlers.imports.ImportExportHandlersRegistryReader;
|
||||
import org.talend.repository.items.importexport.handlers.model.EmptyFolderImportItem;
|
||||
import org.talend.repository.items.importexport.handlers.model.ImportItem;
|
||||
import org.talend.repository.items.importexport.handlers.model.ImportItem.State;
|
||||
import org.talend.repository.items.importexport.i18n.Messages;
|
||||
import org.talend.repository.items.importexport.manager.ChangeIdManager;
|
||||
import org.talend.repository.items.importexport.manager.ResourcesManager;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.RepositoryConstants;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
@@ -71,6 +88,8 @@ public final class ImportExportHandlersManager {
|
||||
|
||||
private IImportResourcesHandler[] resImportHandlers;
|
||||
|
||||
private ChangeIdManager changeIdManager = new ChangeIdManager();
|
||||
|
||||
public ImportExportHandlersManager() {
|
||||
registryReader = new ImportExportHandlersRegistryReader();
|
||||
registryReader.init();
|
||||
@@ -183,6 +202,81 @@ public final class ImportExportHandlersManager {
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
// add empty folders for TUP-2716
|
||||
List<IPath> emptyFolders = resManager.getEmptyFolders();
|
||||
if (!emptyFolders.isEmpty()) {
|
||||
DynaEnum<? extends DynaEnum<?>>[] values = ERepositoryObjectType.values();
|
||||
ERepositoryObjectType folderType = null;
|
||||
for (IPath folder : emptyFolders) {
|
||||
if (folder.segmentCount() < 1) {
|
||||
continue;
|
||||
}
|
||||
IPath folderPathToCheck = folder.removeFirstSegments(1);
|
||||
String generatedPath = ERepositoryObjectType.DOCUMENTATION.getFolder() + "/"
|
||||
+ RepositoryConstants.DOCUMENTATION_GENERATED_PATH;
|
||||
if (folderPathToCheck.removeTrailingSeparator().toPortableString().startsWith(generatedPath)) {
|
||||
continue;
|
||||
}
|
||||
for (DynaEnum<? extends DynaEnum<?>> type : ERepositoryObjectType.values()) {
|
||||
ERepositoryObjectType objectType = (ERepositoryObjectType) type;
|
||||
String[] products = objectType.getProducts();
|
||||
boolean isDI = false;
|
||||
for (String product : products) {
|
||||
if (ERepositoryObjectType.PROD_DI.equals(product)) {
|
||||
isDI = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isDI && objectType.isResouce()) {
|
||||
if (folderPathToCheck.toPortableString().startsWith(objectType.getFolder() + "/")) {
|
||||
folderType = objectType;
|
||||
ERepositoryObjectType fromChildrenType = getTypeFromChildren(objectType.getChildrenTypesArray(),
|
||||
folderPathToCheck.toPortableString());
|
||||
if (fromChildrenType != null) {
|
||||
folderType = fromChildrenType;
|
||||
}
|
||||
if (folderType == ERepositoryObjectType.SQLPATTERNS
|
||||
&& folderPathToCheck.removeTrailingSeparator().toPortableString()
|
||||
.endsWith(RepositoryConstants.USER_DEFINED)) {
|
||||
folderType = null;
|
||||
}
|
||||
if (folderPathToCheck.removeTrailingSeparator().toPortableString().equals(objectType.getFolder())) {
|
||||
// don't import if it is system folder
|
||||
folderType = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (folderType != null) {
|
||||
IPath typePath = new Path(folderType.getFolder());
|
||||
IPath folderPath = folder.removeFirstSegments(1 + typePath.segmentCount()).removeLastSegments(1)
|
||||
.removeTrailingSeparator();
|
||||
String folderLabel = folder.lastSegment();
|
||||
|
||||
EmptyFolderImportItem folderItem = new EmptyFolderImportItem(folderPath);
|
||||
folderItem.setRepositoryType(folderType);
|
||||
folderItem.setLabel(folderLabel);
|
||||
Project project = PropertiesFactory.eINSTANCE.createProject();
|
||||
project.setTechnicalLabel(folder.segment(0));
|
||||
project.setLabel(folder.segment(0));
|
||||
folderItem.setItemProject(project);
|
||||
|
||||
Property property = PropertiesFactory.eINSTANCE.createProperty();
|
||||
property.setId(ProxyRepositoryFactory.getInstance().getNextId());
|
||||
FolderItem createFolderItem = PropertiesFactory.eINSTANCE.createFolderItem();
|
||||
ItemState createStatus = PropertiesFactory.eINSTANCE.createItemState();
|
||||
property.setItem(createFolderItem);
|
||||
createStatus.setPath(folderPath.toPortableString());
|
||||
createFolderItem.setState(createStatus);
|
||||
items.add(folderItem);
|
||||
folderItem.setProperty(property);
|
||||
folderType = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// post populate
|
||||
postPopulate(monitor, resManager, items.toArray(new ImportItem[0]));
|
||||
|
||||
@@ -199,6 +293,27 @@ public final class ImportExportHandlersManager {
|
||||
|
||||
}
|
||||
|
||||
private ERepositoryObjectType getTypeFromChildren(ERepositoryObjectType[] types, String folderPath) {
|
||||
ERepositoryObjectType objectType = null;
|
||||
for (ERepositoryObjectType type : types) {
|
||||
if (folderPath.startsWith(type.getFolder() + "/")) {
|
||||
objectType = type;
|
||||
ERepositoryObjectType[] childrenTypesArray = objectType.getChildrenTypesArray();
|
||||
if (childrenTypesArray.length > 0) {
|
||||
objectType = getTypeFromChildren(childrenTypesArray, folderPath);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return objectType;
|
||||
}
|
||||
|
||||
protected ImportHandlerHelper createImportHandlerHelper() {
|
||||
// TODO Auto-generated method stub
|
||||
return new ImportHandlerHelper();
|
||||
}
|
||||
|
||||
public void importItemRecords(final IProgressMonitor progressMonitor, final ResourcesManager resManager,
|
||||
final List<ImportItem> checkedItemRecords, final boolean overwrite, final ImportItem[] allImportItemRecords,
|
||||
final IPath destinationPath) throws InvocationTargetException {
|
||||
@@ -207,6 +322,19 @@ public final class ImportExportHandlersManager {
|
||||
TimeMeasure.measureActive = CommonsPlugin.isDebugMode();
|
||||
TimeMeasure.begin("importItemRecords"); //$NON-NLS-1$
|
||||
|
||||
final List<EmptyFolderImportItem> checkedFolders = new ArrayList<EmptyFolderImportItem>();
|
||||
for (ImportItem importItem : checkedItemRecords) {
|
||||
if (importItem instanceof EmptyFolderImportItem) {
|
||||
checkedFolders.add((EmptyFolderImportItem) importItem);
|
||||
}
|
||||
}
|
||||
checkedItemRecords.removeAll(checkedFolders);
|
||||
|
||||
changeIdManager.clear();
|
||||
for (ImportItem importItem : checkedItemRecords) {
|
||||
changeIdManager.add(importItem);
|
||||
}
|
||||
|
||||
/*
|
||||
* Re-order the import items according to the priority of extension point.
|
||||
*/
|
||||
@@ -234,7 +362,7 @@ public final class ImportExportHandlersManager {
|
||||
// cache
|
||||
importCacheHelper.beforeImportItems();
|
||||
|
||||
if (resManager == null || checkedItemRecords.isEmpty()) {
|
||||
if (resManager == null || checkedItemRecords.isEmpty() && checkedFolders.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
progressMonitor.beginTask(
|
||||
@@ -277,6 +405,8 @@ public final class ImportExportHandlersManager {
|
||||
// pre import
|
||||
preImport(monitor, resManager, checkedItemRecords.toArray(new ImportItem[0]), allImportItemRecords);
|
||||
|
||||
final IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
|
||||
// bug 10520
|
||||
final Set<String> overwriteDeletedItems = new HashSet<String>();
|
||||
final Set<String> idDeletedBeforeImport = new HashSet<String>();
|
||||
@@ -288,21 +418,45 @@ public final class ImportExportHandlersManager {
|
||||
return;
|
||||
}
|
||||
if (itemRecord.isValid()) {
|
||||
if (itemRecord.getState() == State.ID_EXISTED) {
|
||||
if (itemRecord.getState() == State.ID_EXISTED
|
||||
|| itemRecord.getState() == State.NAME_AND_ID_EXISTED_BOTH) {
|
||||
String id = nameToIdMap.get(itemRecord.getProperty().getLabel()
|
||||
+ ERepositoryObjectType.getItemType(itemRecord.getProperty().getItem())
|
||||
.toString());
|
||||
if (id == null) {
|
||||
/*
|
||||
* if id exsist then need to genrate new id for this job,in this case the
|
||||
* job won't override the old one
|
||||
*/
|
||||
id = EcoreUtil.generateUUID();
|
||||
try {
|
||||
if (overwrite && itemRecord.getState() == State.NAME_AND_ID_EXISTED_BOTH) {
|
||||
// just try to reuse the id of the item which will be overwrited
|
||||
IRepositoryViewObject object = itemRecord.getExistingItemWithSameName();
|
||||
if (object != null) {
|
||||
if (ProjectManager.getInstance().isInCurrentMainProject(
|
||||
object.getProperty())) {
|
||||
// in case it is in reference project
|
||||
id = object.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e, Priority.WARN);
|
||||
}
|
||||
if (id == null) {
|
||||
/*
|
||||
* if id exsist then need to genrate new id for this job,in this case
|
||||
* the job won't override the old one
|
||||
*/
|
||||
id = EcoreUtil.generateUUID();
|
||||
}
|
||||
nameToIdMap.put(itemRecord.getProperty().getLabel()
|
||||
+ ERepositoryObjectType.getItemType(itemRecord.getProperty().getItem())
|
||||
.toString(), id);
|
||||
}
|
||||
String oldId = itemRecord.getProperty().getId();
|
||||
itemRecord.getProperty().setId(id);
|
||||
try {
|
||||
changeIdManager.mapOldId2NewId(oldId, id);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -341,8 +495,6 @@ public final class ImportExportHandlersManager {
|
||||
// saved
|
||||
// with relations
|
||||
try {
|
||||
final IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance()
|
||||
.getProxyRepositoryFactory();
|
||||
factory.saveProject(ProjectManager.getInstance().getCurrentProject());
|
||||
} catch (PersistenceException e) {
|
||||
if (Platform.inDebugMode()) {
|
||||
@@ -355,9 +507,50 @@ public final class ImportExportHandlersManager {
|
||||
TimeMeasure.step("importItemRecords", "save project"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
}
|
||||
|
||||
// import empty folders
|
||||
if (!checkedFolders.isEmpty()) {
|
||||
for (EmptyFolderImportItem folder : checkedFolders) {
|
||||
boolean exist = false;
|
||||
ERepositoryObjectType repositoryType = folder.getRepositoryType();
|
||||
IPath path = folder.getPath();
|
||||
if (destinationPath != null) {
|
||||
IPath desPath = destinationPath.makeRelativeTo(new Path(repositoryType.getFolder()));
|
||||
path = desPath.append(folder.getPath());
|
||||
}
|
||||
String label = folder.getLabel();
|
||||
FolderItem getFolderItem = factory.getFolderItem(ProjectManager.getInstance()
|
||||
.getCurrentProject(), repositoryType, path);
|
||||
if (getFolderItem != null) {
|
||||
for (Object obj : getFolderItem.getChildren()) {
|
||||
if (obj instanceof FolderItem) {
|
||||
FolderItem existFolder = (FolderItem) obj;
|
||||
if (label.equals(existFolder.getProperty().getLabel())) {
|
||||
exist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!exist) {
|
||||
try {
|
||||
factory.createFolder(repositoryType, path, label);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// post import
|
||||
List<ImportItem> importedItemRecords = ImportCacheHelper.getInstance().getImportedItemRecords();
|
||||
postImport(monitor, resManager, importedItemRecords.toArray(new ImportItem[0]));
|
||||
try {
|
||||
changeIdManager.changeIds();
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
unloadImportItems(allImportItemRecords);
|
||||
}
|
||||
|
||||
private void importItemRecordsWithRelations(final IProgressMonitor monitor,
|
||||
@@ -473,7 +666,7 @@ public final class ImportExportHandlersManager {
|
||||
for (IImportResourcesHandler resHandler : importResourcesHandlers) {
|
||||
resHandler.prePopulate(monitor, resManager);
|
||||
}
|
||||
|
||||
changeIdManager.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -518,4 +711,48 @@ public final class ImportExportHandlersManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void unloadImportItems(ImportItem[] importItems) {
|
||||
for (ImportItem importItem : importItems) {
|
||||
try {
|
||||
unloadImportItem(importItem);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
changeIdManager.clear();
|
||||
}
|
||||
|
||||
private void unloadImportItem(ImportItem importItem) throws Exception {
|
||||
ProxyRepositoryFactory proxyFactory = ProxyRepositoryFactory.getInstance();
|
||||
// unload the imported resources
|
||||
EList<Resource> resources = importItem.getResourceSet().getResources();
|
||||
Iterator<Resource> iterator = resources.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Resource res = iterator.next();
|
||||
// Due to the system of lazy loading for db repository of ByteArray,
|
||||
// it can't be unloaded just after create the item.
|
||||
if (res != null && !(res instanceof ByteArrayResource)) {
|
||||
res.unload();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
Item item = importItem.getItem();
|
||||
if (item != null) {
|
||||
if (item.getProperty().eResource() != null) {
|
||||
proxyFactory.unloadResources(item.getProperty());
|
||||
if (item.getParent() != null && item.getParent() instanceof FolderItem) {
|
||||
((FolderItem) item.getParent()).getChildren().remove(item);
|
||||
item.setParent(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Property property = importItem.getProperty();
|
||||
if (property != null) {
|
||||
proxyFactory.unloadResources(property);
|
||||
}
|
||||
importItem.setProperty(null);
|
||||
importItem.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,13 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.repository.RepositoryViewObject;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.items.importexport.handlers.model.ImportItem;
|
||||
|
||||
/**
|
||||
@@ -78,8 +80,17 @@ public class RepositoryObjectCache {
|
||||
public void initialize(ERepositoryObjectType itemType) throws PersistenceException {
|
||||
if (!types.contains(itemType)) {
|
||||
types.add(itemType);
|
||||
List<Project> allRefProjects = ProjectManager.getInstance().getAllReferencedProjects();
|
||||
// load object by type
|
||||
List<IRepositoryViewObject> list = factory.getAll(itemType, true, false);
|
||||
if (allRefProjects != null && !allRefProjects.isEmpty()) {
|
||||
for (Project refProject : allRefProjects) {
|
||||
List<IRepositoryViewObject> objList = factory.getAll(refProject, itemType, true, false);
|
||||
if (objList != null && !objList.isEmpty()) {
|
||||
list.addAll(objList);
|
||||
}
|
||||
}
|
||||
}
|
||||
// change to RepositoryViewObject to save memory
|
||||
// (could be enhanced directly in repository for future versions)
|
||||
List<IRepositoryViewObject> newList = new ArrayList<IRepositoryViewObject>();
|
||||
|
||||
@@ -78,7 +78,6 @@ import org.talend.core.model.properties.ReferenceFileItem;
|
||||
import org.talend.core.model.properties.RoutineItem;
|
||||
import org.talend.core.model.properties.SnippetItem;
|
||||
import org.talend.core.model.properties.User;
|
||||
import org.talend.core.model.properties.helper.ByteArrayResource;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
@@ -335,10 +334,13 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
IRepositoryViewObject itemWithSameIdObj = null;
|
||||
IRepositoryViewObject itemWithSameNameObj = null;
|
||||
|
||||
org.talend.core.model.general.Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
for (IRepositoryViewObject current : repObjectcache.getItemsFromRepository().get(itemType)) {
|
||||
final Property property = importItem.getProperty();
|
||||
if (property != null) {
|
||||
if (isSameName(importItem, current)) {
|
||||
boolean isInCurrentProject = ProjectManager.getInstance().isInMainProject(currentProject,
|
||||
current.getProperty());
|
||||
if (isInCurrentProject && isSameName(importItem, current)) {
|
||||
itemWithSameNameObj = current;
|
||||
}
|
||||
if (property.getId() != null && property.getId().equals(current.getId())) {
|
||||
@@ -370,6 +372,7 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
// if anything system, don't replace the source item if same name.
|
||||
// if not from system, can overwrite.
|
||||
importItem.setExistingItemWithSameId(itemWithSameNameObj);
|
||||
importItem.setExistingItemWithSameName(itemWithSameNameObj);
|
||||
// TDI-21399,TDI-21401
|
||||
// if item is locked, cannot overwrite
|
||||
if (itemWithSameNameObj != null) {
|
||||
@@ -380,18 +383,22 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// same name and same id
|
||||
importItem.setState(State.NAME_AND_ID_EXISTED);
|
||||
if (overwrite) {
|
||||
importItem.setExistingItemWithSameId(itemWithSameNameObj);
|
||||
boolean isSameItem = StringUtils.equals(itemWithSameNameObj.getId(), itemWithSameIdObj.getId());
|
||||
if (isSameItem) {
|
||||
importItem.setState(State.NAME_AND_ID_EXISTED);
|
||||
} else {
|
||||
importItem.setState(State.NAME_AND_ID_EXISTED_BOTH);
|
||||
}
|
||||
importItem.setExistingItemWithSameId(itemWithSameIdObj);
|
||||
importItem.setExistingItemWithSameName(itemWithSameNameObj);
|
||||
}
|
||||
if (!overwrite) {
|
||||
importItem.addError(Messages.getString("AbstractImportHandler_nameUsed")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
if (overwrite && importItem.getState() == State.NAME_AND_ID_EXISTED) {
|
||||
if (overwrite && (importItem.getState() == State.NAME_AND_ID_EXISTED
|
||||
|| importItem.getState() == State.NAME_AND_ID_EXISTED_BOTH)) {
|
||||
// if item is locked, cannot overwrite
|
||||
if (checkIfLocked(importItem)) {
|
||||
importItem.addError(Messages.getString("AbstractImportHandler_itemLocked")); //$NON-NLS-1$
|
||||
@@ -641,18 +648,6 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
doImportItem(monitor, resManager, selectedImportItem, overwrite, destinationPath, overwriteDeletedItems,
|
||||
idDeletedBeforeImport);
|
||||
|
||||
// unload the imported resources
|
||||
EList<Resource> resources = selectedImportItem.getResourceSet().getResources();
|
||||
Iterator<Resource> iterator = resources.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Resource res = iterator.next();
|
||||
// Due to the system of lazy loading for db repository of ByteArray,
|
||||
// it can't be unloaded just after create the item.
|
||||
if (res != null && !(res instanceof ByteArrayResource)) {
|
||||
res.unload();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
String label = selectedImportItem.getLabel();
|
||||
TimeMeasure.step("importItemRecords", "Import item: " + label); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
@@ -678,11 +673,15 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
String id = selectedImportItem.getProperty().getId();
|
||||
|
||||
IRepositoryViewObject lastVersion = selectedImportItem.getExistingItemWithSameId();
|
||||
if (lastVersion != null
|
||||
&& overwrite
|
||||
&& !selectedImportItem.isLocked()
|
||||
if (selectedImportItem.getState() == State.NAME_EXISTED
|
||||
|| selectedImportItem.getState() == State.NAME_AND_ID_EXISTED_BOTH) {
|
||||
lastVersion = selectedImportItem.getExistingItemWithSameName();
|
||||
}
|
||||
if (lastVersion != null && overwrite && !selectedImportItem.isLocked()
|
||||
&& (selectedImportItem.getState() == State.ID_EXISTED
|
||||
|| selectedImportItem.getState() == State.NAME_EXISTED || selectedImportItem.getState() == State.NAME_AND_ID_EXISTED)
|
||||
|| selectedImportItem.getState() == State.NAME_EXISTED
|
||||
|| selectedImportItem.getState() == State.NAME_AND_ID_EXISTED
|
||||
|| selectedImportItem.getState() == State.NAME_AND_ID_EXISTED_BOTH)
|
||||
&& !ImportCacheHelper.getInstance().getDeletedItems().contains(id)) {
|
||||
|
||||
if (overwriteDeletedItems != null && !overwriteDeletedItems.contains(id)) { // bug 10520.
|
||||
@@ -695,7 +694,8 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
|
||||
/* only delete when name exsit rather than id exist */
|
||||
if (selectedImportItem.getState().equals(ImportItem.State.NAME_EXISTED)
|
||||
|| selectedImportItem.getState().equals(ImportItem.State.NAME_AND_ID_EXISTED)) {
|
||||
|| selectedImportItem.getState().equals(ImportItem.State.NAME_AND_ID_EXISTED)
|
||||
|| selectedImportItem.getState().equals(ImportItem.State.NAME_AND_ID_EXISTED_BOTH)) {
|
||||
final IRepositoryViewObject lastVersionBackup = lastVersion;
|
||||
if (idDeletedBeforeImport != null && !idDeletedBeforeImport.contains(id)) {
|
||||
// TDI-19535 (check if exists, delete all items with same id)
|
||||
@@ -731,7 +731,8 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
beforeCreatingItem(selectedImportItem);
|
||||
|
||||
final RepositoryObjectCache repObjectcache = ImportCacheHelper.getInstance().getRepObjectcache();
|
||||
if (lastVersion == null || selectedImportItem.getState().equals(ImportItem.State.ID_EXISTED)) {
|
||||
if (lastVersion == null || selectedImportItem.getState().equals(ImportItem.State.ID_EXISTED)
|
||||
|| selectedImportItem.getState().equals(ImportItem.State.NAME_AND_ID_EXISTED_BOTH)) {
|
||||
repFactory.create(tmpItem, path, true);
|
||||
|
||||
afterCreatedItem(resManager, selectedImportItem);
|
||||
@@ -1146,7 +1147,7 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
}
|
||||
migrationService.executeMigrationTasksForImport(project, item, importItem.getMigrationTasksToApply(), monitor);
|
||||
importItem.setExistingItemWithSameId(null);
|
||||
importItem.clear();
|
||||
// importItem.clear();
|
||||
importItem.setProperty(item.getProperty());
|
||||
} catch (Exception e) {
|
||||
logError(e);
|
||||
@@ -1175,8 +1176,8 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
property = object.getProperty();
|
||||
}
|
||||
RelationshipItemBuilder.getInstance().addOrUpdateItem(property.getItem(), true);
|
||||
importItem.setProperty(null);
|
||||
factory.unloadResources(property);
|
||||
// importItem.setProperty(null);
|
||||
// factory.unloadResources(property);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2014 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.repository.items.importexport.handlers.model;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
|
||||
/**
|
||||
* created by wchen on Aug 3, 2016 Detailled comment
|
||||
*
|
||||
*/
|
||||
public class EmptyFolderImportItem extends ImportItem {
|
||||
|
||||
/**
|
||||
* DOC wchen ImportFolderItem constructor comment.
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
public EmptyFolderImportItem(IPath path) {
|
||||
super(path);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.items.importexport.handlers.model.ImportItem#getRepositoryType()
|
||||
*/
|
||||
@Override
|
||||
public ERepositoryObjectType getRepositoryType() {
|
||||
return repositoryType;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.items.importexport.handlers.model.ImportItem#getLabel()
|
||||
*/
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC wchen Comment method "setLabel".
|
||||
*/
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((this.path == null) ? 0 : this.path.hashCode())
|
||||
+ ((this.label == null) ? 0 : this.label.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof ImportItem)) {
|
||||
return false;
|
||||
}
|
||||
ImportItem other = (ImportItem) obj;
|
||||
if (this.path == null) {
|
||||
if (other.path != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this.path.equals(other.path)) {
|
||||
return false;
|
||||
}
|
||||
if (this.label == null) {
|
||||
if (other.label != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this.label.equals(other.label)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class ImportItem {
|
||||
|
||||
private Property property;
|
||||
|
||||
private IPath path;
|
||||
protected IPath path;
|
||||
|
||||
private List<String> errors = new ArrayList<String>();
|
||||
|
||||
@@ -53,11 +53,13 @@ public class ImportItem {
|
||||
|
||||
private boolean imported = false;
|
||||
|
||||
private String label;
|
||||
protected String label;
|
||||
|
||||
private IRepositoryViewObject existingItemWithSameId;
|
||||
|
||||
private ERepositoryObjectType repositoryType;
|
||||
private IRepositoryViewObject existingItemWithSameName;
|
||||
|
||||
protected ERepositoryObjectType repositoryType;
|
||||
|
||||
private String itemId;
|
||||
|
||||
@@ -186,10 +188,27 @@ public class ImportItem {
|
||||
* DOC hcw ImportItem class global comment. Detailled comment
|
||||
*/
|
||||
public enum State {
|
||||
NAME_EXISTED,
|
||||
ID_EXISTED,
|
||||
NON_EXISTED,
|
||||
NAME_AND_ID_EXISTED
|
||||
/**
|
||||
* only name existed
|
||||
*/
|
||||
NAME_EXISTED,
|
||||
|
||||
/**
|
||||
* only id existed
|
||||
*/
|
||||
ID_EXISTED,
|
||||
|
||||
NON_EXISTED,
|
||||
|
||||
/**
|
||||
* only one existed item with same name and same id
|
||||
*/
|
||||
NAME_AND_ID_EXISTED,
|
||||
|
||||
/**
|
||||
* one existed item with same name, while another existed item with same id
|
||||
*/
|
||||
NAME_AND_ID_EXISTED_BOTH
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
@@ -256,6 +275,14 @@ public class ImportItem {
|
||||
this.existingItemWithSameId = existingItemWithSameId;
|
||||
}
|
||||
|
||||
public IRepositoryViewObject getExistingItemWithSameName() {
|
||||
return this.existingItemWithSameName;
|
||||
}
|
||||
|
||||
public void setExistingItemWithSameName(IRepositoryViewObject existingItemWithSameName) {
|
||||
this.existingItemWithSameName = existingItemWithSameName;
|
||||
}
|
||||
|
||||
public ERepositoryObjectType getRepositoryType() {
|
||||
if (repositoryType == null) {
|
||||
repositoryType = ERepositoryObjectType.getItemType(property.getItem());
|
||||
|
||||
@@ -0,0 +1,530 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.repository.items.importexport.manager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.Project;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.relationship.Relation;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.designer.joblet.model.JobletProcess;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.items.importexport.handlers.model.ImportItem;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
|
||||
/**
|
||||
* created by cmeng on Dec 8, 2016
|
||||
* Detailled comment
|
||||
*
|
||||
*/
|
||||
public class ChangeIdManager {
|
||||
|
||||
private Map<Project, RelationshipItemBuilder> project2RelationshipMap = new HashMap<Project, RelationshipItemBuilder>();
|
||||
|
||||
private Map<String, List<ImportItem>> id2ImportItemsMap = new HashMap<String, List<ImportItem>>();
|
||||
|
||||
private Map<String, Collection<String>> refIds2ItemIdsMap = new HashMap<String, Collection<String>>();
|
||||
|
||||
private Map<String, String> oldId2NewIdMap = new HashMap<String, String>();
|
||||
|
||||
private Set<String> idsNeed2CheckRefs = new HashSet<String>();
|
||||
|
||||
private org.talend.core.model.general.Project currentProject;
|
||||
|
||||
public void clear() {
|
||||
if (!project2RelationshipMap.isEmpty()) {
|
||||
for (RelationshipItemBuilder itemBuilder : project2RelationshipMap.values()) {
|
||||
itemBuilder.unloadRelations();
|
||||
}
|
||||
project2RelationshipMap.clear();
|
||||
}
|
||||
id2ImportItemsMap.clear();
|
||||
refIds2ItemIdsMap.clear();
|
||||
oldId2NewIdMap.clear();
|
||||
idsNeed2CheckRefs.clear();
|
||||
currentProject = null;
|
||||
}
|
||||
|
||||
public void add(ImportItem importItem) {
|
||||
|
||||
prepareRelationshipItemBuilder(importItem.getItemProject());
|
||||
|
||||
// update id-importItem map
|
||||
Property property = importItem.getProperty();
|
||||
if (property != null) {
|
||||
String id = property.getId();
|
||||
// record all importing id
|
||||
oldId2NewIdMap.put(id, null);
|
||||
List<ImportItem> itemRecords = id2ImportItemsMap.get(id);
|
||||
if (itemRecords == null) {
|
||||
itemRecords = new ArrayList<ImportItem>();
|
||||
id2ImportItemsMap.put(id, itemRecords);
|
||||
}
|
||||
itemRecords.add(importItem);
|
||||
|
||||
Item item = property.getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
idsNeed2CheckRefs.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mapOldId2NewId(String oldId, String newId) throws Exception {
|
||||
oldId2NewIdMap.put(oldId, newId);
|
||||
List<ImportItem> importItems = id2ImportItemsMap.get(oldId);
|
||||
if (importItems != null) {
|
||||
id2ImportItemsMap.put(newId, importItems);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeIds() throws Exception {
|
||||
buildRefIds2ItemIdsMap();
|
||||
for (Map.Entry<String, String> entry : oldId2NewIdMap.entrySet()) {
|
||||
changeId(entry.getValue(), entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
private void changeId(String newId, String oldId) throws Exception {
|
||||
|
||||
if (newId == null || StringUtils.equals(newId, oldId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> relationIds = new HashSet<String>();
|
||||
Collection<String> itemIds = refIds2ItemIdsMap.get(oldId);
|
||||
if (itemIds != null && !itemIds.isEmpty()) {
|
||||
relationIds.addAll(itemIds);
|
||||
}
|
||||
|
||||
List<Relation> relations = getRelations(oldId);
|
||||
for (Relation relation : relations) {
|
||||
relationIds.add(relation.getId());
|
||||
}
|
||||
|
||||
if (relationIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> changedIds = new HashSet<String>();
|
||||
for (String relationId : relationIds) {
|
||||
String id = relationId;
|
||||
if (!oldId2NewIdMap.containsKey(id)) {
|
||||
// means didn't import this item
|
||||
continue;
|
||||
}
|
||||
|
||||
if (changedIds.contains(id)) {
|
||||
continue;
|
||||
} else {
|
||||
changedIds.add(id);
|
||||
}
|
||||
|
||||
List<ImportItem> importItems = id2ImportItemsMap.get(id);
|
||||
ERepositoryObjectType repType = importItems.get(0).getRepositoryType();
|
||||
String newRelatedId = oldId2NewIdMap.get(id);
|
||||
if (newRelatedId == null) {
|
||||
// means the id didn't be changed
|
||||
newRelatedId = id;
|
||||
}
|
||||
List<IRepositoryViewObject> repViewObjs = getAllVersion(newRelatedId, repType);
|
||||
if (repViewObjs != null && !repViewObjs.isEmpty()) {
|
||||
for (IRepositoryViewObject repViewObj : repViewObjs) {
|
||||
Property property = repViewObj.getProperty();
|
||||
changeRelated(newId, oldId, property, getCurrentProject());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<IRepositoryViewObject> getAllVersion(String id, ERepositoryObjectType repType) throws Exception {
|
||||
List<IRepositoryViewObject> repViewObjs = null;
|
||||
if (repType != null) {
|
||||
repViewObjs = ProxyRepositoryFactory.getInstance().getAllVersion(getCurrentProject(), id, null, repType);
|
||||
} else {
|
||||
repViewObjs = ProxyRepositoryFactory.getInstance().getAllVersion(getCurrentProject(), id, true);
|
||||
}
|
||||
return repViewObjs;
|
||||
}
|
||||
|
||||
private void buildRefIds2ItemIdsMap() throws Exception {
|
||||
for (String id : idsNeed2CheckRefs) {
|
||||
Collection<String> refIds = getRelatedIdsIfNeeded(id);
|
||||
if (refIds != null && !refIds.isEmpty()) {
|
||||
for (String refId : refIds) {
|
||||
Collection<String> ids = refIds2ItemIdsMap.get(refId);
|
||||
if (ids == null) {
|
||||
ids = new HashSet<String>();
|
||||
refIds2ItemIdsMap.put(refId, ids);
|
||||
}
|
||||
ids.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Collection<String> getRelatedIdsIfNeeded(String oldId) throws Exception {
|
||||
Collection<String> relatedIds = new HashSet<String>();
|
||||
if (!idsNeed2CheckRefs.contains(oldId)) {
|
||||
return relatedIds;
|
||||
}
|
||||
|
||||
String givenId = oldId2NewIdMap.get(oldId);
|
||||
if (givenId == null) {
|
||||
givenId = oldId;
|
||||
}
|
||||
|
||||
List<IRepositoryViewObject> givenObjs = getAllVersion(givenId, id2ImportItemsMap.get(givenId).get(0).getRepositoryType());
|
||||
|
||||
if (givenObjs != null && !givenObjs.isEmpty()) {
|
||||
for (IRepositoryViewObject givenObj : givenObjs) {
|
||||
Item item = givenObj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
String ctxId = ((ConnectionItem) item).getConnection().getContextId();
|
||||
if (ctxId != null && !ctxId.isEmpty()) {
|
||||
relatedIds.add(ctxId);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Unsupportted type when importing: " + item.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return relatedIds;
|
||||
}
|
||||
|
||||
private List<Relation> getRelations(String id) {
|
||||
List<Relation> relations = new ArrayList<Relation>();
|
||||
Collection<RelationshipItemBuilder> relationshipBuilders = project2RelationshipMap.values();
|
||||
for (RelationshipItemBuilder relationshipBuilder : relationshipBuilders) {
|
||||
List<Relation> list = relationshipBuilder.getItemsHaveRelationWith(id, null);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
relations.addAll(list);
|
||||
}
|
||||
}
|
||||
return relations;
|
||||
}
|
||||
|
||||
private void changeRelated(String newId, String oldId, Property property, org.talend.core.model.general.Project project)
|
||||
throws Exception {
|
||||
Item item = property.getItem();
|
||||
boolean modified = false;
|
||||
if (item instanceof ProcessItem) {
|
||||
modified = changeRelatedProcess(newId, oldId, item);
|
||||
} else if (item instanceof JobletProcessItem) {
|
||||
modified = changeRelatedProcess(newId, oldId, item);
|
||||
} else if (item instanceof ConnectionItem) {
|
||||
modified = changeRelatedConnection(newId, oldId, (ConnectionItem) item);
|
||||
} else {
|
||||
throw new Exception("Unsupported id change: id[" + property.getId() + "], name[" + property.getLabel() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
if (modified) {
|
||||
ProxyRepositoryFactory.getInstance().save(project, item);
|
||||
RelationshipItemBuilder.getInstance().addOrUpdateItem(property.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean changeRelatedConnection(String newId, String oldId, ConnectionItem item) throws Exception {
|
||||
boolean modified = false;
|
||||
Connection conn = item.getConnection();
|
||||
String ctxId = conn.getContextId();
|
||||
if (StringUtils.equals(oldId, ctxId)) {
|
||||
conn.setContextId(newId);
|
||||
modified = true;
|
||||
} else {
|
||||
throw new Exception("Unhandled case for import: " + item.toString()); //$NON-NLS-1$
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean changeRelatedProcess(String newId, String oldId, Item item) throws Exception {
|
||||
boolean modified = false;
|
||||
|
||||
/**
|
||||
* designerCoreService must not be null
|
||||
*/
|
||||
IDesignerCoreService designerCoreService = (IDesignerCoreService) GlobalServiceRegister.getDefault()
|
||||
.getService(IDesignerCoreService.class);
|
||||
|
||||
IProcess process = designerCoreService.getProcessFromItem(item);
|
||||
if (process == null) {
|
||||
throw new Exception("Can't get process of item: id[" + item.getProperty().getId() + "], name[" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ item.getProperty().getLabel() + "]"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. change context
|
||||
*/
|
||||
// List contexts = item.getProcess().getContext();
|
||||
// if (contexts != null && !contexts.isEmpty()) {
|
||||
// changeValue(contexts, oldId, newId);
|
||||
// modified = true;
|
||||
// }
|
||||
IContextManager contextManager = process.getContextManager();
|
||||
if (contextManager != null) {
|
||||
changeValue(contextManager.getListContext(), oldId, newId);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 2. change elementParameters
|
||||
*/
|
||||
changeValue(process.getElementParameters(), oldId, newId);
|
||||
modified = true;
|
||||
|
||||
/**
|
||||
* 3. change the nodes like tRunjob, tMysql
|
||||
*/
|
||||
List<? extends INode> nodes = process.getGraphicalNodes();
|
||||
if (nodes != null && !nodes.isEmpty()) {
|
||||
Iterator<? extends INode> nodeIter = nodes.iterator();
|
||||
while (nodeIter.hasNext()) {
|
||||
INode node = nodeIter.next();
|
||||
if (node != null) {
|
||||
changeParamValueOfNode(node, oldId, newId);
|
||||
}
|
||||
}
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
if (process instanceof IProcess2) {
|
||||
ProcessType processType = ((IProcess2) process).saveXmlFile();
|
||||
if (item instanceof ProcessItem) {
|
||||
((ProcessItem) item).setProcess(processType);
|
||||
} else if (item instanceof JobletProcessItem) {
|
||||
((JobletProcessItem) item).setJobletProcess((JobletProcess) processType);
|
||||
} else {
|
||||
throw new Exception("Unhandled process type: id[" + item.getProperty().getId() + "], name[" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ item.getProperty().getLabel() + "]"); //$NON-NLS-1$
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Unhandled process type: id[" + item.getProperty().getId() + "], name[" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ item.getProperty().getLabel() + "]"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
|
||||
}
|
||||
|
||||
private boolean changeParamValueOfNode(INode node, String fromValue, String toValue) throws Exception {
|
||||
boolean changed = false;
|
||||
List<? extends IElementParameter> elementParameters = node.getElementParameters();
|
||||
if (elementParameters != null && !elementParameters.isEmpty()) {
|
||||
changeValue(elementParameters, fromValue, toValue);
|
||||
changed = true;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private void changeValue(Object aim, String fromValue, String toValue) throws Exception {
|
||||
if (aim == null) {
|
||||
return;
|
||||
}
|
||||
if (aim instanceof IElementParameter) {
|
||||
IElementParameter elemParameter = (IElementParameter) aim;
|
||||
Object elementParamValue = elemParameter.getValue();
|
||||
if (elementParamValue != null) {
|
||||
if (elementParamValue instanceof String) {
|
||||
elemParameter.setValue(doReplace(elementParamValue.toString(), fromValue, toValue));
|
||||
} else {
|
||||
changeValue(elementParamValue, fromValue, toValue);
|
||||
}
|
||||
}
|
||||
Map<String, IElementParameter> childParameters = elemParameter.getChildParameters();
|
||||
if (childParameters != null && !childParameters.isEmpty()) {
|
||||
changeValue(childParameters, fromValue, toValue);
|
||||
}
|
||||
} else if (aim instanceof ContextType) {
|
||||
changeValue(((ContextType) aim).getContextParameter(), fromValue, toValue);
|
||||
} else if (aim instanceof ContextParameterType) {
|
||||
ContextParameterType ctxParamType = (ContextParameterType) aim;
|
||||
String comment = ctxParamType.getComment();
|
||||
if (comment != null) {
|
||||
ctxParamType.setComment(doReplace(comment, fromValue, toValue));
|
||||
}
|
||||
String name = ctxParamType.getName();
|
||||
if (name != null) {
|
||||
ctxParamType.setName(doReplace(name, fromValue, toValue));
|
||||
}
|
||||
String prompt = ctxParamType.getPrompt();
|
||||
if (prompt != null) {
|
||||
ctxParamType.setPrompt(doReplace(prompt, fromValue, toValue));
|
||||
}
|
||||
|
||||
// String rawValue = ctxParamType.getRawValue();
|
||||
// if (rawValue != null) {
|
||||
// ctxParamType.setRawValue(doReplace(rawValue, fromValue, toValue));
|
||||
// }
|
||||
|
||||
String repCtxId = ctxParamType.getRepositoryContextId();
|
||||
if (repCtxId != null) {
|
||||
ctxParamType.setRepositoryContextId(doReplace(repCtxId, fromValue, toValue));
|
||||
}
|
||||
|
||||
// String type = ctxParamType.getType();
|
||||
// if (type != null) {
|
||||
// ctxParamType.setType(doReplace(type, fromValue, toValue));
|
||||
// }
|
||||
|
||||
String value = ctxParamType.getValue();
|
||||
if (value != null) {
|
||||
ctxParamType.setValue(doReplace(value, fromValue, toValue));
|
||||
}
|
||||
} else if (aim instanceof IContext) {
|
||||
changeValue(((IContext) aim).getContextParameterList(), fromValue, toValue);
|
||||
} else if (aim instanceof IContextParameter) {
|
||||
IContextParameter contextParameter = (IContextParameter) aim;
|
||||
String comment = contextParameter.getComment();
|
||||
if (comment != null) {
|
||||
contextParameter.setComment(doReplace(comment, fromValue, toValue));
|
||||
}
|
||||
String name = contextParameter.getName();
|
||||
if (name != null) {
|
||||
contextParameter.setName(doReplace(name, fromValue, toValue));
|
||||
}
|
||||
String prompt = contextParameter.getPrompt();
|
||||
if (prompt != null) {
|
||||
contextParameter.setPrompt(doReplace(prompt, fromValue, toValue));
|
||||
}
|
||||
String scriptCode = contextParameter.getScriptCode();
|
||||
if (scriptCode != null) {
|
||||
contextParameter.setScriptCode(doReplace(scriptCode, fromValue, toValue));
|
||||
}
|
||||
String source = contextParameter.getSource();
|
||||
if (source != null) {
|
||||
contextParameter.setSource(doReplace(source, fromValue, toValue));
|
||||
}
|
||||
|
||||
// // reset type will clear the value
|
||||
// String type = contextParameter.getType();
|
||||
// if (type != null) {
|
||||
// contextParameter.setType(doReplace(type, fromValue, toValue));
|
||||
// }
|
||||
|
||||
String value = contextParameter.getValue();
|
||||
if (value != null) {
|
||||
contextParameter.setValue(doReplace(value, fromValue, toValue));
|
||||
}
|
||||
String[] values = contextParameter.getValueList();
|
||||
if (values != null && 0 < values.length) {
|
||||
List<String> list = Arrays.asList(values);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.set(i, doReplace(list.get(i), fromValue, toValue));
|
||||
}
|
||||
contextParameter.setValueList(list.toArray(values));
|
||||
}
|
||||
} else if (aim instanceof String) {
|
||||
throw new Exception("Uncatched value type case!"); //$NON-NLS-1$
|
||||
} else if (aim instanceof List) {
|
||||
List aimList = (List) aim;
|
||||
for (int i = 0; i < aimList.size(); i++) {
|
||||
Object obj = aimList.get(i);
|
||||
if (obj instanceof String) {
|
||||
aimList.set(i, doReplace(obj.toString(), fromValue, toValue));
|
||||
} else {
|
||||
changeValue(obj, fromValue, toValue);
|
||||
}
|
||||
}
|
||||
} else if (aim instanceof Map) {
|
||||
Map aimMap = (Map) aim;
|
||||
if (aimMap != null && !aimMap.isEmpty()) {
|
||||
Object key1 = aimMap.keySet().iterator().next();
|
||||
if (key1 instanceof String) {
|
||||
// maybe need to consider the order like LinkedHashMap
|
||||
Object value = aimMap.get(fromValue);
|
||||
if (value != null) {
|
||||
aimMap.remove(fromValue);
|
||||
aimMap.put(toValue, value);
|
||||
}
|
||||
}
|
||||
Iterator<Map.Entry> iter = aimMap.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry entry = iter.next();
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof String) {
|
||||
entry.setValue(doReplace(value.toString(), fromValue, toValue));
|
||||
} else {
|
||||
changeValue(value, fromValue, toValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (aim instanceof Iterable) {
|
||||
Iterator iter = ((Iterable) aim).iterator();
|
||||
while (iter.hasNext()) {
|
||||
// maybe not good
|
||||
changeValue(iter.next(), fromValue, toValue);
|
||||
}
|
||||
ExceptionHandler.process(new Exception("Unchecked id change type: " + aim.getClass().toString()), Priority.WARN); //$NON-NLS-1$
|
||||
} else if (aim instanceof Object[]) {
|
||||
Object[] objs = (Object[]) aim;
|
||||
for (Object obj : objs) {
|
||||
changeValue(obj, fromValue, toValue);
|
||||
}
|
||||
} else {
|
||||
// some types no need to be changed like Boolean
|
||||
// throw new Exception("Unhandled type: " + aim.getClass().getName()); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
private String doReplace(String aimString, String from, String to) {
|
||||
return aimString.replaceAll("\\b" + from + "\\b", to); //$NON-NLS-1$//$NON-NLS-2$
|
||||
}
|
||||
|
||||
private void prepareRelationshipItemBuilder(Project project) {
|
||||
RelationshipItemBuilder itemBuilder = project2RelationshipMap.get(project);
|
||||
if (itemBuilder == null) {
|
||||
IProxyRepositoryFactory repFactory = ProxyRepositoryFactory.getInstance();
|
||||
itemBuilder = RelationshipItemBuilder.createInstance(repFactory, new org.talend.core.model.general.Project(project));
|
||||
project2RelationshipMap.put(project, itemBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
private org.talend.core.model.general.Project getCurrentProject() {
|
||||
if (currentProject == null) {
|
||||
currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
}
|
||||
return currentProject;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,11 @@ package org.talend.repository.items.importexport.manager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -27,6 +31,8 @@ public abstract class ResourcesManager {
|
||||
|
||||
protected Map<IPath, Object> path2Object = new HashMap<IPath, Object>();
|
||||
|
||||
protected List<IPath> emptyFolders = new ArrayList<IPath>();
|
||||
|
||||
public void add(String path, Object object) {
|
||||
path2Object.put(new Path(path), object);
|
||||
}
|
||||
@@ -37,6 +43,36 @@ public abstract class ResourcesManager {
|
||||
|
||||
public abstract InputStream getStream(IPath path) throws IOException;
|
||||
|
||||
public boolean isContainsPath(IPath path) {
|
||||
return getPaths().contains(path);
|
||||
}
|
||||
|
||||
public void addFolder(String path) {
|
||||
boolean isEmptyFolder = true;
|
||||
for (IPath objectPath : path2Object.keySet()) {
|
||||
if (objectPath.toPortableString().contains(path)) {
|
||||
isEmptyFolder = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isEmptyFolder) {
|
||||
Path newPath = new Path(path);
|
||||
emptyFolders.add(newPath);
|
||||
}
|
||||
}
|
||||
|
||||
public List<IPath> getEmptyFolders() {
|
||||
Collections.sort(emptyFolders, new Comparator<IPath>() {
|
||||
|
||||
@Override
|
||||
public int compare(IPath o1, IPath o2) {
|
||||
return o1.segmentCount() - o2.segmentCount();
|
||||
}
|
||||
});
|
||||
return emptyFolders;
|
||||
|
||||
}
|
||||
|
||||
public abstract boolean collectPath2Object(Object root);
|
||||
|
||||
public abstract void closeResource();
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.talend.repository.items.importexport.wizard.models;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.repository.items.importexport.handlers.model.ImportItem;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
*/
|
||||
@@ -28,6 +30,8 @@ public abstract class ImportNode implements Comparable<ImportNode> {
|
||||
|
||||
private boolean visible;
|
||||
|
||||
protected ImportItem itemRecord;
|
||||
|
||||
public ImportNode() {
|
||||
super();
|
||||
this.visible = true; // default, all should be visible.
|
||||
@@ -174,4 +178,17 @@ public abstract class ImportNode implements Comparable<ImportNode> {
|
||||
return label.compareTo(label2);
|
||||
}
|
||||
|
||||
public ImportItem getItemRecord() {
|
||||
return this.itemRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the itemRecord.
|
||||
*
|
||||
* @param itemRecord the itemRecord to set
|
||||
*/
|
||||
public void setItemRecord(ImportItem itemRecord) {
|
||||
this.itemRecord = itemRecord;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.talend.core.hadoop.IHadoopClusterService;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.Project;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.repository.items.importexport.handlers.model.EmptyFolderImportItem;
|
||||
import org.talend.repository.items.importexport.handlers.model.ImportItem;
|
||||
|
||||
/**
|
||||
@@ -100,13 +101,21 @@ public class ImportNodesBuilder {
|
||||
if (parentImportNode == null) {
|
||||
parentImportNode = projectImportNode;
|
||||
}
|
||||
//
|
||||
String path = item.getState().getPath();
|
||||
if (StringUtils.isNotEmpty(path)) { // if has path, will find the real path node.
|
||||
parentImportNode = findAndCreateFolderNode(typeImportNode, new Path(path));
|
||||
|
||||
if (itemRecord instanceof EmptyFolderImportItem) {
|
||||
IPath path = new Path(item.getState().getPath());
|
||||
path = path.append(itemRecord.getLabel());
|
||||
parentImportNode = findAndCreateFolderNode(parentImportNode, path);
|
||||
parentImportNode.setItemRecord(itemRecord);
|
||||
} else {
|
||||
//
|
||||
String path = item.getState().getPath();
|
||||
if (StringUtils.isNotEmpty(path)) { // if has path, will find the real path node.
|
||||
parentImportNode = findAndCreateFolderNode(typeImportNode, new Path(path));
|
||||
}
|
||||
ItemImportNode itemNode = new ItemImportNode(itemRecord);
|
||||
parentImportNode.addChild(itemNode);
|
||||
}
|
||||
ItemImportNode itemNode = new ItemImportNode(itemRecord);
|
||||
parentImportNode.addChild(itemNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@ import org.talend.repository.items.importexport.handlers.model.ImportItem;
|
||||
*/
|
||||
public class ItemImportNode extends ImportNode {
|
||||
|
||||
private final ImportItem itemRecord;
|
||||
|
||||
public ItemImportNode(ImportItem itemRecord) {
|
||||
super();
|
||||
this.itemRecord = itemRecord;
|
||||
@@ -57,8 +55,4 @@ public class ItemImportNode extends ImportNode {
|
||||
return getItemRecord().getLabel();
|
||||
}
|
||||
|
||||
public ImportItem getItemRecord() {
|
||||
return this.itemRecord;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K, T> void addFolderMembers(Project project, ERepositoryObjectType type, Container<K, T> toReturn,
|
||||
public synchronized <K, T> void addFolderMembers(Project project, ERepositoryObjectType type, Container<K, T> toReturn,
|
||||
Object objectFolder, int options) throws PersistenceException {
|
||||
FolderHelper folderHelper = getFolderHelper(project.getEmfProject());
|
||||
FolderItem currentFolderItem = null;
|
||||
@@ -546,7 +546,7 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
* @throws PersistenceException
|
||||
*/
|
||||
@Override
|
||||
protected List<IRepositoryViewObject> getSerializableFromFolder(Project project, Object folder, String id,
|
||||
protected synchronized List<IRepositoryViewObject> getSerializableFromFolder(Project project, Object folder, String id,
|
||||
ERepositoryObjectType type, boolean allVersion, boolean searchInChildren, boolean withDeleted,
|
||||
boolean avoidSaveProject, boolean... recursiveCall) throws PersistenceException {
|
||||
List<IRepositoryViewObject> toReturn = new VersionList(allVersion);
|
||||
@@ -2023,8 +2023,8 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
return itemResource;
|
||||
}
|
||||
|
||||
private Resource save(BusinessProcessItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(item);
|
||||
private Resource save(ResourceSet resourceSet, BusinessProcessItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(resourceSet, item);
|
||||
itemResource.getContents().clear();
|
||||
// itemResource.getContents().add(item.getNotation());
|
||||
itemResource.getContents().add(item.getSemantic());
|
||||
@@ -2034,8 +2034,8 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
return itemResource;
|
||||
}
|
||||
|
||||
private Resource save(ConnectionItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(item);
|
||||
private Resource save(ResourceSet resourceSet, ConnectionItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(resourceSet, item);
|
||||
itemResource.getContents().clear();
|
||||
MetadataManager.addContents(item, itemResource); // 13221
|
||||
|
||||
@@ -2057,8 +2057,8 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
return itemResource;
|
||||
}
|
||||
|
||||
private Resource save(TDQItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(item);
|
||||
private Resource save(ResourceSet resourceSet, TDQItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(resourceSet, item);
|
||||
return itemResource;
|
||||
}
|
||||
|
||||
@@ -2070,8 +2070,8 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
return itemResource;
|
||||
}
|
||||
|
||||
private Resource save(FileItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(item);
|
||||
private Resource save(ResourceSet resourceSet, FileItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(resourceSet, item);
|
||||
|
||||
ByteArray content = item.getContent();
|
||||
itemResource.getContents().clear();
|
||||
@@ -2118,8 +2118,8 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
return itemResource;
|
||||
}
|
||||
|
||||
private Resource save(ContextItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(item);
|
||||
private Resource save(ResourceSet resourceSet, ContextItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(resourceSet, item);
|
||||
|
||||
itemResource.getContents().clear();
|
||||
itemResource.getContents().addAll(item.getContext());
|
||||
@@ -2134,8 +2134,8 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
return itemResource;
|
||||
}
|
||||
|
||||
private Resource save(SnippetItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(item);
|
||||
private Resource save(ResourceSet resourceSet, SnippetItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(resourceSet, item);
|
||||
|
||||
itemResource.getContents().clear();
|
||||
itemResource.getContents().addAll(item.getVariables());
|
||||
@@ -2143,8 +2143,8 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
return itemResource;
|
||||
}
|
||||
|
||||
private Resource saveScreenshots(Item item) {
|
||||
Resource itemResource = xmiResourceManager.getScreenshotResource(item, true, true);
|
||||
private Resource saveScreenshots(ResourceSet resourceSet, Item item) {
|
||||
Resource itemResource = xmiResourceManager.getScreenshotResource(resourceSet, item, true, true);
|
||||
EMap screenshots = null;
|
||||
if (item instanceof ProcessItem) {
|
||||
screenshots = ((ProcessItem) item).getProcess().getScreenshots();
|
||||
@@ -2158,15 +2158,15 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
return itemResource;
|
||||
}
|
||||
|
||||
private Resource save(ProcessItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(item);
|
||||
private Resource save(ResourceSet resourceSet, ProcessItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(resourceSet, item);
|
||||
itemResource.getContents().clear();
|
||||
itemResource.getContents().add(item.getProcess());
|
||||
return itemResource;
|
||||
}
|
||||
|
||||
private Resource save(JobletProcessItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(item);
|
||||
private Resource save(ResourceSet resourceSet, JobletProcessItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(resourceSet, item);
|
||||
|
||||
itemResource.getContents().clear();
|
||||
itemResource.getContents().add(item.getJobletProcess());
|
||||
@@ -2198,8 +2198,8 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
return itemResource;
|
||||
}
|
||||
|
||||
private Resource save(LinkDocumentationItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(item);
|
||||
private Resource save(ResourceSet resourceSet, LinkDocumentationItem item) {
|
||||
Resource itemResource = xmiResourceManager.getItemResource(resourceSet, item);
|
||||
|
||||
itemResource.getContents().clear();
|
||||
itemResource.getContents().add(item.getLink());
|
||||
@@ -2209,8 +2209,23 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
|
||||
@Override
|
||||
public void save(Project project, Item item) throws PersistenceException {
|
||||
xmiResourceManager.getAffectedResources(item.getProperty()); // only call this will force to load all sub items
|
||||
// in case some are not loaded
|
||||
|
||||
boolean isSameResourceSet = true;
|
||||
ResourceSet resourceSet = xmiResourceManager.getResourceSet();
|
||||
try {
|
||||
ResourceSet projectResourceSet = project.getEmfProject().eResource().getResourceSet();
|
||||
ResourceSet defaultResourceSet = xmiResourceManager.getResourceSet();
|
||||
if (projectResourceSet != null) {
|
||||
resourceSet = projectResourceSet;
|
||||
}
|
||||
isSameResourceSet = (projectResourceSet == defaultResourceSet);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
if (isSameResourceSet) {
|
||||
xmiResourceManager.getAffectedResources(item.getProperty()); // only call this will force to load all sub
|
||||
// items in case some are not loaded
|
||||
}
|
||||
|
||||
computePropertyMaxInformationLevel(item.getProperty());
|
||||
item.getProperty().setModificationDate(new Date());
|
||||
@@ -2222,13 +2237,13 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
switch (eClass.getClassifierID()) {
|
||||
|
||||
case PropertiesPackage.HEADER_FOOTER_CONNECTION_ITEM:
|
||||
itemResource = save((HeaderFooterConnectionItem) item);
|
||||
itemResource = save(resourceSet, (HeaderFooterConnectionItem) item);
|
||||
break;
|
||||
case PropertiesPackage.BUSINESS_PROCESS_ITEM:
|
||||
itemResource = save((BusinessProcessItem) item);
|
||||
itemResource = save(resourceSet, (BusinessProcessItem) item);
|
||||
break;
|
||||
case PropertiesPackage.SVG_BUSINESS_PROCESS_ITEM:
|
||||
itemResource = save((SVGBusinessProcessItem) item);
|
||||
itemResource = save(resourceSet, (SVGBusinessProcessItem) item);
|
||||
break;
|
||||
case PropertiesPackage.POSITIONAL_FILE_CONNECTION_ITEM:
|
||||
case PropertiesPackage.DELIMITED_FILE_CONNECTION_ITEM:
|
||||
@@ -2247,58 +2262,58 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
case PropertiesPackage.EBCDIC_CONNECTION_ITEM:
|
||||
// not really usefull for ConnectionItem : it's not copied to
|
||||
// another resource for edition
|
||||
itemResource = save((ConnectionItem) item);
|
||||
itemResource = save(resourceSet, (ConnectionItem) item);
|
||||
break;
|
||||
case PropertiesPackage.LDIF_FILE_CONNECTION_ITEM:
|
||||
// not really usefull for ConnectionItem : it's not copied to
|
||||
// another resource for edition
|
||||
itemResource = save((ConnectionItem) item);
|
||||
itemResource = save(resourceSet, (ConnectionItem) item);
|
||||
break;
|
||||
case PropertiesPackage.GENERIC_SCHEMA_CONNECTION_ITEM:
|
||||
// not really usefull for ConnectionItem : it's not copied to
|
||||
// another resource for edition
|
||||
itemResource = save((ConnectionItem) item);
|
||||
itemResource = save(resourceSet, (ConnectionItem) item);
|
||||
break;
|
||||
case PropertiesPackage.DOCUMENTATION_ITEM:
|
||||
case PropertiesPackage.ROUTINE_ITEM:
|
||||
case PropertiesPackage.PIGUDF_ITEM:
|
||||
case PropertiesPackage.JOB_SCRIPT_ITEM:
|
||||
case PropertiesPackage.SQL_PATTERN_ITEM:
|
||||
itemResource = save((FileItem) item);
|
||||
itemResource = save(resourceSet, (FileItem) item);
|
||||
break;
|
||||
case PropertiesPackage.PROCESS_ITEM:
|
||||
screenshotResource = saveScreenshots(item);
|
||||
itemResource = save((ProcessItem) item);
|
||||
screenshotResource = saveScreenshots(resourceSet, item);
|
||||
itemResource = save(resourceSet, (ProcessItem) item);
|
||||
screenshotFlag = true;
|
||||
break;
|
||||
case PropertiesPackage.JOBLET_PROCESS_ITEM:
|
||||
screenshotResource = saveScreenshots(item);
|
||||
itemResource = save((JobletProcessItem) item);
|
||||
screenshotResource = saveScreenshots(resourceSet, item);
|
||||
itemResource = save(resourceSet, (JobletProcessItem) item);
|
||||
screenshotFlag = true;
|
||||
break;
|
||||
case PropertiesPackage.CONTEXT_ITEM:
|
||||
itemResource = save((ContextItem) item);
|
||||
itemResource = save(resourceSet, (ContextItem) item);
|
||||
break;
|
||||
case PropertiesPackage.SNIPPET_ITEM:
|
||||
itemResource = save((SnippetItem) item);
|
||||
itemResource = save(resourceSet, (SnippetItem) item);
|
||||
break;
|
||||
case PropertiesPackage.JOB_DOCUMENTATION_ITEM:
|
||||
itemResource = save((JobDocumentationItem) item);
|
||||
itemResource = save(resourceSet, (JobDocumentationItem) item);
|
||||
break;
|
||||
case PropertiesPackage.JOBLET_DOCUMENTATION_ITEM:
|
||||
itemResource = save((JobletDocumentationItem) item);
|
||||
itemResource = save(resourceSet, (JobletDocumentationItem) item);
|
||||
break;
|
||||
case PropertiesPackage.LINK_DOCUMENTATION_ITEM:
|
||||
itemResource = save((LinkDocumentationItem) item);
|
||||
itemResource = save(resourceSet, (LinkDocumentationItem) item);
|
||||
break;
|
||||
case PropertiesPackage.RULES_ITEM:// feature 6484 added
|
||||
itemResource = save((RulesItem) item);
|
||||
itemResource = save(resourceSet, (RulesItem) item);
|
||||
break;
|
||||
case PropertiesPackage.VALIDATION_RULES_CONNECTION_ITEM:
|
||||
itemResource = save((ValidationRulesConnectionItem) item);
|
||||
itemResource = save(resourceSet, (ValidationRulesConnectionItem) item);
|
||||
break;
|
||||
case PropertiesPackage.EDIFACT_CONNECTION_ITEM:
|
||||
itemResource = save((EDIFACTConnectionItem) item);
|
||||
itemResource = save(resourceSet, (EDIFACTConnectionItem) item);
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
@@ -2313,7 +2328,7 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
Property property = repositoryViewObject.getProperty();
|
||||
item = property.getItem();
|
||||
}
|
||||
itemResource = save((TDQItem) item);
|
||||
itemResource = save(resourceSet, (TDQItem) item);
|
||||
} else {
|
||||
for (IRepositoryContentHandler handler : RepositoryContentManager.getHandlers()) {
|
||||
screenshotResource = handler.saveScreenShots(item);
|
||||
@@ -3151,7 +3166,18 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
|
||||
@Override
|
||||
public void unloadResources(Property property) {
|
||||
xmiResourceManager.unloadResources(property);
|
||||
ResourceSet resourceSet = null;
|
||||
org.talend.core.model.properties.Project project = ProjectManager.getInstance().getProject(property);
|
||||
if (project != null) {
|
||||
Resource resource = project.eResource();
|
||||
if (resource != null) {
|
||||
resourceSet = resource.getResourceSet();
|
||||
}
|
||||
}
|
||||
if (resourceSet == null) {
|
||||
resourceSet = xmiResourceManager.getResourceSet();
|
||||
}
|
||||
xmiResourceManager.unloadResources(resourceSet, property);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.MDMConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
|
||||
/**
|
||||
* created by ggu on Sep 1, 2014 Detailled comment
|
||||
@@ -55,6 +56,7 @@ public class UnifyPasswordEncryption4MDMConnectionMigrationTask extends Abstract
|
||||
try {
|
||||
if (!mdmConn.isContextMode()) {
|
||||
String pass = mdmConn.getPassword();
|
||||
pass = ConnectionHelper.getCleanPassword(pass);
|
||||
// because before, it's raw value, so encrypt it directly.
|
||||
mdmConn.setPassword(mdmConn.getValue(pass, true));
|
||||
factory.save(item, true);
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.LDAPSchemaConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
|
||||
/**
|
||||
* created by ggu on Aug 29, 2014 Detailled comment
|
||||
@@ -56,6 +57,7 @@ public class UnifyPasswordEncryption4LdapConnectionMigrationTask extends Abstrac
|
||||
if (!ldapConn.isContextMode()) {
|
||||
// before this migration ,the pass is raw, didn't encrypt.
|
||||
String pass = ldapConn.getBindPassword();
|
||||
pass = ConnectionHelper.getCleanPassword(pass);
|
||||
ldapConn.setBindPassword(ldapConn.getValue(pass, true));
|
||||
factory.save(item, true);
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.SalesforceSchemaConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
|
||||
/**
|
||||
* created by ggu on Aug 29, 2014 Detailled comment
|
||||
@@ -55,9 +56,11 @@ public class UnifyPasswordEncryption4SalesforceSchemaConnectionMigrationTask ext
|
||||
try {
|
||||
if (!ssConn.isContextMode()) {
|
||||
// before this migration ,the pass is raw, didn't encrypt.
|
||||
ssConn.setPassword(ssConn.getValue(ssConn.getPassword(), true));
|
||||
ssConn.setProxyPassword(ssConn.getValue(ssConn.getProxyPassword(), true));
|
||||
ssConn.setConsumeSecret(ssConn.getValue(ssConn.getConsumeSecret(), true));
|
||||
ssConn.setPassword(ssConn.getValue(ConnectionHelper.getCleanPassword(ssConn.getPassword()), true));
|
||||
ssConn.setProxyPassword(
|
||||
ssConn.getValue(ConnectionHelper.getCleanPassword(ssConn.getProxyPassword()), true));
|
||||
ssConn.setConsumeSecret(
|
||||
ssConn.getValue(ConnectionHelper.getCleanPassword(ssConn.getConsumeSecret()), true));
|
||||
factory.save(item, true);
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.WSDLSchemaConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
|
||||
/**
|
||||
* created by ggu on Aug 29, 2014 Detailled comment
|
||||
@@ -55,8 +56,9 @@ public class UnifyPasswordEncryption4WsdlConnectionMigrationTask extends Abstrac
|
||||
try {
|
||||
if (!wsdlConn.isContextMode()) {
|
||||
// before this migration ,the password is raw, didn't encrypt.
|
||||
wsdlConn.setPassword(wsdlConn.getValue(wsdlConn.getPassword(), true));
|
||||
wsdlConn.setProxyPassword(wsdlConn.getValue(wsdlConn.getProxyPassword(), true));
|
||||
wsdlConn.setPassword(wsdlConn.getValue(ConnectionHelper.getCleanPassword(wsdlConn.getPassword()), true));
|
||||
wsdlConn.setProxyPassword(
|
||||
wsdlConn.getValue(ConnectionHelper.getCleanPassword(wsdlConn.getProxyPassword()), true));
|
||||
factory.save(item, true);
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
}
|
||||
|
||||
@@ -45,11 +45,15 @@ public class RepoCommonViewerProvider extends AbstractViewerProvider {
|
||||
|
||||
private String baseViewId = null;
|
||||
|
||||
public TreeViewer createViewer(Composite parent, String specifiedPerspectiveId) {
|
||||
TreeViewer treeViewer = super.createViewer(parent);
|
||||
doFilterForCommonViewer(treeViewer, specifiedPerspectiveId);
|
||||
return treeViewer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeViewer createViewer(Composite parent) {
|
||||
TreeViewer treeViewer = super.createViewer(parent);
|
||||
doFilterForCommonViewer(treeViewer);
|
||||
return treeViewer;
|
||||
return createViewer(parent, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,6 +67,10 @@ public class RepoCommonViewerProvider extends AbstractViewerProvider {
|
||||
}
|
||||
|
||||
protected void doFilterForCommonViewer(TreeViewer treeViewer) {
|
||||
doFilterForCommonViewer(treeViewer, null);
|
||||
}
|
||||
|
||||
protected void doFilterForCommonViewer(TreeViewer treeViewer, String specifiedPerspectiveId) {
|
||||
if (treeViewer instanceof INavigatorContentServiceProvider) {
|
||||
INavigatorContentService navigatorContentService = ((INavigatorContentServiceProvider) treeViewer)
|
||||
.getNavigatorContentService();
|
||||
@@ -77,7 +85,8 @@ public class RepoCommonViewerProvider extends AbstractViewerProvider {
|
||||
helper.setNavigatorContentService(navigatorContentService);
|
||||
helper.setActionProviderId(PerspectiveFilterActionProvider.ID);
|
||||
|
||||
String perspectiveId = activePage.getPerspective().getId();
|
||||
String perspectiveId = specifiedPerspectiveId == null ? activePage.getPerspective().getId()
|
||||
: specifiedPerspectiveId;
|
||||
helper.doFiltering(perspectiveId);
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public final class FilesUtils {
|
||||
if (name != null) {
|
||||
String checkedName = name.toLowerCase();
|
||||
for (String element : SVN_FOLDER_NAMES) {
|
||||
if (element.equals(checkedName) || checkedName.endsWith(element)) {
|
||||
if (element.equals(checkedName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -99,6 +99,7 @@ public final class FilesUtils {
|
||||
|
||||
FileFilter folderFilter = new FileFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
return pathname.isDirectory() && (sourceFolderFilter == null || sourceFolderFilter.accept(pathname));
|
||||
}
|
||||
@@ -106,6 +107,7 @@ public final class FilesUtils {
|
||||
};
|
||||
FileFilter fileFilter = new FileFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
return !pathname.isDirectory() && (sourceFileFilter == null || sourceFileFilter.accept(pathname));
|
||||
}
|
||||
@@ -226,6 +228,7 @@ public final class FilesUtils {
|
||||
public static FileFilter getExcludeSystemFilesFilter() {
|
||||
FileFilter filter = new FileFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
return !isSVNFolder(pathname);
|
||||
}
|
||||
@@ -237,6 +240,7 @@ public final class FilesUtils {
|
||||
public static FileFilter getAcceptJARFilesFilter() {
|
||||
FileFilter filter = new FileFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
return pathname.toString().endsWith(".jar");
|
||||
}
|
||||
@@ -248,6 +252,7 @@ public final class FilesUtils {
|
||||
public static FileFilter getAcceptPMFilesFilter() {
|
||||
FileFilter filter = new FileFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
return pathname.toString().endsWith(".pm");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user