@Override public int hashCode() { int hash = 7; hash = 31 * hash + getInstallers().hashCode(); hash = 31 * hash + getEnv().hashCode(); hash = 31 * hash + getAttributes().hashCode(); hash = 31 * hash + getServers().hashCode(); hash = 31 * hash + getVolumes().hashCode(); return hash; }
public EnvironmentImpl(Recipe recipe, Map<String, ? extends MachineConfig> machines) { if (recipe != null) { this.recipe = new RecipeImpl(recipe); } if (machines != null) { this.machines = machines .entrySet() .stream() .collect( Collectors.toMap( Map.Entry::getKey, entry -> new MachineConfigImpl(entry.getValue()))); } }
private void showInstallers() { String defaultEnvironmentName = appContext.getWorkspace().getConfig().getDefaultEnv(); EnvironmentImpl defaultEnvironment = appContext.getWorkspace().getConfig().getEnvironments().get(defaultEnvironmentName); if (defaultEnvironment == null) { return; } Map<String, MachineConfigImpl> machines = defaultEnvironment.getMachines(); for (final String machineName : machines.keySet()) { MachineConfigImpl machineConfig = machines.get(machineName); for (String installerId : machineConfig.getInstallers()) { String installerName = installernames.get(installerId); if (installerName == null) { installerName = ""; } String installerDescription = installerDescriptions.get(installerId); if (installerDescription == null) { installerDescription = ""; } view.addInstaller(machineName, installerId, installerName, installerDescription); } } }
if (preConfiguredRuntime.getServers().containsKey(serverRef)) { serverPort = preConfiguredRuntime.getServers().get(serverRef).getPort();
@Override public Path getProjectsRoot() { // default root (backward compatible solution) Path projectsRoot = Path.valueOf("/projects"); if (workspace != null && workspace.getStatus().equals(WorkspaceStatus.RUNNING)) { String machineName = wsAgentServerUtilProvider.get().getWsAgentServerMachine().get().getName(); String activeEnv = workspace.getRuntime().getActiveEnv(); EnvironmentImpl environment = workspace.getConfig().getEnvironments().get(activeEnv); VolumeImpl vol = null; if (environment != null) { vol = environment.getMachines().get(machineName).getVolume("projects"); } // if voulme exists return its path, otherwise use backward compatible path (/projects) if (vol != null) { projectsRoot = Path.valueOf(vol.getPath()); } } Log.debug( AppContextImpl.class, "Project Root: " + projectsRoot + " workspace: " + workspace.getConfig().getName()); return projectsRoot; }
@Override public void showPanel() { showWorkspaceStatusPanel(); addMachines(); showInstallers(); if (WorkspaceStatus.RUNNING == appContext.getWorkspace().getStatus()) { view.showWorkspaceStarted(); Map<String, MachineImpl> runtimeMachines = appContext.getWorkspace().getRuntime().getMachines(); for (String machineName : runtimeMachines.keySet()) { view.setMachineRunning(machineName); } String defaultEnvironmentName = appContext.getWorkspace().getConfig().getDefaultEnv(); EnvironmentImpl defaultEnvironment = appContext.getWorkspace().getConfig().getEnvironments().get(defaultEnvironmentName); if (defaultEnvironment == null) { return; } Map<String, MachineConfigImpl> environmentMachines = defaultEnvironment.getMachines(); for (final String machineName : environmentMachines.keySet()) { MachineConfigImpl machineConfig = environmentMachines.get(machineName); for (String installerId : machineConfig.getInstallers()) { view.setInstallerRunning(machineName, installerId); } } } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof MachineConfigImpl)) { return false; } final MachineConfigImpl that = (MachineConfigImpl) obj; return getInstallers().equals(that.getInstallers()) && getEnv().equals(that.getEnv()) && getAttributes().equals(that.getAttributes()) && getServers().equals(that.getServers()) && getVolumes().equals(that.getVolumes()); }