Skip to content

Commit 3838001

Browse files
author
Christine Koulopoulos
authored
fix(version): stach extension (#65)
- updating the stach extension version to the latest 1.1.0 - fixing the code snippets to work with `rawMetadata` which was introduced in stach extensions v1.1.0
1 parent 9462313 commit 3838001

14 files changed

+295
-72
lines changed

examples/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
</dependency>
3535
<dependency>
3636
<groupId>com.factset.protobuf</groupId>
37-
<artifactId>stachextensions</artifactId>
38-
<version>1.0.0</version>
39-
</dependency>
37+
<artifactId>stachextensions</artifactId>
38+
<version>${stach-extension-version}</version>
39+
</dependency>
4040
<!-- @Nullable annotation -->
4141
<dependency>
4242
<groupId>com.google.code.findbugs</groupId>
@@ -127,6 +127,7 @@
127127
<migbase64-version>2.2</migbase64-version>
128128
<protobuf-version>3.12.2</protobuf-version>
129129
<stach-version>1.0.0</stach-version>
130+
<stach-extension-version>1.1.0</stach-extension-version>
130131
<engines-sdk-version>5.1.0</engines-sdk-version>
131132
<poi-ooxml-version>4.0.1</poi-ooxml-version>
132133
</properties>

examples/src/examples/AfiInteractiveOptimizerEngineExample.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import javax.ws.rs.client.ClientBuilder;
1010

11+
import com.factset.protobuf.stach.extensions.models.Row;
12+
import com.factset.protobuf.stach.extensions.v2.StachUtilities;
13+
import com.google.protobuf.InvalidProtocolBufferException;
14+
import com.google.protobuf.Value;
1115
import factset.analyticsapi.engines.models.*;
1216
import org.apache.poi.xssf.usermodel.XSSFCell;
1317
import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -42,19 +46,19 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
4246
try {
4347
AfiOptimizerApi apiInstance = new AfiOptimizerApi(getApiClient());
4448
AFIOptimizationParameters afiItem = new AFIOptimizationParameters();
45-
49+
4650
AFIOptimizerStrategy strategy = new AFIOptimizerStrategy();
4751
strategy.setId(STRATEGY_ID);
48-
52+
4953
OptimizerOutputTypes optOutputTypes = new OptimizerOutputTypes();
5054
OptimizerTradesList tradesList = new OptimizerTradesList();
5155
tradesList.setIdentifierType(TRADES_ID_TYPE);
5256
tradesList.setIncludeCash(INCLUDE_CASH);
5357
optOutputTypes.setTrades(tradesList);
54-
58+
5559
afiItem.setStrategy(strategy);
5660
afiItem.setOutputTypes(optOutputTypes);
57-
61+
5862
AFIOptimizationParametersRoot afiOptimizerParam = new AFIOptimizationParametersRoot();
5963
afiOptimizerParam.setData(afiItem);
6064

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

113117
ObjectMapper mapper = new ObjectMapper();
114-
String json = mapper.writeValueAsString(tables);
115-
System.out.println(json); // Prints the result in 2D table format.
118+
for (TableData table : tables) {
119+
// Prints the results in 2D table format.
120+
List<Row> rows = table.getRows();
121+
String json = mapper.writeValueAsString(rows);
122+
System.out.println(json);
123+
124+
// Prints the metadata
125+
if (table.getRawMetadata().size() > 0) System.out.println("Printing metadata...");
126+
for (Map.Entry<String, List<Value>> rawMetadata : table.getRawMetadata().entrySet()) {
127+
for (Value val : rawMetadata.getValue()) {
128+
System.out.println(" " + rawMetadata.getKey() + ": " + StachUtilities.valueToString(val));
129+
}
130+
}
131+
}
116132
// Uncomment the following line to generate an Excel file
117133
// generateExcel(tables);
118134
} catch (ApiException e) {
119135
handleException("AfiOptimizerEngineExample#Main", e);
136+
} catch (InvalidProtocolBufferException e) {
137+
System.out.println(e.getMessage());
138+
e.printStackTrace();
120139
}
121140
}
122141

examples/src/examples/AxpInteractiveOptimizerEngineExample.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import javax.ws.rs.client.ClientBuilder;
1010

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

131135
ObjectMapper mapper = new ObjectMapper();
132-
String json = mapper.writeValueAsString(tables);
133-
System.out.println(json); // Prints the result in 2D table format.
136+
for (TableData table : tables) {
137+
// Prints the results in 2D table format.
138+
List<Row> rows = table.getRows();
139+
String json = mapper.writeValueAsString(rows);
140+
System.out.println(json);
141+
142+
// Prints the metadata
143+
if (table.getRawMetadata().size() > 0) System.out.println("Printing metadata...");
144+
for (Map.Entry<String, List<Value>> rawMetadata : table.getRawMetadata().entrySet()) {
145+
for (Value val : rawMetadata.getValue()) {
146+
System.out.println(" " + rawMetadata.getKey() + ": " + StachUtilities.valueToString(val));
147+
}
148+
}
149+
}
134150
// Uncomment the following line to generate an Excel file
135151
// generateExcel(tables);
136152
} catch (ApiException e) {
137153
handleException("AxpOptimizerEngineExample#Main", e);
154+
} catch (InvalidProtocolBufferException e) {
155+
System.out.println(e.getMessage());
156+
e.printStackTrace();
138157
}
139158
}
140159

examples/src/examples/BpmInteractiveOptimizerEngineExample.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import javax.ws.rs.client.ClientBuilder;
1010

11+
import com.factset.protobuf.stach.extensions.models.Row;
12+
import com.factset.protobuf.stach.extensions.v2.StachUtilities;
13+
import com.google.protobuf.InvalidProtocolBufferException;
14+
import com.google.protobuf.Value;
1115
import factset.analyticsapi.engines.models.*;
1216
import org.apache.poi.xssf.usermodel.XSSFCell;
1317
import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -84,7 +88,7 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
8488
do {
8589
response = apiInstance.getOptimizationStatusByIdWithHttpInfo(calculationId);
8690
headers = response.getHeaders();
87-
91+
8892
List<String> cacheControl = headers.get("Cache-Control");
8993
if (cacheControl != null) {
9094
int maxAge = Integer.parseInt(cacheControl.get(0).replace("max-age=", ""));
@@ -119,12 +123,27 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
119123
}
120124

121125
ObjectMapper mapper = new ObjectMapper();
122-
String json = mapper.writeValueAsString(tables);
123-
System.out.println(json); // Prints the result in 2D table format.
126+
for (TableData table : tables) {
127+
// Prints the results in 2D table format.
128+
List<Row> rows = table.getRows();
129+
String json = mapper.writeValueAsString(rows);
130+
System.out.println(json);
131+
132+
// Prints the metadata
133+
if (table.getRawMetadata().size() > 0) System.out.println("Printing metadata...");
134+
for (Map.Entry<String, List<Value>> rawMetadata : table.getRawMetadata().entrySet()) {
135+
for (Value val : rawMetadata.getValue()) {
136+
System.out.println(" " + rawMetadata.getKey() + ": " + StachUtilities.valueToString(val));
137+
}
138+
}
139+
}
124140
// Uncomment the following line to generate an Excel file
125141
// generateExcel(tables);
126142
} catch (ApiException e) {
127143
handleException("BpmOptimizerEngineExample#Main", e);
144+
} catch (InvalidProtocolBufferException e) {
145+
System.out.println(e.getMessage());
146+
e.printStackTrace();
128147
}
129148
}
130149

examples/src/examples/FiInteractiveEngineExample.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
import javax.ws.rs.client.ClientBuilder;
1111

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

139143
ObjectMapper mapper = new ObjectMapper();
140-
String json = mapper.writeValueAsString(tables);
141-
System.out.println(json); // Prints the result in 2D table format.
144+
for (TableData table : tables) {
145+
// Prints the results in 2D table format.
146+
List<Row> rows = table.getRows();
147+
String json = mapper.writeValueAsString(rows);
148+
System.out.println(json);
149+
150+
// Prints the metadata
151+
if (table.getRawMetadata().size() > 0) System.out.println("Printing metadata...");
152+
for (Map.Entry<String, List<Value>> rawMetadata : table.getRawMetadata().entrySet()) {
153+
for (Value val : rawMetadata.getValue()) {
154+
System.out.println(" " + rawMetadata.getKey() + ": " + StachUtilities.valueToString(val));
155+
}
156+
}
157+
}
142158
// Uncomment the following line to generate an Excel file
143159
// generateExcel(tables);
144160
} catch (ApiException e) {
145161
handleException("FiEngineExample#Main", e);
162+
} catch (InvalidProtocolBufferException e) {
163+
System.out.println(e.getMessage());
164+
e.printStackTrace();
146165
}
147166
}
148167

examples/src/examples/FpoInteractiveOptimizerEngineExample.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import javax.ws.rs.client.ClientBuilder;
1010

11+
import com.factset.protobuf.stach.extensions.models.Row;
12+
import com.factset.protobuf.stach.extensions.v2.StachUtilities;
13+
import com.google.protobuf.InvalidProtocolBufferException;
14+
import com.google.protobuf.Value;
1115
import factset.analyticsapi.engines.models.*;
1216
import org.apache.poi.xssf.usermodel.XSSFCell;
1317
import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -103,7 +107,7 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
103107
do {
104108
response = apiInstance.getOptimizationStatusByIdWithHttpInfo(calculationId);
105109
headers = response.getHeaders();
106-
110+
107111
List<String> cacheControl = headers.get("Cache-Control");
108112
if (cacheControl != null) {
109113
int maxAge = Integer.parseInt(cacheControl.get(0).replace("max-age=", ""));
@@ -138,12 +142,27 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
138142
}
139143

140144
ObjectMapper mapper = new ObjectMapper();
141-
String json = mapper.writeValueAsString(tables);
142-
System.out.println(json); // Prints the result in 2D table format.
145+
for (TableData table : tables) {
146+
// Prints the results in 2D table format.
147+
List<Row> rows = table.getRows();
148+
String json = mapper.writeValueAsString(rows);
149+
System.out.println(json);
150+
151+
// Prints the metadata
152+
if (table.getRawMetadata().size() > 0) System.out.println("Printing metadata...");
153+
for (Map.Entry<String, List<Value>> rawMetadata : table.getRawMetadata().entrySet()) {
154+
for (Value val : rawMetadata.getValue()) {
155+
System.out.println(" " + rawMetadata.getKey() + ": " + StachUtilities.valueToString(val));
156+
}
157+
}
158+
}
143159
// Uncomment the following line to generate an Excel file
144160
// generateExcel(tables);
145161
} catch (ApiException e) {
146162
handleException("FpoOptimizerEngineExample#Main", e);
163+
} catch (InvalidProtocolBufferException e) {
164+
System.out.println(e.getMessage());
165+
e.printStackTrace();
147166
}
148167
}
149168

examples/src/examples/PAEngineMultipleUnitExample.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import javax.ws.rs.client.ClientBuilder;
1010

11+
import com.factset.protobuf.stach.extensions.models.Row;
12+
import com.factset.protobuf.stach.extensions.v2.StachUtilities;
13+
import com.google.protobuf.InvalidProtocolBufferException;
14+
import com.google.protobuf.Value;
1115
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
1216
import org.glassfish.jersey.client.ClientProperties;
1317

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

165169
ObjectMapper mapper = new ObjectMapper();
166-
String json = mapper.writeValueAsString(tables);
167-
System.out.println(json); // Prints the result in 2D table format.
170+
for (TableData table : tables) {
171+
// Prints the results in 2D table format.
172+
List<Row> rows = table.getRows();
173+
String json = mapper.writeValueAsString(rows);
174+
System.out.println(json);
175+
176+
// Prints the metadata
177+
if (table.getRawMetadata().size() > 0) System.out.println("Printing metadata...");
178+
for (Map.Entry<String, List<Value>> rawMetadata : table.getRawMetadata().entrySet()) {
179+
for (Value val : rawMetadata.getValue()) {
180+
System.out.println(" " + rawMetadata.getKey() + ": " + StachUtilities.valueToString(val));
181+
}
182+
}
183+
}
168184
// Uncomment the following line to generate an Excel file
169185
// generateExcel(tables);
170186
} else {
@@ -174,6 +190,9 @@ public static void main(String[] args) throws InterruptedException, JsonProcessi
174190
}
175191
} catch (ApiException e) {
176192
handleException("PAEngineExample#Main", e);
193+
}catch (InvalidProtocolBufferException e) {
194+
System.out.println(e.getMessage());
195+
e.printStackTrace();
177196
}
178197
}
179198

0 commit comments

Comments
 (0)