Skip to content

Commit

Permalink
Extract DocumentType and document name and type utility methods in
Browse files Browse the repository at this point in the history
independent classes
  • Loading branch information
zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL committed Aug 5, 2021
1 parent 8f68190 commit d729d02
Show file tree
Hide file tree
Showing 7 changed files with 5,702 additions and 5,649 deletions.
227 changes: 114 additions & 113 deletions src/org/ods/orchestration/scheduler/LeVADocumentScheduler.groovy

Large diffs are not rendered by default.

114 changes: 57 additions & 57 deletions src/org/ods/orchestration/usecase/LeVADocumentUseCase.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,31 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

protected static Map DOCUMENT_TYPE_NAMES = [
(DocumentType.CSD as String) : 'Combined Specification Document',
(DocumentType.DIL as String) : 'Discrepancy Log',
(DocumentType.DTP as String) : 'Software Development Testing Plan',
(DocumentType.DTR as String) : 'Software Development Testing Report',
(DocumentType.CFTP as String) : 'Combined Functional and Requirements Testing Plan',
(DocumentType.CFTR as String) : 'Combined Functional and Requirements Testing Report',
(DocumentType.IVP as String) : 'Configuration and Installation Testing Plan',
(DocumentType.IVR as String) : 'Configuration and Installation Testing Report',
(DocumentType.RA as String) : 'Risk Assessment',
(DocumentType.TRC as String) : 'Traceability Matrix',
(DocumentType.SSDS as String) : 'System and Software Design Specification',
(DocumentType.TCP as String) : 'Test Case Plan',
(DocumentType.TCR as String) : 'Test Case Report',
(DocumentType.TIP as String) : 'Technical Installation Plan',
(DocumentType.TIR as String) : 'Technical Installation Report',
(DocumentType.OVERALL_DTR as String): 'Overall Software Development Testing Report',
(DocumentType.OVERALL_IVR as String): 'Overall Configuration and Installation Testing Report',
(DocumentType.OVERALL_TIR as String): 'Overall Technical Installation Report',
(LeVADocumentType.CSD as String) : 'Combined Specification Document',
(LeVADocumentType.DIL as String) : 'Discrepancy Log',
(LeVADocumentType.DTP as String) : 'Software Development Testing Plan',
(LeVADocumentType.DTR as String) : 'Software Development Testing Report',
(LeVADocumentType.CFTP as String) : 'Combined Functional and Requirements Testing Plan',
(LeVADocumentType.CFTR as String) : 'Combined Functional and Requirements Testing Report',
(LeVADocumentType.IVP as String) : 'Configuration and Installation Testing Plan',
(LeVADocumentType.IVR as String) : 'Configuration and Installation Testing Report',
(LeVADocumentType.RA as String) : 'Risk Assessment',
(LeVADocumentType.TRC as String) : 'Traceability Matrix',
(LeVADocumentType.SSDS as String) : 'System and Software Design Specification',
(LeVADocumentType.TCP as String) : 'Test Case Plan',
(LeVADocumentType.TCR as String) : 'Test Case Report',
(LeVADocumentType.TIP as String) : 'Technical Installation Plan',
(LeVADocumentType.TIR as String) : 'Technical Installation Report',
(LeVADocumentType.OVERALL_DTR as String): 'Overall Software Development Testing Report',
(LeVADocumentType.OVERALL_IVR as String): 'Overall Configuration and Installation Testing Report',
(LeVADocumentType.OVERALL_TIR as String): 'Overall Technical Installation Report',
]

static GAMP_CATEGORY_SENSITIVE_DOCS = [
DocumentType.SSDS as String,
DocumentType.CSD as String,
DocumentType.CFTP as String,
DocumentType.CFTR as String
LeVADocumentType.SSDS as String,
LeVADocumentType.CSD as String,
LeVADocumentType.CFTP as String,
LeVADocumentType.CFTR as String
]

