Skip to content

Commit

Permalink
Merge pull request IQSS#11072 from QualitativeDataRepository/IQSS/110…
Browse files Browse the repository at this point in the history
…69-fix_index_status_query

IQSS/11069 fix index status query
  • Loading branch information
ofahimIQSS authored Dec 10, 2024
2 parents 15e9fe9 + d3be336 commit 206d8f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1407,8 +1407,7 @@ public UploadSessionQuotaLimit getUploadSessionQuotaLimit(DvObjectContainer pare
}

public boolean isInReleasedVersion(Long id) {
Query query = em.createQuery("SELECT fm.id FROM FileMetadata fm, DvObject dvo WHERE fm.datasetVersion.id=(SELECT dv.id FROM DatasetVersion dv WHERE dv.dataset.id=dvo.owner.id and dv.versionState=edu.harvard.iq.dataverse.DatasetVersion.VersionState.RELEASED ORDER BY dv.versionNumber DESC, dv.minorVersionNumber DESC LIMIT 1) AND dvo.id=fm.dataFile.id AND fm.dataFile.id=:fid");
query.setParameter("fid", id);
Query query = em.createNativeQuery("SELECT fm.id FROM filemetadata fm WHERE fm.datasetversion_id=(SELECT dv.id FROM datasetversion dv, dvobject dvo WHERE dv.dataset_id=dvo.owner_id AND dv.versionState='RELEASED' and dvo.id=" + id + " ORDER BY dv.versionNumber DESC, dv.minorVersionNumber DESC LIMIT 1) AND fm.datafile_id=" + id);

try {
query.getSingleResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1151,9 +1151,7 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
logger.fine(solrFieldFacetable + " gets " + vals);
solrInputDocument.addField(solrFieldFacetable, vals);
}
}

if (dsfType.isControlledVocabulary()) {
} else if (dsfType.isControlledVocabulary()) {
/** If the cvv list is empty but the dfv list is not then it is assumed this was harvested
* from an installation that had controlled vocabulary entries that don't exist in our this db
* @see <a href="https://github.com/IQSS/dataverse/issues/9992">Feature Request/Idea: Harvest metadata values that aren't from a list of controlled values #9992</a>
Expand Down Expand Up @@ -1301,7 +1299,6 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
solrInputDocument.addField(SearchFields.DATASET_DEACCESSION_REASON, deaccessionNote);
}
}

docs.add(solrInputDocument);

/**
Expand Down Expand Up @@ -2235,8 +2232,7 @@ public List<String> findPermissionsInSolrOnly() throws SearchException {
String dtype = dvObjectService.getDtype(id);
if (dtype == null) {
permissionInSolrOnly.add(docId);
}
if (dtype.equals(DType.Dataset.getDType())) {
}else if (dtype.equals(DType.Dataset.getDType())) {
List<String> states = datasetService.getVersionStates(id);
if (states != null) {
String latestState = states.get(states.size() - 1);
Expand All @@ -2257,7 +2253,7 @@ public List<String> findPermissionsInSolrOnly() throws SearchException {
} else if (dtype.equals(DType.DataFile.getDType())) {
List<VersionState> states = dataFileService.findVersionStates(id);
Set<String> strings = states.stream().map(VersionState::toString).collect(Collectors.toSet());
logger.fine("States for " + docId + ": " + String.join(", ", strings));
logger.finest("States for " + docId + ": " + String.join(", ", strings));
if (docId.endsWith("draft_permission")) {
if (!states.contains(VersionState.DRAFT)) {
permissionInSolrOnly.add(docId);
Expand All @@ -2271,7 +2267,7 @@ public List<String> findPermissionsInSolrOnly() throws SearchException {
permissionInSolrOnly.add(docId);
} else {
if (!dataFileService.isInReleasedVersion(id)) {
logger.fine("Adding doc " + docId + " to list of permissions in Solr only");
logger.finest("Adding doc " + docId + " to list of permissions in Solr only");
permissionInSolrOnly.add(docId);
}
}
Expand Down

0 comments on commit 206d8f0

Please sign in to comment.