-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from zendesk/ben/pk_6
primary key strings!
- Loading branch information
Showing
7 changed files
with
120 additions
and
12 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
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
44 changes: 44 additions & 0 deletions
44
src/main/java/com/zendesk/maxwell/MaxwelllPKJSONObject.java
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,44 @@ | ||
package com.zendesk.maxwell; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.LinkedHashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import org.json.JSONObject; | ||
|
||
public class MaxwelllPKJSONObject extends JSONObject { | ||
private final ArrayList<String> pkKeys; | ||
|
||
public MaxwelllPKJSONObject(String db, String table, Map<String, Object> pks) { | ||
super(); | ||
|
||
this.put("database", db); | ||
this.put("table", table); | ||
this.pkKeys = new ArrayList<String>(); | ||
|
||
ArrayList<String> sortedPKs = new ArrayList<String>(pks.keySet()); | ||
Collections.sort(sortedPKs); | ||
|
||
for ( String pk : sortedPKs ) { | ||
String prefixed = "pk." + pk; | ||
this.pkKeys.add(prefixed); | ||
this.put(prefixed, pks.get(pk)); | ||
} | ||
} | ||
|
||
@Override | ||
public Set<String> keySet() { | ||
LinkedHashSet<String> set = new LinkedHashSet<>(); | ||
|
||
set.add("database"); | ||
set.add("table"); | ||
for ( String key : this.pkKeys ) { | ||
set.add(key); | ||
} | ||
|
||
return set; | ||
} | ||
|
||
} |
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