Advertisement
Guest User

service

a guest
Mar 29th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 3.18 KB | None | 0 0
  1.     override suspend fun createRowSectionById(
  2.             company: Company,
  3.             rowId: String,
  4.             templateId: String,
  5.             name: String,
  6.             thumbnail: String,
  7.             labels: List<String>
  8.     ): RowSectionData {
  9.         if (templateId.isEmpty()) {
  10.             val pageRow = datastore.get(PageRow::class.java, ObjectId(rowId)) orNotFound "page row"
  11.             val pageComponent = datastore.find(PageComponent::class.java).field("row").equal(pageRow).asList()
  12.             val rowTemplate = PageRowSection()
  13.             rowTemplate.team = company
  14.             rowTemplate.name = name
  15.             rowTemplate.thumbnail = thumbnail
  16.             datastore.find(PageRowSectionLabel::class.java)
  17.                     .field("team").equal(company)
  18.                     .field("labels").`in`(labels).get() orNotFound "label"
  19.  
  20.             rowTemplate.labels = if (labels != null) labels!!.toHashSet() else HashSet()
  21.             rowTemplate.index = if (labels != null) labels!!.joinToString() else String()
  22.             rowTemplate.setting = pageRow.setting
  23.             datastore.save(rowTemplate)
  24.  
  25.             val res = pageComponent.map { pageComp ->
  26.                 val comp = PageComponentSection()
  27.                 comp.row = rowTemplate
  28.                 comp.type = pageComp.type
  29.                 comp.setting = pageComp.setting
  30.                 comp.colomorder = pageComp.colomorder
  31.                 comp.formId = pageComp.formId
  32.                 comp.html = pageComp.html
  33.                 comp.htmlCode = pageComp.htmlCode
  34.                 comp.order = pageComp.order
  35.                 comp.selected = pageComp.selected
  36.                 comp.source = pageComp.source
  37.                 comp.textHtml = pageComp.textHtml
  38.                 comp.title = pageComp.title
  39.                 comp.titleHtml = pageComp.titleHtml
  40.                 comp.rating = pageComp.rating
  41.                 comp.priceHtml = pageComp.priceHtml
  42.                 datastore.save(comp)
  43.                 comp
  44.             }
  45.             return RowSectionData(rowTemplate, res)
  46.         }
  47.         else{
  48.             val pageRowSection = datastore.get(PageRowSection::class.java, ObjectId(templateId)) orNotFound "page row section"
  49.             val pageComponentSection = datastore.find(PageComponentSection::class.java).field("row")
  50.                     .equal(pageRowSection).asList()
  51.  
  52.             val rowTemplate = datastore.get(PageRowSection::class.java, ObjectId(rowId)) orNotFound "page row section"
  53.             val componentTemplate = datastore.find(PageComponentSection::class.java).field("row")
  54.                     .equal(pageRowSection).asList()
  55.  
  56.             rowTemplate.name = pageRowSection.name
  57.             rowTemplate.team = pageRowSection.team
  58.             rowTemplate.colomType = pageRowSection.colomType
  59.             rowTemplate.labels = pageRowSection.labels
  60.             rowTemplate.setting = pageRowSection.setting
  61.             rowTemplate.index = pageRowSection.index
  62.             rowTemplate.thumbnail = pageRowSection.thumbnail
  63.             datastore.save(rowTemplate)
  64.  
  65.             val res =  pageComponentSection.map { pageComp ->
  66.  
  67.             return RowSectionData(rowTemplate, res)
  68.         }
  69.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement