You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by jo...@apache.org on 2021/01/22 17:16:31 UTC
[isis] 02/04: enum Representation amended
This is an automated email from the ASF dual-hosted git repository.
joergrade pushed a commit to branch ISIS-2465_Kroviz-Demo_Menu_Actions_Show_No_Output
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 89961b133110027315e945f160f9872ae807c72a
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Thu Jan 21 09:30:50 2021 +0100
enum Representation amended
---
.../org/apache/isis/client/kroviz/to/Link.kt | 17 ++++++++++--
.../isis/client/kroviz/to/PlainTransferObjects.kt | 32 ++++++++++++++++++++--
2 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/Link.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/Link.kt
index c3c7598..107f1a8 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/Link.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/Link.kt
@@ -38,6 +38,19 @@ data class Link(val rel: String = "",
: TransferObject {
private val relPrefix = "urn:org.restfulobjects:rels/"
+ private val typePrefix = "application/json;profile=\"urn:org.restfulobjects:repr-types/"
+ val relation: Relation
+ val representation: Represention
+
+ init {
+ var rawRel = rel.replace(relPrefix, "")
+ rawRel = rawRel.split(";").first() //TODO handle args=value separated by ;
+ relation = Relation.valueOf(rawRel)
+
+ var rawRep = type.replace(typePrefix, "")
+ rawRep = rawRep.replace("\"", "")
+ representation = Represention.valueOf(rawRep)
+ }
fun argMap(): Map<String, Argument?>? {
return when {
@@ -59,11 +72,11 @@ data class Link(val rel: String = "",
}
fun isProperty(): Boolean {
- return rel.endsWith("/property")
+ return relation == Relation.PROPERTY
}
fun isAction(): Boolean {
- return rel.endsWith("/action")
+ return relation == Relation.ACTION
}
fun name(): String {
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/PlainTransferObjects.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/PlainTransferObjects.kt
index 5871ffb..420ee1a 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/PlainTransferObjects.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/PlainTransferObjects.kt
@@ -112,9 +112,10 @@ data class Property(val id: String = "",
/**
- * IANA SPEC http://www.iana.org/assignments/link-relations/link-relations.xml
* RO SPEC restfulobject-spec.pdf §2.7.1
-*/
+ * extends ->
+ * IANA SPEC http://www.iana.org/assignments/link-relations/link-relations.xml
+ */
enum class Relation(val type: String) {
ACTION("action"),
DESCRIBED_BY("describedBy"), //IANA
@@ -130,7 +131,7 @@ enum class Relation(val type: String) {
PROPERTY("property"),
RETURN_TYPE("return-type"),
SELF("self"), //IANA
- SERVICE("service"), //IANA (&RO)
+ SERVICE("service"), //specified in both IANA & RO
SERVICES("services"),
UP("up"), //IANA
UPDATE("update"),
@@ -139,6 +140,31 @@ enum class Relation(val type: String) {
VERSION("version"),
}
+/**
+ * RO SPEC restfulobject-spec.pdf §2.4.1
+ */
+enum class Represention(val type: String) {
+ ACTION("action"), // missing in RO SPEC ???
+ ACTION_DESCRIPTION("action-description"),
+ ACTION_RESULT("action-result"),
+ ACTION_PARAM_DESCRIPTION("action-param-description"),
+ COLLECTION_DESCRIPTION("collection-description"),
+ DOMAIN_TYPE("domain-type"),
+ ERROR("error"),
+ HOMEPAGE("homepage"),
+ LIST("list"),
+ OBJECT("object"),
+ OBJECT_ACTION("object-action"),
+ OBJECT_COLLECTION("object-collection"),
+ OBJECT_LAYOUT_BS3("object-layout-bs3"), // missing in RO SPEC ???
+ OBJECT_PROPERTY("object-property"),
+ PROPERTY_DESCRIPTION("property-description"),
+ TYPE_LIST("type-list"),
+ TYPE_ACTION_RESULT("type-action-result"),
+ USER("user"),
+ VERSION("version"),
+}
+
@Serializable
data class Restful(override val links: List<Link> = emptyList(),
val extensions: Extensions