diff --git a/core/src/main/scala/flatgraph/DiffGraphApplier.scala b/core/src/main/scala/flatgraph/DiffGraphApplier.scala index a6fe84ac..9312fcd2 100644 --- a/core/src/main/scala/flatgraph/DiffGraphApplier.scala +++ b/core/src/main/scala/flatgraph/DiffGraphApplier.scala @@ -8,7 +8,11 @@ import flatgraph.misc.SchemaViolationReporter import scala.collection.{Iterator, mutable} object DiffGraphApplier { - def applyDiff(graph: Graph, diff: DiffGraphBuilder, schemaViolationReporter: SchemaViolationReporter = new SchemaViolationReporter): Unit = { + def applyDiff( + graph: Graph, + diff: DiffGraphBuilder, + schemaViolationReporter: SchemaViolationReporter = new SchemaViolationReporter + ): Unit = { if (graph.isClosed) throw new GraphClosedException(s"graph cannot be modified any longer since it's closed") new DiffGraphApplier(graph, diff, schemaViolationReporter).applyUpdate() diff.buffer = null diff --git a/core/src/main/scala/flatgraph/misc/SchemaViolationReporter.scala b/core/src/main/scala/flatgraph/misc/SchemaViolationReporter.scala index d7605305..f60cb84b 100644 --- a/core/src/main/scala/flatgraph/misc/SchemaViolationReporter.scala +++ b/core/src/main/scala/flatgraph/misc/SchemaViolationReporter.scala @@ -5,23 +5,23 @@ import org.slf4j.LoggerFactory import scala.collection.mutable -/** Illegal usage of node properties often roots in deserialising an old storage format, so we - * don't want to error out but rather log a warning, and only do so once for each node/property combination. - */ +/** Illegal usage of node properties often roots in deserialising an old storage format, so we don't want to error out but rather log a + * warning, and only do so once for each node/property combination. + */ class SchemaViolationReporter { - private val logger = LoggerFactory.getLogger(getClass) - private val loggedSchemaViolations = mutable.Set.empty[(Int, String|Int)] // (NodeKind, PropertyLabel|PropertyKind) + private val logger = LoggerFactory.getLogger(getClass) + private val loggedSchemaViolations = mutable.Set.empty[(Int, String | Int)] // (NodeKind, PropertyLabel|PropertyKind) - def illegalNodeProperty(nodeKind: Int, propertyIdentifier: String|Int, schema: Schema): Unit = { + def illegalNodeProperty(nodeKind: Int, propertyIdentifier: String | Int, schema: Schema): Unit = { if (loggedSchemaViolations.contains((nodeKind, propertyIdentifier))) { val contextBuilder = Seq.newBuilder[String] - + contextBuilder += s"nodeKind=$nodeKind" schema.getNodeLabelMaybe(nodeKind).foreach { nodeLabel => contextBuilder += s",nodeLabel=$nodeLabel" } propertyIdentifier match { - case name: String => + case name: String => contextBuilder += s",propertyName=$name" case kind: Int => contextBuilder += s",propertyKind=$kind" diff --git a/core/src/main/scala/flatgraph/traversal/Language.scala b/core/src/main/scala/flatgraph/traversal/Language.scala index 8851a407..9b532199 100644 --- a/core/src/main/scala/flatgraph/traversal/Language.scala +++ b/core/src/main/scala/flatgraph/traversal/Language.scala @@ -600,7 +600,7 @@ class NodeSteps[A <: GNode](traversal: Iterator[A]) extends AnyVal { def property[@specialized ValueType](propertyKey: MultiPropertyKey[ValueType]): Iterator[ValueType] = traversal.flatMap(_.property(propertyKey)) - + def propertiesMap: Iterator[java.util.Map[String, AnyRef]] = traversal.map(_.propertiesMap) } diff --git a/domain-classes-generator/src/main/scala/flatgraph/codegen/DomainClassesGenerator.scala b/domain-classes-generator/src/main/scala/flatgraph/codegen/DomainClassesGenerator.scala index 9f2ac9c9..5992700f 100644 --- a/domain-classes-generator/src/main/scala/flatgraph/codegen/DomainClassesGenerator.scala +++ b/domain-classes-generator/src/main/scala/flatgraph/codegen/DomainClassesGenerator.scala @@ -691,7 +691,8 @@ class DomainClassesGenerator(schema: Schema) { } os.write(outputDir0 / "GraphSchema.scala", schemaFile) - os.write(outputDir0 / "PropertyErrorRegister.scala", + os.write( + outputDir0 / "PropertyErrorRegister.scala", s"""package $basePackage | |object PropertyErrorRegister { diff --git a/tests/src/test/scala/flatgraph/GraphTests.scala b/tests/src/test/scala/flatgraph/GraphTests.scala index 2818495a..03aeb7bf 100644 --- a/tests/src/test/scala/flatgraph/GraphTests.scala +++ b/tests/src/test/scala/flatgraph/GraphTests.scala @@ -14,15 +14,14 @@ import org.scalatest.wordspec.AnyWordSpec import scala.collection.mutable import scala.jdk.CollectionConverters.MapHasAsScala - class GraphTests extends AnyWordSpec with MockFactory { "node property: log warning for schema-unconform property usage" in { // unknown node properties often root in deserialising an old storage format, // so we don't want to error out but rather log a warning - val genericDomain = GenericDomain.empty - val graph = genericDomain.graph - val schema = graph.schema + val genericDomain = GenericDomain.empty + val graph = genericDomain.graph + val schema = graph.schema val Seq(nodeA, nodeB) = TestHelpers.addNodes(graph, Seq(NewNodeA(), NewNodeB())) val mockSchemaViolationReporter = mock[SchemaViolationReporter] @@ -43,7 +42,6 @@ class GraphTests extends AnyWordSpec with MockFactory { genericDomain.nodeB.head.propertiesMap.asScala shouldBe Map() } - /* sample graph: * L3 <- L2 <- L1 <- Center -> R1 -> R2 -> R3 -> R4 -> R5 */