Project

General

Profile

Bug #2489

FileSystemOps.searchPath(String) should return the 4GL procedure name for external procedures found via SourceNameMapper

Added by Greg Shah over 9 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Start date:
Due date:
% Done:

100%

Estimated time:
8.00 h
billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:

History

#1 Updated by Greg Shah over 9 years ago

It is common for 4GL code to search for 4GL external procedure names before executing those programs. Such searches use SEARCH() which maps to FileSystemOps.searchPath(String) in P2J. Since the PROPATH can be assigned in the 4GL, the use of SEARCH() honors such changes and the results of the call can change at runtime.

Our searchPath() does also honor the propath, including any assigned changes. But since the 4GL code is not actually existing in the file system on the client, we cannot find such resources using the standard search algorithm. So what we have done is to first query the SourceNameMapper to see if it knows about the name as an external procedure. That code is also propath aware and it can have its results change at runtime based on this.

The only problem is that today, is SourceNameMapper.convertName() returns a non-null value (meaning it found a match), we return that value which is the Java class name that matches the original 4GL program that was being searched for. This breaks the contract with the original 4GL code, which is certainly expecting a return value that corresponds to the following:

  • It is a 4GL external procedure name, usually (but not always) ending in a .p or .w and possibly including characters that are invalid in a Java package and class name (e.g. hyphens).
  • The name is fully qualified with a client filesystem absolute path.

We need to fix FileSystemOps.searchPath(String) to return the 4GL procedure name for external procedures found via SourceNameMapper. This will have to be turned into a absolute path, which is tricky because no such path actually exists. We may have to either:

  • Have a pre-configured application-specific 4gl-src-root that we treat like our pkgroot (as a fixed prefix on all application package + class names).
  • Use the client filesystem's current directory (or other queryable value) to calculate a 4gl-src-root.

Or perhaps we do both of these things (use a 4gl-src-root if is configured, otherwise calculate one).

#2 Updated by Greg Shah almost 9 years ago

As part of this task, please also review how absolute paths are handled by SourceNameMapper. Make sure there are no inconsistencies or problems in the implementation. The intention has always been to be tolerant of absolute paths coded into the 4GL while actually eliminating them in the converted system. The way we did this was by allowing flexible matches based on the propath. I'm not 100% sure our approach is correct, so it needs some consideration.

#3 Updated by Greg Shah over 8 years ago

  • Target version changed from Milestone 12 to Milestone 16

#4 Updated by Greg Shah about 8 years ago

From Ovidiu:

Related to searchPath() of #2489. While the system was busy I checked this method and related ones from SourceNameMapper & FileSystemOps. I could not identify a flow in the logic. The behaviour described in 2489 is exact the reason why the 13/14 SwipeCardExtractTest tests ere failing in #3072. Do you know a specific testcase that fails, or at least was failing before the merge of 2475c?

#5 Updated by Greg Shah about 8 years ago

  • % Done changed from 0 to 50
  • Assignee set to Ovidiu Maxiniuc

The following code demonstrates the problem:

def var pname as char init "search-for-program-file.p".
def var fname as char.
def var txt   as char.

fname = search(pname).

txt   = "SEARCH(" + pname + ") ".
txt   = if fname eq ? then txt + "failed (no result found)." 
                      else txt + fname. 

message txt.

I have checked this program into testcases/uast/search-for-program-file.p.

When I run this in the 4GL, here is the result:

SEARCH(search-for-program-file.p) search-for-program-file.p

Procedure complete. Press space bar to continue.

The P2J result:

SEARCH(search-for-program-file.p) com.goldencode.testcases.SearchForProgramFile

Procedure complete. Press space bar to continue.

Please fix this in a 2489a branch. The 2475d should be kept separate.

#6 Updated by Ovidiu Maxiniuc about 8 years ago

  • Status changed from New to WIP
  • % Done changed from 50 to 80

2489a branch was created from trunk 11022. The update fixes the FileSystemOps.searchPath(String) by making SourceNameMapper.convertName() returning both converted java and legacy name in a String array. The callers will pick the element they are interested in. Now search-for-program-file.p prints correctly the legacy name of the procedure.
Current revision is 11023. Please review.

