Skip to content

Commit 4094f11

Browse files
author
Doris Lam
committed
fixes
1 parent 42f8276 commit 4094f11

4 files changed

Lines changed: 21 additions & 14 deletions

File tree

src/main/kotlin/org/openmbee/flexo/sysmlv2/apis/ElementApi.kt

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,19 @@ fun FlexoModelHandler.extractModelElementToJson(elementIri: String): JsonObject
6363
out.forEach { (predicate, values) ->
6464
// extract the suffix name part
6565
var propertyKey = predicate.uri.autoSuffix
66-
66+
val obj = values.elementAt(0)
6767
// relations
6868
if(predicate.uri.startsWith(SYSMLV2.RELATION)) {
69-
// prefer the annotation triple for all relations, skip
69+
// multiple values means it's an array, skip and prefer JSON annotation
70+
// if we've already seen a JSON annotation with the same property key then ignore
71+
if (values.size > 1 || seenArrays.contains(propertyKey)) return@forEach
72+
if (obj.isResource()) {
73+
put(propertyKey, buildJsonObject {
74+
put("@id", obj.asResource().uri.autoSuffix)
75+
})
76+
} else {
77+
throw InvalidTripleError("Relation cannot be literal", elementIri, predicate, obj)
78+
}
7079
}
7180
// properties & annotations
7281
else {
@@ -84,18 +93,16 @@ fun FlexoModelHandler.extractModelElementToJson(elementIri: String): JsonObject
8493
val lit = obj.asLiteral()
8594

8695
// depending on its datatype
87-
when (lit.datatype) {
88-
XSD.xboolean -> put(propertyKey, lit.boolean)
89-
XSD.integer -> put(propertyKey, lit.int)
90-
XSD.decimal, XSD.xdouble -> put(propertyKey, lit.float)
96+
when (lit.datatype.uri) {
97+
XSD.xboolean.uri -> put(propertyKey, lit.boolean)
98+
XSD.integer.uri -> put(propertyKey, lit.int)
99+
XSD.decimal.uri, XSD.xdouble.uri -> put(propertyKey, lit.float)
91100
else -> put(propertyKey, lit.string)
92101
}
93102
}
94103
// object is a Resource
95104
else {
96-
put(propertyKey, buildJsonObject {
97-
put("@id", obj.asResource().uri.autoSuffix)
98-
})
105+
throw InvalidTripleError("Property cannot be resource", elementIri, predicate, obj)
99106
}
100107
}
101108
// annotations
@@ -131,9 +138,9 @@ fun FlexoModelHandler.extractModelElementToJson(elementIri: String): JsonObject
131138
}
132139
// something else
133140
else {
134-
throw InvalidTripleError("Unrecognized triple purpose", elementIri, predicate, obj)
141+
//throw InvalidTripleError("Unrecognized triple purpose", elementIri, predicate, obj)
135142
}
136-
}
143+
//}
137144
}
138145
}
139146
}

src/main/kotlin/org/openmbee/flexo/sysmlv2/apis/ProjectApi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import java.util.*
4040
fun projectFromResponse(
4141
outgoing: Map<Property, Set<RDFNode>>,
4242
projectUuid: UUID = UUID.fromString(outgoing[MMS.id]?.literal()),
43-
branchUuid: UUID = UUID.fromString(outgoing[MMS.defaultBranchId]?.literal())
43+
branchUuid: UUID = UUID.randomUUID()//UUID.fromString(outgoing[MMS.defaultBranchId]?.literal())
4444
): Project {
4545
return Project(
4646
atId = projectUuid,

src/main/resources/application.conf.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ktor {
1212
}
1313

1414
flexo {
15-
protocol = "localhost"
15+
protocol = "http"
1616
protocol = ${?FLEXO_PROTOCOL}
1717
host = "localhost"
1818
host = ${?FLEXO_HOST}

src/test/resources/application.test.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ktor {
1111
}
1212
}
1313
flexo {
14-
protocol = "localhost"
14+
protocol = "http"
1515
protocol = ${?FLEXO_PROTOCOL}
1616
host = "localhost"
1717
host = ${?FLEXO_HOST}

0 commit comments

Comments
 (0)