Commit 44e7fb22 authored by Colin PUY's avatar Colin PUY

Merge commit '4e5d1ef614ace45bca79d6d38344b292e96ae62f' as 'community'

parents
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
[*.md]
trim_trailing_whitespace = false
[*.js]
indent_style = space
indent_size = 2
[*.json]
indent_style = space
indent_size = 2
[*.html]
indent_style = space
indent_size = 4
.idea/
*.iml
.classpath
.project
.settings/
bower_components/
node_modules/
target/
npm-debug.log
.extract/
backend/webapp/node/
backend/webapp/src/main/webapp/i18n/*.json
backend/webapp/src/test/resources/i18n/*.json
# image to create a standalone form builder
# to build, use `docker build -t bonita/form-builder .`
# to run on random port, use `docker run -p 8080 bonita/form-builder`
# to run on a fixed port, 8000 for example, use `docker run -p 8000:8080 bonita/form-builder`
# base image with java 7 installed
FROM dockerfile/java:openjdk-7-jre
MAINTAINER cedric@ninja-squad.com
# expose page builder port
EXPOSE 8080
# run standalone ui designer on container start
CMD java -jar ui-designer-standalone.jar
# add build jar in the current directory of the image (/data)
ADD ./backend/webapp/target/ui-designer-1.0.0-SNAPSHOT-standalone.jar /data/ui-designer-standalone.jar
# Bonita UI designer
## Build
You can build entire project using maven.
mvn clean package
This will build frontend and backend and create two artifacts :
backend/target/ui-designer-{version}.war
backend/target/ui-designer-{version}-standalone.jar
## Test
while running `mvn clean package` only unit tests are run.
If you want to run the integration tests, run the following command
mvn clean install -Pintegration-test
Also frontend e2e test could be launched via
mvn clean install -Pe2e
## Run
To run build standalone jar, just launch it as a standard jar :
java -jar backend/target/ui-designer-{version}-standalone.jar [-Dworkspace=/path/to/workspace] [-Drepository.widgets=/path/widgets/repository] [-Drepository.pages=/path/pages/repository]
Application is now available at http://localhost:8080/designer
You can specify workspace location where pages and widgets are stored. Default value is {user.home}/.bonita
Available options can be listed by running
java -jar backend/target/ui-designer-{version}-standalone.jar -h
Other available options are listed here : http://tomcat.apache.org/maven-plugin-2.0/executable-war-jar.html
## Develop
Backend and frontend side could be launched in dev mode by using _server.sh_ script.
It launch _gulp serve_ backend task, waits for jetty to be running then launches _gulp serve_ frontend task.
```shell
$ ./server.sh
```
You can access the application at http://localhost:3000/index-dev.html, backend side is accessible at http://localhost:8080/
## Docker
You can run the ui-designer locally using Docker (of course, you need to install Docker to do so).
The Dockerfile is a really simple one, using a base image with java7, adding the build standalone jar and starting it.
Before building docker image, you need to build the project.
To build the image :
docker build -t bonita/ui-designer .
To run the image built with the previous command :
docker run -p 8080 bonita/ui-designer
This will start the builder on a random port on your docker host (*either the local host if you're running linux, or the boot2docker VM if you're on MacOS*). For boot2docker, you can find your VM IP with :
boot2docker ip
You can find the random port used with :
docker ps
For example, the application can start on [http://192.168.59.103:49153/designer](http://192.168.59.103:49153/designer)
(*192.168.59.103 being the default boot2docker IP and 49153 the random port used*).
You can also run the image on a fixed port, 8000 for example, with :
docker run -p 8000:8080 bonita/ui-designer
# Backend
## Development
### IDE
Before pushing your code, you have to format it and organize imports.
The former is pretty standard and the configuration used on IntelliJ for the later can be configured in `Code Style/Java/Imports`.
![Java Imports](https://cloud.githubusercontent.com/assets/4922020/5725146/c639881e-9b50-11e4-981b-80ad11a93776.png)
You should note that `*` is used only if more than 20 classes are used, and that static imports are done before the `java`
and `javax` packages, and then the other imports.
### Jetty
To start a jetty server
mvn jetty:run
For debugging purpose
mvnDebug jetty:run
Default configuration launch jetty on http://localhost:8080/, source code is _watched_ every two seconds to enable hot reload of modified code
### Gulp
While editing backend js files, extra build steps are performed when building war. For development purpose you can launch jetty via gulp. This will 'watch' js files and rebuild them every time a change happens
gulp serve
## Unit test code coverage
To run unit test code coverage, launch maven profile _coverage_
mvn clean test -Pcoverage
###Javascript test
#### Single run
```shell
$ npm test
```
or
```shell
$ gulp test
```
### Watch source files and tests
```shell
$ npm run test-watch
```
or
```shell
$ gulp test-watch
```
## Licensing
The build will check if the license is correctly added and up to date in each files, and fail if that's not the case.
If you want to add or update the license, run :
mvn license:format
If you want to run the check manually :
mvn license:check
## Rest API
### Widgets
#### Resource URI
/rest/widgets
#### Get all widgets
GET /rest/widgets
* Response : array of widgets
* Response code
* 200 OK
* 500 internal server error
#### Create a custom widget
POST /rest/widgets
BODY json representation of the model of the widget
* Response : created widget
* Response code
* 204 OK
* 403 not allowed to save a non custom widget
* 500 internal server error
#### Save a custom widget
PUT /rest/widgets/{widgetId}
BODY json representation of the model of the widget
* Response code
* 204 OK
* 403 not allowed to save a non custom widget
* 500 internal server error
#### Delete a custom widget
DELETE /rest/widgets/{widgetId}
* Response code
* 200 OK
* 403 not allowed to delete a non custom widget
* 404 not found
* 500 internal server error
#### Add a new property to a custom widget
POST /rest/widgets/{widgetId}/properties
BODY json representation of the model of a property
* Response code
* 200 OK
* 403 not allowed to modify a non custom widget
* 404 widget not found
* 500 internal server error
#### Update a property of a custom widget
PUT /rest/widgets/{widgetId}/properties/{propertyName}
BODY json representation of the model of a property
* Response code
* 200 OK
* 403 not allowed to modify a non custom widget
* 404 widget/property not found
* 500 internal server error
#### Delete a property of a custom widget
DELETE /rest/widgets/{widgetId}/properties/{propertyName}
* Response code
* 200 OK
* 403 not allowed to modify a non custom widget
* 404 widget/property not found
* 500 internal server error
### Page model
#### Resource URI
/rest/pages
#### Get all page information model
GET /rest/pages
* Response : light json representation of the model of the page (id, name)
#### Get a page model
GET /rest/pages/{pageId}
* Response : json representation of the model of the page
* Response code
* 200 OK
* 404 Page {pageId} not found
#### Save a page model
PUT /rest/pages/{pageId}
BODY json representation of the model of the page
* Response : N/A
* Response code
* 204 OK
* 500 internal server error
#### Get page data
GET /rest/pages/{pageId}/data
* Response : array of data
* Response code
* 200 OK
* 404 page {pageId} not found
* 500 internal server error
#### Save page data
PUT /rest/pages/{pageId}/data/{dataName}
BODY { "value": page data value, "type": page data type }
* Response : json representation of data
* Response code
* 200 OK
* 404 page {pageId} not found
* 500 internal server error
#### Delete page data
DELETE /rest/pages/{pageId}/data/{dataName}
* Response : json representation of data
* Response code
* 200 OK
* 404 page {pageId} not found or data {dataName} not found
* 500 internal server error
<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>
<groupId>org.bonitasoft.web</groupId>
<artifactId>ui-designer-backend</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>ui-designer-backend-contract</artifactId>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
/**
* Copyright (C) 2015 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.web.designer.model.contract;
import static com.google.common.base.Joiner.on;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Lists.reverse;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
public abstract class AbstractContractInput implements ContractInput {
private ContractInput parentInput;
private boolean mandatory;
private boolean multiple;
private String description;
private String name;
public AbstractContractInput(String name) {
this.name = name;
}
@Override
public String getName() {
return name;
}
@Override
public boolean isMandatory() {
return mandatory;
}
@Override
public boolean isMultiple() {
return multiple;
}
@Override
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public void setMandatory(boolean mandatory) {
this.mandatory = mandatory;
}
public void setMultiple(boolean multiple) {
this.multiple = multiple;
}
@JsonIgnore
@Override
public ContractInput getParent() {
return parentInput;
}
@JsonIgnore
public void setParent(ContractInput parentInput) {
this.parentInput = parentInput;
}
@Override
public String path() {
List<String> pathNames = newArrayList();
pathNames.add(getName());
ContractInput pInput = getParent();
while (pInput != null) {
pathNames.add(pInput.getName());
pInput = pInput.getParent();
}
return pathNames.isEmpty() ? null : on(".").join(reverse(pathNames));
}
}
/**
* Copyright (C) 2015 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.web.designer.model.contract;
import java.util.ArrayList;
import java.util.List;
import org.bonitasoft.web.designer.model.contract.databind.ContractDeserializer;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@JsonDeserialize(using = ContractDeserializer.class)
public class Contract implements ContractInputContainer {
private List<ContractInput> contractInput = new ArrayList<>();
private ContractType contractType = ContractType.TASK;
public void setContractInput(List<ContractInput> contractInput) {
this.contractInput = contractInput;
}
public ContractType getContractType() {
return contractType;
}
public void setContractType(ContractType contractType) {
this.contractType = contractType;
}
@JsonIgnore
public void accept(ContractInputVisitor contractInputVisitor) {
for (ContractInput input : contractInput) {
input.accept(contractInputVisitor);
}
}
@Override
public List<ContractInput> getInput() {
return contractInput;
}
@Override
public void addInput(ContractInput childInput) {
contractInput.add(childInput);
}
}
/**
* Copyright (C) 2015 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.web.designer.model.contract;
public interface ContractInput extends ContractInputContainer {