Open Anthem

All the examples can be cloned from the below two github repositories

Note
Point to the latest framework( https://github.com/openanthem/nimbus-core/blob/2.0.x/pom.xml ) and check and update the nimbus-parent version in the pom.xml of the below examples
  1. HelloWorld-and-Form-Elements-Code-Snippets:

    1. https://github.com/Lavanya-anthem/HelloWorld-and-Form-Elements-Code-Snippets

    2. In this repo, you have two branches: 'helloworld' & 'form-elements'

  2. Drools-Actions-DB-examples:

    1. https://github.com/Lavanya-anthem/Drools-Actions-DB-examples

    2. In this repo, there are three branches: 'drools', 'fw-actions' & 'db-interaction'

  3. Import the projects in your STS. Right click the web folder and run as spring boot app

Hello World

Objective

To create a simple page which displays “Hello World! We have created our first application!”

Steps

  1. Open Spring Tool Suite.

    HW1
  2. Right click the project explorer area and click New→Maven Project

    HW2
  3. You can see your workspace location. Select Create simple project and click Next

    HW1
  4. Enter the Group Id, Artifact Id and Version as follows:

    1. Group Id: com.atlas.client.extension.helloworld

    2. Artifact Id: com.atlas.client.extension.helloworld

    3. Version: 1.1.1 BUILD-SNAPSHOT

      Note
      We follow a naming convention for project’s group id, artifact id and version. This goes like com.atlas.client.extension.(name of your project)
  5. Click Finish

    HW2
  6. You can see the project in the Package Explorer area.

    HW2
  7. Update pom.xml

    1. Expand the folder and open pom.xml (file which contains the project configuration details used by Maven)

    2. Add the parent class information. Here we have added the version of parent as 1.1.10.BUILD-SNAPSHOT. Check the version of the parent @ https://github.com/openanthem/nimbus-core/blob/1.1.x/pom.xml while upadting pom.xml

      HW2
    3. Add the project dependencies

    4. Add the plugins requires to configure this project

      POM.xml
      <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>
        <groupId>com.atlas.client.extension.helloworld</groupId>
        <artifactId>com.atlas.client.extension.helloworld</artifactId>
        <version>1.1.1.BUILD-SNAPSHOT</version>
      
          <parent>
              <groupId>com.antheminc.oss</groupId>
              <artifactId>nimbus-parent</artifactId>
              <version>1.1.10.BUILD-SNAPSHOT</version>
              </parent>
          <dependencies>
              <dependency>
                  <groupId>com.antheminc.oss</groupId>
                  <artifactId>nimbus-core</artifactId>
                  <exclusions>
                      <exclusion>
                          <groupId>de.flapdoodle.embed</groupId>
                          <artifactId>de.flapdoodle.embed.mongo</artifactId>
                      </exclusion>
                  </exclusions>
              </dependency>
              <dependency>
                  <groupId>com.antheminc.oss</groupId>
                  <artifactId>nimbus-ui</artifactId>
              </dependency>
              <dependency>
                  <groupId>com.antheminc.oss</groupId>
                  <artifactId>nimbus-test</artifactId>
                  <scope>test</scope>
              </dependency>
      
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-security</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-tomcat</artifactId>
                  <scope>provided</scope>
              </dependency>
      
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-configuration-processor</artifactId>
              </dependency>
              <dependency>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-test</artifactId>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>org.springframework.ws</groupId>
                  <artifactId>spring-ws-core</artifactId>
                  <exclusions>
                      <exclusion>
                          <artifactId>commons-logging</artifactId>
                          <groupId>commons-logging</groupId>
                      </exclusion>
                  </exclusions>
              </dependency>
              <dependency>
                  <groupId>com.querydsl</groupId>
                  <artifactId>querydsl-mongodb</artifactId>
              </dependency>
              <dependency>
                  <groupId>com.querydsl</groupId>
                  <artifactId>querydsl-apt</artifactId>
              </dependency>
              <dependency>
                  <groupId>com.sleepycat</groupId>
                  <artifactId>je</artifactId>
                  <version>5.0.73</version>
              </dependency>
              <!-- tomcat-embed-jasper is only to enable support to render JSP page -->
              <dependency>
                  <groupId>org.apache.tomcat.embed</groupId>
                  <artifactId>tomcat-embed-jasper</artifactId>
                  <scope>provided</scope>
              </dependency>
              <dependency>
                  <groupId>com.h2database</groupId>
                  <artifactId>h2</artifactId>
      
              </dependency>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-devtools</artifactId>
                  <optional>true</optional>
                  <scope>runtime</scope>
              </dependency>
      
              <dependency>
                  <groupId>de.flapdoodle.embed</groupId>
                  <artifactId>de.flapdoodle.embed.mongo</artifactId>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>com.fasterxml.jackson.datatype</groupId>
                  <artifactId>jackson-datatype-jsr310</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.apache.httpcomponents</groupId>
                  <artifactId>httpclient</artifactId>
              </dependency>
          </dependencies>
        <build>
              <plugins>
                  <plugin>
                      <groupId>com.mysema.maven</groupId>
                      <artifactId>apt-maven-plugin</artifactId>
                      <version>1.1.3</version>
                      <executions>
                          <execution>
                              <goals>
                                  <goal>process</goal>
                              </goals>
                              <configuration>
                                  <outputDirectory>${basedir}/target/generated-sources/annotations</outputDirectory>
                                  <processor>
                                      com.antheminc.oss.nimbus.domain.support.DomainQuerydslProcessor
                                  </processor>
                              </configuration>
                          </execution>
                      </executions>
                  </plugin>
                          <plugin>
                      <groupId>org.codehaus.mojo</groupId>
                      <artifactId>build-helper-maven-plugin</artifactId>
                      <executions>
                          <execution>
                              <id>add-extra-source</id>
                              <phase>generate-sources</phase>
                              <goals>
                                  <goal>add-source</goal>
                              </goals>
                              <configuration>
                                  <sources>
                                      <source>${basedir}/target/generated-sources/annotations</source>
                                  </sources>
                              </configuration>
                          </execution>
                      </executions>
                  </plugin>
              </plugins>
          </build>
      
          <repositories>
              <repository>
                  <id>spring-snapshots</id>
                  <name>Spring Snapshots</name>
                  <url>https://repo.spring.io/snapshot</url>
                  <snapshots>
                      <enabled>true</enabled>
                  </snapshots>
              </repository>
              <repository>
                  <id>spring-milestones</id>
                  <name>Spring Milestones</name>
                  <url>https://repo.spring.io/milestone</url>
                  <snapshots>
                      <enabled>false</enabled>
                  </snapshots>
              </repository>
          </repositories>
  8. Build the project:

    1. Right click the project folder and select Run as→m2 5 Mavenbuild.

      HW3
    2. Enter ‘clean install’ in the Goals field

      HW3
  9. Create another project the same way. Right click the project explorer area and click New→Maven Project

    HW2
  10. You can see your workspace location. Select Create simple project and click Next

    HW1
  11. Enter the Group Id, Artifact Id and Version as follows:

    1. Group Id: com.atlas.helloworld-web

    2. Artifact Id: com.atlas.helloworld-web

    3. Version: 1.1.1 BUILD-SNAPSHOT

  12. Click Finish

    HW1
  13. You can see the project in the Package Explorer area.

    HW1
  14. Update Pom.xml

    1. Expand the folder and open pom.xml (file which contains the project configuration details used by Maven)

    2. Add the parent class information

    3. Add the project dependencies including the corresponding extension folder (highlighted in yellow)

    4. Add the plugins requires to configure this project

      POM.xml
      <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>
        <groupId>com.atlas.Helloworld-web</groupId>
        <artifactId>com.atlas.Helloworld-web</artifactId>
        <version>1.1.1 BUILD-SNAPSHOT</version>
        <parent>
              <groupId>com.antheminc.oss</groupId>
              <artifactId>nimbus-parent</artifactId>
              <version>1.1.10.BUILD-SNAPSHOT</version>
          </parent>
        <properties>
          <nimbus.version>1.1.10.BUILD-SNAPSHOT</nimbus.version>
        </properties>
      
        <dependencies>
          <dependency>
              <groupId>com.antheminc.oss</groupId>
              <artifactId>nimbus-core</artifactId>
              <exclusions>
                  <exclusion>
                       <groupId>de.flapdoodle.embed</groupId>
                       <artifactId>de.flapdoodle.embed.mongo</artifactId>
                  </exclusion>
              </exclusions>
          </dependency>
          <dependency>
              <groupId>com.antheminc.oss</groupId>
              <artifactId>nimbus-ui</artifactId>
          </dependency>
          <dependency>
              <groupId>com.antheminc.oss</groupId>
              <artifactId>nimbus-test</artifactId>
              <scope>test</scope>
          </dependency>
          <dependency>
            <groupId>com.client.extension.helloworld</groupId>
        <artifactId>com.client.extension.helloworld</artifactId>
        <version>1.1.1 BUILD-SNAPSHOT</version>
              <exclusions>
                  <exclusion>
                       <groupId>de.flapdoodle.embed</groupId>
                       <artifactId>de.flapdoodle.embed.mongo</artifactId>
                  </exclusion>
              </exclusions>
          </dependency>
      
          <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-security</artifactId>
          </dependency>
          <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-tomcat</artifactId>
              <scope>provided</scope>
           </dependency>
      
          <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-configuration-processor</artifactId>
          </dependency>
          <dependency>
              <groupId>junit</groupId>
              <artifactId>junit</artifactId>
          </dependency>
          <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-test</artifactId>
              <scope>test</scope>
          </dependency>
          <dependency>
              <groupId>org.springframework.ws</groupId>
              <artifactId>spring-ws-core</artifactId>
              <exclusions>
                  <exclusion>
                      <artifactId>commons-logging</artifactId>
                      <groupId>commons-logging</groupId>
                  </exclusion>
              </exclusions>
          </dependency>
          <dependency>
              <groupId>com.querydsl</groupId>
              <artifactId>querydsl-mongodb</artifactId>
          </dependency>
          <dependency>
              <groupId>com.querydsl</groupId>
              <artifactId>querydsl-apt</artifactId>
          </dependency>
          <dependency>
              <groupId>com.sleepycat</groupId>
              <artifactId>je</artifactId>
              <version>5.0.73</version>
          </dependency>
          <dependency>
              <groupId>org.apache.tomcat.embed</groupId>
              <artifactId>tomcat-embed-jasper</artifactId>
              <scope>provided</scope>
          </dependency>
      
          <dependency>
              <groupId>com.h2database</groupId>
              <artifactId>h2</artifactId>
              <!-- <scope>test</scope> -->
          </dependency>
          <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-devtools</artifactId>
              <optional>true</optional>
              <scope>runtime</scope>
          </dependency>
          <dependency>
              <groupId>org.apache.httpcomponents</groupId>
              <artifactId>httpclient</artifactId>
          </dependency>
        </dependencies>
        <build>
          <resources>
             <resource>
             <directory>${project.basedir}/src/main/resources</directory>
             </resource>
          </resources>
      
        </build>
      </project>
  15. Build the project (Refer 5.1→8)

  16. Create VRHelloworld.java class inside com.atlas.client.extension.helloworld → src/main/java → com.atlas.client.extension.helloworld

    HW2
    VRHelloworld.java
    //Necessary packages
    import javax.validation.constraints.NotNull;
    import com.antheminc.oss.nimbus.domain.defn.Domain;
    import com.antheminc.oss.nimbus.domain.defn.MapsTo;
    import com.antheminc.oss.nimbus.domain.defn.Model;
    import com.antheminc.oss.nimbus.domain.defn.Model.Param.Values.Source;
    import com.antheminc.oss.nimbus.domain.defn.Repo;
    import com.antheminc.oss.nimbus.domain.defn.Domain.ListenerType;
    import com.antheminc.oss.nimbus.domain.defn.MapsTo.Path;
    import com.antheminc.oss.nimbus.domain.defn.MapsTo.Type;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Form;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Header;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Page;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Paragraph;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Section;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Tile;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.ViewRoot;
    import com.antheminc.oss.nimbus.domain.defn.extension.Content.Label;
    import com.antheminc.oss.nimbus.domain.model.config.ParamValue;
    
    import lombok.Getter;
    import lombok.Setter;
    import lombok.ToString;
    
    // Defining the Domain Entity
    @Domain(value ="helloworldview", includeListeners = {ListenerType.websocket})
    
    //Repository values
    @Repo(value=Repo.Database.rep_none,cache=Repo.Cache.rep_device)
    
    //Generate Getter and Setter for the class
    @Getter @Setter @ToString(callSuper=true)
    
    //Layout of the Root
    @ViewRoot(layout = "home")
    public class VRHelloworld{
    
    // Define a Page instance
    @Page(defaultPage=true)
    private VPHelloworld vpHelloworld;
    
    // Define a Tile instance
    @Model
    @Getter @Setter
    public static class VPHelloworld{
    
         @Tile(size = Tile.Size.Large)
         private VTHelloworld vtHelloworld;
    }
    
    // Add a Header variable and define a Section instance
    @Model
    @Getter @Setter
    public static class VTHelloworld{
    
        @Header(size=Header.Size.H3)
        private String addHelloWorldHeader;
    
        @Section
        private VSHelloworld vsHelloworld;
    }
    
    // Define a Form instance which has one column
    @Model
    @Getter @Setter
    public static class VSHelloworld{
    
            @Form(cssClass="oneColumn")
            private VFHelloworld vfHelloworld;
        }
    
    //Define a Paragraph with the Label “Hello All”
    @Model
        @Getter @Setter
        public static class VFHelloworld {
    
            @Paragraph
            @Label(value = "Hello ALL")
            private String title1;
    
             }
        }
  17. Create VLHome.java class inside com.atlas.client.extension.helloworld → src/main/java → com.atlas.client.extension.helloworld

    HW2
    VLHome.java
    import com.antheminc.oss.nimbus.domain.defn.Domain;
    import com.antheminc.oss.nimbus.domain.defn.Domain.ListenerType;
    import com.antheminc.oss.nimbus.domain.defn.Model;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Hints;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Initialize;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Link;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Page;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.PageHeader;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Paragraph;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Section;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Hints.AlignOptions;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.PageHeader.Property;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Section.Type;
    import com.antheminc.oss.nimbus.domain.defn.extension.Content.Label;
    import com.antheminc.oss.nimbus.domain.defn.Repo;
    import com.antheminc.oss.nimbus.domain.defn.Repo.Cache;
    import com.antheminc.oss.nimbus.domain.defn.Repo.Database;
    
    import lombok.Getter;
    import lombok.Setter;
    
    @Domain(value="home", includeListeners={ListenerType.websocket})
    @Repo(value = Database.rep_none, cache = Cache.rep_device)
    @Getter @Setter
    public class VLHome {
    
        @Page private VPHome vpHome;
    
        @Model @Getter @Setter
        public static class VPHome {
    
            @Section(Type.HEADER)
            private VSHomeHeader vsHomeHeader;
    
        }
        @Model @Getter @Setter
        public class VSHomeHeader {
    
    
            @PageHeader(Property.APPTITLE)
            @Paragraph
            @Label(value = "Welcome !")
            private String title;
    
        }
    }
  18. Create Application.java to start up our spring boot application and LoginController.java class inside com.atlas.helloworld-web → src/main/java → com.atlas.helloworld

    HW
    Application.java
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.boot.web.support.SpringBootServletInitializer;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.ComponentScan;
    import org.springframework.context.annotation.Configuration;
    
    import com.antheminc.oss.nimbus.domain.session.HttpSessionProvider;
    import com.antheminc.oss.nimbus.domain.session.SessionProvider;
    
    
    @Configuration
    @SpringBootApplication(scanBasePackageClasses=LoginController.class)
    @ComponentScan
    @EnableAutoConfiguration
    public class Application extends SpringBootServletInitializer {
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application){
            return application.sources(Application.class);
        }
        public static void main(String[] args) throws Exception {
            SpringApplication.run(Application.class, args);
        }
    
        @Bean
        public SessionProvider sessionProvider() {
            return new HttpSessionProvider();
    LoginController.java
    import java.util.Enumeration;
    import java.util.List;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.security.core.context.SecurityContextHolder;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.ResponseBody;
    import com.antheminc.oss.nimbus.entity.client.access.ClientUserRole;
    import com.antheminc.oss.nimbus.entity.client.user.ClientUser;
    import com.antheminc.oss.nimbus.support.JustLogit;
    
    
    @Controller
    public class LoginController {
    
        @RequestMapping(value = "/login", method = RequestMethod.GET)
        public void login(HttpServletRequest request, HttpServletResponse response) throws Exception {
        response.sendRedirect("/helloworld/#/h/helloworldview/vpHelloworld");
    
        }
    
        private JustLogit _logger = new JustLogit(this.getClass());
    }
  19. Create application.yml file under com.atlas.helloworld-web → src/main/resources to tell the framework about the classes we configured, database connection etc. . We can reuse this application.yml file for any of our applications by making changes to the following:

    1. application name

    2. context path

    3. basePackages

      HW
      Application.yml
      spring:
        application:
          name: helloworld
        h2:
          console:
            enabled: true
            path: /console/
        rabbitmq:
          host: localhost
          port: 5672
        redis:
          host: localhost
          port: 6379
        data:
          mongodb:
            host: localhost
            database: ltss
            port: 27017
        activiti:
          processDefinitionLocationPrefix:  classpath*:process-defs/**.xml
        mvc:
          view:
            prefix: /
            suffix: .jsp
        sqldatasource:
          driver-class-name: oracle.jdbc.driver.OracleDriver
      
      #    datasource:
      #      url: jdbc:mysql://localhost/test
      #      driver-class-name: com.mysql.jdbc.Driver
      packageName: com.example
      application:
        mode: online
        error:
          genericMsg: System Error ERR.UNIQUEID
      #  exceptions:
      #    com.antheminc.oss.nimbus.FrameworkRuntimeException: Runtime Exception - ERR.UNIQUEID
      #    genericMsg: ERR.UNIQUEID - System Error. ## Can use ERR.UNIQUEID as a placeholder to replace the uniqueId for error.
      
      ##Logging properties
      #logging.file=${LOG_DIR_PATH}/${spring.application.name}.log
      #logging.file=/var/tmp/nimbus/logs/${spring.application.name}.log
      
      serviceUserName: integration_service
      servicePassword: HashedPwd1234!!!!!!!!!!!!!****
      
      logging:
        file: ${HOME}/Documents/nimbuslogs/${spring.application.name}.log
        level:
          reactor.io.net.impl.netty.tcp: DEBUG
        pattern:
          file: "%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } [%X{SESSIONID:- }] --- [%t] %-40.40logger{39} : %replace(%replace(%m){'\n', ''}){'\r', ''} %n${LOG_EXCEPTION_CONVERSION_WORD: %wEx}"
          console: "%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } [%X{SESSIONID:- }] --- [%t] %-40.40logger{39} : %replace(%replace(%m){'\n', ''}){'\r', ''} %n${LOG_EXCEPTION_CONVERSION_WORD: %wEx}"
      
      #logging.level.org.springframework=DEBUG
      
      jwt:
        secret: nimbustest
        algorithm: HS512
      
      process:
        key:
          regex:
           ([A-Za-z0-9_\\-\\*~\\?=\\.\\$]+)
        database:
          driver:
            embeddedH2
          url:
            embeddedH2
          username:
            embeddedH2
          password:
            embeddedH2
          taskUpdateQuery:
            update ACT_RU_TASK set TASK_DEF_KEY_ = ?, NAME_ = ? WHERE ID_=?
          executionUpdateQuery:
            update ACT_RU_EXECUTION set ACT_ID_ = ?  WHERE ID_=? AND ACT_ID_=?
        history:
          level:
            full
        definitions:
         - classpath*:process-defs/**.xml
        rules:
         - rules/**.drl
        customDeployers:
      
      platform:
        config:
          cookies:
            gateway:
              name: GATEWAYSESSIONID
              path: /
      
            api:
              name: APISESSIONID
              path: /
      
            sticky:
              name: STICKYSERVERID
              path: /
          secure:
            regex: "^[a-zA-Z0-9<>()\\[\\]@/: &.=?,$#_-]{1,1000}"
      server:
        port: 8082
        session:
          timeout: 1800
        context-path: /helloworld
      #  context-path: /api
      auth-server: http://localhost:8891
      security:
        basic:
          enabled: false
        oauth2:
          resource:
            tokenInfoUri: ${auth-server}/auth-service/oauth/check_token
          client:
            clientId: nimbus
            clientSecret: xfer498
      
      eureka:
        client:
          enabled: false
      
      ruleBasedRequestHandler:
                           - defaultRuleBasedRequestHandler
                           - defaultRuleBasedResponseHandler
      
      scriptBasedRequestHandler: defaultScriptBasedRequestHandler
      scriptBasedResponseHandler: defaultScriptBasedResponseHandler
      
      scriptHandlerType: cript
      customHandlerType: Custom
      
      stomp:
          hostName: localhost
          port: 61613
      
      domain:
        model:
          basePackages:
            - com.atlas.client.extension.helloworld
          typeClassMappings:
            java.lang.String :
              string
          includeFilter: ['a','b']
          persistenceStrategy: ATOMIC
        action: abc
      
        validation:
          markerAnnotations:
            javax.validation.Constraint
          markerInterfaces:
      
      #logging:
      #  file: ${HOME}/Documents/nimbuslogs/platform-core-web.log
      user:
        permissionToActions:
          ACCESS:
            _get,_info,_search,_new,_replace,_update,_delete,_nav,_process
          READ:
            _get,_info,_search,_getAll,_nav,_process
          CREATE:
            _new,_nav,_process
          UPDATE:
            _update,_replace,_nav,_process
          DELETE:
            _delete,_nav,_process
        #authenticationStrategyBeans:
           #jwtAuthenticationStrategy, ldapAuthenticationStrategy
      template:
        definitions:
          - path: e_post/*/comm/icr/p/flow_umcase/_findPatient/_process/_execute
            id: flow_umcase_findPatient
            criteria:
      model:
        persistence:
          strategy:
            mode:
              ATOMIC
      dsl:
        behavior:
          extensions:
            #$execute:
              #$save
      quartz:
        enabled: true
        frequency: 1000
      
      org:
        quartz:
          scheduler:
            instanceName:
              spring-activiti-quartz
            instanceId:
              AUTO
          threadPool:
            threadCount: 2
          jobStore:
            class: org.quartz.impl.jdbcjobstore.JobStoreTX
            driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
            useProperties: true
            misfireThreshold: 60000
            tablePrefix: QRTZ_
            isClustered: true
            clusterCheckinInterval: 20000
      
      session:
        userKey: client-user-key
      
      staticResourcesPath: ./target/webapp/
      
      app:
        endpoints:
          ltss-integration-services: http://localhost:8080/ltss-integration-services
          cue: http://va10dwviss323.us.ad.wellpoint.com:81/CUEDEV_RESTServices
      
      search:
        threshold:
          50
      
      ext:
        repository:
          targetUrl:
            pharmacydrug: ${app.endpoints.ltss-integration-services}
            memberauthorization: ${app.endpoints.ltss-integration-services}
            memberauthorizations: ${app.endpoints.ltss-integration-services}
            adhocmember: ${app.endpoints.ltss-integration-services}
      
      cueIntegration:
        applicationId: 5666A5D6-3303-4E2A-BC45-05A3191286F0
        cueServiceUrl: ${app.endpoints.cue}/api/documents
        fileUploadUrl: ${app.endpoints.ltss-integration-services}/fileupload
        cueDocViewUrl: ${app.endpoints.ltss-integration-services}
        # templateServiceUrl: http://va10twviss352.us.ad.wellpoint.com:85/CUE_RESTServices_SIT/api/GenerateDocument
        # assessmentServiceUrl: http://va10twviss352.us.ad.wellpoint.com:85/CUE_RESTServices_SIT/api/generateassessment
      #  applicationId: 58C02B8C-0FD6-4FBD-9AC3-90493B232F2D
      #  templateServiceUrl: http://va10twviss352.us.ad.wellpoint.com:85/CUE_RESTServices_SIT/api/GenerateDocument
      
      #  assessmentServiceUrl: http://va10twviss352.us.ad.wellpoint.com:85/CUE_RESTServices_SIT/api/generateassessment
  20. Build the project(Refer 5.1→8)

  21. Run the application:

    1. Right click com.atlas.helloworld-web and click Run as→Spring Boot App

      HW5
    2. Wait to the see the Started Application log in the console

      HW5
  22. Go to http://localhost:8082/helloworld/login to view your output

    HW5

Form Elements

Objective

To add form elements like Textbox, Radio button, Check box, Signature and Submit button to our Hello World page.

Steps

  1. Add form elements to our webpage with the help of simple annotations.

  2. Open VRHelloworld.java

    HW5
  3. Update VRHelloWorld.java as follows:

VRHelloWorld.java
package com.atlas.client.extension.helloworld;

import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.NotNull;
import com.antheminc.oss.nimbus.domain.defn.Domain;
import com.antheminc.oss.nimbus.domain.defn.MapsTo;
import com.antheminc.oss.nimbus.domain.defn.Model;
import com.antheminc.oss.nimbus.domain.defn.Model.Param.Values.Source;
import com.antheminc.oss.nimbus.domain.defn.Repo;
import com.antheminc.oss.nimbus.domain.defn.Domain.ListenerType;
import com.antheminc.oss.nimbus.domain.defn.MapsTo.Path;
import com.antheminc.oss.nimbus.domain.defn.MapsTo.Type;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Button;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.ButtonGroup;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.CheckBoxGroup;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Form;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Header;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Page;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Paragraph;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Radio;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Section;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Signature;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.StaticText;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.TextBox;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Tile;
import com.antheminc.oss.nimbus.domain.defn.ViewConfig.ViewRoot;
import com.antheminc.oss.nimbus.domain.defn.extension.Content.Label;
import com.antheminc.oss.nimbus.domain.model.config.ParamValue;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

// Defining the Domain Entity
@Domain(value ="helloworldview", includeListeners = {ListenerType.websocket})

//Repository values
@Repo(value=Repo.Database.rep_none,cache=Repo.Cache.rep_device)

//Generate Getter and Setter for the class
@Getter @Setter @ToString(callSuper=true)

//Layout of the Root
@ViewRoot(layout = "home")
public class VRHelloworld{

// Define a Page instance
@Page(defaultPage=true)
private VPHelloworld vpHelloworld;

// Define a Tile instance
@Model
@Getter @Setter
public static class VPHelloworld{

     @Tile(size = Tile.Size.Large)
     private VTHelloworld vtHelloworld;
}

// Add a Header variable and define a Section instance
@Model
@Getter @Setter
public static class VTHelloworld{

    @Header(size=Header.Size.H3)
    private String addHelloWorldHeader;

    @Section
    private VSHelloworld vsHelloworld;
}

// Define a Form instance which has one column
@Model
@Getter @Setter
public static class VSHelloworld{

        @Form(cssClass="oneColumn")
        private VFHelloworld vfHelloworld;
    }

//Define a Paragraph with the Label “Hello All”
@Model
    @Getter @Setter
    public static class VFHelloworld {

        @Paragraph
        @Label(value = "Hello All!")
        private String title1;

       // Creates a Textbox which is not null and has the label Name
         @TextBox @NotNull
         @Label(" Name") private String name;

        /* Creates a CheckBox which changes on an event
           with the label Choose an option and has options defined
           in YNType.class
        */
         @CheckBoxGroup(postEventOnChange = true)
      @Model.Param.Values(value = YNType1.class)
      @Label(value = "Skill Set") private String checkbox;

      /* Creates a RadioButton which changes on an event
         with the label Choose an option and has options defined
         in YNType.class
      */ @Radio(postEventOnChange = true)
      @Model.Param.Values(value = YNType.class)
         @Label(value = "Years of Experience") private String radio;

        /* Creates a Signature box which accepts signature and
           has the label  Signature
        */
         @Signature(postEventOnChange=true)
         @Label(" Signature") private String signature;

         // Creates a Button with style PRIMARY and has the label Submit
         @Button(style=Button.Style.PRIMARY)
         @Label(" Submit")
         private String submit;
}
        /* YNTypeclass creates a List which accept values of the
           type ParamValue and has values 0-2 yrs,2-5 yrs, Above 5 yrs
        */
          public static class YNType implements Source
      {
         @Override
          public List<ParamValue> getValues(String paramPath)
           {
             List<ParamValue> values = new ArrayList<>();
              values.add(new ParamValue("0", "0-2 yrs"));
              values.add(new ParamValue("2", "2-5 yrs"));
              values.add(new ParamValue("5", "Above 5 yrs"));
              return values;
            }
       }



        /* YNTypeclass1 creates a List which accept values of the
           type ParamValue and has values Core Java,Spring MVC, Spring Cloud,
           DevOps
        */

       public static class YNType1 implements Source
       {
          @Override
            public List<ParamValue> getValues(String paramPath)
             {
              List<ParamValue> values = new ArrayList<>();
              values.add(new ParamValue("CJ", "Core Java"));
              values.add(new ParamValue("SM", "Spring MVC"));
              values.add(new ParamValue("SC", "Spring Cloud"));
              values.add(new ParamValue("De", "DevOps"));
              return values;
             }
          }
}
  1. Build the project(Refer 5.1→8)

  2. Run the application (Refer 5.1→21)

  3. Output:

    FE1

Using drools within framework

Objective

Changing the state of the variable with the help of a drools file

Steps

  1. Create 2 new maven projects:

    1. com.atlas.client.extension.newhello

    2. com.atlas.newhello-web

      HW5
  2. Update pom.xml

    HW5
  3. Create 2 java classes inside com.atlas.client.extension.newhello

    1. VLHome.java

    2. VRNewhello.java

      HW5
      VLHome.java
      package com.atlas.client.extension.newhello;
      import com.antheminc.oss.nimbus.domain.defn.Domain;
      import com.antheminc.oss.nimbus.domain.defn.Domain.ListenerType;
      import com.antheminc.oss.nimbus.domain.defn.Model;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Hints;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Initialize;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Link;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Page;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.PageHeader;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Paragraph;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Section;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Hints.AlignOptions;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.PageHeader.Property;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Section.Type;
      import com.antheminc.oss.nimbus.domain.defn.extension.Content.Label;
      import com.antheminc.oss.nimbus.domain.defn.Repo;
      import com.antheminc.oss.nimbus.domain.defn.Repo.Cache;
      import com.antheminc.oss.nimbus.domain.defn.Repo.Database;
      
      import lombok.Getter;
      import lombok.Setter;
      
      @Domain(value="home", includeListeners={ListenerType.websocket})
      @Repo(value = Database.rep_none, cache = Cache.rep_device)
      @Getter @Setter
      public class VLHome {
      
          @Page private VPHome vpHome;
      
          @Model @Getter @Setter
          public static class VPHome {
      
              @Section(Type.HEADER)
              private VSHomeHeader vsHomeHeader;
      
          }
          @Model @Getter @Setter
          public class VSHomeHeader {
      
      
              @PageHeader(Property.APPTITLE)
              @Paragraph
              @Label(value = "Welcome !")
              private String title;
      
          }
      }
      VRNewHello.java
      package com.atlas.client.extension.newhello;
      
      import javax.validation.constraints.NotNull;
      import com.antheminc.oss.nimbus.domain.defn.Domain;
      import com.antheminc.oss.nimbus.domain.defn.Model;
      import com.antheminc.oss.nimbus.domain.defn.Repo;
      import com.antheminc.oss.nimbus.domain.defn.Domain.ListenerType;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Form;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Header;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Page;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Paragraph;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Section;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.TextBox;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Tile;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.ViewRoot;
      import com.antheminc.oss.nimbus.domain.defn.extension.Content.Label;
      import com.antheminc.oss.nimbus.domain.defn.extension.Rule;
      
      import lombok.Getter;
      import lombok.Setter;
      import lombok.ToString;
      
      @Domain(value ="newhelloview", includeListeners = {ListenerType.websocket})
      @Repo(value=Repo.Database.rep_none,cache=Repo.Cache.rep_device)
      @Getter @Setter @ToString(callSuper=true)
      @ViewRoot(layout = "home")
      public class VRNewhello {
      
           @Page(defaultPage=true)
              private VPNewhello vpNewhello;
      
      @Model
      @Getter @Setter
      public static class VPNewhello{
      
        @Tile(size = Tile.Size.Large)
        private VTNewhello vtNewhello;
      }
      
      @Model
      @Getter @Setter
      public static class VTNewhello{
      
       @Header(size=Header.Size.H3)
       private String addHelloWorldHeader;
      
       @Section
       private VSNewhello vsNewhello;
      }
      @Model
      @Getter @Setter
      public static class VSNewhello{
      
           @Form(cssClass="oneColumn")
           private VFNewhello vfNewhello;
       }
      
      @Model
       @Getter @Setter
       public static class VFNewhello {
      
              @Paragraph
              @Label(value = "Hello All!")
              private String title1;
      
             // Listens to an event change in the textbox
              @TextBox(postEventOnChange=true) @NotNull
              @Label("Enter your name:")
              @Rule("sample")
               private String itname;
      
              @TextBox @NotNull
              @Label(" You have entered:") private String otname;
      }
      }
  4. Create Application.java to start up our spring boot application and LoginController.java class inside com.atlas.newhello-web → src/main/java → com.atlas.newhello (Refer 5.1→18)

  5. Create application.yml file under com.atlas.newhello-web → src/main/resources and update pom.xml (Refer 5.1→19)

    HW5
  6. Create sample.drl inside com.atlas.client.extension.newhello → src/main/resources

    sample.drl: This rules file contains details on how the state of the form variables are set through web sockets.

    HW5
    sample.drl
    import com.antheminc.oss.nimbus.domain.model.state.internal.DefaultParamState;
    
    rule "output"
    when
    $core : DefaultParamState($core.findParamByPath("/../itname").getState()!=null)
    then
    $core.findParamByPath("/../otname").setState($core.findParamByPath("/../itname").getState());
    end
  7. Build the project (Refer 5.1→8)

  8. Run the application and view the output:

    1. Go to http://localhost:8082/newhello/login to view your screen.

    2. Enter text in the first textbox

      DR1
    3. Click the second textbox to see the text you have entered.

      DR1

Understanding Actions: _replace

Objective

Get the value from one form element and display in another form element with the help of Config annotation(Changing the state of the variable)

Steps

  1. Open VRNewHello.java

    HW5
    1. Update VRNewHello.java as follows:

      VRNewHello.java
      package com.atlas.client.extension.newhello;
      
      import javax.validation.constraints.NotNull;
      import com.antheminc.oss.nimbus.domain.defn.Domain;
      import com.antheminc.oss.nimbus.domain.defn.Model;
      import com.antheminc.oss.nimbus.domain.defn.Repo;
      import com.antheminc.oss.nimbus.domain.defn.Domain.ListenerType;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Form;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Header;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Page;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Paragraph;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Section;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.TextBox;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Tile;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.ViewRoot;
      import com.antheminc.oss.nimbus.domain.defn.extension.Content.Label;
      import com.antheminc.oss.nimbus.domain.defn.extension.Rule;
      
      
      import lombok.Getter;
      import lombok.Setter;
      import lombok.ToString;
      
      @Domain(value ="newhelloview", includeListeners = {ListenerType.websocket})
      @Repo(value=Repo.Database.rep_none,cache=Repo.Cache.rep_device)
      @Getter @Setter @ToString(callSuper=true)
      @ViewRoot(layout = "home")
      public class VRNewhello {
      
           @Page(defaultPage=true)
              private VPNewhello vpNewhello;
      
      @Model
      @Getter @Setter
      public static class VPNewhello{
      
        @Tile(size = Tile.Size.Large)
        private VTNewhello vtNewhello;
      }
      
      @Model
      @Getter @Setter
      public static class VTNewhello{
      
       @Header(size=Header.Size.H3)
       private String addHelloWorldHeader;
      
       @Section
       private VSNewhello vsNewhello;
      }
      @Model
      @Getter @Setter
      public static class VSNewhello{
      
           @Form(cssClass="oneColumn")
           private VFNewhello vfNewhello;
       }
      
      @Model
       @Getter @Setter
       public static class VFNewhello {
      
              @Paragraph
              @Label(value = "Hello All!")
              private String title1;
      
             // Listens to an event change in the textbox
              @TextBox(postEventOnChange=true) @NotNull
              @Label("Enter your name:")
               private String itname;
      
              @TextBox
              @Label(" Output:") private String otname;
      
             /* Here we are updating the state of the variable. The action _replace
              * sets the state of the param identified by domain alias to a new state,
              * provided as a query parameter: rawPayload*/
      @Config(url="/p/newhelloview/vpNewhello/vtNewhello/vsNewhello/vfNewhello/"
                  + "otname/_replace?rawPayload=\"You have typed <!/../itname!>\"")
              @Button(style=Button.Style.SECONDARY)
              @Label(" Click to see the output")
              private String submit;
      
      
      }
      }
  2. Build the project (Refer 5.1→8)

  3. Run the application:

    1. Go to http://localhost:8082/newhello/login to view your screen.

    2. Enter text in the first textbox

    3. Click the "Click to see the output" button to see the same text in the second textbox.

      AC1

Understanding Actions: _new

Objective

Creates a new instance of the model . In this example, on click of a button, we will be redirected to a new landing page

Steps

  1. Open VRNewHello.java

    HW5
    1. Update VRNewHello.java as follows:

      VRNewHello.java
      package com.atlas.client.extension.newhello;
      
      import javax.validation.constraints.NotNull;
      import com.antheminc.oss.nimbus.domain.defn.Domain;
      import com.antheminc.oss.nimbus.domain.defn.Model;
      import com.antheminc.oss.nimbus.domain.defn.Repo;
      import com.antheminc.oss.nimbus.domain.defn.Domain.ListenerType;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Form;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Header;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Page;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Paragraph;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Section;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.TextBox;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Tile;
      import com.antheminc.oss.nimbus.domain.defn.ViewConfig.ViewRoot;
      import com.antheminc.oss.nimbus.domain.defn.extension.Content.Label;
      import com.antheminc.oss.nimbus.domain.defn.extension.Rule;
      
      import lombok.Getter;
      import lombok.Setter;
      import lombok.ToString;
      
      @Domain(value ="newhelloview", includeListeners = {ListenerType.websocket})
      @Repo(value=Repo.Database.rep_none,cache=Repo.Cache.rep_device)
      @Getter @Setter @ToString(callSuper=true)
      @ViewRoot(layout = "home")
      public class VRNewhello {
      
           @Page(defaultPage=true)
              private VPNewhello vpNewhello;
      
      @Model
      @Getter @Setter
      public static class VPNewhello{
      
        @Tile(size = Tile.Size.Large)
        private VTNewhello vtNewhello;
      }
      
      @Model
      @Getter @Setter
      public static class VTNewhello{
      
       @Header(size=Header.Size.H3)
       private String addHelloWorldHeader;
      
       @Section
       private VSNewhello vsNewhello;
      }
      @Model
      @Getter @Setter
      public static class VSNewhello{
      
           @Form(cssClass="oneColumn")
           private VFNewhello vfNewhello;
       }
      
      @Model
       @Getter @Setter
       public static class VFNewhello {
      
              @Paragraph
              @Label(value = "Hello All!")
              private String title1;
      
             // Listens to an event change in the textbox
              @TextBox(postEventOnChange=true) @NotNull
              @Label("Enter your name:")
               private String itname;
      
              @TextBox
              @Label(" Output:") private String otname;
      
             /* Here we are updating the state of the variable. The action _replace
              * sets the state of the param identified by domain alias to a new state,
              * provided as a query parameter: rawPayload*/
      @Config(url="/p/newhelloview/vpNewhello/vtNewhello/vsNewhello/vfNewhello/"
                  + "otname/_replace?rawPayload=\"You have typed <!/../itname!>\"")
              @Button(style=Button.Style.SECONDARY)
              @Label(" Click to see the output")
              private String submit;
      
             /*Once you click the button, you will be redirected to
              * a new page defined in VRNewHelloLanding.java */
              @Config(url="/p/newhellolandingview/_new")
              @Button(style=Button.Style.SECONDARY)
              @Label(" Click here to go to the next page")
              private String submit1;
      }
      }
  2. Create VRNewHelloLanding.java inside com.atlas.client.extension.newhello → src/main/java → com.atlas.client.extension.newhello

    NE
  3. Add the following code

    VRNewHelloLanding.java
    package com.atlas.client.extension.newhello;
    
    import javax.validation.constraints.NotNull;
    
    import com.antheminc.oss.nimbus.domain.defn.Domain;
    import com.antheminc.oss.nimbus.domain.defn.Model;
    import com.antheminc.oss.nimbus.domain.defn.Repo;
    import com.antheminc.oss.nimbus.domain.defn.Domain.ListenerType;
    import com.antheminc.oss.nimbus.domain.defn.Execution.Config;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Button;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Form;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Header;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Page;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Paragraph;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Section;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.TextBox;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Tile;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.ViewRoot;
    import com.antheminc.oss.nimbus.domain.defn.extension.Content.Label;
    import com.atlas.client.extension.newhello.VRNewhello.VFNewhello;
    import com.atlas.client.extension.newhello.VRNewhello.VPNewhello;
    import com.atlas.client.extension.newhello.VRNewhello.VSNewhello;
    import com.atlas.client.extension.newhello.VRNewhello.VTNewhello;
    
    import lombok.Getter;
    import lombok.Setter;
    import lombok.ToString;
    
    @Domain(value ="newhellolandingview", includeListeners = {ListenerType.websocket})
    @Repo(value=Repo.Database.rep_none,cache=Repo.Cache.rep_device)
    @Getter @Setter @ToString(callSuper=true)
    @ViewRoot(layout = "home")
    
    public class VRNewHelloLanding {
        @Page(defaultPage=true)
        private VPNewhelloLanding vpNewhellolanding;
    
    @Model
    @Getter @Setter
    public static class VPNewhelloLanding{
    
    @Tile(size = Tile.Size.Large)
    private VTNewhelloLanding vtNewhellolanding;
    }
    
    @Model
    @Getter @Setter
    public static class VTNewhelloLanding{
    
    @Header(size=Header.Size.H3)
    private String addHelloWorldHeader;
    
    @Section
    private VSNewhelloLanding vsNewhellolanding;
    }
    @Model
    @Getter @Setter
    public static class VSNewhelloLanding{
    
     @Form(cssClass="oneColumn")
     private VFNewhelloLanding vfNewhellolanding;
    }
    
    @Model
    @Getter @Setter
    public static class VFNewhelloLanding {
    
        @Paragraph
        @Label(value = "Hello All! This is your landing page")
        private String title1;
    
    }
    
    }
  4. Build the project (Refer 5.1→8)

  5. Run the application:

    1. Go to http://localhost:8082/newhello/login

    2. Enter text in the first textbox

      AC2
    3. Click the first button to see the output on the textbox

      AC3
    4. Click the second button "Click here to go to the next page" to land on your new page

      AC4

Interacting with Database using framework

Objective

To understand how the framwork interact with the database through the DB client Robo3T

Steps

  1. Create 2 new packages inside com.atlas.client.extension.newhello named as follows:

    1. com.atlas.client.extension.newhello.core

    2. com.atlas.client.extension.newhello.view

      DB
  2. Move the previously created java files namely- VLHome.java, VLNewHello.java, VLNewHelloLanding.java inside com.atlas.client.extension.newhello.view

    DB
  3. Create a new java class Name.java inside com.atlas.client.extension.newhello.core

    DB
  4. Add the following code to Name.java

Name.java
package com.atlas.client.extension.newhello.core;

import com.antheminc.oss.nimbus.domain.defn.Domain;
import com.antheminc.oss.nimbus.domain.defn.Repo;
import com.antheminc.oss.nimbus.domain.defn.Domain.ListenerType;
import com.antheminc.oss.nimbus.domain.defn.Repo.Cache;
import com.antheminc.oss.nimbus.domain.defn.Repo.Database;
import com.antheminc.oss.nimbus.entity.AbstractEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Domain(value="Name", includeListeners={ListenerType.persistence, ListenerType.update})
@Repo(value=Database.rep_mongodb, cache=Cache.rep_device)
@Getter
@Setter
@ToString(callSuper=true)

public class Name extends AbstractEntity.IdLong{

    private static final long serialVersionUID = 1L;

    private String firstName;

    private String lastName;
}
  1. Modify VLNewHelloLanding.java

    VRNewHelloLanding.java
    package com.atlas.client.extension.newhello.view;
    
    import javax.validation.constraints.NotNull;
    
    import com.antheminc.oss.nimbus.domain.defn.Domain;
    import com.antheminc.oss.nimbus.domain.defn.Model;
    import com.antheminc.oss.nimbus.domain.defn.Repo;
    import com.antheminc.oss.nimbus.domain.defn.Domain.ListenerType;
    import com.antheminc.oss.nimbus.domain.defn.Execution.Config;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Button;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Form;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Header;
    package com.atlas.client.extension.newhello.view;
    
    import javax.validation.constraints.NotNull;
    
    import com.antheminc.oss.nimbus.domain.defn.Domain;
    import com.antheminc.oss.nimbus.domain.defn.Model;
    import com.antheminc.oss.nimbus.domain.defn.Repo;
    import com.antheminc.oss.nimbus.domain.defn.Domain.ListenerType;
    import com.antheminc.oss.nimbus.domain.defn.Execution.Config;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Button;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Form;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Header;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Page;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Paragraph;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Section;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.TextBox;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.Tile;
    import com.antheminc.oss.nimbus.domain.defn.ViewConfig.ViewRoot;
    import com.antheminc.oss.nimbus.domain.defn.extension.Content.Label;
    import com.atlas.client.extension.newhello.core.Name;
    import com.atlas.client.extension.newhello.view.VRNewhello.VFNewhello;
    import com.atlas.client.extension.newhello.view.VRNewhello.VPNewhello;
    import com.atlas.client.extension.newhello.view.VRNewhello.VSNewhello;
    import com.atlas.client.extension.newhello.view.VRNewhello.VTNewhello;
    
    import com.antheminc.oss.nimbus.domain.defn.MapsTo;
    import com.antheminc.oss.nimbus.domain.defn.MapsTo.Path;
    import com.antheminc.oss.nimbus.domain.defn.MapsTo.Type;
    
    import lombok.Getter;
    import lombok.Setter;
    import lombok.ToString;
    
    @Domain(value ="newhellolandingview", includeListeners = {ListenerType.websocket})
    @Repo(value=Repo.Database.rep_none,cache=Repo.Cache.rep_device)
    @Getter @Setter @ToString(callSuper=true)
    @MapsTo.Type(Name.class)
    @ViewRoot(layout = "home")
    
    public class VRNewHelloLanding {
        @Page(defaultPage=true)
        private VPNewhelloLanding vpNewhellolanding;
    
    @Model
    @Getter @Setter
    public static class VPNewhelloLanding{
    
    @Tile(size = Tile.Size.Large)
    private VTNewhelloLanding vtNewhellolanding;
    }
    
    @Model
    @Getter @Setter
    public static class VTNewhelloLanding{
    
    @Header(size=Header.Size.H3)
    private String addHelloWorldHeader;
    
    @Section
    private VSNewhelloLanding vsNewhellolanding;
    }
    @Model
    @Getter @Setter
    public static class VSNewhelloLanding{
    
     @Path(linked=false)
     @Form(cssClass="oneColumn")
     private VFNewhelloLanding vfNewhellolanding;
    }
    
    @Model
    @Getter @Setter
    @MapsTo.Type(Name.class)
    public static class VFNewhelloLanding {
    
    
    
        @TextBox(postEventOnChange=true)
        @Label("First Name")
        @MapsTo.Path private String firstName;
    
    
        @TextBox (postEventOnChange=true)
        @Label("Last Name")
        @MapsTo.Path private String lastName;
    
    
      // Get the parameters from Name.java
        @Config(url = "/p/Name/_new?fn=_initEntity&target=/firstName&json=\"<!../firstName!>\"&target=/lastName&json=\"<!../lastName!>\"")
        @Button(style=Button.Style.PRIMARY, type = Button.Type.submit)
        @Label("Click to insert into DB.")
        private String clickMe;
    
    }
    
    }
  2. Build the project (Refer 5.1→8)

  3. Run the application:

    1. Go to http://localhost:8082/newhello/login

    2. Click "Click here to go to the next page"

      D1
    3. Enter the first name and last name and click Click to insert into db

      D2
    4. Go to Robo3T and expand helloworld→Name to see the data inserted

      D3

Using SSL to connect to MongoDB:

  1. We have seen how to connect to our local database using robo 3T in our Module 1. We will see how to connect to development environment db.

  2. Go to : https://confluence.anthem.com/display/NIM/Nimbus+Environment+Links?preview=%2F155207215%2F226468110%2Froot_chain.pem and download root_chaim.pem certificate

    S1a
  3. Create a new folder in your desktop and copy the downloaded certificate to the new folder

  4. Open Robo 3T and click Create. Enter details as follows in the Connection tab:

    Name: cm dm dev
    Address: VA33DLVMDB304.wellpoint.com
    Port : 37043
    S1
  5. Click the Authentication tab. Select Perform Authentication and enter the following details:

    Database: NICU1D
    User Name: nimbusDev
    Password: ArR&GX8Z
    S2
  6. Click SSL tab.

    • Select Use SSL Protocol check box.

    • Select Authentication Method as Use CA Certificate

    • Choose CA Certificate from your desktop folder (root_chain.pem)

    • Click Advanced Options

    • Select Allowed from the drop down against Invalid Hostname

    • Click Save and then Test

      S3
  7. Connection is established

    S4
  8. Close the alert box . We can see that cm dm dev is in the list of connections

    S5
  9. Click Connect

    S6

Conclusion:

Yes!!! You’re well on your way in understanding and coding on Nimbus framework!