1
0
Fork 0

Add mergeWith and copyTo method

master
Toni Van de Voorde 2014-07-23 11:38:56 +02:00
parent 020046b781
commit 8f111d036c
1 changed files with 46 additions and 0 deletions

View File

@ -47,6 +47,52 @@ public class Version extends Resource {
if (json != null)
deserialise(json);
}
/**
* Merges the given version with current version
*
* @param version
* The version to merge
*/
public void mergeWith(Version version) {
JSONObject req = new JSONObject();
req.put("description", version.getDescription());
req.put("name", version.getName());
req.put("archived", version.isArchived());
req.put("released", version.isReleased());
req.put("releaseDate", version.getReleaseDate());
try {
restclient.put(Resource.getBaseUri() + "version/" + id, req);
} catch (Exception ex) {
throw new RuntimeException("Failed to merge", ex);
}
}
/**
* Copies the version to the given project
*
* @param project
* The project the version will be copied to
*/
public void copyTo(Project project) {
JSONObject req = new JSONObject();
req.put("description", getDescription());
req.put("name", getName());
req.put("archived", isArchived());
req.put("released", isReleased());
req.put("releaseDate", getReleaseDate());
req.put("project", project.getKey());
req.put("projectId", project.getId());
try {
restclient.post(Resource.getBaseUri() + "version/", req);
} catch (Exception ex) {
throw new RuntimeException("Failed to copy to project '" + project.getKey() + "'", ex);
}
}
/**
* Retrieves the given version record.