All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.innovenso.townplanner.io.concepts.DataAttributePropertyExcelIO.scala Maven / Gradle / Ivy

package com.innovenso.townplanner.io.concepts

import com.innovenso.townplanner.io.concepts.ExcelFields._
import com.innovenso.townplanner.model.EnterpriseArchitecture
import com.innovenso.townplanner.model.concepts.properties.{
  DataAttribute,
  HasDataAttributes
}

object DataAttributePropertyExcelIO
    extends PropertiesExcelIO[HasDataAttributes, DataAttribute] {
  override def propertyClass: Class[DataAttribute] = classOf[DataAttribute]

  override def propertyHolderClass: Class[HasDataAttributes] =
    classOf[HasDataAttributes]

  override def sheetName: String = "Data Attributes"

  override def headerLabels: List[String] =
    List(NAME, DESCRIPTION, REQUIRED, MULTIPLE, DATA_TYPE)

  override def cellValues(property: DataAttribute): List[String] =
    List(
      property.name,
      property.description.getOrElse(""),
      property.required.toString,
      property.multiple.toString,
      property.dataType.getOrElse("")
    )

  override def properties(holder: HasDataAttributes): List[DataAttribute] =
    holder.dataAttributes

  override protected def readProperty(
      props: PropertyProperties,
      enterpriseArchitecture: EnterpriseArchitecture
  ): Unit = {
    val modelComponent = enterpriseArchitecture.hasProperty(
      props.conceptKey,
      DataAttribute(
        name = props.name,
        description = props.descriptionOption,
        required = props.bool(REQUIRED),
        multiple = props.bool(MULTIPLE),
        dataType = props.option(DATA_TYPE)
      )
    )
    println(s"imported data attribute on $modelComponent")
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy