Hi Rob,

Some answers below.

> On 24 Jul 2018, at 06:58, Rob Atkinson <[email protected]> wrote:
> 
> Looking at the page source in the browser there is this:
> 
> <form action="swp" enctype="multipart/form-data" id="theForm" method="post">
> ...
> <input name="_viewClass" type="hidden" 
> value="http://topbraid.org/teamwork#ScriptBasedFileImportService";>
> <input id="submitButton" type="submit" value="Finish">
> 
> 
> <script>teamwork.initImportFileForm("uniqueId3232", 
> "swp?_viewName=teamProject&projectGraph=urn%3Ax-evn-master%3Atweed")</script>
> 
> (its been a while since immersed in HTML - but it looks like the page should 
> submit a HTTP POST request rather than call a javascript function on submit - 
> so I dont understand why the UI doesnt leave the page and show the service 
> output ?) 
> 
> - is some javacript tweaking the form behaviour ?

Yes. This particular importer needs to handle imports that may take a few 
minutes, and in that case it’s better to do it asynchronously and show a 
progress indicator. Here is the source code for teamwork.initImportFileForm():

    initImportFileForm: function(progressId) {
        $('#theForm').ajaxForm({
            beforeSubmit: function() {
                swa.openProgressMonitorDialog(progressId, 'Importing File');
            },
            error: function(xhr, status, error) {
                swa.populateModalDialog('File import error: ' + status);
            },
            success: function(data) {
                window.location.href = data;
            }
        });
    },

So it turns the HTML form into an “AJAX form” that is submitted asynchronously 
while the browser stays on the page. The called service is expected to return a 
URL upon completion (variable “data” in the success callback), and the browser 
will navigate to that URL.

For imports that finish quickly, it would be quite reasonable to ditch the AJAX 
call, and generate an HTML page with an error message or success message as the 
output of the import service. You can try removing the call to 
teamwork.initImportFileForm to better understand what happens.

> So a few questions about the best way to customise this:
> 
> 1) what does ui:logMessage do - where is it logged and how is that configured

You mean ui:logMessage on <ui:transaction>? It only does something if the 
transaction modifies a Teamwork-managed graph (one that has a parallel .tch 
graph). In that case, when the transaction completes, a change history entry is 
written into the .tch graph, and the log message is attached to the entry. You 
can see this in action in the change history report for an asset collection.

> 2) what does ui:message on the ui:transaction element do? (it is referenced 
> in http://uispin.org/ui.html#update)

I believe that’s a typo. It should be ui:logMessage. I’ll see about getting it 
fixed.

> 3) how does one report status back to the user?

It depends. If the SWP service returns HTML, the answer is obvious. If it’s 
some other kind of SWP service that is called from an HTML page via AJAX, then 
it really depends. Is the status about an error condition? Try <ui:throw/> with 
an appropriate message. Chances are that the display code will show the error 
in a popup. Is the status about a success condition? Then there are any number 
of different mechanisms, depending on what specifically we are talking about, 
and there may be none. Is the status about reporting progress on a long-running 
task? Check the section on “Monitoring long-running processes” in the SWP docs.

> 4) how to log messages to console in TBC 

In 6.0.0, there is the ui:log control element:

    <ui:log log:info=“This will show up in the TBC Error Log / TBL Log file"/>

Older versions have the SPARQL function smf:trace:

    <ui:group let:dummy="{= smf:trace('This will show up in the TBC Error Log / 
TBL Log file') }"/>

> 5) where are, and how to customise,    EDG logs when running as a server

In the server administration there is a link “TBL Log” which displays the log 
file and shows its location. This is the main Eclipse log and is equivalent to 
the TBC Error Log in TBCME.

Aside from that, there are the usual Tomcat logs. The standard output log 
(catalina.out) sometimes has useful extra stuff on startup & shutdown 
(before/after the Eclipse part of TopBraid is running), and some low-level 
exceptions are only logged here.

> 6) how to customise the message dialogue when the transaction is running

I’m not sure it’s possible with the ScriptBasedFileImport. If the import 
service is implemented in SWP, then it would be with the ui:task/ui:subTask 
stuff discussed in “Monitoring long-running processes”.

> 7) how best to interact with a user to ask a question during an import script 
> - in the SWP 

Make your own clone of the importer. Add a form field to the importer’s form, 
add that field as an argument to the importer’s service, and process the input 
there.

> 8) is it possible to interact with the user in the SMS script?

I don’t know (not much of a SPARQLMotion user). I would assume no.

(If you’re comfortable with writing SWP, then I would recommend against using 
the ScriptBasedFileImport, or any SPARQLMotion in fact, and writing the entire 
import service in SWP. More flexibility and better control.)

Richard

-- 
You received this message because you are subscribed to the Google Groups 
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to