Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- override suspend fun createRowSectionById(
- company: Company,
- rowId: String,
- templateId: String,
- name: String,
- thumbnail: String,
- labels: List<String>
- ): RowSectionData {
- if (templateId.isEmpty()) {
- val pageRow = datastore.get(PageRow::class.java, ObjectId(rowId)) orNotFound "page row"
- val pageComponent = datastore.find(PageComponent::class.java).field("row").equal(pageRow).asList()
- val rowTemplate = PageRowSection()
- rowTemplate.team = company
- rowTemplate.name = name
- rowTemplate.thumbnail = thumbnail
- datastore.find(PageRowSectionLabel::class.java)
- .field("team").equal(company)
- .field("labels").`in`(labels).get() orNotFound "label"
- rowTemplate.labels = if (labels != null) labels!!.toHashSet() else HashSet()
- rowTemplate.index = if (labels != null) labels!!.joinToString() else String()
- rowTemplate.setting = pageRow.setting
- datastore.save(rowTemplate)
- val res = pageComponent.map { pageComp ->
- val comp = PageComponentSection()
- comp.row = rowTemplate
- comp.type = pageComp.type
- comp.setting = pageComp.setting
- comp.colomorder = pageComp.colomorder
- comp.formId = pageComp.formId
- comp.html = pageComp.html
- comp.htmlCode = pageComp.htmlCode
- comp.order = pageComp.order
- comp.selected = pageComp.selected
- comp.source = pageComp.source
- comp.textHtml = pageComp.textHtml
- comp.title = pageComp.title
- comp.titleHtml = pageComp.titleHtml
- comp.rating = pageComp.rating
- comp.priceHtml = pageComp.priceHtml
- datastore.save(comp)
- comp
- }
- return RowSectionData(rowTemplate, res)
- }
- else{
- val pageRowSection = datastore.get(PageRowSection::class.java, ObjectId(templateId)) orNotFound "page row section"
- val pageComponentSection = datastore.find(PageComponentSection::class.java).field("row")
- .equal(pageRowSection).asList()
- val rowTemplate = datastore.get(PageRowSection::class.java, ObjectId(rowId)) orNotFound "page row section"
- val componentTemplate = datastore.find(PageComponentSection::class.java).field("row")
- .equal(pageRowSection).asList()
- rowTemplate.name = pageRowSection.name
- rowTemplate.team = pageRowSection.team
- rowTemplate.colomType = pageRowSection.colomType
- rowTemplate.labels = pageRowSection.labels
- rowTemplate.setting = pageRowSection.setting
- rowTemplate.index = pageRowSection.index
- rowTemplate.thumbnail = pageRowSection.thumbnail
- datastore.save(rowTemplate)
- val res = pageComponentSection.map { pageComp ->
- return RowSectionData(rowTemplate, res)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement