mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
Generate valid tags in thing-description-1.0.0.xsd (#4626)
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
@Grab('com.xlson.groovycsv:groovycsv:1.1')
|
||||
import static com.xlson.groovycsv.CsvParser.parseCsv
|
||||
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.time.Year
|
||||
@@ -53,6 +54,7 @@ labelsFile.close()
|
||||
|
||||
createDefaultSemanticTags(tagSets)
|
||||
createDefaultProviderFile(tagSets)
|
||||
updateThingDescriptionXsd()
|
||||
|
||||
println "\n\nTagSets:"
|
||||
for (String tagSet : tagSets) {
|
||||
@@ -177,6 +179,45 @@ public class DefaultSemanticTagProvider implements SemanticTagProvider {
|
||||
file.close()
|
||||
}
|
||||
|
||||
def updateThingDescriptionXsd() {
|
||||
def xsdPath = baseDir.resolveSibling("org.openhab.core.thing/schema/thing/thing-description-1.0.0.xsd")
|
||||
def tempPath = xsdPath.resolveSibling("thing-description.xsd.tmp")
|
||||
def xsdFile = new File(xsdPath.toString()).text
|
||||
def tempFile = new FileWriter(tempPath.toString())
|
||||
def tagSection = ""
|
||||
def beginEquipment = "<!-- Begin Allowed Semantic Equipment Tag Values -->"
|
||||
def beginProperty = "<!-- Begin Allowed Semantic Property Tag Values -->"
|
||||
def beginPoint = "<!-- Begin Allowed Semantic Point Tag Values -->"
|
||||
def endTag = "<!-- End Allowed Semantic "
|
||||
def doNotEdit = "\t\t\t<!-- DO NOT EDIT THIS LIST - Generated by generateTagClasses.groovy -->"
|
||||
xsdFile.eachLine { sourceLine, lineNumber ->
|
||||
if (tagSection && !sourceLine.contains(endTag)) {
|
||||
return
|
||||
} else {
|
||||
tempFile.write(sourceLine + "\n")
|
||||
|
||||
if (sourceLine.contains(endTag)) {
|
||||
tagSection = ""
|
||||
} else if (sourceLine.contains(beginEquipment)) {
|
||||
tagSection = "Equipment"
|
||||
} else if (sourceLine.contains(beginPoint)) {
|
||||
tagSection = "Point"
|
||||
} else if (sourceLine.contains(beginProperty)) {
|
||||
tagSection = "Property"
|
||||
}
|
||||
|
||||
if (tagSection) {
|
||||
tempFile.write(doNotEdit + "\n")
|
||||
for (tag in tagsByType[tagSection]) {
|
||||
tempFile.write("""\t\t\t<xs:enumeration value="${tag.Tag}"/>\n""")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tempFile.close()
|
||||
Files.move(tempPath, xsdPath, REPLACE_EXISTING)
|
||||
}
|
||||
|
||||
def header() {
|
||||
def headerPath = baseDir.resolve("../../licenses/epl-2.0/header.txt")
|
||||
def year = String.valueOf(Year.now().getValue())
|
||||
|
||||
@@ -274,6 +274,7 @@
|
||||
<xs:simpleType name="semanticPropertyOrPointTag">
|
||||
<xs:restriction base="xs:string">
|
||||
<!-- Begin Allowed Semantic Property Tag Values -->
|
||||
<!-- DO NOT EDIT THIS LIST - Generated by generateTagClasses.groovy -->
|
||||
<xs:enumeration value="Temperature"/>
|
||||
<xs:enumeration value="Light"/>
|
||||
<xs:enumeration value="ColorTemperature"/>
|
||||
@@ -308,6 +309,7 @@
|
||||
<!-- End Allowed Semantic Property Tag Values -->
|
||||
|
||||
<!-- Begin Allowed Semantic Point Tag Values -->
|
||||
<!-- DO NOT EDIT THIS LIST - Generated by generateTagClasses.groovy -->
|
||||
<xs:enumeration value="Alarm"/>
|
||||
<xs:enumeration value="Control"/>
|
||||
<xs:enumeration value="Switch"/>
|
||||
|
||||
Reference in New Issue
Block a user