Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/issue3369' into feature/…
Browse files Browse the repository at this point in the history
…issue3369
  • Loading branch information
temi committed Dec 9, 2024
2 parents 6936cb3 + be014dd commit 22fb5df
Show file tree
Hide file tree
Showing 23 changed files with 115 additions and 52 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ jobs:
- name: Run javascript unit tests
run: node_modules/karma/bin/karma start karma.conf.js --single-run --browsers ChromeHeadless

- name: Run MERIT functional tests
run: ./src/main/scripts/runFunctionalTests.sh
env:
GPR_USER: ${{env.GITHUB_ACTOR}}
GPR_TOKEN: ${{secrets.GITHUB_TOKEN}}
# - name: Run MERIT functional tests
# run: ./src/main/scripts/runFunctionalTests.sh
# env:
# GPR_USER: ${{env.GITHUB_ACTOR}}
# GPR_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Clean to remove clover instrumentation
uses: gradle/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion grails-app/assets/javascripts/organisation.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ OrganisationPageViewModel = function (props, options) {
self.allTargetMeasures = _.sortBy(self.allTargetMeasures, 'label');
var propDetails = props && props.custom && props.custom.details || {};
self.selectedTargetMeasures = ko.observableArray();
var details = new DetailsViewModel(propDetails, props, self.periods, self.allTargetMeasures, options);
var details = new OrganisationDetailsViewModel(propDetails, props, self.periods, self.allTargetMeasures, options);
updatedTargetMeasures(details);
self.reportingTargets = ko.observable(details);
self.isProjectDetailsLocked = ko.observable(false);
Expand Down
6 changes: 3 additions & 3 deletions grails-app/assets/javascripts/services.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function DetailsViewModel(o, organisation, budgetHeaders, allServices, config) {
function OrganisationDetailsViewModel(o, organisation, budgetHeaders, allServices, config) {
var self = this;
var period = budgetHeaders,
serviceIds = o.services && o.services.serviceIds || [],
targets = o.services && o.services.targets || [];
self.services = new ServicesViewModel(serviceIds, config.services, targets, budgetHeaders);
self.services = new OrganisationServicesViewModel(serviceIds, config.services, targets, budgetHeaders);
function clearHiddenFields(jsData) {

};
Expand Down Expand Up @@ -33,7 +33,7 @@ function DetailsViewModel(o, organisation, budgetHeaders, allServices, config) {
* @param outputTargets The current organisation targets
* @param periods An array of periods, each of which require a target to be set
*/
function ServicesViewModel(serviceIds, allServices, outputTargets, periods) {
function OrganisationServicesViewModel(serviceIds, allServices, outputTargets, periods) {
var self = this,
OPERATION_SUM = "SUM",
OPERATION_AVG = "AVG",
Expand Down
7 changes: 3 additions & 4 deletions grails-app/controllers/au/org/ala/merit/HomeController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,9 @@ class HomeController {

if (userService.userIsAlaOrFcAdmin()){
params.include = ['name', 'managementUnitName', 'managementUnitId', 'programId', 'description', 'associatedProgram', 'associatedSubProgram','lastUpdated',
'funding', 'organisationName', 'externalId', 'plannedEndDate', 'plannedStartDate', 'activities.siteId','activities.type','sites.siteId', 'sites.projects', 'sites.extent.geometry']

}else{
params.include = ['name', 'description', 'lastUpdated', 'organisationName', 'managementUnitName','managementUnitId', 'programId', 'associatedProgram', 'associatedSubProgram']
'funding', 'associatedOrgs', 'externalId', 'plannedEndDate', 'plannedStartDate', 'activities.siteId','activities.type','sites.siteId', 'sites.projects', 'sites.extent.geometry']
} else {
params.include = ['name', 'description', 'lastUpdated', 'associatedOrgs', 'managementUnitName','managementUnitId', 'programId', 'associatedProgram', 'associatedSubProgram']
}
Map resp = searchService.allProjects(params)
render resp as JSON
Expand Down
2 changes: 1 addition & 1 deletion grails-app/services/au/org/ala/merit/ImportService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ class ImportService {
}
else {
refreshOrganisationList()
projectDetails.associatedOrgs[0].organisationId = orgCreationResult.resp.organisationId
projectDetails.project.associatedOrgs[0].organisationId = orgCreationResult.resp.organisationId
}
}

Expand Down
11 changes: 10 additions & 1 deletion grails-app/views/home/_projectFinder.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,16 @@
$tr.find('.homeLine a').attr("href", "${createLink(controller: 'project')}/" + id);
$tr.find('a.zoom-in').data("id", id);
$tr.find('a.zoom-out').data("id", id);
$tr.find('.orgLine').text(src.organisationName);
var organisations = '';
if (src.associatedOrgs) {
for (var i=0; i<src.associatedOrgs.length; i++) {
if (organisations.length > 0) {
organisations = organisations + ', ';
}
organisations = organisations + src.associatedOrgs[i].name;
}
}
$tr.find('.orgLine').text(organisations);
$tr.find('.descLine').text(src.description);
<g:if test="${fc.userIsSiteAdmin()}">
$tr.find('.downloadLine a').attr("href", "${createLink(controller: 'project',action: 'downloadProjectData')}" + "?id="+id+"&view=xlsx");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import pages.AdminClearCachePage
import pages.AdminTools
import pages.MeriPlanPDFPage
import pages.RlpProjectPage
import spock.lang.Ignore
import spock.lang.Stepwise
import geb.module.FormElement

Expand Down Expand Up @@ -53,6 +54,11 @@ class ConfigurableMeriPlanSpec extends StubbedCasSpec {

meriPlan = openMeriPlanEditTab()

waitFor{meriPlan.projectName.displayed}
interact {
moveToElement(meriPlan.projectName)
}

meriPlan.projectName = "MERI plan edited name"
meriPlan.projectDescription = "MERI plan edited description"
meriPlan.priorityPlace.supportsPriorityPlaces = 'Yes'
Expand Down Expand Up @@ -497,7 +503,9 @@ class ConfigurableMeriPlanSpec extends StubbedCasSpec {
at RlpProjectPage // reset at check time.

meriPlan = openMeriPlanEditTab()

meriPlan.checkObjective("objective 2")

meriPlan.monitoringIndicators[0].indicator = "indicator 1"
meriPlan.monitoringIndicators[0].approach = "approach 1"
meriPlan.projectImplementation = "project implementation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package au.org.ala.fieldcapture
import geb.module.FormElement
import pages.DatasetPage
import pages.RlpProjectPage
import spock.lang.Ignore
import spock.lang.Stepwise

@Stepwise
Expand Down Expand Up @@ -237,8 +238,11 @@ class DatasetSpec extends StubbedCasSpec{
hasBeenReloaded()
}
at RlpProjectPage // reset at check time.

meriPlan = openMeriPlanEditTab()

waitFor {
meriPlan.holdsEditLock()
}
meriPlan.save()

and: "We reload the page and reopen the data set summary tab"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ class EditableMeriPlan extends Module {

/** Users of this method should waitFor hasBeenReloaded as this triggers a page reload */
void aquireEditLock() {
waitFor {
lockMeriPlanButton.displayed
}
lockMeriPlanButton.click()
}

Expand Down
15 changes: 15 additions & 0 deletions src/integration-test/resources/wiremock/mappings/ws_objects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"request": {
"urlPattern": "/ws/objects/.+",

"method": "GET"
},
"response" : {
"status": 200,
"headers": {
"content-Type": "application/json"
},
"body": "[]"

}
}
13 changes: 9 additions & 4 deletions src/main/groovy/au/org/ala/merit/GmsMapper.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package au.org.ala.merit

import au.com.bytecode.opencsv.CSVWriter
import org.apache.commons.lang.WordUtils
import org.apache.commons.validator.EmailValidator

import java.text.DecimalFormat
Expand Down Expand Up @@ -285,20 +286,24 @@ class GmsMapper {
abnLookup = abnLookupService.lookupOrganisationDetailsByABN(abn)
if (abnLookup && !abnLookup.error) {
List names = [abnLookup.entityName] + abnLookup.businessNames
organisation = organisations.find { it.name in names }
if (contractName) {
names << contractName
}
organisation = organisations.find { Map org ->
names.find{it && (it.toLowerCase() == org.name?.toLowerCase())}
}
if (organisation) {
error = "An existing organisation name was matched via the entity/business name ${organisation.name} but the ABN doesn't match the abn of the MERIT organisation (${organisation.abn})"
} else {
createOrganisation = true
String name
if (contractName) {
name = contractName
organisation = abnLookup + [name:contractName, contractNames: [contractName]]
}
else {
name = abnLookup.businessNames ? abnLookup.businessNames[0] : abnLookup.entityName
organisation = abnLookup + [name: name]
name = WordUtils.capitalizeFully(abnLookup.entityName)
}
organisation = abnLookup + [name: name]
messages << "An organisation will be created with ABN: ${abn} and name: ${name}"
}
} else {
Expand Down
1 change: 1 addition & 0 deletions src/main/groovy/au/org/ala/merit/Score.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Score {
String label
String units
String category
String name
boolean isOutputTarget

int overDeliveryThreshold = OVER_DELIVERY_PERCENTAGE_THRESHOLD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ abstract class EditOrViewReportCommand implements Validateable {
model.documentOwner[getEntityIdField()] = id

ReportLifecycleListener listener = reportService.reportLifeCycleListener(model.report)
model.putAll(listener.getContextData(entity, model.report))
if (listener) {
model.putAll(listener.getContextData(entity, model.report))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package au.org.ala.merit.reports

import au.org.ala.ecodata.forms.ActivityFormService
import au.org.ala.merit.MetadataService
import groovy.util.logging.Slf4j
import org.springframework.beans.factory.annotation.Autowired
/**
Expand All @@ -13,6 +14,8 @@ class ReportLifecycleListener {
boolean deleteSiteOnReset = true
@Autowired
ActivityFormService activityFormService
@Autowired
MetadataService metadataService

Map getContextData(Map context, Map report) { [:] }
Map getOutputData(Map context, Map outputConfig, Map report) { [:] }
Expand Down Expand Up @@ -91,18 +94,24 @@ class ReportLifecycleListener {
result
}

static Map getTargetsForReportPeriod(Map report, List<Map> outputTargets) {
Map getTargetsForReportPeriod(Map report, List<Map> outputTargets) {
String endDate = report.toDate

outputTargets?.collectEntries { Map outputTarget ->
String scoreId = outputTarget.scoreId
String name = scoreName(scoreId) ?: scoreId
String previousPeriod = ''
Map matchingPeriodTarget = outputTarget?.periodTargets?.find { Map periodTarget ->
previousPeriod < endDate && periodTarget.period >= endDate
}
[(scoreId): matchingPeriodTarget?.target]
[(name): matchingPeriodTarget?.target]
}
}

String scoreName(String scoreId) {
List scores = metadataService.getScores(false)
scores.find { it.scoreId == scoreId }?.name
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,6 @@ var config =
"title": "Project review, improvement and evaluation methodology and approach (3000 character limit [approximately 500 words])"
}
},
{
"template": "nationalAndRegionalPlans",
"model": {
"includeUrl": true,
"headingTitle": "Conservation and management plans"
}
},
{
"template": "serviceOutcomeTargets",
"model": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,6 @@ var config =
"title": "Project review, improvement and evaluation methodology and approach (3000 character limit [approximately 500 words])"
}
},
{
"template": "nationalAndRegionalPlans",
"model": {
"includeUrl": true,
"headingTitle": "Conservation and management plans"
}
},
{
"template": "serviceOutcomeTargets",
"model": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ var config =
}
},
{
"template": "outcomeStatements",
"template": "additionalOutcomes",
"model": {
"outcomeType": "short",
"helpText": "Outline the degree of impact having undertaken the services for up to three years. Ensure the outcomes are measurable with consideration to the baseline and proposed monitoring regime",
"subtitle": "Short-term outcome statement/s",
"extendedOutcomes": true
"outcomePriority": "Additional outcome/s",
"maxAdditionalOutcomes": "7",
"helpTextHeading": "If the project is not delivering additional benefits, delete the row using the 'x' in the right-most column.",
"title": "Additional benefits",
"renderPrioritiesWithSelect2": true,
"priority": "Additional investment priorities",
"priorityHelpText": "Other investment priorities that will benefit from the project. Delete the row if there are no additional outcomes."
}
},
{
Expand Down Expand Up @@ -542,6 +545,7 @@ var outcomes = [
"targeted": true,
"shortDescription": "EPBC Species",
"category": "Threatened Species",
"supportsMultiplePrioritiesAsSecondary": true,
"outcome": "1. Species and Landscapes (Long term): Threatened Species (TS) - The trajectory of species targeted under the Threatened Species Action Plan 2022-2032 and other EPBC Act listed Species is improved"
},
{
Expand Down
17 changes: 15 additions & 2 deletions src/main/scripts/releases/4.1/configureIPPRS.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ var scores = [
{
"category": "Indigenous Procurement",
"configuration": {
"filter": {
filterValue: "Regional capacity services - reporting",
property: "name",
type: "filter"
},
"childAggregations": [{
"property": "data.workforcePerformancePercentage",
"type": "AVERAGE"
Expand All @@ -27,11 +32,17 @@ var scores = [
"label": "Indigenous workforce performance",
"outputType": "Regional capacity services - reporting",
"scoreId": indigenousWorkforcePerformanceScoreId,
"status": "active"
"status": "active",
"name":"targetIndigenousParticipationPercentage"
},
{
"category": "Indigenous Procurement",
"configuration": {
"filter": {
filterValue: "Regional capacity services - reporting",
property: "name",
type: "filter"
},
"childAggregations": [{
"property": "data.workforcePerformancePercentage",
"type": "AVERAGE"
Expand All @@ -45,7 +56,8 @@ var scores = [
"label": "Indigenous supply chain performance",
"outputType": "Regional capacity services - reporting",
"scoreId": indigenousSupplyChainPerformanceScoreId,
"status": "active"
"status": "active",
"name":"targetIndigenousProcurementPercentage"
}
];

Expand All @@ -54,6 +66,7 @@ for (var i=0; i<scores.length; i++) {
if (existing.hasNext()) {
var existingScore = existing.next();
existingScore.configuration = scores[i].configuration;
existingScore.name = scores[i].name;
db.score.replaceOne({label:scores[i].label}, existingScore);
}
else {
Expand Down
8 changes: 4 additions & 4 deletions src/test/groovy/au/org/ala/merit/GmsMapperSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ class GmsMapperSpec extends Specification{
1 * abnLookupService.lookupOrganisationDetailsByABN(abn) >> abnValue

and:
result.project.associatedOrgs == [[organisationId:null, name:"Test org 12345678900", description:"Recipient"]]
result.messages[0] == "An organisation will be created with ABN: 12345678900 and name: Test org 12345678900"
result.project.associatedOrgs == [[organisationId:null, name:"Test Org 12345678900", description:"Recipient"]]
result.messages[0] == "An organisation will be created with ABN: 12345678900 and name: Test Org 12345678900"
}

def "The organisation relationship can be derived from the program"(){
Expand All @@ -266,8 +266,8 @@ class GmsMapperSpec extends Specification{
1 * abnLookupService.lookupOrganisationDetailsByABN(abn) >> abnValue

and:
result.project.associatedOrgs == [[organisationId:null, name:"Test org 12345678900", description:"Recipient"]]
result.messages[0] == "An organisation will be created with ABN: 12345678900 and name: Test org 12345678900"
result.project.associatedOrgs == [[organisationId:null, name:"Test Org 12345678900", description:"Recipient"]]
result.messages[0] == "An organisation will be created with ABN: 12345678900 and name: Test Org 12345678900"
}

def "If an ABN is supplied in the project load, the looked up entity name cannot match another MERIT organisation"(){
Expand Down
Loading

0 comments on commit 22fb5df

Please sign in to comment.