public ServerDtoImpl(org.eclipse.che.api.workspace.shared.dto.ServerDto origin) { this.url = origin.getUrl(); java.util.Map<java.lang.String, java.lang.String> attributesIn = origin.getAttributes(); if (attributesIn != null) { java.util.Map<java.lang.String, java.lang.String> attributesOut = new java.util.HashMap<java.lang.String, java.lang.String>(); for (java.util.Map.Entry<String, java.lang.String> entry0 : attributesIn.entrySet()) { java.lang.String attributesIn_ = entry0.getValue(); attributesOut.put(entry0.getKey(), attributesIn_); } this.attributes = attributesOut; } this.status = origin.getStatus(); }
/** Converts {@link Server} to {@link ServerDto}. */ public static ServerDto asDto(Server server) { return newDto(ServerDto.class) .withUrl(server.getUrl()) .withStatus(server.getStatus()) .withAttributes(server.getAttributes()); }
private WorkspaceDto filterServers(WorkspaceDto workspace, boolean includeInternal) { // no runtime - nothing to filter if (workspace.getRuntime() == null) { return workspace; } // if it is needed to include internal there is nothing to filter if (includeInternal) { return workspace; } for (MachineDto machine : workspace.getRuntime().getMachines().values()) { Map<String, ServerDto> filteredServers = new HashMap<>(); machine .getServers() .forEach( (name, server) -> { if (!"true" .equals(server.getAttributes().get(ServerConfig.INTERNAL_SERVER_ATTRIBUTE))) { filteredServers.put(name, server); } }); machine.withServers(filteredServers); } return workspace; } }