Beispiel #1
0
        public override CodeNamespaceCollection GenerateClassesToGenerate(Activity activity, Dictionary <string, string> variables)
        {
            JavaActivity javaActivity = (JavaActivity)activity;

            var javaNamespace = new CodeNamespace(javaActivity.PackageName);

            // Generate the Service
            javaNamespace.Imports.AddRange(this.GenerateImports());
            var javaClass = this.GenerateClass(javaActivity);

            javaClass.Members.Add(this.GenerateInvokeMethod());
            javaNamespace.Types.Add(javaClass);

            var codeNameSpaces = new CodeNamespaceCollection {
                javaNamespace
            };

            // Generate the corresponding interface
            if (ConfigurationApp.GetProperty("IsJavaInterfaceAlreadyGenerated") != "true")
            {
                //TODO : Refactor because it's a bit dirty
                var javaServiceInterfaceNameSpace = InterfaceExtractorFromClass.Extract(javaClass, TargetAppNameSpaceService.javaToolsNameSpace());
                javaServiceInterfaceNameSpace.Types[0].Name = IJavaActivityService;
                codeNameSpaces.Add(javaServiceInterfaceNameSpace);
                ConfigurationApp.SaveProperty("IsJavaInterfaceAlreadyGenerated", "true");
            }

            return(codeNameSpaces);
        }
Beispiel #2
0
        private CodeStatementCollection GenerateOutputCallOnJavaClass(JavaActivity javaActivity, CodeVariableReferenceExpression javaClassReference, CodeVariableReferenceExpression activityClassReference)
        {
            var invocationCodeCollection = new CodeStatementCollection();

            foreach (var parameter in javaActivity.OutputData)
            {
                CodeAssignStatement _assign1 = new CodeAssignStatement();

                CodePropertyReferenceExpression _prop1 = new CodePropertyReferenceExpression();
                _prop1.PropertyName = parameter.Name;
                _prop1.TargetObject = activityClassReference;
                _assign1.Left       = _prop1;
                //           CodePrimitiveExpression _value1 = new CodePrimitiveExpression();
                //          _value1.Value = "testvalue";
                //         _assign1.Right = _value1;
                //        __ctor_ctor1.Statements.Add(_assign1);


                CodeMethodInvokeExpression getterCall = new CodeMethodInvokeExpression();
                getterCall.Parameters.AddRange(new CodeExpression[0]);
                CodeMethodReferenceExpression getterMethod = new CodeMethodReferenceExpression();
                getterMethod.MethodName   = "get" + parameter.Name;
                getterMethod.TargetObject = javaClassReference;
                getterCall.Method         = getterMethod;
                _assign1.Right            = getterCall;
                invocationCodeCollection.Add(_assign1);
            }

            return(invocationCodeCollection);
        }
        public void SetUp()
        {
            this.activityBuilder      = new JavaActivityBuilder(new XslBuilder(new XpathBuilder()));
            this.activity             = new JavaActivity("My Activity Name", ActivityType.javaActivityType);
            this.activity.FileName    = "MyJavaFileName";
            this.activity.PackageName = "My.Package.Name";
            this.activity.FullSource  = @" package My.Package.Name
import java.util.*;
import java.io.*;
public class MyJavaFileName{
    protected String platform = "";
    public String getplatform(){return platform;}
    public String setplatform(String val){platform = val;}

    protected Date lastDate = null;
    public String getlastDate(){return lastDate;}
    public String setlastDate(Date val){lastDate = val;}

    public MyJavaFileName(){}

public void invoke () throws Exception{
    setlastDate(System.getDate());
}
    
}

";
            var xml =
                @"
    <javaCodeActivityInput xmlns:xsl=""http://w3.org/1999/XSL/Transform"" >
        <platform>
            <xsl:value-of select=""'testvalue'""/>
        </platform>
    </javaCodeActivityInput>
";
            XElement doc = XElement.Parse(xml);

            this.activity.InputBindings = doc.Nodes();
            this.activity.Parameters    = new List <ClassParameter> {
                new ClassParameter {
                    Name = "platform",
                    Type = "string"
                }
            };
            this.activity.InputData = new List <ClassParameter> {
                new ClassParameter {
                    Name = "platform",
                    Type = "string"
                }
            };
            this.activity.OutputData = new List <ClassParameter> {
                new ClassParameter {
                    Name = "lastDate",
                    Type = "date"
                }
            };
        }
Beispiel #4
0
        public CodeTypeDeclaration GenerateClass(JavaActivity activity)
        {
            var javaClass = new CodeTypeDeclaration(activity.FileName)
            {
                IsClass        = true,
                TypeAttributes = TypeAttributes.Public
            };

            javaClass.BaseTypes.Add(new CodeTypeReference(IJavaActivityService));

            javaClass.Comments.Add(new CodeCommentStatement(activity.FullSource));

            return(javaClass);
        }
Beispiel #5
0
        private CodeStatementCollection GenerateInputCallOnJavaClass(JavaActivity javaActivity, CodeVariableReferenceExpression javaClassReference)
        {
            var invocationCodeCollection = new CodeStatementCollection();

            foreach (var parameter in javaActivity.Parameters)
            {
                CodeMethodInvokeExpression setterCall = new CodeMethodInvokeExpression();
                setterCall.Parameters.AddRange(new List <CodeExpression> {
                    new CodeSnippetExpression(parameter.Name)
                }.ToArray());
                CodeMethodReferenceExpression setterMethod = new CodeMethodReferenceExpression();
                setterMethod.MethodName   = "set" + parameter.Name;
                setterMethod.TargetObject = javaClassReference;
                setterCall.Method         = setterMethod;
                invocationCodeCollection.Add(setterCall);
            }

            return(invocationCodeCollection);
        }
Beispiel #6
0
        public Activity Parse(XElement inputElement)
        {
            var activity = new JavaActivity();

            activity.Name = inputElement.Attribute("name").Value;
            activity.Type = (ActivityType)inputElement.Element(XmlnsConstant.tibcoProcessNameSpace + "type").Value;

            var configElement = inputElement.Element("config");

            activity.FileName    = XElementParserUtils.GetStringValue(configElement.Element("fileName"));
            activity.PackageName = XElementParserUtils.GetStringValue(configElement.Element("packageName"));
            activity.FullSource  = XElementParserUtils.GetStringValue(configElement.Element("fullsource"));

            activity.InputData  = this.GetInputOrOutputData(configElement.Element("inputData"));
            activity.OutputData = this.GetInputOrOutputData(configElement.Element("outputData"));

            if (inputElement.Element(XmlnsConstant.tibcoProcessNameSpace + "inputBindings") != null && inputElement.Element(XmlnsConstant.tibcoProcessNameSpace + "inputBindings").Element("javaCodeActivityInput") != null)
            {
                activity.InputBindings = inputElement.Element(XmlnsConstant.tibcoProcessNameSpace + "inputBindings").Element("javaCodeActivityInput").Nodes();
                activity.Parameters    = new XslParser().Parse(activity.InputBindings);
            }

            return(activity);
        }