Compare commits

..

1 Commits

Author SHA1 Message Date
Sébastien Gandon
0292b0364a Merge release/5.4.2/tis_shared and release/5.4.2/tos for release/5.4.2. 2014-06-22 14:17:21 +02:00
10499 changed files with 6384 additions and 168194 deletions

5
.gitignore vendored
View File

@@ -1,5 +0,0 @@
*.class
bin/
target/
class/
classes/

View File

@@ -1,47 +0,0 @@
# Talend Common Repository
http://www.talend.com
![alt text](http://www.talend.com/sites/default/files/logo-talend.jpg "Talend")
> 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

View File

@@ -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>

View File

@@ -1,6 +0,0 @@
source.. = src/main/java/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin_en.properties,\
plugin_fr.properties

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -1 +0,0 @@
talend.version=5.5.2

View File

@@ -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);
}
}

View File

@@ -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;
}
}

View File

@@ -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";
}

View File

@@ -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();
}

View File

@@ -1,700 +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.utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.PatternCompiler;
import org.apache.oro.text.regex.PatternMatcher;
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Perl5Matcher;
import org.apache.oro.text.regex.Perl5Substitution;
import org.apache.oro.text.regex.Substitution;
import org.apache.oro.text.regex.Util;
import org.eclipse.emf.common.util.EList;
import org.eclipse.swt.graphics.Point;
import org.talend.core.model.context.UpdateContextVariablesHelper;
import org.talend.core.model.process.EParameterFieldType;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.utils.TalendQuoteUtils;
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ElementValueType;
/**
* cli class global comment. Detailled comment
*/
public final class ParameterValueUtil {
private ParameterValueUtil() {
}
@SuppressWarnings("unchecked")
public static void renameValues(final IElementParameter param, final String oldName, final String newName) {
if (param == null || oldName == null || newName == null) {
return;
}
// boolean flag = true;
// if (param.getFieldType() == EParameterFieldType.MEMO_SQL) {
// flag = false;
// }
if (param.getValue() instanceof String) { // for TEXT / MEMO etc..
String value = (String) param.getValue();
if (value.contains(oldName)) {
// param.setValue(value.replaceAll(oldName, newName));
// String newValue = renameValues(value, oldName, newName, flag);
String newValue = splitQueryData(oldName, newName, value);
if (!value.equals(newValue)) {
param.setValue(newValue);
}
}
} else if (param.getValue() instanceof List) { // for TABLE
List<Map<String, Object>> tableValues = (List<Map<String, Object>>) param.getValue();
for (Map<String, Object> line : tableValues) {
for (String key : line.keySet()) {
Object cellValue = line.get(key);
if (cellValue instanceof String) { // cell is text so
// rename data if
// needed
String value = (String) cellValue;
if (value.contains(oldName)) {
// line.put(key, value.replaceAll(oldName,
// newName));
// String newValue = renameValues(value, oldName, newName, flag);
String newValue = splitQueryData(oldName, newName, value);
if (!value.equals(newValue)) {
line.put(key, newValue);
}
}
}
}
}
}
}
public static String renameValues(final String value, final String oldName, final String newName, boolean flag) {
if (value == null || oldName == null || newName == null) {
return value; // keep original value
}
PatternCompiler compiler = new Perl5Compiler();
Perl5Matcher matcher = new Perl5Matcher();
matcher.setMultiline(true);
Perl5Substitution substitution = new Perl5Substitution(newName + "$2", Perl5Substitution.INTERPOLATE_ALL); //$NON-NLS-1$
Pattern pattern;
try {
pattern = compiler.compile(getQuotePattern(oldName));
} catch (MalformedPatternException e) {
return value; // keep original value
}
if (matcher.contains(value, pattern)) {
// replace
String returnValue = "";
if (value.contains(TalendQuoteUtils.getQuoteChar()) && !flag) {
// returnValue = splitQueryData(matcher, pattern, substitution, value, Util.SUBSTITUTE_ALL);
returnValue = splitQueryData(oldName, newName, value);
} else {
returnValue = Util.substitute(matcher, pattern, substitution, value, Util.SUBSTITUTE_ALL);
}
return returnValue;
}
return value; // keep original value
}
// function before TDI-29092 modify,this function seems only rename variables in context,I put this funciton back
// incase any problem with the new function and we can refer the old one to check the problem.
public static String splitQueryData(PatternMatcher matcher, Pattern pattern, Substitution sub, String value, int numSubs) {
String[] split = value.split("\"");
int i = 0;
String replace = "";
for (String s : split) {
if (i % 2 == 0) {
replace = s;
if (i != 0) {
if (matcher.contains(value, pattern)) {
replace = split[i].toString();
split[i] = Util.substitute(matcher, pattern, sub, replace, numSubs);
}
}
}
i++;
}
String returnValue = "";
for (int t = 1; t < split.length; t++) {
if (t % 2 == 0) {
returnValue += split[t];
} else {
returnValue += "\"" + split[t] + "\"";
}
}
return returnValue;
}
// for bug 12594 split "; for bug 29092(it has JUnits)
public static String splitQueryData(String oldName, String newName, String value) {
// example:"drop table "+context.oracle_schema+".\"TDI_26803\""
// >>>>>>>>_*_(const)__ _____*_(varible)_______ __*_(const)___
/**
* <b>NOTE</b>: This [inputString] variable only used to debug, should not use it in product
*/
inputString = value;
final int length = value.length();
// quotaStrings which stores the start and end point for all const strings in the value
LinkedHashMap<Integer, Integer> quotaStrings = new LinkedHashMap<Integer, Integer>();
// List<Point> functionNameAreas = new ArrayList<Point>();
List<FunctionInfo> functions = new ArrayList<FunctionInfo>();
// get and store all start and end point of const strings
int start = -1;
int end = -2;
char ch;
for (int i = 0; i < length; i++) {
ch = value.charAt(i);
if (ch == '\"') {
// in case of cases :
// case 1 : [ "select * from " + context.table + " where value = \"context.table\"" ]
// case 2 : [ "select * from " + context.table + " where value = \"\\" + context.table +
// "\\context.table\"" ]
if (isEscapeSequence(value, i)) {
continue;
}
// [0 <= start] >> in case the first const String position compute error
if (0 <= start && end < start) {
end = i;
quotaStrings.put(start, end);
} else {
start = i;
}
}
}
{
// in case the value has not complete quota
// exapmle > "select a,context.b from " + context.b + "where value = context.b
// **but** maybe more impossible truth is that
// they write this(context.b) just want to use it as a varible...
// so maybe should not set the string behind the quota as a const by default..
// ---*--- the following code is set the string behind the quota as a const
// if (0 <= start && end < start) {
// end = length - 1;
// quotaStrings.put(start, end);
// }
}
// find the varible string, do replace, then concat them
StringBuffer strBuffer = new StringBuffer();
String subString = null;
int vStart = 0;
int vEnd = 0;
int methodMaxIndex = -1;
vStart = 0;
vEnd = 0;
start = 0;
end = 0;
for (Entry<Integer, Integer> entry : quotaStrings.entrySet()) {
start = entry.getKey();
end = entry.getValue() + 1;
vEnd = start;
if (vStart != start) {
subString = value.substring(vStart, vEnd);
calcMethodArea(subString, value, vStart, functions);
}
vStart = end;
}
vStart = 0;
vEnd = 0;
start = 0;
end = 0;
for (Entry<Integer, Integer> entry : quotaStrings.entrySet()) {
start = entry.getKey();
end = entry.getValue() + 1;
vEnd = start;
if (vStart == start) {
// const string follow with const string, maybe won't happen...
// get the const string
subString = value.substring(start, end);
if (start < methodMaxIndex) {
subString = subString.replaceAll(oldName, newName);
}
} else {
// get the varible string, do replace, then append it
subString = value.substring(vStart, vEnd);
// calcMaxIndex = calcMethodArea(subString, value, vStart, functions, methodMaxIndex);
if (methodMaxIndex < start) {
methodMaxIndex = FunctionInfo.getMaxIndexForCurrentParentFunction(start, functions);
}
String replacedString = doVaribleReplace(oldName, newName, value, functions, vStart, vEnd);
strBuffer.append(replacedString);
// get the const string
// deal with: context.getProperty("test") + "test"
subString = value.substring(start, end);
if (start < methodMaxIndex) {
FunctionInfo function = FunctionInfo.getParentFunctionFromList(start, end, functions);
Point funcNameArea = function.getNameArea();
String functionName = value.substring(funcNameArea.x, funcNameArea.y);
if (functionName.matches("^globalMap\\..+")) { //$NON-NLS-1$
subString = subString.replaceAll(oldName, newName);
} else {
if (subString.equals("\"" + oldName + "\"")) { //$NON-NLS-1$ //$NON-NLS-2$
subString = "\"" + newName + "\""; //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
}
// append the const string
strBuffer.append(subString);
// update the varible string start point
vStart = end;
}
// in case the last string of the value is a varible string
// then get it, and do replace, finally append it.
if (vStart < length) {
vEnd = length;
String replacedString = doVaribleReplace(oldName, newName, value, functions, vStart, vEnd);
strBuffer.append(replacedString);
}
return strBuffer.toString();
}
/**
* <b>NOTE</b>: This variable only used to debug, should not use it in product
*/
private static String inputString = ""; //$NON-NLS-1$
private static class FunctionInfo {
private Point nameArea;
private Point paramArea;
private List<FunctionInfo> subFunctions = new ArrayList<FunctionInfo>();
public FunctionInfo(Point _nameArea) {
nameArea = _nameArea;
}
public Point getNameArea() {
return this.nameArea;
}
public void setParamArea(Point paramArea) {
this.paramArea = paramArea;
}
public Point getParamArea() {
return this.paramArea;
}
public int getFuncAreaMinIndex() {
return nameArea.x;
}
public int getFuncAreaMaxIndex() {
return paramArea.y;
}
public FunctionInfo getParentFunction(int x, int y) {
FunctionInfo parentFunction = null;
for (FunctionInfo funcInfo : subFunctions) {
int paramX = funcInfo.paramArea.x;
int paramY = funcInfo.paramArea.y;
if (paramX <= x && y <= paramY) {
if (!funcInfo.subFunctions.isEmpty()) {
FunctionInfo retFuncInfo = funcInfo.getParentFunction(x, y);
if (retFuncInfo != null) {
return retFuncInfo;
}
}
return funcInfo;
}
}
int paramX = this.paramArea.x;
int paramY = this.paramArea.y;
if (paramX <= x && y <= paramY) {
parentFunction = this;
}
return parentFunction;
}
public void addSubFunction(FunctionInfo subFunc) {
this.subFunctions.add(subFunc);
}
public List<FunctionInfo> getSubFunctions() {
return this.subFunctions;
}
public static void addFunctionToList(FunctionInfo funcInfo, List<FunctionInfo> functionList) {
if (functionList != null) {
for (FunctionInfo iFuncInfo : functionList) {
FunctionInfo parentFuncInfo = iFuncInfo.getParentFunction(funcInfo.getFuncAreaMinIndex(),
funcInfo.getFuncAreaMaxIndex());
if (parentFuncInfo != null) {
parentFuncInfo.addSubFunction(funcInfo);
return;
}
}
// if can not found, add it to the functionList dirrectly
functionList.add(funcInfo);
}
}
public static FunctionInfo getParentFunctionFromList(int x, int y, List<FunctionInfo> functionList) {
if (functionList != null) {
for (FunctionInfo funcInfo : functionList) {
FunctionInfo parentFunction = funcInfo.getParentFunction(x, y);
if (parentFunction != null) {
return parentFunction;
}
}
}
return null;
}
public static int getMaxIndexForCurrentParentFunction(int index, List<FunctionInfo> functionList) {
int maxIndex = -1;
if (functionList != null) {
for (FunctionInfo funcInfo : functionList) {
Point paramArea = funcInfo.getParamArea();
if (paramArea.x <= index && index <= paramArea.y) {
return paramArea.y;
}
}
}
return maxIndex;
}
public static List<FunctionInfo> getFunctionsInSpecifiedAreaFromList(int x, int y, List<FunctionInfo> functionList) {
List<FunctionInfo> findedList = new ArrayList<FunctionInfo>();
for (FunctionInfo funcInfo : functionList) {
Point nameArea = funcInfo.getNameArea();
if (y < nameArea.y) {
break;
}
if (x <= nameArea.x && nameArea.y <= y) {
findedList.add(funcInfo);
List<FunctionInfo> subFuncs = funcInfo.getSubFunctions();
if (subFuncs != null && !subFuncs.isEmpty()) {
List<FunctionInfo> findedListInSubFuncs = getFunctionsInSpecifiedAreaFromList(x, y, subFuncs);
if (findedListInSubFuncs != null && !findedListInSubFuncs.isEmpty()) {
findedList.addAll(findedListInSubFuncs);
}
}
}
}
return findedList;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
if (getFuncAreaMaxIndex() < getFuncAreaMinIndex()) {
return "not available"; //$NON-NLS-1$
}
return inputString.substring(getFuncAreaMinIndex(), getFuncAreaMaxIndex() + 1);
}
}
/**
* DOC cmeng Comment method "doVaribleReplace".
*
* @param oldName
* @param newName
* @param value
* @param functionNameAreas
* @param vStart
* @param vEnd
*/
private static String doVaribleReplace(String oldName, String newName, String value, List<FunctionInfo> functions,
int vStart, int vEnd) {
if (value.trim().isEmpty()) {
return value;
}
StringBuffer replacedString = new StringBuffer();
int replaceableStart = vStart;
int replaceableEnd = vEnd;
List<FunctionInfo> replaceableFunctions = FunctionInfo.getFunctionsInSpecifiedAreaFromList(vStart, vEnd, functions);
for (FunctionInfo funcInfo : replaceableFunctions) {
Point functionNameArea = funcInfo.getNameArea();
if (vEnd <= functionNameArea.x) {
break;
}
if (functionNameArea.y <= vStart) {
continue;
}
if (replaceableStart < functionNameArea.x) {
replaceableEnd = functionNameArea.x;
String replaceableString = value.substring(replaceableStart, replaceableEnd);
replacedString.append(doReplace(oldName, newName, replaceableString));
replacedString.append(doReplace(oldName, newName, value.substring(functionNameArea.x, functionNameArea.y)));
} else {
replacedString.append(doReplace(oldName, newName, value.substring(functionNameArea.x, functionNameArea.y)));
}
replaceableStart = functionNameArea.y;
}
if (replaceableStart < vEnd) {
String replaceableString = value.substring(replaceableStart, vEnd);
replacedString.append(doReplace(oldName, newName, replaceableString));
}
return replacedString.toString();
}
private static String doReplace(String oldName, String newName, String value) {
if (value.trim().isEmpty()) {
return value;
}
String vOldName = oldName.replaceAll("\\.", "\\\\."); //$NON-NLS-1$ //$NON-NLS-2$
// ((\b\w+\s*\.\s*)+schema(\s*\.\s*\w+)*)|((\b\w+\s*\.\s*)*schema(\s*\.\s*\w+)+)
String regex = "((\\b\\w+\\s*\\.\\s*)+" + vOldName + "\\b)|(\\b" + vOldName + "\\s*\\()"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// obtain all varibles
String[] split = value.split(regex);
Map<String, String> replacedStrings = new HashMap<String, String>();
StringBuffer returnValue = new StringBuffer();
// replace the variables & store both value of old and new
for (String s : split) {
if (s.contains(oldName)) {
replacedStrings.put(s, s.replaceAll("\\b" + oldName + "\\b", newName)); //$NON-NLS-1$ //$NON-NLS-2$
} else {
replacedStrings.put(s, s);
}
}
if (split.length == 1) {
returnValue.append(replacedStrings.get(split[0]));
}
// obtain consts & concat the consts with the variables
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(regex);
Matcher matcher = pattern.matcher(value);
if (matcher.find()) {
int x = matcher.start();
int y = matcher.end();
int curPos = 0;
int valueLength = value.length();
String oldFill = null;
String newFill = null;
String subRegEx = "^" + vOldName + "(\\s*\\.\\s*\\w+)+"; //$NON-NLS-1$ //$NON-NLS-2$
java.util.regex.Pattern subPattern = java.util.regex.Pattern.compile(subRegEx);
while (true) {
if (curPos == valueLength) {
break;
}
if (curPos < x) {
oldFill = value.substring(curPos, x);
if ((newFill = replacedStrings.get(oldFill)) != null) {
returnValue.append(newFill);
} else {
returnValue.append(oldFill);
}
curPos = x;
continue;
}
String matchedString = matcher.group();
Matcher subMatcher = subPattern.matcher(matchedString);
if (subMatcher.find()) {
returnValue.append(matchedString.replaceFirst(vOldName, newName));
} else {
returnValue.append(matchedString);
}
curPos = y;
if (!matcher.find()) {
x = valueLength;
} else {
x = matcher.start();
y = matcher.end();
}
}
}
return returnValue.toString();
}
/**
* DOC cmeng Comment method "isEscapeSequence".
*
* @param value
* @param i
* @return
*/
private static boolean isEscapeSequence(String value, int i) {
boolean isEscapeSequence = false;
for (int index = i; 0 < index; index--) {
if (value.charAt(index - 1) == '\\') {
isEscapeSequence = !isEscapeSequence;
} else {
break;
}
}
return isEscapeSequence;
}
private static int calcMethodArea(String varibleString, String wholeString, int beginIndex, List<FunctionInfo> functions) {
// globalMap.get(...)
// String regex = "\\b\\S*\\s*\\.\\s*\\S*\\s*\\(\\z"; //$NON-NLS-1$
// maybe get(...) also is target
String regex = "\\b[\\w\\.]*?\\s*\\("; //$NON-NLS-1$
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(regex);
Matcher matcher = pattern.matcher(varibleString);
int i = 0;
int currentMaxIndex = i;
while (matcher.find()) {
boolean isInQuota = false;
int parenthesisNum = 0;
int matchedStart = matcher.start();
int matchedEnd = matcher.end();
Point functionNameArea = new Point(beginIndex + matchedStart, beginIndex + matchedEnd);
FunctionInfo funcInfo = new FunctionInfo(functionNameArea);
Point functionParamArea = new Point(-1, -1);
funcInfo.setParamArea(functionParamArea);
i = beginIndex + matchedEnd;
functionParamArea.x = i;
for (; i < wholeString.length(); i++) {
char ch = wholeString.charAt(i);
if (ch == '\"' && !isEscapeSequence(wholeString, i)) {
isInQuota = !isInQuota;
}
if (isInQuota) {
continue;
}
if (ch == '(') {
parenthesisNum++;
} else if (ch == ')') {
parenthesisNum--;
}
if (parenthesisNum < 0) {
break;
}
}
functionParamArea.y = i;
FunctionInfo.addFunctionToList(funcInfo, functions);
if (currentMaxIndex < i) {
currentMaxIndex = i;
}
}
return currentMaxIndex;
}
public static boolean isUseData(final IElementParameter param, final String name) {
if (param == null || name == null) {
return false;
}
if (param.getValue() instanceof String) { // for TEXT / MEMO etc..
String value = (String) param.getValue();
if (ParameterValueUtil.valueContains(value, name)) {
return true;
}
} else if (param.getValue() instanceof List) { // for TABLE
List<Map<String, Object>> tableValues = (List<Map<String, Object>>) param.getValue();
for (Map<String, Object> line : tableValues) {
for (String key : line.keySet()) {
Object cellValue = line.get(key);
if (cellValue instanceof String) { // cell is text so
// test data
if (ParameterValueUtil.valueContains((String) cellValue, name)) {
return true;
}
}
}
}
}
return false;
}
@SuppressWarnings("unchecked")
public static boolean isUseData(final ElementParameterType param, final String name) {
if (param == null || name == null) {
return false;
}
if (param.getField().equals(EParameterFieldType.TABLE.getName())) { // for TABLE
EList elementValue = param.getElementValue();
if (elementValue != null) {
for (ElementValueType valueType : (List<ElementValueType>) elementValue) {
if (valueType.getValue() != null) { // cell is text so
// test data
if (ParameterValueUtil.valueContains(valueType.getValue(), name)) {
return true;
}
}
}
}
} else {
String value = param.getValue();
if (value != null && ParameterValueUtil.valueContains(value, name)) {
return true;
}
}
return false;
}
public static boolean valueContains(String value, String toTest) {
if (value.contains(toTest)) {
Perl5Matcher matcher = new Perl5Matcher();
Perl5Compiler compiler = new Perl5Compiler();
Pattern pattern;
try {
pattern = compiler.compile(getQuotePattern(toTest));
if (matcher.contains(value, pattern)) {
return true;
}
} catch (MalformedPatternException e) {
throw new RuntimeException(e);
}
}
return false;
}
private static String getQuotePattern(String toTest) {
final String prefix = "\\b("; //$NON-NLS-1$
String suffix = ")\\b"; //$NON-NLS-1$
if (!ContextParameterUtils.isContainContextParam(toTest)) { // context parameter renamed
suffix = ")(\\b|\\_)"; //$NON-NLS-1$
}
return prefix + UpdateContextVariablesHelper.replaceSpecialChar(toTest) + suffix;
}
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}

View File

@@ -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>

View File

@@ -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

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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();
}
}

View File

@@ -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>();
}
}

View File

@@ -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$
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

View File

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 318 B

View File

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 342 B

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 80 B

After

Width:  |  Height:  |  Size: 80 B

View File

Before

Width:  |  Height:  |  Size: 158 B

After

Width:  |  Height:  |  Size: 158 B

View File

Before

Width:  |  Height:  |  Size: 149 B

After

Width:  |  Height:  |  Size: 149 B

View File

Before

Width:  |  Height:  |  Size: 93 B

After

Width:  |  Height:  |  Size: 93 B

View File

Before

Width:  |  Height:  |  Size: 606 B

After

Width:  |  Height:  |  Size: 606 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 595 B

After

Width:  |  Height:  |  Size: 595 B

View File

Before

Width:  |  Height:  |  Size: 594 B

After

Width:  |  Height:  |  Size: 594 B

View File

Before

Width:  |  Height:  |  Size: 350 B

After

Width:  |  Height:  |  Size: 350 B

View File

Before

Width:  |  Height:  |  Size: 753 B

After

Width:  |  Height:  |  Size: 753 B

View File

Before

Width:  |  Height:  |  Size: 58 B

After

Width:  |  Height:  |  Size: 58 B

View File

Before

Width:  |  Height:  |  Size: 326 B

After

Width:  |  Height:  |  Size: 326 B

View File

Before

Width:  |  Height:  |  Size: 952 B

After

Width:  |  Height:  |  Size: 952 B

View File

Before

Width:  |  Height:  |  Size: 55 B

After

Width:  |  Height:  |  Size: 55 B

View File

Before

Width:  |  Height:  |  Size: 626 B

After

Width:  |  Height:  |  Size: 626 B

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 54 B

After

Width:  |  Height:  |  Size: 54 B

View File

Before

Width:  |  Height:  |  Size: 605 B

After

Width:  |  Height:  |  Size: 605 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 353 B

After

Width:  |  Height:  |  Size: 353 B

View File

Before

Width:  |  Height:  |  Size: 633 B

After

Width:  |  Height:  |  Size: 633 B

View File

Before

Width:  |  Height:  |  Size: 95 B

After

Width:  |  Height:  |  Size: 95 B

Some files were not shown because too many files have changed in this diff Show More