Java Application with bonita

1
0
-1

Hi,

I want to create a JAVA application to start the process , to create and assign roles and users login and logout and also all other process flow to complete with java only. I want to use only process daigram from bonita studio all other from starting to end deployments and production also I want to do in java only. Please suggest me. Thanks in Advance.

1 answer

1
0
-1

Hello,

You have to use the JAVA API to do that.

In the maven, just add



org.bonitasoft.engine
bonita-client
7.10.4

then here a simple Java example

package org.bonitasoft.training;


import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.bonitasoft.engine.api.ApiAccessType;
import org.bonitasoft.engine.api.IdentityAPI;
import org.bonitasoft.engine.api.LoginAPI;
import org.bonitasoft.engine.api.TenantAPIAccessor;
import org.bonitasoft.engine.identity.RoleSearchDescriptor;
import org.bonitasoft.engine.identity.User;
import org.bonitasoft.engine.identity.UserCriterion;
import org.bonitasoft.engine.identity.UserSearchDescriptor;
import org.bonitasoft.engine.search.SearchOptionsBuilder;
import org.bonitasoft.engine.search.SearchResult;
import org.bonitasoft.engine.session.APISession;
import org.bonitasoft.engine.util.APITypeManager;

public class TestUserList {

public static void main(final String args[]) {
final Logger logger = Logger.getLogger("TestUserList");
try {

final Map map = new HashMap();
map.put("server.url", "http://localhost:8080");
map.put("application.name", "bonita");
APITypeManager.setAPITypeAndParams(ApiAccessType.HTTP, map);

// Set the username and password
final String username = "William.Jobs";
final String password = "bpm";
// get the LoginAPI using the TenantAPIAccessor
final LoginAPI loginAPI = TenantAPIAccessor.getLoginAPI();
// log in to the tenant to create a session
final APISession session = loginAPI.login(username, password);
// get the identityAPI bound to the session created previously.
final IdentityAPI identity = TenantAPIAccessor.getIdentityAPI(session);

// get the list of users
final List user = identity.getUsers(0, 30, UserCriterion.FIRST_NAME_ASC);

// display the list of userNames

for (int i = 0; i < user.size(); i++) {
System.out.println(user.get(i).getUserName());
}

loginAPI.logout(session);
} catch (final Exception e) {
logger.log(Level.SEVERE, "ERROR RETRIEVING USERS", e);
}
}
}

Hope this help,

Comments

Submitted by ramireddy.pingala on Fri, 09/04/2020 - 09:28

Thank you Pierre-yves Monnet for helping me. Actually i want use only for processFlow diagram from bonita studio, rest of the things i.e creation of orgnization, groups , roles and users i want to do from java application and also deplyment and evcerything whatever we do from studio i want to do from java application except process flow daigram.

Submitted by Pierre-yves Monnet on Fri, 09/04/2020 - 20:08

Hello,

I don't get it.

I understood that you want to access Bonita via JAVA.

To execute the process, you have

* to install a Bonita Server, then you have to deal with organization to be able to connect. Then, you can use this piece of Java to connect your server.

* you don't want to install a Bonita Server. Then, you want to include the Bonita Server in YOUR application. It's more complex, but doable. Then, your application must include all components used by the BonitaServer (Spring, Hibernate....) and you have to deal with all the artifact by your application (deploy a process...)

That what we call the "embed engine" : visit https://documentation.bonitasoft.com/bonita/7.11/embed-engine

Hope this help,

Notifications