private Review copyReview(Review review) {
if (review == null) {
return null;
}
Review copiedReview = new Review();
copiedReview.setAuthor(review.getAuthor());
copiedReview.setDescription(review.getDescription());
copiedReview.setDirectory(review.getDirectory());
copiedReview.setId(review.getId());
CreationDate creationDate = review.getCreationDate();
if (creationDate != null) {
CreationDate copiedCreationDate = new CreationDate();
copiedCreationDate.setFormat(creationDate.getFormat());
copiedCreationDate.setValue(creationDate.getValue());
copiedReview.setCreationDate(copiedCreationDate);
}
Reviewers reviewers = review.getReviewers();
if (reviewers != null) {
Reviewers copiedReviewers = new Reviewers();
List<Reviewers.Entry> entryList = reviewers.getEntry();
for (Reviewers.Entry entry : entryList) {
Reviewers.Entry copiedReviewersEntry = new Reviewers.Entry();
copiedReviewersEntry.setId(entry.getId());
copiedReviewersEntry.setName(entry.getName());
copiedReviewers.getEntry().add(copiedReviewersEntry);
}
copiedReview.setReviewers(copiedReviewers);
}
Files files = review.getFiles();
if (files != null) {
Files copiedFiles = new Files();
List<Files.Entry> entryList = files.getEntry();
for (Files.Entry entry : entryList) {
Files.Entry copiedFilesEntry = new Files.Entry();
copiedFilesEntry.setName(entry.getName());
copiedFiles.getEntry().add(copiedFilesEntry);
}
copiedReview.setFiles(copiedFiles);
}
FieldItems fieldItems = review.getFieldItems();
if (fieldItems != null) {
FieldItems copiedFieldItems = new FieldItems();
List<FieldItem> fieldItemList = fieldItems.getFieldItem();
for (FieldItem fieldItem : fieldItemList) {
FieldItem copiedFieldItem = new FieldItem();
copiedFieldItem.setDefault(fieldItem.getDefault());
copiedFieldItem.setId(fieldItem.getId());
List<FieldItem.Entry> entryList = fieldItem.getEntry();
for (FieldItem.Entry entry : entryList) {
FieldItem.Entry copiedFieldItemEntry = new FieldItem.Entry();
copiedFieldItemEntry.setName(entry.getName());
copiedFieldItem.getEntry().add(copiedFieldItemEntry);
}
copiedFieldItems.getFieldItem().add(copiedFieldItem);
}
copiedReview.setFieldItems(copiedFieldItems);
}
Filters filters = review.getFilters();
if (filters != null) {
Filters copiedFilters = new Filters();
List<Phase> phaseList = filters.getPhase();
for (Phase phase : phaseList) {
Phase copiedPhase = new Phase();
copiedPhase.setName(phase.getName());
copiedPhase.setEnabled(phase.isEnabled());
// filter objects
List<Filter> filterList = phase.getFilter();
for (Filter filter : filterList) {
Filter copiedFilter = new Filter();
copiedFilter.setName(filter.getName());
copiedFilter.setValue(filter.getValue());
copiedFilter.setEnabled(filter.isEnabled());
copiedPhase.getFilter().add(copiedFilter);
}
copiedFilters.getPhase().add(copiedPhase);
}
copiedReview.setFilters(copiedFilters);
}
return copiedReview;
}