Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Commit

Permalink
Reuse TypeScript DTO that are generated by maven typescript DTO plugin
Browse files Browse the repository at this point in the history
it allows to reuse correct objects provided by the server with type safe

Change-Id: I7b59dfccf2fb0a5885ec0aedbe80f2ca67752760
Signed-off-by: Florent BENOIT <[email protected]>
  • Loading branch information
benoitf committed Oct 10, 2016
1 parent 25c97f5 commit dfa5527
Show file tree
Hide file tree
Showing 23 changed files with 289 additions and 337 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ test-output/

.DAV

che-dto.ts
8 changes: 8 additions & 0 deletions lib/maven-dto/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
DIR=$(cd "$(dirname "$0")"; pwd)
echo "Generating TypeScript DTO from $DIR directory"
cd $DIR
rm -rf target
docker run -it --rm -v "$HOME/.m2:/root/.m2" -v "$PWD":/usr/src/mymaven -w /usr/src/mymaven maven:3.3-jdk-8 mvn -DskipTests=true -Dfindbugs.skip=true -Dskip-validate-sources install
mkdir -p ../typescript/src/api/dto
cp target/dto-typescript.ts ../typescript/src/api/dto/che-dto.ts
122 changes: 122 additions & 0 deletions lib/maven-dto/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2016 Codenvy, S.A.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Codenvy, S.A. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-depmgt-pom</artifactId>
<groupId>org.eclipse.che.depmgt</groupId>
<version>5.0.0-M3-SNAPSHOT</version>
</parent>
<artifactId>dto-typescript</artifactId>
<packaging>pom</packaging>
<name>Che TypeScript DTO</name>
<properties>
<che.version>5.0.0-M3-SNAPSHOT</che.version>
</properties>
<repositories>
<repository>
<id>codenvy-public-repo</id>
<name>codenvy public</name>
<url>https://maven.codenvycorp.com/content/groups/public/</url>
</repository>
<repository>
<id>codenvy-public-snapshots-repo</id>
<name>codenvy public snapshots</name>
<url>https://maven.codenvycorp.com/content/repositories/codenvy-public-snapshots/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>codenvy-public-repo</id>
<name>codenvy public</name>
<url>https://maven.codenvycorp.com/content/groups/public/</url>
</pluginRepository>
<pluginRepository>
<id>codenvy-public-snapshots-repo</id>
<name>codenvy public snapshots</name>
<url>https://maven.codenvycorp.com/content/repositories/codenvy-public-snapshots/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-typescript-dto-maven-plugin</artifactId>
<version>${che.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-agent-shared</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-debug-shared</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-factory-shared</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-git-shared</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-machine-shared</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project-shared</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project-templates-shared</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-ssh-shared</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-user-shared</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace-shared</artifactId>
<version>${che.version}</version>
</dependency>
</dependencies>
<configuration>
<inherited>false</inherited>
</configuration>
</plugin>
</plugins>
</build>
</project>
24 changes: 0 additions & 24 deletions lib/typescript/src/api/wsmaster/machine/dto/machine-process-dto.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
* Codenvy, S.A. - initial API and implementation
*/

import {org} from "../../../api/dto/che-dto"
import {ProcessTerminatedEventPromiseMessageBusSubscriber} from "./process-terminated-event-promise-subscriber";
import {ProcesLogOutputMessageBusSubscriber} from "./process-log-output-subscriber";
import {AuthData} from "../auth/auth-data";
import {Websocket} from "../../../spi/websocket/websocket";
import {Workspace} from "../workspace/workspace";
import {WorkspaceDto} from "../workspace/dto/workspacedto";
import {MachineProcessDto} from "./dto/machine-process-dto";
import {MessageBusSubscriber} from "../../../spi/websocket/messagebus-subscriber";
import {MessageBus} from "../../../spi/websocket/messagebus";
import {HttpJsonRequest} from "../../../spi/http/default-http-json-request";
Expand Down Expand Up @@ -51,11 +50,11 @@ export class MachineServiceClientImpl {
/**
* Create a workspace and return a promise with content of WorkspaceDto in case of success
*/
executeCommand(workspaceDto : WorkspaceDto,
executeCommand(workspaceDto : org.eclipse.che.api.workspace.shared.dto.WorkspaceDto,
machineId:string,
cheFileStructWorkspaceCommand:CheFileStructWorkspaceCommand,
outputChannel:string,
asynchronous : boolean = true):Promise<MachineProcessDto> {
asynchronous : boolean = true):Promise<org.eclipse.che.api.machine.shared.dto.MachineProcessDto> {

let command:any = {
"name" : !cheFileStructWorkspaceCommand.name ? "custom-command" : cheFileStructWorkspaceCommand.name,
Expand All @@ -67,7 +66,7 @@ export class MachineServiceClientImpl {
// get MessageBus
var displayOutputWorkspaceSubscriber:MessageBusSubscriber = new ProcesLogOutputMessageBusSubscriber();
let processTerminatedEventPromiseMessageBusSubscriber : ProcessTerminatedEventPromiseMessageBusSubscriber;
let userMachineProcessDto : MachineProcessDto;
let userMachineProcessDto : org.eclipse.che.api.machine.shared.dto.MachineProcessDto;
let userMessageBus : MessageBus;
return this.workspace.getMessageBus(workspaceDto).then((messageBus:MessageBus) => {
userMessageBus = messageBus;
Expand All @@ -83,11 +82,11 @@ export class MachineServiceClientImpl {
return jsonRequest.request();
}).then((jsonResponse : HttpJsonResponse) => {
// return response
return new MachineProcessDto(JSON.parse(jsonResponse.getData()));
}).then((machineProcessDto : MachineProcessDto) => {
return jsonResponse.asDto(org.eclipse.che.api.machine.shared.dto.MachineProcessDtoImpl);
}).then((machineProcessDto : org.eclipse.che.api.machine.shared.dto.MachineProcessDto) => {
userMachineProcessDto = machineProcessDto;
// get pid
let pid: number = machineProcessDto.getContent().pid;
let pid: number = machineProcessDto.getPid();

// subscribe to pid event end
if (asynchronous) {
Expand Down
24 changes: 0 additions & 24 deletions lib/typescript/src/api/wsmaster/project/dto/projectdto.ts

This file was deleted.

Loading

0 comments on commit dfa5527

Please sign in to comment.