Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Add the Java API to GitHub.
  • Loading branch information
tredpath committed Dec 25, 2022
1 parent b1938ec commit 1a6e762
Show file tree
Hide file tree
Showing 146 changed files with 9,920 additions and 2 deletions.
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar

# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# repoTemplate
template repo for WISE Open Source
# W.I.S.E. Java API

This repository contains the W.I.S.E. API for Java. The minimum compatible
version of Java is 1.8.
59 changes: 59 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ca.wise</groupId>
<artifactId>javaapi</artifactId>
<packaging>jar</packaging>
<version>7.2022.12.00</version>
<name>WISE_JavaAPI</name>
<url>https://firegrowthmodel.ca/</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>WISE_JavaAPI</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<show>public</show>
<doclint>none</doclint>
</configuration>
</plugin>
</plugins>
</build>
</project>
59 changes: 59 additions & 0 deletions pom.xml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ca.wise</groupId>
<artifactId>javaapi</artifactId>
<packaging>jar</packaging>
<version>@PROMETHEUS_VERSION@</version>
<name>WISE_JavaAPI</name>
<url>https://firegrowthmodel.ca/</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>WISE_JavaAPI</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<show>public</show>
<doclint>none</doclint>
</configuration>
</plugin>
</plugins>
</build>
</project>
6 changes: 6 additions & 0 deletions src/main/java/ca/wise/api/Color.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package ca.wise.api;

public interface Color {

String stream();
}
30 changes: 30 additions & 0 deletions src/main/java/ca/wise/api/FileAttachment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ca.wise.api;

import lombok.Getter;
import lombok.Setter;

/**
* Stores file contents for use in the simulation. All file
* names must begin with `attachment:/`.
*/
public class FileAttachment {

@Getter @Setter
private String filename;

@Getter @Setter
private String contents;

@Getter @Setter
private byte[] data = null;

public FileAttachment(String filename, String contents) {
this.filename = filename;
this.contents = contents;
}

public FileAttachment(String filename, byte[] data) {
this.filename = filename;
this.data = data;
}
}
16 changes: 16 additions & 0 deletions src/main/java/ca/wise/api/IWISESerializable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ca.wise.api;

import java.util.List;

import ca.wise.api.validation.ValidationError;

/**
* @exclude
*/
public interface IWISESerializable {

/**
* Find all errors that may exist in the object.
*/
List<ValidationError> checkValid();
}
69 changes: 69 additions & 0 deletions src/main/java/ca/wise/api/JobOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package ca.wise.api;

import java.util.Collections;
import java.util.List;

import ca.wise.api.validation.ValidationError;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
* Options for running the job not directly related to
* scenarios or fire growth.
*/
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class JobOptions implements IWISESerializable {

/**
* The type of load balancing to use to run the job.
*/
@Getter @Setter
@Builder.Default
private LoadBalanceType loadBalance = LoadBalanceType.NONE;

/**
* A priority to use to sort the job queue. When a
* job is recieved by an instance of W.I.S.E. Manager
* it will be placed in the job queue immediately
* below the first job found with the same or higher
* priority that isn't already running starting from
* the bottom of the queue.
*
* The priority can be any valid integer value.
*/
@Getter @Setter
@Builder.Default
private int priority = 0;

/**
* Should the job be validated by W.I.S.E. instead of
* being run. The user can redo the job if there
* is a validation error or restart the job so
* that it simulates in W.I.S.E. using MQTT commands.
*/
@Getter @Setter
@Builder.Default
private boolean validate = false;

@Getter @Setter
private Integer tempOutputInterval;

@Getter @Setter
private Integer tempOutputCount;

@Getter @Setter
private Integer exportFormat;

/**
* {@inheritDoc}
*/
@Override
public List<ValidationError> checkValid() {
return Collections.emptyList();
}
}
30 changes: 30 additions & 0 deletions src/main/java/ca/wise/api/LatLon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ca.wise.api;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
* A class to store location information.
*/
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class LatLon {

/**
* The locations latitude.
*/
@Getter @Setter
@Builder.Default
private double latitude = 0;

/**
* The locations longitude.
*/
@Getter @Setter
@Builder.Default
private double longitude = 0;
}
46 changes: 46 additions & 0 deletions src/main/java/ca/wise/api/LoadBalanceType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ca.wise.api;

/**
* The types of load balancing available in W.I.S.E..
*/
public enum LoadBalanceType {
/**
* Don't use any load balancing. The generated FGM will be sent to
* a single instance of W.I.S.E. Manager and it will run all scenarios.
*/
NONE(0),
/**
* Every instance of W.I.S.E. Manager in the same cluster will receive
* the generated FGM. An external service will provide scenario
* indices to run so that each instance of W.I.S.E. that is processing
* the FGM will run different scenarios. The indices will be
* communicated to the W.I.S.E. instance over MQTT. See the
* [MQTT documentation](https://spydmobile.bitbucket.io/psaas_mqtt/#topic-psaas/{originator}/delegator/balance)
* for more information.
*/
EXTERNAL_COUNTER(1),
/**
* The generated FGM will be sent to a single instance of W.I.S.E.
* Manager. A file that the user creates will provide scenario
* indices to the instance of W.I.S.E. that runs the FGM. The file
* must be named balance.txt and each line must contain a valid
* scenario index that should be run. Typically used for debugging
* to force W.I.S.E. to only process a single scenario when many
* are present in the FGM.
*/
LOCAL_FILE(2);

public final int value;

LoadBalanceType(int value) {
this.value = value;
}

public static LoadBalanceType fromValue(int value) {
for (LoadBalanceType val : values()) {
if (val.value == value)
return val;
}
return NONE;
}
}
14 changes: 14 additions & 0 deletions src/main/java/ca/wise/api/SocketMsg.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ca.wise.api;

public class SocketMsg {

/**
* Should file existence tests for input files be skipped.
*/
public static boolean skipFileTests = false;

/**
* Should errors be thrown when invalid values are detected.
*/
public static boolean inlineThrowError = false;
}
Loading

0 comments on commit 1a6e762

Please sign in to comment.