Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
</dependency>
<dependency>
<groupId>com.factset.protobuf</groupId>
<artifactId>stachextensions</artifactId>
<version>1.0.0</version>
</dependency>
<artifactId>stachextensions</artifactId>
<version>${stach-extension-version}</version>
</dependency>
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
Expand Down Expand Up @@ -127,6 +127,7 @@
<migbase64-version>2.2</migbase64-version>
<protobuf-version>3.12.2</protobuf-version>
<stach-version>1.0.0</stach-version>
<stach-extension-version>1.1.0</stach-extension-version>
<engines-sdk-version>5.1.0</engines-sdk-version>
<poi-ooxml-version>4.0.1</poi-ooxml-version>
</properties>
Expand Down
31 changes: 25 additions & 6 deletions examples/src/examples/AfiInteractiveOptimizerEngineExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

import javax.ws.rs.client.ClientBuilder;

import com.factset.protobuf.stach.extensions.models.Row;
import com.factset.protobuf.stach.extensions.v2.StachUtilities;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Value;
import factset.analyticsapi.engines.models.*;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
Expand Down Expand Up @@ -42,19 +46,19 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
try {
AfiOptimizerApi apiInstance = new AfiOptimizerApi(getApiClient());
AFIOptimizationParameters afiItem = new AFIOptimizationParameters();

AFIOptimizerStrategy strategy = new AFIOptimizerStrategy();
strategy.setId(STRATEGY_ID);

OptimizerOutputTypes optOutputTypes = new OptimizerOutputTypes();
OptimizerTradesList tradesList = new OptimizerTradesList();
tradesList.setIdentifierType(TRADES_ID_TYPE);
tradesList.setIncludeCash(INCLUDE_CASH);
optOutputTypes.setTrades(tradesList);

afiItem.setStrategy(strategy);
afiItem.setOutputTypes(optOutputTypes);

AFIOptimizationParametersRoot afiOptimizerParam = new AFIOptimizationParametersRoot();
afiOptimizerParam.setData(afiItem);

Expand Down Expand Up @@ -111,12 +115,27 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
}

ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(tables);
System.out.println(json); // Prints the result in 2D table format.
for (TableData table : tables) {
// Prints the results in 2D table format.
List<Row> rows = table.getRows();
String json = mapper.writeValueAsString(rows);
System.out.println(json);

// Prints the metadata
if (table.getRawMetadata().size() > 0) System.out.println("Printing metadata...");
for (Map.Entry<String, List<Value>> rawMetadata : table.getRawMetadata().entrySet()) {
for (Value val : rawMetadata.getValue()) {
System.out.println(" " + rawMetadata.getKey() + ": " + StachUtilities.valueToString(val));
}
}
}
// Uncomment the following line to generate an Excel file
// generateExcel(tables);
} catch (ApiException e) {
handleException("AfiOptimizerEngineExample#Main", e);
} catch (InvalidProtocolBufferException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}

Expand Down
23 changes: 21 additions & 2 deletions examples/src/examples/AxpInteractiveOptimizerEngineExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

import javax.ws.rs.client.ClientBuilder;

import com.factset.protobuf.stach.extensions.models.Row;
import com.factset.protobuf.stach.extensions.v2.StachUtilities;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Value;
import factset.analyticsapi.engines.models.*;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
Expand Down Expand Up @@ -129,12 +133,27 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
}

ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(tables);
System.out.println(json); // Prints the result in 2D table format.
for (TableData table : tables) {
// Prints the results in 2D table format.
List<Row> rows = table.getRows();
String json = mapper.writeValueAsString(rows);
System.out.println(json);

// Prints the metadata
if (table.getRawMetadata().size() > 0) System.out.println("Printing metadata...");
for (Map.Entry<String, List<Value>> rawMetadata : table.getRawMetadata().entrySet()) {
for (Value val : rawMetadata.getValue()) {
System.out.println(" " + rawMetadata.getKey() + ": " + StachUtilities.valueToString(val));
}
}
}
// Uncomment the following line to generate an Excel file
// generateExcel(tables);
} catch (ApiException e) {
handleException("AxpOptimizerEngineExample#Main", e);
} catch (InvalidProtocolBufferException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}

Expand Down
25 changes: 22 additions & 3 deletions examples/src/examples/BpmInteractiveOptimizerEngineExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

import javax.ws.rs.client.ClientBuilder;

