To work with Foresight Analytics Platform create the FapActivity application, which uses the web method implemented in the RequestAPI unit.
Foresight Analytics Platform is addressed identically as addressing to WEB resources.
The application enables the user to get data of Foresight Analytics Platform.
Before creating the FapActivity application add the Foresight Web data source with the parameters:
Name: Fap.
Host: 10.30.217.48.
Port: 80.
Protocol: HTTP.
Data transfer timeout: 40.
Path: FPBI_App_v9.2x64/axis2/services/PP.SOM.Som.
Metabase ID: TEST_INV_X.
The FapActivity application consists of one screen and a button:
CONNECTFAP. Get data of Foresight Analytics Platform.
To view application work results, use the interactive example:
Click the CONNECTFAP button.
public class FapActivity extends AppCompatActivity {
private static final String MY_URL = "http://testmasterfmp.fsight.cloud/";
private static final VersionAPI MY_VERSION_API = VersionAPI.V_1;
private static final String MY_ENVIRONMENT = "Leonid_environment";
private static final String MY_PROJECT = "Leonid_project";
private static final String MY_VERSION = "v1";
private static final String MY_LOGIN = "ilm";
private static final String MY_PASSWORD = "123123";
public static final String MY_WEB_RESOURCE = "Fap";
private static final String TAG = "FapActivity";
private HyperHive hyperHive;
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fap);
textView = findViewById(R.id.text_view_activity_fap);
Handler uiHandler = new Handler();
hyperHive = new HyperHiveState(getApplicationContext())
.setHostWithSchema(MY_URL)
.setApiVersion(MY_VERSION_API)
.setEnvironmentSlug(MY_ENVIRONMENT)
.setProjectSlug(MY_PROJECT)
.setVersionProject(MY_VERSION)
.setHandler(uiHandler)
.buildHyperHive();
auth();
}
public void auth() {
String status = hyperHive.authAPI.auth(MY_LOGIN, MY_PASSWORD, true).execute().toString();
showDate(status);
}
public void connectFap(View view) {
WebCallParams webCallParams = new WebCallParams();
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/json");
headers.put("Content-Encoding", "utf-8");
webCallParams.setHeaders(headers);
webCallParams.setData("{\"OpenMetabase\":{\"tDef\":{\"id\":\"TEST_INV_X\"},\"tCreds\":{\"user\":{\"id\":\"TEST_INV_X\"},\"pass\":\"TEST_INV_X\"},\"tArg\": \"\"}}");
String status = hyperHive.requestAPI.web(MY_WEB_RESOURCE, webCallParams).execute();
showDate(status);
}
private void showDate(String status) {
Log.d(TAG, "showDate: " + status);
textView.setText(status);
}
}
See also: