import org.onap.ccsdk.cds.controllerblueprints.core.annotations.ArtifactExpression
import org.onap.ccsdk.cds.controllerblueprints.core.annotations.AttributeExpression
-import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BluePrintsConstrain
-import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BluePrintsDataType
-import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BluePrintsProperty
+import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BlueprintsConstrain
+import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BlueprintsDataType
+import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BlueprintsProperty
import org.onap.ccsdk.cds.controllerblueprints.core.annotations.DSLExpression
import org.onap.ccsdk.cds.controllerblueprints.core.annotations.InputExpression
import org.onap.ccsdk.cds.controllerblueprints.core.annotations.OperationOutputExpression
import kotlin.reflect.KType
import kotlin.reflect.full.declaredMemberProperties
-fun <T : KClass<*>> T.asBluePrintsDataTypes(): DataType {
- val annotation = this.annotations.filter { it is BluePrintsDataType }.single() as BluePrintsDataType
- checkNotNull(annotation) { "BluePrintsDataType annotation definition not found" }
+fun <T : KClass<*>> T.asBlueprintsDataTypes(): DataType {
+ val annotation = this.annotations.filter { it is BlueprintsDataType }.single() as BlueprintsDataType
+ checkNotNull(annotation) { "BlueprintsDataType annotation definition not found" }
val dataType = DataType().apply {
id = annotation.name
version = annotation.version
property.id = this.name
val getter = this.getter
property.required = !this.returnType.isMarkedNullable
- property.type = this.returnType.asBluePrintsDataType(this.name)
+ property.type = this.returnType.asBlueprintsDataType(this.name)
if (this.returnType.arguments.isNotEmpty()) {
property.entrySchema = this.returnType.entitySchema()
}
this.annotations.forEach { fieldAnnotation ->
// println("Field : ${this.name} : Annotation : $fieldAnnotation")
when (fieldAnnotation) {
- is BluePrintsProperty ->
+ is BlueprintsProperty ->
property.description = fieldAnnotation.description
is PropertyDefaultValue ->
property.value = fieldAnnotation.value.asJsonType(property.type)
- is BluePrintsConstrain -> {
+ is BlueprintsConstrain -> {
if (property.constraints == null) property.constraints = arrayListOf()
- property.constraints!!.add(fieldAnnotation.asBluePrintConstraintClause())
+ property.constraints!!.add(fieldAnnotation.asBlueprintConstraintClause())
}
is InputExpression -> {
property.value = getInput(fieldAnnotation.propertyName)
return property
}
-internal fun BluePrintsConstrain.asBluePrintConstraintClause(): ConstraintClause {
+internal fun BlueprintsConstrain.asBlueprintConstraintClause(): ConstraintClause {
TODO()
}
internal fun <T : KType> T.entitySchema(): EntrySchema {
val entrySchema = EntrySchema()
if (this.arguments.size == 1) {
- entrySchema.type = this.arguments[0].type!!.asBluePrintsDataType("")
+ entrySchema.type = this.arguments[0].type!!.asBlueprintsDataType("")
} else if (this.arguments.size == 2) {
- entrySchema.type = this.arguments[1].type!!.asBluePrintsDataType("")
+ entrySchema.type = this.arguments[1].type!!.asBlueprintsDataType("")
}
return entrySchema
}
-internal fun <T : KType> T.asBluePrintsDataType(propertyName: String): String {
+internal fun <T : KType> T.asBlueprintsDataType(propertyName: String): String {
val simpleName = (this.classifier as? KClass<*>)?.java?.simpleName
- ?: throw BluePrintException("filed to get simple name.")
+ ?: throw BlueprintException("filed to get simple name.")
return when (simpleName) {
- "String", "Date" -> BluePrintConstants.DATA_TYPE_STRING
- "int" -> BluePrintConstants.DATA_TYPE_INTEGER
- "Boolean" -> BluePrintConstants.DATA_TYPE_BOOLEAN
- "Float" -> BluePrintConstants.DATA_TYPE_FLOAT
- "Double" -> BluePrintConstants.DATA_TYPE_DOUBLE
- "List" -> BluePrintConstants.DATA_TYPE_LIST
- "Map" -> BluePrintConstants.DATA_TYPE_MAP
- "Object", "JsonNode", "ObjectNode", "ArrayNode" -> BluePrintConstants.DATA_TYPE_JSON
+ "String", "Date" -> BlueprintConstants.DATA_TYPE_STRING
+ "int" -> BlueprintConstants.DATA_TYPE_INTEGER
+ "Boolean" -> BlueprintConstants.DATA_TYPE_BOOLEAN
+ "Float" -> BlueprintConstants.DATA_TYPE_FLOAT
+ "Double" -> BlueprintConstants.DATA_TYPE_DOUBLE
+ "List" -> BlueprintConstants.DATA_TYPE_LIST
+ "Map" -> BlueprintConstants.DATA_TYPE_MAP
+ "Object", "JsonNode", "ObjectNode", "ArrayNode" -> BlueprintConstants.DATA_TYPE_JSON
else -> simpleName
}
}