Skip to content

Commit

Permalink
checkpoint commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrdoherty committed Feb 8, 2024
1 parent ac484d9 commit 23c59fc
Show file tree
Hide file tree
Showing 35 changed files with 270 additions and 733 deletions.
37 changes: 0 additions & 37 deletions Model/lib/conifer/roles/conifer/templates/WDK/model-config.xml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ site_vars file: {{ site_vars }}
{% if modelconfig_useWeights is defined -%}
assetsUrl="{{ modelconfig_useWeights }}"
{% endif -%}
{% if modelconfig_secretKeyFile is defined -%}
secretKeyFile="{{ modelconfig_secretKeyFile }}"
{% endif -%}
{% if modelconfig_blockedThreshold is defined -%}
monitorBlockedThreads="{{ modelconfig_monitorBlockedThreads }}"
{% endif -%}
Expand Down Expand Up @@ -145,40 +142,6 @@ site_vars file: {{ site_vars }}
{% endif -%}
/>

<accountDb login="{{ modelconfig_accountDb_login }}"
password="{{ modelconfig_accountDb_password }}"
connectionUrl="{{ modelconfig_accountDb_connectionUrl }}"
platform="{{ modelconfig_accountDb_platform }}"
accountSchema="{{ modelconfig_accountDb_accountSchema }}"
{% if modelconfig_accountDb_maxActive is defined -%}
maxActive="{{ modelconfig_accountDb_maxActive }}"
{% endif -%}
{% if modelconfig_accountDb_maxIdle is defined -%}
maxIdle="{{ modelconfig_accountDb_maxIdle }}"
{% endif -%}
{% if modelconfig_accountDb_minIdle is defined -%}
minIdle="{{ modelconfig_accountDb_minIdle }}"
{% endif -%}
{% if modelconfig_accountDb_maxWait is defined -%}
maxWait="{{ modelconfig_accountDb_maxWait }}"
{% endif -%}
{% if modelconfig_accountDb_defaultFetchSize is defined -%}
defaultFetchSize="{{ modelconfig_accountDb_defaultFetchSize }}"
{% endif -%}
{% if modelconfig_accountDb_showConnections is defined -%}
showConnections="{{ modelconfig_accountDb_showConnections }}"
{% endif -%}
{% if modelconfig_accountDb_showConnectionsInterval is defined -%}
showConnectionsInterval="{{ modelconfig_accountDb_showConnectionsInterval }}"
{% endif -%}
{% if modelconfig_accountDb_showConnectionsDuration is defined -%}
showConnectionsDuration="{{ modelconfig_accountDb_showConnectionsDuration }}"
{% endif -%}
{% if modelconfig_accountDb_driverInitClass is defined -%}
driverInitClass="{{ modelconfig_accountDb_driverInitClass }}"
{% endif %}
/>

{% if modelconfig_userDatasetStoreConfig is defined -%}
{{ modelconfig_userDatasetStoreConfig|indent }}
{% endif -%}
Expand Down
2 changes: 0 additions & 2 deletions Model/src/main/java/org/gusdb/wdk/jmx/mbeans/ModelConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ protected void init() {
org.gusdb.wdk.model.config.QueryMonitor queryMonitor = modelConfig.getQueryMonitor();
org.gusdb.wdk.model.config.ModelConfigUserDB modelConfigUserDB = modelConfig.getUserDB();
org.gusdb.wdk.model.config.ModelConfigAppDB modelConfigAppDB = modelConfig.getAppDB();
org.gusdb.wdk.model.config.ModelConfigAccountDB modelConfigAccountDB = modelConfig.getAccountDB();
org.gusdb.wdk.model.config.ModelConfigUserDatasetStore
modelConfigUserDatasetStore = modelConfig.getUserDatasetStoreConfig();

setValuesFromGetters("global", modelConfig);
setValuesFromGetters("queryMonitor", queryMonitor);
setValuesFromGetters("userDb", modelConfigUserDB);
setValuesFromGetters("appDb", modelConfigAppDB);
setValuesFromGetters("accountDb", modelConfigAccountDB);
setValuesFromGetters("userDatasetStore", modelConfigUserDatasetStore);
}

