}
/* 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("");
while (jobsOut && jobsOut[i]) {
char *chid = edg_wlc_JobIdUnparse(jobsOut[i]);
- asprintf(&pomA,"%s\t\t <li> <a href=\"%s\">%s</a>\r\n",
- pomB, chid,chid);
-
- free(chid);
+ if (! statsOut[i].parent_job){
+ asprintf(&pomA,"%s\t\t <li><a href=\"%s\">%s</a></li>\r\n",
+ pomB, chid,chid);
+ free(pomB);
+ pomB = pomA;
+ if (statsOut[i].jobtype == EDG_WLL_STAT_COLLECTION){
+ asprintf(&pomA,"%s\t\t <ul>\r\n", pomB);
+ free(pomB);
+ pomB = pomA;
+ j = 0;
+ while (jobsOut[j]) {
+ char *chid_parent = edg_wlc_JobIdUnparse(statsOut[j].parent_job);
+ if (chid_parent && (strcmp(chid, chid_parent) == 0)){
+ char *chid_children = edg_wlc_JobIdUnparse(jobsOut[j]);
+ asprintf(&pomA,"%s\t\t <li><a href=\"%s\">%s</a></li>\r\n",
+ pomB, chid_children,chid_children);
+ free(chid_children);
+ free(pomB);
+ pomB = pomA;
+ }
+ free(chid_parent);
+ j++;
+ }
+ asprintf(&pomA,"%s\t\t </ul>\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++;
}
{
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);
if (stat.rsl) asprintf(&rsl,"<h3>RSL</h3>\r\n"
"<pre>%s</pre>\r\n",stat.rsl);
+ if ((stat.jobtype == EDG_WLL_STAT_COLLECTION) && (stat.children_num > 0)){
+ asprintf(&children, "<h3>Children</h3>\r\n");
+ for (i = 0; i < stat.children_num; i++){
+ asprintf(&pomA,"%s\t\t <li/> <a href=\"%s\">%s</a>\r\n",
+ children, stat.children[i], stat.children[i]);
+ children = pomA;
+ }
+ }
asprintf(&pomA, "<html>\r\n\t<body>\r\n"
"<h2>%s</h2>\r\n"
"<table halign=\"left\">%s</table>"
- "%s%s"
+ "%s%s%s"
"\t</body>\r\n</html>",
- chid,pomB,jdl,rsl);
+ chid,pomB,jdl,rsl, children);
free(pomB);
*message = pomA;
free(chid);
if (chis) free(chis);
if (chos) free(chos);
+ if (chpa) free(chpa);
free(jdl);
free(rsl);
+ free(children);
return 0;
}
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);
/* 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;
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)
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);
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;
*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++;
}
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;