22import com .genexus .ModelContext ;
33import com .genexus .common .interfaces .IPendingEventHelper ;
44import com .genexus .common .interfaces .SpecificImplementation ;
5+ import com .genexus .diagnostics .core .ILogger ;
6+ import com .genexus .diagnostics .core .LogManager ;
57import com .genexus .util .GXProperties ;
68
79import java .io .InputStream ;
8- import java .io .StringWriter ;
10+ import java .io .StringWriter ;
11+ import java .lang .reflect .Method ;
12+ import java .util .HashMap ;
13+ import java .util .HashSet ;
14+
915import com .genexus .xml .GXXMLSerializer ;
1016
1117public class GxSilentTrnSdt extends com .genexus .xml .GXXMLSerializable
1218{
13-
19+ static final ILogger logger = LogManager .getLogger (GxSilentTrnSdt .class );
20+ static final String SET_METHOD_PREFIX = "setgxTv_" ;
21+ static final String GET_METHOD_PREFIX = "getgxTv_" ;
1422 IPendingEventHelper pendingHelper ;
1523 GXProperties dirties = new GXProperties ();
1624
@@ -262,7 +270,7 @@ public void setvalue(String name, String value)
262270 try
263271 {
264272 Class <?> me = getClass ();
265- String methodName = "setgxTv_" + me .getSimpleName () + "_" + name .substring (0 , 1 ).toUpperCase () + name .substring (1 ).toLowerCase ();
273+ String methodName = SET_METHOD_PREFIX + me .getSimpleName () + "_" + name .substring (0 , 1 ).toUpperCase () + name .substring (1 ).toLowerCase ();
266274 for (java .lang .reflect .Method method : me .getMethods ())
267275 {
268276 if (method .getName ().equals (methodName ))
@@ -272,7 +280,7 @@ public void setvalue(String name, String value)
272280 {
273281 if (GXSimpleCollection .class .isAssignableFrom (parmTypes [0 ]))
274282 {
275- String methodNameGet = "getgxTv_" + me .getSimpleName () + "_" + name .substring (0 , 1 ).toUpperCase () + name .substring (1 ).toLowerCase ();
283+ String methodNameGet = GET_METHOD_PREFIX + me .getSimpleName () + "_" + name .substring (0 , 1 ).toUpperCase () + name .substring (1 ).toLowerCase ();
276284 GXSimpleCollection col = (GXSimpleCollection )me .getMethod (methodNameGet , new Class []{}).invoke (this , (Object [])null );
277285 col .removeAllItems ();
278286 col .fromJSonString (value );
@@ -288,13 +296,43 @@ public void setvalue(String name, String value)
288296 {
289297 }
290298 }
299+ public void copy (GxSilentTrnSdt source )
300+ {
301+ try
302+ {
303+ Class <?> me = getClass ();
304+ HashMap <String , Method > setMethods = new HashMap <>();
305+ HashMap <String , Method > getMethods = new HashMap <>();
306+ for (java .lang .reflect .Method method : me .getDeclaredMethods ())
307+ {
308+ String methodName = method .getName ();
309+ if (methodName .startsWith (SET_METHOD_PREFIX ))
310+ {
311+ setMethods .put (methodName , method );
312+ }else if (methodName .startsWith (GET_METHOD_PREFIX )){
313+ getMethods .put (methodName , method );
314+ }
315+ }
316+ for (java .lang .reflect .Method setMethod : setMethods .values ()) {
317+ String getMethod = setMethod .getName ().replace (SET_METHOD_PREFIX , GET_METHOD_PREFIX );
318+ if (getMethods .containsKey (getMethod )) {
319+ Object value = getMethods .get (getMethod ).invoke (source , (Object []) null );
320+ setMethod .invoke (this , new Object []{value });
321+ }
322+ }
323+
324+ }catch (Exception e )
325+ {
326+ logger .fatal (e .getMessage (), e );
327+ }
328+ }
291329
292330 public String getvalue (String name )
293331 {
294332 try
295333 {
296334 Class <?> me = getClass ();
297- String methodName = "getgxTv_" + me .getSimpleName () + "_" + name .substring (0 , 1 ).toUpperCase () + name .substring (1 ).toLowerCase ();
335+ String methodName = GET_METHOD_PREFIX + me .getSimpleName () + "_" + name .substring (0 , 1 ).toUpperCase () + name .substring (1 ).toLowerCase ();
298336
299337 Object obj = me .getMethod (methodName , new Class []{}).invoke (this , (Object [])null );
300338 if (obj instanceof GXSimpleCollection )
0 commit comments