import com.factset.protobuf.stach.extensions.models.Row;
import com.factset.protobuf.stach.extensions.v2.StachUtilities;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Value;
import factset.analyticsapi.engines.models.*;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
Expand Down Expand Up @@ -84,7 +88,7 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
do {
response = apiInstance.getOptimizationStatusByIdWithHttpInfo(calculationId);
headers = response.getHeaders();

List<String> cacheControl = headers.get("Cache-Control");
if (cacheControl != null) {
int maxAge = Integer.parseInt(cacheControl.get(0).replace("max-age=", ""));
Expand Down Expand Up @@ -119,12 +123,27 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
}

ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(tables);
System.out.println(json); // Prints the result in 2D table format.
for (TableData table : tables) {
// Prints the results in 2D table format.
List<Row> rows = table.getRows();
String json = mapper.writeValueAsString(rows);
System.out.println(json);

// Prints the metadata
if (table.getRawMetadata().size() > 0) System.out.println("Printing metadata...");
for (Map.Entry<String, List<Value>> rawMetadata : table.getRawMetadata().entrySet()) {
for (Value val : rawMetadata.getValue()) {
System.out.println(" " + rawMetadata.getKey() + ": " + StachUtilities.valueToString(val));
}
}
}
// Uncomment the following line to generate an Excel file
// generateExcel(tables);
} catch (ApiException e) {
handleException("BpmOptimizerEngineExample#Main", e);
} catch (InvalidProtocolBufferException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}

Expand Down
23 changes: 21 additions & 2 deletions examples/src/examples/FiInteractiveEngineExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

import javax.ws.rs.client.ClientBuilder;

import com.factset.protobuf.stach.extensions.models.Row;
import com.factset.protobuf.stach.extensions.v2.StachUtilities;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Value;
import factset.analyticsapi.engines.models.*;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
Expand Down Expand Up @@ -137,12 +141,27 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
}

ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(tables);
System.out.println(json); // Prints the result in 2D table format.
for (TableData table : tables) {
// Prints the results in 2D table format.
List<Row> rows = table.getRows();
String json = mapper.writeValueAsString(rows);
System.out.println(json);

// Prints the metadata
if (table.getRawMetadata().size() > 0) System.out.println("Printing metadata...");
for (Map.Entry<String, List<Value>> rawMetadata : table.getRawMetadata().entrySet()) {
for (Value val : rawMetadata.getValue()) {
System.out.println(" " + rawMetadata.getKey() + ": " + StachUtilities.valueToString(val));
}
}
}
// Uncomment the following line to generate an Excel file
// generateExcel(tables);
} catch (ApiException e) {
handleException("FiEngineExample#Main", e);
} catch (InvalidProtocolBufferException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}

Expand Down
25 changes: 22 additions & 3 deletions examples/src/examples/FpoInteractiveOptimizerEngineExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

import javax.ws.rs.client.ClientBuilder;

import com.factset.protobuf.stach.extensions.models.Row;
import com.factset.protobuf.stach.extensions.v2.StachUtilities;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Value;
import factset.analyticsapi.engines.models.*;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
Expand Down Expand Up @@ -103,7 +107,7 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
do {
response = apiInstance.getOptimizationStatusByIdWithHttpInfo(calculationId);
headers = response.getHeaders();

List<String> cacheControl = headers.get("Cache-Control");
if (cacheControl != null) {
int maxAge = Integer.parseInt(cacheControl.get(0).replace("max-age=", ""));
Expand Down Expand Up @@ -138,12 +142,27 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
}

ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(tables);
System.out.println(json); // Prints the result in 2D table format.
for (TableData table : tables) {
// Prints the results in 2D table format.
List<Row> rows = table.getRows();
String json = mapper.writeValueAsString(rows);
System.out.println(json);

// Prints the metadata
if (table.getRawMetadata().size() > 0) System.out.println("Printing metadata...");
for (Map.Entry<String, List<Value>> rawMetadata : table.getRawMetadata().entrySet()) {
for (Value val : rawMetadata.getValue()) {
System.out.println(" " + rawMetadata.getKey() + ": " + StachUtilities.valueToString(val));
}
}
}
// Uncomment the following line to generate an Excel file
// generateExcel(tables);
} catch (ApiException e) {
handleException("FpoOptimizerEngineExample#Main", e);
} catch (InvalidProtocolBufferException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}

Expand Down
23 changes: 21 additions & 2 deletions examples/src/examples/PAEngineMultipleUnitExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

import javax.ws.rs.client.ClientBuilder;

import com.factset.protobuf.stach.extensions.models.Row;
import com.factset.protobuf.stach.extensions.v2.StachUtilities;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Value;
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
import org.glassfish.jersey.client.ClientProperties;

Expand Down Expand Up @@ -163,8 +167,20 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
}

ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(tables);
System.out.println(json); // Prints the result in 2D table format.
for (TableData table : tables) {
// Prints the results in 2D table format.
List<Row> rows = table.getRows();
String json = mapper.writeValueAsString(rows);
System.out.println(json);

// Prints the metadata
if (table.getRawMetadata().size() > 0) System.out.println("Printing metadata...");
for (Map.Entry<String, List<Value>> rawMetadata : table.getRawMetadata().entrySet()) {
for (Value val : rawMetadata.getValue()) {
System.out.println(" " + rawMetadata.getKey() + ": " + StachUtilities.valueToString(val));
}
}
}
// Uncomment the following line to generate an Excel file
// generateExcel(tables);
} else {
Expand All @@ -174,6 +190,9 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
}
} catch (ApiException e) {
handleException("PAEngineExample#Main", e);
}catch (InvalidProtocolBufferException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}

Expand Down
Loading