view software/eXist/webapp/mpdl/scheduler/get-jobs.xql @ 7:5589d865af7a

Erstellung XQL/XSL Applikation
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 08 Feb 2011 15:16:46 +0100
parents
children
line wrap: on
line source

xquery version "1.0";

declare namespace request="http://exist-db.org/xquery/request";
declare namespace util = "http://exist-db.org/xquery/util";

let $jobId := request:get-parameter("id", "all")

let $result := mpdldoc:get-jobs($jobId)

let $resultHtml := 
  for $operation in $result//mpdl-doc-operation
    let $operationName := $operation/name
    let $jobId := $operation/job-id
    let $srcUrl := $operation/src/url
    let $source :=
      if ($operationName = 'delete')
      then ()
      else if (starts-with($srcUrl, 'file:'))
      then
        <bla> 
          <b>Source</b>
          <ul>
            <li><b>Upload file name:</b> {$operation/src/upload-file-name}</li>
          </ul>
        </bla>
      else
        <bla> 
          <b>Source</b>
          <ul>
            <li><b>Url:</b> {$operation/src/url}</li>
          </ul>
        </bla>
    let $destUrl :=
      if ($operationName = 'create' or $operationName = 'update')
      then
        <bla>
        <li><b>Link to eSciDoc:</b> <a href="{$operation/dest/escidoc-url}">{$operation/dest/escidoc-url}</a></li>
        <li><b>Link to eXist:</b> <a href="{$operation/dest/exist-url}">{$operation/dest/exist-url}</a></li>
        </bla>
      else if ($operationName = 'updateExist')
      then
        <bla>
        <li><b>Link to eXist:</b> <a href="{$operation/dest/exist-url}">{$operation/dest/exist-url}</a></li>
        </bla>
      else ()
    let $errorMessage := $operation/status/error-message
    let $errorLIEntry := 
      if ($errorMessage = 'no error')
      then <li><b>Error:</b> {$errorMessage}</li>
      else <li><font color="#FF0000"><b>Error:</b></font> {$errorMessage}</li>
    let $operationHtmlTableData :=
      <bla>
        <tr><td>
        <b>Refresh:</b> <a href="?id={$jobId}">operation status</a><p/>
        <b>Operation:</b> {$operation/name}<p/>
        <b>Job-Id:</b> {$operation/job-id}<p/>
        <b>Job status</b>
          <ul>
          <li><b>Started:</b> {$operation/status/started}</li>
          <li><b>Finished:</b> {$operation/status/finished}</li>
          <li><b>Description:</b> {$operation/status/description}</li>
          {$errorLIEntry}
        </ul>
        {$source}
        <b>Destination</b>
          <ul>
            <li><b>Document base:</b> {$operation/dest/doc-base}</li>
            <li><b>Language:</b> {$operation/dest/language}</li>
            <li><b>Document name:</b> {$operation/dest/file-name}</li>
            {$destUrl}
          </ul>
        <b>Description:</b> {$operation/description}<p/>
        <hr/>
        </td></tr>
      </bla>  
  return <bla>{$operationHtmlTableData}</bla>

let $title := "Document operation status"
return 
<html>
<head>
<title>{$title}</title>
</head>
<body>
  <h1>{$title}</h1>
  <table>
  {$resultHtml}
  </table>
  See the <a href="get-jobs.xql?_source=yes">XQuery source</a> of this page, if you find a bug <a href="https://itgroup.mpiwg-berlin.mpg.de:8080/tracs/mpdl-project-software/newticket">let us know</a>
</body>
</html>