GDPR Cookie Consent by Free Privacy Policy Generator
post thumb
Asset Control
by Matthias Hanitzsch-Moonlight/ on 14 Mar 2018

A Basic Java API for Asset Control - Formula Engine

A brief demonstration on how to execute Formula Engine code via the Basic Java API.

Note: This article is part of a series. You can find a list of all the articles here. As a minimum pre-requisite you should be familiar with the article Connect to AC.

Executing Formula Engine code

The Basic Java API allows the execution of Formula Engine code via the AcService class:

  List<List<String>> res = ac.executeFormulaEngineQuery("return 1;");
  assertThat(res.get(0).get(0), is("1"));

  List<List<String>> res2 = ac.executeFormulaEngineQuery("return [1, 2];");
  assertThat(res2.get(0).get(0), is("1"));
  assertThat(res2.get(1).get(0), is("2"));

  List<List<String>> res3 = ac.executeFormulaEngineQuery("return [[1, 2], [3, 4]];");
  assertThat(res3.get(0).get(0), is("1"));
  assertThat(res3.get(0).get(1), is("2"));
  assertThat(res3.get(1).get(0), is("3"));
  assertThat(res3.get(1).get(1), is("4"));
  List<List<String>>res4 = ac.executeFormulaEngineQuery("return [[1, 2], [3, ['abc']]];");
  assertThat(res4.get(0).get(0), is("1"));
  assertThat(res4.get(0).get(1), is("2"));
  assertThat(res4.get(1).get(0), is("3"));
  assertThat(res4.get(1).get(1), is("[abc]"));

The result returned is simply a matrix of strings. Please keep in mind that only queries are allowed. Updates are not possible.

Thank you for reading.

This concludes the introduction to the Basic Java API for Asset Control. I hope you find the material useful. Should you be interested in an Extended Java API, please get in touch via email or on LinkedIn.

comments powered by Disqus