2

The situation is as follows:

  • I have an XML export of a project;
  • I have a working Caché installation (which means I have cachedb.jar and cachejdbc.jar);
  • I have a namespace/user/pass to work with.

What I want to do is:

  • import the XML into this namespace;
  • collect the list of classes imported by that XML;
  • write the plain source files in a destination directory;
  • remove the imported classes after I'm done reading.

I know how to do point 3 (using class %Compiler.UDL.TextServices); but I have no idea how to do point 1.

Also, it may be that the Caché installation is not on the machine on which I want to do the import.

So, what class can I use to import that XML, and how do I specifically retrieve the classes which I have just imported, and not the others?


EDIT: OK, it appears that what I must use is the LoadStream method from %System.OBJ.

Given a Database object, it means I can run it as a class method using the .runClassMethod() on this object... Except that I fail to see how to create the stream in the first place. Argh.

fge
  • 119,121
  • 33
  • 254
  • 329

2 Answers2

3

You can use $System.OBJ.Load method and pass him the XML file name to import and possibly compile files.Use loadedlist argument to get a list of imported items.

To remove imported classes first call $System.OBJ.UnCompile method, and after that delete class definitions from %Dictionary.ClassDefinition class.

rfg
  • 1,331
  • 1
  • 8
  • 24
  • The problem with this method is that the file is required to be on the same machine that the Caché installation is; I don't want that restriction :/ – fge Feb 10 '16 at 07:39
  • Okay, why don't you create stream in java and call LoadStream method? – rfg Feb 10 '16 at 07:42
  • http://docs.intersystems.com/cache20152/csp/docbook/DocBook.UI.Page.cls?KEY=BLJV_using#BLJV_using_streams – rfg Feb 10 '16 at 07:42
  • Yes, that is indeed the idea I'm trying to figure out how to code at the moment... Thanks for the link! – fge Feb 10 '16 at 07:47
  • Also, uhm, do you have to compile before you can write back using %Compiler.UDL.TextServices? – fge Feb 10 '16 at 07:52
  • 1
    loading will be enough, compile does not needed – DAiMor Feb 10 '16 at 07:57
0

Answer to self: it's done, and it's on Github.

There are still problems though.

fge
  • 119,121
  • 33
  • 254
  • 329