#7 Updated by Greg Shah about 8 years ago

Code Review Task Branch 2489a Revision 11022

The code is good.

One thing I'd prefer is to implement convenience workers in SourceNameMapper to hide the two different use cases:

public String convertNameToClass(String legacy)
{
   String[] paths = convertName(legacy);
   return (paths != null) ? paths[0] : null;
}

public String lookupAbsoluteLegacyName(String legacy)
{
   String[] paths = convertName(legacy);
   return (paths != null) ? paths[1] : null;
}

#8 Updated by Ovidiu Maxiniuc about 8 years ago

Task branch 2489a was rebased to trunk 11037. The changes from note 7 were applied. The current revision is 11040.
I am going to regression test it on devsrv01.

#9 Updated by Greg Shah about 8 years ago

Code Review Task Branch 2489a Revision 11040

Overall, this is very good. Please rebase. Also apply these minor changes:

1. On more reflection, I think SourceNameMapper.lookupAbsoluteLegacyName() should be named SourceNameMapper.lookupLegacyName() since it can match relative names as well as absolute names. The lookupAbsoluteLegacyName() suggests that we are passing in an absolute name, which is not always correct.

2. The return javadoc for lookupAbsoluteLegacyName() is incorrect.

3. In FileSystemOps.searchPath(), there is this comment/code:

      // if the Progress code was checking for the availability of an external procedure, we have
      // to "fake" it out into thinking that this still exists, try a converted class name lookup
      // first (but returning its legacy name)

      String cls = SourceNameMapper.lookupAbsoluteLegacyName(filename);
      if (cls != null)
      {
         // this is a program name, return the Java class name instead
         return new character(cls);
      }

In this case both comments seem misleading. We aren't looking up the class name anymore. But we are saying that try a converted class name lookup first and return the Java class name instead which are not accurate.

Since a class is not being returned, the cls variable name is no longer descriptive.

Please change it like this:

      // if the Progress code was checking for the availability of an external procedure, we have
      // to "fake" it out into thinking that this still exists, try to match this given filename
      // with a known program name, optionally honoring any absolute prefix passed in

      String legacy = SourceNameMapper.lookupAbsoluteLegacyName(filename);
      if (legacy != null)
      {
         // this is a legacy program name, return it instead of searching on the client side
         return new character(legacy);
      }

#10 Updated by Greg Shah about 8 years ago

From Ovidiu:

Task branch 2489a was rebased to latest trunk. After update, the current revision is 11048.

#11 Updated by Greg Shah about 8 years ago

Code Review Task Branch 2489a Revision 11048

I'm fine with the changes. Please runtime regression test them.

#12 Updated by Ovidiu Maxiniuc about 8 years ago

I ran the regression testing on 2489a/11053 (after rebasing to latest trunk).
It went all fine except for gc_tests/gc_65 and gc_tests/gc_66. The problem is in 25th step of gc_65:
2489a/11053 codebase: reference screen:
PROGRAM: so/operskil.p PROGRAM: aero.timco.majic.so.Operskil

This is normal, since now the searchPath() returned the legacy procedure name, as documented in the task. The reference must be updated.

I ran manually the rest of the test and gc_tests/gc_66 and they are matched the reference (gc_66 failed because the screen got out of sync in gc_65).

In conclusion, the update passed the regression testing on devsrv01.

#13 Updated by Greg Shah about 8 years ago

Please make the required updates to the baselines to match the new text, test the result to confirm that these changes will allow these tests to pass.

Then you can merge 2489a to trunk. Make sure to check in the baseline changes at the same time. In the notification email, explain to people how they must pull down the baseline updates.

#14 Updated by Ovidiu Maxiniuc about 8 years ago

  • % Done changed from 80 to 100

The task branch 2489a was merged to trunk as revision 11051. The changes in magic_baseline were also committed.
Then the branch and the regression results were archived and notification was sent to team members.

#15 Updated by Greg Shah about 8 years ago

  • Status changed from WIP to Closed

#16 Updated by Greg Shah over 7 years ago

  • Target version changed from Milestone 16 to Cleanup and Stabilization for GUI

Also available in: Atom PDF