-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backends): create verbatim sheets.
* Create a verbatim for one talk * Create verbatim for every talks
- Loading branch information
1 parent
93ab20a
commit fc679ed
Showing
9 changed files
with
243 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...end/src/main/java/org/gdglille/devfest/backend/internals/helpers/drive/DriveDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.gdglille.devfest.backend.internals.helpers.drive | ||
|
||
import com.google.api.services.drive.Drive | ||
|
||
interface DriveDataSource { | ||
fun findDriveByName(name: String): String? | ||
fun findFolderByName(driveId: String, parentId: String?, name: String): String? | ||
fun findFileByName(driveId: String, parentId: String?, name: String): String? | ||
fun copyFile(driveId: String, fileId: String, name: String): String | ||
fun moveFile(driveId: String, fileId: String, folderId: String): List<String> | ||
fun grantPermission(fileId: String, email: String) | ||
|
||
object Factory { | ||
fun create(service: Drive): DriveDataSource = GoogleDriveDataSource(service) | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
...c/main/java/org/gdglille/devfest/backend/internals/helpers/drive/GoogleDriveDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.gdglille.devfest.backend.internals.helpers.drive | ||
|
||
import com.google.api.services.drive.Drive | ||
import com.google.api.services.drive.model.File | ||
import com.google.api.services.drive.model.Permission | ||
|
||
private const val PageSize = 10 | ||
|
||
class GoogleDriveDataSource(private val service: Drive) : DriveDataSource { | ||
override fun findDriveByName(name: String): String? { | ||
val drives = service.drives().list().apply { | ||
pageSize = PageSize | ||
fields = "nextPageToken, drives(id, name)" | ||
}.execute() | ||
return drives.drives.find { it.name == name }?.id | ||
} | ||
|
||
override fun findFolderByName(driveId: String, parentId: String?, name: String): String? { | ||
return service.files().list().apply { | ||
this.driveId = driveId | ||
includeItemsFromAllDrives = true | ||
supportsAllDrives = true | ||
corpora = "drive" | ||
pageSize = PageSize | ||
fields = "nextPageToken, files(id)" | ||
this.q = "name='$name'${parentId?.let { " and parents='$parentId'" } ?: run { "" }}" | ||
}.execute().files.firstOrNull()?.id | ||
} | ||
|
||
override fun findFileByName(driveId: String, parentId: String?, name: String): String? { | ||
return service.files().list().apply { | ||
this.driveId = driveId | ||
includeItemsFromAllDrives = true | ||
supportsAllDrives = true | ||
corpora = "drive" | ||
pageSize = PageSize | ||
fields = "nextPageToken, files(id)" | ||
this.q = "name='$name'${parentId?.let { " and parents='$parentId'" } ?: run { "" }}" | ||
}.execute().files.firstOrNull()?.id | ||
} | ||
|
||
override fun copyFile(driveId: String, fileId: String, name: String): String { | ||
val file = File().apply { | ||
this.name = name | ||
this.mimeType = "application/vnd.google-apps.spreadsheet" | ||
parents = listOf(driveId) | ||
} | ||
return service.files().copy(fileId, file).apply { | ||
supportsAllDrives = true | ||
fields = "id" | ||
}.execute().id | ||
} | ||
|
||
override fun moveFile(driveId: String, fileId: String, folderId: String): List<String> { | ||
val file = service.files()[fileId].apply { | ||
supportsAllDrives = true | ||
fields = "parents" | ||
}.execute() | ||
return service.files().update(fileId, null).apply { | ||
supportsAllDrives = true | ||
addParents = folderId | ||
removeParents = file.parents.joinToString(",") | ||
fields = "parents" | ||
}.execute().parents | ||
} | ||
|
||
override fun grantPermission(fileId: String, email: String) { | ||
val userPermission: Permission = Permission() | ||
.setType("user") | ||
.setRole("writer") | ||
userPermission.setEmailAddress(email) | ||
service.permissions().create(fileId, userPermission).setFields("id").execute() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
shared/models/src/commonMain/kotlin/org/gdglille/devfest/models/inputs/TalkVerbatimInput.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.gdglille.devfest.models.inputs | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class TalkVerbatimInput( | ||
@SerialName("drive_name") | ||
val driveName: String, | ||
@SerialName("event_folder") | ||
val eventFolder: String, | ||
@SerialName("target_folder") | ||
val targetFolder: String, | ||
@SerialName("template_name") | ||
val templateName: String | ||
) : Validator { | ||
override fun validate(): List<String> = emptyList() | ||
} |