Publisher Full is a feature that allows you to display objects from your BIMachine project outside the platform, dynamically, securely and with support for customized filters. This functionality is ideal for incorporating dashboards, analyses, KPIs and maps into external applications.
Below is a complete step-by-step guide to setting up and using Publisher Full.
1. Application key 🔑
To start using Publisher Full, you need to create an application key, see the step-by-step below or in more detail here:
- Go to the Account Management menu.
- Click on New Application Key.
- Give the key a name.
- Copy the generated key.
This key will be used to authenticate future requests to the API.
2. Authentication token generation 🔐
With the application key, you can generate a user authentication token, which is needed to validate external access.
POST
<url_aplicação>/api/token-manager/?appKey=<chave_aplicação>
Request Body:
{
"email":"email@exemplo.com"
}
Expected answer:
{
"id": 1,
"applicationKey": {
"id": 1,
"name": "NomeDaAplicacao",
"token": "chave_da_aplicacao",
"account": {
"id": 1,
"accountOwnerId": 1,
"accountMasterId": 1,
"applicationKeys": null,
"name": "NomeDaConta"
},
"blockByDomain": false,
"allowedDomains": null
},
"user": {
"id": 1,
"username": "usuario@dominio.com",
"email": "usuario@dominio.com",
"preferredLanguage": "idioma_preferido",
"displayName": "Nome de Exibição",
"viewTutorial": false,
"createObject": false,
"addData": false,
"preferences": {
"id": 1,
"defaultProjectId": 0,
"defaultCockpits": null
},
"phone": "(00) 0000-0000",
"projectLinks": null,
"members": [1],
"avatarLink": "/avatar?user-id=1&i=0000000000000&oi=0"
},
"token": "token_de_autenticacao"
}
The token generated is used to authenticate the user in BIMachine when used in other applications. This token is unique and expires in 30 minutes, but is renewed every time it is used.
Example JAVA code for token authentication:
public String getToken(){
try {
return new SimpleTimeLimiter().callWithTimeout(new Callable<String>() {
@Override
public String call() throws Exception {
String emailUser = "usuario@dominio.com";
String appKey = "chave_da_aplicacao";
RestTemplate restTemplate = new RestTemplate();
URI uri = UriComponentsBuilder
.fromHttpUrl("https://app.bimachine.com.br/api/token-manager")
.queryParam("appKey", appKey)
.build()
.toUri();
HttpEntity httpEntity = jsonEntity(new EmailToken(emailUser, appKey));
ResponseEntity<Token> responseEntity = restTemplate.postForEntity(uri, httpEntity, Token.class);
if (responseEntity.getStatusCode().value() == 200) {
return responseEntity.getBody().getToken();
} else {
return null;
}
}
}, 2, TimeUnit.SECONDS, true);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
3. Listing projects and objects📋
After authenticating the user, you can consult the available projects and objects.
🔎 List account projects
GET
<url_aplicação>/api/projects/list?appKey=<chave_aplicação>
🔎 List objects in a project
GET
<url_aplicação>/api/projects/<id_projeto>/find-resources-for/<id_usuario>?appKey=<sua_chave_aplicacao>&addCaptions=true&addPublisher=true&filter=analysis&filter=dashboard&filter=maps&filter=kpi
4. Generating the URL for Embedding 🔗
To display the object outside the platform, access it via BIMachine, go to the Publishing menu and copy the generated link. Learn more.
The embed URL can be customized according to the parameters below:
UriComponentsBuilder url = UriComponentsBuilder.fromHttpUrl("https://" + url_app)
.path("/publisher/" + Files.getFileExtension(object.getPath()) + ".spr")
.queryParam("content", object.getPath())
.queryParam("chart", false)
.queryParam("applyFrame", true)
.queryParam("frameBorderColor", "%23CCCCCC")
.queryParam("borderType", "SIMPLE")
.queryParam("showUpdateDate", true)
.queryParam("showTitle", true)
.queryParam("width", width)
.queryParam("height", height);
5. Applying filters 🧩
You can apply custom filters to the object’s publication URL. To do this, the filter must be:
- Created in the project.
- Selected in the object’s publication.
After these steps, you need to convert the desired filter(s) with the JS function below:
encodeURIComponent('[{"id":<id_filtro>,"members":["[<nome_do_membro_desejado>]"]}, {"id":<id_filtro>,"members":["[<nome_do_membro_desejado>]"]}]')
This function will return a string that must be grouped with the link generated in the publisher:
<url_gerado_no_publisher(com seu appKey*)>&filter=<retorno_da_função_js>
*Remember to replace <appToken> at the end of the url with your previously generated token.
This link will return the publisher object with the desired filter applied.
6. Filter queries 🔍
🔸 View members of a filter
GET
<url_aplicação>/api/filters/<id_filtro>/members
🔸 View dynamic period options (Time filters)
GET
<url_aplicação>/api/filters/<id_filtro>/dynamic-periodicities
🔸 View complete filter information
GET
<url_aplicação>/api/filters/<id_filtro>
