Skip to content
Snippets Groups Projects
Commit a32aec84 authored by Powers, Peter M.'s avatar Powers, Peter M.
Browse files

refac disagg output flag handling; add DISAGG_DATA

parent 167c3cb5
No related branches found
No related tags found
1 merge request!242Set datatypes in config
...@@ -24,6 +24,9 @@ public enum DataType { ...@@ -24,6 +24,9 @@ public enum DataType {
MAP, MAP,
/** Data by {@link SourceType}. */ /** Data by {@link SourceType}. */
SOURCE; SOURCE,
/** Disaggregation r-m-ε bin data */
DISAGG_DATA;
} }
...@@ -61,18 +61,16 @@ final class DisaggExport { ...@@ -61,18 +61,16 @@ final class DisaggExport {
DisaggDataset dd, DisaggDataset dd,
DisaggConfig dc, DisaggConfig dc,
String id, String id,
boolean jsonFlag, boolean εDataFlag) {
boolean εDataFlag,
boolean summaryFlag) {
this.ddTotal = ddTotal; this.ddTotal = ddTotal;
this.dd = dd; this.dd = dd;
this.dc = dc; this.dc = dc;
this.id = id; this.id = id;
summary = summaryFlag ? createSummaryElements(ddTotal, dd, dc) : null; summary = createSummaryElements(ddTotal, dd, dc);
sources = createJsonContributorList(ddTotal, dd, dc.contributorLimit);
data = εDataFlag ? createDistanceMagnitudeData(ddTotal, dd) : null; data = εDataFlag ? createDistanceMagnitudeData(ddTotal, dd) : null;
sources = jsonFlag ? createJsonContributorList(ddTotal, dd, dc.contributorLimit) : null;
} }
@Override @Override
......
...@@ -186,33 +186,18 @@ public final class Disaggregation { ...@@ -186,33 +186,18 @@ public final class Disaggregation {
} }
/** /**
* Returns an object containing all disaggregation results that is suitable * Returns an object containing disaggregation results that is suitable for
* for JSON serialization. * JSON serialization.
* *
* @param imt of the disaggregation to retrieve. * @param imt of the disaggregation to retrieve.
*/
public Object toJson(Imt imt) {
return disaggs.get(imt).toJson(true, true, true, true);
}
/**
* Returns an object containing custom disaggregation results that is suitable
* for JSON serialization.
*
* @param imt of the disaggregation to retrieve.
* @param summary include summary information, or not
* @param gmms include results decomposed by GMM (values are scaled by GMM * @param gmms include results decomposed by GMM (values are scaled by GMM
* logic tree weight) * logic tree weight)
* @param types include results decomposed by source type * @param types include results decomposed by source type
* @param epsilons include distance-magnitude-epsilon data that can be used to * @param rmeData include distance-magnitude-epsilon data that can be used to
* build a 3D stem plot * build a 3D stem plot
*/ */
public Object toJson(Imt imt, public Object toJson(Imt imt, boolean gmms, boolean types, boolean rmeData) {
boolean summary, return disaggs.get(imt).toJson(gmms, types, rmeData);
boolean gmms,
boolean types,
boolean epsilons) {
return disaggs.get(imt).toJson(summary, gmms, types, epsilons);
} }
/** /**
...@@ -298,7 +283,7 @@ public final class Disaggregation { ...@@ -298,7 +283,7 @@ public final class Disaggregation {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(NEWLINE); sb.append(NEWLINE);
for (DisaggExport export : buildExports(false, true, true, true, true)) { for (DisaggExport export : buildExports(true, true, false)) {
sb.append(export.toString()); sb.append(export.toString());
sb.append(NEWLINE); sb.append(NEWLINE);
} }
...@@ -310,16 +295,14 @@ public final class Disaggregation { ...@@ -310,16 +295,14 @@ public final class Disaggregation {
* structured object that may be serialized directly or added to some other * structured object that may be serialized directly or added to some other
* object prior to serialization. * object prior to serialization.
*/ */
Object toJson(boolean summary, boolean gmmDisaggs, boolean typeDisaggs, boolean εData) { Object toJson(boolean gmmDisaggs, boolean typeDisaggs, boolean rmεData) {
return buildExports(true, summary, gmmDisaggs, typeDisaggs, εData); return buildExports(gmmDisaggs, typeDisaggs, rmεData);
} }
private List<DisaggExport> buildExports( private List<DisaggExport> buildExports(
boolean json,
boolean summary,
boolean gmmDisaggs, boolean gmmDisaggs,
boolean typeDisaggs, boolean typeDisaggs,
boolean εData) { boolean rmεData) {
List<DisaggExport> exports = new ArrayList<>(); List<DisaggExport> exports = new ArrayList<>();
DisaggExport total = new DisaggExport( DisaggExport total = new DisaggExport(
...@@ -327,9 +310,7 @@ public final class Disaggregation { ...@@ -327,9 +310,7 @@ public final class Disaggregation {
totalDataset, totalDataset,
config, config,
TOTAL_COMPONENT, TOTAL_COMPONENT,
json, rmεData);
εData,
summary);
exports.add(total); exports.add(total);
if (gmmDisaggs) { if (gmmDisaggs) {
for (Entry<Gmm, DisaggDataset> gmmEntry : gmmDatasets.entrySet()) { for (Entry<Gmm, DisaggDataset> gmmEntry : gmmDatasets.entrySet()) {
...@@ -338,9 +319,7 @@ public final class Disaggregation { ...@@ -338,9 +319,7 @@ public final class Disaggregation {
gmmEntry.getValue(), gmmEntry.getValue(),
config, config,
GMM_COMPONENT + gmmEntry.getKey().toString(), GMM_COMPONENT + gmmEntry.getKey().toString(),
json, rmεData);
εData,
summary);
exports.add(gmm); exports.add(gmm);
} }
} }
...@@ -351,9 +330,7 @@ public final class Disaggregation { ...@@ -351,9 +330,7 @@ public final class Disaggregation {
typeEntry.getValue(), typeEntry.getValue(),
config, config,
TYPE_COMPONENT + typeEntry.getKey().toString(), TYPE_COMPONENT + typeEntry.getKey().toString(),
json, rmεData);
εData,
summary);
exports.add(type); exports.add(type);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment