Compare commits

...

5 Commits

Author SHA1 Message Date
Francis Upton IV
e126fa6db8 TDM-3313 New Component Architecture (more work) 2015-07-27 23:03:37 -07:00
Francis Upton IV
9b45a98460 TDM-3313 New Component Architecture (more work) 2015-07-27 22:58:12 -07:00
Francis Upton IV
f7a23f5888 TDM-3313 New Component Architecture (more work) 2015-07-27 19:29:22 -07:00
Francis Upton IV
12d32aff94 TDM-3313 New Component Architecture (initial work) 2015-07-26 22:57:59 -07:00
Francis Upton IV
1c471aa48b TDM-3313 New Component Architecture (initial work) 2015-07-26 22:35:08 -07:00
20 changed files with 823 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.talend.component</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,8 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Component
Bundle-SymbolicName: org.talend.component
Bundle-Version: 6.1.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: org.talend.component,
org.talend.component.common

View File

@@ -0,0 +1,5 @@
To run this:
mvn clean install
mvn spring-boot:run

View File

@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View File

@@ -0,0 +1,151 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>6.1.0-SNAPSHOT</version>
<relativePath>../../../</relativePath>
</parent>
<!-- <groupId>org.talend.studio</groupId> <version>6.1.0-SNAPSHOT></version> -->
<artifactId>org.talend.component</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws</artifactId>
<version>2.1.4.RELEASE</version>
<classifier>all</classifier>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.3.11</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.4.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.4.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.5</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.eclipse.tycho
</groupId>
<artifactId>
tycho-compiler-plugin
</artifactId>
<versionRange>
[0.22.0,)
</versionRange>
<goals>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.eclipse.tycho
</groupId>
<artifactId>
tycho-packaging-plugin
</artifactId>
<versionRange>
[0.22.0,)
</versionRange>
<goals>
<goal>validate-id</goal>
<goal>
validate-version
</goal>
<goal>build-qualifier</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
build-helper-maven-plugin
</artifactId>
<versionRange>
[1.8,)
</versionRange>
<goals>
<goal>parse-version</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@@ -0,0 +1,12 @@
package org.talend.component;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -0,0 +1,37 @@
package org.talend.component;
public class ComponentConnector {
public enum Type {FLOW, ITERATE, SUBJOB_OK, SUBJOB_ERROR, COMPONENT_OK, COMPONENT_ERROR, RUN_IF };
protected Type type;
protected int maxInput;
protected int maxOutput;
public ComponentConnector(Type type, int maxInput, int maxOutput) {
this.type = type;
this.maxInput = maxInput;
this.maxOutput = maxOutput;
}
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
public int getMaxInput() {
return maxInput;
}
public void setMaxInput(int maxInput) {
this.maxInput = maxInput;
}
public int getMaxOutput() {
return maxOutput;
}
public void setMaxOutput(int maxOutput) {
this.maxOutput = maxOutput;
}
}

View File

@@ -0,0 +1,27 @@
package org.talend.component;
/**
* Component design service.
*
* An instance of this class handles the setup of the properties associated with
* a component.
*
* @author Francis Upton
*
*/
public abstract class ComponentDesign {
public enum Family {
BUSINESS, CLOUD
};
public abstract ComponentProperties createProperties();
public void setDesignerFamily(Family family) {
}
public abstract Family[] getSupportedFamilies();
}

View File

@@ -0,0 +1,51 @@
package org.talend.component;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
/**
* TODO - need to serialize the annotations associated with each property so the client can see them.
* @author fupton
*
*/
//@JsonSerialize(using = ComponentPropertiesSerializer.class)
public abstract class ComponentProperties {
/**
* Unique identification of the this object for the lifetime of the
* ComponentService. Used to reference the current value of the
* ComponentProperties on the server.
*/
protected int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@JsonAnyGetter
public Map<String, Object> getAnnotations() {
Map<String, Map<String, String>> methods = new HashMap<String, Map<String, String>>();
Field[] fields = getClass().getFields();
for (Field field : fields) {
Map<String, String> annotations = new HashMap();
for (Annotation an : field.getAnnotations()) {
// FIXME - pull the value out of here
annotations.put(an.annotationType().getName(), an.toString());
}
methods.put(field.getName(), annotations);
}
Map<String, Object> returnMap = new HashMap();
returnMap.put("_annotations", methods);
return returnMap;
}
}

