Merge "Add SDN-R odlux performance"
[ccsdk/features.git] / sdnr / wt / odlux / README.md
1 # Developing a ODLUX application
2
3 ## Prerequisites
4
5 * Node: 8.10 or higher
6 * Yarn: 1.12.3 or higher
7 * Lerna: 3.10.7 or higher
8
9 You can install these globally or let it be installed by maven due "mvn clean install"
10
11 * Maven: 3 or higher
12 * Java: 8 or higher
13
14 ## Dev-Environment Installation
15
16  * install NodeJS LTS https://nodejs.org/en/ or via packetmanager
17  * sudo npm install -g yarn
18  * sudo yarn global add lerna
19  * get framework from repository: git clone https://gerrit.onap.org/r/ccsdk/features
20  * in features/sdnr/wt/odlux you find a structure like this:
21  ```
22   odlux
23   |-apps
24   |-core
25   |-framework
26
27  ```
28  * go to features/sdnr/wt/odlux/apps and create your app: 
29  ```
30  mvn archetype:generate -DarchetypeGroupId=org.onap.ccsdk.features.sdnr.wt \
31   -DarchetypeArtifactId=odlux-app-archetype \
32   -DgroupId=<groupId> \
33   -DartifactId=<artifactId> \
34   -Dversion=<version> \
35   -DappName=<applicationName>
36  ```
37
38  * your start folder for your web application is src/
39  * in src2/main/java are located the Java files and in src2/main/resources/ is the blueprint located
40  * with ```yarn start``` you can run your application due runtime in your application folder
41  * by default this will run on http://localhost:3100/index.html
42  * if you have added new dependencies you have to run ```lerna bootstrap``` in odlux/
43  * build your app for development version you can use ```yarn run build``` or ```yarn run build:dev``` 
44  * build for karaf with ```mvn clean install```
45
46
47 ## Including app into karaf environment
48
49  * copy maven repository files to karaf repository e.g.: ```cp ~/.m2/repository/path/of/groupId/artifactId $KARAF_HOME/system/path/of/groupId/```
50  * check if odlux-core is started in karaf console: ```feature:list | grep odlux```
51  * if not install: ```sdnr-wt-odlux-core-feature```
52  * start your app in karaf console: ```bundle:install -s mvn:<groupId>/<artifactId>/<version>```
53
54 ## Including into ONAP sdnc docker container
55
56  * add maven module to odlux/pom.xml
57  * add dependency to odlux/apps/app-feature/pom.xml and odlux/apps/app-installer/pom.xml
58  * build odlux/pom.xml
59  * this will automatically package your app into the packaged zip file of the installer
60
61 ## Details
62
63 ### Default menu positions
64
65  * from 0 for top to 999 for bottom.
66  
67 ```
68 0       Connect
69 10      Fault
70 20      Maintenance
71 30      Configuration
72 40      Protection
73 50      Performance
74 60      Security
75 70      Inventory
76 80      Topology
77 90      Mediator
78 100     Help
79 ```
80
81 ### blueprint.xml
82
83 ```
84 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
85     <reference id="loadersvc" availability="mandatory" activation="eager" interface="org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundleLoader"/>
86     <bean id="bundle" init-method="initialize" destroy-method="clean" class="org.onap.ccsdk.features.sdnr.wt.odlux.bundles.MyOdluxBundle">
87         <property name="loader" ref="loadersvc"/>
88         <property name="bundleName" value="demoApp"/>
89         <property name="index" value="999"/>
90     </bean>
91 </blueprint>
92 ```
93  * bundleName defines the applicationName => default javascript file: <applicationName>.js
94  * index defines the menu position.
95
96 ### MyOdluxBundle.java
97
98  * is just for getting access to the resources of its bundle (implemented because of OSGi access restrictions)
99
100 ### pom.xml
101
102 ```
103 <?xml version="1.0" encoding="UTF-8"?>
104 <project xmlns="http://maven.apache.org/POM/4.0.0"
105     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
106     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
107
108     <parent>
109         <groupId>org.onap.ccsdk.parent</groupId>
110         <artifactId>odlparent</artifactId>
111         <version>1.2.1-SNAPSHOT</version>
112         <relativePath />
113     </parent>
114     <modelVersion>4.0.0</modelVersion>
115     <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
116     <artifactId>sdnr-wt-odlux-app-demoApp</artifactId>
117     <version>0.4.1-SNAPSHOT</version>
118     <packaging>bundle</packaging>
119     <name>sdnr-wt-odlux-app-demoApp</name>
120     <licenses>
121         <license>
122             <name>Apache License, Version 2.0</name>
123             <url>http://www.apache.org/licenses/LICENSE-2.0</url>
124         </license>
125     </licenses>
126     <dependencies>
127         <dependency>
128             <groupId>${project.groupId}</groupId>
129             <artifactId>sdnr-wt-odlux-core-model</artifactId>
130             <version>${project.version}</version>
131         </dependency>
132         <dependency>
133             <groupId>${project.groupId}</groupId>
134             <artifactId>sdnr-wt-odlux-core-provider</artifactId>
135             <version>${project.version}</version>
136             <scope>test</scope>
137         </dependency>
138         <dependency>
139             <groupId>junit</groupId>
140             <artifactId>junit</artifactId>
141             <scope>test</scope>
142         </dependency>
143     </dependencies>
144     <build>
145         <sourceDirectory>src2/main/java</sourceDirectory>
146         <plugins>
147             <plugin>
148                 <artifactId>maven-clean-plugin</artifactId>
149                 <configuration>
150                     <filesets>
151                         <fileset>
152                             <directory>dist</directory>
153                             <followSymlinks>false</followSymlinks>
154                         </fileset>
155                         <fileset>
156                             <directory>node</directory>
157                             <followSymlinks>false</followSymlinks>
158                         </fileset>
159                         <fileset>
160                             <directory>node_modules</directory>
161                             <followSymlinks>false</followSymlinks>
162                         </fileset>
163                         <fileset>
164                             <directory>../node_modules</directory>
165                             <followSymlinks>false</followSymlinks>
166                         </fileset>
167                     </filesets>
168                 </configuration>
169             </plugin>
170             <plugin>
171                 <groupId>org.codehaus.mojo</groupId>
172                 <artifactId>build-helper-maven-plugin</artifactId>
173                 <executions>
174                     <execution>
175                         <id>add-test-source</id>
176                         <phase>generate-test-sources</phase>
177                         <goals>
178                             <goal>add-test-source</goal>
179                         </goals>
180                         <configuration>
181                             <sources>
182                                 <source>src2/test/java</source>
183                             </sources>
184                         </configuration>
185                     </execution>
186                 </executions>
187             </plugin>
188             <plugin>
189                 <groupId>com.github.eirslett</groupId>
190                 <artifactId>frontend-maven-plugin</artifactId>
191                 <version>1.8-SNAPSHOT</version>
192                 <executions>
193                     <execution>
194                         <id>install node and yarn</id>
195                         <goals>
196                             <goal>install-node-and-yarn</goal>
197                         </goals>
198                         <!-- optional: default phase is "generate-resources" -->
199                         <phase>initialize</phase>
200                         <configuration>
201                             <nodeVersion>v8.10.0</nodeVersion>
202                             <yarnVersion>v1.12.3</yarnVersion>
203                         </configuration>
204                     </execution>
205                     <execution>
206                         <id>yarn build</id>
207                         <goals>
208                             <goal>yarn</goal>
209                         </goals>
210                         <configuration>
211                             <arguments>run build</arguments>
212                         </configuration>
213                     </execution>
214                 </executions>
215             </plugin>
216             <plugin>
217                 <groupId>org.apache.maven.plugins</groupId>
218                 <artifactId>maven-jar-plugin</artifactId>
219             </plugin>
220             <plugin>
221                 <groupId>org.apache.felix</groupId>
222                 <artifactId>maven-bundle-plugin</artifactId>
223                 <extensions>true</extensions>
224                 <configuration>
225                     <instructions>
226                         <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package>
227                         <Private-Package></Private-Package>
228                     </instructions>
229                 </configuration>
230             </plugin>
231         </plugins>
232         <resources>
233             <resource>
234                 <directory>dist</directory>
235                 <targetPath>odlux</targetPath>
236             </resource>
237             <resource>
238                 <directory>src2/main/resources</directory>
239             </resource>
240             <resource>
241                 <directory>src2/test/resources</directory>
242             </resource>
243         </resources>
244     </build>
245     <pluginRepositories>
246         <pluginRepository>
247             <id>highstreet repo</id>
248             <url>https://cloud-highstreet-technologies.com/mvn/</url>
249             <snapshots>
250                 <enabled>true</enabled>
251                 <updatePolicy>always</updatePolicy>
252             </snapshots>
253         </pluginRepository>
254     </pluginRepositories>
255 </project>
256 your
257 ```
258
259 * a modified frontend-maven-plugin installs node, yarn and (optionally lerna) to compile the typescript sources to javascript. These will be build into the dist folder.
260