|
|
@ -5,11 +5,16 @@ import org.springframework.ui.Model;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
|
|
import ru.ulstu.extractor.model.Branch;
|
|
|
|
import ru.ulstu.extractor.mvc.model.FilterForm;
|
|
|
|
import ru.ulstu.extractor.mvc.model.FilterForm;
|
|
|
|
import ru.ulstu.extractor.mvc.model.RepoForm;
|
|
|
|
import ru.ulstu.extractor.mvc.model.RepoForm;
|
|
|
|
import ru.ulstu.extractor.service.FilteringService;
|
|
|
|
import ru.ulstu.extractor.service.FilteringService;
|
|
|
|
import ru.ulstu.extractor.service.GitRepositoryService;
|
|
|
|
import ru.ulstu.extractor.service.GitRepositoryService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
@Controller
|
|
|
|
public class GitExtractorController {
|
|
|
|
public class GitExtractorController {
|
|
|
|
private final FilteringService filteringService;
|
|
|
|
private final FilteringService filteringService;
|
|
|
@ -33,29 +38,35 @@ public class GitExtractorController {
|
|
|
|
return "filtering";
|
|
|
|
return "filtering";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/sendRepo")
|
|
|
|
@PostMapping("/sendFilter")
|
|
|
|
public String sendRepo(@ModelAttribute RepoForm repoForm, Model model) {
|
|
|
|
public String sendFilter(@ModelAttribute FilterForm filterForm, Model model) {
|
|
|
|
if (repoForm.getRepo() == null || repoForm.getRepo().isEmpty()) {
|
|
|
|
if (filterForm.getFilter() == null || filterForm.getFilter().isEmpty()) {
|
|
|
|
model.addAttribute("error", "'Git' не должно быть пустым");
|
|
|
|
model.addAttribute("error", "'Строка' не должно быть пустым");
|
|
|
|
return "newRepo";
|
|
|
|
return "filtering";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
model.addAttribute("filterForm", new FilterForm(repoForm.getRepo()));
|
|
|
|
return "resultRepo";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/newRepo", method = RequestMethod.POST, params = "send")
|
|
|
|
|
|
|
|
public String getBranch(@ModelAttribute RepoForm repoForm, Model model) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
gitRepositoryService.cloneOrUpdateRepo(repoForm.getRepo());
|
|
|
|
gitRepositoryService.cloneOrUpdateRepo(repoForm.getRepo());
|
|
|
|
|
|
|
|
List<Branch> list = gitRepositoryService.getBranches(repoForm.getRepo());
|
|
|
|
|
|
|
|
model.addAttribute("branches", list);
|
|
|
|
|
|
|
|
return "newRepo";
|
|
|
|
} catch (Exception ex) {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
model.addAttribute("error", ex.getMessage());
|
|
|
|
model.addAttribute("error", ex.getMessage());
|
|
|
|
return "newRepo";
|
|
|
|
return "newRepo";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "filtering";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/sendFilter")
|
|
|
|
@RequestMapping(value = "/newRepo", method = RequestMethod.POST, params = "next")
|
|
|
|
public String sendFilter(@ModelAttribute FilterForm filterForm, Model model) {
|
|
|
|
public String setBranch(@ModelAttribute RepoForm repoForm, Model model) {
|
|
|
|
if (filterForm.getFilter() == null || filterForm.getFilter().isEmpty()) {
|
|
|
|
model.addAttribute("filterForm", new FilterForm(repoForm.getRepo()));
|
|
|
|
model.addAttribute("error", "'Строка' не должно быть пустым");
|
|
|
|
if (repoForm.getBranch() == null) {
|
|
|
|
|
|
|
|
return "newRepo";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return "filtering";
|
|
|
|
return "filtering";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
model.addAttribute("commits", filteringService.getCommits(filterForm.getFilter(), filterForm.getFilter()));
|
|
|
|
|
|
|
|
return "resultRepo";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|