• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IQSS / dataverse / #22987

23 Aug 2024 06:44PM UTC coverage: 20.61% (-0.2%) from 20.791%
#22987

Pull #10781

github

landreev
added an upfront locks check to the /addGlobusFiles api #10623
Pull Request #10781: Improved handling of Globus uploads

4 of 417 new or added lines in 15 files covered. (0.96%)

4194 existing lines in 35 files now uncovered.

17388 of 84365 relevant lines covered (20.61%)

0.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

20.15
/src/main/java/edu/harvard/iq/dataverse/search/SolrSearchResult.java
1
package edu.harvard.iq.dataverse.search;
2

3
import static edu.harvard.iq.dataverse.util.json.NullSafeJsonBuilder.jsonObjectBuilder;
4

5
import java.util.ArrayList;
6
import java.util.Date;
7
import java.util.HashMap;
8
import java.util.List;
9
import java.util.Map;
10
import java.util.function.Predicate;
11
import java.util.logging.Logger;
12

13
import edu.harvard.iq.dataverse.*;
14
import jakarta.json.Json;
15
import jakarta.json.JsonArrayBuilder;
16
import jakarta.json.JsonObject;
17
import jakarta.json.JsonObjectBuilder;
18

19
import org.apache.commons.collections4.CollectionUtils;
20

21
import edu.harvard.iq.dataverse.api.Util;
22
import edu.harvard.iq.dataverse.dataset.DatasetThumbnail;
23
import edu.harvard.iq.dataverse.settings.JvmSettings;
24
import edu.harvard.iq.dataverse.util.DateUtil;
25
import edu.harvard.iq.dataverse.util.json.JsonPrinter;
26
import edu.harvard.iq.dataverse.util.json.NullSafeJsonBuilder;
27

28
public class SolrSearchResult {
29
        private static final Logger logger = Logger.getLogger(SolrSearchResult.class.getCanonicalName());
1✔
30

31
        private String id;
32
        private Long entityId;
33
        private DvObject entity;
34
        private String identifier;
35
        private String type;
36
        private String htmlUrl;
37
        private String persistentUrl;
38
        private String downloadUrl;
39
        private String apiUrl;
40
        /**
41
         * This is called "imageUrl" because it used to really be a URL. While performance improvements were being made in the 4.2 timeframe, we started
42
         * putting base64 representations of images in this String instead, which broke the Search API and probably things built on top of it such as MyData.
43
         * See "`image_url` from Search API results no longer yields a downloadable image" at https://github.com/IQSS/dataverse/issues/3616
44
         */
45
        private String imageUrl;
46
        private DatasetThumbnail datasetThumbnail;
47
        private String query;
48
        private String name;
49
        private String nameSort;
50
        private String status;
51
        private Date releaseOrCreateDate;
52
        private String dateToDisplayOnCard;
53
        private List<String> publicationStatuses = new ArrayList<>();
1✔
54

55
        /**
56
         * @todo: how important is it to differentiate between name and title?
57
         */
58
        private String title;
59
        private String descriptionNoSnippet;
60
        private List<String> datasetAuthors = new ArrayList<>();
1✔
61
        private String deaccessionReason;
62
        private List<Highlight> highlightsAsList = new ArrayList<>();
1✔
63
        private Map<SolrField, Highlight> highlightsMap;
64
        private Map<String, Highlight> highlightsAsMap;
65

66
        // parent can be dataverse or dataset, store the name and id
67
        /**
68
         * The "identifier" of a file's parent (a dataset) is a globalId (often a doi).
69
         */
70
        public static String PARENT_IDENTIFIER = "identifier";
1✔
71
        private Map<String, String> parent;
72
        private String dataverseAffiliation;
73
        private String citation;
74
        private String citationHtml;
75
        /**
76
         * Files and datasets might have a UNF. Dataverses don't.
77
         */
78
        private String unf;
79
        private String filetype;
80
        private String fileContentType;
81
        private Long fileSizeInBytes;
82
        /**
83
         * fileMD5 is here for legacy and backward-compatibility reasons. It might be deprecated some day in favor of "fileChecksumType" and
84
         * "fileChecksumValue"
85
         */
86
        private String fileMd5;
87
        private DataFile.ChecksumType fileChecksumType;
88
        private String fileChecksumValue;
89
        private String dataverseAlias;
90
        private String dataverseParentAlias;
91
//    private boolean statePublished;
92
        /**
93
         * @todo Investigate/remove this "unpublishedState" variable. For files that have been published along with a dataset it says "true", which makes no
94
         *       sense.
95
         */
96
        private boolean publishedState = false;
1✔
97
        private boolean unpublishedState = false;
1✔
98
        private boolean draftState = false;
1✔
99
        private boolean inReviewState = false;
1✔
100
        private boolean deaccessionedState = false;
1✔
101
        private long datasetVersionId;
102
        private String versionNumberFriendly;
103
        // Determine if the search result is owned by any of the dvs in the tree of the DV displayed
104
        private boolean isInTree;
105
        private float score;
106
        private List<String> userRole;
107
        private boolean harvested = false;
1✔
108
        private String dvTree;
109
        private String harvestingDescription = null;
1✔
110
        private List<String> fileCategories = null;
1✔
111
        private List<String> tabularDataTags = null;
1✔
112

113
        private String identifierOfDataverse = null;
1✔
114
        private String nameOfDataverse = null;
1✔
115

116
        private String filePersistentId = null;
1✔
117

118
        private Long embargoEndDate;
119

120
        private Long retentionEndDate;
121

122
        private boolean datasetValid;
123

124
        public String getDvTree() {
125
                return dvTree;
×
126
        }
127

128
        public void setDvTree(String dvTree) {
129
                this.dvTree = dvTree;
×
130
        }
×
131

132
        public boolean isIsInTree() {
133
                return isInTree;
×
134
        }
135

136
        public void setIsInTree(boolean isInTree) {
137
                this.isInTree = isInTree;
×
138
        }
×
139

140
        public boolean isHarvested() {
141
                return harvested;
×
142
        }
143

144
        public void setHarvested(boolean harvested) {
145
                this.harvested = harvested;
×
146
        }
×
147

148
        public String getHarvestingDescription() {
149
                // if (this.isHarvested()) {
150
                return harvestingDescription;
×
151
                // }
152
                // return null;
153
        }
154

155
        public void setHarvestingDescription(String harvestingDescription) {
156
                this.harvestingDescription = harvestingDescription;
×
157
        }
×
158
//    public boolean isStatePublished() {
159
//        return statePublished;
160
//    }
161
//    public void setStatePublished(boolean statePublished) {
162
//        this.statePublished = statePublished;
163
//    }
164

165
        public boolean isPublishedState() {
166
                return publishedState;
1✔
167
        }
168

169
        public void setPublishedState(boolean publishedState) {
170
                this.publishedState = publishedState;
1✔
171
        }
1✔
172

173
        public boolean isUnpublishedState() {
174
                return unpublishedState;
1✔
175
        }
176

177
        public void setUnpublishedState(boolean unpublishedState) {
178
                this.unpublishedState = unpublishedState;
1✔
179
        }
1✔
180

181
        public void setPublicationStatuses(List<String> statuses) {
182

183
                if (statuses == null) {
1✔
184
                        this.publicationStatuses = new ArrayList<>();
1✔
185
                        return;
1✔
186
                }
187
                this.publicationStatuses = statuses;
1✔
188

189
                // set booleans for individual statuses
190
                //
191
                for (String status : this.publicationStatuses) {
1✔
192

193
                        if (status.equals(IndexServiceBean.getUNPUBLISHED_STRING())) {
1✔
194
                                this.setUnpublishedState(true);
1✔
195

196
                        } else if (status.equals(IndexServiceBean.getPUBLISHED_STRING())) {
1✔
197
                                this.setPublishedState(true);
1✔
198

199
                        } else if (status.equals(IndexServiceBean.getDRAFT_STRING())) {
1✔
200
                                this.setDraftState(true);
1✔
201

202
                        } else if (status.equals(IndexServiceBean.getIN_REVIEW_STRING())) {
1✔
203
                                this.setInReviewState(true);
1✔
204

205
                        } else if (status.equals(IndexServiceBean.getDEACCESSIONED_STRING())) {
1✔
206
                                this.setDeaccessionedState(true);
1✔
207
                        }
208
                }
1✔
209
        } // setPublicationStatuses
1✔
210

211
        /**
212
         * Never return null, return an empty list instead
213
         *
214
         * @return
215
         */
216
        public List<String> getPublicationStatuses() {
217

218
                if (this.publicationStatuses == null) {
1✔
219
                        this.publicationStatuses = new ArrayList<>();
×
220
                }
221
                return this.publicationStatuses;
1✔
222
        }
223

224
        public JsonArrayBuilder getPublicationStatusesAsJSON() {
225

UNCOV
226
                JsonArrayBuilder statuses = Json.createArrayBuilder();
×
UNCOV
227
                for (String status : this.getPublicationStatuses()) {
×
UNCOV
228
                        statuses.add(status);
×
UNCOV
229
                }
×
UNCOV
230
                return statuses;
×
231
        }
232

233
        public boolean isDraftState() {
234
                return draftState;
1✔
235
        }
236

237
        public void setDraftState(boolean draftState) {
238
                this.draftState = draftState;
1✔
239
        }
1✔
240

241
        public boolean isInReviewState() {
242
                return inReviewState;
1✔
243
        }
244

245
        public void setInReviewState(boolean inReviewState) {
246
                this.inReviewState = inReviewState;
1✔
247
        }
1✔
248

249
        public boolean isDeaccessionedState() {
250
                return deaccessionedState;
1✔
251
        }
252

253
        public void setDeaccessionedState(boolean deaccessionedState) {
254
                this.deaccessionedState = deaccessionedState;
1✔
255
        }
1✔
256

257
        /**
258
         * @todo: used? remove
259
         */
260
        private List<String> matchedFields;
261

262
        // External Status Label (enabled via AllowedCurationLabels setting)
263
        private String externalStatus;
264

265
        /**
266
         * @todo: remove name?
267
         */
268
        SolrSearchResult(String queryFromUser, String name) {
1✔
269
                this.query = queryFromUser;
1✔
270
//        this.name = name;
271
        }
1✔
272

273
        public Map<String, Highlight> getHighlightsAsMap() {
274
                return highlightsAsMap;
×
275
        }
276

277
        public void setHighlightsAsMap(Map<String, Highlight> highlightsAsMap) {
278
                this.highlightsAsMap = highlightsAsMap;
×
279
        }
×
280

281
        public String getNameHighlightSnippet() {
282
                Highlight highlight = highlightsAsMap.get(SearchFields.NAME);
×
283
                if (highlight != null) {
×
284
                        String firstSnippet = highlight.getSnippets().get(0);
×
285
                        if (firstSnippet != null) {
×
286
                                return firstSnippet;
×
287
                        }
288
                }
289
                return null;
×
290
        }
291

292
        public String getDataverseAffiliationHighlightSnippet() {
293
                Highlight highlight = highlightsAsMap.get(SearchFields.AFFILIATION);
×
294
                if (highlight != null) {
×
295
                        String firstSnippet = highlight.getSnippets().get(0);
×
296
                        if (firstSnippet != null) {
×
297
                                return firstSnippet;
×
298
                        }
299
                }
300
                return null;
×
301
        }
302

303
        public String getFileTypeHighlightSnippet() {
304
                Highlight highlight = highlightsAsMap.get(SearchFields.FILE_TYPE_FRIENDLY);
×
305
                if (highlight != null) {
×
306
                        String firstSnippet = highlight.getSnippets().get(0);
×
307
                        if (firstSnippet != null) {
×
308
                                return firstSnippet;
×
309
                        }
310
                }
311
                return null;
×
312
        }
313

314
        public String getTitleHighlightSnippet() {
315
                /**
316
                 * @todo: don't hard-code title, look it up properly... or start indexing titles as names: https://redmine.hmdc.harvard.edu/issues/3798#note-2
317
                 */
318
                Highlight highlight = highlightsAsMap.get("title");
×
319
                if (highlight != null) {
×
320
                        String firstSnippet = highlight.getSnippets().get(0);
×
321
                        if (firstSnippet != null) {
×
322
                                return firstSnippet;
×
323
                        }
324
                }
325
                return null;
×
326
        }
327

328
        public List<String> getDescriptionSnippets() {
329
                for (Map.Entry<SolrField, Highlight> entry : highlightsMap.entrySet()) {
×
330
                        SolrField solrField = entry.getKey();
×
331
                        Highlight highlight = entry.getValue();
×
332
                        logger.fine("SolrSearchResult class: " + solrField.getNameSearchable() + ":" + highlight.getSnippets());
×
333
                }
×
334

335
                Highlight highlight = highlightsAsMap.get(SearchFields.DESCRIPTION);
×
336
                if (type.equals("datasets")) {
×
337
                        highlight = highlightsAsMap.get(SearchFields.DATASET_DESCRIPTION);
×
338
                }
339
                if (highlight != null) {
×
340
                        return highlight.getSnippets();
×
341
                } else {
342
                        return new ArrayList<>();
×
343
                }
344
        }
345

346
        public Map<SolrField, Highlight> getHighlightsMap() {
347
                return highlightsMap;
×
348
        }
349

350
        public void setHighlightsMap(Map<SolrField, Highlight> highlightsMap) {
351
                this.highlightsMap = highlightsMap;
×
352
        }
×
353

354
        public List<String> getMatchedFields() {
355
                return matchedFields;
×
356
        }
357

358
        public void setMatchedFields(List<String> matchedFields) {
359
                this.matchedFields = matchedFields;
×
360
        }
×
361

362
        @Override
363
        public String toString() {
364
                if (this.name != null) {
×
365
                        return this.id + ":" + this.name + ":" + this.entityId;
×
366
                } else {
367
                        return this.id + ":" + this.title + ":" + this.entityId;
×
368
                }
369
        }
370

371
        public JsonArrayBuilder getRelevance() {
372
                JsonArrayBuilder matchedFieldsArray = Json.createArrayBuilder();
×
373
                JsonObjectBuilder matchedFieldObject = Json.createObjectBuilder();
×
374
                for (Map.Entry<SolrField, Highlight> entry : highlightsMap.entrySet()) {
×
375
                        SolrField solrField = entry.getKey();
×
376
                        Highlight snippets = entry.getValue();
×
377
                        JsonArrayBuilder snippetArrayBuilder = Json.createArrayBuilder();
×
378
                        JsonObjectBuilder matchedFieldDetails = Json.createObjectBuilder();
×
379
                        for (String highlight : snippets.getSnippets()) {
×
380
                                snippetArrayBuilder.add(highlight);
×
381
                        }
×
382
                        /**
383
                         * @todo for the Search API, it might be nice to return offset numbers rather than html snippets surrounded by span tags or whatever.
384
                         *
385
                         *       That's what the GitHub Search API does: "Requests can opt to receive those text fragments in the response, and every fragment is accompanied
386
                         *       by numeric offsets identifying the exact location of each matching search term." https://developer.github.com/v3/search/#text-match-metadata
387
                         *
388
                         *       It's not clear if getting the offset values is possible with Solr, however:
389
                         *       stackoverflow.com/questions/13863118/can-solr-highlighting-also-indicate-the-position-or-offset-of-the-returned-fragments-within-the-original-field
390
                         */
391
                        matchedFieldDetails.add("snippets", snippetArrayBuilder);
×
392
                        /**
393
                         * @todo In addition to the name of the field used by Solr , it would be nice to show the "friendly" name of the field we show in the GUI.
394
                         */
395
//            matchedFieldDetails.add("friendly", "FIXME");
396
                        matchedFieldObject.add(solrField.getNameSearchable(), matchedFieldDetails);
×
397
                        matchedFieldsArray.add(matchedFieldObject);
×
398
                }
×
399
                return matchedFieldsArray;
×
400
        }
401

402
        /**
403
         * Add additional fields for the MyData page
404
         *
405
         * @return
406
         */
407
        public JsonObjectBuilder getJsonForMyData(boolean isValid) {
408

409
                JsonObjectBuilder myDataJson = json(true, true, true);// boolean showRelevance, boolean showEntityIds, boolean showApiUrls)
×
410

411
                myDataJson.add("publication_statuses", this.getPublicationStatusesAsJSON())
×
412
                                .add("is_draft_state", this.isDraftState()).add("is_in_review_state", this.isInReviewState())
×
413
                                .add("is_unpublished_state", this.isUnpublishedState()).add("is_published", this.isPublishedState())
×
414
                                .add("is_deaccesioned", this.isDeaccessionedState())
×
415
                                .add("is_valid", isValid)
×
416
                                .add("date_to_display_on_card", getDateToDisplayOnCard());
×
417

418
                // Add is_deaccessioned attribute, even though MyData currently screens any deaccessioned info out
419
                //
420
                if ((this.isDeaccessionedState()) && (this.getPublicationStatuses().size() == 1)) {
×
421
                        myDataJson.add("deaccesioned_is_only_pubstatus", true);
×
422
                }
423

424
                if ((this.getParent() != null) && (!this.getParent().isEmpty())) {
×
425
                        // System.out.println("keys:" + parent.keySet().toString());
426
                        if (this.entity != null && this.entity.isInstanceofDataFile()) {
×
427
                                myDataJson.add("parentIdentifier", this.getParent().get(SolrSearchResult.PARENT_IDENTIFIER))
×
428
                                                .add("parentName", this.getParent().get("name"));
×
429

430
                        } else {
431
                                // for Dataverse and Dataset, get parent which is a Dataverse
432
                                myDataJson.add("parentId", this.getParent().get("id")).add("parentName", this.getParent().get("name"));
×
433
                        }
434
                }
435

436
                return myDataJson;
×
437
        } // getJsonForMydata
438

439
        public JsonObjectBuilder json(boolean showRelevance, boolean showEntityIds, boolean showApiUrls) {
440
                return json(showRelevance, showEntityIds, showApiUrls, null, null);
1✔
441
        }
442

443
        public JsonObjectBuilder json(boolean showRelevance, boolean showEntityIds, boolean showApiUrls, List<String> metadataFields, Long datasetFileCount) {
444
                if (this.type == null) {
1✔
445
                        return jsonObjectBuilder();
×
446
                }
447

448
                String displayName = null;
1✔
449

450
                String identifierLabel = null;
1✔
451
                String datasetCitation = null;
1✔
452
                String datasetName = null;
1✔
453
                String datasetId = null;
1✔
454
                String datasetPersistentId = null;
1✔
455
                String filePersistentId = null;
1✔
456
                String preferredUrl = null;
1✔
457
                String apiUrl = null;
1✔
458
                String publisherName = null;
1✔
459

460
                if (this.type.equals(SearchConstants.DATAVERSES)) {
1✔
461
                        displayName = this.name;
1✔
462
                        identifierLabel = "identifier";
1✔
463
                        preferredUrl = getHtmlUrl();
1✔
464
                } else if (this.type.equals(SearchConstants.DATASETS)) {
×
465
                        displayName = this.title;
×
466
                        identifierLabel = "global_id";
×
467
                        preferredUrl = getPersistentUrl();
×
468
                        publisherName = this.parent.get("name");
×
469
                        // if
470
                        /**
471
                         * @todo Should we show the name of the parent dataverse?
472
                         */
473
                } else if (this.type.equals(SearchConstants.FILES)) {
×
474
                        displayName = this.name;
×
475
                        identifierLabel = "file_id";
×
476
                        preferredUrl = getDownloadUrl();
×
477
                        /**
478
                         * @todo show more information for a file's parent, such as the title of the dataset it belongs to.
479
                         */
480
                        datasetCitation = parent.get("citation");
×
481
                        datasetName = parent.get("name");
×
482
                        datasetId = parent.get("id");
×
483
                        datasetPersistentId = parent.get(SolrSearchResult.PARENT_IDENTIFIER);
×
484
                }
485

486
                // displayName = null; // testing NullSafeJsonBuilder
487
                // because we are using NullSafeJsonBuilder key/value pairs will be dropped if the value is null
488
                NullSafeJsonBuilder nullSafeJsonBuilder = jsonObjectBuilder().add("name", displayName)
1✔
489
                                .add("type", getDisplayType(getType())).add("url", preferredUrl).add("image_url", getImageUrl())
1✔
490
                                // .add("persistent_url", this.persistentUrl)
491
                                // .add("download_url", this.downloadUrl)
492
                                /**
493
                                 * @todo How much value is there in exposing the identifier for dataverses? For
494
                                 */
495
                                .add(identifierLabel, this.identifier)
1✔
496
                                /**
497
                                 * @todo Get dataset description from dsDescriptionValue. Also, is descriptionNoSnippet the right field to use generally?
498
                                 *
499
                                 * @todo What about the fact that datasets can now have multiple descriptions? Should we create an array called "additional_descriptions" that gets
500
                                 *       populated if there is more than one dataset description?
501
                                 *
502
                                 * @todo Why aren't file descriptions ever null? They always have an empty string at least.
503
                                 */
504
                                .add("description", this.descriptionNoSnippet)
1✔
505
                                /**
506
                                 * @todo In the future we'd like to support non-public datasets per https://github.com/IQSS/dataverse/issues/1299 but for now we are only supporting
507
                                 *       non-public searches.
508
                                 */
509
                                .add("published_at", getDateTimePublished())
1✔
510
                                /**
511
                                 * @todo Expose MIME Type: https://github.com/IQSS/dataverse/issues/1595
512
                                 */
513
                                .add("file_type", this.filetype).add("file_content_type", this.fileContentType)
1✔
514
                                .add("size_in_bytes", getFileSizeInBytes())
1✔
515
                                /**
516
                                 * "md5" was the only possible value so it's hard-coded here but we might want to deprecate it someday since we now put the MD5 or SHA-1 in
517
                                 * "checksum".
518
                                 */
519
                                .add("md5", getFileMd5())
1✔
520
                                .add("checksum", JsonPrinter.getChecksumTypeAndValue(getFileChecksumType(), getFileChecksumValue()))
1✔
521
                                .add("unf", getUnf()).add("file_persistent_id", this.filePersistentId).add("dataset_name", datasetName)
1✔
522
                                .add("dataset_id", datasetId).add("publisher", publisherName)
1✔
523
                                .add("dataset_persistent_id", datasetPersistentId).add("dataset_citation", datasetCitation)
1✔
524
                                .add("deaccession_reason", this.deaccessionReason).add("citationHtml", this.citationHtml)
1✔
525
                                .add("identifier_of_dataverse", this.identifierOfDataverse)
1✔
526
                                .add("name_of_dataverse", this.nameOfDataverse).add("citation", this.citation);
1✔
527
                // Now that nullSafeJsonBuilder has been instatiated, check for null before adding to it!
528
                if (showRelevance) {
1✔
529
                        nullSafeJsonBuilder.add("matches", getRelevance());
×
530
                        nullSafeJsonBuilder.add("score", getScore());
×
531
                }
532
                if (showEntityIds) {
1✔
533
                        if (this.entityId != null) {
×
534
                                nullSafeJsonBuilder.add("entity_id", this.entityId);
×
535
                        }
536
                }
537

538
                if (this.entity == null) {
1✔
539

540
                } else {
UNCOV
541
                        if (this.entity.isInstanceofDataset()) {
×
UNCOV
542
                                nullSafeJsonBuilder.add("storageIdentifier", this.entity.getStorageIdentifier());
×
UNCOV
543
                                Dataset ds = (Dataset) this.entity;
×
544
                                DatasetVersion dv = ds.getVersionFromId(this.datasetVersionId);
×
545

546
                                if (!dv.getKeywords().isEmpty()) {
×
547
                                        JsonArrayBuilder keyWords = Json.createArrayBuilder();
×
UNCOV
548
                                        for (String keyword : dv.getKeywords()) {
×
549
                                                keyWords.add(keyword);
×
550
                                        }
×
551
                                        nullSafeJsonBuilder.add("keywords", keyWords);
×
552
                                }
553

554
                                JsonArrayBuilder subjects = Json.createArrayBuilder();
×
UNCOV
555
                                for (String subject : dv.getDatasetSubjects()) {
×
UNCOV
556
                                        subjects.add(subject);
×
557
                                }
×
558
                                nullSafeJsonBuilder.add("subjects", subjects);
×
559
                                nullSafeJsonBuilder.add("fileCount", datasetFileCount);
×
560
                                nullSafeJsonBuilder.add("versionId", dv.getId());
×
561
                                nullSafeJsonBuilder.add("versionState", dv.getVersionState().toString());
×
562
                                if (this.isPublishedState()) {
×
563
                                        nullSafeJsonBuilder.add("majorVersion", dv.getVersionNumber());
×
564
                                        nullSafeJsonBuilder.add("minorVersion", dv.getMinorVersionNumber());
×
565
                                }
566

567
                                nullSafeJsonBuilder.add("createdAt", ds.getCreateDate());
×
UNCOV
568
                                nullSafeJsonBuilder.add("updatedAt", ds.getModificationTime());
×
569

570
                                if (!dv.getDatasetContacts().isEmpty()) {
×
571
                                        JsonArrayBuilder contacts = Json.createArrayBuilder();
×
UNCOV
572
                                        NullSafeJsonBuilder nullSafeJsonBuilderInner = jsonObjectBuilder();
×
573
                                        for (String contact[] : dv.getDatasetContacts(false)) {
×
574
                                                nullSafeJsonBuilderInner.add("name", contact[0]);
×
575
                                                nullSafeJsonBuilderInner.add("affiliation", contact[1]);
×
576
                                                contacts.add(nullSafeJsonBuilderInner);
×
577
                                        }
×
578
                                        nullSafeJsonBuilder.add("contacts", contacts);
×
579
                                }
580
                                if (!dv.getRelatedPublications().isEmpty()) {
×
581
                                        JsonArrayBuilder relPub = Json.createArrayBuilder();
×
UNCOV
582
                                        NullSafeJsonBuilder inner = jsonObjectBuilder();
×
583
                                        for (DatasetRelPublication dsRelPub : dv.getRelatedPublications()) {
×
584
                                                inner.add("title", dsRelPub.getTitle());
×
585
                                                inner.add("citation", dsRelPub.getText());
×
586
                                                inner.add("url", dsRelPub.getUrl());
×
587
                                                relPub.add(inner);
×
588
                                        }
×
589
                                        nullSafeJsonBuilder.add("publications", relPub);
×
590
                                }
591

592
                                if (!dv.getDatasetProducers().isEmpty()) {
×
UNCOV
593
                                        JsonArrayBuilder producers = Json.createArrayBuilder();
×
UNCOV
594
                                        for (String[] producer : dv.getDatasetProducers()) {
×
595
                                                producers.add(producer[0]);
×
596
                                        }
×
597
                                        nullSafeJsonBuilder.add("producers", producers);
×
598
                                }
599
                                if (!dv.getRelatedMaterial().isEmpty()) {
×
600
                                        JsonArrayBuilder relatedMaterials = Json.createArrayBuilder();
×
UNCOV
601
                                        for (String relatedMaterial : dv.getRelatedMaterial()) {
×
602
                                                relatedMaterials.add(relatedMaterial);
×
603
                                        }
×
604
                                        nullSafeJsonBuilder.add("relatedMaterial", relatedMaterials);
×
605
                                }
606

607
                                if (!dv.getGeographicCoverage().isEmpty()) {
×
UNCOV
608
                                        JsonArrayBuilder geoCov = Json.createArrayBuilder();
×
UNCOV
609
                                        NullSafeJsonBuilder inner = jsonObjectBuilder();
×
610
                                        for (String ind[] : dv.getGeographicCoverage()) {
×
611
                                                inner.add("country", ind[0]);
×
612
                                                inner.add("state", ind[1]);
×
613
                                                inner.add("city", ind[2]);
×
614
                                                inner.add("other", ind[3]);
×
615
                                                geoCov.add(inner);
×
616
                                        }
×
617
                                        nullSafeJsonBuilder.add("geographicCoverage", geoCov);
×
618
                                }
619
                                if (!dv.getDataSource().isEmpty()) {
×
620
                                        JsonArrayBuilder dataSources = Json.createArrayBuilder();
×
UNCOV
621
                                        for (String dsource : dv.getDataSource()) {
×
622
                                                dataSources.add(dsource);
×
623
                                        }
×
624
                                        nullSafeJsonBuilder.add("dataSources", dataSources);
×
625
                                }
626

627
                                if (CollectionUtils.isNotEmpty(metadataFields)) {
×
628
                                        // create metadata fields map names
UNCOV
629
                                        Map<String, List<String>> metadataFieldMapNames = computeRequestedMetadataFieldMapNames(
×
630
                                                        metadataFields);
631

632
                                        // add metadatafields objet to wrap all requeested fields
UNCOV
633
                                        NullSafeJsonBuilder metadataFieldBuilder = jsonObjectBuilder();
×
634

UNCOV
635
                                        Map<MetadataBlock, List<DatasetField>> groupedFields = DatasetField
×
636
                                                        .groupByBlock(dv.getFlatDatasetFields());
×
UNCOV
637
                                        json(metadataFieldMapNames, groupedFields, metadataFieldBuilder);
×
638

639
                                        nullSafeJsonBuilder.add("metadataBlocks", metadataFieldBuilder);
×
640
                                }
641
                        }
642
                }
643

644
                if (showApiUrls) {
1✔
645
                        /**
646
                         * @todo We should probably have a metadata_url or api_url concept enabled by default, not hidden behind an undocumented boolean. For datasets, this
647
                         *       would be http://example.com/api/datasets/10 or whatever (to get more detailed JSON), but right now this requires an API token. Discuss at
648
                         *       https://docs.google.com/document/d/1d8sT2GLSavgiAuMTVX8KzTCX0lROEET1edhvHHRDZOs/edit?usp=sharing";
649
                         */
UNCOV
650
                        if (getApiUrl() != null) {
×
UNCOV
651
                                nullSafeJsonBuilder.add("api_url", getApiUrl());
×
652
                        }
653
                }
654
                // NullSafeJsonBuilder is awesome but can't build null safe arrays. :(
655
                if (!datasetAuthors.isEmpty()) {
1✔
UNCOV
656
                        JsonArrayBuilder authors = Json.createArrayBuilder();
×
UNCOV
657
                        for (String datasetAuthor : datasetAuthors) {
×
UNCOV
658
                                authors.add(datasetAuthor);
×
659
                        }
×
660
                        nullSafeJsonBuilder.add("authors", authors);
×
661
                }
662
                return nullSafeJsonBuilder;
1✔
663
        }
664

665
        private void json(Map<String, List<String>> metadataFieldMapNames,
666
                        Map<MetadataBlock, List<DatasetField>> groupedFields, NullSafeJsonBuilder metadataFieldBuilder) {
UNCOV
667
                for (Map.Entry<String, List<String>> metadataFieldNamesEntry : metadataFieldMapNames.entrySet()) {
×
UNCOV
668
                        String metadataBlockName = metadataFieldNamesEntry.getKey();
×
UNCOV
669
                        List<String> metadataBlockFieldNames = metadataFieldNamesEntry.getValue();
×
670
                        for (MetadataBlock metadataBlock : groupedFields.keySet()) {
×
671
                                if (metadataBlockName.equals(metadataBlock.getName())) {
×
672
                                        // create metadataBlock object
673
                                        NullSafeJsonBuilder metadataBlockBuilder = jsonObjectBuilder();
×
674
                                        metadataBlockBuilder.add("displayName", metadataBlock.getDisplayName());
×
UNCOV
675
                                        JsonArrayBuilder fieldsArray = Json.createArrayBuilder();
×
676

677
                                        List<DatasetField> datasetFields = groupedFields.get(metadataBlock);
×
678
                                        for (DatasetField datasetField : datasetFields) {
×
UNCOV
679
                                                if (metadataBlockFieldNames.contains("*")
×
680
                                                                || metadataBlockFieldNames.contains(datasetField.getDatasetFieldType().getName())) {
×
681
                                                        if (datasetField.getDatasetFieldType().isCompound() || !datasetField.getDatasetFieldType().isHasParent()) {
×
682
                                                                JsonObject item = JsonPrinter.json(datasetField);
×
683
                                                                if (item != null) {
×
684
                                                                        fieldsArray.add(item);
×
685
                                                                }
686
                                                        }
687
                                                }
UNCOV
688
                                        }
×
689
                                        // with a fields to hold all requested properties
UNCOV
690
                                        metadataBlockBuilder.add("fields", fieldsArray);
×
691

UNCOV
692
                                        metadataFieldBuilder.add(metadataBlock.getName(), metadataBlockBuilder);
×
693
                                }
UNCOV
694
                        }
×
695
                }
×
UNCOV
696
        }
×
697

698
        private Map<String, List<String>> computeRequestedMetadataFieldMapNames(List<String> metadataFields) {
699
                Map<String, List<String>> metadataFieldMapNames = new HashMap<>();
×
UNCOV
700
                for (String metadataField : metadataFields) {
×
UNCOV
701
                        String parts[] = metadataField.split(":");
×
702
                        if (parts.length == 2) {
×
703
                                List<String> metadataFieldNames = metadataFieldMapNames.get(parts[0]);
×
704
                                if (metadataFieldNames == null) {
×
705
                                        metadataFieldNames = new ArrayList<>();
×
706
                                        metadataFieldMapNames.put(parts[0], metadataFieldNames);
×
707
                                }
708
                                metadataFieldNames.add(parts[1]);
×
709
                        }
UNCOV
710
                }
×
711
                return metadataFieldMapNames;
×
712
        }
713

714
        private String getDateTimePublished() {
715
                String datePublished = null;
1✔
716
                if (draftState == false) {
1✔
717
                        datePublished = releaseOrCreateDate == null ? null : Util.getDateTimeFormat().format(releaseOrCreateDate);
1✔
718
                }
719
                return datePublished;
1✔
720
        }
721

722
        public String getId() {
UNCOV
723
                return id;
×
724
        }
725

726
        public void setId(String id) {
UNCOV
727
                this.id = id;
×
UNCOV
728
        }
×
729

730
        public Long getEntityId() {
731
                return entityId;
×
732
        }
733

734
        public void setEntityId(Long entityId) {
UNCOV
735
                this.entityId = entityId;
×
UNCOV
736
        }
×
737

738
        public DvObject getEntity() {
739
                return entity;
×
740
        }
741

742
        public void setEntity(DvObject entity) {
UNCOV
743
                this.entity = entity;
×
UNCOV
744
        }
×
745

746
        public String getIdentifier() {
747
                return identifier;
×
748
        }
749

750
        public void setIdentifier(String identifier) {
UNCOV
751
                this.identifier = identifier;
×
UNCOV
752
        }
×
753

754
        public String getType() {
755
                return type;
1✔
756
        }
757

758
        public void setType(String type) {
759
                this.type = type;
1✔
760
        }
1✔
761

762
        public String getHtmlUrl() {
763
                return htmlUrl;
1✔
764
        }
765

766
        public void setHtmlUrl(String htmlUrl) {
UNCOV
767
                this.htmlUrl = htmlUrl;
×
UNCOV
768
        }
×
769

770
        public String getPersistentUrl() {
771
                return persistentUrl;
×
772
        }
773

774
        public void setPersistentUrl(String persistentUrl) {
UNCOV
775
                this.persistentUrl = persistentUrl;
×
UNCOV
776
        }
×
777

778
        public String getDownloadUrl() {
779
                return downloadUrl;
×
780
        }
781

782
        public void setDownloadUrl(String downloadUrl) {
UNCOV
783
                this.downloadUrl = downloadUrl;
×
UNCOV
784
        }
×
785

786
        public String getApiUrl() {
787
                return apiUrl;
×
788
        }
789

790
        public void setApiUrl(String apiUrl) {
UNCOV
791
                this.apiUrl = apiUrl;
×
UNCOV
792
        }
×
793

794
        public String getImageUrl() {
795
                return imageUrl;
1✔
796
        }
797

798
        public void setImageUrl(String imageUrl) {
UNCOV
799
                this.imageUrl = imageUrl;
×
UNCOV
800
        }
×
801

802
        public DatasetThumbnail getDatasetThumbnail() {
803
                return datasetThumbnail;
×
804
        }
805

806
        public void setDatasetThumbnail(DatasetThumbnail datasetThumbnail) {
UNCOV
807
                this.datasetThumbnail = datasetThumbnail;
×
UNCOV
808
        }
×
809

810
        public String getQuery() {
811
                return query;
×
812
        }
813

814
        public void setQuery(String query) {
UNCOV
815
                this.query = query;
×
UNCOV
816
        }
×
817

818
        public String getName() {
819
                return name;
×
820
        }
821

822
        public void setName(String name) {
UNCOV
823
                this.name = name;
×
UNCOV
824
        }
×
825

826
        public String getTitle() {
827
                return title;
×
828
        }
829

830
        public void setTitle(String title) {
UNCOV
831
                this.title = title;
×
UNCOV
832
        }
×
833

834
        public String getDescriptionNoSnippet() {
835
                return descriptionNoSnippet;
×
836
        }
837

838
        public void setDescriptionNoSnippet(String descriptionNoSnippet) {
UNCOV
839
                this.descriptionNoSnippet = descriptionNoSnippet;
×
UNCOV
840
        }
×
841

842
        public List<String> getDatasetAuthors() {
843
                return datasetAuthors;
×
844
        }
845

846
        public void setDatasetAuthors(List<String> datasetAuthors) {
UNCOV
847
                this.datasetAuthors = datasetAuthors;
×
UNCOV
848
        }
×
849

850
        public String getDeaccessionReason() {
851
                return deaccessionReason;
×
852
        }
853

854
        public void setDeaccessionReason(String deaccessionReason) {
UNCOV
855
                this.deaccessionReason = deaccessionReason;
×
UNCOV
856
        }
×
857

858
        public List<Highlight> getHighlightsAsListOrig() {
859
                return highlightsAsList;
×
860
        }
861

862
        public List<Highlight> getHighlightsAsList() {
UNCOV
863
                List<Highlight> filtered = new ArrayList<>();
×
UNCOV
864
                for (Highlight highlight : highlightsAsList) {
×
UNCOV
865
                        String field = highlight.getSolrField().getNameSearchable();
×
866
                        /**
867
                         * @todo don't hard code "title" here. And should we collapse name and title together anyway?
868
                         */
UNCOV
869
                        if (!field.equals(SearchFields.NAME) && !field.equals(SearchFields.DESCRIPTION)
×
UNCOV
870
                                        && !field.equals(SearchFields.DATASET_DESCRIPTION) && !field.equals(SearchFields.AFFILIATION)
×
UNCOV
871
                                        && !field.equals("title")) {
×
872
                                filtered.add(highlight);
×
873
                        }
874
                }
×
875
                return filtered;
×
876
        }
877

878
        public void setHighlightsAsList(List<Highlight> highlightsAsList) {
UNCOV
879
                this.highlightsAsList = highlightsAsList;
×
UNCOV
880
        }
×
881

882
        public List<String> getFileCategories() {
883
                return fileCategories;
×
884
        }
885

886
        public void setFileCategories(List<String> fileCategories) {
UNCOV
887
                this.fileCategories = fileCategories;
×
UNCOV
888
        }
×
889

890
        public List<String> getTabularDataTags() {
891
                return tabularDataTags;
×
892
        }
893

894
        public void setTabularDataTags(List<String> tabularDataTags) {
UNCOV
895
                this.tabularDataTags = tabularDataTags;
×
UNCOV
896
        }
×
897

898
        public Map<String, String> getParent() {
899
                return parent;
×
900
        }
901

902
        public Long getParentIdAsLong() {
903

UNCOV
904
                if (this.getParent() == null) {
×
UNCOV
905
                        return null;
×
906
                }
907
                if (!this.getParent().containsKey("id")) {
×
908
                        return null;
×
909
                }
910

911
                String parentIdString = getParent().get("id");
×
UNCOV
912
                if (parentIdString == null) {
×
UNCOV
913
                        return null;
×
914
                }
915

916
                try {
UNCOV
917
                        return Long.parseLong(parentIdString);
×
UNCOV
918
                } catch (NumberFormatException ex) {
×
UNCOV
919
                        return null;
×
920
                }
921
        }
922

923
        public void setParent(Map<String, String> parent) {
UNCOV
924
                this.parent = parent;
×
UNCOV
925
        }
×
926

927
        public String getDataverseAffiliation() {
928
                return dataverseAffiliation;
×
929
        }
930

931
        public void setDataverseAffiliation(String dataverseAffiliation) {
UNCOV
932
                this.dataverseAffiliation = dataverseAffiliation;
×
UNCOV
933
        }
×
934

935
        public String getCitation() {
936
                return citation;
×
937
        }
938

939
        public void setCitation(String citation) {
UNCOV
940
                this.citation = citation;
×
UNCOV
941
        }
×
942

943
        public String getCitationHtml() {
944
                return citationHtml;
×
945
        }
946

947
        public void setCitationHtml(String citationHtml) {
UNCOV
948
                this.citationHtml = citationHtml;
×
UNCOV
949
        }
×
950

951
        public String getFiletype() {
952
                return filetype;
×
953
        }
954

955
        public void setFiletype(String filetype) {
UNCOV
956
                this.filetype = filetype;
×
UNCOV
957
        }
×
958

959
        public String getFileContentType() {
960
                return fileContentType;
×
961
        }
962

963
        public void setFileContentType(String fileContentType) {
UNCOV
964
                this.fileContentType = fileContentType;
×
UNCOV
965
        }
×
966

967
        public String getUnf() {
968
                return unf;
1✔
969
        }
970

971
        public void setUnf(String unf) {
UNCOV
972
                this.unf = unf;
×
UNCOV
973
        }
×
974

975
        public Long getFileSizeInBytes() {
976
                return fileSizeInBytes;
1✔
977
        }
978

979
        public void setFileSizeInBytes(Long fileSizeInBytes) {
UNCOV
980
                this.fileSizeInBytes = fileSizeInBytes;
×
UNCOV
981
        }
×
982

983
        public String getFileMd5() {
984
                if (DataFile.ChecksumType.MD5.equals(getFileChecksumType())) {
1✔
UNCOV
985
                        return fileMd5;
×
986
                } else {
987
                        return null;
1✔
988
                }
989
        }
990

991
        public void setFileMd5(String fileMd5) {
UNCOV
992
                this.fileMd5 = fileMd5;
×
UNCOV
993
        }
×
994

995
        public DataFile.ChecksumType getFileChecksumType() {
996
                return fileChecksumType;
1✔
997
        }
998

999
        public void setFileChecksumType(DataFile.ChecksumType fileChecksumType) {
UNCOV
1000
                this.fileChecksumType = fileChecksumType;
×
UNCOV
1001
        }
×
1002

1003
        public String getFileChecksumValue() {
1004
                return fileChecksumValue;
1✔
1005
        }
1006

1007
        public void setFileChecksumValue(String fileChecksumValue) {
UNCOV
1008
                this.fileChecksumValue = fileChecksumValue;
×
UNCOV
1009
        }
×
1010

1011
        public String getNameSort() {
1012
                return nameSort;
×
1013
        }
1014

1015
        public void setNameSort(String nameSort) {
UNCOV
1016
                this.nameSort = nameSort;
×
UNCOV
1017
        }
×
1018

1019
        public String getStatus() {
1020
                return status;
×
1021
        }
1022

1023
        void setStatus(String status) {
UNCOV
1024
                this.status = status;
×
UNCOV
1025
        }
×
1026

1027
        public Date getReleaseOrCreateDate() {
1028
                return releaseOrCreateDate;
×
1029
        }
1030

1031
        public void setReleaseOrCreateDate(Date releaseOrCreateDate) {
UNCOV
1032
                this.releaseOrCreateDate = releaseOrCreateDate;
×
UNCOV
1033
        }
×
1034

1035
        public String getDateToDisplayOnCard() {
1036
                return DateUtil.formatDate(this.releaseOrCreateDate);
×
1037
        }
1038

1039
        public long getDatasetVersionId() {
UNCOV
1040
                return datasetVersionId;
×
1041
        }
1042

1043
        public void setDatasetVersionId(long datasetVersionId) {
UNCOV
1044
                this.datasetVersionId = datasetVersionId;
×
UNCOV
1045
        }
×
1046

1047
        public String getVersionNumberFriendly() {
1048
                return versionNumberFriendly;
×
1049
        }
1050

1051
        public void setVersionNumberFriendly(String versionNumberFriendly) {
UNCOV
1052
                this.versionNumberFriendly = versionNumberFriendly;
×
UNCOV
1053
        }
×
1054

1055
        public String getDatasetUrl() {
1056
                String failSafeUrl = "/dataset.xhtml?id=" + entityId + "&versionId=" + datasetVersionId;
×
UNCOV
1057
                if (identifier != null) {
×
1058
                        /**
1059
                         * Unfortunately, colons in the globalId (doi:10...) are converted to %3A (doi%3A10...). To prevent this we switched many JSF tags to a plain "a" tag
1060
                         * with an href as suggested at http://stackoverflow.com/questions/24733959/houtputlink-value-escaped
1061
                         */
UNCOV
1062
                        String badString = "null";
×
UNCOV
1063
                        if (!identifier.contains(badString)) {
×
UNCOV
1064
                                if (entity != null && entity instanceof Dataset) {
×
1065
                                        if (this.isHarvested() && ((Dataset) entity).getHarvestedFrom() != null) {
×
1066
                                                String remoteArchiveUrl = ((Dataset) entity).getRemoteArchiveURL();
×
1067
                                                if (remoteArchiveUrl != null) {
×
1068
                                                        return remoteArchiveUrl;
×
1069
                                                }
1070
                                                return null;
×
1071
                                        }
1072
                                }
1073
                                if (isDraftState()) {
×
UNCOV
1074
                                        return "/dataset.xhtml?persistentId=" + identifier + "&version=DRAFT";
×
1075
                                }
1076
                                return "/dataset.xhtml?persistentId=" + identifier;
×
1077
                        } else {
UNCOV
1078
                                logger.info("Dataset identifier/globalId contains \"" + badString
×
1079
                                                + "\" perhaps due to https://github.com/IQSS/dataverse/issues/1147 . Fix data in database and reindex. Returning failsafe URL: "
1080
                                                + failSafeUrl);
1081
                                return failSafeUrl;
×
1082
                        }
1083
                } else {
1084
                        logger.info("Dataset identifier/globalId was null. Returning failsafe URL: " + failSafeUrl);
×
UNCOV
1085
                        return failSafeUrl;
×
1086
                }
1087
        }
1088

1089
        public String getFileParentIdentifier() {
UNCOV
1090
                if (entity == null) {
×
UNCOV
1091
                        return null;
×
1092
                }
1093
                if (entity instanceof DataFile) {
×
1094
                        return parent.get(PARENT_IDENTIFIER); // Dataset globalID
×
1095
                }
1096

1097
                return null;
×
1098
                // if (entity)
1099
        }
1100

1101
        public String getFilePersistentId() {
UNCOV
1102
                return filePersistentId;
×
1103
        }
1104

1105
        public void setFilePersistentId(String pid) {
UNCOV
1106
                filePersistentId = pid;
×
UNCOV
1107
        }
×
1108

1109
        public String getFileUrl() {
1110
                // Nothing special needs to be done for harvested file URLs:
1111
                // simply directing these to the local dataset.xhtml for this dataset
1112
                // will take care of it - because DatasetPage will issue a redirect
1113
                // to the remote archive URL.
1114
                // This is true AS OF 4.2.4, FEB. 2016! - We'll probably want to make
1115
                // .getRemoteArchiveURL() methods, both in DataFile and Dataset objects,
1116
                // work again at some point in the future.
1117
                /*
1118
                 * if (entity != null && entity instanceof DataFile && this.isHarvested()) { String remoteArchiveUrl = ((DataFile) entity).getRemoteArchiveURL(); if
1119
                 * (remoteArchiveUrl != null) { return remoteArchiveUrl; } return null; }
1120
                 */
UNCOV
1121
        if (entity.getIdentifier() != null) {
×
UNCOV
1122
            GlobalId entityPid = entity.getGlobalId();
×
UNCOV
1123
            return "/file.xhtml?persistentId=" + ((entityPid != null) ? entityPid.asString() : null);
×
1124
        }
1125

1126
                return "/file.xhtml?fileId=" + entity.getId() + "&datasetVersionId=" + datasetVersionId;
×
1127

1128
                /*
1129
                 * if (parentDatasetGlobalId != null) { return "/dataset.xhtml?persistentId=" + parentDatasetGlobalId; } else { return "/dataset.xhtml?id=" +
1130
                 * parent.get(SearchFields.ID) + "&versionId=" + datasetVersionId; }
1131
                 */
1132
        }
1133

1134
        public String getFileDatasetUrl() {
1135
                // See the comment in the getFileUrl() method above. -- L.A. 4.2.4
1136
                /*
1137
                 * if (entity != null && entity instanceof DataFile && this.isHarvested()) { String remoteArchiveUrl = ((DataFile) entity).getRemoteArchiveURL(); if
1138
                 * (remoteArchiveUrl != null) { return remoteArchiveUrl; } return null; }
1139
                 */
1140

UNCOV
1141
                String parentDatasetGlobalId = parent.get(PARENT_IDENTIFIER);
×
1142

UNCOV
1143
                if (parentDatasetGlobalId != null) {
×
1144
                        if (isDraftState()) {
×
UNCOV
1145
                                return "/dataset.xhtml?persistentId=" + parentDatasetGlobalId + "&version=DRAFT";
×
1146
                        } else {
1147
                                return "/dataset.xhtml?persistentId=" + parentDatasetGlobalId;
×
1148
                        }
1149
                } else {
1150
                        return "/dataset.xhtml?id=" + parent.get(SearchFields.ID) + "&versionId=" + datasetVersionId;
×
1151
                }
1152
        }
1153

1154
        /**
1155
         * @return the dataverseAlias
1156
         */
1157
        public String getDataverseAlias() {
UNCOV
1158
                return dataverseAlias;
×
1159
        }
1160

1161
        /**
1162
         * @param dataverseAlias the dataverseAlias to set
1163
         */
1164
        public void setDataverseAlias(String dataverseAlias) {
UNCOV
1165
                this.dataverseAlias = dataverseAlias;
×
UNCOV
1166
        }
×
1167

1168
        /**
1169
         * @return the dataverseParentAlias
1170
         */
1171
        public String getDataverseParentAlias() {
UNCOV
1172
                return dataverseParentAlias;
×
1173
        }
1174

1175
        /**
1176
         * @param dataverseParentAlias the dataverseParentAlias to set
1177
         */
1178
        public void setDataverseParentAlias(String dataverseParentAlias) {
UNCOV
1179
                this.dataverseParentAlias = dataverseParentAlias;
×
UNCOV
1180
        }
×
1181

1182
        public float getScore() {
1183
                return score;
×
1184
        }
1185

1186
        public void setScore(float score) {
UNCOV
1187
                this.score = score;
×
UNCOV
1188
        }
×
1189

1190
        private String getDisplayType(String type) {
1191
                if (type.equals(SearchConstants.DATAVERSES)) {
1✔
1192
                        return SearchConstants.DATAVERSE;
1✔
UNCOV
1193
                } else if (type.equals(SearchConstants.DATASETS)) {
×
UNCOV
1194
                        return SearchConstants.DATASET;
×
UNCOV
1195
                } else if (type.equals(SearchConstants.FILES)) {
×
1196
                        return SearchConstants.FILE;
×
1197
                } else {
1198
                        return null;
×
1199
                }
1200
        }
1201

1202
        /*
1203
         * public JsonArrayBuilder getUserRolesAsJson() {
1204
         * 
1205
         * JsonArrayBuilder jsonRoleStrings = Json.createArrayBuilder(); for (String role : this.getUserRole()) { jsonRoleStrings.add(role); } return
1206
         * jsonRoleStrings; }
1207
         */
1208
        public List<String> getUserRole() {
UNCOV
1209
                return userRole;
×
1210
        }
1211

1212
        public void setUserRole(List<String> userRole) {
UNCOV
1213
                this.userRole = userRole;
×
UNCOV
1214
        }
×
1215

1216
        public String getIdentifierOfDataverse() {
1217
                return identifierOfDataverse;
×
1218
        }
1219

1220
        public void setIdentifierOfDataverse(String id) {
UNCOV
1221
                this.identifierOfDataverse = id;
×
UNCOV
1222
        }
×
1223

1224
        public String getNameOfDataverse() {
1225
                return nameOfDataverse;
×
1226
        }
1227

1228
        public void setNameOfDataverse(String id) {
UNCOV
1229
                this.nameOfDataverse = id;
×
UNCOV
1230
        }
×
1231

1232
        public String getExternalStatus() {
1233
                return externalStatus;
×
1234
        }
1235

1236
        public void setExternalStatus(String externalStatus) {
UNCOV
1237
                this.externalStatus = externalStatus;
×
1238

UNCOV
1239
        }
×
1240

1241
        public Long getEmbargoEndDate() {
1242
                return embargoEndDate;
×
1243
        }
1244

1245
        public void setEmbargoEndDate(Long embargoEndDate) {
UNCOV
1246
                this.embargoEndDate = embargoEndDate;
×
UNCOV
1247
        }
×
1248

1249
        public Long getRetentionEndDate() {
1250
                return retentionEndDate;
×
1251
        }
1252

1253
        public void setRetentionEndDate(Long retentionEndDate) {
UNCOV
1254
                this.retentionEndDate = retentionEndDate;
×
UNCOV
1255
        }
×
1256

1257
        public void setDatasetValid(Boolean datasetValid) {
1258
                this.datasetValid = datasetValid == null || Boolean.valueOf(datasetValid);
×
UNCOV
1259
        }
×
1260

1261
        public boolean isValid(Predicate<SolrSearchResult> canUpdateDataset) {
1262
        if (this.datasetValid) {
×
UNCOV
1263
            return true;
×
1264
        }
1265
        if (!this.getType().equals("datasets")) {
×
1266
            return true;
×
1267
        }
1268
        if (this.isDraftState()) {
×
1269
            return false;
×
1270
        }
1271
        if (!JvmSettings.UI_SHOW_VALIDITY_LABEL_WHEN_PUBLISHED.lookupOptional(Boolean.class).orElse(true)) {
×
1272
            return true;
×
1273
        }
1274
                return !canUpdateDataset.test(this);
×
1275
    }
1276
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc