Skip to content

Commit 8387bfd

Browse files
committed
Address feedback, support backwards compatibility with job_id and pyclowder
1 parent f0dac3e commit 8387bfd

File tree

6 files changed

+57
-52
lines changed

6 files changed

+57
-52
lines changed

app/api/Extractions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class Extractions @Inject()(
142142
// FIXME dataset not available?
143143
plugin.fileCreated(file, None, Utils.baseUrl(request), request.apiKey) match {
144144
case Some(jobId) => {
145-
Ok(Json.obj("status" -> "Ok", "job_id" -> jobId))
145+
Ok(Json.obj("status" -> "OK", "job_id" -> jobId))
146146
}
147147
case None => {
148148
val message = "No jobId found for Extraction"

app/models/Extraction.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import play.api.libs.functional.syntax._
1212
case class Extraction(
1313
id: UUID = UUID.generate,
1414
file_id: UUID,
15-
job_id: UUID,
15+
job_id: Option[UUID],
1616
extractor_id: String,
1717
status: String = "N/A",
1818
start: Date,

app/services/RabbitmqPlugin.scala

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import scala.util.Try
4646
case class ExtractorMessage(
4747
msgid: UUID,
4848
fileId: UUID,
49-
jobId: UUID,
49+
jobId: Option[UUID],
5050
notifies: List[String],
5151
intermediateId: UUID,
5252
host: String,
@@ -431,13 +431,13 @@ class RabbitmqPlugin(application: Application) extends Plugin {
431431
* @param file_id the UUID of file
432432
* @param extractor_id the extractor queue name to be submitted
433433
*/
434-
def postSubmissionEven(file_id: UUID, extractor_id: String): (UUID, UUID) = {
434+
def postSubmissionEven(file_id: UUID, extractor_id: String): (UUID, Option[UUID]) = {
435435
val extractions: ExtractionService = DI.injector.getInstance(classOf[ExtractionService])
436436

437437
import java.text.SimpleDateFormat
438438
val dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX")
439439
val submittedDateConvert = new java.util.Date()
440-
val job_id = UUID.generate()
440+
val job_id = Some(UUID.generate())
441441
extractions.insert(Extraction(UUID.generate(), file_id, job_id, extractor_id, "SUBMITTED", submittedDateConvert, None)) match {
442442
case Some(objectid) => (UUID(objectid.toString), job_id)
443443
case None => (UUID(""), job_id)
@@ -487,7 +487,7 @@ class RabbitmqPlugin(application: Application) extends Plugin {
487487
val msg = ExtractorMessage(id, file.id, job_id, notifies, file.id, host, queue, extraInfo, file.length.toString,
488488
d.id, "", apiKey, routingKey, source, "created", None)
489489
extractWorkQueue(msg)
490-
jobId = Option(job_id)
490+
jobId = job_id
491491
}
492492
jobId
493493
}
@@ -609,7 +609,7 @@ class RabbitmqPlugin(application: Application) extends Plugin {
609609
* @param newFlags
610610
*/
611611
def submitFileManually(originalId: UUID, file: File, host: String, queue: String, extraInfo: Map[String, Any],
612-
datasetId: UUID, newFlags: String, requestAPIKey: Option[String], user: Option[User]): UUID = {
612+
datasetId: UUID, newFlags: String, requestAPIKey: Option[String], user: Option[User]): Option[UUID] = {
613613
Logger.debug(s"Sending message to $queue from $host with extraInfo $extraInfo")
614614
val apiKey = getApiKey(requestAPIKey, user)
615615
val sourceExtra = JsObject((Seq("filename" -> JsString(file.filename))))
@@ -632,7 +632,7 @@ class RabbitmqPlugin(application: Application) extends Plugin {
632632
* @param newFlags
633633
*/
634634
def submitDatasetManually(host: String, queue: String, extraInfo: Map[String, Any], datasetId: UUID, newFlags: String,
635-
requestAPIKey: Option[String], user: Option[User]): UUID = {
635+
requestAPIKey: Option[String], user: Option[User]): Option[UUID] = {
636636
Logger.debug(s"Sending message $queue from $host with extraInfo $extraInfo")
637637
val apiKey = getApiKey(requestAPIKey, user)
638638
val source = Entity(ResourceRef(ResourceRef.dataset, datasetId), None, JsObject(Seq.empty))
@@ -964,13 +964,13 @@ class PendingRequestCancellationActor(exchange: String, connection: Option[Conne
964964
val extractions: ExtractionService = DI.injector.getInstance(classOf[ExtractionService])
965965
val dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX")
966966
var startDate = new java.util.Date()
967-
val job_id: UUID = extractions.get(msg_id) match {
967+
val job_id: Option[UUID] = extractions.get(msg_id) match {
968968
case Some(extraction) => {
969969
extraction.job_id
970970
}
971971
case None => {
972972
Logger.warn("Failed to lookup jobId.. no extraction message found with id=" + msg_id)
973-
UUID("")
973+
None
974974
}
975975
}
976976
extractions.insert(Extraction(UUID.generate(), id, job_id, queueName, "Cancel Requested", startDate, None))
@@ -1111,7 +1111,7 @@ class PublishDirectActor(channel: Channel, replyQueueName: String) extends Actor
11111111
"notifies" -> Json.toJson(notifies),
11121112
"msgid" -> Json.toJson(msgid.stringify),
11131113
"id" -> Json.toJson(fileid.stringify),
1114-
"jobid" -> Json.toJson(jobid.stringify),
1114+
"jobid" -> Json.toJson(jobid.get.stringify),
11151115
"intermediateId" -> Json.toJson(intermediateId.stringify),
11161116
"fileSize" -> Json.toJson(fileSize),
11171117
"host" -> Json.toJson(actualHost),
@@ -1189,7 +1189,10 @@ class EventFilter(channel: Channel, queue: String) extends Actor {
11891189
Logger.debug("Received extractor status: " + statusBody)
11901190
val json = Json.parse(statusBody)
11911191
val file_id = UUID((json \ "file_id").as[String])
1192-
val job_id = UUID((json \ "job_id").as[String])
1192+
val job_id: Option[UUID] = (json \ "job_id").asOpt[String] match {
1193+
case Some(jid) => { Some(UUID(jid)) }
1194+
case None => { None }
1195+
}
11931196
val extractor_id = (json \ "extractor_id").as[String]
11941197
val status = (json \ "status").as[String]
11951198
val startDate = (json \ "start").asOpt[String].map(x =>

app/services/mongodb/MongoDBExtractionService.scala

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class MongoDBExtractionService extends ExtractionService {
8585
var groupings = Map[String, ExtractionGroup]()
8686

8787
for (e <- extraction_list) {
88-
88+
var job_id = e.job_id.getOrElse(UUID(""))
8989
// Update timestamp and groupings
9090
if (groupings.contains(e.extractor_id)) {
9191
// Update entry in the Map
@@ -95,14 +95,11 @@ class MongoDBExtractionService extends ExtractionService {
9595
var grp_endmsg = groupings(e.extractor_id).latestMsg
9696

9797
// For each job_id, keep track of all extraction events for that job
98-
var grp_map = groupings(e.extractor_id).allMsgs
99-
if(grp_map.contains(e.job_id)) {
100-
val existing: List[Extraction] = grp_map(e.job_id)
101-
val updated = List(e) ++ existing
102-
// Re-sort list by timestamp (newest first)
103-
grp_map = grp_map + (e.job_id -> updated)
98+
val init_grp_map = groupings(e.extractor_id).allMsgs
99+
val grp_map = if(init_grp_map.contains(job_id)) {
100+
init_grp_map + (job_id -> (List(e) ++ init_grp_map(job_id)))
104101
} else {
105-
grp_map = grp_map + (e.job_id -> List(e))
102+
init_grp_map + (job_id -> List(e))
106103
}
107104

108105
// Use start time for time groupings as backup because end is frequently empty
@@ -140,7 +137,7 @@ class MongoDBExtractionService extends ExtractionService {
140137
case Some(e) => e.toString
141138
case None => start
142139
}
143-
groupings = groupings + (e.extractor_id -> ExtractionGroup(start, end, e.status, Map(e.job_id -> List(e))))
140+
groupings = groupings + (e.extractor_id -> ExtractionGroup(start, end, e.status, Map(job_id -> List(e))))
144141
}
145142

146143
}

app/views/extractions/extractionsList.scala.html

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@(extractions: Map[String, ExtractionGroup], extractType: String)
2+
<link rel="stylesheet" href="@routes.Assets.at("stylesheets/extractions.css")">
23
<div class="well">
34
@if(extractions.size == 0) {
45
<p>No extraction events recorded.</p>
@@ -36,7 +37,7 @@
3637
@for((job_id, eventList) <- group.allMsgs.toSeq.sortWith(_._1.stringify > _._1.stringify)) {
3738
<tr class="job-list-accordion-toggle clickable collapsed" data-toggle="collapse" data-target="#extraction-job-@job_id">
3839
<td width="35%" title="@job_id"><a class="btn btn-link">@eventList.head.start</a></td>
39-
<td width="60%" class="accordion-status" style="vertical-align:middle;">@eventList.head.status</td>
40+
<td width="60%" class="accordion-status" style="vertical-align:middle;">@eventList.head.status.replace("StatusMessage.start", "START").replace("StatusMessage.processing", "PROCESS").replace("StatusMessage.error", "ERROR")</td>
4041
</tr>
4142
<tr class="collapse" id="extraction-job-@job_id">
4243
<td colspan="3" class="extractor-log">
@@ -52,7 +53,7 @@
5253
<td width="60%">
5354
@evt.status.replace("StatusMessage.start", "START").replace("StatusMessage.processing", "PROCESS").replace("StatusMessage.error", "ERROR")
5455
@if(evt.status == "SUBMITTED") {
55-
<a class="btn btn-link" id='@(evt.id)' onclick="cancelSubmission('@(evt.file_id)', '@(evt.id)', '@(evt.extractor_id)', '@(extractType)')">(Cancel submission)</a>
56+
<a class="btn btn-link btn-xs" id='@(evt.id)' onclick="cancelSubmission('@(evt.file_id)', '@(evt.id)', '@(evt.extractor_id)', '@(extractType)')">(Cancel submission)</a>
5657
}
5758
</td>
5859
</tr>
@@ -100,32 +101,3 @@
100101
});
101102
}
102103
</script>
103-
<style>
104-
.clickable {
105-
cursor: pointer;
106-
}
107-
.job-list-accordion-toggle:before, .extractor-accordion-toggle:before {
108-
/* symbol for "opening" panels */
109-
font-family: 'Glyphicons Halflings'; /* essential for enabling glyphicon */
110-
content: "\e114"; /* adjust as needed, taken from bootstrap.css */
111-
float: right; /* adjust as needed */
112-
color: grey; /* adjust as needed */
113-
}
114-
.job-list-accordion-toggle.collapsed:before, .extractor-accordion-toggle.collapsed:before {
115-
/* symbol for "collapsed" panels */
116-
content: "\e080"; /* adjust as needed, taken from bootstrap.css */
117-
}
118-
.job-list-accordion-toggle:before {
119-
padding: 14px 12px;
120-
}
121-
.extractor-accordion-toggle:before {
122-
padding: 16px 12px;
123-
}
124-
.job-list-accordion-status {
125-
padding: 12px 8px !important;
126-
}
127-
.extractor-log {
128-
padding: 10px 0px 10px 50px !important;
129-
border-top: none !important;
130-
}
131-
</style>

public/stylesheets/extractions.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.clickable {
2+
cursor: pointer;
3+
}
4+
5+
.job-list-accordion-toggle:before, .extractor-accordion-toggle:before {
6+
/* symbol for "opening" panels */
7+
font-family: 'Glyphicons Halflings'; /* essential for enabling glyphicon */
8+
content: "\e114"; /* adjust as needed, taken from bootstrap.css */
9+
float: right; /* adjust as needed */
10+
color: grey; /* adjust as needed */
11+
}
12+
13+
.job-list-accordion-toggle.collapsed:before, .extractor-accordion-toggle.collapsed:before {
14+
/* symbol for "collapsed" panels */
15+
content: "\e080"; /* adjust as needed, taken from bootstrap.css */
16+
}
17+
18+
.job-list-accordion-toggle:before {
19+
padding: 14px 12px;
20+
}
21+
22+
.extractor-accordion-toggle:before {
23+
padding: 16px 12px;
24+
}
25+
26+
.job-list-accordion-status {
27+
padding: 12px 8px !important;
28+
}
29+
30+
.extractor-log {
31+
padding: 10px 0px 10px 50px !important;
32+
border-top: none !important;
33+
}

0 commit comments

Comments
 (0)