View File

@@ -0,0 +1,20 @@
package org.talend.component;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
class ComponentPropertiesSerializer extends JsonSerializer<ComponentProperties> {
@Override
public void serialize(ComponentProperties cp, JsonGenerator jsonGenerator,
SerializerProvider sp) throws IOException, JsonProcessingException {
// FIXME
}
}

View File

@@ -0,0 +1,60 @@
package org.talend.component;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiParam;
@RestController
@Api(value = "components", basePath = "/components", description = "Component services")
@Service
public class ComponentService {
/**
* Injected, this is temporary only for testing, we need to have a means of binding the component name
* with multiple instances of ComponentDesign.
*/
protected ComponentDesign design;
protected int nextId;
protected Map<Integer, ComponentProperties> propertiesMap = new HashMap<Integer, ComponentProperties>();
@Autowired
public ComponentService(ComponentDesign design) {
this.design = design;
}
@RequestMapping(value = "/components/{name}/newProperties", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ComponentProperties newComponentProperties(
@PathVariable(value = "name") @ApiParam(name = "name", value = "Name of the component") String componentName) {
ComponentProperties cp = getDesign().createProperties();
cp.setId(++nextId);
propertiesMap.put(cp.getId(), cp);
return cp;
}
@RequestMapping(value = "/components/{id}/existingProperties", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ComponentProperties existingComponentProperties(
@PathVariable(value = "id") @ApiParam(name = "id", value = "Id of ComponentProperties") int id) {
return propertiesMap.get(id);
}
public ComponentDesign getDesign() {
return design;
}
public void setDesign(ComponentDesign design) {
this.design = design;
}
}

View File

@@ -0,0 +1,14 @@
package org.talend.component.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Order {
int value();
}

View File

@@ -0,0 +1,14 @@
package org.talend.component.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Page {
String value();
}

View File

@@ -0,0 +1,12 @@
package org.talend.component.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Required {
}

View File

@@ -0,0 +1,65 @@
package org.talend.component.common;
import org.talend.component.ComponentProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
@JsonRootName("oauthProperties")
public class OauthProperties extends ComponentProperties {
@JsonProperty
public String clientId;
@JsonProperty
public String clientSecret;
@JsonProperty
public String callbackHost;
@JsonProperty
public int callbackPort;
@JsonProperty
public String tokenFile;
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getClientSecret() {
return clientSecret;
}
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
public String getCallbackHost() {
return callbackHost;
}
public void setCallbackHost(String callbackHost) {
this.callbackHost = callbackHost;
}
public int getCallbackPort() {
return callbackPort;
}
public void setCallbackPort(int callbackPort) {
this.callbackPort = callbackPort;
}
public String getTokenFile() {
return tokenFile;
}
public void setTokenFile(String tokenFile) {
this.tokenFile = tokenFile;
}
}

View File

@@ -0,0 +1,58 @@
package org.talend.component.common;
import org.talend.component.ComponentProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
@JsonRootName("oauthProperties")
public class ProxyProperties extends ComponentProperties {
@JsonProperty
public boolean useProxy;
@JsonProperty
public String host;
@JsonProperty
public int port;
@JsonProperty
public String userName;
@JsonProperty
public String password;
public boolean isUseProxy() {
return useProxy;
}
public void setUseProxy(boolean useProxy) {
this.useProxy = useProxy;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

View File

@@ -0,0 +1,30 @@
package org.talend.component.common;
import org.talend.component.ComponentProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
@JsonRootName("userPasswordProperties")
public class UserPasswordProperties extends ComponentProperties {
@JsonProperty
public String userId;
@JsonProperty
public String password;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

View File

@@ -0,0 +1,30 @@
package org.talend.component.salesforce;
import org.springframework.stereotype.Service;
import org.talend.component.ComponentConnector;
import org.talend.component.ComponentConnector.Type;
import org.talend.component.ComponentDesign;
import org.talend.component.ComponentProperties;
@Service
public class SalesforceDesign extends ComponentDesign {
protected ComponentConnector[] connectors = {
new ComponentConnector(Type.FLOW, 0, 0),
new ComponentConnector(Type.ITERATE, 1, 0),
new ComponentConnector(Type.SUBJOB_OK, 1, 0),
new ComponentConnector(Type.SUBJOB_ERROR, 1, 0) };
protected SalesforceProperties properties;
@Override
public ComponentProperties createProperties() {
return new SalesforceProperties();
}
@Override
public Family[] getSupportedFamilies() {
return new Family[] { Family.BUSINESS, Family.CLOUD };
}
}

View File

@@ -0,0 +1,151 @@
package org.talend.component.salesforce;
import org.talend.component.ComponentProperties;
import org.talend.component.annotation.Order;
import org.talend.component.annotation.Page;
import org.talend.component.annotation.Required;
import org.talend.component.common.OauthProperties;
import org.talend.component.common.ProxyProperties;
import org.talend.component.common.UserPasswordProperties;
import com.fasterxml.jackson.annotation.JsonRootName;
@JsonRootName("salesforceProperties")
public class SalesforceProperties extends ComponentProperties {
public enum LoginType {
BASIC, OAUTH
};
protected static final String LOGIN = "login";
protected static final String MAIN = "main";
public SalesforceProperties() {
proxy = new ProxyProperties();
oauth = new OauthProperties();
userPassword = new UserPasswordProperties();
}
@Order(1)
@Required
@Page(LOGIN)
public LoginType loginType;
@Order(1)
@Page(MAIN)
public boolean bulkConnection;
public String apiVersion;
public String endPoint;
public boolean needCompression;
public int timeout;
public boolean httpTraceMessage;
public String clientId;
@Order(3)
public ProxyProperties proxy;
@Order(2)
@Required
@Page(LOGIN)
public OauthProperties oauth;
@Order(2)
@Required
@Page(LOGIN)
public UserPasswordProperties userPassword;
public LoginType getLoginType() {
return loginType;
}
public void setLoginType(LoginType loginType) {
this.loginType = loginType;
}
public boolean isBulkConnection() {
return bulkConnection;
}
public void setBulkConnection(boolean bulkConnection) {
this.bulkConnection = bulkConnection;
}
public String getApiVersion() {
return apiVersion;
}
public void setApiVersion(String apiVersion) {
this.apiVersion = apiVersion;
}
public String getEndPoint() {
return endPoint;
}
public void setEndPoint(String endPoint) {
this.endPoint = endPoint;
}
public boolean isNeedCompression() {
return needCompression;
}
public void setNeedCompression(boolean needCompression) {
this.needCompression = needCompression;
}
public int getTimeout() {
return timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public boolean isHttpTraceMessage() {
return httpTraceMessage;
}
public void setHttpTraceMessage(boolean httpTraceMessage) {
this.httpTraceMessage = httpTraceMessage;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public ProxyProperties getProxy() {
return proxy;
}
public void setProxy(ProxyProperties proxy) {
this.proxy = proxy;
}
public OauthProperties getOauth() {
return oauth;
}
public void setOauth(OauthProperties oauth) {
this.oauth = oauth;
}
public UserPasswordProperties getUserPassword() {
return userPassword;
}
public void setUserPassword(UserPasswordProperties userPassword) {
this.userPassword = userPassword;
}
}