Skip to content

Commit ef91b03

Browse files
committed
Change array for vector
1 parent c91809f commit ef91b03

File tree

2 files changed

+33
-38
lines changed

2 files changed

+33
-38
lines changed

gxdynamiccall/src/main/java/com/genexus/gxdynamiccall/GXDynamicCall.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
import java.lang.reflect.Array;
44
import java.lang.reflect.Constructor;
55
import java.lang.reflect.Method;
6+
import java.util.Vector;
67

78
import com.genexus.CommonUtil;
89
import com.genexus.GXBaseCollection;
9-
import com.genexus.GXSimpleCollection;
10-
import com.genexus.ModelContext;
1110
import com.genexus.SdtMessages_Message;
1211
import com.genexus.common.interfaces.SpecificImplementation;
1312

@@ -38,22 +37,20 @@ public void setObjectName(String name){
3837
objectName=name;
3938
}
4039

41-
public void execute(Object[] parametersArray, Object[] errorsArray) {
40+
public void execute(Vector<Object> parameters, Vector<SdtMessages_Message> errorsArray) {
4241
//Create the instance with default constructor
4342
create(null, errorsArray);
4443
//Create methodconfiguration
45-
if(errorsArray.length>0){
44+
if(errorsArray.size()==0){
4645
GXDynCallMethodConf method = new GXDynCallMethodConf();
4746
//Execute with default method configuration
48-
execute(parametersArray, method, errorsArray);
47+
execute(parameters, method, errorsArray);
4948
}
5049
}
5150

52-
public Object execute(Object[] parametersArray, GXDynCallMethodConf methodConfiguration, Object[] errorsArray) {
51+
public Object execute(Vector<Object> parameters, GXDynCallMethodConf methodConfiguration, Vector<SdtMessages_Message> errorsArray) {
5352

5453
GXBaseCollection<SdtMessages_Message> errors =new GXBaseCollection<SdtMessages_Message>();
55-
// Take the collection of parameters from de array
56-
GXSimpleCollection<Object> parameters = (GXSimpleCollection<Object>) parametersArray[0];
5754
Object result=null;
5855
Object objectToInvoke;
5956
if (!methodConfiguration.getIsStatic())
@@ -66,6 +63,7 @@ public Object execute(Object[] parametersArray, GXDynCallMethodConf methodConfig
6663
{
6764
objectToInvoke=null;
6865
CommonUtil.ErrorToMessages("NullInstance Error", "You must invoke create method before execute a non static one", errors);
66+
errorsArray.addAll(errors.getStruct());
6967
return null;
7068
}
7169
}
@@ -76,18 +74,17 @@ public Object execute(Object[] parametersArray, GXDynCallMethodConf methodConfig
7674
auxClass = loadClass(externalName, packageName);
7775
} catch (ClassNotFoundException e) {
7876
CommonUtil.ErrorToMessages("Load class Error", e.getMessage(), errors);
79-
errorsArray[0]=errors;
77+
errorsArray.addAll(errors.getStruct());
8078
return null;
8179
}
8280
objectToInvoke=auxClass;
8381
}
8482
result = executeMethod(objectToInvoke,methodConfiguration.getMethodName(), parameters, errors, methodConfiguration.getIsStatic());
85-
errorsArray[0]=errors;
86-
parametersArray[0] = parameters;
83+
errorsArray.addAll(errors.getStruct());
8784
return result;
8885
}
8986

90-
public void create(GXSimpleCollection<Object> constructParameters, Object[] errors) {
87+
public void create(Vector<Object> constructParameters, Vector<SdtMessages_Message> errors) {
9188
GXBaseCollection<SdtMessages_Message> error =new GXBaseCollection<SdtMessages_Message>();
9289
String objectNameToInvoke;
9390
Constructor<?> constructor=null;
@@ -125,25 +122,25 @@ public void create(GXSimpleCollection<Object> constructParameters, Object[] erro
125122
}
126123
else{
127124
CommonUtil.ErrorToMessages("CreateInstance Error", "None constructor found", error);
128-
errors[0]=error;
125+
errors.addAll(error.getStruct());
129126
return;
130127
}
131128
} catch (Exception e) {
132129
CommonUtil.ErrorToMessages("CreateInstance Error", e.getMessage(), error);
133130
e.printStackTrace();
134-
errors[0]=error;
131+
errors.addAll(error.getStruct());
135132
return;
136133
}
137134
}
138135
else{
139136
CommonUtil.ErrorToMessages("CreateInstance Error", "Object name not set", error);
140-
errors[0]=error;
137+
errors.addAll(error.getStruct());
141138
return;
142139
}
143140

144141
}
145142

146-
private Object executeMethod(Object objectToInvoke, String method, GXSimpleCollection<Object> params, GXBaseCollection<SdtMessages_Message> errors, boolean isStatic) {
143+
private Object executeMethod(Object objectToInvoke, String method, Vector<Object> params, GXBaseCollection<SdtMessages_Message> errors, boolean isStatic) {
147144

148145
Object returnObject = null;
149146
Method[] methods;
@@ -234,7 +231,7 @@ private Object executeMethod(Object objectToInvoke, String method, GXSimpleColle
234231
return returnObject;
235232
}
236233

237-
private static void updateParams(GXSimpleCollection<Object> originalParameter, Object[] callingParams)
234+
private static void updateParams(Vector<Object> originalParameter, Object[] callingParams)
238235
throws Exception {
239236

240237
for (int i = 0; i < callingParams.length; i++) {

gxdynamiccall/src/test/java/com/genexus/gxdynamiccall/test/GxDynamicCallTest.java

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.genexus.gxdynamiccall.test;
22
import com.genexus.GXBaseCollection;
33
import com.genexus.GXSimpleCollection;
4+
import com.genexus.SdtMessages_Message;
45
import com.genexus.gxdynamiccall.GXDynCallMethodConf;
56
import com.genexus.gxdynamiccall.GXDynCallProperties;
67
import com.genexus.gxdynamiccall.GXDynamicCall;
@@ -9,23 +10,23 @@
910
import org.junit.Assert;
1011
import org.junit.Test;
1112

13+
import java.util.Vector;
14+
1215
public class GxDynamicCallTest {
1316

1417
@Test
1518
public void callGxNativeObject(){
1619
Connect.init();
1720
GXDynamicCall call = new GXDynamicCall();
1821
call.setObjectName("com.genexus.gxdynamiccall.test.DynamicCallTestProcedure");
19-
GXSimpleCollection<Object> paramArray = new GXSimpleCollection<Object>();
22+
Vector<Object> paramArray = new Vector<>();
2023
paramArray.add((short)3);
2124
paramArray.add((short)4);
2225
paramArray.add(new String());
23-
Object[] parametersArray = {paramArray};
24-
Object[] errorsArray= new Object[1];
25-
call.execute(parametersArray, errorsArray);
26-
Assert.assertTrue(((GXBaseCollection)errorsArray[0]).size()==0);
27-
GXSimpleCollection<Object> parms= (GXSimpleCollection<Object>)parametersArray[0];
28-
String parm = ((String)parms.get(2)).trim();
26+
Vector<SdtMessages_Message> errorsArray= new Vector<>();
27+
call.execute(paramArray, errorsArray);
28+
Assert.assertTrue(errorsArray.size()==0);
29+
String parm = ((String)paramArray.get(2)).trim();
2930
Assert.assertTrue(parm.equals("7"));
3031
}
3132

@@ -34,32 +35,30 @@ public void callExternalClass(){
3435
Connect.init();
3536
GXDynamicCall call = new GXDynamicCall();
3637
GXDynCallProperties props = new GXDynCallProperties();
37-
Object[] errorsArray= new Object[1];
38+
Vector<SdtMessages_Message> errorsArray= new Vector<>();
3839
props.setExternalName("DynamicCallExternalTestProcedure");
3940
props.setPackageName("com.genexus.gxdynamiccall.test");
4041
call.setProperties(props);
4142
//Constructor
42-
GXSimpleCollection<Object> constructParamArray = new GXSimpleCollection<Object>();
43+
Vector<Object> constructParamArray = new Vector<>();
4344
constructParamArray.add((int)3);
4445
call.create(constructParamArray, errorsArray);
4546
//Parameters
46-
GXSimpleCollection<Object> paramArray = new GXSimpleCollection<Object>();
47+
Vector<Object> paramArray = new Vector<>();
4748
paramArray.add((short)3);
4849
paramArray.add((short)4);
49-
Object[] parametersArray = {paramArray};
5050
//MethodConfiguration
5151
GXDynCallMethodConf method = new GXDynCallMethodConf();
5252
method.setIsStatic(false);
5353
method.setMethodName("calculateAsString");
54-
String result = (String)call.execute(parametersArray, method, errorsArray);
55-
Assert.assertTrue(((GXBaseCollection)errorsArray[0]).size()==0);
54+
String result = (String)call.execute(paramArray, method, errorsArray);
55+
Assert.assertTrue(errorsArray.size()==0);
5656
Assert.assertTrue(result.trim().equals("21"));
5757
paramArray.clear();
5858
paramArray.add((short)4);
5959
paramArray.add((short)4);
60-
parametersArray[0]=paramArray;
61-
result = (String)call.execute(parametersArray, method, errorsArray);
62-
Assert.assertTrue(((GXBaseCollection)errorsArray[0]).size()==0);
60+
result = (String)call.execute(paramArray, method, errorsArray);
61+
Assert.assertTrue(errorsArray.size()==0);
6362
Assert.assertTrue(result.trim().equals("24"));
6463
}
6564

@@ -68,21 +67,20 @@ public void callExternalClassWithStaticMethod(){
6867
Connect.init();
6968
GXDynamicCall call = new GXDynamicCall();
7069
GXDynCallProperties props = new GXDynCallProperties();
71-
Object[] errorsArray= new Object[1];
70+
Vector<SdtMessages_Message> errorsArray= new Vector<>();
7271
props.setExternalName("DynamicCallExternalTestProcedure");
7372
props.setPackageName("com.genexus.gxdynamiccall.test");
7473
call.setProperties(props);
7574
//Parameters
76-
GXSimpleCollection<Object> paramArray = new GXSimpleCollection<Object>();
75+
Vector<Object> paramArray = new Vector<>();
7776
paramArray.add((short)3);
7877
paramArray.add((short)4);
79-
Object[] parametersArray = {paramArray};
8078
//MethodConfiguration
8179
GXDynCallMethodConf method = new GXDynCallMethodConf();
8280
method.setIsStatic(true);
8381
method.setMethodName("sumAsString");
84-
String result = (String)call.execute(parametersArray, method, errorsArray);
85-
Assert.assertTrue(((GXBaseCollection)errorsArray[0]).size()==0);
82+
String result = (String)call.execute(paramArray, method, errorsArray);
83+
Assert.assertTrue(errorsArray.size()==0);
8684
Assert.assertTrue(result.trim().equals("7"));
8785
}
8886

0 commit comments

Comments
 (0)