Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.sudicode.fb2gh.FB2GHException;
- import com.sudicode.fb2gh.fogbugz.FBCase;
- import com.sudicode.fb2gh.fogbugz.FBFactory;
- import com.sudicode.fb2gh.fogbugz.FogBugz;
- import com.sudicode.fb2gh.github.GHFactory;
- import com.sudicode.fb2gh.github.GHLabel;
- import com.sudicode.fb2gh.github.GHRepo;
- import com.sudicode.fb2gh.migrate.FBAttachmentConverter;
- import com.sudicode.fb2gh.migrate.FBCaseLabeler;
- import com.sudicode.fb2gh.migrate.GHAttachmentUploader;
- import com.sudicode.fb2gh.migrate.GHAttachmentUploader.Browser;
- import com.sudicode.fb2gh.migrate.Migrator;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.function.Predicate;
- public class FB2GHExample {
- public static void main(String[] args) {
- try {
- /* ==================================================
- * Required configuration
- * ================================================== */
- // FogBugz info
- String fogBugzURL = ""; // FogBugz URL goes here.
- String fogBugzAPIToken = ""; // FogBugz API key goes here.
- String fogBugzCaseQuery = "\"\""; // Enter search query here, or leave as is.
- // GitHub info
- String githubAPIToken = ""; // GitHub API key goes here.
- String githubRepoOwner = ""; // GitHub repo owner goes here.
- String githubRepoName = ""; // GitHub repo name goes here.
- // Objects necessary to construct the migrator
- FogBugz fogBugz = FBFactory.newFogBugz(fogBugzURL, fogBugzAPIToken);
- List<FBCase> caseList = fogBugz.searchCases(fogBugzCaseQuery);
- GHRepo ghRepo = GHFactory.newGitHub(githubAPIToken).getRepo(githubRepoOwner, githubRepoName);
- /* ==================================================
- * Optional configuration
- * ================================================== */
- // Map FogBugz names to GitHub usernames
- Map<String, String> usernameMap = new HashMap<>();
- usernameMap.put("Alice Adams", "aliceadams");
- usernameMap.put("Bob Brown", "bobbrown");
- usernameMap.put("Carol Cage", "carolcage");
- // Close cases that are not active
- Predicate<FBCase> closeIf = fbCase -> !fbCase.getStatus().equals("Active");
- // Label issues with their original FogBugz case ID, category, and priority
- FBCaseLabeler labeler = fbCase -> {
- List<GHLabel> list = new ArrayList<>();
- list.add(new GHLabel("F" + fbCase.getId(), "92602c"));
- list.add(new GHLabel(fbCase.getCategory()));
- list.add(new GHLabel(fbCase.getPriority()));
- return list;
- };
- // Upload attachments to GitHub (Experimental)
- String githubUser = ""; // GitHub username goes here.
- String githubPassword = ""; // GitHub password goes here.
- Browser browser = Browser.FIREFOX; // Change browser here, or leave as is.
- FBAttachmentConverter converter = new GHAttachmentUploader.Builder(githubUser, githubPassword, ghRepo, browser).build();
- /* ==================================================
- * Perform the migration
- * ================================================== */
- Migrator migrator = new Migrator.Builder(fogBugz, caseList, ghRepo)
- .usernameMap(usernameMap)
- .closeIf(closeIf)
- .fbCaseLabeler(labeler)
- .fbAttachmentConverter(converter)
- .build();
- migrator.migrate();
- } catch (FB2GHException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement