From baa477c6a1eac1e08d76edc622c048a3ed18882d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20Filipovi=C4=8D?= Date: Thu, 4 Nov 2010 15:35:25 +0000 Subject: [PATCH] Support collection display in HTML interface. --- org.glite.lb.server/src/lb_html.c | 68 ++++++++++++++++++++++++++++++++------ org.glite.lb.server/src/lb_html.h | 2 +- org.glite.lb.server/src/lb_proto.c | 8 ++--- org.glite.lb.server/src/lb_proto.h | 2 +- org.glite.lb.server/src/userjobs.c | 6 ++-- org.glite.lb.server/src/ws_query.c | 2 +- 6 files changed, 68 insertions(+), 20 deletions(-) diff --git a/org.glite.lb.server/src/lb_html.c b/org.glite.lb.server/src/lb_html.c index 507b9db..90d3786 100644 --- a/org.glite.lb.server/src/lb_html.c +++ b/org.glite.lb.server/src/lb_html.c @@ -44,10 +44,12 @@ int edg_wll_QueryToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wll_Event *eventsOut } /* construct Message-Body of Response-Line for edg_wll_UserJobs */ -int edg_wll_UserInfoToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wlc_JobId *jobsOut, char **message) +int edg_wll_UserInfoToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wlc_JobId *jobsOut, edg_wll_JobStat *statsOut, char **message) { + //TODO remove quadratic complexity one day... + char *pomA = NULL, *pomB; - int i = 0; + int i = 0, j; /* head */ pomB = strdup(""); @@ -55,12 +57,42 @@ int edg_wll_UserInfoToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wlc_JobId *jobsOu while (jobsOut && jobsOut[i]) { char *chid = edg_wlc_JobIdUnparse(jobsOut[i]); - asprintf(&pomA,"%s\t\t
  • %s\r\n", - pomB, chid,chid); - - free(chid); + if (! statsOut[i].parent_job){ + asprintf(&pomA,"%s\t\t
  • %s
  • \r\n", + pomB, chid,chid); + free(pomB); + pomB = pomA; + if (statsOut[i].jobtype == EDG_WLL_STAT_COLLECTION){ + asprintf(&pomA,"%s\t\t \r\n", pomB); + free(pomB); + pomB = pomA; + } + free(chid); + } + +// stat.jobtype == EDG_WLL_STAT_COLLECTION +// if (stat.parent_job) chpa = edg_wlc_JobIdUnparse(stat.parent_job); + + /*free(chid); free(pomB); - pomB = pomA; + pomB = pomA;*/ i++; } @@ -192,16 +224,20 @@ int edg_wll_GeneralJobStatusToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobSt { char *pomA = NULL, *pomB = NULL; int pomL = 0; - char *chid,*chstat,*chis = NULL, *chos = NULL; - char *jdl,*rsl; + char *chid,*chstat,*chis = NULL, *chos = NULL, *chpa = NULL; + char *jdl,*rsl,*children; + int i; jdl = strdup(""); rsl = strdup(""); + children = strdup(""); chid = edg_wlc_JobIdUnparse(stat.jobId); if (stat.isb_transfer) chis = edg_wlc_JobIdUnparse(stat.isb_transfer); if (stat.osb_transfer) chos = edg_wlc_JobIdUnparse(stat.osb_transfer); + if (stat.parent_job) chpa = edg_wlc_JobIdUnparse(stat.parent_job); + TRL("Parent job", "%s", chpa, NULL); TR("Status","%s",(chstat = edg_wll_StatToString(stat.state)), NULL); free(chstat); TR("Owner","%s",stat.owner, NULL); @@ -249,13 +285,21 @@ int edg_wll_GeneralJobStatusToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobSt if (stat.rsl) asprintf(&rsl,"

    RSL

    \r\n" "
    %s
    \r\n",stat.rsl); + if ((stat.jobtype == EDG_WLL_STAT_COLLECTION) && (stat.children_num > 0)){ + asprintf(&children, "

    Children

    \r\n"); + for (i = 0; i < stat.children_num; i++){ + asprintf(&pomA,"%s\t\t
  • %s\r\n", + children, stat.children[i], stat.children[i]); + children = pomA; + } + } asprintf(&pomA, "\r\n\t\r\n" "

    %s

    \r\n" "%s
    " - "%s%s" + "%s%s%s" "\t\r\n", - chid,pomB,jdl,rsl); + chid,pomB,jdl,rsl, children); free(pomB); *message = pomA; @@ -263,8 +307,10 @@ int edg_wll_GeneralJobStatusToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobSt free(chid); if (chis) free(chis); if (chos) free(chos); + if (chpa) free(chpa); free(jdl); free(rsl); + free(children); return 0; } diff --git a/org.glite.lb.server/src/lb_html.h b/org.glite.lb.server/src/lb_html.h index e5c4eeb..faea17d 100644 --- a/org.glite.lb.server/src/lb_html.h +++ b/org.glite.lb.server/src/lb_html.h @@ -28,7 +28,7 @@ limitations under the License. int edg_wll_QueryToHTML(edg_wll_Context,edg_wll_Event *,char **); int edg_wll_GeneralJobStatusToHTML(edg_wll_Context, edg_wll_JobStat, char **); int edg_wll_CreamJobStatusToHTML(edg_wll_Context, edg_wll_JobStat, char **); -int edg_wll_UserInfoToHTML(edg_wll_Context, edg_wlc_JobId *, char **); +int edg_wll_UserInfoToHTML(edg_wll_Context, edg_wlc_JobId *, edg_wll_JobStat *, char **); int edg_wll_UserNotifsToHTML(edg_wll_Context ctx, char **notifids, char **message); int edg_wll_NotificationToHTML(edg_wll_Context ctx, notifInfo *ni, char **message); char *edg_wll_ErrorToHTML(edg_wll_Context,int); diff --git a/org.glite.lb.server/src/lb_proto.c b/org.glite.lb.server/src/lb_proto.c index 8dc453a..3116d8d 100644 --- a/org.glite.lb.server/src/lb_proto.c +++ b/org.glite.lb.server/src/lb_proto.c @@ -642,16 +642,16 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx, /* GET /: Current User Jobs */ else if (requestPTR[0]=='/' && (requestPTR[1]==' ' || requestPTR[1]=='?')) { edg_wlc_JobId *jobsOut = NULL; + edg_wll_JobStat *statesOut = NULL; int i, flags; flags = (requestPTR[1]=='?') ? edg_wll_string_to_stat_flags(requestPTR + 2) : 0; -// FIXME: edg_wll_UserJobs should take flags as parameter - switch (edg_wll_UserJobsServer(ctx,&jobsOut,NULL)) { + switch (edg_wll_UserJobsServer(ctx, EDG_WLL_STAT_CHILDREN, &jobsOut, &statesOut)) { case 0: if (text) edg_wll_UserInfoToText(ctx, jobsOut, &message); else if (html) - edg_wll_UserInfoToHTML(ctx, jobsOut, &message); + edg_wll_UserInfoToHTML(ctx, jobsOut, statesOut, &message); else ret = HTTP_OK; break; case ENOENT: ret = HTTP_NOTFOUND; break; @@ -699,7 +699,7 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx, edg_wll_SetError(ctx,EDG_WLL_ERROR_JOBID_FORMAT,fullid); ret = HTTP_BADREQ; } - else switch (edg_wll_JobStatusServer(ctx,jobId,EDG_WLL_STAT_CLASSADS,&stat)) { + else switch (edg_wll_JobStatusServer(ctx,jobId,EDG_WLL_STAT_CLASSADS | EDG_WLL_STAT_CHILDREN,&stat)) { case 0: if (text) edg_wll_JobStatusToText(ctx,stat,&message); else if (html) diff --git a/org.glite.lb.server/src/lb_proto.h b/org.glite.lb.server/src/lb_proto.h index a89417f..4b0eebe 100644 --- a/org.glite.lb.server/src/lb_proto.h +++ b/org.glite.lb.server/src/lb_proto.h @@ -50,7 +50,7 @@ typedef struct _notifInfo{ extern char *edg_wll_HTTPErrorMessage(int); -extern int edg_wll_UserJobsServer(edg_wll_Context ctx, edg_wlc_JobId **jobs, edg_wll_JobStat **states); +extern int edg_wll_UserJobsServer(edg_wll_Context ctx, int flags, edg_wlc_JobId **jobs, edg_wll_JobStat **states); extern int edg_wll_QuerySequenceCodeServer(edg_wll_Context ctx, edg_wlc_JobId jobid, const char *source, char **seqcode); diff --git a/org.glite.lb.server/src/userjobs.c b/org.glite.lb.server/src/userjobs.c index d859a51..4fd24b9 100644 --- a/org.glite.lb.server/src/userjobs.c +++ b/org.glite.lb.server/src/userjobs.c @@ -35,8 +35,10 @@ limitations under the License. int edg_wll_UserJobsServer( edg_wll_Context ctx, + int flags, edg_wlc_JobId **jobs, - edg_wll_JobStat **states) + edg_wll_JobStat **states +) { char *userid, *stmt = NULL, *res = NULL; @@ -118,7 +120,7 @@ int edg_wll_UserJobsServer( *states = calloc(njobs+1, sizeof(**states)); idx = 0; for (i = 0; i < njobs; i++) { - if (edg_wll_JobStatusServer(ctx, out[idx], -1, &(*states)[idx]) != 0) + if (edg_wll_JobStatusServer(ctx, out[idx], flags, &(*states)[idx]) != 0) edg_wll_ResetError(ctx); idx++; } diff --git a/org.glite.lb.server/src/ws_query.c b/org.glite.lb.server/src/ws_query.c index 8c6a7e4..d392836 100644 --- a/org.glite.lb.server/src/ws_query.c +++ b/org.glite.lb.server/src/ws_query.c @@ -193,7 +193,7 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb__UserJobs( ctx = (edg_wll_Context) glite_gsplugin_get_udata(soap); memset(out, 0, sizeof *out); - if (edg_wll_UserJobsServer(ctx, &jobs, &states) != 0) goto fault; + if (edg_wll_UserJobsServer(ctx, -1, &jobs, &states) != 0) goto fault; if (edg_wll_UserJobsResToSoap(soap, (glite_jobid_const_t *)jobs, (const edg_wll_JobStat *)states, out) != SOAP_OK) { edg_wll_SetError(ctx, ENOMEM, "Couldn't create internal structures"); goto freefault; -- 1.8.2.3