Skip to content

[jtx] Add builders for categories, comments, resources#405

Open
cketti wants to merge 3 commits into
mainfrom
403-jtx-categories-builder
Open

[jtx] Add builders for categories, comments, resources#405
cketti wants to merge 3 commits into
mainfrom
403-jtx-categories-builder

Conversation

@cketti
Copy link
Copy Markdown
Contributor

@cketti cketti commented May 19, 2026

Old code:

is Categories ->
for (category in prop.categories.texts)
iCalObject.categories.add(Category(text = category))
is net.fortuna.ical4j.model.property.Comment -> {
iCalObject.comments.add(
Comment().apply {
this.text = prop.value
this.language = prop.getParameter<Language>(Parameter.LANGUAGE)?.getOrNull()?.value
this.altrep = prop.getParameter<AltRep>(Parameter.ALTREP)?.getOrNull()?.value
// remove the known parameter
prop.removeAll<Property>(
Parameter.LANGUAGE,
Parameter.ALTREP
)
// save unknown parameters in the other field
this.other = JtxContract.getJsonStringFromXParameters(prop.parameterList)
})
}
is Resources ->
for (resource in prop.resources.texts)
iCalObject.resources.add(Resource(text = resource))

and

this.categories.forEach { category ->
insertBatch += BatchOperation.CpoBuilder
.newInsert(JtxContract.JtxCategory.CONTENT_URI.asSyncAdapter(collection.account))
.withValue(JtxContract.JtxCategory.ICALOBJECT_ID, id)
.withValue(JtxContract.JtxCategory.TEXT, category.text)
.withValue(JtxContract.JtxCategory.ID, category.categoryId)
.withValue(JtxContract.JtxCategory.LANGUAGE, category.language)
.withValue(JtxContract.JtxCategory.OTHER, category.other)
}
this.comments.forEach { comment ->
insertBatch += BatchOperation.CpoBuilder
.newInsert(JtxContract.JtxComment.CONTENT_URI.asSyncAdapter(collection.account))
.withValue(JtxContract.JtxComment.ICALOBJECT_ID, id)
.withValue(JtxContract.JtxComment.ID, comment.commentId)
.withValue(JtxContract.JtxComment.TEXT, comment.text)
.withValue(JtxContract.JtxComment.LANGUAGE, comment.language)
.withValue(JtxContract.JtxComment.OTHER, comment.other)
}
this.resources.forEach { resource ->
insertBatch += BatchOperation.CpoBuilder
.newInsert(JtxContract.JtxResource.CONTENT_URI.asSyncAdapter(collection.account))
.withValue(JtxContract.JtxResource.ICALOBJECT_ID, id)
.withValue(JtxContract.JtxResource.ID, resource.resourceId)
.withValue(JtxContract.JtxResource.TEXT, resource.text)
.withValue(JtxContract.JtxResource.LANGUAGE, resource.language)
.withValue(JtxContract.JtxResource.OTHER, resource.other)
}

@cketti cketti marked this pull request as ready for review May 19, 2026 15:07
@cketti cketti requested a review from ArnyminerZ May 19, 2026 15:07
@cketti cketti linked an issue May 19, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[jtx rewrite] Add builders for categories, comments, resources

1 participant