commit
6f86742d5b
4 changed files with 73 additions and 22 deletions
|
|
@ -106,7 +106,7 @@ public class ProjectPersistService {
|
|||
return projectPersist;
|
||||
}
|
||||
|
||||
public void createProjectGroupIfNeeded(String projectName, KieWorkbench kieWorkbench,ProjectPersist projectPersist,UserGroups workspaceUserGroup ) {
|
||||
public void createProjectGroupIfNeeded(String projectName, KieWorkbench kieWorkbench, ProjectPersist projectPersist, UserGroups workspaceUserGroup) {
|
||||
UserGroups userGroups = userGroupsRepository.findByName("prj_" + projectName);
|
||||
if (userGroups == null) {
|
||||
UserGroups projectGroup = new UserGroups(UUID.randomUUID().toString(), "prj_" + projectName);
|
||||
|
|
@ -119,7 +119,7 @@ public class ProjectPersistService {
|
|||
groupUser.getUserGroups().add(projectGroup);
|
||||
groupUser.getUserRoles().add(userRolesRepository.findByName("analyst"));
|
||||
userRepository.save(groupUser);
|
||||
}else{
|
||||
} else {
|
||||
userGroups.setWorkspaceUserGroup(workspaceUserGroup);
|
||||
userGroupsRepository.save(userGroups);
|
||||
}
|
||||
|
|
@ -144,30 +144,39 @@ public class ProjectPersistService {
|
|||
|
||||
public Map<String, ProjectPersist> findProjectsConnectedUser() {
|
||||
//VaadinSession.getCurrent().get
|
||||
boolean isAdmin =false;
|
||||
boolean isAdmin = false;
|
||||
|
||||
UserConnected userConnected = userConnectedService.getUserConnected();
|
||||
User user = userRepository.findByLogin(userConnected.getUserName());
|
||||
for (UserRoles userRoles : user.getUserRoles()){
|
||||
if ("admin".equals(userRoles.getName())){
|
||||
isAdmin=true;
|
||||
for (UserRoles userRoles : user.getUserRoles()) {
|
||||
if ("admin".equals(userRoles.getName())) {
|
||||
isAdmin = true;
|
||||
}
|
||||
}
|
||||
List<ProjectPersist> projectPersists = new ArrayList<>();
|
||||
if (isAdmin) {
|
||||
projectPersists = projectRepository.findAll();
|
||||
}else {
|
||||
} else {
|
||||
List<UserGroups> userGroups = user.getUserGroups();
|
||||
|
||||
}
|
||||
Map<String, ProjectPersist> map = new HashMap<>();
|
||||
for (ProjectPersist projectPersist : projectPersists){
|
||||
map.put(projectPersist.getProjectName().toString() + "-" + projectPersist.getBranch(),projectPersist);
|
||||
for (ProjectPersist projectPersist : projectPersists) {
|
||||
map.put(projectPersist.getProjectName().toString() + "-" + projectPersist.getBranch(), projectPersist);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public void removeAssociation(ProjectPersist projectPersist, List<RuntimePersist> runtimesRemove) {
|
||||
for (RuntimePersist runtimePersist : runtimesRemove) {
|
||||
List<ContainerRuntimePojoPersist> elts = containerRuntimeRepository.findByServerNameAndContainerId(runtimePersist.getServerName(), projectPersist.getContainerID());
|
||||
for (ContainerRuntimePojoPersist elt : elts) {
|
||||
elt.setStatus(ContainerRuntimePojoPersist.STATUS.TODELETE.name());
|
||||
containerRuntimeRepository.save(elt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean associate(ProjectPersist projectPersist, List<RuntimePersist> runtimePersists) {
|
||||
|
|
@ -189,10 +198,27 @@ public class ProjectPersistService {
|
|||
newContainer.setServerName(runtimePersist.getServerName());
|
||||
newContainer.setGroupId(projectPersist.getGroupID());
|
||||
newContainer.setArtifactId(projectPersist.getArtifactID());
|
||||
|
||||
newContainer.setVersion(projectPersist.getProjectVersion());
|
||||
containerRepository.save(newContainer);
|
||||
List<ContainerRuntimePojoPersist> elts = containerRuntimeRepository.findByServerNameAndContainerId(runtimePersist.getServerName(), projectPersist.getContainerID());
|
||||
if (!elts.isEmpty()) {
|
||||
for (ContainerRuntimePojoPersist elt : elts) {
|
||||
elt.setStatus(ContainerRuntimePojoPersist.STATUS.TODEPLOY.name());
|
||||
containerRuntimeRepository.save(elt);
|
||||
}
|
||||
} else {
|
||||
|
||||
ContainerRuntimePojoPersist runtimePojoPersist = new ContainerRuntimePojoPersist();
|
||||
runtimePojoPersist.setServerName(runtimePersist.getServerName());
|
||||
runtimePojoPersist.setHostname(runtimePersist.getHostname());
|
||||
runtimePojoPersist.setContainerId(projectPersist.getContainerID());
|
||||
runtimePojoPersist.setStatus(ContainerRuntimePojoPersist.STATUS.TODEPLOY.name());
|
||||
containerRuntimeRepository.save(runtimePojoPersist);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String hostName = runtimePersist.getServerUrl() + "/api/" + projectPersist.getContainerID();
|
||||
reverseProxyUpdate.getServerNames().add(hostName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,20 +49,34 @@ public class AssociateProjectKie extends VerticalLayout {
|
|||
add(associer);
|
||||
associer.addClickListener(buttonClickEvent -> {
|
||||
List<RuntimePersist> lstToSave = new ArrayList<>();
|
||||
List<RuntimePersist> lstToDelete = new ArrayList<>();
|
||||
for (RuntimePersist runtimePersist : gridRuntime.getSelectedItems()) {
|
||||
lstToSave.add(runtimePersist);
|
||||
}
|
||||
for (RuntimePersist runtime : gridRuntime.getRuntimeSelected()){
|
||||
boolean found=false;
|
||||
for (RuntimePersist runtimePersist : gridRuntime.getSelectedItems()) {
|
||||
if (runtimePersist.getServerName().equals(runtime.getServerName())
|
||||
&& runtimePersist.getServerPort().equals(runtime.getServerPort())){
|
||||
found=true;
|
||||
}
|
||||
|
||||
}
|
||||
if (!found){
|
||||
lstToDelete.add(runtime);
|
||||
}
|
||||
}
|
||||
if (!lstToDelete.isEmpty()){
|
||||
projectPersistService.removeAssociation(projectPersist,lstToDelete);
|
||||
}
|
||||
if (!lstToSave.isEmpty()) {
|
||||
|
||||
boolean tmp = projectPersistService.associate(projectPersist, lstToSave);
|
||||
projectPersistService.associate(projectPersist, lstToSave);
|
||||
|
||||
if (tmp) {
|
||||
}
|
||||
if (!lstToDelete.isEmpty() || !lstToSave.isEmpty()){
|
||||
deploymentView.setDataProvider();
|
||||
dialog.close();
|
||||
} else {
|
||||
associer.setEnabled(false);
|
||||
Notification.show("There is already a project of this name on this runtime");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
|||
|
||||
private String strStatus = "State";
|
||||
|
||||
private List<RuntimePersist> runtimeSelected= new ArrayList<>();
|
||||
|
||||
private transient ProjectPersistService projectPersistService;
|
||||
private transient RuntimeService runtimeService;
|
||||
|
||||
|
|
@ -146,12 +148,17 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
|||
return columnPredicate;
|
||||
}
|
||||
|
||||
public List<RuntimePersist> getRuntimeSelected() {
|
||||
return runtimeSelected;
|
||||
}
|
||||
|
||||
public void setDataProvider() {
|
||||
|
||||
List<RuntimePersist> runtimePersists = runtimeService.getRuntimeRepository().findAll();
|
||||
|
||||
if (runtimePersists != null) {
|
||||
List<RuntimePersist> runtimeToShow = new ArrayList<>();
|
||||
Map<String, String> urlMap = new HashMap<>();
|
||||
List<RuntimePersist> runtimeToShow= new ArrayList<>();
|
||||
for (RuntimePersist runtimePersist : runtimePersists) {
|
||||
if (urlMap.containsKey(runtimePersist.getServerName()) == false) {
|
||||
|
||||
|
|
@ -161,6 +168,7 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
|||
runtimeToShow.add(runtimePersist1);
|
||||
if (projectPersist.getServerNames().contains(runtimePersist1.getServerName())) {
|
||||
selectionModel.select(runtimePersist1);
|
||||
runtimeSelected.add(runtimePersist);
|
||||
}
|
||||
} else {
|
||||
runtimeToShow.add(runtimePersist1);
|
||||
|
|
|
|||
|
|
@ -176,7 +176,6 @@ public class KieServiceCommon {
|
|||
}
|
||||
try {
|
||||
for (KieContainerResource kieContainerResource : this.server.getServerState().getResult().getContainers()) {
|
||||
this.createContainer(kieContainerResource.getContainerId(), kieContainerResource);
|
||||
ContainerPojoPersist container = containerRepository.findByServerNameAndContainerId(serverName, kieContainerResource.getContainerId());
|
||||
if (container != null) {
|
||||
ContainerRuntimePojoPersist containerRuntimePojoPersist = containerRuntimeRepository.findByServerNameAndContainerIdAndHostname(serverName, kieContainerResource.getContainerId(), hostName);
|
||||
|
|
@ -187,10 +186,11 @@ public class KieServiceCommon {
|
|||
containerRuntimePojoPersist.setHostname(hostName);
|
||||
containerRuntimePojoPersist.setStatus(ContainerRuntimePojoPersist.STATUS.UP.name());
|
||||
containerRuntimeRepository.save(containerRuntimePojoPersist);
|
||||
}
|
||||
this.createContainer(kieContainerResource.getContainerId(), kieContainerResource);
|
||||
this.initCamelBusinessRoute(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.info("initCamelBusinessRoutes", e);
|
||||
}
|
||||
|
|
@ -406,8 +406,11 @@ public class KieServiceCommon {
|
|||
} else if (element.getStatus().equals(ContainerRuntimePojoPersist.STATUS.TODELETE.name())) {
|
||||
this.disposeContainer(element.getContainerId());
|
||||
this.deleteCamelBusinessRoute(element.getContainerId());
|
||||
element.setStatus(ContainerRuntimePojoPersist.STATUS.DOWN.toString());
|
||||
containerRuntimeRepository.save(element);
|
||||
containerRuntimeRepository.delete(element);
|
||||
if (containerPojoPersist!= null){
|
||||
containerRepository.delete(containerPojoPersist);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue