Skip to content

Commit

Permalink
upgraded to data-anon version 0.9.3 with new data & datetime strategies
Browse files Browse the repository at this point in the history
  • Loading branch information
sunitparekh committed Mar 14, 2018
1 parent 93b658e commit c29181e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<dependency>
<groupId>com.github.dataanon</groupId>
<artifactId>data-anon</artifactId>
<version>0.9.2</version>
<version>0.9.3</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
Expand Down
35 changes: 20 additions & 15 deletions src/main/kotlin/com/github/dataanon/Anonymizer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import com.github.dataanon.model.DbConfig
import com.github.dataanon.model.Field
import com.github.dataanon.model.Record
import com.github.dataanon.strategy.AnonymizationStrategy
import com.github.dataanon.strategy.datetime.DateRandomDelta
import com.github.dataanon.strategy.datetime.DateTimeRandomDelta
import com.github.dataanon.strategy.list.PickFromDatabase
import com.github.dataanon.strategy.number.FixedDouble
import com.github.dataanon.strategy.string.FixedString
import java.time.Duration

fun main(args: Array<String>) {

Expand All @@ -20,20 +23,22 @@ fun main(args: Array<String>) {
val dest = DbConfig("jdbc:h2:tcp://localhost/~/movies_dest", "sa", "")

Whitelist(source,dest)
.table("MOVIES") {
where("GENRE = 'Drama'")
limit(1_00_000)
whitelist("MOVIE_ID","RELEASE_DATE")
anonymize("TITLE").using(object: AnonymizationStrategy<String>{
override fun anonymize(field: Field<String>, record: Record): String = "MY MOVIE ${record.rowNum}"
})
anonymize("GENRE").using(FixedString("Action"))
}
.table("RATINGS") {
whitelist("MOVIE_ID","USER_ID","CREATED_AT")
anonymize("RATING").using(FixedDouble(4.3))
}
.execute(true)
.table("MOVIES") {
where("GENRE = 'Drama'")
limit(1_00_000)
whitelist("MOVIE_ID")
anonymize("TITLE").using(object: AnonymizationStrategy<String>{
override fun anonymize(field: Field<String>, record: Record): String = "MY MOVIE ${record.rowNum}"
})
anonymize("GENRE").using(PickFromDatabase<String>(source,"SELECT DISTINCT GENRE FROM MOVIES"))
anonymize("RELEASE_DATE").using(DateRandomDelta(10))
}
.table("RATINGS") {
whitelist("MOVIE_ID","USER_ID")
anonymize("RATING").using(FixedDouble(4.3))
anonymize("CREATED_AT").using(DateTimeRandomDelta(Duration.ofSeconds(2000)))
}
.execute(true)
}


0 comments on commit c29181e

Please sign in to comment.