diff --git a/AMW_angular/io/src/app/servers/servers.service.ts b/AMW_angular/io/src/app/servers/servers.service.ts index 0eb080dba..36358397f 100644 --- a/AMW_angular/io/src/app/servers/servers.service.ts +++ b/AMW_angular/io/src/app/servers/servers.service.ts @@ -21,7 +21,10 @@ export class ServersService extends BaseService { servers: Signal = toSignal(this.reloadedServers, { initialValue: [] as Server[] }); - private runtimes$ = this.http.get(`${this.serversUrl}/runtimes`).pipe(catchError(this.handleError)); + private runtimes$ = this.http + .get(`${this.serversUrl}/runtimes`) + .pipe(catchError(this.handleError)) + .pipe(map((data) => data.sort((a, b) => (a.name < b.name ? -1 : 1)))); runtimes: Signal = toSignal(this.runtimes$); private appServersSuggestions$ = this.http diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/dtos/ServerDTO.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/dtos/ServerDTO.java new file mode 100644 index 000000000..783fa64af --- /dev/null +++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/dtos/ServerDTO.java @@ -0,0 +1,47 @@ +package ch.mobi.itc.mobiliar.rest.dtos; + + +import ch.puzzle.itc.mobiliar.business.server.entity.ServerTuple; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "appAppServer") +@XmlAccessorType(XmlAccessType.FIELD) +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ServerDTO { + + private String host; + private String appServer; + private String appServerRelease; + private String runtime; + private String node; + private String nodeRelease; + private String environment; + private Integer appServerId; + private Integer nodeId; + private Integer environmentId; + private String domain; + private boolean definedOnNode; + + public ServerDTO(ServerTuple serverTuple) { + this.host = serverTuple.getHost(); + this.appServer = serverTuple.getAppServer(); + this.appServerRelease = serverTuple.getAppServerRelease(); + this.runtime = serverTuple.getRuntime(); + this.node = serverTuple.getNode(); + this.nodeRelease = serverTuple.getNodeRelease(); + this.environment = serverTuple.getEnvironment(); + this.appServerId = serverTuple.getAppServerId(); + this.nodeId = serverTuple.getNodeId(); + this.environmentId = serverTuple.getEnvironmentId(); + this.domain = serverTuple.getDomain(); + this.definedOnNode = serverTuple.isDefinedOnNode(); + } +} diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/servers/ServersRest.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/servers/ServersRest.java index 4b4c34ade..4cf4b13ec 100644 --- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/servers/ServersRest.java +++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/servers/ServersRest.java @@ -1,11 +1,14 @@ package ch.mobi.itc.mobiliar.rest.servers; import ch.mobi.itc.mobiliar.rest.dtos.ResourceGroupDTO; +import ch.mobi.itc.mobiliar.rest.dtos.ResourceTypeDTO; +import ch.mobi.itc.mobiliar.rest.dtos.ServerDTO; import ch.puzzle.itc.mobiliar.business.resourcegroup.boundary.ResourceGroupLocator; import ch.puzzle.itc.mobiliar.business.resourcegroup.control.ResourceGroupPersistenceService; import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceGroupEntity; import ch.puzzle.itc.mobiliar.business.server.boundary.GetServersUseCase; import ch.puzzle.itc.mobiliar.business.server.boundary.ServerView; +import ch.puzzle.itc.mobiliar.business.server.entity.ServerTuple; import ch.puzzle.itc.mobiliar.common.util.DefaultResourceTypeDefinition; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -76,6 +79,9 @@ public Response getServers(@QueryParam("environment") String environment, @QueryParam("appServer") String appServer, @QueryParam("host") String host, @QueryParam("node") String node) { - return Response.status(OK).entity(serverView.getServers(host,appServer,runtime, node, environment,true)).build(); + + List servers = serverView.getServers(host,appServer,runtime, node, environment,true).stream().map(ServerDTO::new).collect(Collectors.toList()); + + return Response.status(OK).entity(servers).build(); } }