Skip to content

Commit

Permalink
Merge pull request #413 from alexhuang091/release/2.6.1
Browse files Browse the repository at this point in the history
Release/2.6.1
  • Loading branch information
alexhuang091 authored Mar 21, 2021
2 parents daa70fd + 85fdc4b commit 9fbf487
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 110 deletions.
2 changes: 2 additions & 0 deletions conf/cassandra3_case_sensitive_schema.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ CREATE TABLE occ.qa (
"userDisplayName" text,
"userEmail" text,
uuid text,
relatedrecordid text,
relatedrecordreason text,
PRIMARY KEY (rowkey, "userId", code)
) WITH CLUSTERING ORDER BY ("userId" ASC, code ASC)
AND bloom_filter_fp_chance = 0.01
Expand Down
4 changes: 3 additions & 1 deletion conf/cassandra3_schema.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ CREATE TABLE qa (
userentityuid text,
userid text,
userrole text,
value text
value text,
relatedrecordid text,
relatedrecordreason text,
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<parent>
<groupId>au.org.ala</groupId>
<artifactId>ala-parent-pom</artifactId>
<version>11</version>
<version>14</version>
</parent>

<groupId>au.org.ala</groupId>
<artifactId>biocache-store</artifactId>
<version>2.6.0</version>
<version>2.6.1</version>
<url>https://biocache.ala.org.au</url>
<issueManagement>
<system>GitHub</system>
Expand Down Expand Up @@ -348,7 +348,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
23 changes: 17 additions & 6 deletions src/main/scala/au/org/ala/biocache/dao/OccurrenceDAOImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ class OccurrenceDAOImpl extends OccurrenceDAO {
}

// Updating system assertion, pass in false
val (userAssertionStatus, trueUserAssertions) = getCombinedUserStatus(false, userAssertions)
val (userAssertionStatus, trueUserAssertions, originalAssertions) = getCombinedUserStatus(false, userAssertions)

val verified = if (userAssertionStatus == AssertionStatus.QA_VERIFIED || userAssertionStatus == AssertionStatus.QA_CORRECTED) true else false

Expand Down Expand Up @@ -910,7 +910,7 @@ class OccurrenceDAOImpl extends OccurrenceDAO {
persistenceManager.put(rowKey, qaEntityName, qaMap, true, false)
val systemAssertions = getSystemAssertions(rowKey)
val userAssertions = getUserAssertions(rowKey)
updateAssertionStatus(rowKey, qualityAssertion, systemAssertions, userAssertions :+ qualityAssertion)
updateAssertionStatus(rowKey, qualityAssertion, systemAssertions, userAssertions)

//set the last user assertion date
persistenceManager.put(rowKey, entityName, FullRecordMapper.lastUserAssertionDateColumn, qualityAssertion.created, false, false)
Expand Down Expand Up @@ -1008,15 +1008,25 @@ class OccurrenceDAOImpl extends OccurrenceDAO {
* If Collection Admin verifies the record, currentAssertion will have
* code: 50000 (AssertionCodes.VERIFIED.code),
* qaStatus: AssertionStatus.QA_OPEN_ISSUE, AssertionStatus.QA_VERIFIED, AssertionStatus:QA_CORRECTED
*
* Alex updated on 07/12/2020, combinedUserAssertions contains all assertions in 50005 or 50001 state (outstanding assertions)
* originalAssertions contains all assertions users (not admin) made. Keep the original interface just to make sure new change
* doesn't break anything
*/
private def getCombinedUserStatus(bVerified: Boolean, userAssertions: List[QualityAssertion]): (Int, ArrayBuffer[QualityAssertion]) = {
private def getCombinedUserStatus(bVerified: Boolean, userAssertions: List[QualityAssertion]): (Int, ArrayBuffer[QualityAssertion], ArrayBuffer[QualityAssertion]) = {

// Filter off only verified records
val verifiedAssertions = userAssertions.filter(qa => qa.code == AssertionCodes.VERIFIED.code)

// Filter off only user assertions type
val assertions = userAssertions.filter(qa => qa.code != AssertionCodes.VERIFIED.code && AssertionStatus.isUserAssertionType(qa.qaStatus))

var originalAssertions = new ArrayBuffer[QualityAssertion]()
// qa.relatedUuid == null means it's not a verification because a verification must have an associated assertion thus relatedUuid not null
assertions.filter(qa => qa.relatedUuid == null).foreach {
originalAssertions.append(_)
}

// Sort the verified list according to relatedUuid and order of reference rowKey.
// RowKey for verified records consist of rowKey|userId|code|recNum where recNum increments everytime a verified record is added
val sortedList = verifiedAssertions.sortWith(QualityAssertion.compareByReferenceRowKeyDesc).sortBy(_.relatedUuid)
Expand Down Expand Up @@ -1072,7 +1082,7 @@ class OccurrenceDAOImpl extends OccurrenceDAO {

logger.debug("Overall assertion Status: " + userAssertionStatus)

(userAssertionStatus, combinedUserAssertions)
(userAssertionStatus, combinedUserAssertions, originalAssertions)
}

/**
Expand All @@ -1083,7 +1093,7 @@ class OccurrenceDAOImpl extends OccurrenceDAO {
logger.debug("Updating the assertion status for : " + rowKey)

val bVerified = AssertionCodes.isVerified(assertion)
val (userAssertionStatus, remainingAssertions) = getCombinedUserStatus(bVerified, userAssertions)
val (userAssertionStatus, remainingAssertions, originalAssertions) = getCombinedUserStatus(bVerified, userAssertions)

// default to the assertion which is to be evaluated
var actualAssertion = assertion
Expand Down Expand Up @@ -1152,7 +1162,8 @@ class OccurrenceDAOImpl extends OccurrenceDAO {
logger.debug("Final " + listErrorCodes)

//update the list
persistenceManager.put(rowKey, entityName, FullRecordMapper.userQualityAssertionColumn, Json.toJSON(remainingAssertions.toList), false, false)
// use all user assertions (no matter if it's already verified) to fill userQualityAssertionColumn so that assertion_user_id can be extracted correctly when reindexing
persistenceManager.put(rowKey, entityName, FullRecordMapper.userQualityAssertionColumn, Json.toJSON(originalAssertions.toList), false, false)
persistenceManager.putList(rowKey, entityName, FullRecordMapper.markAsQualityAssertion(phase), listErrorCodes.toList, classOf[Int], false, true, false)

//set the overall decision if necessary
Expand Down
Loading

0 comments on commit 9fbf487

Please sign in to comment.