Skip to content

Commit a58d576

Browse files
tcnichollmarini
andauthored
editor can now successfully delete tags (#144)
* editor can now successfully delete tags * changelog * Removed unused method parameters when removing tags. Also fixed removing tags for sections so that space editors can remove those as well. Co-authored-by: Luigi Marini <[email protected]> Co-authored-by: Luigi Marini <[email protected]>
1 parent 61ab297 commit a58d576

File tree

9 files changed

+19
-22
lines changed

9 files changed

+19
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515

1616
### Fixed
1717
- GeospatialViewer preview tab should no longer show if it does not contain any rendered data.
18+
- Editor can now delete tags on files, datasets and sections.
1819
- An extractor with file matching set to `*/*` (all file types) would mistakenly send out dataset events.
1920

2021
## 1.12.2 - 2020-11-19

app/api/Datasets.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,18 +1395,16 @@ class Datasets @Inject()(
13951395

13961396
val error_str = tagCheck.error_str
13971397
val not_found = tagCheck.not_found
1398-
val userOpt = tagCheck.userOpt
1399-
val extractorOpt = tagCheck.extractorOpt
14001398
val tags = tagCheck.tags
14011399

14021400
// Now the real work: removing the tags.
14031401
if ("" == error_str) {
14041402
// Clean up leading, trailing and multiple contiguous white spaces.
14051403
val tagsCleaned = tags.get.map(_.trim().replaceAll("\\s+", " "))
14061404
(obj_type) match {
1407-
case TagCheck_File => files.removeTags(id, userOpt, extractorOpt, tagsCleaned)
1405+
case TagCheck_File => files.removeTags(id, tagsCleaned)
14081406
case TagCheck_Dataset => {
1409-
datasets.removeTags(id, userOpt, extractorOpt, tagsCleaned)
1407+
datasets.removeTags(id, tagsCleaned)
14101408
datasets.get(id) match {
14111409
case Some(dataset) => {
14121410
events.addObjectEvent(request.user, id, dataset.name, EventType.REMOVE_TAGS_DATASET.toString)
@@ -1416,7 +1414,7 @@ class Datasets @Inject()(
14161414

14171415
}
14181416

1419-
case TagCheck_Section => sections.removeTags(id, userOpt, extractorOpt, tagsCleaned)
1417+
case TagCheck_Section => sections.removeTags(id, tagsCleaned)
14201418
}
14211419
Ok(Json.obj("status" -> "success"))
14221420
} else {

app/services/DatasetService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ trait DatasetService {
253253
/** Queue a dataset to be indexed in Elasticsearch. */
254254
def index(id: UUID, idx: Option[String] = None)
255255

256-
def removeTags(id: UUID, userIdStr: Option[String], eid: Option[String], tags: List[String])
256+
def removeTags(id: UUID, tags: List[String])
257257

258258
def removeTag(id: UUID, tagId: UUID)
259259

app/services/FileService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ trait FileService {
153153

154154
def isInDataset(file: File, dataset: Dataset): Boolean
155155

156-
def removeTags(id: UUID, userIdStr: Option[String], eid: Option[String], tags: List[String])
156+
def removeTags(id: UUID, tags: List[String])
157157

158158
def addMetadata(fileId: UUID, metadata: JsValue)
159159

app/services/SectionService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ trait SectionService {
1818

1919
def addTags(id: UUID, userIdStr: Option[String], eid: Option[String], tags: List[String]) : List[Tag]
2020

21-
def removeTags(id: UUID, userIdStr: Option[String], eid: Option[String], tags: List[String])
21+
def removeTags(id: UUID, tags: List[String])
2222

2323
def findByFileId(fileId: UUID): List[Section]
2424

app/services/mongodb/MongoDBDatasetService.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,10 +1072,10 @@ class MongoDBDatasetService @Inject() (
10721072
val result = Dataset.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), $pull("tags" -> MongoDBObject("_id" -> new ObjectId(tagId.stringify))), false, false, WriteConcern.Safe)
10731073
}
10741074

1075-
def removeTags(id: UUID, userIdStr: Option[String], eid: Option[String], tags: List[String]) {
1076-
Logger.debug("Removing tags in dataset " + id + " : " + tags + ", userId: " + userIdStr + ", eid: " + eid)
1075+
def removeTags(id: UUID, tags: List[String]) {
1076+
Logger.debug("Removing tags in dataset " + id + " : " + tags )
10771077
val dataset = get(id).get
1078-
val existingTags = dataset.tags.filter(x => userIdStr == x.userId && eid == x.extractor_id).map(_.name)
1078+
val existingTags = dataset.tags.map(_.name)
10791079
Logger.debug("existingTags before user and extractor filtering: " + existingTags.toString)
10801080
// Only remove existing tags.
10811081
tags.intersect(existingTags).map {

app/services/mongodb/MongoDBFileService.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,10 @@ class MongoDBFileService @Inject() (
519519
}
520520
}
521521

522-
def removeTags(id: UUID, userIdStr: Option[String], eid: Option[String], tags: List[String]) {
523-
Logger.debug("Removing tags in file " + id + " : " + tags + ", userId: " + userIdStr + ", eid: " + eid)
522+
def removeTags(id: UUID, tags: List[String]) {
523+
Logger.debug("Removing tags in file " + id + " : " + tags)
524524
val file = get(id).get
525-
val existingTags = file.tags.filter(x => userIdStr == x.userId && eid == x.extractor_id).map(_.name)
525+
val existingTags = file.tags.map(_.name)
526526
Logger.debug("existingTags after user and extractor filtering: " + existingTags.toString)
527527
// Only remove existing tags.
528528
tags.intersect(existingTags).map {

app/services/mongodb/MongoDBSectionService.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ class MongoDBSectionService @Inject() (comments: CommentService, previews: Previ
5252
tagsAdded.toList
5353
}
5454

55-
def removeTags(id: UUID, userIdStr: Option[String], eid: Option[String], tags: List[String]) {
56-
Logger.debug("Removing tags in section " + id + " : " + tags + ", userId: " + userIdStr + ", eid: " + eid)
55+
def removeTags(id: UUID, tags: List[String]) {
56+
Logger.debug("Removing tags in section " + id + " : " + tags)
5757
val section = SectionDAO.findOneById(new ObjectId(id.stringify)).get
58-
val existingTags = section.tags.filter(x => userIdStr == x.userId && eid == x.extractor_id).map(_.id.toString())
58+
val existingTags = section.tags.map(_.id.toString())
5959
Logger.debug("existingTags after user and extractor filtering: " + existingTags.toString)
6060
// Only remove existing tags.
6161
tags.intersect(existingTags).map { tag =>

app/services/mongodb/MongoDBTagService.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,16 @@ class MongoDBTagService @Inject()(files: FileService, datasets: DatasetService,
149149

150150
val error_str = tagCheck.error_str
151151
val not_found = tagCheck.not_found
152-
val userOpt = tagCheck.userOpt
153-
val extractorOpt = tagCheck.extractorOpt
154152
val tags = tagCheck.tags
155153

156154
// Now the real work: removing the tags.
157155
if ("" == error_str) {
158156
// Clean up leading, trailing and multiple contiguous white spaces.
159157
val tagsCleaned = tags.get.map(_.trim().replaceAll("\\s+", " "))
160158
(obj_type) match {
161-
case TagCheck_File => files.removeTags(id, userOpt, extractorOpt, tagsCleaned)
162-
case TagCheck_Dataset => datasets.removeTags(id, userOpt, extractorOpt, tagsCleaned)
163-
case TagCheck_Section => sections.removeTags(id, userOpt, extractorOpt, tagsCleaned)
159+
case TagCheck_File => files.removeTags(id, tagsCleaned)
160+
case TagCheck_Dataset => datasets.removeTags(id, tagsCleaned)
161+
case TagCheck_Section => sections.removeTags(id, tagsCleaned)
164162
}
165163
}
166164
(not_found, error_str)

0 commit comments

Comments
 (0)