package de.unixwork.rssreader
+import de.unixwork.ui.Context
import java.sql.Connection
import java.sql.DriverManager
import java.sql.Statement
}
}
- public fun getFeedTree() : List<FeedGroup> {
+ public fun getFeedTree(context: Context) : List<FeedGroup> {
val groups = mutableListOf<FeedGroup>()
connection.createStatement().use { stmt ->
val feedName = rs.getString("feed_name")
if(currentGroup == null || currentGroup.id != groupId) {
- currentGroup = FeedGroup(groupId, groupName)
+ currentGroup = FeedGroup(context, groupId, groupName)
groups.add(currentGroup)
}
return groups
}
- public fun newFeedGroup(name: String) : FeedGroup {
+ public fun newFeedGroup(context: Context, name: String) : FeedGroup {
var groupId = 0
connection.prepareStatement("""
insert into groups (pos, name) select coalesce(max(pos), 0)+1, ? from groups
}
}
}
- return FeedGroup(groupId, name)
+ return FeedGroup(context, groupId, name)
}
public fun newFeeds(
uris: Collection<String>,
user: String? = null,
password: String? = null,
- cert: String? = null)
+ cert: String? = null) : FeedCollection
{
var feedcollectionId = -1
connection.prepareStatement("""
}
}
+ var feedCol = FeedCollection(feedcollectionId, name)
+
uris.forEach { uri ->
connection.prepareStatement("""
insert into feeds (feedcollection_id, url, auth_user, auth_password, certpath) values
stmt.execute()
}
}
+ parent.feeds.add(feedCol)
+ parent.feeds.update()
+ return feedCol
}
}
package de.unixwork.rssreader
-class FeedGroup(id: Int, name: String) {
+import de.unixwork.ui.Context
+
+class FeedGroup(context: Context, id: Int, name: String) {
val id = id
val name: String = name
-
- val feeds = mutableListOf<FeedCollection>()
+ val feeds = context.list<FeedCollection>()
}
\ No newline at end of file
val uris = urlStr.split("\n").map { it.trim() }.filter { it.isNotBlank() }
println("groupSel: ${groups?.selectedIndex}, feedName: $feedName, urlStr: $urlStr")
parent?.let {
- Database.newFeeds(it, feedName, uris, user.toString(), password.toString(), cert.toString())
+ val feedCol = Database.newFeeds(it, feedName, uris, user.toString(), password.toString(), cert.toString())
+ parent.feeds.add(feedCol)
}
}
ev.`object`.close()
if(ev.intValue == 1) {
val nameStr = name.toString()
if(!nameStr.isBlank()) {
- Database.newFeedGroup(nameStr)
+ Database.newFeedGroup(sourceList,nameStr)
} else {
println("name is null or blank")
return@dialogWindow