feat(TUP-30834) add 2 axis2 module to classpath and export package. (#4317)
add 2 axis2 module to classpath and export package. replace axis1 with axis2 for S56MDMConnetionHelper remove salesforce code&dependency from tup, adpt the 'create salesforce connection' toolbar action to generic salesforce connection creation action.
This commit is contained in:
@@ -150,6 +150,8 @@ public interface IGenericWizardService extends IService {
|
||||
*/
|
||||
public ITreeContextualAction getDefaultAction(RepositoryNode node);
|
||||
|
||||
public ITreeContextualAction getGenericAction(String typeName, String location);
|
||||
|
||||
public void loadAdditionalJDBC();
|
||||
|
||||
public List<String> getAllAdditionalJDBCTypes();
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/axis2-metadata-1.7.9.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/axis2-java2wsdl-1.7.9.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/axis2-codegen-1.7.9.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/woden-api-1.0M9.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/axiom-api-1.2.13.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/axiom-impl-1.2.13.jar"/>
|
||||
@@ -11,7 +14,7 @@
|
||||
<classpathentry exported="true" kind="lib" path="lib/httpcore-4.0.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/neethi-3.0.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/wstx-asl-3.2.9.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/xmlschema-core-2.0.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/xmlschema-core-2.2.1.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="class"/>
|
||||
|
||||
@@ -22,8 +22,11 @@ Bundle-ClassPath: lib/activation-1.1.jar,
|
||||
lib/mail-1.4.jar,
|
||||
lib/neethi-3.0.1.jar,
|
||||
lib/wstx-asl-3.2.9.jar,
|
||||
lib/xmlschema-core-2.0.1.jar,
|
||||
lib/xmlschema-core-2.2.1.jar,
|
||||
lib/woden-api-1.0M9.jar,
|
||||
lib/axis2-codegen-1.7.9.jar,
|
||||
lib/axis2-java2wsdl-1.7.9.jar,
|
||||
lib/axis2-metadata-1.7.9.jar,
|
||||
.
|
||||
Export-Package: com.ctc.wstx.api,
|
||||
com.ctc.wstx.cfg,
|
||||
@@ -129,6 +132,7 @@ Export-Package: com.ctc.wstx.api,
|
||||
org.apache.axis2.i18n,
|
||||
org.apache.axis2.java.security,
|
||||
org.apache.axis2.jaxrs,
|
||||
org.apache.axis2.jaxws.description,
|
||||
org.apache.axis2.jsr181,
|
||||
org.apache.axis2.modules,
|
||||
org.apache.axis2.namespace,
|
||||
@@ -170,6 +174,8 @@ Export-Package: com.ctc.wstx.api,
|
||||
org.apache.ws.commons.schema.internal,
|
||||
org.apache.ws.commons.schema.resolver,
|
||||
org.apache.ws.commons.schema.utils,
|
||||
org.apache.ws.java2wsdl,
|
||||
org.apache.ws.java2wsdl.utils,
|
||||
org.codehaus.stax2,
|
||||
org.codehaus.stax2.evt,
|
||||
org.codehaus.stax2.io,
|
||||
|
||||
@@ -46,6 +46,32 @@
|
||||
<artifactId>axis2-transport-local</artifactId>
|
||||
<version>1.7.9</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.apache.axis2</groupId>
|
||||
<artifactId>axis2-codegen</artifactId>
|
||||
<version>1.7.9</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.apache.axis2</groupId>
|
||||
<artifactId>axis2-metadata</artifactId>
|
||||
<version>1.7.9</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.apache.axis2</groupId>
|
||||
<artifactId>axis2-java2wsdl</artifactId>
|
||||
<version>1.7.9</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.apache.axis2</groupId>
|
||||
<artifactId>axis2-adb-codegen</artifactId>
|
||||
<version>1.7.9</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.apache.ws.xmlschema</groupId>
|
||||
<artifactId>xmlschema-core</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
@@ -7,7 +7,6 @@ Require-Bundle: org.eclipse.ui,
|
||||
org.apache.commons.logging,
|
||||
org.apache.commons.collections,
|
||||
org.apache.commons.lang,
|
||||
org.apache.axis,
|
||||
org.talend.libraries.mdm;resolution:=optional,
|
||||
org.talend.common.ui.runtime,
|
||||
org.talend.core.runtime,
|
||||
|
||||
@@ -4,8 +4,7 @@ Bundle-Name: Registration Plug-in
|
||||
Bundle-SymbolicName: org.talend.registration;singleton:=true
|
||||
Bundle-Version: 7.4.1.qualifier
|
||||
Bundle-Vendor: .Talend SA.
|
||||
Require-Bundle: org.apache.axis,
|
||||
javax.xml.rpc,
|
||||
Require-Bundle: javax.xml.rpc,
|
||||
org.eclipse.ui,
|
||||
org.talend.core.runtime,
|
||||
org.talend.core.ui,
|
||||
@@ -15,7 +14,8 @@ Require-Bundle: org.apache.axis,
|
||||
org.talend.metadata.managment,
|
||||
org.talend.common.ui.runtime,
|
||||
org.eclipse.ui.intro,
|
||||
org.talend.commons.ui
|
||||
org.talend.commons.ui,
|
||||
org.talend.libraries.apache.axis2
|
||||
Export-Package: org.talend.registration,
|
||||
org.talend.registration.license,
|
||||
org.talend.registration.register,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package org.talend.registration.register.proxy;
|
||||
|
||||
public interface RegisterUser extends javax.xml.rpc.Service {
|
||||
public interface RegisterUser {
|
||||
public java.lang.String getRegisterUserPortAddress();
|
||||
|
||||
public org.talend.registration.register.proxy.RegisterUserPortType getRegisterUserPort() throws javax.xml.rpc.ServiceException;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,20 +6,12 @@
|
||||
|
||||
package org.talend.registration.register.proxy;
|
||||
|
||||
public class RegisterUserLocator extends org.apache.axis.client.Service implements
|
||||
public class RegisterUserLocator implements
|
||||
org.talend.registration.register.proxy.RegisterUser {
|
||||
|
||||
public RegisterUserLocator() {
|
||||
}
|
||||
|
||||
public RegisterUserLocator(org.apache.axis.EngineConfiguration config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public RegisterUserLocator(java.lang.String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException {
|
||||
super(wsdlLoc, sName);
|
||||
}
|
||||
|
||||
// Use to get a proxy class for RegisterUserPort
|
||||
private java.lang.String RegisterUserPort_address = "https://www.talend.com/TalendRegisterWS/registerws.php";
|
||||
|
||||
@@ -53,10 +45,9 @@ public class RegisterUserLocator extends org.apache.axis.client.Service implemen
|
||||
throws javax.xml.rpc.ServiceException {
|
||||
try {
|
||||
org.talend.registration.register.proxy.RegisterUserBindingStub _stub = new org.talend.registration.register.proxy.RegisterUserBindingStub(
|
||||
portAddress, this);
|
||||
_stub.setPortName(getRegisterUserPortWSDDServiceName());
|
||||
portAddress.toString());
|
||||
return _stub;
|
||||
} catch (org.apache.axis.AxisFault e) {
|
||||
} catch (org.apache.axis2.AxisFault e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -73,8 +64,7 @@ public class RegisterUserLocator extends org.apache.axis.client.Service implemen
|
||||
try {
|
||||
if (org.talend.registration.register.proxy.RegisterUserPortType.class.isAssignableFrom(serviceEndpointInterface)) {
|
||||
org.talend.registration.register.proxy.RegisterUserBindingStub _stub = new org.talend.registration.register.proxy.RegisterUserBindingStub(
|
||||
new java.net.URL(RegisterUserPort_address), this);
|
||||
_stub.setPortName(getRegisterUserPortWSDDServiceName());
|
||||
RegisterUserPort_address);
|
||||
return _stub;
|
||||
}
|
||||
} catch (java.lang.Throwable t) {
|
||||
@@ -98,7 +88,6 @@ public class RegisterUserLocator extends org.apache.axis.client.Service implemen
|
||||
return getRegisterUserPort();
|
||||
} else {
|
||||
java.rmi.Remote _stub = getPort(serviceEndpointInterface);
|
||||
((org.apache.axis.client.Stub) _stub).setPortName(portName);
|
||||
return _stub;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,79 +217,4 @@ public class UserRegistration implements java.io.Serializable {
|
||||
return _hashCode;
|
||||
}
|
||||
|
||||
// Type metadata
|
||||
private static org.apache.axis.description.TypeDesc typeDesc =
|
||||
new org.apache.axis.description.TypeDesc(UserRegistration.class, true);
|
||||
|
||||
static {
|
||||
typeDesc.setXmlType(new javax.xml.namespace.QName("http://www.talend.com/TalendRegisterWS/wsdl", "UserRegistration"));
|
||||
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
|
||||
elemField.setFieldName("id");
|
||||
elemField.setXmlName(new javax.xml.namespace.QName("", "id"));
|
||||
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"));
|
||||
elemField.setNillable(false);
|
||||
typeDesc.addFieldDesc(elemField);
|
||||
elemField = new org.apache.axis.description.ElementDesc();
|
||||
elemField.setFieldName("email");
|
||||
elemField.setXmlName(new javax.xml.namespace.QName("", "email"));
|
||||
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||
elemField.setNillable(false);
|
||||
typeDesc.addFieldDesc(elemField);
|
||||
elemField = new org.apache.axis.description.ElementDesc();
|
||||
elemField.setFieldName("country");
|
||||
elemField.setXmlName(new javax.xml.namespace.QName("", "country"));
|
||||
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||
elemField.setNillable(false);
|
||||
typeDesc.addFieldDesc(elemField);
|
||||
elemField = new org.apache.axis.description.ElementDesc();
|
||||
elemField.setFieldName("designer_version");
|
||||
elemField.setXmlName(new javax.xml.namespace.QName("", "designer_version"));
|
||||
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||
elemField.setNillable(false);
|
||||
typeDesc.addFieldDesc(elemField);
|
||||
elemField = new org.apache.axis.description.ElementDesc();
|
||||
elemField.setFieldName("productname");
|
||||
elemField.setXmlName(new javax.xml.namespace.QName("", "productname"));
|
||||
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||
elemField.setNillable(false);
|
||||
typeDesc.addFieldDesc(elemField);
|
||||
elemField = new org.apache.axis.description.ElementDesc();
|
||||
elemField.setFieldName("registration_date");
|
||||
elemField.setXmlName(new javax.xml.namespace.QName("", "registration_date"));
|
||||
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||
elemField.setNillable(false);
|
||||
typeDesc.addFieldDesc(elemField);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type metadata object
|
||||
*/
|
||||
public static org.apache.axis.description.TypeDesc getTypeDesc() {
|
||||
return typeDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Custom Serializer
|
||||
*/
|
||||
public static org.apache.axis.encoding.Serializer getSerializer(
|
||||
java.lang.String mechType,
|
||||
java.lang.Class _javaType,
|
||||
javax.xml.namespace.QName _xmlType) {
|
||||
return
|
||||
new org.apache.axis.encoding.ser.BeanSerializer(
|
||||
_javaType, _xmlType, typeDesc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Custom Deserializer
|
||||
*/
|
||||
public static org.apache.axis.encoding.Deserializer getDeserializer(
|
||||
java.lang.String mechType,
|
||||
java.lang.Class _javaType,
|
||||
javax.xml.namespace.QName _xmlType) {
|
||||
return
|
||||
new org.apache.axis.encoding.ser.BeanDeserializer(
|
||||
_javaType, _xmlType, typeDesc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ Bundle-Version: 7.4.1.qualifier
|
||||
Bundle-Activator: org.talend.repository.metadata.Activator
|
||||
Require-Bundle: org.apache.commons.lang,
|
||||
org.apache.log4j,
|
||||
org.apache.axis,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.emf.ecore.xmi,
|
||||
org.eclipse.gef,
|
||||
@@ -20,7 +19,6 @@ Require-Bundle: org.apache.commons.lang,
|
||||
org.talend.libraries.jexcel;resolution:=optional,
|
||||
org.talend.libraries.excel,
|
||||
org.talend.libraries.jxplorer;resolution:=optional,
|
||||
org.talend.libraries.salesforce;resolution:=optional,
|
||||
javax.xml.rpc,
|
||||
org.talend.model,
|
||||
org.talend.commons.ui,
|
||||
|
||||
@@ -165,13 +165,6 @@
|
||||
isReadAction="true"
|
||||
level="10"
|
||||
name="Metadata/Create file Excel"/>
|
||||
<Action
|
||||
class="org.talend.repository.metadata.ui.actions.metadata.CreateSalesforceSchemaAction"
|
||||
id="org.talend.repository.actions.createsalesforceschema"
|
||||
isEditAction="true"
|
||||
isReadAction="true"
|
||||
level="10"
|
||||
name="Metadata/Create Salesforce"/>
|
||||
|
||||
<Action
|
||||
class="org.talend.repository.metadata.ui.actions.metadata.CreateGenericSchemaAction"
|
||||
@@ -197,20 +190,6 @@
|
||||
level="10"
|
||||
name="Metadata/Create WSDL schemas">
|
||||
</Action>
|
||||
<Action
|
||||
class="org.talend.repository.metadata.ui.actions.metadata.CreateSalesforceModulesAction"
|
||||
id="org.talend.repository.actions.createSalesforceModulesAction"
|
||||
isEditAction="true"
|
||||
isReadAction="true"
|
||||
level="10"
|
||||
name="Metadata/Create Salesforce Modules"/>
|
||||
<Action
|
||||
class="org.talend.repository.metadata.ui.actions.metadata.CreateSalesforceSchemasAction"
|
||||
id="org.talend.repository.actions.CreateSalesforceSchemasAction"
|
||||
isEditAction="true"
|
||||
isReadAction="true"
|
||||
level="10"
|
||||
name="Metadata/Create Salesforce Schemas"/>
|
||||
<Action
|
||||
class="org.talend.repository.metadata.ui.actions.metadata.ImportSchemaFileAction"
|
||||
id="org.talend.repository.actions.ImportSchemaFileAction"
|
||||
|
||||
@@ -55,7 +55,6 @@ import org.talend.repository.ui.wizards.metadata.connection.files.excel.ExcelFil
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.ldif.LdifFileWizard;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.positional.FilePositionalWizard;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.regexp.RegexpFileWizard;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.salesforce.SalesforceSchemaWizard;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.xml.XmlFileWizard;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.genericshema.GenericSchemaWizard;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.ldap.LDAPSchemaWizard;
|
||||
@@ -150,8 +149,6 @@ public class MetadataService implements IMetadataService {
|
||||
relatedWizard = new LDAPSchemaWizard(PlatformUI.getWorkbench(), creation, realNode, null, false);
|
||||
} else if (objectType.equals(ERepositoryObjectType.METADATA_FILE_EXCEL)) {
|
||||
relatedWizard = new ExcelFileWizard(PlatformUI.getWorkbench(), creation, realNode, null);
|
||||
} else if (objectType.equals(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA)) {
|
||||
relatedWizard = new SalesforceSchemaWizard(PlatformUI.getWorkbench(), creation, realNode, null, false);
|
||||
} else if (objectType.equals(ERepositoryObjectType.METADATA_FILE_EBCDIC)) {
|
||||
if (PluginChecker.isEBCDICPluginLoaded()) {
|
||||
IProviderService iebcdicService = GlobalServiceRegister.getDefault().findService("IEBCDICProviderService");
|
||||
|
||||
@@ -52,8 +52,6 @@ import org.talend.core.model.metadata.builder.connection.LdifFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.metadata.builder.connection.PositionalFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.RegexpFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.SalesforceModuleUnit;
|
||||
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.XmlFileConnection;
|
||||
import org.talend.core.model.metadata.builder.database.ExtractMetaDataFromDataBase;
|
||||
@@ -71,7 +69,6 @@ import org.talend.core.model.properties.LdifFileConnectionItem;
|
||||
import org.talend.core.model.properties.PositionalFileConnectionItem;
|
||||
import org.talend.core.model.properties.RegExFileConnectionItem;
|
||||
import org.talend.core.model.properties.SAPConnectionItem;
|
||||
import org.talend.core.model.properties.SalesforceSchemaConnectionItem;
|
||||
import org.talend.core.model.properties.WSDLSchemaConnectionItem;
|
||||
import org.talend.core.model.properties.XmlFileConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
@@ -99,9 +96,6 @@ import org.talend.repository.model.IRepositoryNode.EProperties;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
import org.talend.repository.ui.views.IRepositoryView;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.salesforce.SalesforceModulesWizard;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.salesforce.SalesforceSchemaTableWizard;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.salesforce.SalesforceSchemasWizard;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.genericshema.GenericSchemaTableWizard;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.ldap.LDAPSchemaTableWizard;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.wsdl.WSDLSchemaTableWizard;
|
||||
@@ -699,174 +693,6 @@ public abstract class AbstractCreateTableAction extends AbstractCreateAction {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC YeXiaowei Comment method "createSalesforceSchemaWizard".
|
||||
*
|
||||
* @param selection
|
||||
* @param forceReadOnly
|
||||
*/
|
||||
public void createSalesforceSchemaWizard(RepositoryNode node, final boolean forceReadOnly) {
|
||||
SalesforceSchemaConnection connection = null;
|
||||
MetadataTable metadataTable = null;
|
||||
|
||||
boolean creation = false;
|
||||
if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
|
||||
ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
|
||||
String tableLabel = (String) node.getProperties(EProperties.LABEL);
|
||||
|
||||
SalesforceSchemaConnectionItem item = null;
|
||||
if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
|
||||
if (node.getParent().isBin() && node.getParent().getObject() == null) {
|
||||
item = (SalesforceSchemaConnectionItem) node.getObject().getProperty().getItem();
|
||||
} else {
|
||||
item = (SalesforceSchemaConnectionItem) node.getParent().getObject().getProperty().getItem();
|
||||
}
|
||||
connection = (SalesforceSchemaConnection) item.getConnection();
|
||||
metadataTable = TableHelper.findByLabel(connection, tableLabel);
|
||||
creation = false;
|
||||
} else if (nodeType == ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA) {
|
||||
item = (SalesforceSchemaConnectionItem) node.getObject().getProperty().getItem();
|
||||
connection = (SalesforceSchemaConnection) item.getConnection();
|
||||
metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
|
||||
String nextId = ProxyRepositoryFactory.getInstance().getNextId();
|
||||
metadataTable.setId(nextId);
|
||||
metadataTable.setLabel(getStringIndexed(metadataTable.getLabel()));
|
||||
GenericPackage g = (GenericPackage) ConnectionHelper.getPackage(connection.getName(), connection,
|
||||
GenericPackage.class);
|
||||
if (g != null) { // hywang
|
||||
g.getOwnedElement().add(metadataTable);
|
||||
} else {
|
||||
GenericPackage gpkg = ConnectionFactory.eINSTANCE.createGenericPackage();
|
||||
PackageHelper.addMetadataTable(metadataTable, gpkg);
|
||||
ConnectionHelper.addPackage(gpkg, connection);
|
||||
|
||||
}
|
||||
creation = true;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
initContextMode(item);
|
||||
|
||||
if (metadataTable.eContainer() instanceof SalesforceModuleUnit) {
|
||||
SalesforceModuleUnit unit = (SalesforceModuleUnit) metadataTable.eContainer();
|
||||
connection.setModuleName(unit.getModuleName());
|
||||
}
|
||||
// set the repositoryObject, lock and set isRepositoryObjectEditable
|
||||
SalesforceSchemaTableWizard salesforceSchemaWizard = new SalesforceSchemaTableWizard(PlatformUI.getWorkbench(),
|
||||
creation, item, metadataTable, forceReadOnly);
|
||||
salesforceSchemaWizard.setRepositoryObject(node.getObject());
|
||||
|
||||
WizardDialog wizardDialog = new WizardDialog(Display.getCurrent().getActiveShell(), salesforceSchemaWizard);
|
||||
handleWizard(node, wizardDialog);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC YeXiaowei Comment method "createSalesforceSchemaWizard".
|
||||
*
|
||||
* @param selection
|
||||
* @param forceReadOnly
|
||||
*/
|
||||
public void createSalesforceSchemasWizard(RepositoryNode node, final boolean forceReadOnly) {
|
||||
SalesforceSchemaConnection connection = null;
|
||||
MetadataTable metadataTable = null;
|
||||
boolean creation = false;
|
||||
if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
|
||||
ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
|
||||
String tableLabel = (String) node.getProperties(EProperties.LABEL);
|
||||
|
||||
SalesforceSchemaConnectionItem item = null;
|
||||
// if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
|
||||
//
|
||||
// item = (SalesforceSchemaConnectionItem) node.getParent().getObject().getProperty().getItem();
|
||||
// connection = (SalesforceSchemaConnection) item.getConnection();
|
||||
// metadataTable = TableHelper.findByLabel(connection, tableLabel);
|
||||
// creation = false;
|
||||
// } else if (nodeType == ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA) {
|
||||
// item = (SalesforceSchemaConnectionItem) node.getObject().getProperty().getItem();
|
||||
// connection = (SalesforceSchemaConnection) item.getConnection();
|
||||
// metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
|
||||
// String nextId = ProxyRepositoryFactory.getInstance().getNextId();
|
||||
// metadataTable.setId(nextId);
|
||||
// metadataTable.setLabel(getStringIndexed(metadataTable.getLabel()));
|
||||
// creation = true;
|
||||
// } else
|
||||
if (nodeType == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
|
||||
item = (SalesforceSchemaConnectionItem) node.getObject().getProperty().getItem();
|
||||
connection = (SalesforceSchemaConnection) item.getConnection();
|
||||
metadataTable = TableHelper.findByLabel(connection, tableLabel);
|
||||
creation = false;
|
||||
} else {
|
||||
return;
|
||||
|
||||
}
|
||||
initContextMode(item);
|
||||
if (metadataTable.eContainer() instanceof SalesforceModuleUnit) {
|
||||
SalesforceModuleUnit unit = (SalesforceModuleUnit) metadataTable.eContainer();
|
||||
connection.setModuleName(unit.getModuleName());
|
||||
}
|
||||
// set the repositoryObject, lock and set isRepositoryObjectEditable
|
||||
SalesforceSchemasWizard salesforceSchemasWizard = new SalesforceSchemasWizard(PlatformUI.getWorkbench(), creation,
|
||||
node.getObject(), metadataTable, getExistingNames(), forceReadOnly, null, null, node.getProperties(
|
||||
EProperties.LABEL).toString());
|
||||
// salesforceSchemaWizard.setRepositoryObject(node.getObject());
|
||||
|
||||
WizardDialog wizardDialog = new WizardDialog(Display.getCurrent().getActiveShell(), salesforceSchemasWizard);
|
||||
handleWizard(node, wizardDialog);
|
||||
}
|
||||
}
|
||||
|
||||
public void createSalesforceModuleWizard(RepositoryNode node, final boolean forceReadOnly) {
|
||||
SalesforceSchemaConnection connection = null;
|
||||
MetadataTable metadataTable = null;
|
||||
boolean creation = false;
|
||||
if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
|
||||
ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
|
||||
String tableLabel = (String) node.getProperties(EProperties.LABEL);
|
||||
|
||||
SalesforceSchemaConnectionItem item = null;
|
||||
if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
|
||||
if (node.getParent().isBin() && node.getParent().getObject() == null) {
|
||||
item = (SalesforceSchemaConnectionItem) node.getObject().getProperty().getItem();
|
||||
} else {
|
||||
item = (SalesforceSchemaConnectionItem) node.getParent().getObject().getProperty().getItem();
|
||||
}
|
||||
connection = (SalesforceSchemaConnection) item.getConnection();
|
||||
metadataTable = TableHelper.findByLabel(connection, tableLabel);
|
||||
creation = false;
|
||||
} else if (nodeType == ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA) {
|
||||
item = (SalesforceSchemaConnectionItem) node.getObject().getProperty().getItem();
|
||||
connection = (SalesforceSchemaConnection) item.getConnection();
|
||||
metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
|
||||
String nextId = ProxyRepositoryFactory.getInstance().getNextId();
|
||||
metadataTable.setId(nextId);
|
||||
metadataTable.setLabel(getStringIndexed(metadataTable.getLabel()));
|
||||
creation = false;
|
||||
} else if (nodeType == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
|
||||
item = (SalesforceSchemaConnectionItem) node.getObject().getProperty().getItem();
|
||||
connection = (SalesforceSchemaConnection) item.getConnection();
|
||||
metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
|
||||
String nextId = ProxyRepositoryFactory.getInstance().getNextId();
|
||||
metadataTable.setId(nextId);
|
||||
metadataTable.setLabel(getStringIndexed(metadataTable.getLabel()));
|
||||
creation = false;
|
||||
} else {
|
||||
return;
|
||||
|
||||
}
|
||||
initContextMode(item);
|
||||
// set the repositoryObject, lock and set isRepositoryObjectEditable
|
||||
SalesforceModulesWizard salesforceSchemaWizard = new SalesforceModulesWizard(PlatformUI.getWorkbench(), creation,
|
||||
node.getObject(), metadataTable, getExistingNames(), forceReadOnly, null, null);
|
||||
// salesforceSchemaWizard.setRepositoryObject(node.getObject());
|
||||
|
||||
WizardDialog wizardDialog = new WizardDialog(Display.getCurrent().getActiveShell(), salesforceSchemaWizard);
|
||||
handleWizard(node, wizardDialog);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC hwang Comment method "createSAPSchemaWizard".
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.metadata.ui.actions.metadata;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.talend.commons.runtime.model.repository.ERepositoryStatus;
|
||||
import org.talend.commons.ui.runtime.image.ECoreImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.metadata.builder.connection.SubscriberTable;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject;
|
||||
import org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.IRepositoryNode.ENodeType;
|
||||
import org.talend.repository.model.IRepositoryNode.EProperties;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
import org.talend.repository.ui.views.IRepositoryView;
|
||||
|
||||
/**
|
||||
* Action used to create table on metadata.<br/>
|
||||
*
|
||||
* $Id: CreateTableAction.java 54939 2011-02-11 01:34:57Z mhirt $
|
||||
*
|
||||
*/
|
||||
public class CreateSalesforceModulesAction extends AbstractCreateTableAction {
|
||||
|
||||
protected static Logger log = Logger.getLogger(CreateConnectionAction.class);
|
||||
|
||||
protected static final String PID = "org.talend.repository"; //$NON-NLS-1$
|
||||
|
||||
protected static final String CREATE_LABEL = Messages.getString("CreateSalesforceModulesAction.retriveModules"); //$NON-NLS-1$
|
||||
|
||||
protected static final String EDIT_LABEL = Messages.getString("CreateSalesforceModulesAction.retriveModules"); //$NON-NLS-1$
|
||||
|
||||
private RepositoryNode node;
|
||||
|
||||
public CreateSalesforceModulesAction(boolean isToolBar) {
|
||||
super();
|
||||
setToolbar(isToolBar);
|
||||
this.setText(CREATE_LABEL);
|
||||
this.setToolTipText(CREATE_LABEL);
|
||||
this.setImageDescriptor(ImageProvider.getImageDesc(ECoreImage.METADATA_TABLE_ICON));
|
||||
}
|
||||
|
||||
public CreateSalesforceModulesAction() {
|
||||
super();
|
||||
this.setText(CREATE_LABEL);
|
||||
this.setToolTipText(CREATE_LABEL);
|
||||
this.setImageDescriptor(ImageProvider.getImageDesc(ECoreImage.METADATA_TABLE_ICON));
|
||||
}
|
||||
|
||||
/**
|
||||
* yzhang CreateTableAction constructor comment.
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
public CreateSalesforceModulesAction(RepositoryNode node) {
|
||||
this();
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
protected void doRun() {
|
||||
RepositoryNode metadataNode = null;
|
||||
if (node == null && repositoryNode != null) {
|
||||
node = repositoryNode;
|
||||
}
|
||||
if (node == null) {
|
||||
// RepositoryNode metadataNode = getViewPart().getRoot().getChildren().get(6);
|
||||
metadataNode = getMetadataNode(getCurrentRepositoryNode());
|
||||
IStructuredSelection selection = (IStructuredSelection) getSelection();
|
||||
node = (RepositoryNode) selection.getFirstElement();
|
||||
// Force focus to the repositoryView and open Metadata and DbConnection nodes
|
||||
IRepositoryView viewPart = getViewPart();
|
||||
if (viewPart != null) {
|
||||
viewPart.setFocus();
|
||||
viewPart.expand(metadataNode, true);
|
||||
}
|
||||
} else {
|
||||
metadataNode = getMetadataNode(node);
|
||||
}
|
||||
|
||||
// Init the content of the Wizard
|
||||
init(node);
|
||||
|
||||
ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
|
||||
|
||||
if (ERepositoryObjectType.METADATA_CON_TABLE.equals(nodeType)
|
||||
|| ERepositoryObjectType.METADATA_CON_COLUMN.equals(nodeType)) {
|
||||
final IRepositoryViewObject object = node.getObject();
|
||||
if (object instanceof MetadataTableRepositoryObject) {
|
||||
MetadataTable table = ((MetadataTableRepositoryObject) object).getTable();
|
||||
if (table instanceof SubscriberTable) {
|
||||
this.node = null;
|
||||
return;
|
||||
}
|
||||
} else if (object instanceof MetadataColumnRepositoryObject) {
|
||||
MetadataTable table = ((MetadataColumnRepositoryObject) object).getTdColumn().getTable();
|
||||
this.node = node.getParent().getParent();
|
||||
if (table instanceof SubscriberTable) {
|
||||
this.node = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
ConnectionItem connectionItem = (ConnectionItem) object.getProperty().getItem();
|
||||
nodeType = ERepositoryObjectType.getItemType(connectionItem);
|
||||
|
||||
}
|
||||
createSalesforceModuleWizard(node, false);
|
||||
|
||||
this.node = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getClassForDoubleClick() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.repository.ui.actions.metadata.AbstractCreateAction#init(org.talend.repository.model.RepositoryNode)
|
||||
*/
|
||||
@Override
|
||||
protected void init(RepositoryNode node) {
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
if (factory.isUserReadOnlyOnCurrentProject() || !ProjectManager.getInstance().isInCurrentMainProject(node)) {
|
||||
setEnabled(false);
|
||||
} else {
|
||||
if (ENodeType.REPOSITORY_ELEMENT.equals(node.getType())) {
|
||||
if (node.getObject().getRepositoryStatus() == ERepositoryStatus.DELETED
|
||||
|| node.getObject().getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER) {
|
||||
setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
|
||||
if (ERepositoryObjectType.METADATA_CON_TABLE.equals(nodeType)
|
||||
|| ERepositoryObjectType.METADATA_CON_COLUMN.equals(nodeType)) {
|
||||
setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA.equals(nodeType)) {
|
||||
setText(CREATE_LABEL);
|
||||
collectChildNames(node);
|
||||
if (isLastVersion(node)) {
|
||||
setEnabled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// if (ERepositoryObjectType.METADATA_CON_QUERY.equals(nodeType)) {
|
||||
// setEnabled(false);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,22 +13,23 @@
|
||||
package org.talend.repository.metadata.ui.actions.metadata;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.wizard.WizardDialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.talend.commons.ui.runtime.image.ECoreImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.commons.ui.runtime.image.OverlayImageProvider;
|
||||
import org.talend.commons.ui.swt.actions.ITreeContextualAction;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.properties.SalesforceSchemaConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.repository.ui.actions.metadata.AbstractCreateAction;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.IRepositoryNode.ENodeType;
|
||||
import org.talend.repository.model.IRepositoryNode.EProperties;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.salesforce.SalesforceSchemaWizard;
|
||||
|
||||
/**
|
||||
* DOC yexiaowei class global comment. Detailled comment
|
||||
@@ -38,21 +39,13 @@ public class CreateSalesforceSchemaAction extends AbstractCreateAction {
|
||||
|
||||
private static final String CREATE_LABEL = Messages.getString("CreateSalesforceSchemaAction.createConnection"); //$NON-NLS-1$
|
||||
|
||||
private static final String EDIT_LABEL = Messages.getString("CreateSalesforceSchemaAction.editConnection"); //$NON-NLS-1$
|
||||
|
||||
private static final String OPEN_LABEL = Messages.getString("CreateSalesforceSchemaAction.editConnection"); //$NON-NLS-1$
|
||||
|
||||
protected static final int WIZARD_WIDTH = 800;
|
||||
|
||||
protected static final int WIZARD_HEIGHT = 520;
|
||||
|
||||
private boolean creation = false;
|
||||
|
||||
ImageDescriptor defaultImage = ImageProvider.getImageDesc(ECoreImage.METADATA_SALESFORCE_SCHEMA_ICON);
|
||||
|
||||
ImageDescriptor createImage = OverlayImageProvider.getImageWithNew(ImageProvider
|
||||
.getImage(ECoreImage.METADATA_SALESFORCE_SCHEMA_ICON));
|
||||
|
||||
private AbstractCreateAction createAction;
|
||||
|
||||
public CreateSalesforceSchemaAction() {
|
||||
super();
|
||||
|
||||
@@ -72,45 +65,47 @@ public class CreateSalesforceSchemaAction extends AbstractCreateAction {
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
|
||||
if (repositoryNode == null) {
|
||||
repositoryNode = getCurrentRepositoryNode();
|
||||
}
|
||||
|
||||
if (isToolbar()) {
|
||||
if (repositoryNode != null && repositoryNode.getContentType() != ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA) {
|
||||
ERepositoryObjectType salesforceType = ERepositoryObjectType.getType("salesforce");
|
||||
if (repositoryNode != null && repositoryNode.getContentType() != salesforceType) {
|
||||
repositoryNode = null;
|
||||
}
|
||||
if (repositoryNode == null) {
|
||||
repositoryNode = getRepositoryNodeForDefault(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA);
|
||||
if (repositoryNode == null || (repositoryNode.getType() != ENodeType.SIMPLE_FOLDER
|
||||
&& repositoryNode.getType() != ENodeType.SYSTEM_FOLDER)) {
|
||||
repositoryNode = getRepositoryNodeForDefault(salesforceType);
|
||||
}
|
||||
|
||||
init(repositoryNode);
|
||||
|
||||
ITreeContextualAction defaultAction = getGenericAction(repositoryNode);
|
||||
if (defaultAction instanceof AbstractCreateAction) {
|
||||
createAction = (AbstractCreateAction) defaultAction;
|
||||
createAction.setCurrentRepositoryNode(repositoryNode);
|
||||
createAction.init(null, new StructuredSelection(repositoryNode));
|
||||
createAction.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WizardDialog wizardDialog = null;
|
||||
if (isToolbar()) {
|
||||
init(repositoryNode);
|
||||
SalesforceSchemaWizard salesForceSchemaWizard = new SalesforceSchemaWizard(PlatformUI.getWorkbench(), creation,
|
||||
repositoryNode, getExistingNames(), false);
|
||||
salesForceSchemaWizard.setToolbar(true);
|
||||
wizardDialog = new WizardDialog(Display.getCurrent().getActiveShell(), salesForceSchemaWizard);// TODO send
|
||||
} else {
|
||||
wizardDialog = new WizardDialog(Display.getCurrent().getActiveShell(), new SalesforceSchemaWizard(
|
||||
PlatformUI.getWorkbench(), creation, repositoryNode, getExistingNames(), false));
|
||||
private ITreeContextualAction getGenericAction(RepositoryNode repositoryNode) {
|
||||
IGenericWizardService wizardService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
|
||||
}
|
||||
|
||||
wizardDialog.setPageSize(WIZARD_WIDTH, WIZARD_HEIGHT);
|
||||
wizardDialog.create();
|
||||
wizardDialog.open();
|
||||
|
||||
ITreeContextualAction defaultAction = null;
|
||||
if (wizardService != null) {
|
||||
ERepositoryObjectType repObjType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
|
||||
defaultAction = wizardService.getGenericAction(repObjType.getType(), null);
|
||||
}
|
||||
return defaultAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init(RepositoryNode node) {
|
||||
ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
|
||||
if (!ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA.equals(nodeType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
switch (node.getType()) {
|
||||
case SIMPLE_FOLDER:
|
||||
@@ -125,21 +120,8 @@ public class CreateSalesforceSchemaAction extends AbstractCreateAction {
|
||||
}
|
||||
this.setText(CREATE_LABEL);
|
||||
collectChildNames(node);
|
||||
creation = true;
|
||||
this.setImageDescriptor(createImage);
|
||||
break;
|
||||
case REPOSITORY_ELEMENT:
|
||||
if (factory.isPotentiallyEditable(node.getObject())) {
|
||||
this.setText(EDIT_LABEL);
|
||||
this.setImageDescriptor(defaultImage);
|
||||
collectSiblingNames(node);
|
||||
} else {
|
||||
this.setText(OPEN_LABEL);
|
||||
this.setImageDescriptor(defaultImage);
|
||||
}
|
||||
collectSiblingNames(node);
|
||||
creation = false;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.metadata.ui.actions.metadata;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.talend.commons.runtime.model.repository.ERepositoryStatus;
|
||||
import org.talend.commons.ui.runtime.image.ECoreImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.metadata.builder.connection.SubscriberTable;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject;
|
||||
import org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.IRepositoryNode.ENodeType;
|
||||
import org.talend.repository.model.IRepositoryNode.EProperties;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
import org.talend.repository.ui.views.IRepositoryView;
|
||||
|
||||
/**
|
||||
* Action used to create table on metadata.<br/>
|
||||
*
|
||||
* $Id: CreateTableAction.java 54939 2011-02-11 01:34:57Z mhirt $
|
||||
*
|
||||
*/
|
||||
public class CreateSalesforceSchemasAction extends AbstractCreateTableAction {
|
||||
|
||||
protected static Logger log = Logger.getLogger(CreateConnectionAction.class);
|
||||
|
||||
protected static final String PID = "org.talend.repository"; //$NON-NLS-1$
|
||||
|
||||
protected static final String CREATE_LABEL = Messages.getString("CreateSalesforceSchemasAction.createSchemas");//$NON-NLS-1$
|
||||
|
||||
protected static final String EDIT_LABEL = Messages.getString("CreateSalesforceSchemasAction.editSchemas");//$NON-NLS-1$
|
||||
|
||||
private RepositoryNode node;
|
||||
|
||||
public CreateSalesforceSchemasAction(boolean isToolBar) {
|
||||
super();
|
||||
setToolbar(isToolBar);
|
||||
this.setText(CREATE_LABEL);
|
||||
this.setToolTipText(CREATE_LABEL);
|
||||
this.setImageDescriptor(ImageProvider.getImageDesc(ECoreImage.METADATA_TABLE_ICON));
|
||||
}
|
||||
|
||||
public CreateSalesforceSchemasAction() {
|
||||
super();
|
||||
this.setText(CREATE_LABEL);
|
||||
this.setToolTipText(CREATE_LABEL);
|
||||
this.setImageDescriptor(ImageProvider.getImageDesc(ECoreImage.METADATA_TABLE_ICON));
|
||||
}
|
||||
|
||||
/**
|
||||
* yzhang CreateTableAction constructor comment.
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
public CreateSalesforceSchemasAction(RepositoryNode node) {
|
||||
this();
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
protected void doRun() {
|
||||
RepositoryNode metadataNode = null;
|
||||
if (node == null && repositoryNode != null) {
|
||||
node = repositoryNode;
|
||||
}
|
||||
if (node == null) {
|
||||
// RepositoryNode metadataNode = getViewPart().getRoot().getChildren().get(6);
|
||||
metadataNode = getMetadataNode(getCurrentRepositoryNode());
|
||||
IStructuredSelection selection = (IStructuredSelection) getSelection();
|
||||
node = (RepositoryNode) selection.getFirstElement();
|
||||
// Force focus to the repositoryView and open Metadata and DbConnection nodes
|
||||
IRepositoryView viewPart = getViewPart();
|
||||
if (viewPart != null) {
|
||||
viewPart.setFocus();
|
||||
viewPart.expand(metadataNode, true);
|
||||
}
|
||||
} else {
|
||||
metadataNode = getMetadataNode(node);
|
||||
}
|
||||
|
||||
// Init the content of the Wizard
|
||||
init(node);
|
||||
|
||||
ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
|
||||
|
||||
if (ERepositoryObjectType.METADATA_CON_TABLE.equals(nodeType)
|
||||
|| ERepositoryObjectType.METADATA_CON_COLUMN.equals(nodeType)) {
|
||||
final IRepositoryViewObject object = node.getObject();
|
||||
if (object instanceof MetadataTableRepositoryObject) {
|
||||
MetadataTable table = ((MetadataTableRepositoryObject) object).getTable();
|
||||
if (table instanceof SubscriberTable) {
|
||||
this.node = null;
|
||||
return;
|
||||
}
|
||||
} else if (object instanceof MetadataColumnRepositoryObject) {
|
||||
MetadataTable table = ((MetadataColumnRepositoryObject) object).getTdColumn().getTable();
|
||||
this.node = node.getParent().getParent();
|
||||
if (table instanceof SubscriberTable) {
|
||||
this.node = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
ConnectionItem connectionItem = (ConnectionItem) object.getProperty().getItem();
|
||||
nodeType = ERepositoryObjectType.getItemType(connectionItem);
|
||||
|
||||
}
|
||||
createSalesforceSchemasWizard(node, false);
|
||||
|
||||
this.node = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getClassForDoubleClick() {
|
||||
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
if (service != null) {
|
||||
return service.getClassForSalesforceModule();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.repository.ui.actions.metadata.AbstractCreateAction#init(org.talend.repository.model.RepositoryNode)
|
||||
*/
|
||||
@Override
|
||||
protected void init(RepositoryNode node) {
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
if (factory.isUserReadOnlyOnCurrentProject() || !ProjectManager.getInstance().isInCurrentMainProject(node)) {
|
||||
setEnabled(false);
|
||||
} else {
|
||||
if (ENodeType.REPOSITORY_ELEMENT.equals(node.getType())) {
|
||||
if (node.getObject().getRepositoryStatus() == ERepositoryStatus.DELETED
|
||||
|| node.getObject().getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER) {
|
||||
setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
|
||||
if (ERepositoryObjectType.METADATA_CON_TABLE.equals(nodeType)
|
||||
|| ERepositoryObjectType.METADATA_CON_COLUMN.equals(nodeType)) {
|
||||
setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (ERepositoryObjectType.METADATA_SALESFORCE_MODULE.equals(nodeType)) {
|
||||
setText(CREATE_LABEL);
|
||||
collectChildNames(node);
|
||||
if (isLastVersion(node)) {
|
||||
setEnabled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// if (ERepositoryObjectType.METADATA_CON_QUERY.equals(nodeType)) {
|
||||
// setEnabled(false);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,8 +166,6 @@ public class CreateTableAction extends AbstractCreateTableAction {
|
||||
createLDAPSchemaWizard(node, false);
|
||||
} else if (ERepositoryObjectType.METADATA_WSDL_SCHEMA.equals(nodeType)) {
|
||||
createWSDLSchemaWizard(node, false);
|
||||
} else if (ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA.equals(nodeType)) {
|
||||
createSalesforceSchemaWizard(node, false);
|
||||
} else if (ERepositoryObjectType.METADATA_SAPCONNECTIONS != null
|
||||
&& ERepositoryObjectType.METADATA_SAPCONNECTIONS.equals(nodeType)) {
|
||||
createSAPSchemaWizard(node, false);
|
||||
|
||||
@@ -170,8 +170,6 @@ public class ReadTableAction extends AbstractCreateTableAction {
|
||||
createGenericSchemaWizard(node, true);
|
||||
} else if (ERepositoryObjectType.METADATA_LDAP_SCHEMA.equals(nodeType)) {
|
||||
createLDAPSchemaWizard(node, true);
|
||||
} else if (ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA.equals(nodeType)) {
|
||||
createSalesforceSchemaWizard(node, true);
|
||||
} else { // handle the schemas of extensive nodes.
|
||||
createExtenseNodeSchemaWizard(nodeType, node, true);
|
||||
}
|
||||
|
||||
@@ -1,686 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.metadata.ui.wizards.form;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.swt.dialogs.ErrorDialogWidthDetailArea;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.language.LanguageManager;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.IMetadataContextModeManager;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MetadataColumn;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
|
||||
import org.talend.core.model.process.AbstractNode;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.model.utils.RepositoryManagerHelper;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.metadata.managment.ui.wizard.AbstractForm;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.salesforce.ISalesforceModuleParser;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.salesforce.SalesforceModuleParseAPI;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.salesforce.SalesforceModuleParserPartner;
|
||||
import org.talend.salesforce.SforceConnection;
|
||||
import org.talend.salesforce.SforceManagement;
|
||||
import org.talend.salesforce.SforceSessionConnection;
|
||||
import org.talend.salesforce.oauth.OAuthClient;
|
||||
import org.talend.salesforce.oauth.Token;
|
||||
|
||||
import com.salesforce.soap.partner.DescribeSObjectResult;
|
||||
import com.salesforce.soap.partner.Field;
|
||||
import com.sforce.soap.enterprise.DescribeGlobalResult;
|
||||
import com.sforce.soap.enterprise.SoapBindingStub;
|
||||
import com.sforce.soap.enterprise.fault.UnexpectedErrorFault;
|
||||
|
||||
/**
|
||||
* DOC YeXiaowei class global comment. Detailled comment <br/>
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractSalesforceStepForm extends AbstractForm {
|
||||
|
||||
protected int maximumRowsToPreview = RepositoryManagerHelper.getMaximumRowsToPreview();
|
||||
|
||||
protected SalesforceSchemaConnection connection;
|
||||
|
||||
protected AbstractNode fakeSalesforceNode = null;
|
||||
|
||||
private final String tSalesforceUniqueName = "tSalesforceInput"; //$NON-NLS-1$
|
||||
|
||||
private final String BASIC = "basic";
|
||||
|
||||
private SalesforceModuleParseAPI salesforceAPI = null;
|
||||
|
||||
private IMetadataContextModeManager contextModeManager;
|
||||
|
||||
private SoapBindingStub binding = null;
|
||||
|
||||
private SforceManagement sforceMgr = null;
|
||||
|
||||
// private com.salesforce.soap.partner.SoapBindingStub bindingPartner = null;
|
||||
|
||||
public static final String TSALESFORCE_INPUT_URL = "https://login.salesforce.com/services/Soap/u/34.0"; //$NON-NLS-1$
|
||||
|
||||
public static final String TSALESFORCE_INPUT_URL_OAUTH = "https://login.salesforce.com/services/oauth2"; //$NON-NLS-1$
|
||||
|
||||
public static final String TSALESFORCE_VERSION = "34.0";
|
||||
|
||||
public static final String TSALESFORCE_PARTNER_INPUT_URL = "https://test.salesforce.com/services/Soap/u/10.0"; //$NON-NLS-1$
|
||||
|
||||
// note that tSalesforceInput use a different url, if the web service is called by wizard we should use
|
||||
// DEFAULT_WEB_SERVICE_URL, if the web service is called by tSalesforceInput we should use TSALESFORCE_INPUT_URL
|
||||
public static final String DEFAULT_WEB_SERVICE_URL = "https://www.salesforce.com/services/Soap/u/8.0"; //$NON-NLS-1$
|
||||
|
||||
public static final String DEFAULT_WEB_SERVICE_FOR_SOQL_URL = "https://www.salesforce.com/services/Soap/c/8.0"; //$NON-NLS-1$
|
||||
|
||||
public static final String TSALESFORCE_CUSTOM_MODULE = "org.talend.salesforce.custom.module"; //$NON-NLS-1$
|
||||
|
||||
public static final String TSALESFORCE_CUSTOM_MODULE_SPILT = ","; //$NON-NLS-1$
|
||||
|
||||
public boolean useAlphbet;
|
||||
|
||||
public IMetadataTable metadataTableOrder;
|
||||
|
||||
public IMetadataTable metadataTableClone;
|
||||
|
||||
public AbstractSalesforceStepForm(Composite parent, ConnectionItem connectionItem, String[] existingNames,
|
||||
SalesforceModuleParseAPI salesforceAPI) {
|
||||
super(parent, SWT.NONE, existingNames);
|
||||
setConnectionItem(connectionItem);
|
||||
this.salesforceAPI = salesforceAPI;
|
||||
}
|
||||
|
||||
public AbstractSalesforceStepForm(Composite parent, ConnectionItem connectionItem, SalesforceModuleParseAPI salesforceAPI) {
|
||||
this(parent, connectionItem, null, salesforceAPI);
|
||||
}
|
||||
|
||||
public AbstractSalesforceStepForm(Composite parent, ConnectionItem connectionItem, MetadataTable metadataTable,
|
||||
String[] existingNames, SalesforceModuleParseAPI salesforceAPI) {
|
||||
super(parent, SWT.NONE, existingNames);
|
||||
setConnectionItem(connectionItem);
|
||||
this.salesforceAPI = salesforceAPI;
|
||||
}
|
||||
|
||||
protected SalesforceSchemaConnection getConnection() {
|
||||
return (SalesforceSchemaConnection) connectionItem.getConnection();
|
||||
}
|
||||
|
||||
public boolean isPerlProject() {
|
||||
ECodeLanguage codeLanguage = LanguageManager.getCurrentLanguage();
|
||||
return (codeLanguage == ECodeLanguage.PERL);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC YeXiaowei Comment method "getSalesforceComponent".
|
||||
*
|
||||
* @return Always not null
|
||||
*/
|
||||
public INode getSalesforceNode() {
|
||||
return CoreRuntimePlugin.getInstance().getDesignerCoreService().getRefrenceNode(tSalesforceUniqueName);
|
||||
}
|
||||
|
||||
public IMetadataTable getMetadatasForSalesforce(String endPoint, String user, String pass, String timeOut, String moduleName,
|
||||
String betchSize, boolean useProxy, boolean useHttp, String proxyHost, String proxyPort, String proxyUsername,
|
||||
String proxyPassword, boolean update) {
|
||||
|
||||
IMetadataTable result = null;
|
||||
String proxy = null;
|
||||
if (useProxy) {
|
||||
proxy = SalesforceModuleParseAPI.USE_SOCKS_PROXY;
|
||||
} else if (useHttp) {
|
||||
proxy = SalesforceModuleParseAPI.USE_HTTP_PROXY;
|
||||
}
|
||||
if (!moduleName.equals(salesforceAPI.getCurrentModuleName())) {
|
||||
result = getMetadataTableBySalesforceServerAPI(endPoint, user, pass, timeOut, moduleName, proxy, proxyHost,
|
||||
proxyPort, proxyUsername, proxyPassword);
|
||||
if (result == null) {
|
||||
result = getMetadataTableFromConfigFile(moduleName);
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
if (update) {
|
||||
result = getMetadataTableBySalesforceServerAPI(endPoint, user, pass, timeOut, moduleName, proxy, proxyHost,
|
||||
proxyPort, proxyUsername, proxyPassword);
|
||||
if (result == null) {
|
||||
result = getMetadataTableFromConfigFile(moduleName);
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
IMetadataTable metadataTable = new org.talend.core.model.metadata.MetadataTable();
|
||||
metadataTable.setListColumns(salesforceAPI.getCurrentMetadataColumns());
|
||||
return metadataTable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Field[] fetchSFDescriptionField(String module, org.talend.salesforce.SforceManagement sforceManagement) {
|
||||
|
||||
DescribeSObjectResult r;
|
||||
try {
|
||||
r = sforceManagement.describeSObject(module);
|
||||
Field[] fields = r.getFields();
|
||||
return fields;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private IMetadataColumn parseFieldToMetadataColumn(Field field) {
|
||||
|
||||
if (field == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IMetadataColumn mdColumn = new org.talend.core.model.metadata.MetadataColumn();
|
||||
|
||||
mdColumn.setLabel(field.getName());
|
||||
mdColumn.setKey(false);
|
||||
|
||||
String type = field.getType().toString();
|
||||
String talendType = "String"; //$NON-NLS-1$
|
||||
if (type.equals("boolean")) { //$NON-NLS-1$
|
||||
talendType = "Boolean"; //$NON-NLS-1$
|
||||
} else if (type.equals("int")) { //$NON-NLS-1$
|
||||
talendType = "Integer"; //$NON-NLS-1$
|
||||
} else if (type.equals("date") || type.equals("datetime")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
talendType = "Date"; //$NON-NLS-1$
|
||||
} else if (type.equals("double") || type.equals("currency")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
talendType = "Double"; //$NON-NLS-1$
|
||||
} else {
|
||||
talendType = "String"; //$NON-NLS-1$
|
||||
}
|
||||
// mdColumn.setType(talendType);
|
||||
mdColumn.setTalendType("id_" + talendType); // How to transfer type? TODO //$NON-NLS-1$
|
||||
// mdColumn.setNullable(field.isNillable());
|
||||
mdColumn.setNullable(field.getNillable());
|
||||
|
||||
if (type.equals("date")) { //$NON-NLS-1$
|
||||
mdColumn.setPattern("\"yyyy-MM-dd\""); //$NON-NLS-1$
|
||||
} else if (type.equals("datetime")) { //$NON-NLS-1$
|
||||
mdColumn.setPattern("\"yyyy-MM-dd\'T\'HH:mm:ss\'.000Z\'\""); //$NON-NLS-1$
|
||||
} else {
|
||||
mdColumn.setPattern(null);
|
||||
}
|
||||
if ("String".equals(talendType)) { //$NON-NLS-1$
|
||||
mdColumn.setLength(field.getLength());
|
||||
mdColumn.setPrecision(field.getPrecision());
|
||||
} else {
|
||||
mdColumn.setLength(field.getPrecision());
|
||||
mdColumn.setPrecision(field.getScale());
|
||||
}
|
||||
mdColumn.setDefault(field.getDefaultValueFormula());
|
||||
|
||||
return mdColumn;
|
||||
|
||||
}
|
||||
|
||||
private IMetadataTable getMetadataTableBySalesforceServerAPIForOauth(final String endPoint, final String consumeKey,
|
||||
final String consumeSecret, final String callbackHost, final String callbackPort, final String salesforceVersion,
|
||||
final String token, final String timeOut, final String moduleName) {
|
||||
IMetadataTable metadataTable = new org.talend.core.model.metadata.MetadataTable();
|
||||
if (consumeKey == null || consumeSecret == null
|
||||
|| consumeKey.equals("") || consumeSecret.equals("") || moduleName == null || moduleName.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
return null;
|
||||
}
|
||||
org.talend.salesforce.SforceManagement sforceManagement = null;
|
||||
try {
|
||||
OAuthClient client = new OAuthClient();
|
||||
client.setBaseOAuthURL(endPoint);
|
||||
client.setCallbackHost(callbackHost);
|
||||
client.setCallbackPort(Integer.parseInt(callbackPort));
|
||||
client.setClientID(consumeKey);
|
||||
client.setClientSecret(consumeSecret);
|
||||
Token tokenFile = salesforceAPI.login(endPoint, consumeKey, consumeSecret, callbackHost, callbackPort,
|
||||
salesforceVersion, token, timeOut);
|
||||
String url = OAuthClient.getSOAPEndpoint(tokenFile, salesforceVersion);
|
||||
SforceConnection sforceConn = new SforceSessionConnection.Builder(url, tokenFile.getAccess_token())
|
||||
.setTimeout(Integer.parseInt(timeOut)).needCompression(false).build();
|
||||
sforceManagement = new org.talend.salesforce.SforceManagementImpl(sforceConn);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
Field[] fields = fetchSFDescriptionField(moduleName, sforceManagement);
|
||||
List<IMetadataColumn> res = new ArrayList<IMetadataColumn>();
|
||||
for (Field field : fields) {
|
||||
res.add(parseFieldToMetadataColumn(field));
|
||||
}
|
||||
if (res.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
metadataTable.setListColumns(res);
|
||||
return metadataTable;
|
||||
}
|
||||
|
||||
private IMetadataTable getMetadataTableBySalesforceServerAPI(final String endPoint, final String user, final String pass,
|
||||
final String timeOut, final String moduleName, final String proxy, final String proxyHost, final String proxyPort,
|
||||
final String proxyUsername, final String proxyPassword) {
|
||||
IMetadataTable metadataTable = new org.talend.core.model.metadata.MetadataTable();
|
||||
|
||||
if (user == null || pass == null || user.equals("") || pass.equals("") || moduleName == null || moduleName.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
return null;
|
||||
}
|
||||
|
||||
// ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
|
||||
// try {
|
||||
// dialog.run(true, false, new IRunnableWithProgress() {
|
||||
//
|
||||
// public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
//
|
||||
// monitor.beginTask(Messages.getString("AbstractSalesforceStepForm.fetchModule", moduleName), //$NON-NLS-1$
|
||||
// IProgressMonitor.UNKNOWN);
|
||||
boolean socksProxy = false;
|
||||
boolean httpProxy = false;
|
||||
boolean httpsProxy = false;
|
||||
if (SalesforceModuleParseAPI.USE_SOCKS_PROXY.equals(proxy)) {
|
||||
socksProxy = true;
|
||||
}
|
||||
if (SalesforceModuleParseAPI.USE_HTTP_PROXY.equals(proxy)) {
|
||||
if (endPoint.startsWith("https")) {
|
||||
httpsProxy = true;
|
||||
} else {
|
||||
httpProxy = true;
|
||||
}
|
||||
|
||||
}
|
||||
salesforceAPI.resetAllProxy();
|
||||
salesforceAPI.setProxy(proxyHost, proxyPort, proxyUsername, proxyPassword, httpProxy, socksProxy, httpsProxy);
|
||||
if (!salesforceAPI.isLogin()) {
|
||||
try {
|
||||
|
||||
ArrayList loginList = salesforceAPI.login(endPoint, user, pass, timeOut);
|
||||
for (int i = 0; i < loginList.size(); i++) {
|
||||
if (loginList.get(i) instanceof SoapBindingStub) {
|
||||
binding = (SoapBindingStub) loginList.get(i);
|
||||
}
|
||||
if (loginList.get(i) instanceof SforceManagement) {
|
||||
sforceMgr = (SforceManagement) loginList.get(i);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
salesforceAPI.fetchMetaDataColumns(moduleName);
|
||||
salesforceAPI.resetAllProxy();
|
||||
// monitor.done();
|
||||
// }
|
||||
// });
|
||||
// } catch (InvocationTargetException e1) {
|
||||
// ExceptionHandler.process(e1);
|
||||
// } catch (InterruptedException e2) {
|
||||
// ExceptionHandler.process(e2);
|
||||
// }
|
||||
|
||||
if (salesforceAPI.getCurrentMetadataColumns() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
metadataTable.setListColumns(salesforceAPI.getCurrentMetadataColumns());
|
||||
return metadataTable;
|
||||
}
|
||||
|
||||
protected SalesforceModuleParseAPI checkSalesfoceLogin(final String proxy, final String endPoint, final String username,
|
||||
final String password, final String timeOut, final String proxyHost, final String proxyPort,
|
||||
final String proxyUsername, final String proxyPassword) {
|
||||
final List<String> errors = new ArrayList<String>();
|
||||
|
||||
salesforceAPI.setLogin(false);
|
||||
|
||||
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
|
||||
try {
|
||||
dialog.run(true, false, new IRunnableWithProgress() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
|
||||
monitor.beginTask(Messages.getString("AbstractSalesforceStepForm.tryToLogin"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
|
||||
|
||||
if (salesforceAPI == null) {
|
||||
try {
|
||||
salesforceAPI = new SalesforceModuleParseAPI();
|
||||
} catch (Throwable e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
boolean socksProxy = false;
|
||||
boolean httpProxy = false;
|
||||
boolean httpsProxy = false;
|
||||
if (SalesforceModuleParseAPI.USE_SOCKS_PROXY.equals(proxy)) {
|
||||
socksProxy = true;
|
||||
}
|
||||
if (SalesforceModuleParseAPI.USE_HTTP_PROXY.equals(proxy)) {
|
||||
if (endPoint.startsWith("https")) {
|
||||
httpsProxy = true;
|
||||
} else {
|
||||
httpProxy = true;
|
||||
}
|
||||
}
|
||||
salesforceAPI.resetAllProxy();
|
||||
|
||||
salesforceAPI.setProxy(proxyHost, proxyPort, proxyUsername, proxyPassword, httpProxy, socksProxy, httpsProxy);
|
||||
try {
|
||||
// binding ;
|
||||
ArrayList loginList = salesforceAPI.login(endPoint, username, password, timeOut);
|
||||
if (loginList != null) {
|
||||
for (int i = 0; i < loginList.size(); i++) {
|
||||
if (loginList.get(i) instanceof SoapBindingStub) {
|
||||
binding = (SoapBindingStub) loginList.get(i);
|
||||
}
|
||||
if (loginList.get(i) instanceof SforceManagement) {
|
||||
sforceMgr = (SforceManagement) loginList.get(i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
salesforceAPI.setLogin(true);
|
||||
} catch (Throwable e) {
|
||||
errors.add(e.getMessage());
|
||||
ExceptionHandler.process(e);
|
||||
} finally {
|
||||
salesforceAPI.resetAllProxy();
|
||||
}
|
||||
monitor.done();
|
||||
}
|
||||
});
|
||||
} catch (InvocationTargetException e1) {
|
||||
ExceptionHandler.process(e1);
|
||||
} catch (InterruptedException e2) {
|
||||
ExceptionHandler.process(e2);
|
||||
}
|
||||
|
||||
if (salesforceAPI.isLogin()) {
|
||||
MessageDialog.openInformation(getShell(), Messages.getString("SalesforceForm.checkConnectionTitle"), //$NON-NLS-1$
|
||||
Messages.getString("SalesforceForm.checkIsDone")); //$NON-NLS-1$
|
||||
} else {
|
||||
String mainMsg = Messages.getString("SalesforceForm.checkFailure") + " " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ Messages.getString("SalesforceForm.checkFailureTip"); //$NON-NLS-1$
|
||||
String error = errors.size() > 0 ? errors.get(0) : ""; //$NON-NLS-1$
|
||||
new ErrorDialogWidthDetailArea(getShell(), PID, mainMsg, error);
|
||||
}
|
||||
|
||||
return salesforceAPI;
|
||||
}
|
||||
|
||||
protected DescribeGlobalResult describeGlobal() throws UnexpectedErrorFault, RemoteException {
|
||||
if (salesforceAPI.isLogin()) {
|
||||
if (binding != null) {
|
||||
return binding.describeGlobal();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected com.salesforce.soap.partner.DescribeGlobalResult describeGlobalPartner() throws RemoteException {
|
||||
if (salesforceAPI.isLogin()) {
|
||||
ISalesforceModuleParser currentAPI = salesforceAPI.getCurrentAPI();
|
||||
if (currentAPI instanceof SalesforceModuleParserPartner) {
|
||||
SalesforceModuleParserPartner partner = (SalesforceModuleParserPartner) currentAPI;
|
||||
try {
|
||||
sforceMgr.describeSObjects(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private IMetadataTable getMetadataTableFromConfigFile(String moduleName) {
|
||||
|
||||
INode node = getSalesforceNode();
|
||||
|
||||
IElementParameter currentModuleNameParam = node.getElementParameter("MODULENAME"); //$NON-NLS-1$
|
||||
currentModuleNameParam.setValue(moduleName);
|
||||
|
||||
node.getComponent().createElementParameters(node);
|
||||
|
||||
IElementParameter schemaParam = node.getElementParameter("SCHEMA"); //$NON-NLS-1$
|
||||
|
||||
if (schemaParam == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
schemaParam.setValueToDefault(node.getElementParameters()); // Call this method to recompute some parameters
|
||||
// value.
|
||||
|
||||
IMetadataTable metadataTable = (IMetadataTable) schemaParam.getValue();
|
||||
|
||||
return metadataTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC zli Comment method "readMetadataDetail".
|
||||
*/
|
||||
public IMetadataTable readMetadataDetail() {
|
||||
SalesforceSchemaConnection connection2 = getConnection();
|
||||
String moduleName = connection2.getModuleName();
|
||||
|
||||
if (moduleName == null || moduleName.equals("")) { //$NON-NLS-1$
|
||||
return null;
|
||||
}
|
||||
|
||||
String webServiceUrl = connection2.getWebServiceUrl();
|
||||
String userName = connection2.getUserName();
|
||||
String password = connection2.getValue(connection2.getPassword(), false);
|
||||
String timeOut = connection2.getTimeOut();
|
||||
// add for feature 7507
|
||||
String betchSize = connection2.getBatchSize();
|
||||
boolean useProxy = connection2.isUseProxy();
|
||||
boolean useHttp = connection2.isUseHttpProxy();
|
||||
String proxyHost = connection2.getProxyHost();
|
||||
String proxyPort = connection2.getProxyPort();
|
||||
String proxyUsername = connection2.getProxyUsername();
|
||||
String proxyPassword = connection2.getValue(connection2.getProxyPassword(), false);
|
||||
|
||||
String webServiceUrlForOauth = connection2.getWebServiceUrlTextForOAuth();
|
||||
String comsumeKey = connection2.getConsumeKey();
|
||||
String consumeSecret = connection2.getValue(connection2.getConsumeSecret(), false);
|
||||
String callbackHost = connection2.getCallbackHost();
|
||||
String callbackPort = connection2.getCallbackPort();
|
||||
String salesforceVersion = connection2.getSalesforceVersion();
|
||||
String token = connection2.getToken();
|
||||
String loginType = connection2.getLoginType();
|
||||
|
||||
if (isContextMode() && getContextModeManager() != null) {
|
||||
webServiceUrl = getContextModeManager().getOriginalValue(webServiceUrl);
|
||||
userName = getContextModeManager().getOriginalValue(userName);
|
||||
password = getContextModeManager().getOriginalValue(password);
|
||||
timeOut = getContextModeManager().getOriginalValue(timeOut);
|
||||
betchSize = getContextModeManager().getOriginalValue(betchSize);
|
||||
useProxy = Boolean.valueOf(getContextModeManager().getOriginalValue(String.valueOf(useProxy)));
|
||||
useHttp = Boolean.valueOf(getContextModeManager().getOriginalValue(String.valueOf(useHttp)));
|
||||
proxyHost = getContextModeManager().getOriginalValue(proxyHost);
|
||||
proxyPort = getContextModeManager().getOriginalValue(proxyPort);
|
||||
proxyUsername = getContextModeManager().getOriginalValue(proxyUsername);
|
||||
proxyPassword = getContextModeManager().getOriginalValue(proxyPassword);
|
||||
|
||||
webServiceUrlForOauth = getContextModeManager().getOriginalValue(webServiceUrlForOauth);
|
||||
comsumeKey = getContextModeManager().getOriginalValue(comsumeKey);
|
||||
consumeSecret = getContextModeManager().getOriginalValue(consumeSecret);
|
||||
callbackHost = getContextModeManager().getOriginalValue(callbackHost);
|
||||
callbackPort = getContextModeManager().getOriginalValue(callbackPort);
|
||||
salesforceVersion = getContextModeManager().getOriginalValue(salesforceVersion);
|
||||
token = getContextModeManager().getOriginalValue(token);
|
||||
loginType = getContextModeManager().getOriginalValue(loginType);
|
||||
}
|
||||
|
||||
if (loginType.equalsIgnoreCase(BASIC)) {
|
||||
metadataTableOrder = getMetadatasForSalesforce(webServiceUrl, userName, password, timeOut, moduleName, betchSize,
|
||||
useProxy, useHttp, proxyHost, proxyPort, proxyUsername, proxyPassword, true);
|
||||
} else {
|
||||
metadataTableOrder = getMetadataTableBySalesforceServerAPIForOauth(webServiceUrlForOauth, comsumeKey, consumeSecret,
|
||||
callbackHost, callbackPort, salesforceVersion, token, timeOut, moduleName);
|
||||
if (metadataTableOrder == null) {
|
||||
metadataTableOrder = getMetadataTableFromConfigFile(moduleName);
|
||||
}
|
||||
}
|
||||
return metadataTableOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC zli Comment method "modifyMetadataTable".
|
||||
*/
|
||||
public IMetadataTable modifyMetadataTable() {
|
||||
if (metadataTableOrder != null) {
|
||||
List<IMetadataColumn> listColumns = metadataTableOrder.getListColumns();
|
||||
if (listColumns != null) {
|
||||
|
||||
Object[] array = listColumns.toArray();
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
for (int j = i + 1; j < array.length; j++) {
|
||||
|
||||
String labela = ((MetadataColumn) array[i]).getLabel();
|
||||
String labelb = ((MetadataColumn) array[j]).getLabel();
|
||||
if (labela.compareTo(labelb) > 0) {
|
||||
MetadataColumn metadataColumn = (MetadataColumn) array[i];
|
||||
array[i] = array[j];
|
||||
array[j] = metadataColumn;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<Object> asList = Arrays.asList(array);
|
||||
List<IMetadataColumn> aa = new ArrayList();
|
||||
if (asList != null && asList.size() > 0) {
|
||||
Object object = asList.get(0);
|
||||
if (object instanceof MetadataColumn) {
|
||||
for (int i = 0; i < asList.size(); i++) {
|
||||
aa.add(i, (MetadataColumn) asList.get(i));
|
||||
}
|
||||
metadataTableOrder.setListColumns(aa);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return metadataTableOrder;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.swt.utils.AbstractForm#adaptFormToReadOnly()
|
||||
*/
|
||||
@Override
|
||||
protected void adaptFormToReadOnly() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.swt.utils.AbstractForm#addFields()
|
||||
*/
|
||||
@Override
|
||||
protected void addFields() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.swt.utils.AbstractForm#addFieldsListeners()
|
||||
*/
|
||||
@Override
|
||||
protected void addFieldsListeners() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.swt.utils.AbstractForm#addUtilsButtonListeners()
|
||||
*/
|
||||
@Override
|
||||
protected void addUtilsButtonListeners() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.swt.utils.AbstractForm#checkFieldsValue()
|
||||
*/
|
||||
@Override
|
||||
protected boolean checkFieldsValue() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.swt.utils.AbstractForm#initialize()
|
||||
*/
|
||||
@Override
|
||||
protected void initialize() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for salesforceAPI.
|
||||
*
|
||||
* @return the salesforceAPI
|
||||
*/
|
||||
public SalesforceModuleParseAPI getSalesforceAPI() {
|
||||
return this.salesforceAPI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the salesforceAPI.
|
||||
*
|
||||
* @param salesforceAPI the salesforceAPI to set
|
||||
*/
|
||||
public void setSalesforceAPI(SalesforceModuleParseAPI salesforceAPI) {
|
||||
this.salesforceAPI = salesforceAPI;
|
||||
}
|
||||
|
||||
public IMetadataContextModeManager getContextModeManager() {
|
||||
return this.contextModeManager;
|
||||
}
|
||||
|
||||
public void setContextModeManager(IMetadataContextModeManager contextModeManager) {
|
||||
this.contextModeManager = contextModeManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC Administrator Comment method "getTableByLabel".
|
||||
*
|
||||
* @param label
|
||||
* @return
|
||||
*/
|
||||
protected MetadataTable getTableByLabel(String label) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.browser.Browser;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
|
||||
/**
|
||||
* DOC zwzhao class global comment. Detailled comment
|
||||
*/
|
||||
public class BrowerDialog extends Dialog {
|
||||
|
||||
private String url;
|
||||
|
||||
private Browser broswer;
|
||||
|
||||
/**
|
||||
* DOC zwzhao BrowerDialog constructor comment.
|
||||
*
|
||||
* @param parentShell
|
||||
*/
|
||||
protected BrowerDialog(Shell parentShell, String url) {
|
||||
super(parentShell);
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
Composite composite = (Composite) super.createDialogArea(parent);
|
||||
composite.setLayout(new GridLayout());
|
||||
broswer = new Browser(composite, SWT.NONE);
|
||||
if (url != null && !url.trim().isEmpty()) {
|
||||
// linux swt in eclipse4.10 has a bug that we can't pass empty string or null
|
||||
broswer.setUrl(url);
|
||||
} else {
|
||||
String message = Messages.getString("BrowerDialog.empryUrl");
|
||||
Exception e = new Exception(message);
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
broswer.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
broswer.redraw();
|
||||
composite.redraw();
|
||||
return parent;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
|
||||
*/
|
||||
@Override
|
||||
protected Point getInitialSize() {
|
||||
// TODO Auto-generated method stub
|
||||
return new Point(1000, 800);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for broswer.
|
||||
*
|
||||
* @return the broswer
|
||||
*/
|
||||
public Browser getBroswer() {
|
||||
return this.broswer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the broswer.
|
||||
*
|
||||
* @param broswer the broswer to set
|
||||
*/
|
||||
public void setBroswer(Browser broswer) {
|
||||
this.broswer = broswer;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
@Override
|
||||
protected void createButtonsForButtonBar(Composite parent) {
|
||||
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
|
||||
/**
|
||||
* DOC informix class global comment. Detailled comment
|
||||
*/
|
||||
public interface ISalesforceModuleParser {
|
||||
|
||||
ArrayList login(String endPoint, String username, String password) throws Exception;
|
||||
|
||||
ArrayList login(String endPoint, String username, String password, String timeOut) throws Exception;
|
||||
|
||||
void describeGlobalSample();
|
||||
|
||||
/**
|
||||
* Fetch a module from SF and transfor to Talend metadata data type. DOC YeXiaowei Comment method
|
||||
* "fetchMetaDataColumns".
|
||||
*
|
||||
* @param module
|
||||
* @return
|
||||
*/
|
||||
List<IMetadataColumn> fetchMetaDataColumns(String module);
|
||||
|
||||
/**
|
||||
* Getter for login.
|
||||
*
|
||||
* @return the login
|
||||
*/
|
||||
boolean isLogin();
|
||||
|
||||
/**
|
||||
* Sets the login.
|
||||
*
|
||||
* @param login the login to set
|
||||
*/
|
||||
void setLogin(boolean login);
|
||||
|
||||
/**
|
||||
* Getter for currentModuleName.
|
||||
*
|
||||
* @return the currentModuleName
|
||||
*/
|
||||
String getCurrentModuleName();
|
||||
|
||||
/**
|
||||
* Sets the currentModuleName.
|
||||
*
|
||||
* @param currentModuleName the currentModuleName to set
|
||||
*/
|
||||
void setCurrentModuleName(String currentModuleName);
|
||||
|
||||
/**
|
||||
* Getter for currentMetadataColumns.
|
||||
*
|
||||
* @return the currentMetadataColumns
|
||||
*/
|
||||
List<IMetadataColumn> getCurrentMetadataColumns();
|
||||
|
||||
/**
|
||||
* Sets the currentMetadataColumns.
|
||||
*
|
||||
* @param currentMetadataColumns the currentMetadataColumns to set
|
||||
*/
|
||||
void setCurrentMetadataColumns(List<IMetadataColumn> currentMetadataColumns);
|
||||
|
||||
}
|
||||
@@ -1,324 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import org.talend.salesforce.oauth.OAuthClient;
|
||||
import org.talend.salesforce.oauth.Token;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
|
||||
/**
|
||||
* Maybe need a long connection ...
|
||||
* <p>
|
||||
* DOC YeXiaowei class global comment. Detailled comment <br/>
|
||||
*
|
||||
*/
|
||||
public class SalesforceModuleParseAPI {
|
||||
|
||||
public static final String SOCKS_PROXY_HOST = "socksProxyHost"; //$NON-NLS-1$
|
||||
|
||||
public static final String SOCKS_PROXY_PORT = "socksProxyPort"; //$NON-NLS-1$
|
||||
|
||||
public static final String SOCKS_PROXY_USERNAME = "java.net.socks.username"; //$NON-NLS-1$
|
||||
|
||||
public static final String SOCKS_PROXY_PASSWORD = "java.net.socks.password"; //$NON-NLS-1$
|
||||
|
||||
public static final String HTTP_PROXY_HOST = "http.proxyHost"; //$NON-NLS-1$
|
||||
|
||||
public static final String HTTP_PROXY_PORT = "http.proxyPort"; //$NON-NLS-1$
|
||||
|
||||
public static final String HTTP_PROXY_USER = "http.proxyUser";//$NON-NLS-1$
|
||||
|
||||
public static final String HTTP_PROXY_PASSWORD = "http.proxyPassword";//$NON-NLS-1$
|
||||
|
||||
public static final String HTTP_PROXY_SET = "http.proxySet";//$NON-NLS-1$
|
||||
|
||||
public static final String USE_SOCKS_PROXY = "useProxyBtn";
|
||||
|
||||
public static final String USE_HTTP_PROXY = "useHttpBtn";
|
||||
|
||||
public static final String HTTPS_PROXY_HOST = "https.proxyHost"; //$NON-NLS-1$
|
||||
|
||||
public static final String HTTPS_PROXY_PORT = "https.proxyPort"; //$NON-NLS-1$
|
||||
|
||||
public static final String HTTPS_PROXY_USER = "https.proxyUser";//$NON-NLS-1$
|
||||
|
||||
public static final String HTTPS_PROXY_PASSWORD = "https.proxyPassword";//$NON-NLS-1$
|
||||
|
||||
public static final String HTTPS_PROXY_SET = "https.proxySet";//$NON-NLS-1$
|
||||
|
||||
// public static final String FTP_PROXY_HOST = "FtpproxyHost"; //$NON-NLS-1$
|
||||
//
|
||||
// public static final String FTP_PROXY_PORT = "Ftpproxyport"; //$NON-NLS-1$
|
||||
//
|
||||
// public static final String FTP_PROXY_USER = "FtpproxyUser";//$NON-NLS-1$
|
||||
//
|
||||
// public static final String FTP_PROXY_PASSWORD = "FtpproxyPassword";//$NON-NLS-1$
|
||||
//
|
||||
// public static final String FTP_PROXY_SET = "FtpproxySet";//$NON-NLS-1$
|
||||
|
||||
private String oldProxyHost;
|
||||
|
||||
private String oldProxyPort;
|
||||
|
||||
private String oldProxyUser;
|
||||
|
||||
private String oldProxyPwd;
|
||||
|
||||
private String oldHttpProxySet;
|
||||
|
||||
private String oldHttpsProxySet;
|
||||
|
||||
private boolean oldSocksProxySet;
|
||||
|
||||
private boolean login;
|
||||
|
||||
private ISalesforceModuleParser currentAPI;
|
||||
|
||||
public Token login(String endPointForAuth, String consumerKey, String consumeSecret, String callbackHost,
|
||||
String callbackPort, String salesforceVersion, String tokenProperties, String timeOut) throws Exception {
|
||||
OAuthClient client = new OAuthClient();
|
||||
client.setBaseOAuthURL(endPointForAuth);
|
||||
client.setCallbackHost(callbackHost);
|
||||
client.setCallbackPort(Integer.parseInt(callbackPort));
|
||||
client.setClientID(consumerKey);
|
||||
client.setClientSecret(consumeSecret);
|
||||
|
||||
File tokenFile = new File(tokenProperties);
|
||||
if (tokenFile.exists()) {
|
||||
InputStream inputStream = null;
|
||||
InputStreamReader input = null;
|
||||
BufferedReader reader = null;
|
||||
String tokenMessage = null;
|
||||
java.util.Properties properties = new java.util.Properties();
|
||||
FileInputStream inStream = new FileInputStream(tokenProperties);
|
||||
properties.load(inStream);
|
||||
tokenMessage = properties.getProperty("refreshtoken");
|
||||
inStream.close();
|
||||
Token token = client.refreshToken(tokenMessage);
|
||||
return token;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC YeXiaowei Comment method "login".
|
||||
*/
|
||||
public ArrayList login(String endPoint, String username, String password) throws Exception {
|
||||
ArrayList returnValues;
|
||||
currentAPI = new SalesforceModuleParseEnterprise();
|
||||
currentAPI.setLogin(login);
|
||||
try {
|
||||
returnValues = currentAPI.login(endPoint, username, password);
|
||||
} catch (IOException e) {
|
||||
currentAPI = new SalesforceModuleParserPartner();
|
||||
currentAPI.setLogin(login);
|
||||
returnValues = currentAPI.login(endPoint, username, password);
|
||||
}
|
||||
return returnValues;
|
||||
}
|
||||
|
||||
public ArrayList login(String endPoint, String username, String password, String timeOut) throws Exception {
|
||||
ArrayList returnValues;
|
||||
currentAPI = new SalesforceModuleParseEnterprise();
|
||||
currentAPI.setLogin(login);
|
||||
try {
|
||||
returnValues = currentAPI.login(endPoint, username, password);
|
||||
} catch (IOException e) {
|
||||
currentAPI = new SalesforceModuleParserPartner();
|
||||
currentAPI.setLogin(login);
|
||||
returnValues = currentAPI.login(endPoint, username, password, timeOut);
|
||||
}
|
||||
login = true;
|
||||
return returnValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a module from SF and transfor to Talend metadata data type. DOC YeXiaowei Comment method
|
||||
* "fetchMetaDataColumns".
|
||||
*
|
||||
* @param module
|
||||
* @return
|
||||
*/
|
||||
public List<IMetadataColumn> fetchMetaDataColumns(String module) {
|
||||
return currentAPI.fetchMetaDataColumns(module);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for login.
|
||||
*
|
||||
* @return the login
|
||||
*/
|
||||
public boolean isLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the login.
|
||||
*
|
||||
* @param login the login to set
|
||||
*/
|
||||
public void setLogin(boolean login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for currentModuleName.
|
||||
*
|
||||
* @return the currentModuleName
|
||||
*/
|
||||
public String getCurrentModuleName() {
|
||||
if (currentAPI != null) {
|
||||
return currentAPI.getCurrentModuleName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the currentModuleName.
|
||||
*
|
||||
* @param currentModuleName the currentModuleName to set
|
||||
*/
|
||||
public void setCurrentModuleName(String currentModuleName) {
|
||||
currentAPI.setCurrentModuleName(currentModuleName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for currentMetadataColumns.
|
||||
*
|
||||
* @return the currentMetadataColumns
|
||||
*/
|
||||
public List<IMetadataColumn> getCurrentMetadataColumns() {
|
||||
return currentAPI.getCurrentMetadataColumns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the currentMetadataColumns.
|
||||
*
|
||||
* @param currentMetadataColumns the currentMetadataColumns to set
|
||||
*/
|
||||
public void setCurrentMetadataColumns(List<IMetadataColumn> currentMetadataColumns) {
|
||||
currentAPI.setCurrentMetadataColumns(currentMetadataColumns);
|
||||
}
|
||||
|
||||
public ISalesforceModuleParser getCurrentAPI() {
|
||||
return this.currentAPI;
|
||||
}
|
||||
|
||||
public void setProxy(String proxyHost, String proxyPort, String proxyUsername, String proxyPassword, boolean httpProxy,
|
||||
boolean socksProxy, boolean httpsProxy) {
|
||||
Properties properties = System.getProperties();
|
||||
if (socksProxy && proxyHost != null && proxyPort != null) { //$NON-NLS-1$
|
||||
if (properties.containsKey(SalesforceModuleParseAPI.SOCKS_PROXY_HOST)) {
|
||||
oldProxyHost = (String) properties.get(SalesforceModuleParseAPI.SOCKS_PROXY_HOST);
|
||||
oldProxyPort = (String) properties.get(SalesforceModuleParseAPI.SOCKS_PROXY_PORT);
|
||||
oldProxyUser = (String) properties.get(SalesforceModuleParseAPI.SOCKS_PROXY_USERNAME);
|
||||
oldProxyPwd = (String) properties.get(SalesforceModuleParseAPI.SOCKS_PROXY_PASSWORD);
|
||||
oldSocksProxySet = true;
|
||||
} else {
|
||||
oldSocksProxySet = false;
|
||||
}
|
||||
properties.put(SalesforceModuleParseAPI.SOCKS_PROXY_HOST, proxyHost);
|
||||
properties.put(SalesforceModuleParseAPI.SOCKS_PROXY_PORT, proxyPort);
|
||||
properties.put(SalesforceModuleParseAPI.SOCKS_PROXY_USERNAME, proxyUsername == null ? "" : proxyUsername); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.SOCKS_PROXY_PASSWORD, proxyPassword == null ? "" : proxyPassword); //$NON-NLS-1$
|
||||
} else if (httpProxy && proxyHost != null && proxyPort != null) { //$NON-NLS-1$
|
||||
if (properties.containsKey(SalesforceModuleParseAPI.HTTP_PROXY_HOST)) {
|
||||
oldHttpProxySet = (String) properties.get(SalesforceModuleParseAPI.HTTP_PROXY_SET);
|
||||
oldProxyHost = (String) properties.get(SalesforceModuleParseAPI.HTTP_PROXY_HOST);
|
||||
oldProxyPort = (String) properties.get(SalesforceModuleParseAPI.HTTP_PROXY_PORT);
|
||||
oldProxyUser = (String) properties.get(SalesforceModuleParseAPI.HTTP_PROXY_USER);
|
||||
oldProxyPwd = (String) properties.get(SalesforceModuleParseAPI.HTTP_PROXY_PASSWORD);
|
||||
} else {
|
||||
oldHttpProxySet = "false";
|
||||
}
|
||||
properties.put(SalesforceModuleParseAPI.HTTP_PROXY_SET, "true"); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.HTTP_PROXY_HOST, proxyHost);
|
||||
properties.put(SalesforceModuleParseAPI.HTTP_PROXY_PORT, proxyPort);
|
||||
properties.put(SalesforceModuleParseAPI.HTTP_PROXY_USER, proxyUsername == null ? "" : proxyUsername); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.HTTP_PROXY_PASSWORD, proxyPassword == null ? "" : proxyPassword); //$NON-NLS-1$
|
||||
} else if (httpsProxy && proxyHost != null && proxyPort != null) {
|
||||
if (properties.containsKey(SalesforceModuleParseAPI.HTTP_PROXY_HOST)) {
|
||||
oldHttpsProxySet = (String) properties.get(SalesforceModuleParseAPI.HTTPS_PROXY_SET);
|
||||
oldProxyHost = (String) properties.get(SalesforceModuleParseAPI.HTTPS_PROXY_HOST);
|
||||
oldProxyPort = (String) properties.get(SalesforceModuleParseAPI.HTTPS_PROXY_PORT);
|
||||
oldProxyUser = (String) properties.get(SalesforceModuleParseAPI.HTTPS_PROXY_USER);
|
||||
oldProxyPwd = (String) properties.get(SalesforceModuleParseAPI.HTTPS_PROXY_PASSWORD);
|
||||
} else {
|
||||
oldHttpsProxySet = "false";
|
||||
}
|
||||
properties.put(SalesforceModuleParseAPI.HTTPS_PROXY_SET, "true"); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.HTTPS_PROXY_HOST, proxyHost);
|
||||
properties.put(SalesforceModuleParseAPI.HTTPS_PROXY_PORT, proxyPort);
|
||||
properties.put(SalesforceModuleParseAPI.HTTPS_PROXY_USER, proxyUsername == null ? "" : proxyUsername); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.HTTPS_PROXY_PASSWORD, proxyPassword == null ? "" : proxyPassword); //$NON-NLS-1$
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void resetAllProxy() {
|
||||
Properties properties = System.getProperties();
|
||||
if (properties.containsKey(SalesforceModuleParseAPI.SOCKS_PROXY_HOST) && oldSocksProxySet) {
|
||||
properties.put(SalesforceModuleParseAPI.SOCKS_PROXY_HOST, oldProxyHost); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.SOCKS_PROXY_PORT, oldProxyPort); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.SOCKS_PROXY_USERNAME, oldProxyUser); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.SOCKS_PROXY_PASSWORD, oldProxyPwd); //$NON-NLS-1$
|
||||
} else {
|
||||
properties.remove(SalesforceModuleParseAPI.SOCKS_PROXY_HOST); //$NON-NLS-1$
|
||||
properties.remove(SalesforceModuleParseAPI.SOCKS_PROXY_PORT); //$NON-NLS-1$
|
||||
properties.remove(SalesforceModuleParseAPI.SOCKS_PROXY_USERNAME); //$NON-NLS-1$
|
||||
properties.remove(SalesforceModuleParseAPI.SOCKS_PROXY_PASSWORD); //$NON-NLS-1$
|
||||
|
||||
}
|
||||
|
||||
if (properties.containsKey(SalesforceModuleParseAPI.HTTP_PROXY_SET) && "true".equals(oldHttpProxySet)) {
|
||||
properties.put(SalesforceModuleParseAPI.HTTP_PROXY_SET, oldHttpProxySet); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.HTTP_PROXY_HOST, oldProxyHost); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.HTTP_PROXY_PORT, oldProxyPort); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.HTTP_PROXY_USER, oldProxyUser); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.HTTP_PROXY_PASSWORD, oldProxyPwd); //$NON-NLS-1$
|
||||
} else {
|
||||
properties.remove(SalesforceModuleParseAPI.HTTP_PROXY_SET); //$NON-NLS-1$
|
||||
properties.remove(SalesforceModuleParseAPI.HTTP_PROXY_HOST); //$NON-NLS-1$
|
||||
properties.remove(SalesforceModuleParseAPI.HTTP_PROXY_PORT); //$NON-NLS-1$
|
||||
properties.remove(SalesforceModuleParseAPI.HTTP_PROXY_USER); //$NON-NLS-1$
|
||||
properties.remove(SalesforceModuleParseAPI.HTTP_PROXY_PASSWORD); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
if (properties.containsKey(SalesforceModuleParseAPI.HTTPS_PROXY_SET) && "true".equals(oldHttpsProxySet)) {
|
||||
properties.put(SalesforceModuleParseAPI.HTTPS_PROXY_SET, oldHttpsProxySet); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.HTTPS_PROXY_HOST, oldProxyHost); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.HTTPS_PROXY_PORT, oldProxyPort); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.HTTPS_PROXY_USER, oldProxyUser); //$NON-NLS-1$
|
||||
properties.put(SalesforceModuleParseAPI.HTTPS_PROXY_PASSWORD, oldProxyPwd); //$NON-NLS-1$
|
||||
} else {
|
||||
properties.remove(SalesforceModuleParseAPI.HTTPS_PROXY_SET); //$NON-NLS-1$
|
||||
properties.remove(SalesforceModuleParseAPI.HTTPS_PROXY_HOST); //$NON-NLS-1$
|
||||
properties.remove(SalesforceModuleParseAPI.HTTPS_PROXY_PORT); //$NON-NLS-1$
|
||||
properties.remove(SalesforceModuleParseAPI.HTTPS_PROXY_USER); //$NON-NLS-1$
|
||||
properties.remove(SalesforceModuleParseAPI.HTTPS_PROXY_PASSWORD); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,454 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.rpc.ServiceException;
|
||||
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
|
||||
import com.sforce.soap.enterprise.DescribeGlobalResult;
|
||||
import com.sforce.soap.enterprise.DescribeSObjectResult;
|
||||
import com.sforce.soap.enterprise.Field;
|
||||
import com.sforce.soap.enterprise.LoginResult;
|
||||
import com.sforce.soap.enterprise.QueryResult;
|
||||
import com.sforce.soap.enterprise.SessionHeader;
|
||||
import com.sforce.soap.enterprise.SforceServiceLocator;
|
||||
import com.sforce.soap.enterprise.SoapBindingStub;
|
||||
import com.sforce.soap.enterprise.fault.UnexpectedErrorFault;
|
||||
import com.sforce.soap.enterprise.sobject.Account;
|
||||
import com.sforce.soap.enterprise.sobject.SObject;
|
||||
|
||||
/**
|
||||
* Maybe need a long connection ...
|
||||
* <p>
|
||||
* DOC YeXiaowei class global comment. Detailled comment <br/>
|
||||
*
|
||||
*/
|
||||
public class SalesforceModuleParseEnterprise implements ISalesforceModuleParser {
|
||||
|
||||
final String useProxy = "useProxyBtn"; //$NON-NLS-1$
|
||||
|
||||
private String url = null;
|
||||
|
||||
private String name = null;
|
||||
|
||||
private String pwd = null;
|
||||
|
||||
private String proxy = null;
|
||||
|
||||
private boolean loginOk = false;
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
// private String proxyHost = null;
|
||||
//
|
||||
// private String proxyPort = null;
|
||||
//
|
||||
// private String proxyUsername = null;
|
||||
//
|
||||
// private String proxyPassword = null;
|
||||
|
||||
private SoapBindingStub binding = null;
|
||||
|
||||
private LoginResult loginResult = null; // maintain the login results
|
||||
|
||||
private Account[] accounts = null;
|
||||
|
||||
private String currentModuleName = null;
|
||||
|
||||
private List<IMetadataColumn> currentMetadataColumns = null;
|
||||
|
||||
private List list = null;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.repository.ui.wizards.metadata.connection.files.salesforce.ISalesforceModuleParser#login(java.lang
|
||||
* .String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String,
|
||||
* java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ArrayList login(String endPoint, String username, String password) throws Exception {
|
||||
if (endPoint == null) {
|
||||
throw new RemoteException(Messages.getString("SalesforceModuleParseAPI.URLInvalid")); //$NON-NLS-1$
|
||||
}
|
||||
if (username == null || password == null) {
|
||||
throw new Exception(Messages.getString("SalesforceModuleParseAPI.lostUsernameOrPass")); //$NON-NLS-1$
|
||||
}
|
||||
ArrayList doLoginList = null;
|
||||
if (name != null && pwd != null && url != null) {
|
||||
if (!url.equals(endPoint) || !name.equals(username) || !pwd.equals(password)) {
|
||||
doLoginList = doLogin(endPoint, username, password);
|
||||
|
||||
} else {
|
||||
if (isLogin()) {
|
||||
return doLoginList;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
doLoginList = doLogin(endPoint, username, password);
|
||||
}
|
||||
|
||||
this.name = username;
|
||||
this.pwd = password;
|
||||
this.url = endPoint;
|
||||
return doLoginList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList login(String endPoint, String username, String password, String timeOut) throws Exception {
|
||||
if (endPoint == null) {
|
||||
throw new RemoteException(Messages.getString("SalesforceModuleParseAPI.URLInvalid")); //$NON-NLS-1$
|
||||
}
|
||||
if (username == null || password == null) {
|
||||
throw new Exception(Messages.getString("SalesforceModuleParseAPI.lostUsernameOrPass")); //$NON-NLS-1$
|
||||
}
|
||||
ArrayList doLoginList = null;
|
||||
if (name != null && pwd != null && url != null) {
|
||||
if (!url.equals(endPoint) || !name.equals(username) || !pwd.equals(password)) {
|
||||
doLoginList = doLogin(endPoint, username, password);
|
||||
|
||||
} else {
|
||||
if (isLogin()) {
|
||||
return doLoginList;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
doLoginList = doLogin(endPoint, username, password);
|
||||
}
|
||||
|
||||
this.name = username;
|
||||
this.pwd = password;
|
||||
this.url = endPoint;
|
||||
return doLoginList;
|
||||
}
|
||||
|
||||
private boolean checkString(String str1, String str2) {
|
||||
if (str1 == str2) {
|
||||
return true;
|
||||
}
|
||||
if (str1 != null && str2 != null) {
|
||||
return str1.equals(str2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected ArrayList doLogin(String endPoint, String userName, String pwd) throws RemoteException, ServiceException,
|
||||
MalformedURLException {
|
||||
|
||||
try {
|
||||
URL soapAddress = new java.net.URL(endPoint);
|
||||
binding = (SoapBindingStub) new SforceServiceLocator().getSoap(soapAddress);
|
||||
|
||||
loginResult = binding.login(userName, pwd);
|
||||
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
setLogin(true);
|
||||
// on a successful login, you should always set up your session id
|
||||
// and the url for subsequent calls
|
||||
|
||||
// reset the url endpoint property, this will cause subsequent calls
|
||||
// to made to the serverURL from the login result
|
||||
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());
|
||||
|
||||
// create a session head object
|
||||
SessionHeader sh = new SessionHeader();
|
||||
// set the sessionId property on the header object using
|
||||
// the value from the login result
|
||||
sh.setSessionId(loginResult.getSessionId());
|
||||
// add the header to the binding stub
|
||||
String sforceURI = new SforceServiceLocator().getServiceName().getNamespaceURI();
|
||||
binding.setHeader(sforceURI, "SessionHeader", sh); //$NON-NLS-1$
|
||||
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.add(binding);
|
||||
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private void doGetAccounts() {
|
||||
// check to see if we are already logged in
|
||||
if (loginResult == null) {
|
||||
System.out.println("Run the login sample before the others.\n"); //$NON-NLS-1$
|
||||
System.out.println("\n"); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
// create a variable to hold the query result
|
||||
QueryResult qr = null;
|
||||
// call the query saving the results in qr
|
||||
try {
|
||||
qr = binding.query("select Name, numberOfEmployees, Id, Industry from Account"); //$NON-NLS-1$
|
||||
} catch (UnexpectedErrorFault uef) {
|
||||
System.out.println(uef.getExceptionMessage() + "\n\n"); //$NON-NLS-1$
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
ExceptionHandler.process(e);
|
||||
System.out.println("\n\n"); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
// always a good idea
|
||||
if (qr != null) {
|
||||
SObject[] records = qr.getRecords();
|
||||
accounts = new Account[records.length];
|
||||
// we can loop through the returned records
|
||||
for (int i = 0; i < records.length; i++) {
|
||||
// Because we asked for accounts we will convert
|
||||
// the SObject for each record into an Account object
|
||||
Account account = (Account) records[i];
|
||||
accounts[i] = account;
|
||||
// Now we can access any of the fields we had in the query
|
||||
// select clause directly from the account variable
|
||||
System.out.print(new Integer(i).toString() + ". "); //$NON-NLS-1$
|
||||
System.out.print(account.getName() + " - "); //$NON-NLS-1$
|
||||
System.out.println(account.getId());
|
||||
}
|
||||
System.out.println(""); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.repository.ui.wizards.metadata.connection.files.salesforce.ISalesforceModuleParser#describeGlobalSample
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public void describeGlobalSample() {
|
||||
try {
|
||||
DescribeGlobalResult describeGlobalResult = null;
|
||||
describeGlobalResult = binding.describeGlobal();
|
||||
String[] types = describeGlobalResult.getTypes();
|
||||
for (String type : types) {
|
||||
System.out.println(type);
|
||||
}
|
||||
System.out.println("\nDescribe global was successful...\r\n"); //$NON-NLS-1$
|
||||
} catch (Exception ex) {
|
||||
System.out.println("\nFailed to return types, error message was: \n" + ex.getMessage()); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.repository.ui.wizards.metadata.connection.files.salesforce.ISalesforceModuleParser#fetchMetaDataColumns
|
||||
* (java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public List<IMetadataColumn> fetchMetaDataColumns(String module) {
|
||||
Field[] fields = fetchSFDescriptionField(module);
|
||||
|
||||
if (fields == null || fields.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<IMetadataColumn> res = new ArrayList<IMetadataColumn>();
|
||||
for (Field field : fields) {
|
||||
res.add(parseFieldToMetadataColumn(field));
|
||||
}
|
||||
|
||||
setCurrentMetadataColumns(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch module fields from SF service. Make sure login sucess before do this.
|
||||
* <p>
|
||||
* DOC YeXiaowei Comment method "fetchSFDescriptionField".
|
||||
*
|
||||
* @param module
|
||||
* @return
|
||||
*/
|
||||
private Field[] fetchSFDescriptionField(String module) {
|
||||
try {
|
||||
// Invoke describeSObject and save results in DescribeSObjectResult
|
||||
DescribeSObjectResult describeSObjectResult = binding.describeSObject(module);
|
||||
// Determine whether the describeSObject call succeeded.
|
||||
if (!(describeSObjectResult == null)) {
|
||||
// Retrieve fields from the results
|
||||
Field[] fields = describeSObjectResult.getFields();
|
||||
// Get the name of the object
|
||||
String objectName = describeSObjectResult.getName();
|
||||
// Get some flags
|
||||
boolean isActivateable = describeSObjectResult.isActivateable();
|
||||
// Many other values are accessible
|
||||
setCurrentModuleName(module);
|
||||
return fields;
|
||||
}
|
||||
setCurrentModuleName(null);
|
||||
return null;
|
||||
} catch (Exception ex) {
|
||||
setCurrentModuleName(null);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse SF field to Talend data type
|
||||
* <p>
|
||||
* DOC YeXiaowei Comment method "parseFieldToMetadataColumn".
|
||||
*
|
||||
* @param field
|
||||
* @return
|
||||
*/
|
||||
private IMetadataColumn parseFieldToMetadataColumn(Field field) {
|
||||
|
||||
if (field == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IMetadataColumn mdColumn = new org.talend.core.model.metadata.MetadataColumn();
|
||||
|
||||
mdColumn.setLabel(field.getName());
|
||||
mdColumn.setKey(false);
|
||||
|
||||
// public static final java.lang.String _value1 = "string";
|
||||
// public static final java.lang.String _value2 = "picklist";
|
||||
// public static final java.lang.String _value3 = "multipicklist";
|
||||
// public static final java.lang.String _value4 = "combobox";
|
||||
// public static final java.lang.String _value5 = "reference";
|
||||
// public static final java.lang.String _value6 = "base64";
|
||||
// public static final java.lang.String _value7 = "boolean";
|
||||
// public static final java.lang.String _value8 = "currency";
|
||||
// public static final java.lang.String _value9 = "textarea";
|
||||
// public static final java.lang.String _value10 = "int";
|
||||
// public static final java.lang.String _value11 = "double";
|
||||
// public static final java.lang.String _value12 = "percent";
|
||||
// public static final java.lang.String _value13 = "phone";
|
||||
// public static final java.lang.String _value14 = "id";
|
||||
// public static final java.lang.String _value15 = "date";
|
||||
// public static final java.lang.String _value16 = "datetime";
|
||||
// public static final java.lang.String _value17 = "url";
|
||||
// public static final java.lang.String _value18 = "email";
|
||||
// public static final java.lang.String _value19 = "anyType";
|
||||
|
||||
String type = field.getType().toString();
|
||||
String talendType = "String"; //$NON-NLS-1$
|
||||
if (type.equals("boolean")) { //$NON-NLS-1$
|
||||
talendType = "Boolean"; //$NON-NLS-1$
|
||||
} else if (type.equals("int")) { //$NON-NLS-1$
|
||||
talendType = "Integer"; //$NON-NLS-1$
|
||||
} else if (type.equals("date") || type.equals("datetime")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
talendType = "Date"; //$NON-NLS-1$
|
||||
} else if (type.equals("double") || type.equals("currency")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
talendType = "Double"; //$NON-NLS-1$
|
||||
} else {
|
||||
talendType = "String"; //$NON-NLS-1$
|
||||
}
|
||||
// mdColumn.setType(talendType);
|
||||
mdColumn.setTalendType("id_" + talendType); // How to transfer type? TODO //$NON-NLS-1$
|
||||
mdColumn.setNullable(field.isNillable());
|
||||
|
||||
if (type.equals("date")) { //$NON-NLS-1$
|
||||
mdColumn.setPattern("\"yyyy-MM-dd\""); //$NON-NLS-1$
|
||||
} else if (type.equals("datetime")) { //$NON-NLS-1$
|
||||
mdColumn.setPattern("\"yyyy-MM-dd\'T\'HH:mm:ss\'.000Z\'\""); //$NON-NLS-1$
|
||||
} else {
|
||||
mdColumn.setPattern(null);
|
||||
}
|
||||
if ("String".equals(talendType)) { //$NON-NLS-1$
|
||||
mdColumn.setLength(field.getLength());
|
||||
mdColumn.setPrecision(field.getPrecision());
|
||||
} else {
|
||||
mdColumn.setLength(field.getPrecision());
|
||||
mdColumn.setPrecision(field.getScale());
|
||||
}
|
||||
mdColumn.setDefault(field.getDefaultValueFormula());
|
||||
|
||||
return mdColumn;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.wizards.metadata.connection.files.salesforce.ISalesforceModuleParser#isLogin()
|
||||
*/
|
||||
@Override
|
||||
public boolean isLogin() {
|
||||
return this.loginOk;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.repository.ui.wizards.metadata.connection.files.salesforce.ISalesforceModuleParser#setLogin(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setLogin(boolean login) {
|
||||
this.loginOk = login;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.repository.ui.wizards.metadata.connection.files.salesforce.ISalesforceModuleParser#getCurrentModuleName
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public String getCurrentModuleName() {
|
||||
return this.currentModuleName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.talend.repository.ui.wizards.metadata.connection.files.salesforce.ISalesforceModuleParser#setCurrentModuleName
|
||||
* (java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setCurrentModuleName(String currentModuleName) {
|
||||
this.currentModuleName = currentModuleName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.talend.repository.ui.wizards.metadata.connection.files.salesforce.ISalesforceModuleParser#
|
||||
* getCurrentMetadataColumns()
|
||||
*/
|
||||
@Override
|
||||
public List<IMetadataColumn> getCurrentMetadataColumns() {
|
||||
return this.currentMetadataColumns;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.talend.repository.ui.wizards.metadata.connection.files.salesforce.ISalesforceModuleParser#
|
||||
* setCurrentMetadataColumns(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void setCurrentMetadataColumns(List<IMetadataColumn> currentMetadataColumns) {
|
||||
this.currentMetadataColumns = currentMetadataColumns;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,442 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
import org.talend.salesforce.SforceBasicConnection;
|
||||
import org.talend.salesforce.SforceConnection;
|
||||
import org.talend.salesforce.SforceManagementImpl;
|
||||
|
||||
import com.salesforce.soap.partner.DescribeSObjectResult;
|
||||
import com.salesforce.soap.partner.Field;
|
||||
|
||||
/**
|
||||
* Maybe need a long connection ...
|
||||
* <p>
|
||||
* DOC YeXiaowei class global comment. Detailled comment <br/>
|
||||
*
|
||||
*/
|
||||
public class SalesforceModuleParserPartner implements ISalesforceModuleParser {
|
||||
|
||||
final String useProxy = "useProxyBtn"; //$NON-NLS-1$
|
||||
|
||||
private String url = null;
|
||||
|
||||
private String name = null;
|
||||
|
||||
private String pwd = null;
|
||||
|
||||
// private String proxy = null;
|
||||
|
||||
private boolean loginOk = false;
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
// private String proxyHost = null;
|
||||
//
|
||||
// private String proxyPort = null;
|
||||
//
|
||||
// private String proxyUsername = null;
|
||||
//
|
||||
// private String proxyPassword = null;
|
||||
|
||||
// private SoapBindingStub binding = null;
|
||||
|
||||
private SforceManagementImpl sforceManagement = null;
|
||||
|
||||
// private LoginResult loginResult = null; // maintain the login results
|
||||
|
||||
private String currentModuleName = null;
|
||||
|
||||
private List<IMetadataColumn> currentMetadataColumns = null;
|
||||
|
||||
private List list = null;
|
||||
|
||||
/**
|
||||
* DOC YeXiaowei Comment method "login".
|
||||
*/
|
||||
@Override
|
||||
public ArrayList login(String endPoint, String username, String password) throws Exception {
|
||||
if (endPoint == null) {
|
||||
throw new RemoteException(
|
||||
org.talend.repository.metadata.i18n.Messages.getString("SalesforceModuleParseAPI.URLInvalid")); //$NON-NLS-1$
|
||||
}
|
||||
if (username == null || password == null) {
|
||||
throw new Exception(Messages.getString("SalesforceModuleParseAPI.lostUsernameOrPass")); //$NON-NLS-1$
|
||||
}
|
||||
ArrayList doLoginList = null;
|
||||
sforceManagement = null;
|
||||
boolean login = false;
|
||||
if (name != null && pwd != null && url != null) {
|
||||
if (!url.equals(endPoint) || !name.equals(username) || !pwd.equals(password)) {
|
||||
// || !checkString(proxyHost, this.proxyHost)
|
||||
// || !checkString(proxyPort, this.proxyPort)
|
||||
// || !checkString(proxyUsername, this.proxyUsername)
|
||||
// || !checkString(proxyPassword, this.proxyPassword)
|
||||
// || (proxy != null && theProxy != null && !proxy.equals(theProxy) || (proxy != null && theProxy ==
|
||||
// null) || (proxy == null && theProxy != null))) {
|
||||
|
||||
// doLoginList = doLogin(endPoint, username, password);
|
||||
SforceConnection sforceConn = new SforceBasicConnection.Builder(endPoint, username, password).setTimeout(10000)
|
||||
.needCompression(false).build();
|
||||
login = true;
|
||||
sforceManagement = new SforceManagementImpl(sforceConn);
|
||||
|
||||
} else {
|
||||
if (isLogin()) {
|
||||
return doLoginList;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// doLoginList = doLogin(endPoint, username, password);
|
||||
SforceConnection sforceConn = new SforceBasicConnection.Builder(endPoint, username, password).setTimeout(10000)
|
||||
.needCompression(false).build();
|
||||
login = true;
|
||||
sforceManagement = new SforceManagementImpl(sforceConn);
|
||||
doLoginList = new ArrayList();
|
||||
doLoginList.add(sforceManagement);
|
||||
}
|
||||
|
||||
setLogin(login);
|
||||
setSforceManagement(sforceManagement);
|
||||
this.name = username;
|
||||
this.pwd = password;
|
||||
this.url = endPoint;
|
||||
return doLoginList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList login(String endPoint, String username, String password, String timeOut) throws Exception {
|
||||
if (endPoint == null) {
|
||||
throw new RemoteException(Messages.getString("SalesforceModuleParseAPI.URLInvalid")); //$NON-NLS-1$
|
||||
}
|
||||
if (username == null || password == null) {
|
||||
throw new Exception(Messages.getString("SalesforceModuleParseAPI.lostUsernameOrPass")); //$NON-NLS-1$
|
||||
}
|
||||
int time = Integer.valueOf(timeOut);
|
||||
ArrayList doLoginList = null;
|
||||
sforceManagement = null;
|
||||
boolean login = false;
|
||||
if (name != null && pwd != null && url != null) {
|
||||
if (!url.equals(endPoint) || !name.equals(username) || !pwd.equals(password)) {
|
||||
|
||||
// doLoginList = doLogin(endPoint, username, password);
|
||||
SforceConnection sforceConn = new SforceBasicConnection.Builder(endPoint, username, password).setTimeout(time)
|
||||
.needCompression(false).build();
|
||||
login = true;
|
||||
sforceManagement = new SforceManagementImpl(sforceConn);
|
||||
|
||||
} else {
|
||||
if (isLogin()) {
|
||||
return doLoginList;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// doLoginList = doLogin(endPoint, username, password);
|
||||
SforceConnection sforceConn = new SforceBasicConnection.Builder(endPoint, username, password).setTimeout(time)
|
||||
.needCompression(false).build();
|
||||
login = true;
|
||||
sforceManagement = new SforceManagementImpl(sforceConn);
|
||||
doLoginList = new ArrayList();
|
||||
doLoginList.add(sforceManagement);
|
||||
}
|
||||
setLogin(login);
|
||||
setSforceManagement(sforceManagement);
|
||||
this.name = username;
|
||||
this.pwd = password;
|
||||
this.url = endPoint;
|
||||
return doLoginList;
|
||||
}
|
||||
|
||||
private boolean checkString(String str1, String str2) {
|
||||
if (str1 == str2) {
|
||||
return true;
|
||||
}
|
||||
if (str1 != null && str2 != null) {
|
||||
return str1.equals(str2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// protected ArrayList doLogin(String endPoint, String username, String password) throws RemoteException,
|
||||
// ServiceException,
|
||||
// MalformedURLException {
|
||||
// try {
|
||||
// URL soapAddress = new java.net.URL(endPoint);
|
||||
// binding = (SoapBindingStub) new SforceServiceLocator().getSoap(soapAddress);
|
||||
//
|
||||
// loginResult = binding.login(username, password);
|
||||
//
|
||||
// } catch (ArrayIndexOutOfBoundsException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// setLogin(true);
|
||||
// // on a successful login, you should always set up your session id
|
||||
// // and the url for subsequent calls
|
||||
//
|
||||
// // reset the url endpoint property, this will cause subsequent calls
|
||||
// // to made to the serverURL from the login result
|
||||
// binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());
|
||||
//
|
||||
// // create a session head object
|
||||
// SessionHeader sh = new SessionHeader();
|
||||
// // set the sessionId property on the header object using
|
||||
// // the value from the login result
|
||||
// sh.setSessionId(loginResult.getSessionId());
|
||||
// // add the header to the binding stub
|
||||
// String sforceURI = new SforceServiceLocator().getServiceName().getNamespaceURI();
|
||||
// binding.setHeader(sforceURI, "SessionHeader", sh); //$NON-NLS-1$
|
||||
//
|
||||
// ArrayList arrayList = new ArrayList();
|
||||
// arrayList.add(binding);
|
||||
//
|
||||
// return arrayList;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void describeGlobalSample() {
|
||||
// try {
|
||||
// DescribeGlobalResult describeGlobalResult = null;
|
||||
// describeGlobalResult = binding.describeGlobal();
|
||||
// String[] types = describeGlobalResult.getTypes();
|
||||
// for (int i = 0; i < types.length; i++)
|
||||
// System.out.println(types[i]);
|
||||
// System.out.println("\nDescribe global was successful...\r\n"); //$NON-NLS-1$
|
||||
// } catch (Exception ex) {
|
||||
// System.out.println("\nFailed to return types, error message was: \n" + ex.getMessage()); //$NON-NLS-1$
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a module from SF and transfor to Talend metadata data type. DOC YeXiaowei Comment method
|
||||
* "fetchMetaDataColumns".
|
||||
*
|
||||
* @param module
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<IMetadataColumn> fetchMetaDataColumns(String module) {
|
||||
|
||||
Field[] fields = fetchSFDescriptionField(module);
|
||||
|
||||
if (fields == null || fields.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<IMetadataColumn> res = new ArrayList<IMetadataColumn>();
|
||||
for (Field field : fields) {
|
||||
res.add(parseFieldToMetadataColumn(field));
|
||||
}
|
||||
|
||||
setCurrentMetadataColumns(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch module fields from SF service. Make sure login sucess before do this.
|
||||
* <p>
|
||||
* DOC YeXiaowei Comment method "fetchSFDescriptionField".
|
||||
*
|
||||
* @param module
|
||||
* @return
|
||||
*/
|
||||
private Field[] fetchSFDescriptionField(String module) {
|
||||
|
||||
DescribeSObjectResult r;
|
||||
try {
|
||||
r = sforceManagement.describeSObject(module);
|
||||
Field[] fields = r.getFields();
|
||||
setCurrentModuleName(module);
|
||||
return fields;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
// try {
|
||||
// // Invoke describeSObject and save results in DescribeSObjectResult
|
||||
// DescribeSObjectResult describeSObjectResult = binding.describeSObject(module);
|
||||
// // Determine whether the describeSObject call succeeded.
|
||||
// if (!(describeSObjectResult == null)) {
|
||||
// // Retrieve fields from the results
|
||||
// Field[] fields = describeSObjectResult.getFields();
|
||||
// // Get the name of the object
|
||||
// String objectName = describeSObjectResult.getName();
|
||||
// // Get some flags
|
||||
// boolean isActivateable = describeSObjectResult.isActivateable();
|
||||
// // Many other values are accessible
|
||||
// setCurrentModuleName(module);
|
||||
// return fields;
|
||||
// }
|
||||
// setCurrentModuleName(null);
|
||||
// return null;
|
||||
// } catch (Exception ex) {
|
||||
// setCurrentModuleName(null);
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse SF field to Talend data type
|
||||
* <p>
|
||||
* DOC YeXiaowei Comment method "parseFieldToMetadataColumn".
|
||||
*
|
||||
* @param field
|
||||
* @return
|
||||
*/
|
||||
private IMetadataColumn parseFieldToMetadataColumn(Field field) {
|
||||
|
||||
if (field == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IMetadataColumn mdColumn = new org.talend.core.model.metadata.MetadataColumn();
|
||||
|
||||
mdColumn.setLabel(field.getName());
|
||||
mdColumn.setKey(false);
|
||||
|
||||
// public static final java.lang.String _value1 = "string";
|
||||
// public static final java.lang.String _value2 = "picklist";
|
||||
// public static final java.lang.String _value3 = "multipicklist";
|
||||
// public static final java.lang.String _value4 = "combobox";
|
||||
// public static final java.lang.String _value5 = "reference";
|
||||
// public static final java.lang.String _value6 = "base64";
|
||||
// public static final java.lang.String _value7 = "boolean";
|
||||
// public static final java.lang.String _value8 = "currency";
|
||||
// public static final java.lang.String _value9 = "textarea";
|
||||
// public static final java.lang.String _value10 = "int";
|
||||
// public static final java.lang.String _value11 = "double";
|
||||
// public static final java.lang.String _value12 = "percent";
|
||||
// public static final java.lang.String _value13 = "phone";
|
||||
// public static final java.lang.String _value14 = "id";
|
||||
// public static final java.lang.String _value15 = "date";
|
||||
// public static final java.lang.String _value16 = "datetime";
|
||||
// public static final java.lang.String _value17 = "url";
|
||||
// public static final java.lang.String _value18 = "email";
|
||||
// public static final java.lang.String _value19 = "anyType";
|
||||
|
||||
String type = field.getType().toString();
|
||||
String talendType = "String"; //$NON-NLS-1$
|
||||
if (type.equals("boolean")) { //$NON-NLS-1$
|
||||
talendType = "Boolean"; //$NON-NLS-1$
|
||||
} else if (type.equals("int")) { //$NON-NLS-1$
|
||||
talendType = "Integer"; //$NON-NLS-1$
|
||||
} else if (type.equals("date") || type.equals("datetime")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
talendType = "Date"; //$NON-NLS-1$
|
||||
} else if (type.equals("double") || type.equals("currency") || type.equals("percent")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
talendType = "Double"; //$NON-NLS-1$
|
||||
} else {
|
||||
talendType = "String"; //$NON-NLS-1$
|
||||
}
|
||||
// mdColumn.setType(talendType);
|
||||
mdColumn.setTalendType("id_" + talendType); // How to transfer type? TODO //$NON-NLS-1$
|
||||
// mdColumn.setNullable(field.isNillable());
|
||||
mdColumn.setNullable(field.getNillable());
|
||||
|
||||
if (type.equals("date")) { //$NON-NLS-1$
|
||||
mdColumn.setPattern("\"yyyy-MM-dd\""); //$NON-NLS-1$
|
||||
} else if (type.equals("datetime")) { //$NON-NLS-1$
|
||||
mdColumn.setPattern("\"yyyy-MM-dd\'T\'HH:mm:ss\'.000Z\'\""); //$NON-NLS-1$
|
||||
} else {
|
||||
mdColumn.setPattern(null);
|
||||
}
|
||||
if ("String".equals(talendType)) { //$NON-NLS-1$
|
||||
mdColumn.setLength(field.getLength());
|
||||
mdColumn.setPrecision(field.getPrecision());
|
||||
} else {
|
||||
mdColumn.setLength(field.getPrecision());
|
||||
mdColumn.setPrecision(field.getScale());
|
||||
}
|
||||
mdColumn.setDefault(field.getDefaultValueFormula());
|
||||
|
||||
return mdColumn;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for login.
|
||||
*
|
||||
* @return the login
|
||||
*/
|
||||
@Override
|
||||
public boolean isLogin() {
|
||||
return this.loginOk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the login.
|
||||
*
|
||||
* @param login the login to set
|
||||
*/
|
||||
@Override
|
||||
public void setLogin(boolean login) {
|
||||
this.loginOk = login;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for currentModuleName.
|
||||
*
|
||||
* @return the currentModuleName
|
||||
*/
|
||||
@Override
|
||||
public String getCurrentModuleName() {
|
||||
return this.currentModuleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the currentModuleName.
|
||||
*
|
||||
* @param currentModuleName the currentModuleName to set
|
||||
*/
|
||||
@Override
|
||||
public void setCurrentModuleName(String currentModuleName) {
|
||||
this.currentModuleName = currentModuleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for currentMetadataColumns.
|
||||
*
|
||||
* @return the currentMetadataColumns
|
||||
*/
|
||||
@Override
|
||||
public List<IMetadataColumn> getCurrentMetadataColumns() {
|
||||
return this.currentMetadataColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the currentMetadataColumns.
|
||||
*
|
||||
* @param currentMetadataColumns the currentMetadataColumns to set
|
||||
*/
|
||||
@Override
|
||||
public void setCurrentMetadataColumns(List<IMetadataColumn> currentMetadataColumns) {
|
||||
this.currentMetadataColumns = currentMetadataColumns;
|
||||
}
|
||||
|
||||
public SforceManagementImpl getSforceManagement() {
|
||||
return this.sforceManagement;
|
||||
}
|
||||
|
||||
private void setSforceManagement(SforceManagementImpl sforceManagement) {
|
||||
this.sforceManagement = sforceManagement;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.INewWizard;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchWizard;
|
||||
import org.talend.commons.ui.runtime.image.ECoreImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.core.model.metadata.IMetadataConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
|
||||
import org.talend.core.model.metadata.builder.database.TableInfoParameters;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.metadata.managment.repository.ManagerConnection;
|
||||
import org.talend.metadata.managment.ui.wizard.CheckLastVersionRepositoryWizard;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
|
||||
import orgomg.cwm.objectmodel.core.Package;
|
||||
|
||||
/**
|
||||
* TableWizard present the TableForm width the MetaDataTable. Use to create a new table (need a connection to a DB).
|
||||
*/
|
||||
|
||||
public class SalesforceModulesWizard extends CheckLastVersionRepositoryWizard implements INewWizard {
|
||||
|
||||
private static Logger log = Logger.getLogger(SalesforceModulesWizard.class);
|
||||
|
||||
private SelectorModulesWizardPage selectorWizardPage;
|
||||
|
||||
private SalesforceSchemaConnection temConnection;
|
||||
|
||||
protected String[] existingNames;
|
||||
|
||||
private SalesforceModuleParseAPI salesforceAPI = new SalesforceModuleParseAPI();
|
||||
|
||||
private IMetadataConnection metadataConnection;
|
||||
|
||||
/**
|
||||
* DOC ocarbone DatabaseTableWizard constructor comment.
|
||||
*
|
||||
* @param workbench
|
||||
* @param idNodeDbConnection
|
||||
* @param metadataTable
|
||||
* @param existingNames
|
||||
* @param managerConnection
|
||||
*/
|
||||
public SalesforceModulesWizard(IWorkbench workbench, boolean creation, IRepositoryViewObject object,
|
||||
MetadataTable metadataTable, String[] existingNames, boolean forceReadOnly, ManagerConnection managerConnection,
|
||||
IMetadataConnection metadataConnection) {
|
||||
super(workbench, creation, forceReadOnly);
|
||||
this.existingNames = existingNames;
|
||||
this.metadataConnection = metadataConnection;
|
||||
setNeedsProgressMonitor(true);
|
||||
|
||||
// set the repositoryObject, lock and set isRepositoryObjectEditable
|
||||
setRepositoryObject(object);
|
||||
isRepositoryObjectEditable();
|
||||
initLockStrategy();
|
||||
this.connectionItem = (ConnectionItem) object.getProperty().getItem();
|
||||
if (connectionItem != null) {
|
||||
cloneBaseConnection((SalesforceSchemaConnection) connectionItem.getConnection());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding the page to the wizard.
|
||||
*/
|
||||
@Override
|
||||
public void addPages() {
|
||||
setWindowTitle(Messages.getString("TableWizard.windowTitle")); //$NON-NLS-1$
|
||||
setDefaultPageImageDescriptor(ImageProvider.getImageDesc(ECoreImage.METADATA_TABLE_WIZ));
|
||||
TableInfoParameters tableInfoParameters = new TableInfoParameters();
|
||||
selectorWizardPage = new SelectorModulesWizardPage(connectionItem, isRepositoryObjectEditable(), tableInfoParameters,
|
||||
metadataConnection, temConnection, salesforceAPI);
|
||||
|
||||
selectorWizardPage
|
||||
.setTitle(Messages.getString("TableWizardPage.titleCreate") + " \"" + connectionItem.getProperty().getLabel() //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "\""); //$NON-NLS-1$
|
||||
selectorWizardPage.setDescription(Messages.getString("TableWizardPage.descriptionCreate")); //$NON-NLS-1$
|
||||
selectorWizardPage.setPageComplete(true);
|
||||
addPage(selectorWizardPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method determine if the 'Finish' button is enable This method is called when 'Finish' button is pressed in
|
||||
* the wizard. We will create an operation and run it using wizard as execution context.
|
||||
*/
|
||||
@Override
|
||||
public boolean performFinish() {
|
||||
|
||||
boolean formIsPerformed = false;
|
||||
formIsPerformed = true;
|
||||
connectionItem.setConnection((SalesforceSchemaConnection) EcoreUtil.copy(temConnection));
|
||||
|
||||
if (formIsPerformed) {
|
||||
final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
|
||||
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
factory.save(connectionItem);
|
||||
closeLockStrategy();
|
||||
ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
|
||||
} catch (Exception e) {
|
||||
String detailError = e.toString();
|
||||
log.error(Messages.getString("CommonWizard.persistenceException") + "\n" + detailError); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
|
||||
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
try {
|
||||
ISchedulingRule schedulingRule = workspace.getRoot();
|
||||
// the update the project files need to be done in the workspace runnable to avoid all
|
||||
// notification
|
||||
// of changes before the end of the modifications.
|
||||
workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
|
||||
} catch (CoreException e) {
|
||||
throw new InvocationTargetException(e);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
new ProgressMonitorDialog(getShell()).run(true, false, iRunnableWithProgress);
|
||||
} catch (InvocationTargetException e) {
|
||||
// already logged
|
||||
} catch (InterruptedException e) {
|
||||
// nothing to do, since even no cancel here.
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We will accept the selection in the workbench to see if we can initialize from it.
|
||||
*
|
||||
* @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
|
||||
*/
|
||||
public void init(final IWorkbench workbench, final IStructuredSelection selection2) {
|
||||
this.selection = selection2;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.wizards.RepositoryWizard#performCancel()
|
||||
*/
|
||||
@Override
|
||||
public boolean performCancel() {
|
||||
selectorWizardPage.performCancel();
|
||||
temConnection = null;
|
||||
return super.performCancel();
|
||||
}
|
||||
|
||||
/**
|
||||
* clone a new DB connection
|
||||
*/
|
||||
private void cloneBaseConnection(SalesforceSchemaConnection connection) {
|
||||
temConnection = (SalesforceSchemaConnection) EcoreUtil.copy(connection);
|
||||
EList<Package> dataPackage = connection.getDataPackage();
|
||||
Collection<Package> newDataPackage = EcoreUtil.copyAll(dataPackage);
|
||||
ConnectionHelper.addPackages(newDataPackage, temConnection);
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.INewWizard;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchWizard;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.ui.swt.dialogs.ErrorDialogWidthDetailArea;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.builder.ConvertionHelper;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.model.update.RepositoryUpdateManager;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.metadata.managment.ui.wizard.CheckLastVersionRepositoryWizard;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.ui.wizards.metadata.table.files.FileTableWizardPage;
|
||||
|
||||
/**
|
||||
* DOC qzhang class global comment. Detailled comment
|
||||
*/
|
||||
public class SalesforceSchemaTableWizard extends CheckLastVersionRepositoryWizard implements INewWizard {
|
||||
|
||||
private static Logger log = Logger.getLogger(SalesforceSchemaTableWizard.class);
|
||||
|
||||
private FileTableWizardPage tableWizardpage;
|
||||
|
||||
private Map<String, String> oldTableMap;
|
||||
|
||||
private IMetadataTable oldMetadataTable;
|
||||
|
||||
/**
|
||||
* Constructor for TableWizard.
|
||||
*
|
||||
* @param ISelection
|
||||
*/
|
||||
@SuppressWarnings("unchecked")//$NON-NLS-1$
|
||||
public SalesforceSchemaTableWizard(IWorkbench workbench, boolean creation, ConnectionItem connectionItem,
|
||||
MetadataTable metadataTable, boolean forceReadOnly) {
|
||||
super(workbench, creation, forceReadOnly);
|
||||
this.connectionItem = connectionItem;
|
||||
this.metadataTable = metadataTable;
|
||||
if (connectionItem != null) {
|
||||
oldTableMap = RepositoryUpdateManager.getOldTableIdAndNameMap(connectionItem, metadataTable, creation);
|
||||
oldMetadataTable = ConvertionHelper.convert(metadataTable);
|
||||
// initConnectionCopy(connectionItem.getConnection());
|
||||
}
|
||||
|
||||
setNeedsProgressMonitor(true);
|
||||
isRepositoryObjectEditable();
|
||||
initLockStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding the page to the wizard.
|
||||
*/
|
||||
|
||||
public void addPages() {
|
||||
setWindowTitle(Messages.getString("SchemaWizard.windowTitle")); //$NON-NLS-1$
|
||||
|
||||
tableWizardpage = new FileTableWizardPage(connectionItem, metadataTable, isRepositoryObjectEditable());
|
||||
|
||||
if (creation) {
|
||||
tableWizardpage.setTitle(Messages.getString(
|
||||
"FileTableWizardPage.titleCreate", connectionItem.getProperty().getLabel())); //$NON-NLS-1$
|
||||
tableWizardpage.setDescription(Messages.getString("FileTableWizardPage.descriptionCreate")); //$NON-NLS-1$
|
||||
tableWizardpage.setPageComplete(false);
|
||||
} else {
|
||||
tableWizardpage.setTitle(Messages.getString("FileTableWizardPage.titleUpdate", metadataTable.getLabel())); //$NON-NLS-1$
|
||||
tableWizardpage.setDescription(Messages.getString("FileTableWizardPage.descriptionUpdate")); //$NON-NLS-1$
|
||||
tableWizardpage.setPageComplete(isRepositoryObjectEditable());
|
||||
}
|
||||
addPage(tableWizardpage);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method determine if the 'Finish' button is enable This method is called when 'Finish' button is pressed in
|
||||
* the wizard. We will create an operation and run it using wizard as execution context.
|
||||
*/
|
||||
public boolean performFinish() {
|
||||
if (tableWizardpage.isPageComplete()) {
|
||||
// applyConnectionCopy();
|
||||
// update
|
||||
RepositoryUpdateManager.updateSingleSchema(connectionItem, metadataTable, oldMetadataTable, oldTableMap);
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
try {
|
||||
factory.save(repositoryObject.getProperty().getItem());
|
||||
closeLockStrategy();
|
||||
} catch (PersistenceException e) {
|
||||
String detailError = e.toString();
|
||||
new ErrorDialogWidthDetailArea(getShell(), PID,
|
||||
Messages.getString("CommonWizard.persistenceException"), detailError); //$NON-NLS-1$
|
||||
log.error(Messages.getString("CommonWizard.persistenceException") + "\n" + detailError); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
// connectionCopy = null;
|
||||
// metadataTableCopy = null;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean performCancel() {
|
||||
if (metadataTable != null && oldMetadataTable != null && metadataTable.getLabel() != null
|
||||
&& !metadataTable.getLabel().equals(oldMetadataTable.getLabel())) {
|
||||
this.metadataTable.setLabel(oldMetadataTable.getLabel());
|
||||
}
|
||||
return super.performCancel();
|
||||
}
|
||||
|
||||
/**
|
||||
* We will accept the selection in the workbench to see if we can initialize from it.
|
||||
*
|
||||
* @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
|
||||
*/
|
||||
public void init(final IWorkbench workbench, final IStructuredSelection selection) {
|
||||
this.selection = selection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionItem getConnectionItem() {
|
||||
return this.connectionItem;
|
||||
}
|
||||
}
|
||||
@@ -1,371 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.INewWizard;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.talend.commons.ui.runtime.image.ECoreImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.commons.ui.swt.dialogs.ErrorDialogWidthDetailArea;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.model.metadata.IMetadataContextModeManager;
|
||||
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
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.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.metadata.managment.ui.utils.ConnectionContextHelper;
|
||||
import org.talend.metadata.managment.ui.wizard.CheckLastVersionRepositoryWizard;
|
||||
import org.talend.metadata.managment.ui.wizard.PropertiesWizardPage;
|
||||
import org.talend.metadata.managment.ui.wizard.metadata.MetadataContextModeManager;
|
||||
import org.talend.metadata.managment.ui.wizard.metadata.connection.Step0WizardPage;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
import org.talend.repository.model.RepositoryNodeUtilities;
|
||||
|
||||
import orgomg.cwm.resource.record.RecordFactory;
|
||||
import orgomg.cwm.resource.record.RecordFile;
|
||||
|
||||
/**
|
||||
* DOC YeXiaowei class global comment. Detailled comment <br/>
|
||||
*
|
||||
*/
|
||||
public class SalesforceSchemaWizard extends CheckLastVersionRepositoryWizard implements INewWizard {
|
||||
|
||||
private static Logger log = Logger.getLogger(SalesforceSchemaWizard.class);
|
||||
|
||||
private PropertiesWizardPage salesforceSchemaWizardPage0 = null;
|
||||
|
||||
private SalesforceWizardPage page1 = null;
|
||||
|
||||
private SalesforceSchemaConnection connection = null;
|
||||
|
||||
private Property connectionProperty = null;
|
||||
|
||||
private final SalesforceModuleParseAPI salesforceAPI = new SalesforceModuleParseAPI();
|
||||
|
||||
private boolean isSinglePageOnly = false;
|
||||
|
||||
private static final String ALL_STEPS = " 4"; //$NON-NLS-1$
|
||||
|
||||
private IMetadataContextModeManager contextModeManager;
|
||||
|
||||
private boolean isToolbar;
|
||||
|
||||
private String originaleObjectLabel;
|
||||
|
||||
private String originalVersion;
|
||||
|
||||
private String originalPurpose;
|
||||
|
||||
private String originalDescription;
|
||||
|
||||
private String originalStatus;
|
||||
|
||||
/**
|
||||
* Sets the isToolbar.
|
||||
*
|
||||
* @param isToolbar the isToolbar to set
|
||||
*/
|
||||
public void setToolbar(boolean isToolbar) {
|
||||
this.isToolbar = isToolbar;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC YeXiaowei SalesforceSchemaWizard constructor comment.
|
||||
*
|
||||
* @param workbench
|
||||
* @param creation
|
||||
* @param forceReadOnly
|
||||
*/
|
||||
public SalesforceSchemaWizard(IWorkbench workbench, boolean creation, ISelection selection, String[] existingNames,
|
||||
boolean isSinglePageOnly) {
|
||||
super(workbench, creation);
|
||||
this.selection = selection;
|
||||
this.existingNames = existingNames;
|
||||
this.isSinglePageOnly = isSinglePageOnly;
|
||||
setNeedsProgressMonitor(true);
|
||||
|
||||
// TODO: should to changed icon.
|
||||
setDefaultPageImageDescriptor(ImageProvider.getImageDesc(ECoreImage.DEFAULT_WIZ));
|
||||
|
||||
if (selection == null || existingNames == null) {
|
||||
connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
|
||||
connectionProperty.setAuthor(((RepositoryContext) CoreRuntimePlugin.getInstance().getContext()
|
||||
.getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
|
||||
connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
|
||||
connectionProperty.setStatusCode(""); //$NON-NLS-1$
|
||||
|
||||
connectionItem = PropertiesFactory.eINSTANCE.createSalesforceSchemaConnectionItem();
|
||||
connectionItem.setProperty(connectionProperty);
|
||||
return;
|
||||
}
|
||||
|
||||
Object obj = ((IStructuredSelection) selection).getFirstElement();
|
||||
RepositoryNode node = (RepositoryNode) obj;
|
||||
switch (node.getType()) {
|
||||
case SIMPLE_FOLDER:
|
||||
case REPOSITORY_ELEMENT:
|
||||
pathToSave = RepositoryNodeUtilities.getPath(node);
|
||||
break;
|
||||
case SYSTEM_FOLDER:
|
||||
pathToSave = new Path(""); //$NON-NLS-1$
|
||||
break;
|
||||
}
|
||||
|
||||
switch (node.getType()) {
|
||||
case SIMPLE_FOLDER:
|
||||
case SYSTEM_FOLDER:
|
||||
connection = ConnectionFactory.eINSTANCE.createSalesforceSchemaConnection();
|
||||
connection.setName(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA.getKey());
|
||||
MetadataTable metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
metadataTable.setId(factory.getNextId());
|
||||
RecordFile record = (RecordFile) ConnectionHelper.getPackage(connection.getName(), connection, RecordFile.class);
|
||||
if (record != null) { // hywang
|
||||
PackageHelper.addMetadataTable(metadataTable, record);
|
||||
} else {
|
||||
RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
|
||||
newrecord.setName(connection.getName());
|
||||
ConnectionHelper.addPackage(newrecord, connection);
|
||||
PackageHelper.addMetadataTable(metadataTable, newrecord);
|
||||
}
|
||||
connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
|
||||
connectionProperty.setAuthor(((RepositoryContext) CoreRuntimePlugin.getInstance().getContext()
|
||||
.getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
|
||||
connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
|
||||
connectionProperty.setStatusCode(""); //$NON-NLS-1$
|
||||
|
||||
connectionItem = PropertiesFactory.eINSTANCE.createSalesforceSchemaConnectionItem();
|
||||
connectionItem.setProperty(connectionProperty);
|
||||
connectionItem.setConnection(connection);
|
||||
initProxySettings(connection);
|
||||
break;
|
||||
|
||||
case REPOSITORY_ELEMENT:
|
||||
connection = (SalesforceSchemaConnection) ((ConnectionItem) node.getObject().getProperty().getItem()).getConnection();
|
||||
connectionProperty = node.getObject().getProperty();
|
||||
connectionItem = (ConnectionItem) node.getObject().getProperty().getItem();
|
||||
setRepositoryObject(node.getObject());
|
||||
isRepositoryObjectEditable();
|
||||
initLockStrategy();
|
||||
break;
|
||||
}
|
||||
if (!creation) {
|
||||
this.originaleObjectLabel = this.connectionItem.getProperty().getLabel();
|
||||
this.originalVersion = this.connectionItem.getProperty().getVersion();
|
||||
this.originalDescription = this.connectionItem.getProperty().getDescription();
|
||||
this.originalPurpose = this.connectionItem.getProperty().getPurpose();
|
||||
this.originalStatus = this.connectionItem.getProperty().getStatusCode();
|
||||
}
|
||||
initConnection();
|
||||
}
|
||||
|
||||
public SalesforceSchemaWizard(IWorkbench workbench, boolean creation, RepositoryNode node, String[] existingNames,
|
||||
boolean isSinglePageOnly) {
|
||||
super(workbench, creation);
|
||||
this.existingNames = existingNames;
|
||||
this.isSinglePageOnly = isSinglePageOnly;
|
||||
setNeedsProgressMonitor(true);
|
||||
|
||||
// TODO: should to changed icon.
|
||||
setDefaultPageImageDescriptor(ImageProvider.getImageDesc(ECoreImage.DEFAULT_WIZ));
|
||||
switch (node.getType()) {
|
||||
case SIMPLE_FOLDER:
|
||||
case REPOSITORY_ELEMENT:
|
||||
pathToSave = RepositoryNodeUtilities.getPath(node);
|
||||
break;
|
||||
case SYSTEM_FOLDER:
|
||||
pathToSave = new Path(""); //$NON-NLS-1$
|
||||
break;
|
||||
}
|
||||
|
||||
switch (node.getType()) {
|
||||
case SIMPLE_FOLDER:
|
||||
case SYSTEM_FOLDER:
|
||||
connection = ConnectionFactory.eINSTANCE.createSalesforceSchemaConnection();
|
||||
connection.setName(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA.getKey());
|
||||
MetadataTable metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
metadataTable.setId(factory.getNextId());
|
||||
RecordFile record = (RecordFile) ConnectionHelper.getPackage(connection.getName(), connection, RecordFile.class);
|
||||
if (record != null) { // hywang
|
||||
PackageHelper.addMetadataTable(metadataTable, record);
|
||||
} else {
|
||||
RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
|
||||
newrecord.setName(connection.getName());
|
||||
ConnectionHelper.addPackage(newrecord, connection);
|
||||
PackageHelper.addMetadataTable(metadataTable, newrecord);
|
||||
}
|
||||
connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
|
||||
connectionProperty.setAuthor(((RepositoryContext) CoreRuntimePlugin.getInstance().getContext()
|
||||
.getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
|
||||
connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
|
||||
connectionProperty.setStatusCode(""); //$NON-NLS-1$
|
||||
|
||||
connectionItem = PropertiesFactory.eINSTANCE.createSalesforceSchemaConnectionItem();
|
||||
connectionItem.setProperty(connectionProperty);
|
||||
connectionItem.setConnection(connection);
|
||||
initProxySettings(connection);
|
||||
break;
|
||||
|
||||
case REPOSITORY_ELEMENT:
|
||||
connection = (SalesforceSchemaConnection) ((ConnectionItem) node.getObject().getProperty().getItem()).getConnection();
|
||||
connectionProperty = node.getObject().getProperty();
|
||||
connectionItem = (ConnectionItem) node.getObject().getProperty().getItem();
|
||||
// set the repositoryObject, lock and set isRepositoryObjectEditable
|
||||
setRepositoryObject(node.getObject());
|
||||
isRepositoryObjectEditable();
|
||||
initLockStrategy();
|
||||
break;
|
||||
}
|
||||
if (!creation) {
|
||||
this.originaleObjectLabel = this.connectionItem.getProperty().getLabel();
|
||||
this.originalVersion = this.connectionItem.getProperty().getVersion();
|
||||
this.originalDescription = this.connectionItem.getProperty().getDescription();
|
||||
this.originalPurpose = this.connectionItem.getProperty().getPurpose();
|
||||
this.originalStatus = this.connectionItem.getProperty().getStatusCode();
|
||||
}
|
||||
initConnection();
|
||||
}
|
||||
|
||||
private void initConnection() {
|
||||
ConnectionContextHelper.checkContextMode(connectionItem);
|
||||
contextModeManager = new MetadataContextModeManager();
|
||||
if (connectionItem.getConnection().isContextMode()) {
|
||||
ContextType contextTypeForContextMode = ConnectionContextHelper.getContextTypeForContextMode(connectionItem
|
||||
.getConnection());
|
||||
contextModeManager.setSelectedContextType(contextTypeForContextMode);
|
||||
}
|
||||
}
|
||||
|
||||
private void initProxySettings(SalesforceSchemaConnection ssCon) {
|
||||
|
||||
Properties properties = System.getProperties();
|
||||
String oldProxyHost = (String) properties.get(SalesforceModuleParseAPI.SOCKS_PROXY_HOST);
|
||||
String oldProxyPort = (String) properties.get(SalesforceModuleParseAPI.SOCKS_PROXY_PORT);
|
||||
String oldProxyUser = (String) properties.get(SalesforceModuleParseAPI.SOCKS_PROXY_USERNAME);
|
||||
String oldProxyPwd = (String) properties.get(SalesforceModuleParseAPI.SOCKS_PROXY_PASSWORD);
|
||||
|
||||
ssCon.setProxyHost(oldProxyHost);
|
||||
ssCon.setProxyPort(oldProxyPort);
|
||||
ssCon.setProxyUsername(oldProxyUser);
|
||||
ssCon.setProxyPassword(ssCon.getValue(oldProxyPwd, true));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPages() {
|
||||
if (isToolbar) {
|
||||
pathToSave = null;
|
||||
}
|
||||
salesforceSchemaWizardPage0 = new Step0WizardPage(connectionProperty, pathToSave,
|
||||
ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA, !isRepositoryObjectEditable(), creation);
|
||||
|
||||
salesforceSchemaWizardPage0.setTitle(Messages.getString("SalesforceWizardPage.titleCreate.Step") + " 1 " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ Messages.getString("FileWizardPage.of") + ALL_STEPS); //$NON-NLS-1$
|
||||
salesforceSchemaWizardPage0.setDescription(Messages.getString("SalesforceWizardPage.descriptionCreate.Step1")); //$NON-NLS-1$
|
||||
addPage(salesforceSchemaWizardPage0);
|
||||
if (creation) {
|
||||
setWindowTitle(Messages.getString("SalesforceSchemaWizard.windowTitleCreate")); //$NON-NLS-1$
|
||||
} else {
|
||||
setWindowTitle(Messages.getString("SalesforceSchemaWizard.windowTitleUpdate")); //$NON-NLS-1$
|
||||
}
|
||||
page1 = new SalesforceWizardPage(1, connectionItem, isRepositoryObjectEditable(), existingNames, salesforceAPI,
|
||||
contextModeManager);
|
||||
page1.setTitle(Messages.getString("SalesforceWizardPage.titleCreate.Step") + " 2 " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ Messages.getString("FileWizardPage.of") + ALL_STEPS); //$NON-NLS-1$
|
||||
page1.setDescription(Messages.getString("SalesforceWizardPage.descriptionCreate.Step2")); //$NON-NLS-1$
|
||||
addPage(page1);
|
||||
page1.setPageComplete(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performFinish() {
|
||||
boolean formIsPerformed = false;
|
||||
formIsPerformed = page1.isPageComplete();
|
||||
if (formIsPerformed) {
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
try {
|
||||
if (creation) {
|
||||
String nextId = factory.getNextId();
|
||||
connectionProperty.setId(nextId);
|
||||
factory.create(connectionItem, salesforceSchemaWizardPage0.getDestinationPath());
|
||||
} else {
|
||||
// update
|
||||
RepositoryUpdateManager.updateFileConnection(connectionItem);
|
||||
refreshInFinish(salesforceSchemaWizardPage0.isNameModifiedByUser());
|
||||
updateConnectionItem();
|
||||
}
|
||||
ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
|
||||
|
||||
} catch (Exception e) {
|
||||
String detailError = e.toString();
|
||||
new ErrorDialogWidthDetailArea(getShell(), PID, Messages.getString("CommonWizard.persistenceException"), //$NON-NLS-1$
|
||||
detailError);
|
||||
log.error(Messages.getString("CommonWizard.persistenceException") + "\n" + detailError); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performCancel() {
|
||||
if (!creation) {
|
||||
connectionItem.getProperty().setVersion(this.originalVersion);
|
||||
connectionItem.getProperty().setLabel(this.originaleObjectLabel);
|
||||
connectionItem.getProperty().setDisplayName(this.originaleObjectLabel);
|
||||
connectionItem.getProperty().setDescription(this.originalDescription);
|
||||
connectionItem.getProperty().setPurpose(this.originalPurpose);
|
||||
connectionItem.getProperty().setStatusCode(this.originalStatus);
|
||||
}
|
||||
return super.performCancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
||||
this.selection = selection;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.wizards.RepositoryWizard#getConnectionItem()
|
||||
*/
|
||||
@Override
|
||||
public ConnectionItem getConnectionItem() {
|
||||
return this.connectionItem;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,312 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.INewWizard;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchWizard;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.ui.runtime.image.ECoreImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.commons.ui.swt.dialogs.ErrorDialogWidthDetailArea;
|
||||
import org.talend.core.model.metadata.IMetadataConnection;
|
||||
import org.talend.core.model.metadata.IMetadataContextModeManager;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.update.RepositoryUpdateManager;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.metadata.managment.repository.ManagerConnection;
|
||||
import org.talend.metadata.managment.ui.wizard.CheckLastVersionRepositoryWizard;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.ui.wizards.metadata.table.database.DatabaseTableFilterWizardPage;
|
||||
|
||||
import orgomg.cwm.objectmodel.core.Package;
|
||||
|
||||
/**
|
||||
* TableWizard present the TableForm width the MetaDataTable. Use to create a new table (need a connection to a DB).
|
||||
*/
|
||||
|
||||
public class SalesforceSchemasWizard extends CheckLastVersionRepositoryWizard implements INewWizard {
|
||||
|
||||
private static Logger log = Logger.getLogger(SalesforceSchemasWizard.class);
|
||||
|
||||
private SelectorModulesWizardPage selectorWizardPage;
|
||||
|
||||
// private DatabaseTableWizardPage tableWizardpage;
|
||||
|
||||
private DatabaseTableFilterWizardPage tableFilterWizardPage;
|
||||
|
||||
private SalesforceSchemaConnection temConnection;
|
||||
|
||||
private IMetadataContextModeManager contextModeManager;
|
||||
|
||||
private boolean skipStep;
|
||||
|
||||
protected String[] existingNames;
|
||||
|
||||
private SalesforceModuleParseAPI salesforceAPI = new SalesforceModuleParseAPI();
|
||||
|
||||
private final ManagerConnection managerConnection;
|
||||
|
||||
private Map<String, String> oldTableMap;
|
||||
|
||||
private IMetadataConnection metadataConnection;
|
||||
|
||||
private List<IMetadataTable> oldMetadataTable;
|
||||
|
||||
private MetadataTable selectedMetadataTable;
|
||||
|
||||
private SalesforceWizardPage page2 = null;
|
||||
|
||||
private SalesforceWizardPage page3 = null;
|
||||
|
||||
private Property connectionProperty = null;
|
||||
|
||||
private static final String ALL_STEPS = " 4"; //$NON-NLS-1$
|
||||
|
||||
private String moduleName;
|
||||
|
||||
/* hywang add for 0017426,catches used to store the uuids and labels of old tables and columns */
|
||||
// private static Map<String, String> originalColumnsMap = new HashMap<String, String>();
|
||||
//
|
||||
// private static Map<String, String> originalTablesMap = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* DOC ocarbone DatabaseTableWizard constructor comment.
|
||||
*
|
||||
* @param workbench
|
||||
* @param idNodeDbConnection
|
||||
* @param metadataTable
|
||||
* @param existingNames
|
||||
* @param managerConnection
|
||||
*/
|
||||
@SuppressWarnings("unchecked")//$NON-NLS-1$
|
||||
public SalesforceSchemasWizard(IWorkbench workbench, boolean creation, IRepositoryViewObject object,
|
||||
MetadataTable metadataTable, String[] existingNames, boolean forceReadOnly, ManagerConnection managerConnection,
|
||||
IMetadataConnection metadataConnection, String moduleName) {
|
||||
super(workbench, creation, forceReadOnly);
|
||||
this.existingNames = existingNames;
|
||||
this.managerConnection = managerConnection;
|
||||
this.metadataConnection = metadataConnection;
|
||||
setNeedsProgressMonitor(true);
|
||||
|
||||
// set the repositoryObject, lock and set isRepositoryObjectEditable
|
||||
setRepositoryObject(object);
|
||||
isRepositoryObjectEditable();
|
||||
initLockStrategy();
|
||||
this.selectedMetadataTable = metadataTable;
|
||||
this.connectionItem = (ConnectionItem) object.getProperty().getItem();
|
||||
if (connectionItem != null) {
|
||||
// oldTableMap = RepositoryUpdateManager.getOldTableIdAndNameMap(connectionItem, metadataTable, creation);
|
||||
// oldMetadataTable = RepositoryUpdateManager.getConversionMetadataTables(connectionItem.getConnection());
|
||||
cloneBaseConnection((SalesforceSchemaConnection) connectionItem.getConnection());
|
||||
}
|
||||
this.moduleName = moduleName;
|
||||
// originalColumnsMap.clear();
|
||||
// originalTablesMap.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC acer Comment method "setSkipStep".
|
||||
*
|
||||
* @param skipStep
|
||||
*/
|
||||
public void setSkipStep(boolean skipStep) {
|
||||
this.skipStep = skipStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding the page to the wizard.
|
||||
*/
|
||||
@Override
|
||||
public void addPages() {
|
||||
setWindowTitle(Messages.getString("TableWizard.windowTitle")); //$NON-NLS-1$
|
||||
setDefaultPageImageDescriptor(ImageProvider.getImageDesc(ECoreImage.METADATA_TABLE_WIZ));
|
||||
|
||||
page2 = new SalesforceWizardPage(2, connectionItem, temConnection, isRepositoryObjectEditable(), existingNames,
|
||||
salesforceAPI, contextModeManager, moduleName);
|
||||
page2.setTitle(Messages.getString("SalesforceWizardPage.titleCreate.Step") + " 3 " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ Messages.getString("FileWizardPage.of") + ALL_STEPS); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
page2.setDescription(Messages.getString("SalesforceWizardPage.descriptionCreate.Step3")); //$NON-NLS-1$
|
||||
|
||||
page3 = new SalesforceWizardPage(3, connectionItem, temConnection, isRepositoryObjectEditable(), existingNames,
|
||||
salesforceAPI, contextModeManager, moduleName);
|
||||
|
||||
page3.setTitle(Messages.getString("SalesforceWizardPage.titleCreate.Step") + " 4 " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ Messages.getString("FileWizardPage.of") + ALL_STEPS); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
page3.setDescription(Messages.getString("FileWizardPage.descriptionCreateStep3")); //$NON-NLS-1$
|
||||
page2.setPageComplete(true);
|
||||
page3.setPageComplete(false);
|
||||
addPage(page2);
|
||||
addPage(page3);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method determine if the 'Finish' button is enable This method is called when 'Finish' button is pressed in
|
||||
* the wizard. We will create an operation and run it using wizard as execution context.
|
||||
*/
|
||||
@Override
|
||||
public boolean performFinish() {
|
||||
|
||||
boolean formIsPerformed = true;
|
||||
connectionItem.setConnection((SalesforceSchemaConnection) EcoreUtil.copy(temConnection));
|
||||
if (formIsPerformed) {
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
try {
|
||||
if (creation) {
|
||||
factory.create(connectionItem, new Path(""));
|
||||
} else {
|
||||
// update
|
||||
RepositoryUpdateManager.updateFileConnection(connectionItem);
|
||||
updateConnectionItem();
|
||||
}
|
||||
|
||||
ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
|
||||
} catch (Exception e) {
|
||||
String detailError = e.toString();
|
||||
new ErrorDialogWidthDetailArea(getShell(), PID, Messages.getString("CommonWizard.persistenceException"), //$NON-NLS-1$
|
||||
detailError);
|
||||
log.error(Messages.getString("CommonWizard.persistenceException") + "\n" + detailError); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// private void generateOriginalColumnsMap(Collection<? extends Package> dataPackageFromOrignalConnection) {
|
||||
// for (orgomg.cwm.objectmodel.core.Package pkg : dataPackageFromOrignalConnection) {
|
||||
// for (ModelElement mol : pkg.getOwnedElement()) {
|
||||
// if (mol instanceof MetadataTable) {
|
||||
// MetadataTable table = (MetadataTable) mol;
|
||||
// String oldTableUuid = ResourceHelper.getUUID(table);
|
||||
// originalTablesMap.put(table.getLabel(), oldTableUuid);
|
||||
// for (ModelElement col : table.getFeature()) {
|
||||
// if (col instanceof MetadataColumn) {
|
||||
// MetadataColumn column = (MetadataColumn) col;
|
||||
// String oldColumnUuid = ResourceHelper.getUUID(column);
|
||||
// originalColumnsMap.put(column.getLabel(), oldColumnUuid);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (mol instanceof Catalog) {
|
||||
// Catalog catlog = (Catalog) mol;
|
||||
// List<Schema> subschemas = CatalogHelper.getSchemas(catlog);
|
||||
// if (!subschemas.isEmpty()) {
|
||||
// generateOriginalColumnsMap(subschemas);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
// private void replaceUUidsForColumnsAndTables(Collection<? extends Package> copyDataPackage) {
|
||||
// for (orgomg.cwm.objectmodel.core.Package pkg : copyDataPackage) {
|
||||
// for (ModelElement mol : pkg.getOwnedElement()) {
|
||||
// if (mol instanceof MetadataTable) {
|
||||
// MetadataTable table = (MetadataTable) mol;
|
||||
// if (originalTablesMap.keySet().contains(table.getLabel())) {
|
||||
// Resource resource = table.eResource();
|
||||
// if (resource != null && resource instanceof XMLResource) {
|
||||
// XMLResource xmlResource = (XMLResource) resource;
|
||||
// xmlResource.setID(table, originalTablesMap.get(table.getLabel()));
|
||||
// }
|
||||
// }
|
||||
// for (ModelElement col : table.getFeature()) {
|
||||
// if (col instanceof MetadataColumn) {
|
||||
// MetadataColumn column = (MetadataColumn) col;
|
||||
// if (originalColumnsMap.keySet().contains(column.getLabel())) {
|
||||
// Resource resource = column.eResource();
|
||||
// if (resource != null && resource instanceof XMLResource) {
|
||||
// XMLResource xmlResource = (XMLResource) resource;
|
||||
// xmlResource.setID(column, originalColumnsMap.get(column.getLabel()));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (mol instanceof Catalog) {
|
||||
// Catalog catlog = (Catalog) mol;
|
||||
// List<Schema> subschemas = CatalogHelper.getSchemas(catlog);
|
||||
// if (!subschemas.isEmpty()) {
|
||||
// replaceUUidsForColumnsAndTables(subschemas);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* We will accept the selection in the workbench to see if we can initialize from it.
|
||||
*
|
||||
* @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
|
||||
*/
|
||||
public void init(final IWorkbench workbench, final IStructuredSelection selection2) {
|
||||
this.selection = selection2;
|
||||
}
|
||||
|
||||
/**
|
||||
* execute saveMetaData() on TableForm.
|
||||
*/
|
||||
private void saveMetaData() {
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
try {
|
||||
factory.save(connectionItem);
|
||||
} catch (PersistenceException e) {
|
||||
String detailError = e.toString();
|
||||
new ErrorDialogWidthDetailArea(getShell(), PID, Messages.getString("CommonWizard.persistenceException"), detailError); //$NON-NLS-1$
|
||||
log.error(Messages.getString("CommonWizard.persistenceException") + "\n" + detailError); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.wizards.RepositoryWizard#performCancel()
|
||||
*/
|
||||
@Override
|
||||
public boolean performCancel() {
|
||||
// selectorWizardPage.performCancel();
|
||||
// temConnection = null;
|
||||
return super.performCancel();
|
||||
}
|
||||
|
||||
/**
|
||||
* clone a new DB connection
|
||||
*/
|
||||
private void cloneBaseConnection(SalesforceSchemaConnection connection) {
|
||||
temConnection = (SalesforceSchemaConnection) EcoreUtil.copy(connection);
|
||||
EList<Package> dataPackage = connection.getDataPackage();
|
||||
Collection<Package> newDataPackage = EcoreUtil.copyAll(dataPackage);
|
||||
ConnectionHelper.addPackages(newDataPackage, temConnection);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,940 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.CTabFolder;
|
||||
import org.eclipse.swt.custom.CTabItem;
|
||||
import org.eclipse.swt.custom.SashForm;
|
||||
import org.eclipse.swt.custom.ScrolledComposite;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.swt.widgets.TableColumn;
|
||||
import org.eclipse.swt.widgets.TableItem;
|
||||
import org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorNotModifiable.LAYOUT_MODE;
|
||||
import org.talend.commons.ui.swt.formtools.Form;
|
||||
import org.talend.commons.ui.swt.formtools.LabelledText;
|
||||
import org.talend.commons.ui.swt.formtools.UtilsButton;
|
||||
import org.talend.commons.ui.swt.tableviewer.TableViewerCreator;
|
||||
import org.talend.commons.ui.swt.thread.SWTUIThreadProcessor;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.IMetadataContextModeManager;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MetadataTable;
|
||||
import org.talend.core.model.metadata.builder.ConvertionHelper;
|
||||
import org.talend.core.model.metadata.builder.connection.SalesforceModuleUnit;
|
||||
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
|
||||
import org.talend.core.model.metadata.types.JavaType;
|
||||
import org.talend.core.model.metadata.types.JavaTypesManager;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.repository.model.preview.SalesforceSchemaBean;
|
||||
import org.talend.core.utils.CsvArray;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.metadata.managment.ui.preview.ProcessDescription;
|
||||
import org.talend.metadata.managment.ui.preview.ShadowProcessPreview;
|
||||
import org.talend.metadata.managment.ui.utils.ConnectionContextHelper;
|
||||
import org.talend.metadata.managment.ui.utils.OtherConnectionContextUtils;
|
||||
import org.talend.metadata.managment.ui.utils.ShadowProcessHelper;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
import org.talend.repository.metadata.ui.wizards.form.AbstractSalesforceStepForm;
|
||||
|
||||
/**
|
||||
* DOC YeXiaowei class global comment. Detailled comment <br/>
|
||||
*
|
||||
*/
|
||||
public class SalesforceStep2Form extends AbstractSalesforceStepForm {
|
||||
|
||||
private static Logger log = Logger.getLogger(SalesforceStep2Form.class);
|
||||
|
||||
private TableViewerCreator tableViewerCreator;
|
||||
|
||||
private Table tableNavigator;
|
||||
|
||||
// private UtilsButton addTableButton;
|
||||
//
|
||||
// private UtilsButton removeTableButton;
|
||||
|
||||
private static final int WIDTH_GRIDDATA_PIXEL = 750;
|
||||
|
||||
private LabelledText queryConditionText = null;
|
||||
|
||||
private String defaultQueryString = ""; // 'name == talend' //$NON-NLS-1$
|
||||
|
||||
private Button previewButton = null;
|
||||
|
||||
private Label previewInformationLabel = null;
|
||||
|
||||
private ShadowProcessPreview salesforcePreviewProcess = null;
|
||||
|
||||
private boolean readOnly;
|
||||
|
||||
private Button alphabet;
|
||||
|
||||
private UtilsButton cancelButton;
|
||||
|
||||
private TableViewer moduleViewer = null;
|
||||
|
||||
private static final int COLUMN_WIDTH = 60;
|
||||
|
||||
private SWTUIThreadProcessor processor = new PreviewProcessor();
|
||||
|
||||
/**
|
||||
* Output tab.
|
||||
*/
|
||||
private CTabFolder tabFolder;
|
||||
|
||||
private CTabItem previewTabItem;
|
||||
|
||||
private CTabItem outputTabItem;
|
||||
|
||||
private Composite outputComposite;
|
||||
|
||||
private SalesforceModuleParseAPI salesforceAPI = null;
|
||||
|
||||
private IMetadataTable metadataTable;
|
||||
|
||||
private SalesforceSchemaConnection temConnection;
|
||||
|
||||
private String moduleName;
|
||||
|
||||
/**
|
||||
* DOC YeXiaowei SalesforceStep2Form constructor comment.
|
||||
*
|
||||
* @param parent
|
||||
* @param connectionItem
|
||||
*/
|
||||
public SalesforceStep2Form(Composite parent, ConnectionItem connectionItem, SalesforceSchemaConnection temConnection,
|
||||
SalesforceModuleParseAPI salesforceAPI, IMetadataContextModeManager contextModeManager, String moduleName) {
|
||||
super(parent, connectionItem, salesforceAPI);
|
||||
setConnectionItem(connectionItem);
|
||||
setContextModeManager(contextModeManager);
|
||||
setupForm(true);
|
||||
this.salesforceAPI = salesforceAPI;
|
||||
this.temConnection = temConnection;
|
||||
this.moduleName = moduleName;
|
||||
initTreeNavigatorNodes();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.swt.utils.AbstractForm#adaptFormToReadOnly()
|
||||
*/
|
||||
@Override
|
||||
protected void adaptFormToReadOnly() {
|
||||
readOnly = isReadOnly();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.swt.utils.AbstractForm#addFields()
|
||||
*/
|
||||
@Override
|
||||
protected void addFields() {
|
||||
int leftCompositeWidth = 125;
|
||||
int rightCompositeWidth = WIDTH_GRIDDATA_PIXEL - leftCompositeWidth;
|
||||
int headerCompositeHeight = 80;
|
||||
int tableSettingsCompositeHeight = 15;
|
||||
int tableCompositeHeight = 200;
|
||||
|
||||
int height = headerCompositeHeight + tableSettingsCompositeHeight + tableCompositeHeight;
|
||||
Composite mainComposite = Form.startNewDimensionnedGridLayout(this, 2, WIDTH_GRIDDATA_PIXEL, height);
|
||||
mainComposite.setLayout(new GridLayout(2, false));
|
||||
GridData gridData = new GridData(GridData.FILL_BOTH);
|
||||
mainComposite.setLayoutData(gridData);
|
||||
|
||||
SashForm sash = new SashForm(mainComposite, SWT.HORIZONTAL);
|
||||
GridData sashData = new GridData(GridData.FILL_BOTH);
|
||||
sash.setLayoutData(sashData);
|
||||
Composite leftComposite = Form.startNewDimensionnedGridLayout(sash, 1, leftCompositeWidth, height);
|
||||
Composite rightComposite = Form.startNewDimensionnedGridLayout(sash, 1, rightCompositeWidth, height);
|
||||
sash.setWeights(new int[] { 1, 5 });
|
||||
|
||||
Composite composite1 = Form.startNewDimensionnedGridLayout(rightComposite, 1, rightCompositeWidth, headerCompositeHeight);
|
||||
addTreeNavigator(leftComposite, leftCompositeWidth, height);
|
||||
addQueryConditionGroup(composite1, tableCompositeHeight);
|
||||
addSalesforcePreviewGroup(composite1);
|
||||
|
||||
if (!isInWizard()) {
|
||||
Composite compositeBottomButton = Form.startNewGridLayout(this, 2, false, SWT.CENTER, SWT.CENTER);
|
||||
cancelButton = new UtilsButton(compositeBottomButton, Messages.getString("CommonWizard.cancel"), WIDTH_BUTTON_PIXEL, //$NON-NLS-1$
|
||||
HEIGHT_BUTTON_PIXEL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ocarbone Comment method "addTreeNavigator".
|
||||
*
|
||||
* @param parent
|
||||
* @param width
|
||||
* @param height
|
||||
*/
|
||||
private void addTreeNavigator(Composite parent, int width, int height) {
|
||||
// Group
|
||||
Group group = Form.createGroup(parent, 1, Messages.getString("SalesforceStep2Form.module"), height); //$NON-NLS-1$
|
||||
|
||||
// ScrolledComposite
|
||||
ScrolledComposite scrolledCompositeFileViewer = new ScrolledComposite(group, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NONE);
|
||||
scrolledCompositeFileViewer.setExpandHorizontal(true);
|
||||
scrolledCompositeFileViewer.setExpandVertical(true);
|
||||
GridData gridData1 = new GridData(GridData.FILL_BOTH);
|
||||
gridData1.widthHint = width + 12;
|
||||
gridData1.heightHint = height;
|
||||
gridData1.horizontalSpan = 2;
|
||||
scrolledCompositeFileViewer.setLayoutData(gridData1);
|
||||
|
||||
tableViewerCreator = new TableViewerCreator(scrolledCompositeFileViewer);
|
||||
tableViewerCreator.setHeaderVisible(false);
|
||||
tableViewerCreator.setColumnsResizableByDefault(false);
|
||||
tableViewerCreator.setBorderVisible(false);
|
||||
tableViewerCreator.setLinesVisible(false);
|
||||
tableViewerCreator.setLayoutMode(LAYOUT_MODE.NONE);
|
||||
tableViewerCreator.setCheckboxInFirstColumn(false);
|
||||
tableViewerCreator.setFirstColumnMasked(false);
|
||||
|
||||
tableNavigator = tableViewerCreator.createTable();
|
||||
tableNavigator.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
TableColumn tableColumn = new TableColumn(tableNavigator, SWT.NONE);
|
||||
tableColumn.setText(Messages.getString("DatabaseTableForm.tableColumnText.talbe")); //$NON-NLS-1$
|
||||
tableColumn.setWidth(width + 120);
|
||||
|
||||
scrolledCompositeFileViewer.setContent(tableNavigator);
|
||||
scrolledCompositeFileViewer.setSize(width + 12, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC YeXiaowei Comment method "addSalesforcePreviewGroup".
|
||||
*/
|
||||
private void addSalesforcePreviewGroup(Composite mainComposite) {
|
||||
// Group previewGroup = Form.createGroup(this, 2, "Salesforce Preview");
|
||||
|
||||
tabFolder = new CTabFolder(mainComposite, SWT.BORDER);
|
||||
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
previewTabItem = new CTabItem(tabFolder, SWT.BORDER);
|
||||
previewTabItem.setText(Messages.getString("SalesforceStep2Form.preview")); //$NON-NLS-1$
|
||||
outputTabItem = new CTabItem(tabFolder, SWT.BORDER);
|
||||
outputTabItem.setText(Messages.getString("SalesforceStep2Form.output")); //$NON-NLS-1$
|
||||
|
||||
Composite previewComposite = Form.startNewGridLayout(tabFolder, 1);
|
||||
outputComposite = Form.startNewGridLayout(tabFolder, 1);
|
||||
|
||||
previewButton = new Button(previewComposite, SWT.NONE);
|
||||
previewButton.setText(Messages.getString("FileStep2.refreshPreview")); //$NON-NLS-1$
|
||||
previewButton.setSize(WIDTH_BUTTON_PIXEL, HEIGHT_BUTTON_PIXEL);
|
||||
|
||||
previewInformationLabel = new Label(previewComposite, SWT.NONE);
|
||||
previewInformationLabel
|
||||
.setText(" "); //$NON-NLS-1$
|
||||
previewInformationLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLUE));
|
||||
|
||||
salesforcePreviewProcess = new ShadowProcessPreview(previewComposite, null, 600, 200);
|
||||
salesforcePreviewProcess.newTablePreview();
|
||||
|
||||
previewTabItem.setControl(previewComposite);
|
||||
outputTabItem.setControl(outputComposite);
|
||||
tabFolder.setSelection(previewTabItem);
|
||||
tabFolder.pack();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC YeXiaowei Comment method "addQueryConditionGroup".
|
||||
*/
|
||||
private void addQueryConditionGroup(Composite parent, int tableCompositeHeight) {
|
||||
Group queryConditionGroup = Form.createGroup(parent, 2,
|
||||
Messages.getString("SalesforceStep2Form.queryCondition"), tableCompositeHeight); //$NON-NLS-1$
|
||||
|
||||
queryConditionText = new LabelledText(queryConditionGroup, "Query Condition", true); //$NON-NLS-1$
|
||||
queryConditionText.setText(defaultQueryString);
|
||||
|
||||
Composite moduleViewerComposite = new Composite(queryConditionGroup, SWT.NONE);
|
||||
|
||||
GridData data = new GridData(GridData.FILL_BOTH);
|
||||
data.horizontalSpan = 2;
|
||||
moduleViewerComposite.setLayoutData(data);
|
||||
|
||||
moduleViewerComposite.setLayout(new GridLayout(2, true));
|
||||
|
||||
Label label = new Label(moduleViewerComposite, SWT.NONE);
|
||||
label.setText(Messages.getString("SalesforceStep2Form.saleforceDetail")); //$NON-NLS-1$
|
||||
label.setLayoutData(new GridData(GridData.FILL | GridData.BEGINNING));
|
||||
|
||||
alphabet = new Button(moduleViewerComposite, SWT.CHECK);
|
||||
alphabet.setText(Messages.getString("SalesforceStep2Form.orderTheFields")); //$NON-NLS-1$
|
||||
alphabet.setLayoutData(new GridData(GridData.CENTER));
|
||||
|
||||
createModuleDetailViewer(moduleViewerComposite);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC YeXiaowei Comment method "readAndSetModuleDetailContent".
|
||||
*/
|
||||
private void readAndSetModuleDetailContent() {
|
||||
org.talend.core.model.metadata.builder.connection.MetadataTable table = getTableByLabel(moduleName);
|
||||
if (table != null) {
|
||||
IMetadataTable metadataTable = ConvertionHelper.convert(table);
|
||||
|
||||
if (metadataTable != null) {
|
||||
if (useAlphbet) {
|
||||
List<IMetadataColumn> listColumns = metadataTable.getListColumns();
|
||||
if (listColumns != null) {
|
||||
moduleViewer.setInput(listColumns.toArray());
|
||||
}
|
||||
} else {
|
||||
List<IMetadataColumn> listColumns = metadataTable.getListColumns();
|
||||
if (listColumns != null) {
|
||||
|
||||
moduleViewer.setInput(listColumns.toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.swt.utils.AbstractForm#addFieldsListeners()
|
||||
*/
|
||||
@Override
|
||||
protected org.talend.core.model.metadata.builder.connection.MetadataTable getTableByLabel(String label) {
|
||||
org.talend.core.model.metadata.builder.connection.MetadataTable result = null;
|
||||
EList<SalesforceModuleUnit> modules = null;
|
||||
if (temConnection == null) {
|
||||
modules = getConnection().getModules();
|
||||
} else {
|
||||
modules = temConnection.getModules();
|
||||
}
|
||||
for (int i = 0; i < modules.size(); i++) {
|
||||
if (modules.get(i).getModuleName().equals(moduleName)) {
|
||||
for (int j = 0; j < modules.get(i).getTables().size(); j++) {
|
||||
if (modules.get(i).getTables().get(j).getLabel().equals(label)) {
|
||||
result = modules.get(i).getTables().get(j);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addFieldsListeners() {
|
||||
// Navigation : when the user select a table
|
||||
tableNavigator.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
String schemaLabel = tableNavigator.getSelection()[0].getText();
|
||||
temConnection.setModuleName(schemaLabel);
|
||||
getConnection().setModuleName(schemaLabel);
|
||||
org.talend.core.model.metadata.builder.connection.MetadataTable table = getTableByLabel(schemaLabel);
|
||||
metadataTable = ConvertionHelper.convert(table);
|
||||
List<IMetadataColumn> listColumns = metadataTable.getListColumns();
|
||||
if (listColumns != null) {
|
||||
moduleViewer.setInput(listColumns.toArray());
|
||||
}
|
||||
}
|
||||
});
|
||||
queryConditionText.addModifyListener(new ModifyListener() {
|
||||
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
if (!isContextMode()) {
|
||||
if (checkFieldsValue()) {
|
||||
getConnection().setQueryCondition(queryConditionText.getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
alphabet.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
useAlphbet = alphabet.getSelection();
|
||||
getConnection().setUseAlphbet(useAlphbet);
|
||||
metadataTableOrder = readMetadataDetail();
|
||||
metadataTableClone = metadataTableOrder.clone();
|
||||
Object input = moduleViewer.getInput();
|
||||
if (input instanceof Object[]) {
|
||||
if (useAlphbet) {
|
||||
modifyMetadataTable();
|
||||
List<IMetadataColumn> listColumns = metadataTableOrder.getListColumns();
|
||||
if (listColumns != null) {
|
||||
moduleViewer.setInput(listColumns.toArray());
|
||||
}
|
||||
} else {
|
||||
List<IMetadataColumn> listColumns = metadataTableClone.getListColumns();
|
||||
if (listColumns != null) {
|
||||
moduleViewer.setInput(listColumns.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
moduleViewer.refresh();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.swt.utils.AbstractForm#addUtilsButtonListeners()
|
||||
*/
|
||||
@Override
|
||||
protected void addUtilsButtonListeners() {
|
||||
// Event PreviewButton
|
||||
previewButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(final SelectionEvent e) {
|
||||
processor.execute();
|
||||
}
|
||||
});
|
||||
|
||||
if (cancelButton != null) {
|
||||
// Event CancelButton
|
||||
cancelButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(final SelectionEvent e) {
|
||||
getShell().close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.swt.utils.AbstractForm#checkFieldsValue()
|
||||
*/
|
||||
@Override
|
||||
protected boolean checkFieldsValue() {
|
||||
previewInformationLabel.setText(" " + Messages.getString("FileStep2.settingsIncomplete")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
updateStatus(IStatus.OK, null);
|
||||
previewButton.setEnabled(false);
|
||||
previewInformationLabel.setText(""); //$NON-NLS-1$
|
||||
previewButton.setEnabled(true);
|
||||
|
||||
updateStatus(IStatus.OK, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.swt.utils.AbstractForm#initialize()
|
||||
*/
|
||||
@Override
|
||||
protected void initialize() {
|
||||
|
||||
String queryCondition = getConnection().getQueryCondition();
|
||||
if (queryCondition != null && !queryCondition.equals("")) { //$NON-NLS-1$
|
||||
queryConditionText.setText(queryCondition);
|
||||
} else {
|
||||
queryConditionText.setText(""); //$NON-NLS-1$
|
||||
}
|
||||
useAlphbet = getConnection().isUseAlphbet();
|
||||
alphabet.setSelection(useAlphbet);
|
||||
|
||||
checkFieldsValue();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
|
||||
super.setVisible(visible);
|
||||
|
||||
if (super.isVisible()) {
|
||||
if (!isContextMode()) {
|
||||
if ((!"".equals(temConnection.getWebServiceUrl())) && (temConnection.getModuleName() != null)) { //$NON-NLS-1$
|
||||
refreshPreview();
|
||||
}
|
||||
}
|
||||
|
||||
if (isReadOnly() != readOnly) {
|
||||
adaptFormToReadOnly();
|
||||
}
|
||||
if (isContextMode()) {
|
||||
adaptFormToEditable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC YeXiaowei Comment method "refreshPreview".
|
||||
*/
|
||||
private void refreshPreview() {
|
||||
initTreeNavigatorNodes();
|
||||
// processor.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC YeXiaowei SalesforceStep2Form class global comment. Detailled comment <br/>
|
||||
*
|
||||
*/
|
||||
class PreviewProcessor extends SWTUIThreadProcessor {
|
||||
|
||||
String previewInformationLabelMsg = null;
|
||||
|
||||
CsvArray csvArray = null;
|
||||
|
||||
ProcessDescription processDescription = null;
|
||||
|
||||
boolean firstRowIsCatption = false;
|
||||
|
||||
@Override
|
||||
public boolean preProcessStart() {
|
||||
previewButton.setText(Messages.getString("FileStep2.stop")); //$NON-NLS-1$
|
||||
|
||||
clearPreview();
|
||||
String webServiceUrl = getConnection().getWebServiceUrl();
|
||||
SalesforceSchemaConnection originalValueConnection = null;
|
||||
if (isContextMode()) {
|
||||
boolean found = false;
|
||||
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(getShell(), getConnection());
|
||||
if (contextType != null) {
|
||||
if (getContextModeManager() != null) {
|
||||
getContextModeManager().setSelectedContextType(contextType);
|
||||
webServiceUrl = getContextModeManager().getOriginalValue(getConnection().getWebServiceUrl());
|
||||
found = true;
|
||||
}
|
||||
originalValueConnection = OtherConnectionContextUtils.cloneOriginalValueSalesforceConnection(getConnection(),
|
||||
contextType);
|
||||
}
|
||||
if (!found) {
|
||||
webServiceUrl = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (webServiceUrl == null || webServiceUrl.equals("")) { //$NON-NLS-1$
|
||||
previewInformationLabel.setText(" Please reset Salesforce URL"); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!checkFieldsValue()) {
|
||||
previewInformationLabel.setText(" " + Messages.getString("FileStep2.settingsIncomplete")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return false;
|
||||
}
|
||||
|
||||
previewInformationLabel.setText(" " + Messages.getString("FileStep2.previewProgress")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
firstRowIsCatption = false;
|
||||
if (originalValueConnection == null) {
|
||||
originalValueConnection = getConnection();
|
||||
}
|
||||
processDescription = getProcessDescription(originalValueConnection);
|
||||
updateStatus(IStatus.ERROR, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nonUIProcessInThread() {
|
||||
// get the XmlArray width an adapt ProcessDescription
|
||||
try {
|
||||
List<IMetadataTable> schema = processDescription.getSchema();
|
||||
if (schema != null && schema.size() > 0) {
|
||||
if (useAlphbet) {
|
||||
if (metadataTableOrder == null) {
|
||||
metadataTableOrder = schema.get(0);
|
||||
metadataTableOrder = modifyMetadataTable();
|
||||
}
|
||||
if (metadataTableOrder != null) {
|
||||
schema.get(0).setListColumns(metadataTableOrder.getListColumns());
|
||||
}
|
||||
} else {
|
||||
if (metadataTableClone == null) {
|
||||
metadataTableClone = schema.get(0);
|
||||
}
|
||||
if (metadataTableClone != null) {
|
||||
schema.get(0).setListColumns(metadataTableClone.getListColumns());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
csvArray = ShadowProcessHelper.getCsvArray(processDescription, "SALESFORCE_SCHEMA", true); //$NON-NLS-1$
|
||||
if (csvArray == null) {
|
||||
previewInformationLabelMsg = " " + Messages.getString("FileStep2.previewFailure"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} else {
|
||||
previewInformationLabelMsg = " " + Messages.getString("FileStep2.previewIsDone"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
// refresh TablePreview on this step
|
||||
previewInformationLabelMsg = ""; //$NON-NLS-1$
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
setException(ex);
|
||||
previewInformationLabelMsg = " " + Messages.getString("FileStep2.previewFailure"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUIInThreadIfThreadIsCanceled() {
|
||||
if (!previewInformationLabel.isDisposed()) {
|
||||
previewInformationLabel.setText(""); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUIInThreadIfThreadIsNotCanceled() {
|
||||
if (previewInformationLabel.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
previewInformationLabel.setText(previewInformationLabelMsg);
|
||||
if (getException() != null) {
|
||||
|
||||
// new ErrorDialogWidthDetailArea(getShell(), PID,
|
||||
// Messages.getString("FileStep2.previewFailure"), getException().getMessage()); //$NON-NLS-1$
|
||||
previewInformationLabel.setText(" " + Messages.getString("FileStep2.previewFailure")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
handleErrorOutput(outputComposite, tabFolder, outputTabItem);
|
||||
}
|
||||
});
|
||||
return;
|
||||
|
||||
}
|
||||
if (csvArray != null) {
|
||||
salesforcePreviewProcess.refreshTablePreview(csvArray, firstRowIsCatption, processDescription);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUIInThreadIfThreadFinally() {
|
||||
checkFieldsValue();
|
||||
if (!previewButton.isDisposed()) {
|
||||
previewButton.setText(Messages.getString("FileStep2.refreshPreview")); //$NON-NLS-1$
|
||||
previewButton.setEnabled(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessCancle() {
|
||||
checkFieldsValue();
|
||||
previewButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void clearPreview() {
|
||||
salesforcePreviewProcess.clearTablePreview();
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC YeXiaowei Comment method "getProcessDescription".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private ProcessDescription getProcessDescription(SalesforceSchemaConnection originalValueConnection) {
|
||||
|
||||
ProcessDescription processDescription = ShadowProcessHelper.getProcessDescription(originalValueConnection);
|
||||
|
||||
SalesforceSchemaBean bean = new SalesforceSchemaBean();
|
||||
bean.setWebServerUrl(originalValueConnection.getWebServiceUrl());
|
||||
bean.setUserName(originalValueConnection.getUserName());
|
||||
bean.setPassword(originalValueConnection.getValue(originalValueConnection.getPassword(), false));
|
||||
bean.setModuleName(originalValueConnection.getModuleName());
|
||||
bean.setQueryCondition(originalValueConnection.getQueryCondition());
|
||||
bean.setUseCustomModule(originalValueConnection.isUseCustomModuleName());
|
||||
bean.setBatchSize(originalValueConnection.getBatchSize());
|
||||
bean.setUseProxy(originalValueConnection.isUseProxy());
|
||||
bean.setUesHttp(originalValueConnection.isUseHttpProxy());
|
||||
bean.setProxyHost(originalValueConnection.getProxyHost());
|
||||
bean.setProxyPort(originalValueConnection.getProxyPort());
|
||||
bean.setProxyUsername(originalValueConnection.getProxyUsername());
|
||||
bean.setProxyPassword(originalValueConnection.getValue(originalValueConnection.getProxyPassword(), false));
|
||||
try {
|
||||
bean.setTimeOut(Integer.parseInt(originalValueConnection.getTimeOut()));
|
||||
} catch (NumberFormatException e) {
|
||||
// use default
|
||||
}
|
||||
processDescription.setSalesforceSchemaBean(bean);
|
||||
|
||||
IMetadataTable tableGet = getMetadatasForSalesforce(bean.getWebServerUrl(), bean.getUserName(), bean.getPassword(),
|
||||
String.valueOf(bean.getTimeOut()), bean.getModuleName(), bean.getBatchSize(), bean.isUseProxy(),
|
||||
bean.isUesHttp(), bean.getProxyHost(), bean.getProxyPort(), bean.getProxyUsername(), bean.getProxyPassword(),
|
||||
false);
|
||||
|
||||
List<IMetadataTable> tableSchema = new ArrayList<IMetadataTable>();
|
||||
IMetadataTable table = new MetadataTable();
|
||||
List<IMetadataColumn> schema = new ArrayList<IMetadataColumn>();
|
||||
|
||||
for (IMetadataColumn column : tableGet.getListColumns()) {
|
||||
schema.add(column.clone());
|
||||
}
|
||||
|
||||
table.setTableName("tSalesforceInput"); //$NON-NLS-1$
|
||||
table.setListColumns(schema);
|
||||
tableSchema.add(table);
|
||||
|
||||
processDescription.setSchema(tableSchema);
|
||||
|
||||
processDescription.setEncoding(TalendQuoteUtils.addQuotes("ISO-8859-15")); //$NON-NLS-1$
|
||||
if (tableGet != null) {
|
||||
moduleViewer.getTable().clearAll();
|
||||
if (useAlphbet) {
|
||||
if (metadataTableOrder == null) {
|
||||
List<IMetadataTable> schema2 = processDescription.getSchema();
|
||||
if (schema2 != null && schema2.size() > 0) {
|
||||
metadataTableOrder = schema2.get(0);
|
||||
metadataTableOrder = modifyMetadataTable();
|
||||
}
|
||||
}
|
||||
if (metadataTableOrder != null) {
|
||||
tableGet.setListColumns(metadataTableOrder.getListColumns());
|
||||
}
|
||||
} else {
|
||||
if (metadataTableClone == null) {
|
||||
List<IMetadataTable> schema2 = processDescription.getSchema();
|
||||
if (schema2 != null && schema2.size() > 0) {
|
||||
metadataTableClone = schema2.get(0);
|
||||
}
|
||||
}
|
||||
if (metadataTableClone != null) {
|
||||
tableGet.setListColumns(metadataTableClone.getListColumns());
|
||||
}
|
||||
}
|
||||
moduleViewer.setInput(tableGet.getListColumns().toArray());
|
||||
moduleViewer.refresh();
|
||||
}
|
||||
|
||||
return processDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC YeXiaowei Comment method "createModuleDetailViewer".
|
||||
*
|
||||
* @param moduleGroup
|
||||
*/
|
||||
private void createModuleDetailViewer(Composite moduleGroup) {
|
||||
moduleViewer = new TableViewer(moduleGroup, SWT.FILL | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
|
||||
|
||||
moduleViewer.getTable().setHeaderVisible(true);
|
||||
moduleViewer.getTable().setLinesVisible(true);
|
||||
GridData gridData = new GridData(GridData.FILL_BOTH);
|
||||
gridData.horizontalSpan = 2;
|
||||
moduleViewer.getTable().setLayoutData(gridData);
|
||||
|
||||
moduleViewer.setContentProvider(new IStructuredContentProvider() {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
if (inputElement instanceof Object[]) {
|
||||
return (Object[]) inputElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
moduleViewer.setLabelProvider(new ITableLabelProvider() {
|
||||
|
||||
@Override
|
||||
public Image getColumnImage(Object element, int columnIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnText(Object element, int columnIndex) {
|
||||
if (element instanceof IMetadataColumn) {
|
||||
IMetadataColumn metadataColumn = (IMetadataColumn) element;
|
||||
String title = null;
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
title = metadataColumn.getLabel();
|
||||
break;
|
||||
case 1:
|
||||
title = metadataColumn.isKey() ? "true" : "false"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
break;
|
||||
case 2:
|
||||
String talendType = metadataColumn.getTalendType();
|
||||
JavaType javaTypeFromId = JavaTypesManager.getJavaTypeFromId(talendType);
|
||||
if (javaTypeFromId != null) {
|
||||
title = javaTypeFromId.getLabel();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
title = metadataColumn.isNullable() ? "true" : "false"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
break;
|
||||
case 4:
|
||||
title = metadataColumn.getPattern();
|
||||
break;
|
||||
case 5:
|
||||
title = getStringFromInt(metadataColumn.getLength());
|
||||
break;
|
||||
case 6:
|
||||
title = getStringFromInt(metadataColumn.getPrecision());
|
||||
break;
|
||||
case 7:
|
||||
title = metadataColumn.getDefault();
|
||||
break;
|
||||
case 8:
|
||||
title = metadataColumn.getComment();
|
||||
break;
|
||||
default:
|
||||
title = Messages.getString("SalesforceStep2Form.otherTitle"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getStringFromInt(int x) {
|
||||
try {
|
||||
return Integer.toString(x);
|
||||
} catch (Error e) {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(ILabelProviderListener listener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLabelProperty(Object element, String property) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(ILabelProviderListener listener) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
String[] titles = new String[] { "Column", "Key", "Type", "Nullable", "Data Pattern", "Length", "Precision", "Default", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
|
||||
"Comment" }; //$NON-NLS-1$
|
||||
|
||||
for (String title : titles) {
|
||||
int width = COLUMN_WIDTH;
|
||||
if (title.equals("Column") || title.equals("Data Pattern") || title.equals("Comment")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
width = COLUMN_WIDTH * 2;
|
||||
}
|
||||
createTableColumn(title, width);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createTableColumn(String title, int width) {
|
||||
TableColumn column = new TableColumn(moduleViewer.getTable(), SWT.NONE);
|
||||
column.setText(title);
|
||||
if (width < COLUMN_WIDTH || width > 400) {
|
||||
column.setWidth(COLUMN_WIDTH);
|
||||
} else {
|
||||
column.setWidth(width);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adaptFormToEditable() {
|
||||
super.adaptFormToEditable();
|
||||
queryConditionText.setEditable(!isContextMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void exportAsContext() {
|
||||
super.exportAsContext();
|
||||
if (getContextModeManager() != null) {
|
||||
getContextModeManager().setDefaultContextType(getConnection());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processWhenDispose() {
|
||||
if (processor != null) {
|
||||
processor.forceStop();
|
||||
}
|
||||
}
|
||||
|
||||
private void initTreeNavigatorNodes() {
|
||||
List<String> selectedNames = new ArrayList<String>();
|
||||
EList<SalesforceModuleUnit> modules = temConnection.getModules();
|
||||
// EList<SalesforceModuleUnit> modules = getConnection().getModules();
|
||||
selectedNames.add(moduleName);
|
||||
// for (int i = 0; i < modules.size(); i++) {
|
||||
// if (modules.get(i).getModuleName().equals(moduleName)) {
|
||||
//
|
||||
// for (int j = 0; j < modules.get(i).getTables().size(); j++) {
|
||||
// selectedNames.add(modules.get(i).getTables().get(j).getLabel());
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
tableNavigator.removeAll();
|
||||
if (selectedNames != null && selectedNames.size() >= 1) {
|
||||
for (int i = 0; i < selectedNames.size(); i++) {
|
||||
TableItem subItem = new TableItem(tableNavigator, SWT.NULL);
|
||||
subItem.setText(selectedNames.get(i));
|
||||
tableNavigator.setSelection(subItem);
|
||||
}
|
||||
} else {
|
||||
TableItem subItem = new TableItem(tableNavigator, SWT.NULL);
|
||||
subItem.setText(getConnection().getModuleName());
|
||||
}
|
||||
readAndSetModuleDetailContent();
|
||||
}
|
||||
}
|
||||
@@ -1,623 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.KeyAdapter;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.talend.commons.ui.swt.formtools.Form;
|
||||
import org.talend.commons.ui.swt.formtools.LabelledText;
|
||||
import org.talend.commons.ui.swt.formtools.UtilsButton;
|
||||
import org.talend.commons.utils.data.list.IListenableListListener;
|
||||
import org.talend.commons.utils.data.list.ListenableListEvent;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.language.LanguageManager;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.IMetadataContextModeManager;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MetadataTalendType;
|
||||
import org.talend.core.model.metadata.MetadataToolHelper;
|
||||
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.SalesforceSchemaConnection;
|
||||
import org.talend.core.model.metadata.types.JavaDataTypeHelper;
|
||||
import org.talend.core.model.metadata.types.JavaTypesManager;
|
||||
import org.talend.core.model.metadata.types.PerlDataTypeHelper;
|
||||
import org.talend.core.model.metadata.types.PerlTypesManager;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.repository.model.preview.SalesforceSchemaBean;
|
||||
import org.talend.core.ui.metadata.editor.MetadataEmfTableEditor;
|
||||
import org.talend.core.ui.metadata.editor.MetadataEmfTableEditorView;
|
||||
import org.talend.core.utils.CsvArray;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.metadata.managment.ui.preview.ProcessDescription;
|
||||
import org.talend.metadata.managment.ui.utils.ConnectionContextHelper;
|
||||
import org.talend.metadata.managment.ui.utils.OtherConnectionContextUtils;
|
||||
import org.talend.metadata.managment.ui.utils.ShadowProcessHelper;
|
||||
import org.talend.metadata.managment.ui.wizard.metadata.MetadataContextModeManager;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
import org.talend.repository.metadata.ui.wizards.form.AbstractSalesforceStepForm;
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC yexiaowei class global comment. Detailled comment
|
||||
*/
|
||||
public class SalesforceStep3Form extends AbstractSalesforceStepForm {
|
||||
|
||||
private static Logger log = Logger.getLogger(SalesforceStep3Form.class);
|
||||
|
||||
private static final int WIDTH_GRIDDATA_PIXEL = 750;
|
||||
|
||||
private UtilsButton cancelButton;
|
||||
|
||||
private UtilsButton guessButton;
|
||||
|
||||
private MetadataEmfTableEditor metadataEditor;
|
||||
|
||||
private MetadataEmfTableEditorView tableEditorView;
|
||||
|
||||
private Label informationLabel;
|
||||
|
||||
private final MetadataTable metadataTable;
|
||||
|
||||
private LabelledText metadataNameText;
|
||||
|
||||
private LabelledText metadataCommentText;
|
||||
|
||||
private boolean readOnly;
|
||||
|
||||
/**
|
||||
* Constructor to use by RCP Wizard.
|
||||
*
|
||||
* @param Composite
|
||||
*/
|
||||
public SalesforceStep3Form(Composite parent, ConnectionItem connectionItem, MetadataTable metadataTable,
|
||||
String[] existingNames, SalesforceModuleParseAPI salesforceAPI) {
|
||||
this(parent, connectionItem, metadataTable, existingNames, salesforceAPI, null);
|
||||
}
|
||||
|
||||
public SalesforceStep3Form(Composite parent, ConnectionItem connectionItem, MetadataTable metadataTable,
|
||||
String[] existingNames, SalesforceModuleParseAPI salesforceAPI, IMetadataContextModeManager contextModeManager) {
|
||||
super(parent, connectionItem, metadataTable, existingNames, salesforceAPI);
|
||||
this.connectionItem = connectionItem;
|
||||
this.metadataTable = metadataTable;
|
||||
setConnectionItem(connectionItem);
|
||||
setContextModeManager(contextModeManager);
|
||||
setupForm();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Initialize value, forceFocus first field.
|
||||
*/
|
||||
@Override
|
||||
protected void initialize() {
|
||||
// init the metadata Table
|
||||
String label = MetadataToolHelper.validateValue(metadataTable.getLabel());
|
||||
metadataNameText.setText(label);
|
||||
metadataCommentText.setText(metadataTable.getComment());
|
||||
metadataEditor.setMetadataTable(metadataTable);
|
||||
tableEditorView.setMetadataEditor(metadataEditor);
|
||||
tableEditorView.getTableViewerCreator().layout();
|
||||
|
||||
if (getConnection().isReadOnly()) {
|
||||
adaptFormToReadOnly();
|
||||
} else {
|
||||
updateStatus(IStatus.OK, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adaptFormToReadOnly() {
|
||||
readOnly = isReadOnly();
|
||||
guessButton.setEnabled(!isReadOnly());
|
||||
metadataNameText.setReadOnly(isReadOnly());
|
||||
metadataCommentText.setReadOnly(isReadOnly());
|
||||
tableEditorView.setReadOnly(isReadOnly());
|
||||
|
||||
// if (getParent().getChildren().length == 1) { // open the table
|
||||
// guessButton.setEnabled(false);
|
||||
// informationLabel.setVisible(false);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addFields() {
|
||||
|
||||
// Header Fields
|
||||
Composite mainComposite = Form.startNewDimensionnedGridLayout(this, 2, WIDTH_GRIDDATA_PIXEL, 60);
|
||||
metadataNameText = new LabelledText(mainComposite, Messages.getString("FileStep3.metadataName")); //$NON-NLS-1$
|
||||
metadataCommentText = new LabelledText(mainComposite, Messages.getString("FileStep3.metadataComment")); //$NON-NLS-1$
|
||||
|
||||
// Group MetaData
|
||||
Group groupMetaData = Form.createGroup(this, 1, Messages.getString("FileStep3.groupMetadata"), 280); //$NON-NLS-1$
|
||||
Composite compositeMetaData = Form.startNewGridLayout(groupMetaData, 1);
|
||||
|
||||
// Composite Guess
|
||||
Composite compositeGuessButton = Form.startNewDimensionnedGridLayout(compositeMetaData, 2, WIDTH_GRIDDATA_PIXEL, 40);
|
||||
informationLabel = new Label(compositeGuessButton, SWT.NONE);
|
||||
informationLabel
|
||||
.setText(Messages.getString("FileStep3.informationLabel") + " "); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
informationLabel.setSize(500, HEIGHT_BUTTON_PIXEL);
|
||||
|
||||
guessButton = new UtilsButton(compositeGuessButton, Messages.getString("FileStep3.guess"), WIDTH_BUTTON_PIXEL, //$NON-NLS-1$
|
||||
HEIGHT_BUTTON_PIXEL);
|
||||
guessButton.setToolTipText(Messages.getString("FileStep3.guessTip")); //$NON-NLS-1$
|
||||
|
||||
// Composite MetadataTableEditorView
|
||||
Composite compositeTable = Form.startNewDimensionnedGridLayout(compositeMetaData, 1, WIDTH_GRIDDATA_PIXEL, 200);
|
||||
compositeTable.setLayout(new FillLayout());
|
||||
metadataEditor = new MetadataEmfTableEditor(Messages.getString("FileStep3.metadataDescription")); //$NON-NLS-1$
|
||||
tableEditorView = new MetadataEmfTableEditorView(compositeTable, SWT.NONE);
|
||||
|
||||
if (!isInWizard()) {
|
||||
// Bottom Button
|
||||
Composite compositeBottomButton = Form.startNewGridLayout(this, 2, false, SWT.CENTER, SWT.CENTER);
|
||||
// Button Cancel
|
||||
cancelButton = new UtilsButton(compositeBottomButton, Messages.getString("CommonWizard.cancel"), WIDTH_BUTTON_PIXEL, //$NON-NLS-1$
|
||||
HEIGHT_BUTTON_PIXEL);
|
||||
}
|
||||
addUtilsButtonListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addFieldsListeners() {
|
||||
// metadataNameText : Event modifyText
|
||||
metadataNameText.addModifyListener(new ModifyListener() {
|
||||
|
||||
@Override
|
||||
public void modifyText(final ModifyEvent e) {
|
||||
MetadataToolHelper.validateSchema(metadataNameText.getText());
|
||||
metadataTable.setLabel(metadataNameText.getText());
|
||||
checkFieldsValue();
|
||||
}
|
||||
});
|
||||
// metadataNameText : Event KeyListener
|
||||
metadataNameText.addKeyListener(new KeyAdapter() {
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
MetadataToolHelper.checkSchema(getShell(), e);
|
||||
}
|
||||
});
|
||||
|
||||
// metadataCommentText : Event modifyText
|
||||
metadataCommentText.addModifyListener(new ModifyListener() {
|
||||
|
||||
@Override
|
||||
public void modifyText(final ModifyEvent e) {
|
||||
metadataTable.setComment(metadataCommentText.getText());
|
||||
}
|
||||
});
|
||||
|
||||
// add listener to tableMetadata (listen the event of the toolbars)
|
||||
tableEditorView.getMetadataEditor().addAfterOperationListListener(new IListenableListListener() {
|
||||
|
||||
@Override
|
||||
public void handleEvent(ListenableListEvent event) {
|
||||
checkFieldsValue();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* addButtonControls.
|
||||
*
|
||||
* @param cancelButton
|
||||
*/
|
||||
@Override
|
||||
protected void addUtilsButtonListeners() {
|
||||
|
||||
// Event guessButton
|
||||
guessButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(final SelectionEvent e) {
|
||||
if (tableEditorView.getMetadataEditor().getBeanCount() > 0) {
|
||||
|
||||
if (!guessButton.getEnabled()) {
|
||||
guessButton.setEnabled(true);
|
||||
if (MessageDialog.openConfirm(getShell(), Messages.getString("FileStep3.guessConfirmation"), Messages //$NON-NLS-1$
|
||||
.getString("FileStep3.guessConfirmationMessage"))) { //$NON-NLS-1$
|
||||
runShadowProcess();
|
||||
}
|
||||
} else {
|
||||
guessButton.setEnabled(false);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (!guessButton.getEnabled()) {
|
||||
guessButton.setEnabled(true);
|
||||
runShadowProcess();
|
||||
} else {
|
||||
guessButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
if (cancelButton != null) {
|
||||
// Event CancelButton
|
||||
cancelButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(final SelectionEvent e) {
|
||||
getShell().close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* create ProcessDescription and set it.
|
||||
*
|
||||
* WARNING ::field FieldSeparator, RowSeparator, EscapeChar and TextEnclosure are surround by double quote.
|
||||
*
|
||||
*
|
||||
* @return processDescription
|
||||
*/
|
||||
private ProcessDescription getProcessDescription(SalesforceSchemaConnection originalValueConnection) {
|
||||
|
||||
ProcessDescription processDescription = ShadowProcessHelper.getProcessDescription(originalValueConnection);
|
||||
|
||||
SalesforceSchemaBean bean = new SalesforceSchemaBean();
|
||||
|
||||
bean.setWebServerUrl(originalValueConnection.getWebServiceUrl());
|
||||
bean.setUserName(originalValueConnection.getUserName());
|
||||
bean.setPassword(originalValueConnection.getValue(originalValueConnection.getPassword(), false));
|
||||
bean.setModuleName(originalValueConnection.getModuleName());
|
||||
bean.setQueryCondition(originalValueConnection.getQueryCondition());
|
||||
// add for feature 7507
|
||||
bean.setBatchSize(originalValueConnection.getBatchSize());
|
||||
bean.setUseProxy(originalValueConnection.isUseProxy());
|
||||
bean.setUesHttp(originalValueConnection.isUseHttpProxy());
|
||||
bean.setProxyHost(originalValueConnection.getProxyHost());
|
||||
bean.setProxyPort(originalValueConnection.getProxyPort());
|
||||
bean.setProxyUsername(originalValueConnection.getProxyUsername());
|
||||
bean.setProxyPassword(originalValueConnection.getValue(originalValueConnection.getProxyPassword(), false));
|
||||
|
||||
processDescription.setSalesforceSchemaBean(bean);
|
||||
|
||||
List<IMetadataTable> tableSchema = new ArrayList<IMetadataTable>();
|
||||
IMetadataTable tableGet = getMetadatasForSalesforce(bean.getWebServerUrl(), bean.getUserName(), bean.getPassword(),
|
||||
String.valueOf(bean.getTimeOut()), bean.getModuleName(), bean.getBatchSize(), bean.isUseProxy(),
|
||||
bean.isUesHttp(), bean.getProxyHost(), bean.getProxyPort(), bean.getProxyUsername(), bean.getProxyPassword(),
|
||||
false);
|
||||
|
||||
IMetadataTable table = new org.talend.core.model.metadata.MetadataTable();
|
||||
List<IMetadataColumn> schema = new ArrayList<IMetadataColumn>();
|
||||
for (IMetadataColumn column : tableGet.getListColumns()) {
|
||||
schema.add(column.clone());
|
||||
}
|
||||
|
||||
table.setTableName("tSalesforceInput"); //$NON-NLS-1$
|
||||
table.setListColumns(schema);
|
||||
tableSchema.add(table);
|
||||
|
||||
processDescription.setSchema(tableSchema);
|
||||
|
||||
processDescription.setEncoding(TalendQuoteUtils.addQuotes("ISO-8859-15")); //$NON-NLS-1$
|
||||
|
||||
return processDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* run a ShadowProcess to determined the Metadata.
|
||||
*/
|
||||
protected void runShadowProcess() {
|
||||
initGuessSchema();
|
||||
SalesforceSchemaConnection originalValueConnection = getOriginalValueConnection();
|
||||
// if no file, the process don't be executed
|
||||
if (originalValueConnection.getWebServiceUrl() == null || originalValueConnection.getWebServiceUrl().equals("")) { //$NON-NLS-1$
|
||||
informationLabel.setText("Salesforce endpoint lost" //$NON-NLS-1$
|
||||
+ " "); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
|
||||
// try {
|
||||
informationLabel.setText(" " + Messages.getString("FileStep3.guessProgress")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
// get the XmlArray width an adapt ProcessDescription
|
||||
ProcessDescription processDescription = getProcessDescription(originalValueConnection);
|
||||
|
||||
IMetadataTable metadataTableOrder = readMetadataDetail();
|
||||
if (metadataTableOrder != null) {
|
||||
metadataTableClone = metadataTableOrder.clone();
|
||||
metadataTableOrder = modifyMetadataTable();
|
||||
}
|
||||
List<IMetadataTable> schema = processDescription.getSchema();
|
||||
if (schema != null && schema.size() > 0) {
|
||||
if (useAlphbet) {
|
||||
if (metadataTableOrder != null) {
|
||||
schema.get(0).setListColumns(metadataTableOrder.getListColumns());
|
||||
}
|
||||
} else {
|
||||
if (metadataTableClone != null) {
|
||||
schema.get(0).setListColumns(metadataTableClone.getListColumns());
|
||||
}
|
||||
}
|
||||
}
|
||||
// the web service url is used by tSalesforceInput, see 0004027: Studio crashes when clicking Next on
|
||||
// Step 3 of SF wizard
|
||||
// processDescription.getSalesforceSchemaBean().setWebServerUrl(TSALESFORCE_INPUT_URL);
|
||||
// CsvArray csvArray = ShadowProcessHelper.getCsvArray(processDescription, "SALESFORCE_SCHEMA", true); //$NON-NLS-1$
|
||||
//
|
||||
// if (csvArray == null) {
|
||||
// informationLabel.setText(" " + Messages.getString("FileStep3.guessFailure")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// } else {
|
||||
// refreshMetaDataTable(csvArray, processDescription);
|
||||
// }
|
||||
|
||||
// } catch (CoreException e) {
|
||||
// if (getParent().getChildren().length == 1) {
|
||||
// new ErrorDialogWidthDetailArea(getShell(), PID, Messages.getString("FileStep3.guessFailureTip") + "\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// + Messages.getString("FileStep3.guessFailureTip2"), e.getMessage()); //$NON-NLS-1$
|
||||
// } else {
|
||||
// new ErrorDialogWidthDetailArea(getShell(), PID, Messages.getString("FileStep3.guessFailureTip"), e.getMessage()); //$NON-NLS-1$
|
||||
// }
|
||||
// log.error(Messages.getString("FileStep3.guessFailure") + " " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// }
|
||||
guessSchema(processDescription);
|
||||
checkFieldsValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC zli Comment method "guessSchema".
|
||||
*
|
||||
* @param processDescription
|
||||
*/
|
||||
public void guessSchema(ProcessDescription processDescription) {
|
||||
informationLabel.setText(" " + Messages.getString("FileStep3.guessIsDone")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// clear all items
|
||||
tableEditorView.getMetadataEditor().removeAll();
|
||||
List<MetadataColumn> columns = new ArrayList<MetadataColumn>();
|
||||
|
||||
List<IMetadataColumn> listColumns = processDescription.getSchema().get(0).getListColumns();
|
||||
int size = listColumns.size();
|
||||
if (size > 0) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
MetadataColumn metadataColumn = ConnectionFactory.eINSTANCE.createMetadataColumn();
|
||||
metadataColumn.setNullable(listColumns.get(i).isNullable());
|
||||
metadataColumn.setLength(listColumns.get(i).getLength());
|
||||
metadataColumn.setPattern(listColumns.get(i).getPattern());
|
||||
metadataColumn.setTalendType(listColumns.get(i).getTalendType());
|
||||
metadataColumn.setPrecision(listColumns.get(i).getPrecision());
|
||||
metadataColumn.setLabel(listColumns.get(i).getLabel());
|
||||
columns.add(i, metadataColumn);
|
||||
}
|
||||
}
|
||||
tableEditorView.getMetadataEditor().addAll(columns);
|
||||
tableEditorView.getTableViewerCreator().layout();
|
||||
informationLabel.setText(Messages.getString("FileStep3.guessTip")); //$NON-NLS-1$
|
||||
|
||||
}
|
||||
|
||||
public void refreshMetaDataTable(final CsvArray csvArray, ProcessDescription processDescription) {
|
||||
informationLabel.setText(" " + Messages.getString("FileStep3.guessIsDone")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// clear all items
|
||||
tableEditorView.getMetadataEditor().removeAll();
|
||||
|
||||
List<MetadataColumn> columns = new ArrayList<MetadataColumn>();
|
||||
if (csvArray == null || csvArray.getRows().isEmpty()) {
|
||||
return;
|
||||
} else {
|
||||
|
||||
List<String[]> csvRows = csvArray.getRows();
|
||||
Integer numberOfCol = getRightFirstRow(csvRows);
|
||||
|
||||
// define the label to the metadata width the content of the first row
|
||||
int firstRowToExtractMetadata = 0;
|
||||
List<IMetadataColumn> listColumns = processDescription.getSchema().get(0).getListColumns();
|
||||
// the first rows is used to define the label of any metadata
|
||||
String[] label = new String[numberOfCol.intValue()];
|
||||
for (int i = 0; i < numberOfCol; i++) {
|
||||
label[i] = DEFAULT_LABEL + i;
|
||||
if (firstRowToExtractMetadata == 0) {
|
||||
|
||||
label[i] = "" + listColumns.get(i); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < numberOfCol.intValue(); i++) {
|
||||
// define the first currentType and assimile it to globalType
|
||||
String globalType = null;
|
||||
int lengthValue = 0;
|
||||
int precisionValue = 0;
|
||||
boolean nullAble = true;
|
||||
|
||||
int current = firstRowToExtractMetadata;
|
||||
while (globalType == null) {
|
||||
String value = csvRows.get(current)[i];
|
||||
if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
|
||||
if (i >= csvRows.get(current).length) {
|
||||
globalType = "id_String"; //$NON-NLS-1$
|
||||
} else {
|
||||
if (value != null && !"".equals(value)) { //$NON-NLS-1$
|
||||
globalType = JavaDataTypeHelper.getTalendTypeOfValue(value);
|
||||
} else {
|
||||
globalType = listColumns.get(i).getTalendType();
|
||||
}
|
||||
current++;
|
||||
}
|
||||
} else {
|
||||
if (i >= csvRows.get(current).length) {
|
||||
globalType = "String"; //$NON-NLS-1$
|
||||
} else {
|
||||
globalType = PerlDataTypeHelper.getTalendTypeOfValue(value);
|
||||
current++;
|
||||
}
|
||||
}
|
||||
}
|
||||
nullAble = listColumns.get(i).isNullable();
|
||||
lengthValue = listColumns.get(i).getLength();
|
||||
precisionValue = listColumns.get(i).getPrecision();
|
||||
|
||||
// define the metadataColumn to field i
|
||||
MetadataColumn metadataColumn = ConnectionFactory.eINSTANCE.createMetadataColumn();
|
||||
// Convert javaType to TalendType
|
||||
String talendType = null;
|
||||
if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
|
||||
talendType = globalType;
|
||||
if (globalType.equals(JavaTypesManager.FLOAT.getId()) || globalType.equals(JavaTypesManager.DOUBLE.getId())) {
|
||||
metadataColumn.setPrecision(precisionValue);
|
||||
} else {
|
||||
metadataColumn.setPrecision(0);
|
||||
}
|
||||
} else {
|
||||
talendType = PerlTypesManager.getNewTypeName(MetadataTalendType.loadTalendType(globalType,
|
||||
"TALENDDEFAULT", false)); //$NON-NLS-1$
|
||||
if (globalType.equals("FLOAT") || globalType.equals("DOUBLE")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
metadataColumn.setPrecision(precisionValue);
|
||||
} else {
|
||||
metadataColumn.setPrecision(0);
|
||||
}
|
||||
}
|
||||
|
||||
metadataColumn.setNullable(nullAble);
|
||||
metadataColumn.setTalendType(talendType);
|
||||
metadataColumn.setLength(lengthValue);
|
||||
// bug 6758
|
||||
if (talendType.equals("id_Date")) { //$NON-NLS-1$
|
||||
String pattern = listColumns.get(i).getPattern();
|
||||
metadataColumn.setPattern(pattern);
|
||||
}
|
||||
// Check the label and add it to the table
|
||||
metadataColumn.setLabel(tableEditorView.getMetadataEditor().getNextGeneratedColumnName(label[i]));
|
||||
columns.add(i, metadataColumn);
|
||||
}
|
||||
}
|
||||
// tableEditorView.getMetadataEditor().registerDataList(columns);
|
||||
tableEditorView.getMetadataEditor().addAll(columns);
|
||||
|
||||
checkFieldsValue();
|
||||
tableEditorView.getTableViewerCreator().layout();
|
||||
informationLabel.setText(Messages.getString("FileStep3.guessTip")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// CALCULATE THE NULBER OF COLUMNS IN THE PREVIEW
|
||||
public Integer getRightFirstRow(List<String[]> csvRows) {
|
||||
|
||||
Integer numbersOfColumns = null;
|
||||
int parserLine = csvRows.size();
|
||||
if (parserLine > 50) {
|
||||
parserLine = 50;
|
||||
}
|
||||
for (int i = 0; i < parserLine; i++) {
|
||||
if (csvRows.get(i) != null) {
|
||||
String[] nbRow = csvRows.get(i);
|
||||
// List<XmlField> nbRowFields = nbRow.getFields();
|
||||
if (numbersOfColumns == null || nbRow.length >= numbersOfColumns) {
|
||||
numbersOfColumns = nbRow.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
return numbersOfColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that fields are set. Update checkEnable / use to checkConnection().
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected boolean checkFieldsValue() {
|
||||
if (metadataNameText.getCharCount() == 0) {
|
||||
metadataNameText.forceFocus();
|
||||
updateStatus(IStatus.ERROR, Messages.getString("FileStep1.nameAlert")); //$NON-NLS-1$
|
||||
return false;
|
||||
} else if (!MetadataToolHelper.isValidSchemaName(metadataNameText.getText())) {
|
||||
metadataNameText.forceFocus();
|
||||
updateStatus(IStatus.ERROR, Messages.getString("FileStep1.nameAlertIllegalChar")); //$NON-NLS-1$
|
||||
return false;
|
||||
} else if (isNameAllowed(metadataNameText.getText())) {
|
||||
updateStatus(IStatus.ERROR, Messages.getString("CommonWizard.nameAlreadyExist")); //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tableEditorView.getMetadataEditor().getBeanCount() > 0) {
|
||||
updateStatus(IStatus.OK, null);
|
||||
return true;
|
||||
}
|
||||
updateStatus(IStatus.ERROR, Messages.getString("FileStep3.itemAlert")); //$NON-NLS-1$
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void saveMetaData() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.swt.widgets.Control#setVisible(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
super.setVisible(visible);
|
||||
if (super.isVisible()) {
|
||||
SalesforceSchemaConnection originalValueConnection = getOriginalValueConnection();
|
||||
if (originalValueConnection.getWebServiceUrl() != null && (!originalValueConnection.getWebServiceUrl().equals("")) //$NON-NLS-1$
|
||||
&& (tableEditorView.getMetadataEditor().getBeanCount() <= 0)) {
|
||||
runShadowProcess();
|
||||
}
|
||||
if (isReadOnly() != readOnly) {
|
||||
adaptFormToReadOnly();
|
||||
}
|
||||
}
|
||||
checkFieldsValue();
|
||||
}
|
||||
|
||||
private SalesforceSchemaConnection getOriginalValueConnection() {
|
||||
if (isContextMode() && getContextModeManager() != null) {
|
||||
return OtherConnectionContextUtils.cloneOriginalValueSalesforceConnection(getConnection(), getContextModeManager()
|
||||
.getSelectedContextType());
|
||||
}
|
||||
return getConnection();
|
||||
|
||||
}
|
||||
|
||||
protected void initGuessSchema() {
|
||||
if (getParent().getChildren().length == 1) { // only open table
|
||||
if (getContextModeManager() == null) { // first
|
||||
setContextModeManager(new MetadataContextModeManager());
|
||||
ConnectionContextHelper.checkContextMode(connectionItem);
|
||||
}
|
||||
if (connectionItem.getConnection().isContextMode()) {
|
||||
ContextType contextTypeForContextMode = ConnectionContextHelper.getContextTypeForContextMode(getShell(),
|
||||
connectionItem.getConnection());
|
||||
getContextModeManager().setSelectedContextType(contextTypeForContextMode);
|
||||
}
|
||||
|
||||
}
|
||||
useAlphbet = getConnection().isUseAlphbet();
|
||||
}
|
||||
}
|
||||
@@ -1,951 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.SashForm;
|
||||
import org.eclipse.swt.custom.ScrolledComposite;
|
||||
import org.eclipse.swt.events.KeyAdapter;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.swt.widgets.TableColumn;
|
||||
import org.eclipse.swt.widgets.TableItem;
|
||||
import org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorNotModifiable.LAYOUT_MODE;
|
||||
import org.talend.commons.ui.swt.formtools.Form;
|
||||
import org.talend.commons.ui.swt.formtools.LabelledText;
|
||||
import org.talend.commons.ui.swt.formtools.UtilsButton;
|
||||
import org.talend.commons.ui.swt.tableviewer.TableViewerCreator;
|
||||
import org.talend.commons.utils.data.list.IListenableListListener;
|
||||
import org.talend.commons.utils.data.list.ListenableListEvent;
|
||||
import org.talend.commons.utils.data.text.IndiceHelper;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.language.LanguageManager;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.IMetadataContextModeManager;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MetadataTalendType;
|
||||
import org.talend.core.model.metadata.MetadataToolHelper;
|
||||
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.SalesforceModuleUnit;
|
||||
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
|
||||
import org.talend.core.model.metadata.types.JavaDataTypeHelper;
|
||||
import org.talend.core.model.metadata.types.JavaTypesManager;
|
||||
import org.talend.core.model.metadata.types.PerlDataTypeHelper;
|
||||
import org.talend.core.model.metadata.types.PerlTypesManager;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.repository.model.preview.SalesforceSchemaBean;
|
||||
import org.talend.core.ui.metadata.editor.MetadataEmfTableEditor;
|
||||
import org.talend.core.ui.metadata.editor.MetadataEmfTableEditorView;
|
||||
import org.talend.core.utils.CsvArray;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.metadata.managment.ui.preview.ProcessDescription;
|
||||
import org.talend.metadata.managment.ui.utils.ConnectionContextHelper;
|
||||
import org.talend.metadata.managment.ui.utils.OtherConnectionContextUtils;
|
||||
import org.talend.metadata.managment.ui.utils.ShadowProcessHelper;
|
||||
import org.talend.metadata.managment.ui.wizard.metadata.MetadataContextModeManager;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
import org.talend.repository.metadata.ui.wizards.form.AbstractSalesforceStepForm;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC yexiaowei class global comment. Detailled comment
|
||||
*/
|
||||
public class SalesforceStep4Form extends AbstractSalesforceStepForm {
|
||||
|
||||
private static Logger log = Logger.getLogger(SalesforceStep4Form.class);
|
||||
|
||||
private static final int WIDTH_GRIDDATA_PIXEL = 550;
|
||||
|
||||
private TableViewerCreator tableViewerCreator;
|
||||
|
||||
private Table tableNavigator;
|
||||
|
||||
private UtilsButton cancelButton;
|
||||
|
||||
private UtilsButton guessButton;
|
||||
|
||||
private UtilsButton addTableButton;
|
||||
|
||||
private UtilsButton removeTableButton;
|
||||
|
||||
private MetadataEmfTableEditor metadataEditor;
|
||||
|
||||
private MetadataEmfTableEditorView tableEditorView;
|
||||
|
||||
private Label informationLabel;
|
||||
|
||||
private MetadataTable metadataTable;
|
||||
|
||||
private LabelledText metadataNameText;
|
||||
|
||||
private LabelledText metadataCommentText;
|
||||
|
||||
private boolean readOnly;
|
||||
|
||||
private SalesforceSchemaConnection temConnection;
|
||||
|
||||
private String moduleName;
|
||||
|
||||
private ArrayList<String> existedNames = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Constructor to use by RCP Wizard.
|
||||
*
|
||||
* @param Composite
|
||||
*/
|
||||
// public SalesforceStep3FormToBe(Composite parent, ConnectionItem connectionItem, MetadataTable metadataTable,
|
||||
// String[] existingNames, SalesforceModuleParseAPI salesforceAPI) {
|
||||
// this(parent, connectionItem, metadataTable, existingNames, salesforceAPI, null);
|
||||
// }
|
||||
|
||||
public SalesforceStep4Form(Composite parent, ConnectionItem connectionItem, SalesforceSchemaConnection temConnection,
|
||||
MetadataTable metadataTable, String[] existingNames, SalesforceModuleParseAPI salesforceAPI,
|
||||
IMetadataContextModeManager contextModeManager, String moduleName) {
|
||||
super(parent, connectionItem, metadataTable, existingNames, salesforceAPI);
|
||||
this.temConnection = temConnection;
|
||||
this.connectionItem = connectionItem;
|
||||
this.metadataTable = metadataTable;
|
||||
this.moduleName = moduleName;
|
||||
setConnectionItem(connectionItem);
|
||||
setContextModeManager(contextModeManager);
|
||||
setupForm();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Initialize value, forceFocus first field.
|
||||
*/
|
||||
@Override
|
||||
protected void initialize() {
|
||||
// init the metadata Table
|
||||
String label = MetadataToolHelper.validateValue(metadataTable.getLabel());
|
||||
metadataNameText.setText(label);
|
||||
metadataCommentText.setText(metadataTable.getComment());
|
||||
metadataEditor.setMetadataTable(metadataTable);
|
||||
tableEditorView.setMetadataEditor(metadataEditor);
|
||||
tableEditorView.getTableViewerCreator().layout();
|
||||
|
||||
if (getConnection().isReadOnly()) {
|
||||
adaptFormToReadOnly();
|
||||
} else {
|
||||
updateStatus(IStatus.OK, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void adaptFormToReadOnly() {
|
||||
readOnly = isReadOnly();
|
||||
guessButton.setEnabled(!isReadOnly());
|
||||
metadataNameText.setReadOnly(isReadOnly());
|
||||
metadataCommentText.setReadOnly(isReadOnly());
|
||||
tableEditorView.setReadOnly(isReadOnly());
|
||||
|
||||
// if (getParent().getChildren().length == 1) { // open the table
|
||||
// guessButton.setEnabled(false);
|
||||
// informationLabel.setVisible(false);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addFields() {
|
||||
|
||||
int leftCompositeWidth = 125;
|
||||
int rightCompositeWidth = WIDTH_GRIDDATA_PIXEL - leftCompositeWidth;
|
||||
int headerCompositeHeight = 80;
|
||||
int tableSettingsCompositeHeight = 15;
|
||||
int tableCompositeHeight = 200;
|
||||
|
||||
int height = headerCompositeHeight + tableSettingsCompositeHeight + tableCompositeHeight;
|
||||
|
||||
// Header Fields
|
||||
Composite mainComposite = Form.startNewDimensionnedGridLayout(this, 2, WIDTH_GRIDDATA_PIXEL, 60);
|
||||
|
||||
SashForm sash = new SashForm(mainComposite, SWT.HORIZONTAL);
|
||||
GridData sashData = new GridData(GridData.FILL_BOTH);
|
||||
sash.setLayoutData(sashData);
|
||||
Composite leftComposite = Form.startNewDimensionnedGridLayout(sash, 1, leftCompositeWidth, height);
|
||||
Composite rightComposite = Form.startNewDimensionnedGridLayout(sash, 1, rightCompositeWidth, height);
|
||||
sash.setWeights(new int[] { 1, 5 });
|
||||
addTreeNavigator(leftComposite, leftCompositeWidth, height);
|
||||
metadataNameText = new LabelledText(rightComposite, Messages.getString("FileStep3.metadataName")); //$NON-NLS-1$
|
||||
metadataCommentText = new LabelledText(rightComposite, Messages.getString("FileStep3.metadataComment")); //$NON-NLS-1$
|
||||
|
||||
// Group MetaData
|
||||
Group groupMetaData = Form.createGroup(rightComposite, 1, Messages.getString("FileStep3.groupMetadata"), 280); //$NON-NLS-1$
|
||||
Composite compositeMetaData = Form.startNewGridLayout(groupMetaData, 1);
|
||||
|
||||
// Composite Guess
|
||||
Composite compositeGuessButton = Form.startNewDimensionnedGridLayout(compositeMetaData, 2, WIDTH_GRIDDATA_PIXEL, 40);
|
||||
informationLabel = new Label(compositeGuessButton, SWT.NONE);
|
||||
informationLabel
|
||||
.setText(Messages.getString("FileStep3.informationLabel") + " "); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
informationLabel.setSize(500, HEIGHT_BUTTON_PIXEL);
|
||||
|
||||
guessButton = new UtilsButton(compositeGuessButton, Messages.getString("FileStep3.guess"), WIDTH_BUTTON_PIXEL, //$NON-NLS-1$
|
||||
HEIGHT_BUTTON_PIXEL);
|
||||
guessButton.setToolTipText(Messages.getString("FileStep3.guessTip")); //$NON-NLS-1$
|
||||
|
||||
// Composite MetadataTableEditorView
|
||||
Composite compositeTable = Form.startNewDimensionnedGridLayout(compositeMetaData, 1, WIDTH_GRIDDATA_PIXEL, 200);
|
||||
compositeTable.setLayout(new FillLayout());
|
||||
metadataEditor = new MetadataEmfTableEditor(Messages.getString("FileStep3.metadataDescription")); //$NON-NLS-1$
|
||||
tableEditorView = new MetadataEmfTableEditorView(compositeTable, SWT.NONE);
|
||||
|
||||
if (!isInWizard()) {
|
||||
// Bottom Button
|
||||
Composite compositeBottomButton = Form.startNewGridLayout(this, 2, false, SWT.CENTER, SWT.CENTER);
|
||||
// Button Cancel
|
||||
cancelButton = new UtilsButton(compositeBottomButton, Messages.getString("CommonWizard.cancel"), WIDTH_BUTTON_PIXEL, //$NON-NLS-1$
|
||||
HEIGHT_BUTTON_PIXEL);
|
||||
}
|
||||
addUtilsButtonListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addFieldsListeners() {
|
||||
// Navigation : when the user select a table
|
||||
tableNavigator.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
String schemaLabel = tableNavigator.getSelection()[0].getText();
|
||||
|
||||
// org.talend.core.model.metadata.MetadataTable table = null;
|
||||
EList<SalesforceModuleUnit> modules = temConnection.getModules();
|
||||
for (int i = 0; i < modules.size(); i++) {
|
||||
if (modules.get(i).getModuleName().equals(moduleName)) {
|
||||
for (int j = 0; j < modules.get(i).getTables().size(); j++) {
|
||||
if (modules.get(i).getTables().get(j).getLabel().equals(schemaLabel)) {
|
||||
metadataTable = modules.get(i).getTables().get(j);
|
||||
metadataNameText.setText(schemaLabel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
metadataEditor.setMetadataTable(metadataTable);
|
||||
if (isReadOnly()) {
|
||||
addTableButton.setEnabled(false);
|
||||
}
|
||||
// }
|
||||
}
|
||||
});
|
||||
// metadataNameText : Event modifyText
|
||||
metadataNameText.addModifyListener(new ModifyListener() {
|
||||
|
||||
@Override
|
||||
public void modifyText(final ModifyEvent e) {
|
||||
String labelText = metadataNameText.getText();
|
||||
MetadataToolHelper.validateSchema(labelText);
|
||||
changeTableNavigatorStatus(labelText);
|
||||
metadataTable.setLabel(labelText);
|
||||
if (tableNavigator.getSelection().length > 0) {
|
||||
tableNavigator.getSelection()[0].setText(labelText);
|
||||
}
|
||||
changeTableNavigatorStatus(checkFieldsValue());
|
||||
|
||||
// kFieldsValue();
|
||||
}
|
||||
});
|
||||
// metadataNameText : Event KeyListener
|
||||
metadataNameText.addKeyListener(new KeyAdapter() {
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
MetadataToolHelper.checkSchema(getShell(), e);
|
||||
// initTreeNavigatorNodes();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// metadataCommentText : Event modifyText
|
||||
metadataCommentText.addModifyListener(new ModifyListener() {
|
||||
|
||||
@Override
|
||||
public void modifyText(final ModifyEvent e) {
|
||||
metadataTable.setComment(metadataCommentText.getText());
|
||||
}
|
||||
});
|
||||
|
||||
// add listener to tableMetadata (listen the event of the toolbars)
|
||||
tableEditorView.getMetadataEditor().addAfterOperationListListener(new IListenableListListener() {
|
||||
|
||||
@Override
|
||||
public void handleEvent(ListenableListEvent event) {
|
||||
checkFieldsValue();
|
||||
}
|
||||
});
|
||||
// add listener to tableMetadata (listen the event of the toolbars)
|
||||
metadataEditor.addAfterOperationListListener(new IListenableListListener() {
|
||||
|
||||
@Override
|
||||
public void handleEvent(ListenableListEvent event) {
|
||||
changeTableNavigatorStatus(checkFieldsValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void changeTableNavigatorStatus(String schemaLabel) {
|
||||
Composite leftGroup = tableNavigator.getParent().getParent().getParent();
|
||||
Control[] children = leftGroup.getChildren();
|
||||
if (schemaLabel == null || schemaLabel.length() == 0) {
|
||||
leftGroup.setEnabled(false);
|
||||
changeControlStatus(children, false);
|
||||
} else {
|
||||
leftGroup.setEnabled(true);
|
||||
changeControlStatus(children, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void changeControlStatus(Control[] children, boolean status) {
|
||||
for (Control control : children) {
|
||||
control.setEnabled(status);
|
||||
if (control instanceof Composite) {
|
||||
Control[] subChildren = ((Composite) control).getChildren();
|
||||
changeControlStatus(subChildren, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void changeTableNavigatorStatus(boolean isEnabled) {
|
||||
Composite leftGroup = tableNavigator.getParent().getParent().getParent();
|
||||
Control[] children = leftGroup.getChildren();
|
||||
leftGroup.setEnabled(isEnabled);
|
||||
changeControlStatus(children, isEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* addButtonControls.
|
||||
*
|
||||
* @param cancelButton
|
||||
*/
|
||||
@Override
|
||||
protected void addUtilsButtonListeners() {
|
||||
|
||||
// Event guessButton
|
||||
guessButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(final SelectionEvent e) {
|
||||
if (tableEditorView.getMetadataEditor().getBeanCount() > 0) {
|
||||
|
||||
if (!guessButton.getEnabled()) {
|
||||
guessButton.setEnabled(true);
|
||||
if (MessageDialog.openConfirm(getShell(), Messages.getString("FileStep3.guessConfirmation"), Messages //$NON-NLS-1$
|
||||
.getString("FileStep3.guessConfirmationMessage"))) { //$NON-NLS-1$
|
||||
runShadowProcess();
|
||||
}
|
||||
} else {
|
||||
guessButton.setEnabled(false);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (!guessButton.getEnabled()) {
|
||||
guessButton.setEnabled(true);
|
||||
runShadowProcess();
|
||||
} else {
|
||||
guessButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
// Event addTable Button
|
||||
addTableButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(final SelectionEvent e) {
|
||||
if (!addTableButton.getEnabled()) {
|
||||
addTableButton.setEnabled(true);
|
||||
addMetadataTable();
|
||||
} else {
|
||||
addTableButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
removeTableButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if (!removeTableButton.getEnabled()) {
|
||||
removeTableButton.setEnabled(true);
|
||||
TableItem[] selection = tableNavigator.getSelection();
|
||||
if (selection != null && selection.length > 0) {
|
||||
boolean openConfirm = MessageDialog.openConfirm(getShell(), "Confirm",
|
||||
"Are you sure to delete this schema ?");
|
||||
if (openConfirm) {
|
||||
for (TableItem item : selection) {
|
||||
|
||||
if (tableNavigator.indexOf(item) != -1) {
|
||||
EList<SalesforceModuleUnit> modules = temConnection.getModules();
|
||||
for (int i = 0; i < modules.size(); i++) {
|
||||
if (modules.get(i).getModuleName().equals(moduleName)) {
|
||||
for (int j = 0; j < modules.get(i).getTables().size(); j++) {
|
||||
if (item.getText().equals(modules.get(i).getTables().get(j).getLabel())) {
|
||||
modules.get(i).getTables().remove(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tableNavigator.remove(tableNavigator.indexOf(item));
|
||||
if (tableNavigator.getItemCount() > 1) {
|
||||
tableNavigator.setSelection(tableNavigator.getItem(tableNavigator.getItemCount() - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
initTreeNavigatorNodes();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
removeTableButton.setEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
if (cancelButton != null) {
|
||||
// Event CancelButton
|
||||
cancelButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(final SelectionEvent e) {
|
||||
getShell().close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void addMetadataTable() {
|
||||
// Create a new metadata and Add it on the connection
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
|
||||
metadataTable.setId(factory.getNextId());
|
||||
// initExistingNames();
|
||||
|
||||
metadataTable.setLabel(IndiceHelper.getIndexedLabel(metadataTable.getLabel(), existingNames));
|
||||
EList<SalesforceModuleUnit> modules = temConnection.getModules();
|
||||
// EList<SalesforceModuleUnit> modules = getConnection().getModules();
|
||||
for (int i = 0; i < modules.size(); i++) {
|
||||
if (modules.get(i).getModuleName().equals(moduleName)) {
|
||||
|
||||
modules.get(i).getTables().add(modules.get(i).getTables().size(), metadataTable);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
// init TreeNavigator
|
||||
initTreeNavigatorNodes();
|
||||
metadataNameText.setText(metadataTable.getLabel());
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ocarbone Comment method "addTreeNavigator".
|
||||
*
|
||||
* @param parent
|
||||
* @param width
|
||||
* @param height
|
||||
*/
|
||||
private void addTreeNavigator(Composite parent, int width, int height) {
|
||||
// Group
|
||||
Group group = Form.createGroup(parent, 1, Messages.getString("DatabaseTableForm.navigatorTree"), height); //$NON-NLS-1$
|
||||
|
||||
// ScrolledComposite
|
||||
ScrolledComposite scrolledCompositeFileViewer = new ScrolledComposite(group, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NONE);
|
||||
scrolledCompositeFileViewer.setExpandHorizontal(true);
|
||||
scrolledCompositeFileViewer.setExpandVertical(true);
|
||||
GridData gridData1 = new GridData(GridData.FILL_BOTH);
|
||||
gridData1.widthHint = width + 12;
|
||||
gridData1.heightHint = height;
|
||||
gridData1.horizontalSpan = 2;
|
||||
scrolledCompositeFileViewer.setLayoutData(gridData1);
|
||||
|
||||
tableViewerCreator = new TableViewerCreator(scrolledCompositeFileViewer);
|
||||
tableViewerCreator.setHeaderVisible(false);
|
||||
tableViewerCreator.setColumnsResizableByDefault(false);
|
||||
tableViewerCreator.setBorderVisible(false);
|
||||
tableViewerCreator.setLinesVisible(false);
|
||||
tableViewerCreator.setLayoutMode(LAYOUT_MODE.NONE);
|
||||
tableViewerCreator.setCheckboxInFirstColumn(false);
|
||||
tableViewerCreator.setFirstColumnMasked(false);
|
||||
|
||||
tableNavigator = tableViewerCreator.createTable();
|
||||
tableNavigator.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
TableColumn tableColumn = new TableColumn(tableNavigator, SWT.NONE);
|
||||
tableColumn.setText(Messages.getString("DatabaseTableForm.tableColumnText.talbe")); //$NON-NLS-1$
|
||||
tableColumn.setWidth(width + 120);
|
||||
|
||||
scrolledCompositeFileViewer.setContent(tableNavigator);
|
||||
scrolledCompositeFileViewer.setSize(width + 12, height);
|
||||
|
||||
// // Button Add metadata Table
|
||||
Composite button = Form.startNewGridLayout(group, HEIGHT_BUTTON_PIXEL, false, SWT.CENTER, SWT.CENTER);
|
||||
addTableButton = new UtilsButton(button,
|
||||
Messages.getString("DatabaseTableForm.AddTable"), width - 30, HEIGHT_BUTTON_PIXEL); //$NON-NLS-1$
|
||||
|
||||
Composite rmButton = Form.startNewGridLayout(group, HEIGHT_BUTTON_PIXEL, false, SWT.CENTER, SWT.CENTER);
|
||||
removeTableButton = new UtilsButton(rmButton, "Remove Schema", width - 30, HEIGHT_BUTTON_PIXEL); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* create ProcessDescription and set it.
|
||||
*
|
||||
* WARNING ::field FieldSeparator, RowSeparator, EscapeChar and TextEnclosure are surround by double quote.
|
||||
*
|
||||
*
|
||||
* @return processDescription
|
||||
*/
|
||||
private ProcessDescription getProcessDescription(SalesforceSchemaConnection originalValueConnection) {
|
||||
|
||||
ProcessDescription processDescription = ShadowProcessHelper.getProcessDescription(originalValueConnection);
|
||||
|
||||
SalesforceSchemaBean bean = new SalesforceSchemaBean();
|
||||
|
||||
bean.setWebServerUrl(originalValueConnection.getWebServiceUrl());
|
||||
bean.setUserName(originalValueConnection.getUserName());
|
||||
bean.setPassword(originalValueConnection.getValue(originalValueConnection.getPassword(), false));
|
||||
bean.setModuleName(originalValueConnection.getModuleName());
|
||||
bean.setQueryCondition(originalValueConnection.getQueryCondition());
|
||||
// add for feature 7507
|
||||
bean.setBatchSize(originalValueConnection.getBatchSize());
|
||||
bean.setUseProxy(originalValueConnection.isUseProxy());
|
||||
bean.setUesHttp(originalValueConnection.isUseHttpProxy());
|
||||
bean.setProxyHost(originalValueConnection.getProxyHost());
|
||||
bean.setProxyPort(originalValueConnection.getProxyPort());
|
||||
bean.setProxyUsername(originalValueConnection.getProxyUsername());
|
||||
bean.setProxyPassword(originalValueConnection.getValue(originalValueConnection.getProxyPassword(), false));
|
||||
|
||||
processDescription.setSalesforceSchemaBean(bean);
|
||||
|
||||
List<IMetadataTable> tableSchema = new ArrayList<IMetadataTable>();
|
||||
IMetadataTable tableGet = getMetadatasForSalesforce(bean.getWebServerUrl(), bean.getUserName(), bean.getPassword(),
|
||||
String.valueOf(bean.getTimeOut()), bean.getModuleName(), bean.getBatchSize(), bean.isUseProxy(),
|
||||
bean.isUesHttp(), bean.getProxyHost(), bean.getProxyPort(), bean.getProxyUsername(), bean.getProxyPassword(),
|
||||
false);
|
||||
|
||||
IMetadataTable table = new org.talend.core.model.metadata.MetadataTable();
|
||||
List<IMetadataColumn> schema = new ArrayList<IMetadataColumn>();
|
||||
for (IMetadataColumn column : tableGet.getListColumns()) {
|
||||
schema.add(column.clone());
|
||||
}
|
||||
|
||||
table.setTableName("tSalesforceInput"); //$NON-NLS-1$
|
||||
table.setListColumns(schema);
|
||||
tableSchema.add(table);
|
||||
|
||||
processDescription.setSchema(tableSchema);
|
||||
|
||||
processDescription.setEncoding(TalendQuoteUtils.addQuotes("ISO-8859-15")); //$NON-NLS-1$
|
||||
|
||||
return processDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* run a ShadowProcess to determined the Metadata.
|
||||
*/
|
||||
protected void runShadowProcess() {
|
||||
initGuessSchema();
|
||||
SalesforceSchemaConnection originalValueConnection = getOriginalValueConnection();
|
||||
// if no file, the process don't be executed
|
||||
if (originalValueConnection.getWebServiceUrl() == null || originalValueConnection.getWebServiceUrl().equals("")) { //$NON-NLS-1$
|
||||
informationLabel.setText("Salesforce endpoint lost" //$NON-NLS-1$
|
||||
+ " "); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
|
||||
// try {
|
||||
informationLabel.setText(" " + Messages.getString("FileStep3.guessProgress")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
// get the XmlArray width an adapt ProcessDescription
|
||||
ProcessDescription processDescription = getProcessDescription(originalValueConnection);
|
||||
|
||||
IMetadataTable metadataTableOrder = readMetadataDetail();
|
||||
if (metadataTableOrder != null) {
|
||||
metadataTableClone = metadataTableOrder.clone();
|
||||
metadataTableOrder = modifyMetadataTable();
|
||||
}
|
||||
List<IMetadataTable> schema = processDescription.getSchema();
|
||||
if (schema != null && schema.size() > 0) {
|
||||
if (useAlphbet) {
|
||||
if (metadataTableOrder != null) {
|
||||
schema.get(0).setListColumns(metadataTableOrder.getListColumns());
|
||||
}
|
||||
} else {
|
||||
if (metadataTableClone != null) {
|
||||
schema.get(0).setListColumns(metadataTableClone.getListColumns());
|
||||
}
|
||||
}
|
||||
}
|
||||
// the web service url is used by tSalesforceInput, see 0004027: Studio crashes when clicking Next on
|
||||
// Step 3 of SF wizard
|
||||
// processDescription.getSalesforceSchemaBean().setWebServerUrl(TSALESFORCE_INPUT_URL);
|
||||
// CsvArray csvArray = ShadowProcessHelper.getCsvArray(processDescription, "SALESFORCE_SCHEMA", true); //$NON-NLS-1$
|
||||
//
|
||||
// if (csvArray == null) {
|
||||
// informationLabel.setText(" " + Messages.getString("FileStep3.guessFailure")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// } else {
|
||||
// refreshMetaDataTable(csvArray, processDescription);
|
||||
// }
|
||||
|
||||
// } catch (CoreException e) {
|
||||
// if (getParent().getChildren().length == 1) {
|
||||
// new ErrorDialogWidthDetailArea(getShell(), PID, Messages.getString("FileStep3.guessFailureTip") + "\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// + Messages.getString("FileStep3.guessFailureTip2"), e.getMessage()); //$NON-NLS-1$
|
||||
// } else {
|
||||
// new ErrorDialogWidthDetailArea(getShell(), PID, Messages.getString("FileStep3.guessFailureTip"), e.getMessage()); //$NON-NLS-1$
|
||||
// }
|
||||
// log.error(Messages.getString("FileStep3.guessFailure") + " " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// }
|
||||
guessSchema(processDescription);
|
||||
checkFieldsValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC zli Comment method "guessSchema".
|
||||
*
|
||||
* @param processDescription
|
||||
*/
|
||||
public void guessSchema(ProcessDescription processDescription) {
|
||||
informationLabel.setText(" " + Messages.getString("FileStep3.guessIsDone")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// clear all items
|
||||
tableEditorView.getMetadataEditor().removeAll();
|
||||
List<MetadataColumn> columns = new ArrayList<MetadataColumn>();
|
||||
|
||||
List<IMetadataColumn> listColumns = processDescription.getSchema().get(0).getListColumns();
|
||||
int size = listColumns.size();
|
||||
if (size > 0) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
MetadataColumn metadataColumn = ConnectionFactory.eINSTANCE.createMetadataColumn();
|
||||
metadataColumn.setNullable(listColumns.get(i).isNullable());
|
||||
metadataColumn.setLength(listColumns.get(i).getLength());
|
||||
metadataColumn.setPattern(listColumns.get(i).getPattern());
|
||||
metadataColumn.setTalendType(listColumns.get(i).getTalendType());
|
||||
metadataColumn.setPrecision(listColumns.get(i).getPrecision());
|
||||
metadataColumn.setLabel(listColumns.get(i).getLabel());
|
||||
columns.add(i, metadataColumn);
|
||||
}
|
||||
}
|
||||
tableEditorView.getMetadataEditor().addAll(columns);
|
||||
tableEditorView.getTableViewerCreator().layout();
|
||||
informationLabel.setText(Messages.getString("FileStep3.guessTip")); //$NON-NLS-1$
|
||||
|
||||
}
|
||||
|
||||
public void refreshMetaDataTable(final CsvArray csvArray, ProcessDescription processDescription) {
|
||||
informationLabel.setText(" " + Messages.getString("FileStep3.guessIsDone")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// clear all items
|
||||
tableEditorView.getMetadataEditor().removeAll();
|
||||
|
||||
List<MetadataColumn> columns = new ArrayList<MetadataColumn>();
|
||||
if (csvArray == null || csvArray.getRows().isEmpty()) {
|
||||
return;
|
||||
} else {
|
||||
|
||||
List<String[]> csvRows = csvArray.getRows();
|
||||
Integer numberOfCol = getRightFirstRow(csvRows);
|
||||
|
||||
// define the label to the metadata width the content of the first row
|
||||
int firstRowToExtractMetadata = 0;
|
||||
List<IMetadataColumn> listColumns = processDescription.getSchema().get(0).getListColumns();
|
||||
// the first rows is used to define the label of any metadata
|
||||
String[] label = new String[numberOfCol.intValue()];
|
||||
for (int i = 0; i < numberOfCol; i++) {
|
||||
label[i] = DEFAULT_LABEL + i;
|
||||
if (firstRowToExtractMetadata == 0) {
|
||||
|
||||
label[i] = "" + listColumns.get(i); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < numberOfCol.intValue(); i++) {
|
||||
// define the first currentType and assimile it to globalType
|
||||
String globalType = null;
|
||||
int lengthValue = 0;
|
||||
int precisionValue = 0;
|
||||
boolean nullAble = true;
|
||||
|
||||
int current = firstRowToExtractMetadata;
|
||||
while (globalType == null) {
|
||||
String value = csvRows.get(current)[i];
|
||||
if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
|
||||
if (i >= csvRows.get(current).length) {
|
||||
globalType = "id_String"; //$NON-NLS-1$
|
||||
} else {
|
||||
if (value != null && !"".equals(value)) { //$NON-NLS-1$
|
||||
globalType = JavaDataTypeHelper.getTalendTypeOfValue(value);
|
||||
} else {
|
||||
globalType = listColumns.get(i).getTalendType();
|
||||
}
|
||||
current++;
|
||||
}
|
||||
} else {
|
||||
if (i >= csvRows.get(current).length) {
|
||||
globalType = "String"; //$NON-NLS-1$
|
||||
} else {
|
||||
globalType = PerlDataTypeHelper.getTalendTypeOfValue(value);
|
||||
current++;
|
||||
}
|
||||
}
|
||||
}
|
||||
nullAble = listColumns.get(i).isNullable();
|
||||
lengthValue = listColumns.get(i).getLength();
|
||||
precisionValue = listColumns.get(i).getPrecision();
|
||||
|
||||
// define the metadataColumn to field i
|
||||
MetadataColumn metadataColumn = ConnectionFactory.eINSTANCE.createMetadataColumn();
|
||||
// Convert javaType to TalendType
|
||||
String talendType = null;
|
||||
if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
|
||||
talendType = globalType;
|
||||
if (globalType.equals(JavaTypesManager.FLOAT.getId()) || globalType.equals(JavaTypesManager.DOUBLE.getId())) {
|
||||
metadataColumn.setPrecision(precisionValue);
|
||||
} else {
|
||||
metadataColumn.setPrecision(0);
|
||||
}
|
||||
} else {
|
||||
talendType = PerlTypesManager.getNewTypeName(MetadataTalendType.loadTalendType(globalType,
|
||||
"TALENDDEFAULT", false)); //$NON-NLS-1$
|
||||
if (globalType.equals("FLOAT") || globalType.equals("DOUBLE")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
metadataColumn.setPrecision(precisionValue);
|
||||
} else {
|
||||
metadataColumn.setPrecision(0);
|
||||
}
|
||||
}
|
||||
|
||||
metadataColumn.setNullable(nullAble);
|
||||
metadataColumn.setTalendType(talendType);
|
||||
metadataColumn.setLength(lengthValue);
|
||||
// bug 6758
|
||||
if (talendType.equals("id_Date")) { //$NON-NLS-1$
|
||||
String pattern = listColumns.get(i).getPattern();
|
||||
metadataColumn.setPattern(pattern);
|
||||
}
|
||||
// Check the label and add it to the table
|
||||
metadataColumn.setLabel(tableEditorView.getMetadataEditor().getNextGeneratedColumnName(label[i]));
|
||||
columns.add(i, metadataColumn);
|
||||
}
|
||||
}
|
||||
// tableEditorView.getMetadataEditor().registerDataList(columns);
|
||||
tableEditorView.getMetadataEditor().addAll(columns);
|
||||
|
||||
checkFieldsValue();
|
||||
tableEditorView.getTableViewerCreator().layout();
|
||||
informationLabel.setText(Messages.getString("FileStep3.guessTip")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// CALCULATE THE NULBER OF COLUMNS IN THE PREVIEW
|
||||
public Integer getRightFirstRow(List<String[]> csvRows) {
|
||||
|
||||
Integer numbersOfColumns = null;
|
||||
int parserLine = csvRows.size();
|
||||
if (parserLine > 50) {
|
||||
parserLine = 50;
|
||||
}
|
||||
for (int i = 0; i < parserLine; i++) {
|
||||
if (csvRows.get(i) != null) {
|
||||
String[] nbRow = csvRows.get(i);
|
||||
// List<XmlField> nbRowFields = nbRow.getFields();
|
||||
if (numbersOfColumns == null || nbRow.length >= numbersOfColumns) {
|
||||
numbersOfColumns = nbRow.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
return numbersOfColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that fields are set. Update checkEnable / use to checkConnection().
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected boolean checkFieldsValue() {
|
||||
|
||||
if (metadataNameText.getCharCount() == 0) {
|
||||
metadataNameText.forceFocus();
|
||||
updateStatus(IStatus.ERROR, Messages.getString("FileStep1.nameAlert")); //$NON-NLS-1$
|
||||
return false;
|
||||
} else if (!MetadataToolHelper.isValidSchemaName(metadataNameText.getText())) {
|
||||
metadataNameText.forceFocus();
|
||||
updateStatus(IStatus.ERROR, Messages.getString("FileStep1.nameAlertIllegalChar")); //$NON-NLS-1$
|
||||
return false;
|
||||
} else if (nameExist(metadataNameText.getText())) {
|
||||
updateStatus(IStatus.ERROR, Messages.getString("CommonWizard.nameAlreadyExist")); //$NON-NLS-1$
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (tableEditorView.getMetadataEditor().getBeanCount() > 0) {
|
||||
updateStatus(IStatus.OK, null);
|
||||
return true;
|
||||
}
|
||||
updateStatus(IStatus.ERROR, Messages.getString("FileStep3.itemAlert")); //$NON-NLS-1$
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean nameExist(String name) {
|
||||
existedNames.clear();
|
||||
for (int i = 0; i < this.temConnection.getModules().size(); i++) {
|
||||
if (this.temConnection.getModules().get(i).getModuleName().equals(moduleName)) {
|
||||
for (int j = 0; j < temConnection.getModules().get(i).getTables().size(); j++) {
|
||||
existedNames.add(temConnection.getModules().get(i).getTables().get(j).getLabel());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
boolean result = false;
|
||||
int number = 0;
|
||||
for (int i = 0; i < this.existedNames.size(); i++) {
|
||||
if (existedNames.get(i).equals(name)) {
|
||||
number++;
|
||||
}
|
||||
}
|
||||
if (number > 1) {
|
||||
result = true;
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public void saveMetaData() {
|
||||
}
|
||||
|
||||
private void initTreeNavigatorNodes() {
|
||||
List<String> selectedNames = new ArrayList<String>();
|
||||
EList<SalesforceModuleUnit> modules = temConnection.getModules();
|
||||
// EList<SalesforceModuleUnit> modules = getConnection().getModules();
|
||||
for (int i = 0; i < modules.size(); i++) {
|
||||
if (modules.get(i).getModuleName().equals(moduleName)) {
|
||||
for (int j = 0; j < modules.get(i).getTables().size(); j++) {
|
||||
selectedNames.add(modules.get(i).getTables().get(j).getLabel());
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
tableNavigator.removeAll();
|
||||
TableItem subItem = null;
|
||||
String lastSelectName = null;
|
||||
if (selectedNames != null && selectedNames.size() >= 1) {
|
||||
for (int i = 0; i < selectedNames.size(); i++) {
|
||||
subItem = new TableItem(tableNavigator, SWT.NULL);
|
||||
subItem.setText(selectedNames.get(i));
|
||||
lastSelectName = selectedNames.get(i);
|
||||
}
|
||||
metadataNameText.setText(subItem.getText());
|
||||
tableNavigator.setSelection(subItem);
|
||||
metadataTable = getTableByLabel(lastSelectName);
|
||||
} else {
|
||||
subItem = new TableItem(tableNavigator, SWT.NULL);
|
||||
subItem.setText(moduleName);
|
||||
}
|
||||
metadataEditor.setMetadataTable(metadataTable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected org.talend.core.model.metadata.builder.connection.MetadataTable getTableByLabel(String label) {
|
||||
org.talend.core.model.metadata.builder.connection.MetadataTable result = null;
|
||||
EList<SalesforceModuleUnit> modules = temConnection.getModules();
|
||||
for (int i = 0; i < modules.size(); i++) {
|
||||
if (modules.get(i).getModuleName().equals(moduleName)) {
|
||||
for (int j = 0; j < modules.get(i).getTables().size(); j++) {
|
||||
if (modules.get(i).getTables().get(j).getLabel().equals(label)) {
|
||||
result = modules.get(i).getTables().get(j);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.swt.widgets.Control#setVisible(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
super.setVisible(visible);
|
||||
if (super.isVisible()) {
|
||||
initTreeNavigatorNodes();
|
||||
changeTableNavigatorStatus(checkFieldsValue());
|
||||
SalesforceSchemaConnection originalValueConnection = getOriginalValueConnection();
|
||||
if (originalValueConnection.getWebServiceUrl() != null && (!originalValueConnection.getWebServiceUrl().equals("")) //$NON-NLS-1$
|
||||
&& (tableEditorView.getMetadataEditor().getBeanCount() <= 0)) {
|
||||
runShadowProcess();
|
||||
}
|
||||
if (isReadOnly() != readOnly) {
|
||||
adaptFormToReadOnly();
|
||||
}
|
||||
}
|
||||
checkFieldsValue();
|
||||
}
|
||||
|
||||
private SalesforceSchemaConnection getOriginalValueConnection() {
|
||||
if (isContextMode() && getContextModeManager() != null) {
|
||||
return OtherConnectionContextUtils.cloneOriginalValueSalesforceConnection(getConnection(), getContextModeManager()
|
||||
.getSelectedContextType());
|
||||
}
|
||||
return getConnection();
|
||||
|
||||
}
|
||||
|
||||
protected void initGuessSchema() {
|
||||
if (getParent().getChildren().length == 1) { // only open table
|
||||
if (getContextModeManager() == null) { // first
|
||||
setContextModeManager(new MetadataContextModeManager());
|
||||
ConnectionContextHelper.checkContextMode(connectionItem);
|
||||
}
|
||||
if (connectionItem.getConnection().isContextMode()) {
|
||||
ContextType contextTypeForContextMode = ConnectionContextHelper.getContextTypeForContextMode(getShell(),
|
||||
connectionItem.getConnection());
|
||||
getContextModeManager().setSelectedContextType(contextTypeForContextMode);
|
||||
}
|
||||
|
||||
}
|
||||
useAlphbet = getConnection().isUseAlphbet();
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import org.eclipse.jface.dialogs.IDialogPage;
|
||||
import org.eclipse.jface.dialogs.IDialogSettings;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.talend.core.model.metadata.IMetadataContextModeManager;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.cwm.helper.TableHelper;
|
||||
import org.talend.cwm.relational.RelationalFactory;
|
||||
import org.talend.metadata.managment.ui.wizard.AbstractForm;
|
||||
import org.talend.repository.metadata.ui.wizards.form.AbstractSalesforceStepForm;
|
||||
|
||||
/**
|
||||
* DOC yexiaowei class global comment. Detailled comment
|
||||
*/
|
||||
public class SalesforceWizardPage extends WizardPage {
|
||||
|
||||
private ConnectionItem connectionItem;
|
||||
|
||||
private int step;
|
||||
|
||||
private AbstractSalesforceStepForm currentComposite;
|
||||
|
||||
private final String[] existingNames;
|
||||
|
||||
private boolean isRepositoryObjectEditable;
|
||||
|
||||
private final SalesforceModuleParseAPI salesforceAPI;
|
||||
|
||||
private IMetadataContextModeManager contextModeManager;
|
||||
|
||||
private SalesforceSchemaConnection temConnection;
|
||||
|
||||
private String moduleName;
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC YeXiaowei SalesforceWizardPage constructor comment.
|
||||
*
|
||||
* @param step
|
||||
* @param connectionItem
|
||||
* @param isRepositoryObjectEditable
|
||||
* @param existingNames
|
||||
*/
|
||||
public SalesforceWizardPage(int step, ConnectionItem connectionItem, boolean isRepositoryObjectEditable,
|
||||
String[] existingNames, SalesforceModuleParseAPI salesforceAPI, IMetadataContextModeManager contextModeManager) {
|
||||
super("wizardPage"); //$NON-NLS-1$
|
||||
this.step = step;
|
||||
this.connectionItem = connectionItem;
|
||||
this.existingNames = existingNames;
|
||||
this.isRepositoryObjectEditable = isRepositoryObjectEditable;
|
||||
this.salesforceAPI = salesforceAPI;
|
||||
this.contextModeManager = contextModeManager;
|
||||
}
|
||||
|
||||
public SalesforceWizardPage(int step, ConnectionItem connectionItem, SalesforceSchemaConnection temConnection,
|
||||
boolean isRepositoryObjectEditable, String[] existingNames, SalesforceModuleParseAPI salesforceAPI,
|
||||
IMetadataContextModeManager contextModeManager, String moduleName) {
|
||||
super("wizardPage"); //$NON-NLS-1$
|
||||
this.step = step;
|
||||
this.temConnection = temConnection;
|
||||
this.connectionItem = connectionItem;
|
||||
this.existingNames = existingNames;
|
||||
this.isRepositoryObjectEditable = isRepositoryObjectEditable;
|
||||
this.salesforceAPI = salesforceAPI;
|
||||
this.contextModeManager = contextModeManager;
|
||||
this.moduleName = moduleName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see IDialogPage#createControl(Composite)
|
||||
*/
|
||||
public void createControl(final Composite parent) {
|
||||
currentComposite = null;
|
||||
|
||||
if (step == 1) {
|
||||
currentComposite = new SalesforceStep1Form(parent, connectionItem, existingNames, salesforceAPI, contextModeManager);
|
||||
} else if (step == 2) {
|
||||
currentComposite = new SalesforceStep2Form(parent, connectionItem, temConnection, salesforceAPI, contextModeManager,
|
||||
moduleName);
|
||||
} else if (step == 3) {
|
||||
MetadataTable metadataTable = RelationalFactory.eINSTANCE.createTdTable();
|
||||
currentComposite = new SalesforceStep4Form(parent, connectionItem, temConnection, metadataTable,
|
||||
TableHelper.getTableNames(((SalesforceSchemaConnection) connectionItem.getConnection()),
|
||||
metadataTable.getLabel()), salesforceAPI, contextModeManager, moduleName);
|
||||
}
|
||||
currentComposite.setReadOnly(!isRepositoryObjectEditable);
|
||||
|
||||
AbstractForm.ICheckListener listener = new AbstractForm.ICheckListener() {
|
||||
|
||||
public void checkPerformed(final AbstractForm source) {
|
||||
|
||||
if (source.isStatusOnError()) {
|
||||
SalesforceWizardPage.this.setPageComplete(false);
|
||||
setErrorMessage(source.getStatus());
|
||||
} else {
|
||||
SalesforceWizardPage.this.setPageComplete(isRepositoryObjectEditable);
|
||||
setErrorMessage(null);
|
||||
setMessage(source.getStatus());
|
||||
}
|
||||
}
|
||||
};
|
||||
currentComposite.setListener(listener);
|
||||
setControl((Composite) currentComposite);
|
||||
}
|
||||
|
||||
public IDialogSettings getDialogSetting() {
|
||||
return getDialogSettings();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,237 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 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.wizards.metadata.connection.files.salesforce;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.dialogs.IDialogPage;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.talend.commons.ui.swt.composites.StateComposite;
|
||||
import org.talend.core.model.metadata.IMetadataConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
|
||||
import org.talend.core.model.metadata.builder.database.TableInfoParameters;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.metadata.managment.ui.wizard.AbstractForm;
|
||||
import org.talend.repository.ui.wizards.metadata.table.database.TemplateWizardPage;
|
||||
|
||||
import orgomg.cwm.resource.relational.Catalog;
|
||||
|
||||
/**
|
||||
* TableWizard present the TableForm width the MetaDataTable. Use to create a new table (need a connection to a DB).
|
||||
* Page allows setting a table.
|
||||
*/
|
||||
public class SelectorModulesWizardPage extends TemplateWizardPage {
|
||||
|
||||
private Composite container;
|
||||
|
||||
private SelectorModulesForm tableForm;
|
||||
|
||||
private StateComposite stateCom;
|
||||
|
||||
private final ConnectionItem connectionItem;
|
||||
|
||||
private ConnectionItem templateConnection;
|
||||
|
||||
private boolean isRepositoryObjectEditable;
|
||||
|
||||
private final TableInfoParameters tableInfoParameters;
|
||||
|
||||
private IMetadataConnection metadataConnection;
|
||||
|
||||
private boolean isCreateTemplate = false;
|
||||
|
||||
private SalesforceSchemaConnection temConnection;
|
||||
|
||||
SalesforceModuleParseAPI salesforceAPI;
|
||||
|
||||
/**
|
||||
* SelectorTableWizardPage constructor (to instance IMetadataConnection OR MetaDataTableType). If MetaDataTableType
|
||||
* exist, it's an update of existing metadata else it's a new metadata.
|
||||
*
|
||||
* @param tableInfoParameters
|
||||
*
|
||||
* @param ISelection
|
||||
*/
|
||||
public SelectorModulesWizardPage(ConnectionItem connectionItem, boolean isRepositoryObjectEditable,
|
||||
TableInfoParameters tableInfoParameters, IMetadataConnection metadataConnection,
|
||||
SalesforceSchemaConnection temConnection, SalesforceModuleParseAPI salesforceAPI) {
|
||||
super("wizardPage"); //$NON-NLS-1$
|
||||
this.connectionItem = connectionItem;
|
||||
this.isRepositoryObjectEditable = isRepositoryObjectEditable;
|
||||
this.tableInfoParameters = tableInfoParameters;
|
||||
this.metadataConnection = metadataConnection;
|
||||
this.temConnection = temConnection;
|
||||
this.salesforceAPI = salesforceAPI;
|
||||
}
|
||||
|
||||
public SelectorModulesWizardPage(ConnectionItem connectionItem, boolean isRepositoryObjectEditable,
|
||||
TableInfoParameters tableInfoParameters, IMetadataConnection metadataConnection, boolean isCreateTemplate) {
|
||||
super("wizardPage"); //$NON-NLS-1$
|
||||
this.connectionItem = connectionItem;
|
||||
this.templateConnection = connectionItem;
|
||||
this.isRepositoryObjectEditable = isRepositoryObjectEditable;
|
||||
this.tableInfoParameters = tableInfoParameters;
|
||||
this.metadataConnection = metadataConnection;
|
||||
this.isCreateTemplate = isCreateTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the first composite, addComponentsAndControls and initialize TableWizardPage.
|
||||
*
|
||||
* @see IDialogPage#createControl(Composite)
|
||||
*/
|
||||
public void createControl(final Composite parent) {
|
||||
container = new Composite(parent, SWT.NONE);
|
||||
|
||||
GridData data = new GridData(GridData.FILL_BOTH);
|
||||
|
||||
container.setLayoutData(data);
|
||||
container.setLayout(new FillLayout());
|
||||
addFields(container);
|
||||
|
||||
setControl(container);
|
||||
}
|
||||
|
||||
private void addFields(Composite container) {
|
||||
int lines = 7;
|
||||
if (isCreateTemplate) {
|
||||
lines = 9;
|
||||
}
|
||||
container.setLayout(new GridLayout(lines, true));
|
||||
GridData data = new GridData(GridData.FILL_BOTH);
|
||||
if (isCreateTemplate) {
|
||||
data.horizontalSpan = 2;
|
||||
stateCom = new StateComposite(container, false, SWT.NONE);
|
||||
stateCom.setLayoutData(data);
|
||||
stateCom.refreshState("step3");//$NON-NLS-1$
|
||||
}
|
||||
|
||||
data = new GridData(GridData.FILL_BOTH);
|
||||
data.horizontalSpan = 7;
|
||||
|
||||
if (isCreateTemplate) {
|
||||
Catalog c = (Catalog) ConnectionHelper.getPackage(((DatabaseConnection) templateConnection.getConnection()).getSID(),
|
||||
templateConnection.getConnection(), Catalog.class);
|
||||
if (c != null) { // hywang
|
||||
c.getOwnedElement().clear();
|
||||
}
|
||||
tableForm = new SelectorModulesForm(container, templateConnection, this, isCreateTemplate, temConnection,
|
||||
salesforceAPI);
|
||||
} else {
|
||||
tableForm = new SelectorModulesForm(container, connectionItem, this, isCreateTemplate, temConnection, salesforceAPI);
|
||||
}
|
||||
|
||||
tableForm.setLayoutData(data);
|
||||
tableForm.setIMetadataConnection(metadataConnection);
|
||||
tableForm.setReadOnly(!isRepositoryObjectEditable);
|
||||
|
||||
AbstractForm.ICheckListener listener = new AbstractForm.ICheckListener() {
|
||||
|
||||
public void checkPerformed(final AbstractForm source) {
|
||||
if (source.isStatusOnError()) {
|
||||
SelectorModulesWizardPage.this.setPageComplete(false);
|
||||
}
|
||||
if (source.isStatusOnValid()) {
|
||||
SelectorModulesWizardPage.this.setPageComplete(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
tableForm.setListener(listener);
|
||||
setControl(container);
|
||||
if (isCreateTemplate) {
|
||||
tableForm.initControlData(false);
|
||||
}
|
||||
tableForm.initControlData(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC nrousseau Comment method "performCancel".
|
||||
*/
|
||||
public void performCancel() {
|
||||
if (tableForm != null) {
|
||||
tableForm.performCancel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for tableInfoParameters.
|
||||
*
|
||||
* @return the tableInfoParameters
|
||||
*/
|
||||
public TableInfoParameters getTableInfoParameters() {
|
||||
return this.tableInfoParameters;
|
||||
}
|
||||
|
||||
public void initControlData() {
|
||||
tableForm.initControlData();
|
||||
}
|
||||
|
||||
public SalesforceSchemaConnection getDatabaseConnection() {
|
||||
if (tableForm == null) {
|
||||
return null;
|
||||
}
|
||||
return tableForm.getConnection();
|
||||
}
|
||||
|
||||
public void setTemplateConnection(ConnectionItem templateConnection, IMetadataConnection metadataConnection) {
|
||||
if (this.templateConnection == templateConnection) {// && this.metadataConnection == metadataConnection) {
|
||||
return;
|
||||
}
|
||||
this.templateConnection = templateConnection;
|
||||
this.metadataConnection = metadataConnection;
|
||||
if (tableForm != null) {
|
||||
tableForm.setTemplateConntion(templateConnection);
|
||||
tableForm.setIMetadataConnection(metadataConnection);
|
||||
Catalog c = (Catalog) ConnectionHelper.getPackage(((DatabaseConnection) tableForm.getConnection()).getSID(),
|
||||
tableForm.getConnection(), Catalog.class);
|
||||
if (c != null) { // hywang
|
||||
c.getOwnedElement().clear();
|
||||
}
|
||||
if (isCreateTemplate) {
|
||||
tableForm.initControlData(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void restoreCheckItems() {
|
||||
tableForm.restoreCheckItems();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.repository.ui.wizards.metadata.table.database.TemplateWizardPage#getConnection()
|
||||
*/
|
||||
public Connection getConnection() {
|
||||
return getDatabaseConnection();
|
||||
}
|
||||
|
||||
public List<String> getItemListName() {
|
||||
return tableForm.getItemTableNameList();
|
||||
}
|
||||
// public IMetadataConnection getMetadataConnection() {
|
||||
// return this.metadataConnection;
|
||||
// }
|
||||
//
|
||||
// public void setMetadataConnection(IMetadataConnection metadataConnection) {
|
||||
// this.metadataConnection = metadataConnection;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -38,8 +38,6 @@ import org.talend.repository.ui.wizards.metadata.connection.files.excel.ExcelFil
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.ldif.LdifFileStep3Form;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.positional.FileStep3Form;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.regexp.RegexpFileStep3Form;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.salesforce.SalesforceModuleParseAPI;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.salesforce.SalesforceStep3Form;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.xml.XmlFileOutputStep3Form;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.xml.XmlFileStep3Form;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.genericshema.GenericSchemaStep2Form;
|
||||
@@ -194,15 +192,6 @@ public class FileTableWizardPage extends WizardPage {
|
||||
return ldapSchemaStep4Form;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object caseSalesforceSchemaConnection(final SalesforceSchemaConnection object) {
|
||||
SalesforceStep3Form salesforceStep3From = new SalesforceStep3Form(parent, connectionItem, metadataTable,
|
||||
TableHelper.getTableNames(object, metadataTable.getLabel()), new SalesforceModuleParseAPI());
|
||||
salesforceStep3From.setReadOnly(!isRepositoryObjectEditable);
|
||||
salesforceStep3From.setListener(listener);
|
||||
return salesforceStep3From;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user