Skip to content

Commit

Permalink
Merge branch 'master' into feat/uiser-153
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Golding committed Oct 2, 2024
2 parents a30168c + 29010bc commit ab8b000
Show file tree
Hide file tree
Showing 5 changed files with 404 additions and 125 deletions.
28 changes: 10 additions & 18 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@ name: Grails CI
on:
push:
branches:
- master
- master
pull_request:
branches:
- master
- master
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./service
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'

- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Start containers
run: |
cd ../tools/testing
docker-compose -f "docker-compose.yml" up -d
docker compose -f "docker-compose.yml" up -d
- name: Build with Gradle
run: |
Expand All @@ -42,11 +42,11 @@ jobs:
- name: Stop containers
run: |
cd ../tools/testing
docker-compose -f "docker-compose.yml" down -v
docker compose -f "docker-compose.yml" down -v
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Unit Test Results
path: |
Expand All @@ -55,11 +55,3 @@ jobs:
service/build/reports/jacoco/test/**/*.html
service/build/reports/jacoco/test/**/*.csv
service/build/reports/jacoco/test/**/*.xml
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
files: |
service/build/test-results/**/*.xml
71 changes: 71 additions & 0 deletions .github/workflows/validate-module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Validate module

on:
push:

jobs:
run:
name: Validate module descriptor
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get Pull Request Number
id: pr_number
run: echo "pull_request_number=$(gh pr view --json number -q .number || echo "")" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.8.2
- name: Set up settings file
uses: 1arp/[email protected]
with:
path: 'service'
file: 'settings.xml'
content:
<settings>
<profiles>
<profile>
<id>folioMavenProfile</id>
<pluginRepositories>
<pluginRepository>
<id>folio-nexus</id>
<name>FOLIO Maven repository</name>
<url>https://repository.folio.org/repository/maven-folio</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>folioMavenProfile</activeProfile>
</activeProfiles>
</settings>
- name: Run validator
run: mvn org.folio:folio-module-descriptor-validator:1.0.0:validate -DmoduleDescriptorFile=service/src/main/okapi/ModuleDescriptor-template.json -s service/settings.xml -l validate_module_descriptor_output.txt
- name: Upload validator result
uses: actions/upload-artifact@v4
if: always()
with:
name: validate_module_descriptor_output
path: |
validate_module_descriptor_output.txt
retention-days: 1
- name: Setup validate_module_descriptor_errors file
if: failure()
run: echo "$(cat validate_module_descriptor_output.txt)" | egrep "\[ERROR\]\s*(\"key\"|\"value\")" | sed 's/\[ERROR\]\(\s*\)//;s/\"value\"\(\s*\):\(\s*\)\(.*\)/\3\n/;s/"key\"\(\s*\):\(\s*\)\(.*\)/\3/' | tee validate_module_descriptor_errors.txt
- name: Comment failures on PR
if: failure()
run: |
# Use GitHub API to create a comment on the PR
PR_NUMBER=${{ steps.pr_number.outputs.pull_request_number }}
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments"
echo "SENDING TO: $COMMENT_URL"
curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL --data "{ \"body\": $(cat validate_module_descriptor_errors.txt | jq -Rs) }"
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ import org.olf.internalPiece.InternalPiece
import com.k_int.okapi.OkapiTenantAwareController

import java.time.LocalDate
import java.util.regex.Pattern

import static org.springframework.http.HttpStatus.*

import grails.rest.*
import grails.converters.*
import grails.gorm.transactions.Transactional
import grails.gorm.multitenancy.CurrentTenant

import org.grails.web.json.JSONObject
import org.grails.web.json.JSONArray

import grails.gorm.transactions.Transactional
import grails.gorm.multitenancy.CurrentTenant
import groovy.util.logging.Slf4j

import java.util.regex.Pattern

@Slf4j
@CurrentTenant
class PredictedPieceSetController extends OkapiTenantAwareController<PredictedPieceSet> {
Expand Down Expand Up @@ -87,4 +89,26 @@ class PredictedPieceSetController extends OkapiTenantAwareController<PredictedPi
respond pps

}

@Transactional
def delete() {
PredictedPieceSet pps = queryForResource(params.id)

if (pps == null) {
transactionStatus.setRollbackOnly()
notFound()
return
}

// Return the relevant status if not allowed to delete.
if (pps.pieces?.any {p -> p?.receivingPieces?.size() >= 1}) {
transactionStatus.setRollbackOnly()
render status: METHOD_NOT_ALLOWED, text: "Cannot delete a predicted piece set which contains receiving pieces"
return
}

// Finally delete the predicted piece set if we get this far and respond.
deleteResource pps
render status: NO_CONTENT
}
}
1 change: 0 additions & 1 deletion service/grails-app/domain/org/olf/PredictedPieceSet.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class PredictedPieceSet implements MultiTenant<PredictedPieceSet> {
note column: 'pps_note'

pieces cascade: 'all-delete-orphan'
ruleset cascade: 'all-delete-orphan'
}

static constraints = {
Expand Down
Loading

0 comments on commit ab8b000

Please sign in to comment.