Expand Down
3 changes: 0 additions & 3 deletions Model/src/main/java/org/gusdb/wdk/model/ModelXmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,6 @@ private Map<String, String> loadProperties(String projectId, URL modelPropURL, M
if (!propMap.containsKey("USER_SCHEMA")) {
propMap.put("USER_SCHEMA", config.getUserDB().getUserSchema());
}
if (!propMap.containsKey("ACCT_SCHEMA")) {
propMap.put("ACCT_SCHEMA", config.getAccountDB().getAccountSchema());
}

return propMap;
}
Expand Down
96 changes: 24 additions & 72 deletions Model/src/main/java/org/gusdb/wdk/model/Utilities.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
package org.gusdb.wdk.model;

import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import javax.activation.DataHandler;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import java.io.*;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Clob;
import java.sql.SQLException;
import java.util.Date;
Expand All @@ -22,6 +16,20 @@
import java.util.regex.Pattern;
import java.util.stream.Stream;

import javax.activation.DataHandler;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

import org.apache.log4j.Logger;

/**
* This class provided constants that are shared among different WDK model
* classes. Furthermore, it also provides utility functions to send
Expand All @@ -31,16 +39,10 @@
*/
public class Utilities {

private static final Logger logger = Logger.getLogger(Utilities.class);
private static final Logger LOG = Logger.getLogger(Utilities.class);

public static final int TRUNCATE_DEFAULT = 100;

/**
* The maximum size for parameter values that will be displayed in thr URL as
* plain values
*/
public static final int MAX_PARAM_VALUE_SIZE = 100;

/**
* The maximum number of attributes used in sorting an answer
*/
Expand All @@ -56,10 +58,6 @@ public class Utilities {
*/
public static final String SYSTEM_PROPERTY_GUS_HOME = "GUS_HOME";

public static final int MAXIMUM_RECORD_INSTANCES = 10000;

public static final int DEFAULT_PAGE_SIZE = 20;

public static final int DEFAULT_SUMMARY_ATTRIBUTE_SIZE = 6;

public static final int DEFAULT_WEIGHT = 10;
Expand All @@ -71,8 +69,6 @@ public class Utilities {
*/
public static final int MAX_PK_COLUMN_COUNT = 4;

public static final int MAX_PK_COLUMN_VALUE_SIZE = 1999;

public static final String INTERNAL_PARAM_SET = "InternalParams";
public static final String INTERNAL_QUERY_SET = "InternalQueries";
public static final String INTERNAL_QUESTION_SET = "InternalQuestions";
Expand All @@ -99,12 +95,12 @@ public class Utilities {
public static final String COLUMN_DIVIDER = ",";

public static final String WDK_MODEL_KEY = "wdk_model";
public static final String WDK_MODEL_BEAN_KEY = "wdkModel"; // cannot change this because of JSPs
public static final String WDK_USER_KEY = "wdk_user";
public static final String WDK_USER_BEAN_KEY = "wdkUser";
public static final String BEARER_TOKEN_KEY = "bearer-token";

public static final String WDK_SERVICE_ENDPOINT_KEY = "wdkServiceEndpoint";


/*
* Inner class to act as a JAF DataSource to send HTML e-mail content
*/
Expand Down Expand Up @@ -164,22 +160,6 @@ public static String[] toArray(String data) {
return data.trim().split("\\s+");
}

public static String fromArray(String[] data) {
return fromArray(data, ",");
}

public static String fromArray(String[] data, String delimiter) {
if (data == null)
return null;
StringBuffer sb = new StringBuffer();
for (String value : data) {
if (sb.length() > 0)
sb.append(delimiter);
sb.append(value);
}
return sb.toString();
}

public static String parseValue(Object objValue) {
if (objValue == null)
return null;
Expand All @@ -197,21 +177,6 @@ private static String parseClob(Clob clobValue) {
}
}

public static String[][] convertContent(String content) throws JSONException {
JSONArray jsResult = new JSONArray(content);
JSONArray jsRow = (JSONArray) jsResult.get(0);
String[][] result = new String[jsResult.length()][jsRow.length()];
for (int row = 0; row < result.length; row++) {
jsRow = (JSONArray) jsResult.get(row);
for (int col = 0; col < result[row].length; col++) {
Object cell = jsRow.get(col);
result[row][col] = (cell == null || cell == JSONObject.NULL) ? null
: cell.toString();
}
}
return result;
}

// sendEmail() method overloading: different number of parameters (max 8), different type for attachments

// 7 parameters (missing bcc, datahandlers instead of attachments)
Expand Down Expand Up @@ -258,7 +223,7 @@ public static void sendEmail(String smtpServer, String sendTos, String reply,
String subject, String content, String ccAddresses, String bccAddresses,
Attachment[] attachments) throws WdkModelException {

logger.debug("Sending message to: " + sendTos + ", bcc to: " + bccAddresses +
LOG.debug("Sending message to: " + sendTos + ", bcc to: " + bccAddresses +
",reply: " + reply + ", using SMPT: " + smtpServer);

// create properties and get the session
Expand Down Expand Up @@ -317,7 +282,6 @@ public static void sendEmail(String smtpServer, String sendTos, String reply,
}
}


public static byte[] readFile(File file) throws IOException {
byte[] buffer = new byte[(int) file.length()];
InputStream stream = new FileInputStream(file);
Expand All @@ -326,18 +290,6 @@ public static byte[] readFile(File file) throws IOException {
return buffer;
}

public static <S,T> int createHashFromValueMap(Map<S,T> map) {
StringBuilder buffer = new StringBuilder("{");
for (S key : map.keySet()) {
if (buffer.length() > 1) {
buffer.append(";");
}
buffer.append(key).append(":").append(map.get(key));
}
buffer.append("}");
return buffer.toString().hashCode();
}

public static Map<String, Boolean> parseSortList(String sortList) throws WdkModelException {
Map<String, Boolean> sortingMap = new LinkedHashMap<String, Boolean>();
String[] attrCombines = sortList.split(",");
Expand Down
20 changes: 3 additions & 17 deletions Model/src/main/java/org/gusdb/wdk/model/WdkModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;

import org.apache.log4j.Logger;
Expand All @@ -38,13 +37,13 @@
import org.gusdb.fgputil.functional.FunctionalInterfaces.SupplierWithException;
import org.gusdb.fgputil.runtime.InstanceManager;
import org.gusdb.fgputil.runtime.Manageable;
import org.gusdb.wdk.model.user.User;
import org.gusdb.wdk.model.analysis.StepAnalysis;
import org.gusdb.wdk.model.analysis.StepAnalysisPlugins;
import org.gusdb.wdk.model.answer.single.SingleRecordQuestion;
import org.gusdb.wdk.model.columntool.ColumnToolBundleMap;
import org.gusdb.wdk.model.columntool.DefaultColumnToolBundleRef;
import org.gusdb.wdk.model.config.ModelConfig;
import org.gusdb.wdk.model.config.ModelConfigAccountDB;
import org.gusdb.wdk.model.config.ModelConfigAppDB;
import org.gusdb.wdk.model.config.ModelConfigUserDB;
import org.gusdb.wdk.model.config.ModelConfigUserDatasetStore;
Expand All @@ -69,7 +68,6 @@
import org.gusdb.wdk.model.user.BasketFactory;
import org.gusdb.wdk.model.user.FavoriteFactory;
import org.gusdb.wdk.model.user.StepFactory;
import org.gusdb.wdk.model.user.User;
import org.gusdb.wdk.model.user.UserFactory;
import org.gusdb.wdk.model.user.analysis.StepAnalysisFactory;
import org.gusdb.wdk.model.user.analysis.StepAnalysisFactoryImpl;
Expand Down Expand Up @@ -203,7 +201,6 @@ public static WdkModel construct(String projectId, String gusHome) throws WdkMod
private ColumnToolBundleMap columnToolBundleMap = new ColumnToolBundleMap();
private String defaultColumnToolBundleRef;

private ReentrantLock systemUserLock = new ReentrantLock();
private User systemUser;

private String buildNumber;
Expand Down Expand Up @@ -551,14 +548,12 @@ public void configure(ModelConfig modelConfig) throws WdkModelException {

ModelConfigAppDB appDbConfig = modelConfig.getAppDB();
ModelConfigUserDB userDbConfig = modelConfig.getUserDB();
ModelConfigAccountDB accountDbConfig = modelConfig.getAccountDB();
ModelConfigUserDatasetStore udsConfig = modelConfig.getUserDatasetStoreConfig();

QueryLogger.initialize(modelConfig.getQueryMonitor());

appDb = new DatabaseInstance(appDbConfig, DB_INSTANCE_APP, true);
userDb = new DatabaseInstance(userDbConfig, DB_INSTANCE_USER, true);
accountDb = new DatabaseInstance(accountDbConfig, DB_INSTANCE_ACCOUNT, true);

// set true to avoid a broken dev irods at build time
if ( udsConfig == null ) {
Expand Down Expand Up @@ -599,6 +594,8 @@ public void configure(ModelConfig modelConfig) throws WdkModelException {
new UnconfiguredStepAnalysisFactory(this) :
new StepAnalysisFactoryImpl(this));

systemUser = userFactory.createUnregisteredUser().getSecond();

LOG.info("WDK Model configured.");
}

Expand Down Expand Up @@ -1360,17 +1357,6 @@ public String queryParamDisplayName(String paramName) {
}

public User getSystemUser() {
if (systemUser == null) {
try {
systemUserLock.lock();
if (systemUser == null) {
systemUser = userFactory.createUnregistedUser();
}
}
finally {
systemUserLock.unlock();
}
}
return systemUser;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
*/
public class WdkSqlScriptRunner {

private static enum DbType { APP, USER, ACCT }
private static enum DbType { APP, USER }

public static void main(String[] args) {
if (args.length != 3 && args.length != 5) {
System.err.println("USAGE: fgpJava " + WdkSqlScriptRunner.class.getName() + " <project_id> [APP|USER|ACCT] <sql_file> [<auto_commit> <stopOnError>]");
System.err.println("USAGE: fgpJava " + WdkSqlScriptRunner.class.getName() + " <project_id> [APP|USER] <sql_file> [<auto_commit> <stopOnError>]");
System.exit(1);
}
BufferedReader sqlReader = null;
Expand All @@ -46,7 +46,6 @@ public static void main(String[] args) {
ModelConfigDB dbConfig = (
whichDb.equals(DbType.APP) ? modelConf.getAppDB() :
whichDb.equals(DbType.USER) ? modelConf.getUserDB() :
whichDb.equals(DbType.ACCT) ? modelConf.getAccountDB() :
null ); // should never happen; value already validated

db = new DatabaseInstance(dbConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
import org.gusdb.wdk.model.record.Field;
import org.gusdb.wdk.model.record.PrimaryKeyDefinition;
import org.gusdb.wdk.model.record.PrimaryKeyIterator;
import org.gusdb.wdk.model.record.ResultSetPrimaryKeyIterator;
import org.gusdb.wdk.model.record.RecordClass;
import org.gusdb.wdk.model.record.RecordInstance;
import org.gusdb.wdk.model.record.ResultSetPrimaryKeyIterator;
import org.gusdb.wdk.model.record.TableField;
import org.gusdb.wdk.model.record.attribute.AttributeField;
import org.gusdb.wdk.model.record.attribute.ColumnAttributeField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import org.gusdb.wdk.model.query.spec.QueryInstanceSpec;
import org.gusdb.wdk.model.question.Question;
import org.gusdb.wdk.model.user.Step;
import org.gusdb.wdk.model.user.StepContainer.ListStepContainer;
import org.gusdb.wdk.model.user.Strategy;
import org.gusdb.wdk.model.user.User;
import org.gusdb.wdk.model.user.UserCache;
import org.gusdb.wdk.model.user.StepContainer.ListStepContainer;

/**
* Provides a utility to use transform questions to convert an answer value of
Expand Down
Loading

0 comments on commit 23c59fc

Please sign in to comment.