Compare commits
6 Commits
patch/5.5.
...
patch/5.4.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1342f2ceec | ||
|
|
f7623122bf | ||
|
|
3c22d8c4e0 | ||
|
|
cff9e0ac4c | ||
|
|
da2be71e56 | ||
|
|
0292b0364a |
5
.gitignore
vendored
@@ -1,5 +0,0 @@
|
||||
*.class
|
||||
bin/
|
||||
target/
|
||||
class/
|
||||
classes/
|
||||
47
README.md
@@ -1,47 +0,0 @@
|
||||
# Talend Common Repository
|
||||
http://www.talend.com
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
> Contents
|
||||
|
||||
This repository contains the source files that are common across all Talend Open Studio products. These files must be used together with one or more of the following: [tdi-studio-se](https://github.com/Talend/tdi-studio-se), [tdq-studio-se](https://github.com/Talend/tdq-studio-se), [tmdm-studio-se](https://github.com/Talend/tmdm-studio-se), [tesb-studio-se](https://github.com/Talend/tesb-studio-se) or [tbd-studio-se](https://github.com/Talend/tbd-studio-se).
|
||||
|
||||
|
||||
## Repository Structure
|
||||
All Talend Studio repositories follow the same file structure:
|
||||
```
|
||||
|
||||
|_ main Main Eclipse plugins and features
|
||||
|_ features
|
||||
|_ plugins
|
||||
|_ test Eclipse plugins and features for unit tests.
|
||||
|_ features
|
||||
|_ plugins
|
||||
|_ i18n Internationalization plugins and features.
|
||||
|_ features
|
||||
|_ plugins
|
||||
```
|
||||
|
||||
|
||||
## Support
|
||||
|
||||
You can ask for help on our [Forum](http://www.talend.com/services/global-technical-support).
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
We welcome contributions of all kinds from anyone.
|
||||
|
||||
Using the bug tracker [Talend bugtracker](http://jira.talendforge.org/) is the best channel for bug reports, feature requests and submitting pull requests.
|
||||
|
||||
Feel free to share your Talend components on [Talend Exchange](http://www.talendforge.org/exchange).
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2006-2014 Talend
|
||||
|
||||
Licensed under the LPGLv3 License
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="class"/>
|
||||
</classpath>
|
||||
@@ -1,6 +0,0 @@
|
||||
source.. = src/main/java/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin_en.properties,\
|
||||
plugin_fr.properties
|
||||
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
@@ -1 +0,0 @@
|
||||
talend.version=5.5.2
|
||||
@@ -1,212 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2013 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.repository.model;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.map.MultiKeyMap;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
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.ICheckDeleteItemReference;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.ERepositoryStatus;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.ItemReferenceBean;
|
||||
import org.talend.repository.ui.actions.DeleteActionCache;
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC hcyi class global comment. Detailled comment
|
||||
*/
|
||||
public class CheckJobDeleteReference extends AbstractCheckDeleteItemReference implements ICheckDeleteItemReference {
|
||||
|
||||
private static final String PROCESS_TYPE_PROCESS = "PROCESS_TYPE_PROCESS"; //$NON-NLS-1$
|
||||
|
||||
private static final String USE_DYNAMIC_JOB = "USE_DYNAMIC_JOB"; //$NON-NLS-1$
|
||||
|
||||
// almost move from the method checkRepositoryNodeFromProcess of DeleteAction class.
|
||||
@Override
|
||||
public Set<ItemReferenceBean> checkItemReferenceBeans(IProxyRepositoryFactory factory, DeleteActionCache deleteActionCache,
|
||||
IRepositoryViewObject object) {
|
||||
Item nodeItem = object.getProperty().getItem();
|
||||
boolean needCheckJobIfUsedInProcess = false;
|
||||
if (nodeItem instanceof ProcessItem) {
|
||||
needCheckJobIfUsedInProcess = true;
|
||||
}
|
||||
Set<ItemReferenceBean> list = new HashSet<ItemReferenceBean>();
|
||||
if (needCheckJobIfUsedInProcess) {
|
||||
Property property = object.getProperty();
|
||||
if (property != null) {
|
||||
String label = property.getLabel();
|
||||
String version = property.getVersion();
|
||||
ERepositoryObjectType type = object.getRepositoryObjectType();
|
||||
boolean isItemDeleted = factory.getStatus(object) == ERepositoryStatus.DELETED;
|
||||
Item item = property.getItem();
|
||||
if (!(item instanceof ProcessItem)) {
|
||||
return list;
|
||||
}
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(property.getId());
|
||||
if (relations.isEmpty()) {
|
||||
return list;
|
||||
}
|
||||
Set<Project> refParentProjects = new HashSet<Project>();
|
||||
try {
|
||||
refParentProjects.add(ProjectManager.getInstance().getCurrentProject());
|
||||
refParentProjects.addAll(ProjectManager.getInstance().getReferencedProjects());
|
||||
for (Project refP : refParentProjects) {
|
||||
List<IRepositoryViewObject> processes = factory.getAll(refP, ERepositoryObjectType.PROCESS, true);
|
||||
deleteActionCache.setProcessList(processes);
|
||||
for (IRepositoryViewObject process : deleteActionCache.getProcessList()) {
|
||||
Property property2 = process.getProperty();
|
||||
if (isOpenedItem(property2, deleteActionCache.getOpenProcessMap())) {
|
||||
// will be checked in the opened item list.
|
||||
continue;
|
||||
}
|
||||
Relation current = new Relation();
|
||||
current.setId(property2.getId());
|
||||
current.setType(RelationshipItemBuilder.JOB_RELATION);
|
||||
current.setVersion(property2.getVersion());
|
||||
if (!relations.contains(current)) {
|
||||
continue;
|
||||
}
|
||||
boolean isDelete = factory.getStatus(process) == ERepositoryStatus.DELETED;
|
||||
Item item2 = property2.getItem();
|
||||
if (item == item2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String path = item2.getState().getPath();
|
||||
boolean found = false;
|
||||
ItemReferenceBean bean = new ItemReferenceBean();
|
||||
bean.setItemName(label);
|
||||
bean.setItemVersion(version);
|
||||
bean.setItemType(type);
|
||||
bean.setItemDeleted(isItemDeleted);
|
||||
bean.setReferenceItemName(property2.getLabel());
|
||||
bean.setReferenceItemVersion(property2.getVersion());
|
||||
bean.setReferenceItemType(process.getRepositoryObjectType());
|
||||
bean.setReferenceItemPath(path);
|
||||
bean.setReferenceProjectName(refP.getLabel());
|
||||
bean.setReferenceItemDeleted(isDelete);
|
||||
for (ItemReferenceBean b : list) {
|
||||
if (b.equals(bean)) {
|
||||
found = true;
|
||||
b.addNodeNum();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
list.add(bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (IProcess2 openedProcess : deleteActionCache.getOpenedProcessList()) {
|
||||
for (INode node : openedProcess.getGraphicalNodes()) {
|
||||
boolean equals = false;
|
||||
IElementParameter processTypeParam = node.getElementParameter(PROCESS_TYPE_PROCESS);
|
||||
if (processTypeParam != null) {
|
||||
IElementParameter isUseDynamicJob = node.getElementParameter(USE_DYNAMIC_JOB); //$NON-NLS-1$
|
||||
if (isUseDynamicJob != null && (Boolean) isUseDynamicJob.getValue()) {
|
||||
String[] jobsID = ((String) processTypeParam.getValue()).split(";"); //$NON-NLS-1$
|
||||
for (String jobID : jobsID) {
|
||||
if (property.getId().equals(jobID)) {
|
||||
equals = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (property.getId().equals(processTypeParam.getValue())) {
|
||||
equals = true;
|
||||
}
|
||||
}
|
||||
boolean isDelete = factory.getStatus(openedProcess) == ERepositoryStatus.DELETED;
|
||||
Property property2 = openedProcess.getProperty();
|
||||
Item item2 = property2.getItem();
|
||||
String path = item2.getState().getPath();
|
||||
if (equals) {
|
||||
boolean found = false;
|
||||
ItemReferenceBean bean = new ItemReferenceBean();
|
||||
bean.setItemName(label);
|
||||
bean.setItemVersion(version);
|
||||
bean.setItemType(type);
|
||||
bean.setItemDeleted(isItemDeleted);
|
||||
bean.setReferenceItemName(property2.getLabel());
|
||||
bean.setReferenceItemVersion(property2.getVersion());
|
||||
bean.setReferenceItemType(ERepositoryObjectType.getItemType(item2));
|
||||
bean.setReferenceItemPath(path);
|
||||
|
||||
bean.setReferenceProjectName(ProjectManager.getInstance().getProject(property2).getLabel());
|
||||
bean.setReferenceItemDeleted(isDelete);
|
||||
for (ItemReferenceBean b : list) {
|
||||
if (b.equals(bean)) {
|
||||
found = true;
|
||||
b.addNodeNum();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
list.add(bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If the reference job or joblet is in the recycle bin but the joblet is not then no need to check; If both the
|
||||
* joblet and the reference job or joblet are all in the recycle bin and they are all in the delete list then no
|
||||
* need to check them; If both the joblet and the reference job or joblet are all not in the recycle bin and
|
||||
* they are all in the delete list then no need to check them too.
|
||||
*/
|
||||
Iterator<ItemReferenceBean> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
ItemReferenceBean bean = it.next();
|
||||
if ((!bean.isItemDeleted() && bean.isReferenceItemDeleted())
|
||||
|| (bean.isItemDeleted() && bean.isReferenceItemDeleted() && isItemInDeleteList(bean, true))
|
||||
|| (!bean.isItemDeleted() && !bean.isReferenceItemDeleted() && isItemInDeleteList(bean, true))) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private boolean isOpenedItem(Property property, MultiKeyMap openProcessMap) {
|
||||
if (property == null) {
|
||||
return false;
|
||||
}
|
||||
return (openProcessMap.get(property.getId(), property.getLabel(), property.getVersion()) != null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.core.hadoop;
|
||||
|
||||
/**
|
||||
* created by ycbai on 2014-5-28 Detailled comment
|
||||
*
|
||||
*/
|
||||
public enum EHadoopConfigurationJars {
|
||||
|
||||
HDFS(
|
||||
new String[] { "hadoop-conf.jar" }, new String[] { "hadoop-conf-kerberos.jar", "jetty-util-6.1.26.jar", "jersey-core-1.8.jar", "commons-io-2.4.jar" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
||||
|
||||
HCATALOG(new String[] { "hadoop-conf.jar" }, new String[] { "hadoop-conf-kerberos.jar" }), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
HIVE(new String[] { "hadoop-conf.jar" }, new String[] { "hadoop-conf-kerberos.jar" }), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
;
|
||||
|
||||
private String[] disableSecurityJars;
|
||||
|
||||
private String[] enableSecurityJars;
|
||||
|
||||
EHadoopConfigurationJars(String[] disableSecurityJars, String[] enableSecurityJars) {
|
||||
this.disableSecurityJars = disableSecurityJars;
|
||||
this.enableSecurityJars = enableSecurityJars;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public String[] getDisableSecurityJars() {
|
||||
return this.disableSecurityJars;
|
||||
}
|
||||
|
||||
public String[] getEnableSecurityJars() {
|
||||
return this.enableSecurityJars;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.core.model.metadata;
|
||||
|
||||
/**
|
||||
* created by ldong on Jan 13, 2015 Detailled comment
|
||||
*
|
||||
*/
|
||||
public interface IDatabaseConstant {
|
||||
|
||||
public static final String REDSHIFT = "DATABASE:REDSHIFT";
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.core.model.relationship;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
*/
|
||||
public abstract class AbstractJobParameterInRepositoryRelationshipHandler extends AbstractJobParameterRelationshipHandler {
|
||||
|
||||
public static final String IN_REPOSITORY = "REPOSITORY"; //$NON-NLS-1$
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.model.relationship.AbstractParameterRelationshipHandler#collect(java.util.Map,
|
||||
* java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
protected Set<Relation> collect(Map<String, ElementParameterType> parametersMap, Map<?, ?> options) {
|
||||
Set<Relation> relationSet = new HashSet<Relation>();
|
||||
|
||||
for (ElementParameterType paramType : parametersMap.values()) {
|
||||
if (paramType.getName().endsWith(":" + getRepositoryTypeName())) { //$NON-NLS-1$
|
||||
String name = paramType.getName().split(":")[0]; //$NON-NLS-1$
|
||||
ElementParameterType repositoryTypeParam = parametersMap.get(name + ":" //$NON-NLS-1$
|
||||
+ getRepositoryTypeName());
|
||||
if (repositoryTypeParam != null && IN_REPOSITORY.equals(repositoryTypeParam.getValue())) {
|
||||
ElementParameterType repositoryTypeValueParam = parametersMap.get(name + ":" //$NON-NLS-1$
|
||||
+ getRepositoryTypeValueName());
|
||||
if (repositoryTypeValueParam != null) {
|
||||
String repositoryIdOrValue = repositoryTypeValueParam.getValue();
|
||||
if (StringUtils.isNotEmpty(repositoryIdOrValue)) {
|
||||
Relation addedRelation = new Relation();
|
||||
addedRelation.setId(repositoryIdOrValue);
|
||||
addedRelation.setType(getRepositoryRelationType());
|
||||
addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
|
||||
relationSet.add(addedRelation);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return relationSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Something like PROPERTY_TYPE
|
||||
*/
|
||||
protected abstract String getRepositoryTypeName();
|
||||
|
||||
/**
|
||||
* Something like REPOSITORY_PROPERTY_TYPE
|
||||
*/
|
||||
protected abstract String getRepositoryTypeValueName();
|
||||
|
||||
/**
|
||||
* get the type of relation type
|
||||
*/
|
||||
protected abstract String getRepositoryRelationType();
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.core.service;
|
||||
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.process.IConnection;
|
||||
|
||||
/**
|
||||
* created by talend on Dec 17, 2014 Detailled comment
|
||||
*
|
||||
*/
|
||||
public interface IDQComponentService extends IService {
|
||||
|
||||
/**
|
||||
*
|
||||
* Handle component chaged
|
||||
*
|
||||
* @param oldConnection
|
||||
* @param newMetadataTable
|
||||
*/
|
||||
void externalComponentChange(IConnection oldConnection, IMetadataTable newMetadataTable);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.core.service;
|
||||
|
||||
import org.talend.core.IProviderService;
|
||||
import org.talend.core.model.process.INode;
|
||||
|
||||
/**
|
||||
* created by ldong on Jan 13, 2015 Detailled comment
|
||||
*
|
||||
*/
|
||||
public interface IDbProviderService extends IProviderService {
|
||||
|
||||
public boolean isRedShiftNode(INode node);
|
||||
}
|
||||
@@ -1,286 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.ui.dialog;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.FutureTask;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.talend.core.runtime.i18n.Messages;
|
||||
|
||||
/**
|
||||
* created by cmeng on Nov 21, 2014 Detailled comment
|
||||
*
|
||||
*/
|
||||
public abstract class AProgressMonitorDialogWithCancel<T> extends ProgressMonitorDialog {
|
||||
|
||||
public static final int ENDLESS_WAIT_TIME = -1;
|
||||
|
||||
public static final int DEFAULT_WAIT_TIME = 60;
|
||||
|
||||
private ARunnableWithProgressCancel<T> runnableWithCancel;
|
||||
|
||||
private boolean isUserCancelled = false;
|
||||
|
||||
/**
|
||||
* DOC cmeng ProgressMonitorDialogWithCancel constructor comment.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public AProgressMonitorDialogWithCancel(Shell parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
abstract protected T runWithCancel(IProgressMonitor monitor) throws Throwable;
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException,
|
||||
InterruptedException {
|
||||
throw new InvocationTargetException(new Throwable("Can not use this method, you should use another run method")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void run() throws InvocationTargetException, InterruptedException {
|
||||
run(null, null, true, DEFAULT_WAIT_TIME);
|
||||
}
|
||||
|
||||
public void run(String executeMessage, String waitingFinishMessage, boolean needWaitingProgressJob)
|
||||
throws InvocationTargetException, InterruptedException {
|
||||
run(executeMessage, waitingFinishMessage, needWaitingProgressJob, DEFAULT_WAIT_TIME);
|
||||
}
|
||||
|
||||
public void run(String executeMessage, String waitingFinishMessage, boolean needWaitingProgressJob, int timeout)
|
||||
throws InvocationTargetException, InterruptedException {
|
||||
runnableWithCancel = new ARunnableWithProgressCancel<T>() {
|
||||
|
||||
@Override
|
||||
protected T runnableWithCancel(IProgressMonitor monitor) throws Throwable {
|
||||
return runWithCancel(monitor);
|
||||
}
|
||||
};
|
||||
if (executeMessage != null) {
|
||||
runnableWithCancel.setExecuteMessage(executeMessage);
|
||||
}
|
||||
if (waitingFinishMessage != null) {
|
||||
runnableWithCancel.setWaitingFinishMessage(waitingFinishMessage);
|
||||
}
|
||||
runnableWithCancel.setNeedWaitingProgressJob(needWaitingProgressJob);
|
||||
runnableWithCancel.setTimeout(timeout);
|
||||
super.run(true, true, runnableWithCancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cancelPressed() {
|
||||
isUserCancelled = true;
|
||||
if (runnableWithCancel != null) {
|
||||
runnableWithCancel.kill();
|
||||
}
|
||||
super.cancelPressed();
|
||||
}
|
||||
|
||||
public boolean isUserCanncelled() {
|
||||
return isUserCancelled;
|
||||
}
|
||||
|
||||
public T getExecuteResult() {
|
||||
if (runnableWithCancel != null) {
|
||||
return runnableWithCancel.getExecuteResult();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Throwable getExecuteException() {
|
||||
if (runnableWithCancel != null) {
|
||||
return runnableWithCancel.getExecuteException();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static abstract class ARunnableWithProgressCancel<T> implements IRunnableWithProgress {
|
||||
|
||||
protected FutureTask<T> futureTask;
|
||||
|
||||
protected Thread executeThread;
|
||||
|
||||
protected ThreadGroup threadGroup;
|
||||
|
||||
protected T executeResult;
|
||||
|
||||
protected Throwable executeException;
|
||||
|
||||
protected String executeMessage = Messages.getString("ProgressMonitorDialogWithCancel.executeMessage.default"); //$NON-NLS-1$
|
||||
|
||||
protected String waitingFinishMessage = Messages
|
||||
.getString("ProgressMonitorDialogWithCancel.waitingFinishMessage.default"); //$NON-NLS-1$
|
||||
|
||||
protected int timeout = 30;
|
||||
|
||||
volatile boolean kill = false;
|
||||
|
||||
boolean needWaitingProgressJob = true;
|
||||
|
||||
public ARunnableWithProgressCancel() {
|
||||
}
|
||||
|
||||
abstract protected T runnableWithCancel(IProgressMonitor monitor) throws Throwable;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public final void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
futureTask = new FutureTask<T>(new Callable<T>() {
|
||||
|
||||
@Override
|
||||
public T call() throws Exception {
|
||||
T result = null;
|
||||
try {
|
||||
result = runnableWithCancel(monitor);
|
||||
} catch (Throwable e) {
|
||||
executeException = e;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
int iTimeout;
|
||||
boolean canGain = true;
|
||||
if (ENDLESS_WAIT_TIME == timeout || timeout <= 0) {
|
||||
iTimeout = 1;
|
||||
canGain = false;
|
||||
monitor.beginTask(executeMessage, IProgressMonitor.UNKNOWN);
|
||||
} else {
|
||||
iTimeout = timeout * 2;
|
||||
monitor.beginTask(executeMessage, iTimeout);
|
||||
}
|
||||
threadGroup = new ThreadGroup("ARunnableWithProgressCancel"); //$NON-NLS-1$
|
||||
executeThread = new Thread(threadGroup, futureTask);
|
||||
executeThread.start();
|
||||
for (int i = 0; i < iTimeout; i = canGain ? i + 1 : i) {
|
||||
try {
|
||||
if (kill) {
|
||||
break;
|
||||
}
|
||||
monitor.worked(1);
|
||||
executeResult = futureTask.get(500, TimeUnit.MILLISECONDS);
|
||||
break;
|
||||
} catch (TimeoutException timeoutException) {
|
||||
continue;
|
||||
} catch (Throwable e) {
|
||||
executeException = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!kill && executeException == null && executeResult == null) {
|
||||
executeException = new TimeoutException(Messages.getString("ProgressMonitorDialogWithCancel.executeTimeout")); //$NON-NLS-1$
|
||||
kill();
|
||||
}
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC cmeng Comment method "addJob".
|
||||
*
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
private void addJob() {
|
||||
if (!needWaitingProgressJob) {
|
||||
return;
|
||||
}
|
||||
StackTraceElement stElement = null;
|
||||
StackTraceElement stackTraceElements[] = executeThread.getStackTrace();
|
||||
if (stackTraceElements != null && 0 < stackTraceElements.length) {
|
||||
stElement = stackTraceElements[0];
|
||||
}
|
||||
String currentMethod;
|
||||
String title = ""; //$NON-NLS-1$
|
||||
if (stElement != null) {
|
||||
currentMethod = stElement.getClassName() + "." + stElement.getMethodName(); //$NON-NLS-1$
|
||||
title = waitingFinishMessage
|
||||
+ Messages
|
||||
.getString(
|
||||
"ProgressMonitorDialogWithCancel.CheckingConnectionJob.waitingFinish", new Object[] { currentMethod }); //$NON-NLS-1$
|
||||
} else {
|
||||
title = waitingFinishMessage
|
||||
+ Messages.getString("ProgressMonitorDialogWithCancel.CheckingConnectionJob.emptyWaitingfinish"); //$NON-NLS-1$
|
||||
}
|
||||
CheckingConnectionJob<T> checkingConnectionJob = new CheckingConnectionJob<T>(title, futureTask);
|
||||
checkingConnectionJob.setUser(false);
|
||||
checkingConnectionJob.setPriority(Job.DECORATE);
|
||||
checkingConnectionJob.schedule();
|
||||
}
|
||||
|
||||
public void setNeedWaitingProgressJob(boolean need) {
|
||||
needWaitingProgressJob = need;
|
||||
}
|
||||
|
||||
public void setExecuteMessage(String exeMsg) {
|
||||
executeMessage = exeMsg;
|
||||
}
|
||||
|
||||
public void setWaitingFinishMessage(String waitingMsg) {
|
||||
waitingFinishMessage = waitingMsg;
|
||||
}
|
||||
|
||||
public T getExecuteResult() {
|
||||
return executeResult;
|
||||
}
|
||||
|
||||
public Throwable getExecuteException() {
|
||||
return executeException;
|
||||
}
|
||||
|
||||
public void setTimeout(int _timeout) {
|
||||
timeout = _timeout;
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
threadGroup.interrupt();
|
||||
kill = true;
|
||||
addJob();
|
||||
}
|
||||
}
|
||||
|
||||
private static class CheckingConnectionJob<T> extends Job {
|
||||
|
||||
protected FutureTask<T> futureTask;
|
||||
|
||||
public CheckingConnectionJob(String name, FutureTask<T> _futureTask) {
|
||||
super(name);
|
||||
this.futureTask = _futureTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
futureTask.get();
|
||||
} catch (Throwable e) {
|
||||
// nothing need to do since all will be done in ARunnableWithProgressCancel
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.core.utils;
|
||||
|
||||
import org.talend.core.model.metadata.IDatabaseConstant;
|
||||
import org.talend.core.model.process.EParameterFieldType;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.INode;
|
||||
|
||||
/**
|
||||
* created by ldong on Jan 16, 2015 Detailled comment
|
||||
*
|
||||
*/
|
||||
public class MetaDataDialogUtil {
|
||||
|
||||
public static final String PROPERTY = "PROPERTY"; //$NON-NLS-1$
|
||||
|
||||
public static boolean isRedShiftNode(INode node) {
|
||||
if (node != null) {
|
||||
IElementParameter param = node.getElementParameter(PROPERTY);
|
||||
if (param != null && param.getFieldType() == EParameterFieldType.PROPERTY_TYPE
|
||||
&& IDatabaseConstant.REDSHIFT.equals(param.getRepositoryValue())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,135 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Cxf
|
||||
Bundle-SymbolicName: org.talend.libraries.apache.cxf;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-ClassPath: lib/javax.ws.rs-api-2.0-m10.jar,
|
||||
lib/neethi-3.0.1.jar,
|
||||
lib/cxf-api-2.7.7.jar,
|
||||
lib/cxf-rt-bindings-xml-2.7.7.jar,
|
||||
lib/cxf-rt-core-2.7.7.jar,
|
||||
lib/cxf-rt-frontend-jaxrs-2.7.7.jar,
|
||||
lib/cxf-rt-transports-http-2.7.7.jar,
|
||||
lib/stax2-api-3.1.1.jar,
|
||||
lib/woodstox-core-asl-4.2.0.jar,
|
||||
.
|
||||
Export-Package: javax.ws.rs,
|
||||
javax.ws.rs.client,
|
||||
javax.ws.rs.container,
|
||||
javax.ws.rs.core,
|
||||
javax.ws.rs.ext,
|
||||
org.apache.cxf,
|
||||
org.apache.cxf.annotations,
|
||||
org.apache.cxf.attachment,
|
||||
org.apache.cxf.binding,
|
||||
org.apache.cxf.binding.xml,
|
||||
org.apache.cxf.binding.xml.interceptor,
|
||||
org.apache.cxf.binding.xml.wsdl11,
|
||||
org.apache.cxf.bindings.xformat,
|
||||
org.apache.cxf.bus,
|
||||
org.apache.cxf.bus.blueprint,
|
||||
org.apache.cxf.bus.extension,
|
||||
org.apache.cxf.bus.managers,
|
||||
org.apache.cxf.bus.osgi,
|
||||
org.apache.cxf.bus.resource,
|
||||
org.apache.cxf.bus.spring,
|
||||
org.apache.cxf.buslifecycle,
|
||||
org.apache.cxf.catalog,
|
||||
org.apache.cxf.common,
|
||||
org.apache.cxf.common.annotation,
|
||||
org.apache.cxf.common.classloader,
|
||||
org.apache.cxf.common.commands,
|
||||
org.apache.cxf.common.i18n,
|
||||
org.apache.cxf.common.injection,
|
||||
org.apache.cxf.common.jaxb,
|
||||
org.apache.cxf.common.logging,
|
||||
org.apache.cxf.common.security,
|
||||
org.apache.cxf.common.util,
|
||||
org.apache.cxf.common.xmlschema,
|
||||
org.apache.cxf.configuration,
|
||||
org.apache.cxf.configuration.blueprint,
|
||||
org.apache.cxf.configuration.jsse,
|
||||
org.apache.cxf.configuration.security,
|
||||
org.apache.cxf.configuration.spring,
|
||||
org.apache.cxf.continuations,
|
||||
org.apache.cxf.databinding,
|
||||
org.apache.cxf.databinding.source,
|
||||
org.apache.cxf.databinding.source.mime,
|
||||
org.apache.cxf.databinding.stax,
|
||||
org.apache.cxf.endpoint,
|
||||
org.apache.cxf.extension,
|
||||
org.apache.cxf.feature,
|
||||
org.apache.cxf.feature.transform,
|
||||
org.apache.cxf.feature.validation,
|
||||
org.apache.cxf.headers,
|
||||
org.apache.cxf.helpers,
|
||||
org.apache.cxf.interceptor,
|
||||
org.apache.cxf.interceptor.security,
|
||||
org.apache.cxf.interceptor.transform,
|
||||
org.apache.cxf.internal,
|
||||
org.apache.cxf.io,
|
||||
org.apache.cxf.jaxrs,
|
||||
org.apache.cxf.jaxrs.blueprint,
|
||||
org.apache.cxf.jaxrs.client,
|
||||
org.apache.cxf.jaxrs.client.spec,
|
||||
org.apache.cxf.jaxrs.ext,
|
||||
org.apache.cxf.jaxrs.ext.form,
|
||||
org.apache.cxf.jaxrs.ext.multipart,
|
||||
org.apache.cxf.jaxrs.ext.xml,
|
||||
org.apache.cxf.jaxrs.impl,
|
||||
org.apache.cxf.jaxrs.impl.tl,
|
||||
org.apache.cxf.jaxrs.interceptor,
|
||||
org.apache.cxf.jaxrs.lifecycle,
|
||||
org.apache.cxf.jaxrs.model,
|
||||
org.apache.cxf.jaxrs.model.wadl,
|
||||
org.apache.cxf.jaxrs.provider,
|
||||
org.apache.cxf.jaxrs.security,
|
||||
org.apache.cxf.jaxrs.servlet,
|
||||
org.apache.cxf.jaxrs.spring,
|
||||
org.apache.cxf.jaxrs.utils,
|
||||
org.apache.cxf.jaxrs.utils.multipart,
|
||||
org.apache.cxf.jaxrs.utils.schemas,
|
||||
org.apache.cxf.logging,
|
||||
org.apache.cxf.management,
|
||||
org.apache.cxf.management.annotation,
|
||||
org.apache.cxf.message,
|
||||
org.apache.cxf.phase,
|
||||
org.apache.cxf.policy,
|
||||
org.apache.cxf.resource,
|
||||
org.apache.cxf.security,
|
||||
org.apache.cxf.security.claims.authorization,
|
||||
org.apache.cxf.security.transport,
|
||||
org.apache.cxf.service,
|
||||
org.apache.cxf.service.factory,
|
||||
org.apache.cxf.service.invoker,
|
||||
org.apache.cxf.service.model,
|
||||
org.apache.cxf.staxutils,
|
||||
org.apache.cxf.staxutils.transform,
|
||||
org.apache.cxf.test,
|
||||
org.apache.cxf.transport,
|
||||
org.apache.cxf.transport.common.gzip,
|
||||
org.apache.cxf.transport.http,
|
||||
org.apache.cxf.transport.http.auth,
|
||||
org.apache.cxf.transport.http.blueprint,
|
||||
org.apache.cxf.transport.http.osgi,
|
||||
org.apache.cxf.transport.http.policy,
|
||||
org.apache.cxf.transport.http.policy.impl,
|
||||
org.apache.cxf.transport.http.spring,
|
||||
org.apache.cxf.transport.https,
|
||||
org.apache.cxf.transport.servlet,
|
||||
org.apache.cxf.transport.servlet.servicelist,
|
||||
org.apache.cxf.transports.http,
|
||||
org.apache.cxf.transports.http.configuration,
|
||||
org.apache.cxf.transports.http.internal,
|
||||
org.apache.cxf.version,
|
||||
org.apache.cxf.workqueue,
|
||||
org.apache.cxf.ws.addressing,
|
||||
org.apache.cxf.ws.addressing.v200403,
|
||||
org.apache.cxf.ws.addressing.v200408,
|
||||
org.apache.cxf.ws.addressing.wsdl,
|
||||
org.apache.cxf.wsdl,
|
||||
org.apache.cxf.wsdl.http,
|
||||
org.apache.cxf.wsdl11
|
||||
Require-Bundle: javax.wsdl;bundle-version="1.6.2",
|
||||
org.apache.log4j
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,453 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.ui.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.xsd.XSDSchema;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.commons.utils.data.list.UniqueStringGenerator;
|
||||
import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MappingTypeRetriever;
|
||||
import org.talend.core.model.metadata.MetadataTalendType;
|
||||
import org.talend.core.model.metadata.builder.ConvertionHelper;
|
||||
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataColumn;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.metadata.builder.connection.XMLFileNode;
|
||||
import org.talend.core.model.metadata.builder.connection.XmlFileConnection;
|
||||
import org.talend.core.model.properties.ByteArray;
|
||||
import org.talend.core.model.properties.ItemState;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.properties.XmlFileConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.update.RepositoryUpdateManager;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.cwm.helper.PackageHelper;
|
||||
import org.talend.datatools.xml.utils.ATreeNode;
|
||||
import org.talend.datatools.xml.utils.OdaException;
|
||||
import org.talend.datatools.xml.utils.XSDPopulationUtil2;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.xml.treeNode.FOXTreeNode;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.xml.util.TreeUtil;
|
||||
import orgomg.cwm.resource.record.RecordFactory;
|
||||
import orgomg.cwm.resource.record.RecordFile;
|
||||
|
||||
/**
|
||||
* created by hcyi on Aug 29, 2014 Detailled comment
|
||||
*
|
||||
* related to: class PublishMetadataRunnable
|
||||
*
|
||||
*/
|
||||
public final class XsdMetadataUtils {
|
||||
|
||||
private static final Pattern PATTERN_TOREPLACE = Pattern.compile("[^a-zA-Z0-9]"); //$NON-NLS-1$
|
||||
|
||||
private static final Pattern PATTERN_PUNCT_EXCEPT_SLASH = Pattern.compile("(?![/])\\p{Punct}");//$NON-NLS-1$
|
||||
|
||||
private static int orderId;
|
||||
|
||||
private static boolean loopElementFound;
|
||||
|
||||
public static void createMetadataFromXSD(QName parameter, File schemaFile) {
|
||||
XSDPopulationUtil2 populationUtil = new XSDPopulationUtil2();
|
||||
Collection<XmlFileConnectionItem> selectItems = new ArrayList<XmlFileConnectionItem>();
|
||||
try {
|
||||
createMetadataFromXSD(parameter, "", "", schemaFile, selectItems, schemaFile, populationUtil);//$NON-NLS-1$//$NON-NLS-2$
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void createMetadataFromXSD(QName parameter, String connectionLabel, String portTypeName, String operationName,
|
||||
File schemaFile) {
|
||||
XSDPopulationUtil2 populationUtil = new XSDPopulationUtil2();
|
||||
Collection<XmlFileConnectionItem> selectItems = new ArrayList<XmlFileConnectionItem>();
|
||||
try {
|
||||
createMetadataFromXSD(parameter, connectionLabel, portTypeName, operationName, schemaFile, selectItems, schemaFile,
|
||||
populationUtil);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC hcyi Comment method "createMetadataFromXSD".
|
||||
*
|
||||
* @param parameter
|
||||
* @param portTypeName
|
||||
* @param operationName
|
||||
* @param schemaFile
|
||||
* @param selectItems
|
||||
* @param zip
|
||||
* @param populationUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void createMetadataFromXSD(QName parameter, String portTypeName, String operationName, File schemaFile,
|
||||
Collection<XmlFileConnectionItem> selectItems, File zip, XSDPopulationUtil2 populationUtil) throws IOException {
|
||||
createMetadataFromXSD(parameter, parameter.getLocalPart(), portTypeName, operationName, schemaFile, selectItems, zip,
|
||||
populationUtil);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC wchen Comment method "createMetadataFromXSD".
|
||||
*
|
||||
* @param parameter
|
||||
* @param connectionLabel
|
||||
* @param portTypeName
|
||||
* @param operationName
|
||||
* @param schemaFile
|
||||
* @param selectItems
|
||||
* @param zip
|
||||
* @param populationUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void createMetadataFromXSD(QName parameter, String connectionLabel, String portTypeName, String operationName,
|
||||
File schemaFile, Collection<XmlFileConnectionItem> selectItems, File zip, XSDPopulationUtil2 populationUtil)
|
||||
throws IOException {
|
||||
String name = /* componentName + "_"+ */parameter.getLocalPart();
|
||||
XmlFileConnection connection = null;
|
||||
Property connectionProperty = null;
|
||||
XmlFileConnectionItem connectionItem = null;
|
||||
String oldConnectionId = null;
|
||||
String oldTableId = null;
|
||||
IMetadataTable oldMetadataTable = null;
|
||||
Map<String, String> oldTableMap = null;
|
||||
if (!selectItems.isEmpty()) {
|
||||
boolean needRewrite = false;
|
||||
for (XmlFileConnectionItem item : selectItems) {
|
||||
connectionProperty = item.getProperty();
|
||||
if (connectionProperty.getLabel().equals(name)) {
|
||||
oldConnectionId = connectionProperty.getId();
|
||||
connectionItem = item;
|
||||
connection = (XmlFileConnection) connectionItem.getConnection();
|
||||
needRewrite = true;
|
||||
Set<MetadataTable> tables = ConnectionHelper.getTables(connection);
|
||||
MetadataTable oldTable = null;
|
||||
if (tables.size() > 0) {
|
||||
oldTable = tables.toArray(new MetadataTable[0])[0];
|
||||
oldTableId = oldTable.getId();
|
||||
oldMetadataTable = ConvertionHelper.convert(oldTable);
|
||||
}
|
||||
oldTableMap = RepositoryUpdateManager.getOldTableIdAndNameMap(connectionItem, oldTable, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!needRewrite && !isNameValidInXmlFileConnection(parameter, portTypeName, operationName)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
connection = ConnectionFactory.eINSTANCE.createXmlFileConnection();
|
||||
connection.setName(ERepositoryObjectType.METADATA_FILE_XML.getKey());
|
||||
connectionItem = PropertiesFactory.eINSTANCE.createXmlFileConnectionItem();
|
||||
connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
|
||||
connectionProperty.setAuthor(((RepositoryContext) CoreRuntimePlugin.getInstance().getContext()
|
||||
.getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
|
||||
connectionProperty.setLabel(connectionLabel);
|
||||
connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
|
||||
connectionProperty.setStatusCode(""); //$NON-NLS-1$
|
||||
connectionItem.setProperty(connectionProperty);
|
||||
connectionItem.setConnection(connection);
|
||||
connection.setInputModel(false);
|
||||
ByteArray byteArray = PropertiesFactory.eINSTANCE.createByteArray();
|
||||
byteArray.setInnerContentFromFile(zip);
|
||||
connection.setFileContent(byteArray.getInnerContent());
|
||||
// don't put any XSD directly inside the xml connection but put zip file
|
||||
// Use xsd schema file name + zip file name as xml file path in case we need get the root schema of xml
|
||||
// connection after.
|
||||
String schemaFileName = schemaFile.getName();
|
||||
schemaFileName = schemaFileName.substring(0, schemaFileName.lastIndexOf(".")); //$NON-NLS-1$
|
||||
connection.setXmlFilePath(schemaFileName.concat("_").concat(zip.getName())); //$NON-NLS-1$
|
||||
try {
|
||||
String filePath = schemaFile.getPath(); // name of xsd file needed
|
||||
XSDSchema xsdSchema = populationUtil.getXSDSchema(filePath);
|
||||
List<ATreeNode> rootNodes = populationUtil.getAllRootNodes(xsdSchema);
|
||||
ATreeNode node = null;
|
||||
// try to find the root element needed from XSD file.
|
||||
// note: if there is any prefix, it will get the node with the first correct name, no matter the prefix.
|
||||
// once the we can get the correct prefix value from the wsdl, this code should be modified.
|
||||
for (ATreeNode curNode : rootNodes) {
|
||||
String curName = (String) curNode.getValue();
|
||||
if (curName.contains(":")) { //$NON-NLS-1$
|
||||
// if with prefix, don't care about it for now, just compare the name.
|
||||
if (curName.split(":")[1].equals(name)) { //$NON-NLS-1$
|
||||
node = curNode;
|
||||
break;
|
||||
}
|
||||
} else if (curName.equals(name)) {
|
||||
node = curNode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
node = populationUtil.getSchemaTree(xsdSchema, node);
|
||||
orderId = 1;
|
||||
loopElementFound = false;
|
||||
if (ConnectionHelper.getTables(connection).isEmpty()) {
|
||||
MetadataTable table = ConnectionFactory.eINSTANCE.createMetadataTable();
|
||||
if (oldTableId != null) {
|
||||
table.setId(oldTableId);
|
||||
} else {
|
||||
table.setId(ProxyRepositoryFactory.getInstance().getNextId());
|
||||
}
|
||||
RecordFile record = (RecordFile) ConnectionHelper.getPackage(connection.getName(), connection, RecordFile.class);
|
||||
if (record != null) { // hywang
|
||||
PackageHelper.addMetadataTable(table, record);
|
||||
} else {
|
||||
RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
|
||||
newrecord.setName(connection.getName());
|
||||
ConnectionHelper.addPackage(newrecord, connection);
|
||||
PackageHelper.addMetadataTable(table, newrecord);
|
||||
}
|
||||
}
|
||||
boolean haveElement = false;
|
||||
for (Object curNode : node.getChildren()) {
|
||||
if (((ATreeNode) curNode).getType() == ATreeNode.ELEMENT_TYPE) {
|
||||
haveElement = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<FOXTreeNode> foxTreeNodes = TreeUtil.getFoxTreeNodesByRootNode(xsdSchema, node, true);
|
||||
if (foxTreeNodes.size() > 0 && false) {
|
||||
FOXTreeNode foxTreeNode = foxTreeNodes.get(0);
|
||||
EList root = connection.getRoot();
|
||||
if (root != null) {
|
||||
XMLFileNode xmlFileNode = ConnectionFactory.eINSTANCE.createXMLFileNode();
|
||||
String currentPath = "/" + foxTreeNode.getLabel();
|
||||
xmlFileNode.setXMLPath(currentPath);
|
||||
xmlFileNode.setRelatedColumn(foxTreeNode.getColumnLabel());
|
||||
xmlFileNode.setAttribute(foxTreeNode.isMain() ? "main" : "branch");
|
||||
xmlFileNode.setDefaultValue(foxTreeNode.getDefaultValue());
|
||||
xmlFileNode.setType(foxTreeNode.getDataType());
|
||||
XMLFileNode originalXmlNode = null;
|
||||
if (root.size() > 0) {
|
||||
originalXmlNode = (XMLFileNode) root.get(0);
|
||||
}
|
||||
root.clear();
|
||||
root.add(xmlFileNode);
|
||||
}
|
||||
}
|
||||
fillRootInfo(connection, node, "", !haveElement); //$NON-NLS-1$
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
} catch (URISyntaxException e1) {
|
||||
ExceptionHandler.process(e1);
|
||||
} catch (OdaException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
// save
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
connectionProperty.setId(factory.getNextId());
|
||||
try {
|
||||
// http://jira.talendforge.org/browse/TESB-3655 Remove possible
|
||||
// schema prefix
|
||||
String folderPath = getImportedXmlSchemaPath(parameter.getNamespaceURI(), portTypeName, operationName);
|
||||
IPath path = new Path(folderPath);
|
||||
factory.create(connectionItem, path, true); // consider this as migration will overwrite the old metadata if
|
||||
// existing in the same path
|
||||
if (oldConnectionId != null) {
|
||||
connectionItem.getProperty().setId(oldConnectionId);
|
||||
factory.save(connectionItem);
|
||||
}
|
||||
propagateSchemaChange(oldMetadataTable, oldTableMap, connection, connectionItem);
|
||||
ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
} catch (URISyntaxException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void propagateSchemaChange(final IMetadataTable oldMetaTable, final Map<String, String> oldTableMap,
|
||||
final XmlFileConnection connection, final XmlFileConnectionItem connectionItem) {
|
||||
if (oldMetaTable == null) {
|
||||
return;
|
||||
}
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
MetadataTable newTable = ConnectionHelper.getTables(connection).toArray(new MetadataTable[0])[0];
|
||||
RepositoryUpdateManager.updateSingleSchema(connectionItem, newTable, oldMetaTable, oldTableMap);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void fillRootInfo(XmlFileConnection connection, ATreeNode node, String path, boolean inLoop) {
|
||||
XMLFileNode xmlNode = ConnectionFactory.eINSTANCE.createXMLFileNode();
|
||||
xmlNode.setXMLPath(path + '/' + node.getValue());
|
||||
xmlNode.setOrder(orderId);
|
||||
orderId++;
|
||||
MappingTypeRetriever retriever;
|
||||
String nameWithoutPrefixForColumn;
|
||||
String curName = (String) node.getValue();
|
||||
if (curName.contains(":")) { //$NON-NLS-1$
|
||||
nameWithoutPrefixForColumn = curName.split(":")[1]; //$NON-NLS-1$
|
||||
} else {
|
||||
nameWithoutPrefixForColumn = curName;
|
||||
}
|
||||
retriever = MetadataTalendType.getMappingTypeRetriever("xsd_id"); //$NON-NLS-1$
|
||||
xmlNode.setAttribute("attri"); //$NON-NLS-1$
|
||||
xmlNode.setType(retriever.getDefaultSelectedTalendType(node.getDataType()));
|
||||
MetadataColumn column = null;
|
||||
MetadataTable metadataTable = ConnectionHelper.getTables(connection).toArray(new MetadataTable[0])[0];
|
||||
switch (node.getType()) {
|
||||
case ATreeNode.ATTRIBUTE_TYPE:
|
||||
// fix for TDI-20390 and TDI-20671 ,XMLPath for attribute should only store attribute name but not full
|
||||
// xpath
|
||||
xmlNode.setXMLPath("" + node.getValue()); //$NON-NLS-1$
|
||||
column = ConnectionFactory.eINSTANCE.createMetadataColumn();
|
||||
column.setTalendType(xmlNode.getType());
|
||||
String uniqueName = extractColumnName(nameWithoutPrefixForColumn, metadataTable.getColumns());
|
||||
column.setLabel(uniqueName);
|
||||
xmlNode.setRelatedColumn(uniqueName);
|
||||
metadataTable.getColumns().add(column);
|
||||
break;
|
||||
case ATreeNode.ELEMENT_TYPE:
|
||||
boolean haveElementOrAttributes = false;
|
||||
for (Object curNode : node.getChildren()) {
|
||||
if (((ATreeNode) curNode).getType() != ATreeNode.NAMESPACE_TYPE) {
|
||||
haveElementOrAttributes = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!haveElementOrAttributes) {
|
||||
xmlNode.setAttribute("branch"); //$NON-NLS-1$
|
||||
column = ConnectionFactory.eINSTANCE.createMetadataColumn();
|
||||
column.setTalendType(xmlNode.getType());
|
||||
uniqueName = extractColumnName(nameWithoutPrefixForColumn, metadataTable.getColumns());
|
||||
column.setLabel(uniqueName);
|
||||
xmlNode.setRelatedColumn(uniqueName);
|
||||
metadataTable.getColumns().add(column);
|
||||
} else {
|
||||
xmlNode.setAttribute("main"); //$NON-NLS-1$
|
||||
}
|
||||
break;
|
||||
case ATreeNode.NAMESPACE_TYPE:
|
||||
xmlNode.setAttribute("ns"); //$NON-NLS-1$
|
||||
// specific for namespace... no path set, there is only the prefix value.
|
||||
// this value is saved now in node.getDataType()
|
||||
xmlNode.setXMLPath(node.getDataType());
|
||||
xmlNode.setDefaultValue((String) node.getValue());
|
||||
break;
|
||||
case ATreeNode.OTHER_TYPE:
|
||||
break;
|
||||
}
|
||||
boolean subElementsInLoop = inLoop;
|
||||
// will try to get the first element (branch or main), and set it as loop.
|
||||
if ((!loopElementFound && path.split("/").length == 2 && node.getType() == ATreeNode.ELEMENT_TYPE) || subElementsInLoop) { //$NON-NLS-1$
|
||||
connection.getLoop().add(xmlNode);
|
||||
loopElementFound = true;
|
||||
subElementsInLoop = true;
|
||||
} else {
|
||||
connection.getRoot().add(xmlNode);
|
||||
}
|
||||
if (node.getChildren().length > 0) {
|
||||
for (Object curNode : node.getChildren()) {
|
||||
if (!path.contains("/" + (String) node.getValue() + "/")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
fillRootInfo(connection, (ATreeNode) curNode, path + '/' + node.getValue(), subElementsInLoop);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String extractColumnName(String currentExpr, List<MetadataColumn> fullSchemaTargetList) {
|
||||
String columnName = currentExpr.startsWith("@") ? currentExpr.substring(1) : currentExpr; //$NON-NLS-1$
|
||||
columnName = PATTERN_TOREPLACE.matcher(columnName).replaceAll("_"); //$NON-NLS-1$
|
||||
UniqueStringGenerator<MetadataColumn> uniqueStringGenerator = new UniqueStringGenerator<MetadataColumn>(columnName,
|
||||
fullSchemaTargetList) {
|
||||
|
||||
@Override
|
||||
protected String getBeanString(MetadataColumn bean) {
|
||||
return bean.getLabel();
|
||||
}
|
||||
};
|
||||
columnName = uniqueStringGenerator.getUniqueString();
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public static boolean isNameValidInXmlFileConnection(QName parameter, String portTypeName, String operationName) {
|
||||
try {
|
||||
XmlFileConnectionItem item = PropertiesFactory.eINSTANCE.createXmlFileConnectionItem();
|
||||
XmlFileConnection connection = ConnectionFactory.eINSTANCE.createXmlFileConnection();
|
||||
Property property = PropertiesFactory.eINSTANCE.createProperty();
|
||||
property.setId(ProxyRepositoryFactory.getInstance().getNextId());
|
||||
property.setLabel(parameter.getLocalPart());
|
||||
property.setVersion(VersionUtils.DEFAULT_VERSION);
|
||||
//
|
||||
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
|
||||
String folderPath = getImportedXmlSchemaPath(parameter.getNamespaceURI(), portTypeName, operationName);
|
||||
itemState.setPath(folderPath);
|
||||
item.setConnection(connection);
|
||||
item.setProperty(property);
|
||||
item.setState(itemState);
|
||||
return ProxyRepositoryFactory.getInstance().isNameAvailable(property.getItem(), parameter.getLocalPart());
|
||||
} catch (PersistenceException e) {
|
||||
return false;
|
||||
} catch (URISyntaxException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static String replaceAllLimited(String input) {
|
||||
if (input == null) {
|
||||
return input;
|
||||
}
|
||||
return PATTERN_PUNCT_EXCEPT_SLASH.matcher(input).replaceAll("-");//$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static String getImportedXmlSchemaPath(String namespace, String portType, String operation) throws URISyntaxException {
|
||||
if (namespace == null || portType == null || operation == null) {
|
||||
throw new URISyntaxException(namespace + " " + portType + " " + operation,//$NON-NLS-1$//$NON-NLS-2$
|
||||
"The arguments can't be empty, please check");//$NON-NLS-1$
|
||||
}
|
||||
StringBuilder builder = new StringBuilder(replaceAllLimited(new URI(namespace).getRawSchemeSpecificPart()));
|
||||
if (portType.equals("") && operation.equals("")) {//$NON-NLS-1$//$NON-NLS-2$
|
||||
return builder.toString();
|
||||
}
|
||||
if (builder.length() > 0) {
|
||||
while (builder.charAt(0) == '/') {
|
||||
builder.deleteCharAt(0);
|
||||
}
|
||||
if (builder.charAt(builder.length() - 1) != '/') {
|
||||
builder.append('/');
|
||||
}
|
||||
}
|
||||
builder.append(portType).append('/').append(operation);
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.core.model.metadata;
|
||||
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
|
||||
import org.talend.utils.sql.metadata.constants.MetaDataConstants;
|
||||
import orgomg.cwm.objectmodel.core.Package;
|
||||
import orgomg.cwm.resource.relational.Catalog;
|
||||
|
||||
/**
|
||||
* created by xqliu on 2014-10-29 Detailled comment
|
||||
*
|
||||
*/
|
||||
public class NetezzaConnectionFiller extends DBConnectionFillerImpl {
|
||||
|
||||
private static Logger log = Logger.getLogger(NetezzaConnectionFiller.class);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.core.model.metadata.DBConnectionFillerImpl#getDatabaseName(org.talend.core.model.metadata.builder.
|
||||
* connection.DatabaseConnection)
|
||||
*/
|
||||
@Override
|
||||
protected String getDatabaseName(DatabaseConnection dbConn) {
|
||||
boolean isJdbc = MetadataFillFactory.isJdbcNetezza(dbConn.getDatabaseType(), dbConn.getDriverClass());
|
||||
return isJdbc ? getDatabaseNameFromUrl(dbConn.getURL()) : super.getDatabaseName(dbConn);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the database name from the url.
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
private String getDatabaseNameFromUrl(String url) {
|
||||
if (StringUtils.isBlank(url)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
int lastIndexOf1 = StringUtils.lastIndexOf(url, "/"); //$NON-NLS-1$
|
||||
if (lastIndexOf1 < 0 || lastIndexOf1 > url.length() - 1) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
int lastIndexOf2 = StringUtils.lastIndexOf(url, "?"); //$NON-NLS-1$
|
||||
if (lastIndexOf2 < 0) {
|
||||
return StringUtils.substring(url, lastIndexOf1 + 1);
|
||||
} else {
|
||||
if (lastIndexOf2 < lastIndexOf1) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return StringUtils.substring(url, lastIndexOf1 + 1, lastIndexOf2);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.model.metadata.DBConnectionFillerImpl#getSchemaName(java.sql.ResultSet,
|
||||
* java.sql.DatabaseMetaData, orgomg.cwm.resource.relational.Catalog)
|
||||
*/
|
||||
@Override
|
||||
protected String getSchemaName(ResultSet schemaRs, DatabaseMetaData dbJDBCMetadata, Catalog catalog) {
|
||||
String schemaName = null;
|
||||
String catalogName = null;
|
||||
try {
|
||||
schemaName = schemaRs.getString(MetaDataConstants.TABLE_SCHEM.name());
|
||||
catalogName = schemaRs.getString(MetaDataConstants.TABLE_CATALOG.name());
|
||||
|
||||
if (catalogName != null && !StringUtils.equalsIgnoreCase(catalogName, catalog.getName())) {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn(e);
|
||||
}
|
||||
return schemaName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Package> fillSchemas(Connection dbConn, DatabaseMetaData dbJDBCMetadata, IMetadataConnection metaConnection,
|
||||
List<String> schemaFilter) {
|
||||
return new ArrayList<Package>();
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.viewer.handler.demo;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.repository.items.importexport.handlers.imports.IImportResourcesHandler;
|
||||
import org.talend.repository.items.importexport.handlers.model.ImportItem;
|
||||
import org.talend.repository.items.importexport.manager.ResourcesManager;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
*/
|
||||
public class DemoImportResourcesHandler implements IImportResourcesHandler {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.repository.items.importexport.handlers.imports.IImportResourcesHandler#prePopulate(org.eclipse.core
|
||||
* .runtime.IProgressMonitor, org.talend.repository.items.importexport.manager.ResourcesManager)
|
||||
*/
|
||||
@Override
|
||||
public void prePopulate(IProgressMonitor monitor, ResourcesManager resManager) {
|
||||
//
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.repository.items.importexport.handlers.imports.IImportResourcesHandler#postPopulate(org.eclipse.core
|
||||
* .runtime.IProgressMonitor, org.talend.repository.items.importexport.manager.ResourcesManager,
|
||||
* org.talend.repository.items.importexport.handlers.model.ImportItem[])
|
||||
*/
|
||||
@Override
|
||||
public void postPopulate(IProgressMonitor monitor, ResourcesManager resManager, ImportItem[] populatedItemRecords) {
|
||||
//
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.repository.items.importexport.handlers.imports.IImportResourcesHandler#preImport(org.eclipse.core.
|
||||
* runtime.IProgressMonitor, org.talend.repository.items.importexport.manager.ResourcesManager,
|
||||
* org.talend.repository.items.importexport.handlers.model.ImportItem[],
|
||||
* org.talend.repository.items.importexport.handlers.model.ImportItem[])
|
||||
*/
|
||||
@Override
|
||||
public void preImport(IProgressMonitor monitor, ResourcesManager resManager, ImportItem[] checkedItemRecords,
|
||||
ImportItem[] allImportItemRecords) {
|
||||
if (resManager.getPaths().isEmpty()) {
|
||||
ExceptionHandler.log("There is no resource to import."); //$NON-NLS-1$
|
||||
} else {
|
||||
ExceptionHandler.log("The items have been prepared to do import."); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.repository.items.importexport.handlers.imports.IImportResourcesHandler#postImport(org.eclipse.core
|
||||
* .runtime.IProgressMonitor, org.talend.repository.items.importexport.manager.ResourcesManager,
|
||||
* org.talend.repository.items.importexport.handlers.model.ImportItem[])
|
||||
*/
|
||||
@Override
|
||||
public void postImport(IProgressMonitor monitor, ResourcesManager resManager, ImportItem[] importedItemRecords) {
|
||||
ExceptionHandler.log("The items have been imported successfully."); //$NON-NLS-1$
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 9.9 KiB |
|
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 318 B |
|
Before Width: | Height: | Size: 342 B After Width: | Height: | Size: 342 B |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 80 B After Width: | Height: | Size: 80 B |
|
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |
|
Before Width: | Height: | Size: 149 B After Width: | Height: | Size: 149 B |
|
Before Width: | Height: | Size: 93 B After Width: | Height: | Size: 93 B |
|
Before Width: | Height: | Size: 606 B After Width: | Height: | Size: 606 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 595 B After Width: | Height: | Size: 595 B |
|
Before Width: | Height: | Size: 594 B After Width: | Height: | Size: 594 B |
|
Before Width: | Height: | Size: 350 B After Width: | Height: | Size: 350 B |
|
Before Width: | Height: | Size: 753 B After Width: | Height: | Size: 753 B |
|
Before Width: | Height: | Size: 58 B After Width: | Height: | Size: 58 B |
|
Before Width: | Height: | Size: 326 B After Width: | Height: | Size: 326 B |
|
Before Width: | Height: | Size: 952 B After Width: | Height: | Size: 952 B |
|
Before Width: | Height: | Size: 55 B After Width: | Height: | Size: 55 B |
|
Before Width: | Height: | Size: 626 B After Width: | Height: | Size: 626 B |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 54 B After Width: | Height: | Size: 54 B |
|
Before Width: | Height: | Size: 605 B After Width: | Height: | Size: 605 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 353 B After Width: | Height: | Size: 353 B |
|
Before Width: | Height: | Size: 633 B After Width: | Height: | Size: 633 B |
|
Before Width: | Height: | Size: 95 B After Width: | Height: | Size: 95 B |
|
Before Width: | Height: | Size: 556 B After Width: | Height: | Size: 556 B |