Skip to content

Commit

Permalink
More module test improvements. Updated files to allow for (eventually…
Browse files Browse the repository at this point in the history
…) better state management.
  • Loading branch information
[email protected] authored and [email protected] committed Dec 5, 2023
1 parent 7e89641 commit 9813b4e
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 6 deletions.
4 changes: 2 additions & 2 deletions language/buildNumber.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
#Thu Nov 16 10:12:17 CST 2023
buildNumber\\d*=12623
#Tue Dec 05 14:58:52 CST 2023
buildNumber\\d*=12624
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,20 @@ public void setDocumentation(List<String> documentation) {
public List<String> getDocumentation() {
return documentation;
}

public QDLModuleMetaClass getMetaClass() {
return metaClass;
}

public void setMetaClass(QDLModuleMetaClass metaClass) {
this.metaClass = metaClass;
}

QDLModuleMetaClass metaClass = null;

public boolean hasMetaClass() {
return metaClass != null;
}


}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package edu.uiuc.ncsa.qdl.extensions;

import net.sf.json.JSONObject;

import java.io.Serializable;

/**
Expand All @@ -12,4 +14,14 @@
* on 10/4/21 at 6:58 AM
*/
public interface QDLModuleMetaClass extends Serializable {
/**
* Send back a serialization of state for this object. This allows for the state
* you choose to be serialized and then reloaded.
* <h3>NOTE</h3>
* There is no canonical form for this. Set it how you will and deserialize it
* accordingly.
* @return
*/
JSONObject serializeToJSON();
void deserializeFromJSON(JSONObject json);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import edu.uiuc.ncsa.qdl.expressions.ConstantNode;
import edu.uiuc.ncsa.qdl.expressions.Polyad;
import edu.uiuc.ncsa.qdl.extensions.QDLFunction;
import edu.uiuc.ncsa.qdl.extensions.QDLModuleMetaClass;
import edu.uiuc.ncsa.qdl.state.State;
import edu.uiuc.ncsa.qdl.util.InputFormUtil;
import edu.uiuc.ncsa.qdl.util.QDLFileUtil;
Expand Down Expand Up @@ -37,7 +38,7 @@
* <p>Created by Jeff Gaynor<br>
* on 2/13/23 at 7:33 AM
*/
public class QDLConvert {
public class QDLConvert implements QDLModuleMetaClass {
public static final String XML_IMPORT_NAME = "xml_in";
public static final String XML_EXPORT_NAME = "xml_out";
public static final int XML_IMPORT_LEVEL_FLATTEN = 0; // no @'s, ignore most structures, attributes flattened to properties
Expand Down Expand Up @@ -1130,6 +1131,16 @@ public List<String> getDocumentation(int argCount) {
return null;
}
}

@Override
public JSONObject serializeToJSON() {
return null;
}

@Override
public void deserializeFromJSON(JSONObject json) {

}
}
/*
module_load(info().lib.xml, 'java') =: q; module_import(q);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,4 +694,14 @@ protected boolean isSingleKey(QDLStem stem) {


SecureRandom secureRandom = new SecureRandom();

@Override
public JSONObject serializeToJSON() {
return null;
}

@Override
public void deserializeFromJSON(JSONObject json) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,16 @@ protected List<String> getArgStatement() {
return argStatement;
}

/* Handy dandy table of SQL types and calls.
@Override
public JSONObject serializeToJSON() {
return null;
}

@Override
public void deserializeFromJSON(JSONObject json) {

}
/* Handy dandy table of SQL types and calls.
SQL JDBC/Java setXXX updateXXX
VARCHAR java.lang.String setString updateString
CHAR java.lang.String setString updateString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Ex. Doing a DB service (to CILogon) all to my local box with a self-signed cert.
Which returns a status of 0 (so all ok), the client_id and the current base 32 encoded grant.
*/
public class HTTPClient implements QDLModuleMetaClass {
CloseableHttpClient httpClient = null;
transient CloseableHttpClient httpClient = null;
String host = null;
public String HOST_METHOD = "host";
public String GET_METHOD = "get";
Expand Down Expand Up @@ -426,7 +426,7 @@ public Object evaluate(Object[] objects, State state) {
boolean doInsecure = false;
if (objects.length == 1) {
if (!(objects[0] instanceof Boolean)) {
throw new IllegalArgumentException(getName() + " retuires a boolean argument if present");
throw new IllegalArgumentException(getName() + " requires a boolean argument if present");
}
doInsecure = (Boolean) objects[0];
}
Expand Down Expand Up @@ -466,6 +466,7 @@ public List<String> getDocumentation(int argCount) {
doxx.add("This boosts neither speed nor performance and turns off essential security.");
break;
}
doxx.add("NOTE that if you serialize this workspace, you must re-open the connection on loading");
return doxx;
}

Expand Down Expand Up @@ -929,4 +930,26 @@ protected String getActualHost(String uriPath) {
// Fixes https://github.com/ncsa/qdl/issues/35
return actualHost + (uriPath.startsWith("/") ? uriPath.substring(1) : uriPath);
}

@Override
public JSONObject serializeToJSON() {
JSONObject json = new JSONObject();
if(!StringUtils.isTrivial(host)){
json.put("host", host);
}
if(headers!=null){
json.put("headers", headers);
}
return json;
}

@Override
public void deserializeFromJSON(JSONObject json) {
if(json.containsKey("host")){
host = json.getString("host");
}
if(json.containsKey("headers")){
headers = json.getJSONObject("headers");
}
}
}

0 comments on commit 9813b4e

Please sign in to comment.