diff --git a/bundles/org.openhab.core.semantics/model/generateTagClasses.groovy b/bundles/org.openhab.core.semantics/model/generateTagClasses.groovy index 439fda143ba..53d15e2d3bf 100755 --- a/bundles/org.openhab.core.semantics/model/generateTagClasses.groovy +++ b/bundles/org.openhab.core.semantics/model/generateTagClasses.groovy @@ -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 = "" + def beginProperty = "" + def beginPoint = "" + def endTag = "" + 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\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()) diff --git a/bundles/org.openhab.core.thing/schema/thing/thing-description-1.0.0.xsd b/bundles/org.openhab.core.thing/schema/thing/thing-description-1.0.0.xsd index 03e162e0213..2801f3c474a 100644 --- a/bundles/org.openhab.core.thing/schema/thing/thing-description-1.0.0.xsd +++ b/bundles/org.openhab.core.thing/schema/thing/thing-description-1.0.0.xsd @@ -26,6 +26,7 @@ + @@ -215,7 +216,7 @@ - + @@ -269,4 +270,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +