Rename webdavUrl to url in CloudEntity
This commit is contained in:
parent
9abf1f6eb6
commit
0f42ddd964
@ -74,7 +74,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
greendao {
|
greendao {
|
||||||
schemaVersion 4
|
schemaVersion 5
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations.all {
|
configurations.all {
|
||||||
|
@ -22,13 +22,15 @@ class DatabaseUpgrades {
|
|||||||
Upgrade0To1 upgrade0To1, //
|
Upgrade0To1 upgrade0To1, //
|
||||||
Upgrade1To2 upgrade1To2, //
|
Upgrade1To2 upgrade1To2, //
|
||||||
Upgrade2To3 upgrade2To3, //
|
Upgrade2To3 upgrade2To3, //
|
||||||
Upgrade3To4 upgrade3To4) {
|
Upgrade3To4 upgrade3To4, //
|
||||||
|
Upgrade4To5 upgrade4To5) {
|
||||||
|
|
||||||
availableUpgrades = defineUpgrades( //
|
availableUpgrades = defineUpgrades( //
|
||||||
upgrade0To1, //
|
upgrade0To1, //
|
||||||
upgrade1To2, //
|
upgrade1To2, //
|
||||||
upgrade2To3, //
|
upgrade2To3, //
|
||||||
upgrade3To4);
|
upgrade3To4, //
|
||||||
|
upgrade4To5);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Comparator<DatabaseUpgrade> reverseOrder() {
|
private static Comparator<DatabaseUpgrade> reverseOrder() {
|
||||||
|
40
data/src/main/java/org/cryptomator/data/db/Upgrade4To5.kt
Normal file
40
data/src/main/java/org/cryptomator/data/db/Upgrade4To5.kt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package org.cryptomator.data.db
|
||||||
|
|
||||||
|
import org.greenrobot.greendao.database.Database
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
internal class Upgrade4To5 @Inject constructor() : DatabaseUpgrade(4, 5) {
|
||||||
|
|
||||||
|
override fun internalApplyTo(db: Database, origin: Int) {
|
||||||
|
db.beginTransaction()
|
||||||
|
try {
|
||||||
|
changeWebdavUrlInCloudEntityToUrl(db)
|
||||||
|
db.setTransactionSuccessful()
|
||||||
|
} finally {
|
||||||
|
db.endTransaction()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun changeWebdavUrlInCloudEntityToUrl(db: Database) {
|
||||||
|
Sql.alterTable("CLOUD_ENTITY").renameTo("CLOUD_ENTITY_OLD").executeOn(db)
|
||||||
|
|
||||||
|
Sql.createTable("CLOUD_ENTITY") //
|
||||||
|
.id() //
|
||||||
|
.requiredText("TYPE") //
|
||||||
|
.optionalText("ACCESS_TOKEN") //
|
||||||
|
.optionalText("URL") //
|
||||||
|
.optionalText("USERNAME") //
|
||||||
|
.optionalText("WEBDAV_CERTIFICATE") //
|
||||||
|
.executeOn(db);
|
||||||
|
|
||||||
|
Sql.insertInto("CLOUD_ENTITY") //
|
||||||
|
.select("_id", "TYPE", "ACCESS_TOKEN", "WEBDAV_URL", "USERNAME", "WEBDAV_CERTIFICATE") //
|
||||||
|
.columns("_id", "TYPE", "ACCESS_TOKEN", "URL", "USERNAME", "WEBDAV_CERTIFICATE") //
|
||||||
|
.from("CLOUD_ENTITY_OLD") //
|
||||||
|
.executeOn(db)
|
||||||
|
|
||||||
|
Sql.dropTable("CLOUD_ENTITY_OLD").executeOn(db)
|
||||||
|
}
|
||||||
|
}
|
@ -16,18 +16,18 @@ public class CloudEntity extends DatabaseEntity {
|
|||||||
|
|
||||||
private String accessToken;
|
private String accessToken;
|
||||||
|
|
||||||
private String webdavUrl;
|
private String url;
|
||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
private String webdavCertificate;
|
private String webdavCertificate;
|
||||||
|
|
||||||
@Generated(hash = 2078985174)
|
@Generated(hash = 361171073)
|
||||||
public CloudEntity(Long id, @NotNull String type, String accessToken, String webdavUrl, String username, String webdavCertificate) {
|
public CloudEntity(Long id, @NotNull String type, String accessToken, String url, String username, String webdavCertificate) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
this.webdavUrl = webdavUrl;
|
this.url = url;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.webdavCertificate = webdavCertificate;
|
this.webdavCertificate = webdavCertificate;
|
||||||
}
|
}
|
||||||
@ -60,12 +60,12 @@ public class CloudEntity extends DatabaseEntity {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWebdavUrl() {
|
public String getUrl() {
|
||||||
return webdavUrl;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWebdavUrl(String webdavUrl) {
|
public void setUrl(String url) {
|
||||||
this.webdavUrl = webdavUrl;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
|
@ -54,7 +54,7 @@ public class CloudEntityMapper extends EntityMapper<CloudEntity, Cloud> {
|
|||||||
case WEBDAV:
|
case WEBDAV:
|
||||||
return aWebDavCloudCloud() //
|
return aWebDavCloudCloud() //
|
||||||
.withId(entity.getId()) //
|
.withId(entity.getId()) //
|
||||||
.withUrl(entity.getWebdavUrl()) //
|
.withUrl(entity.getUrl()) //
|
||||||
.withUsername(entity.getUsername()) //
|
.withUsername(entity.getUsername()) //
|
||||||
.withPassword(entity.getAccessToken()) //
|
.withPassword(entity.getAccessToken()) //
|
||||||
.withCertificate(entity.getWebdavCertificate()) //
|
.withCertificate(entity.getWebdavCertificate()) //
|
||||||
@ -87,7 +87,7 @@ public class CloudEntityMapper extends EntityMapper<CloudEntity, Cloud> {
|
|||||||
break;
|
break;
|
||||||
case WEBDAV:
|
case WEBDAV:
|
||||||
result.setAccessToken(((WebDavCloud) domainObject).password());
|
result.setAccessToken(((WebDavCloud) domainObject).password());
|
||||||
result.setWebdavUrl(((WebDavCloud) domainObject).url());
|
result.setUrl(((WebDavCloud) domainObject).url());
|
||||||
result.setUsername(((WebDavCloud) domainObject).username());
|
result.setUsername(((WebDavCloud) domainObject).username());
|
||||||
result.setWebdavCertificate(((WebDavCloud) domainObject).certificate());
|
result.setWebdavCertificate(((WebDavCloud) domainObject).certificate());
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user