@Override public int hashCode() { int hash = 7; hash = 31 * hash + Objects.hashCode(name); hash = 31 * hash + Objects.hashCode(description); hash = 31 * hash + Objects.hashCode(defaultEnv); hash = 31 * hash + getCommands().hashCode(); hash = 31 * hash + getProjects().hashCode(); hash = 31 * hash + getEnvironments().hashCode(); hash = 31 * hash + getAttributes().hashCode(); return hash; }
/** {@inheritDoc} */ @Override public Promise<String> expand() { return promises.resolve(appContext.getWorkspace().getConfig().getName()); } }
private void addMachines() { 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); view.addMachine(machineName); } }
@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; }
/** Returns commands which are stored in the current workspace. */ List<CommandImpl> getCommands() { final WorkspaceImpl workspace = appContext.getWorkspace(); final WorkspaceConfigImpl workspaceConfig = workspace.getConfig(); return workspaceConfig.getCommands(); }
for (final ProjectConfigImpl projectConfig : factory.getWorkspace().getProjects()) { if (projectsToImport.contains(projectConfig.getName())) { promises.add(
public FactoryImpl( String id, String name, String version, WorkspaceConfig workspace, Author creator, Policies policies, Ide ide, Button button) { this.id = id; this.name = name; this.version = version; if (workspace != null) { this.workspace = new WorkspaceConfigImpl(workspace); } if (creator != null) { this.creator = new AuthorImpl(creator); } if (policies != null) { this.policies = new PoliciesImpl(policies); } if (ide != null) { this.ide = new IdeImpl(ide); } if (button != null) { this.button = new ButtonImpl(button); } }
/** Start the current workspace with a default environment. */ Promise<Void> startWorkspace() { WorkspaceImpl workspace = appContext.getWorkspace(); String defEnvName = workspace.getConfig().getDefaultEnv(); return workspaceServiceClient .startById(workspace.getId(), defEnvName) .then( ws -> { ((AppContextImpl) appContext).setWorkspace(ws); eventBus.fireEvent(new WorkspaceStartingEvent()); }) .then((Function<WorkspaceImpl, Void>) arg -> null) .catchError( error -> { dialogFactory .createMessageDialog(messages.startWsErrorTitle(), error.getMessage(), null) .show(); wsStatusNotification.setError(STARTING_WORKSPACE_RUNTIME); startWorkspaceNotification.show(); }); }
private CommandImpl getWorkspaceCommandByName(String name) { for (Command command : appContext.getWorkspace().getConfig().getCommands()) { if (command.getName().equals(name)) { return new CommandImpl(command); // wrap model interface into implementation, workaround } } return null; }
this.namespace = namespace; if (config != null) { this.config = new WorkspaceConfigImpl(config);
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof WorkspaceConfigImpl)) { return false; } final WorkspaceConfigImpl that = (WorkspaceConfigImpl) obj; return Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(defaultEnv, that.defaultEnv) && getCommands().equals(that.getCommands()) && getProjects().equals(that.getProjects()) && getEnvironments().equals(that.getEnvironments()) && getAttributes().equals(that.getAttributes()); }
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); } } }
@Override public void onWorkspaceRunning(WorkspaceRunningEvent event) { if (arrow != null) { arrow.setAttribute( "href", constant.openDashboardUrlWorkspace(appContext.getWorkspace().getConfig().getName())); } }
if (workspace.getConfig().getDefaultEnv() == null) { return emptyList(); workspace .getConfig() .getEnvironments() .get(workspace.getConfig().getDefaultEnv()) .getMachines() .get(machineName);
@Override public void onDownloadOutput(OutputConsole console) { String id = consoleCommands.get(console); String fileName = appContext.getWorkspace().getNamespace() + "-" + appContext.getWorkspace().getConfig().getName() + " " + DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ".log"; download(fileName, getText(id)); }
@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 void onDownloadWorkspaceOutput(DownloadWorkspaceOutputEvent event) { Optional<MachineImpl> devMachine = wsAgentServerUtil.getWsAgentServerMachine(); if (!devMachine.isPresent()) { return; } WorkspaceImpl workspace = appContext.getWorkspace(); String fileName = workspace.getNamespace() + "-" + workspace.getConfig().getName() + " " + DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ".log"; download(fileName, getText(devMachine.get().getName())); }
final String workspaceName = appContext.getWorkspace().getConfig().getName(); Promise<SshPairDto> sshPairDtoPromise = sshServiceClient.getPair("workspace", appContext.getWorkspaceId());
if (!errorMessage.isEmpty()) { WorkspaceImpl currentWorkspace = appContext.getWorkspace(); String workspaceName = currentWorkspace.getConfig().getName();
constant.openDashboardUrlWorkspace(appContext.getWorkspace().getConfig().getName())); arrow.setAttribute("target", "_blank");