static Map<String, Map> DOCUMENT_TYPE_FILESTORAGE_EXCEPTIONS = [
Expand Down Expand Up @@ -122,7 +122,7 @@ class LeVADocumentUseCase extends DocGenUseCase {

@SuppressWarnings('CyclomaticComplexity')
String createCSD(Map repo = null, Map data = null) {
def documentType = DocumentType.CSD as String
def documentType = LeVADocumentType.CSD as String

def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
Expand Down Expand Up @@ -219,7 +219,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

String createDTP(Map repo = null, Map data = null) {
def documentType = DocumentType.DTP as String
def documentType = LeVADocumentType.DTP as String

def sections = this.getDocumentSectionsFileOptional(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
Expand Down Expand Up @@ -247,7 +247,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

String createDTR(Map repo, Map data) {
def documentType = DocumentType.DTR as String
def documentType = LeVADocumentType.DTR as String

Map resurrectedDocument = resurrectAndStashDocument(documentType, repo)
this.steps.echo "Resurrected ${documentType} for ${repo.id} -> (${resurrectedDocument.found})"
Expand Down Expand Up @@ -336,9 +336,9 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

String createOverallDTR(Map repo = null, Map data = null) {
def documentTypeName = DOCUMENT_TYPE_NAMES[DocumentType.OVERALL_DTR as String]
def documentTypeName = DOCUMENT_TYPE_NAMES[LeVADocumentType.OVERALL_DTR as String]
def metadata = this.getDocumentMetadata(documentTypeName)
def documentType = DocumentType.DTR as String
def documentType = LeVADocumentType.DTR as String

def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())

Expand All @@ -349,7 +349,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

String createDIL(Map repo = null, Map data = null) {
def documentType = DocumentType.DIL as String
def documentType = LeVADocumentType.DIL as String

def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())

Expand Down Expand Up @@ -437,7 +437,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

String createCFTP(Map repo = null, Map data = null) {
def documentType = DocumentType.CFTP as String
def documentType = LeVADocumentType.CFTP as String

def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
Expand Down Expand Up @@ -484,7 +484,7 @@ class LeVADocumentUseCase extends DocGenUseCase {

@SuppressWarnings('CyclomaticComplexity')
String createCFTR(Map repo, Map data) {
def documentType = DocumentType.CFTR as String
def documentType = LeVADocumentType.CFTR as String

def acceptanceTestData = data.tests.acceptance
def integrationTestData = data.tests.integration
Expand Down Expand Up @@ -564,7 +564,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

String createRA(Map repo = null, Map data = null) {
def documentType = DocumentType.RA as String
def documentType = LeVADocumentType.RA as String

def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
Expand Down Expand Up @@ -652,7 +652,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

String createIVP(Map repo = null, Map data = null) {
def documentType = DocumentType.IVP as String
def documentType = LeVADocumentType.IVP as String

def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
Expand Down Expand Up @@ -707,7 +707,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

String createIVR(Map repo, Map data) {
def documentType = DocumentType.IVR as String
def documentType = LeVADocumentType.IVR as String

def installationTestData = data.tests.installation

Expand Down Expand Up @@ -779,7 +779,7 @@ class LeVADocumentUseCase extends DocGenUseCase {

@SuppressWarnings('CyclomaticComplexity')
String createTCR(Map repo = null, Map data = null) {
String documentType = DocumentType.TCR as String
String documentType = LeVADocumentType.TCR as String

def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
Expand Down Expand Up @@ -864,7 +864,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

String createTCP(Map repo = null, Map data = null) {
String documentType = DocumentType.TCP as String
String documentType = LeVADocumentType.TCP as String

def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
Expand Down Expand Up @@ -920,7 +920,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

String createSSDS(Map repo = null, Map data = null) {
def documentType = DocumentType.SSDS as String
def documentType = LeVADocumentType.SSDS as String

this.bbt.generateSourceCodeReviewFile()
def bbInfo = this.bbt.readSourceCodeReviewFile(this.bbt.generateSourceCodeReviewFile())
Expand Down Expand Up @@ -997,7 +997,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

String createTIP(Map repo = null, Map data = null) {
def documentType = DocumentType.TIP as String
def documentType = LeVADocumentType.TIP as String

def sections = this.getDocumentSectionsFileOptional(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
Expand All @@ -1022,7 +1022,7 @@ class LeVADocumentUseCase extends DocGenUseCase {

@SuppressWarnings('CyclomaticComplexity')
String createTIR(Map repo, Map data) {
def documentType = DocumentType.TIR as String
def documentType = LeVADocumentType.TIR as String

def installationTestData = data?.tests?.installation

Expand Down Expand Up @@ -1079,10 +1079,10 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

String createOverallTIR(Map repo = null, Map data = null) {
def documentTypeName = DOCUMENT_TYPE_NAMES[DocumentType.OVERALL_TIR as String]
def documentTypeName = DOCUMENT_TYPE_NAMES[LeVADocumentType.OVERALL_TIR as String]
def metadata = this.getDocumentMetadata(documentTypeName)

def documentType = DocumentType.TIR as String
def documentType = LeVADocumentType.TIR as String

def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())

Expand Down Expand Up @@ -1115,7 +1115,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

String createTRC(Map repo, Map data) {
def documentType = DocumentType.TRC as String
def documentType = LeVADocumentType.TRC as String

def acceptanceTestData = data.tests.acceptance
def installationTestData = data.tests.installation
Expand Down Expand Up @@ -1179,7 +1179,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
// compute suffix based on repository type
if (repo != null) {
if (repo.type.toLowerCase() == MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_INFRA) {
if (documentType == DocumentType.TIR as String) {
if (documentType == LeVADocumentType.TIR as String) {
suffix += "-infra"
}
}
Expand All @@ -1199,7 +1199,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

List<String> getSupportedDocuments() {
return DocumentType.values().collect { it as String }
return LeVADocumentType.values().collect { it as String }
}

String getDocumentTemplatesVersion() {
Expand All @@ -1209,8 +1209,8 @@ class LeVADocumentUseCase extends DocGenUseCase {

boolean shouldCreateArtifact (String documentType, Map repo) {
List nonArtifactDocTypes = [
DocumentType.TIR as String,
DocumentType.DTR as String
LeVADocumentType.TIR as String,
LeVADocumentType.DTR as String
]

return !(documentType && nonArtifactDocTypes.contains(documentType) && repo)
Expand Down Expand Up @@ -1597,7 +1597,7 @@ class LeVADocumentUseCase extends DocGenUseCase {
if (this.project.historyForDocumentExists(documentName)) {
return this.project.getHistoryForDocument(documentName)
} else {
def documentType = documentName.split('-').first()
def documentType = LeVADocumentUtil.getTypeFromName(documentName) as String
def jiraData = this.project.data.jira as Map
def environment = this.computeSavedDocumentEnvironment(documentType)
def docHistory = new DocumentHistory(this.steps, ServiceRegistry.instance.get(Logger), environment, documentName)
Expand Down Expand Up @@ -1719,19 +1719,19 @@ class LeVADocumentUseCase extends DocGenUseCase {
}

def referencedDcocs = [
DocumentType.CSD,
DocumentType.SSDS,
DocumentType.RA,
DocumentType.TRC,
DocumentType.DTP,
DocumentType.DTR,
DocumentType.CFTP,
DocumentType.CFTR,
DocumentType.TIR,
DocumentType.TIP,
LeVADocumentType.CSD,
LeVADocumentType.SSDS,
LeVADocumentType.RA,
LeVADocumentType.TRC,
LeVADocumentType.DTP,
LeVADocumentType.DTR,
LeVADocumentType.CFTP,
LeVADocumentType.CFTR,
LeVADocumentType.TIR,
LeVADocumentType.TIP,
]

referencedDcocs.collectEntries { DocumentType dt ->
referencedDcocs.collectEntries { LeVADocumentType dt ->
def doc = dt as String
def version

Expand Down
7 changes: 4 additions & 3 deletions src/org/ods/orchestration/util/DocumentHistory.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class DocumentHistory {
// Otherwise, use the target environment.
@NonCPS
private getSourceEnvironment(String targetEnvironment, String documentName) {
def documentType = documentName.split('-').first()
def documentType = LeVADocumentUtil.getTypeFromName(documentName) as String
def environment = null
def envs = ['D', 'Q', 'P']
for (int i = 0; i < envs.size() && envs[i] != targetEnvironment; i++) {
Expand Down Expand Up @@ -307,7 +307,7 @@ class DocumentHistory {
def concurrentVersions = getConcurrentVersions(oldVersionsSimplified, currentEntry.getPreviousProjectVersion())

if (currentEntry.getPreviousProjectVersion() && oldVersionsSimplified.size() == concurrentVersions.size() &&
!documentName.contains('-')) {
LeVADocumentUtil.isFullDocument(documentName)) {
throw new RuntimeException('Inconsistent state found when building DocumentHistory. ' +
"Project has as previous project version '${currentEntry.getPreviousProjectVersion()}' " +
'but no document history containing that ' +
Expand Down Expand Up @@ -419,7 +419,8 @@ class DocumentHistory {
private List<Map> getIssueChangesForVersion(String version, String issueType, Map issues) {
// Filter chapter issues for this document only
if (issueType == JiraDataItem.TYPE_DOCS) {
issues = issues.findAll { it.value.documents.contains(this.documentName.split('-').first()) }
def docType = LeVADocumentUtil.getTypeFromName(this.documentName) as String
issues = issues.findAll { it.value.documents.contains(docType) }
}

issues.findAll { it.value.versions?.contains(version) }
Expand Down
22 changes: 22 additions & 0 deletions src/org/ods/orchestration/util/LeVADocumentType.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.ods.orchestration.util

enum LeVADocumentType {
CSD,
DIL,
DTP,
DTR,
RA,
CFTP,
CFTR,
IVP,
IVR,
SSDS,
TCP,
TCR,
TIP,
TIR,
TRC,
OVERALL_DTR,
OVERALL_IVR,
OVERALL_TIR
}
29 changes: 29 additions & 0 deletions src/org/ods/orchestration/util/LeVADocumentUtil.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.ods.orchestration.util

class LeVADocumentUtil {
private LeVADocumentUtil() {
}

static List splitName(String name) {
def components = name.split('-') as List
def type = LeVADocumentType.valueOf(components[0])
components[0] = type
return components
}

static LeVADocumentType getTypeFromName(String name) {
return splitName(name)[0]
}

static String getRepoFromName(String name) {
return splitName(name)[1]
}

static boolean isFullDocument(String name) {
return !getRepoFromName(name)
}

static boolean isPartialDocument(String name) {
return !isFullDocument(name)
}
}
Loading

0 comments on commit d729d02

Please sign in to comment.