Skip to content
Snippets Groups Projects
Commit 59112f83 authored by jakubs's avatar jakubs
Browse files

BIS-153 SP-257 update export master data script

* move the exporting/importing of scripts earlier in the script
* add validation scripts to the entity types

SVN: 26450
parent eba906ca
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,14 @@ def codeLiteral(code):
normalized = code[1:]
return strLiteral(normalized)
def createValidationScriptAssigment(entityType, var):
validationScript = entityType.getValidationScript()
if (validationScript == None):
return ""
else:
script = getVarName("SCRIPT", replaceSpace(validationScript.getName()))
return "%s.setValidationScript(%s)" % (var, script)
def exportFileFormatType(fileType):
var = getVarName("FILE_FORMAT", fileType.getCode())
......@@ -153,9 +161,11 @@ def exportExperimentType(experimentType):
var = getVarName("EXPERIMENT", experimentType.getCode())
code = codeLiteral(experimentType.getCode())
description = strLiteral(experimentType.getDescription())
validationScript = createValidationScriptAssigment(experimentType, var)
return """
%(var)s = tr.getOrCreateNewExperimentType(%(code)s)
%(var)s.setDescription(%(description)s)
%(validationScript)s
""" % vars()
def exportSampleType(sampleType):
......@@ -169,6 +179,7 @@ def exportSampleType(sampleType):
isAutoGeneratedCode = sampleType.isAutoGeneratedCode()
isShowParentMetadata = sampleType.isShowParentMetadata()
generatedCodePrefix = strLiteral(sampleType.getGeneratedCodePrefix())
validationScript = createValidationScriptAssigment(sampleType, var)
return """
%(var)s = tr.getOrCreateNewSampleType(%(code)s)
%(var)s.setDescription(%(description)s)
......@@ -179,6 +190,7 @@ def exportSampleType(sampleType):
%(var)s.setAutoGeneratedCode(%(isAutoGeneratedCode)s)
%(var)s.setShowParentMetadata(%(isShowParentMetadata)s)
%(var)s.setGeneratedCodePrefix(%(generatedCodePrefix)s)
%(validationScript)s
""" % vars()
def exportDataSetType(dataSetType):
......@@ -189,6 +201,7 @@ def exportDataSetType(dataSetType):
mainDataSetPattern = dataSetType.getMainDataSetPattern()
mainDataSetPath = dataSetType.getMainDataSetPath()
deletionDisallowed = dataSetType.isDeletionDisallowed()
validationScript = createValidationScriptAssigment(dataSetType, var)
if (dataSetType.getCode() in EXISTING_DATASET_TYPES):
return ""
else:
......@@ -199,6 +212,7 @@ def exportDataSetType(dataSetType):
%(var)s.setMainDataSetPattern(%(mainDataSetPattern)s)
%(var)s.setMainDataSetPath(%(mainDataSetPath)s)
%(var)s.setDeletionDisallowed(%(deletionDisallowed)s)
%(validationScript)s
""" % vars()
def exportScripts (script):
......@@ -230,9 +244,11 @@ def exportMaterialType(materialType):
var = getVarName("MATERIAL", materialType.getCode())
code = codeLiteral(materialType.getCode())
description = strLiteral(materialType.getDescription())
validationScript = createValidationScriptAssigment(materialType, var)
return """
%(var)s = tr.getOrCreateNewMaterialType(%(code)s)
%(var)s.setDescription(%(description)s)
%(validationScript)s
""" % vars()
def exportPropertyType(propertyType):
......@@ -329,14 +345,14 @@ exportedContent = (
["""\nprint "Imported """ + str(len(tr.listFileFormatTypes())) + """ File Formats" """] +
[exportVocabulary(vocabulary) for vocabulary in tr.listVocabularies()] +
["""\nprint "Imported """ + str(len(tr.listVocabularies())) + """ Vocabularies" """] +
[exportScripts(scripts) for scripts in tr.listScripts()] +
["""\nprint "Imported """ + str(len(tr.listScripts())) + """ Scripts" """] +
[exportExperimentType(expType) for expType in tr.listExperimentTypes()] +
["""\nprint "Imported """ + str(len(tr.listExperimentTypes())) + """ Experiment Types" """] +
[exportSampleType(sampleType) for sampleType in tr.listSampleTypes()] +
["""\nprint "Imported """ + str(len(tr.listSampleTypes())) + """ Sample Types" """] +
[exportDataSetType(dataSetType) for dataSetType in tr.listDataSetTypes()] +
["""\nprint "Imported """ + str(len(tr.listDataSetTypes())) + """ Data Set Types" """] +
[exportScripts(scripts) for scripts in tr.listScripts()] +
["""\nprint "Imported """ + str(len(tr.listScripts())) + """ Scripts" """] +
[exportMaterialType(materialType) for materialType in tr.listMaterialTypes()] +
["""\nprint "Imported """ + str(len(tr.listMaterialTypes())) + """ Material Types" """] +
[exportPropertyType(propertyType) for propertyType in tr.listPropertyTypes()] +
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment