Work on using branch per project

This commit is contained in:
Nicolas Héron 2020-04-14 08:56:20 +02:00
commit b37a988a03
42 changed files with 121 additions and 70 deletions

View file

@ -189,8 +189,11 @@ public class KieRepositoryService {
return reponseMoteur;
}
public JobStatus buildProject(String url, String username, String password, String space, String project, String command, AddLog workOnGoingView, UI ui) {
String completeurl = url + "/spaces/" + space + "/projects/" + project + "/maven/" + command;
public JobStatus buildProject(String url, String username, String password, String space, String project, String branchName,String command, AddLog workOnGoingView, UI ui) {
String completeurl= url + "/spaces/" + space + "/projects/" + project + "/maven/" + command;
if (branchName!= null && branchName.length()>0){
completeurl= url + "/spaces/" + space + "/projects/" + project +"/branches/"+branchName+ "/maven/" + command;
}
logger.info("url Maven install : " + completeurl);
ResponseEntity<JobStatus> response = restTemplateKiewb
.execute(completeurl, HttpMethod.POST, requestCallback(null, username, password), clientHttpResponse -> {

View file

@ -69,12 +69,12 @@ public class ProjectPersistService {
for (PlatformProjectResponse platformProjectResponse : platformProjectResponses) {
ProjectPersist projectPersist = projectRepository.findByProjectName(new KieProject(platformProjectResponse.getSpaceName(), platformProjectResponse.getName()));
ProjectPersist projectPersist = projectRepository.findByProjectNameAndBranch(new KieProject(platformProjectResponse.getSpaceName(), platformProjectResponse.getName()),platformProjectResponse.getBranch());
if (projectPersist == null) {
projectPersist = platformProjectResponseToProjectPersist(platformProjectResponse);
projectRepository.save(projectPersist);
projectPersist=projectRepository.save(projectPersist);
addProjectToSession(projectPersist, true);
} else {
@ -101,12 +101,12 @@ public class ProjectPersistService {
}
if (isModifiable) {
projectPersists.put(projectPersist.getProjectName().toString(), projectPersist);
projectPersists.put(projectPersist.getProjectName().toString()+"-"+projectPersist.getBranch(), projectPersist);
} else {
ProjectPersist tmp = projectPersists.get(projectPersist.getProjectName().toString());
ProjectPersist tmp = projectPersists.get(projectPersist.getProjectName().toString()+"-"+projectPersist.getBranch());
if (tmp == null) {
projectPersists.put(projectPersist.getProjectName().toString(), projectPersist);
projectPersists.put(projectPersist.getProjectName().toString()+"-"+projectPersist.getBranch(), projectPersist);
}
}
@ -162,6 +162,7 @@ public class ProjectPersistService {
projectPersist.setGroupID(platformProjectResponse.getGroupId());
projectPersist.setProjectName(new KieProject(platformProjectResponse.getSpaceName(), platformProjectResponse.getName()));
projectPersist.setProjectVersion(platformProjectResponse.getVersion());
projectPersist.setBranch(platformProjectResponse.getBranch());
projectPersist.setStatus(ProjectPersist.ADEFINIR);
projectPersist.setClassNameList(platformProjectResponse.getJavaClasses());
return projectPersist;
@ -175,12 +176,12 @@ public class ProjectPersistService {
public void run() {
JobStatus result = kieRepositoryService.buildProject(config.getKiewbUrl(), userConnected.getUserName(),
userConnected.getUserPassword(), projectPersist.getProjectName().getSpaceName(), projectPersist.getProjectName().getName(), "compile", workOnGoingView, ui);
userConnected.getUserPassword(), projectPersist.getProjectName().getSpaceName(), projectPersist.getProjectName().getName(),projectPersist.getBranch(), "compile", workOnGoingView, ui);
executeWrite(url, username, password, workOnGoingView, result.getJobId(), ui);
result = kieRepositoryService.buildProject(config.getKiewbUrl(), userConnected.getUserName(),
userConnected.getUserPassword(), projectPersist.getProjectName().getSpaceName(), projectPersist.getProjectName().getName(), "install", workOnGoingView, ui);
userConnected.getUserPassword(), projectPersist.getProjectName().getSpaceName(), projectPersist.getProjectName().getName(),projectPersist.getBranch(), "install", workOnGoingView, ui);
executeWrite(url, username, password, workOnGoingView, result.getJobId(), ui);

View file

@ -11,6 +11,7 @@ public class JobStatus {
private String result;
private Date lastModified;
private String detailedResult[];
private String branchName;
@Override
public String toString() {
@ -81,4 +82,12 @@ public class JobStatus {
public void setDetailedResult(String[] detailedResult) {
this.detailedResult = detailedResult;
}
public String getBranchName() {
return branchName;
}
public void setBranchName(String branchName) {
this.branchName = branchName;
}
}

View file

@ -25,6 +25,8 @@ public class GridRuntime extends Grid<RuntimePersist> {
private TextField hostName;
private TextField branch ;
private TextField version;
private TextField status;
@ -33,6 +35,8 @@ public class GridRuntime extends Grid<RuntimePersist> {
private String strHostName = "Hostname";
private String strBranch = "Branch";
private String strVersion = "Version";
private String strStatus = "State";
@ -87,13 +91,21 @@ public class GridRuntime extends Grid<RuntimePersist> {
refreshtGrid(version.getValue(), strVersion);
});
versionCo.setHeader(version);
Grid.Column<RuntimePersist> statusCo = addColumn(runtimePersist -> runtimePersist.getStatus());
Grid.Column<RuntimePersist> statusCo = addColumn(runtimePersist -> runtimePersist.getBranch());
branch = new TextField(strBranch);
branch.setValueChangeMode(ValueChangeMode.EAGER);
branch.addValueChangeListener(e -> {
refreshtGrid(branch.getValue(), strBranch);
});
versionCo.setHeader(branch);
Grid.Column<RuntimePersist> branchCo = addColumn(runtimePersist -> runtimePersist.getStatus());
status = new TextField(strStatus);
status.setValueChangeMode(ValueChangeMode.EAGER);
status.addValueChangeListener(e -> {
refreshtGrid(status.getValue(), strVersion);
});
statusCo.setHeader(status);
branchCo.setHeader(status);
addColumn(new ComponentRenderer<>(runtimePersist -> {
List<String> serverList = new ArrayList<>();

View file

@ -34,6 +34,7 @@ public class DeploymentView extends VerticalLayout implements AddLog {
private final String strNameDeploy = "Deploy name";
private final String strNameProject = "Project name";
private final String strGroupeId = "Groupe ID";
private final String strBranchName = "Branch Name";
private final String strArtefactID = "Artefact ID";
//TEXTFIELD search
@ -49,6 +50,7 @@ public class DeploymentView extends VerticalLayout implements AddLog {
private TextField nameDeploy;
private TextField nameProject;
private TextField groupeId;
private TextField branchName;
private TextField artifactId;
private TextField processId;
private TextField serverName;
@ -92,6 +94,15 @@ public class DeploymentView extends VerticalLayout implements AddLog {
projectPersistGrid.addColumn(projectPersist -> projectPersist.getMainClass()).setHeader("ClassName")
.setComparator((projectPersist, t1) -> projectPersist.getMainClass().compareTo(t1.getMainClass()));
Grid.Column<ProjectPersist> branchCo = projectPersistGrid.addColumn(projectPersist -> projectPersist.getBranch());
branchName = new TextField(strBranchName);
branchName.setValueChangeMode(ValueChangeMode.EAGER);
branchName.addValueChangeListener(e -> {
refreshtGrid(groupeId.getValue(), strBranchName);
});
branchCo.setHeader(branchName);
Grid.Column<ProjectPersist> groupIdCo = projectPersistGrid.addColumn(projectPersist -> projectPersist.getGroupID());
groupeId = new TextField(strGroupeId);
groupeId.setValueChangeMode(ValueChangeMode.EAGER);
@ -231,7 +242,7 @@ public class DeploymentView extends VerticalLayout implements AddLog {
if (projectPersist.getStatus().equals(ProjectPersist.DEFINI)) {
getDeploymentAction().getAssociateKieServer().setEnabled(true);
getDeploymentAction().getDefinirProject().setEnabled(false);
getDeploymentAction().getDefinirProject().setEnabled(true);
getDeploymentAction().getDeployer().setEnabled(false);
} else if (projectPersist.getStatus().equals(ProjectPersist.ADEFINIR)) {