Skip to content
Snippets Groups Projects
Commit e963a0ef authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

First commit

parents
No related branches found
No related tags found
No related merge requests found
target/
classes/
pom.xml 0 → 100644
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>no.bioforsk.vips.common</groupId>
<artifactId>VIPSCommon</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>VIPSCommon</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<tags>
<tag>
<name>copyright</name>
<!-- copyright tag for classes and interfaces -->
<placement>t</placement>
<head>&copy; Copyright</head>
</tag>
</tags>
</configuration>
</plugin>
</plugins>
</build>
</project>
package no.bioforsk.vips.entity;
import java.util.HashMap;
import java.util.Map;
/**
* Represents all configuration for a model to be run.
* To see which configuration needs to be provided for a particular model,
* read the getUsage() from that model.
*
* @copyright 2013 {@link http://www.bioforsk.no Bioforsk}
* @author Tor-Einar Skog <tor-einar.skog@bioforsk.no>
*/
public class ModelConfiguration {
private String modelId;
private Map<String, Object> configParameters;
public ModelConfiguration()
{
}
/**
* Set a particular config parameter
* @param parameterName
* @param parameterValue
*/
public void setConfigParameter(String parameterName, Object parameterValue)
{
if(this.configParameters == null)
{
this.configParameters = new HashMap();
}
this.configParameters.put(parameterName, parameterValue);
}
/**
* Returns the requested configuration parameter
* @param parameterName
* @return
*/
public Object getConfigParameter(String parameterName)
{
return this.configParameters != null ? this.configParameters.get(parameterName) : null;
}
/**
* @return the modelId
*/
public String getModelId() {
return modelId;
}
/**
* @param modelId the modelId to set
*/
public void setModelId(String modelId) {
this.modelId = modelId;
}
/**
* @return the configParameters
*/
public Map<String, Object> getConfigParameters() {
return configParameters;
}
/**
* @param configParameters the configParameters to set
*/
public void setConfigParameters(Map<String, Object> configParameters) {
this.configParameters = configParameters;
}
}
package no.bioforsk.vips.entity;
import java.util.Date;
import java.util.Map;
import java.util.Set;
/**
* Represents a result from a model run
* @copyright 2013 {@link http://www.bioforsk.no Bioforsk}
* @author Tor-Einar Skog <tor-einar.skog@hyper.no>
*/
public interface Result extends Comparable{
/* Time for which these results are valid */
public void setResultValidTime(Date time);
public Date getResultValidTime();
/* The result parameters in this Result object */
public void setKeys(Set<String> keys);
public Set<String> getKeys();
/* Setting and getting values */
public void setValue(String key, String value);
public String getValue(String key);
public Map<String,String> getAllValues();
}
package no.bioforsk.vips.entity;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Represents a result
* @copyright 2013 {@link http://www.bioforsk.no Bioforsk}
* @author Tor-Einar Skog <tor-einar.skog@bioforsk.no>
*/
public class ResultImpl implements Result{
private Date resultValidTime;
private Set<String> keys;
private HashMap<String, String> values;
public void setResultValidTime(Date time) {
this.resultValidTime = time;
}
public Date getResultValidTime() {
return this.resultValidTime;
}
public void setKeys(Set<String> keys) {
this.keys = keys;
}
public Set<String> getKeys() {
return this.values.keySet();
}
public void setValue(String key, String value) {
if(this.values == null)
this.values = new HashMap();
this.values.put(key, value);
}
public String getValue(String key) {
return this.values != null ? this.values.get(key) : null;
}
public Map<String, String> getAllValues() {
return this.values;
}
/**
* Sorting by timestamp
* @param t
* @return
*/
public int compareTo(Object t) {
return this.getResultValidTime().compareTo(((Result) t).getResultValidTime());
}
}
package no.bioforsk.vips.entity;
import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* TEST object
* @author treinar
*/
@XmlRootElement(name="weather")
@XmlAccessorType(XmlAccessType.FIELD)
public class Weather {
public Weather()
{
}
public Weather(Date date, String details){
this.date=date;
this.details=details;
}
@XmlAttribute
private Date date;
@XmlElement
private String details;
/**
* @return the date
*/
public Date getDate() {
return date;
}
/**
* @param date the date to set
*/
public void setDate(Date date) {
this.date = date;
}
/**
* @return the details
*/
public String getDetails() {
return details;
}
/**
* @param details the details to set
*/
public void setDetails(String details) {
this.details = details;
}
}
package no.bioforsk.vips.model;
import no.bioforsk.vips.entity.Result;
import java.util.List;
/**
* All models must implement this interface
* @copyright 2013 {@link http://www.bioforsk.no Bioforsk}
* @author Tor-Einar Skog <tor-einar.skog@bioforsk.no>
*/
public interface Model {
public List<Result> getResult();
/**
*
* @return 10-character ID of the model. Must be unique (at least in the current system)
*/
public ModelId getModelId();
/**
* @return The name of the model
*/
public String getModelName();
/**
* @return a thorough manual for this model
*/
public String getModelUsage();
}
package no.bioforsk.vips.model;
/**
* Represents a model Id. Must be a 10-character string with alphanumerics and no spaces
* @copyright 2013 {@link http://www.bioforsk.no Bioforsk}
* @author Tor-Einar Skog <tor-einar.skog@bioforsk.no>
*/
public class ModelId {
private char[] id;
public ModelId(){
};
/**
*
* @param theId Must be a 10-character string with alphanumerics and no spaces
*/
public ModelId(String theId){
this();
this.setId(theId);
}
private void setId(String theId) {
this.id = theId.toCharArray();
}
@Override
public String toString()
{
StringBuilder retVal = new StringBuilder();
retVal.append(this.id);
return retVal.toString();
}
}
package no.bioforsk.vips.common;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment