Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Handlers #187

Merged
merged 9 commits into from
Aug 8, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ public EDDGridFromDapHandler(SaxHandler saxHandler, String datasetID, State comp
this.completeState = completeState;
}

public com.cohort.array.Attributes tGlobalAttributes = new com.cohort.array.Attributes();
public String tAccessibleTo = null;
public String tGraphsAccessibleTo = null;
public boolean tAccessibleViaWMS = true;
public StringArray tOnChange = new StringArray();
public String tFgdcFile = null;
public String tIso19115File = null;
public ArrayList tAxisVariables = new ArrayList();
public ArrayList tDataVariables = new ArrayList();
public int tReloadEveryNMinutes = DEFAULT_RELOAD_EVERY_N_MINUTES;
public int tUpdateEveryNMillis = 0;
public String tLocalSourceUrl = null;
public String tDefaultDataQuery = null;
public String tDefaultGraphQuery = null;
public int tnThreads = -1;
public boolean tDimensionValuesInMemory = true;
private com.cohort.array.Attributes tGlobalAttributes = new com.cohort.array.Attributes();
private String tAccessibleTo = null;
private String tGraphsAccessibleTo = null;
private boolean tAccessibleViaWMS = true;
private StringArray tOnChange = new StringArray();
private String tFgdcFile = null;
private String tIso19115File = null;
private ArrayList<Object[]> tAxisVariables = new ArrayList();
private ArrayList<Object[]> tDataVariables = new ArrayList();
private int tReloadEveryNMinutes = DEFAULT_RELOAD_EVERY_N_MINUTES;
private int tUpdateEveryNMillis = 0;
private String tLocalSourceUrl = null;
private String tDefaultDataQuery = null;
private String tDefaultGraphQuery = null;
private int tnThreads = -1;
private boolean tDimensionValuesInMemory = true;

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) {
Expand Down Expand Up @@ -85,14 +85,9 @@ public void endElement(String uri, String localName, String qName) throws Throwa
case "dataset" -> {
int nav = tAxisVariables.size();
Object[][] ttAxisVariables = nav == 0 ? null : new Object[nav][];
for (int i = 0; i < tAxisVariables.size(); i++) {
ttAxisVariables[i] = (Object[]) tAxisVariables.get(i);
}
int ndv = tDataVariables.size();
Object[][] ttDataVariables = new Object[ndv][];
for (int i = 0; i < tDataVariables.size(); i++) {
ttDataVariables[i] = (Object[]) tDataVariables.get(i);
}
ttAxisVariables = tAxisVariables.toArray(ttAxisVariables);
Object[][] ttDataVariables = new Object[tDataVariables.size()][];
ttDataVariables = tDataVariables.toArray(ttDataVariables);

EDD dataset =
new EDDGridFromDap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public EDDGridFromEDDTableHandler(
private StringArray tOnChange = new StringArray();
private String tFgdcFile = null;
private String tIso19115File = null;
private ArrayList tAxisVariables = new ArrayList();
private ArrayList tDataVariables = new ArrayList();
private ArrayList<Object[]> tAxisVariables = new ArrayList();
private ArrayList<Object[]> tDataVariables = new ArrayList();
private int tReloadEveryNMinutes = DEFAULT_RELOAD_EVERY_N_MINUTES;
private int tUpdateEveryNMillis = 0;
private String tLocalSourceUrl = null;
Expand Down Expand Up @@ -119,14 +119,10 @@ public void endElement(String uri, String localName, String qName) throws Throwa
case "dataset" -> {
int nav = tAxisVariables.size();
Object[][] ttAxisVariables = nav == 0 ? null : new Object[nav][];
for (int i = 0; i < tAxisVariables.size(); i++) {
ttAxisVariables[i] = (Object[]) tAxisVariables.get(i);
}
ttAxisVariables = tAxisVariables.toArray(ttAxisVariables);
int ndv = tDataVariables.size();
Object[][] ttDataVariables = new Object[ndv][];
for (int i = 0; i < tDataVariables.size(); i++) {
ttDataVariables[i] = (Object[]) tDataVariables.get(i);
}
ttDataVariables = tDataVariables.toArray(ttDataVariables);

EDD dataset =
new EDDGridFromEDDTable(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package gov.noaa.pfel.erddap.handlers;

import static gov.noaa.pfel.erddap.dataset.EDD.DEFAULT_RELOAD_EVERY_N_MINUTES;

import com.cohort.array.StringArray;
import com.cohort.util.String2;
import gov.noaa.pfel.erddap.dataset.EDD;
Expand All @@ -8,91 +10,90 @@
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import static gov.noaa.pfel.erddap.dataset.EDD.DEFAULT_RELOAD_EVERY_N_MINUTES;

public class EDDGridFromErddapHandler extends State {
private StringBuilder content = new StringBuilder();
private String datasetID;
private State completeState;
private StringBuilder content = new StringBuilder();
private String datasetID;
private State completeState;

public EDDGridFromErddapHandler(SaxHandler saxHandler, String datasetID, State completeState) {
super(saxHandler);
this.datasetID = datasetID;
this.completeState = completeState;
}
public EDDGridFromErddapHandler(SaxHandler saxHandler, String datasetID, State completeState) {
super(saxHandler);
this.datasetID = datasetID;
this.completeState = completeState;
}

public int tReloadEveryNMinutes = DEFAULT_RELOAD_EVERY_N_MINUTES;
public int tUpdateEveryNMillis = 0;
public String tAccessibleTo = null;
public String tGraphsAccessibleTo = null;
public boolean tAccessibleViaWMS = true;
public boolean tAccessibleViaFiles = EDStatic.defaultAccessibleViaFiles;
public boolean tSubscribeToRemoteErddapDataset = EDStatic.subscribeToRemoteErddapDataset;
public boolean tRedirect = true;
public StringArray tOnChange = new StringArray();
public String tFgdcFile = null;
public String tIso19115File = null;
public String tLocalSourceUrl = null;
public String tDefaultDataQuery = null;
public String tDefaultGraphQuery = null;
public int tnThreads = -1; // interpret invalid values (like -1) as EDStatic.nGridThreads
public boolean tDimensionValuesInMemory = true;
private int tReloadEveryNMinutes = DEFAULT_RELOAD_EVERY_N_MINUTES;
private int tUpdateEveryNMillis = 0;
private String tAccessibleTo = null;
private String tGraphsAccessibleTo = null;
private boolean tAccessibleViaWMS = true;
private boolean tAccessibleViaFiles = EDStatic.defaultAccessibleViaFiles;
private boolean tSubscribeToRemoteErddapDataset = EDStatic.subscribeToRemoteErddapDataset;
private boolean tRedirect = true;
private StringArray tOnChange = new StringArray();
private String tFgdcFile = null;
private String tIso19115File = null;
private String tLocalSourceUrl = null;
private String tDefaultDataQuery = null;
private String tDefaultGraphQuery = null;
private int tnThreads = -1; // interpret invalid values (like -1) as EDStatic.nGridThreads
private boolean tDimensionValuesInMemory = true;

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {}

@Override
public void characters(char[] ch, int start, int length) throws SAXException {
content.append(ch, start, length);
}
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
content.append(ch, start, length);
}

@Override
public void endElement(String uri, String localName, String qName) throws Throwable {
String contentStr = content.toString().trim();
@Override
public void endElement(String uri, String localName, String qName) throws Throwable {
String contentStr = content.toString().trim();

switch (localName) {
case "reloadEveryNMinutes" -> tReloadEveryNMinutes = String2.parseInt(contentStr);
case "updateEveryNMillis" -> tUpdateEveryNMillis = String2.parseInt(contentStr);
case "accessibleTo" -> tAccessibleTo = contentStr;
case "graphsAccessibleTo" -> tGraphsAccessibleTo = contentStr;
case "accessibleViaWMS" -> tAccessibleViaWMS = String2.parseBoolean(contentStr);
case "accessibleViaFiles" -> tAccessibleViaFiles = String2.parseBoolean(contentStr);
case "subscribeToRemoteErddapDataset" -> tSubscribeToRemoteErddapDataset = String2.parseBoolean(contentStr);
case "sourceUrl" -> tLocalSourceUrl = contentStr;
case "onChange" -> tOnChange.add(contentStr);
case "fgdcFile" -> tFgdcFile = contentStr;
case "iso19115File" -> tIso19115File = contentStr;
case "defaultDataQuery" -> tDefaultDataQuery = contentStr;
case "defaultGraphQuery" -> tDefaultGraphQuery = contentStr;
case "nThreads" -> tnThreads = String2.parseInt(contentStr);
case "dimensionValuesInMemory" -> tDimensionValuesInMemory = String2.parseBoolean(contentStr);
case "redirect" -> tRedirect = String2.parseBoolean(contentStr);
case "dataset" -> {
EDD dataset = new EDDGridFromErddap(
datasetID,
tAccessibleTo,
tGraphsAccessibleTo,
tAccessibleViaWMS,
tAccessibleViaFiles,
tOnChange,
tFgdcFile,
tIso19115File,
tDefaultDataQuery,
tDefaultGraphQuery,
tReloadEveryNMinutes,
tUpdateEveryNMillis,
tLocalSourceUrl,
tSubscribeToRemoteErddapDataset,
tRedirect,
tnThreads,
tDimensionValuesInMemory
);
this.completeState.handleDataset(dataset);
saxHandler.setState(this.completeState);
}
default -> String2.log("Unexpected end tag: " + localName);
}
content.setLength(0);
switch (localName) {
case "reloadEveryNMinutes" -> tReloadEveryNMinutes = String2.parseInt(contentStr);
case "updateEveryNMillis" -> tUpdateEveryNMillis = String2.parseInt(contentStr);
case "accessibleTo" -> tAccessibleTo = contentStr;
case "graphsAccessibleTo" -> tGraphsAccessibleTo = contentStr;
case "accessibleViaWMS" -> tAccessibleViaWMS = String2.parseBoolean(contentStr);
case "accessibleViaFiles" -> tAccessibleViaFiles = String2.parseBoolean(contentStr);
case "subscribeToRemoteErddapDataset" ->
tSubscribeToRemoteErddapDataset = String2.parseBoolean(contentStr);
case "sourceUrl" -> tLocalSourceUrl = contentStr;
case "onChange" -> tOnChange.add(contentStr);
case "fgdcFile" -> tFgdcFile = contentStr;
case "iso19115File" -> tIso19115File = contentStr;
case "defaultDataQuery" -> tDefaultDataQuery = contentStr;
case "defaultGraphQuery" -> tDefaultGraphQuery = contentStr;
case "nThreads" -> tnThreads = String2.parseInt(contentStr);
case "dimensionValuesInMemory" -> tDimensionValuesInMemory = String2.parseBoolean(contentStr);
case "redirect" -> tRedirect = String2.parseBoolean(contentStr);
case "dataset" -> {
EDD dataset =
new EDDGridFromErddap(
datasetID,
tAccessibleTo,
tGraphsAccessibleTo,
tAccessibleViaWMS,
tAccessibleViaFiles,
tOnChange,
tFgdcFile,
tIso19115File,
tDefaultDataQuery,
tDefaultGraphQuery,
tReloadEveryNMinutes,
tUpdateEveryNMillis,
tLocalSourceUrl,
tSubscribeToRemoteErddapDataset,
tRedirect,
tnThreads,
tDimensionValuesInMemory);
this.completeState.handleDataset(dataset);
saxHandler.setState(this.completeState);
}
default -> String2.log("Unexpected end tag: " + localName);
}

content.setLength(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ public EDDGridLonPM180Handler(
this.context = context;
}

public EDDGrid tChildDataset = null;
public String tAccessibleTo = null;
public String tGraphsAccessibleTo = null;
public boolean tAccessibleViaWMS = true;
public boolean tAccessibleViaFiles = EDStatic.defaultAccessibleViaFiles;
public StringArray tOnChange = new StringArray();
public String tFgdcFile = null;
public String tIso19115File = null;
public String tDefaultDataQuery = null;
public String tDefaultGraphQuery = null;
public int tReloadEveryNMinutes = Integer.MAX_VALUE;
public int tUpdateEveryNMillis = Integer.MAX_VALUE;
public int tnThreads = -1;
public boolean tDimensionValuesInMemory = true;
private EDDGrid tChildDataset = null;
private String tAccessibleTo = null;
private String tGraphsAccessibleTo = null;
private boolean tAccessibleViaWMS = true;
private boolean tAccessibleViaFiles = EDStatic.defaultAccessibleViaFiles;
private StringArray tOnChange = new StringArray();
private String tFgdcFile = null;
private String tIso19115File = null;
private String tDefaultDataQuery = null;
private String tDefaultGraphQuery = null;
private int tReloadEveryNMinutes = Integer.MAX_VALUE;
private int tUpdateEveryNMillis = Integer.MAX_VALUE;
private int tnThreads = -1;
private boolean tDimensionValuesInMemory = true;

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
Expand Down
Loading