// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java
// public class Ion implements Comparable<Ion> {
//     private static String SEPERATOR = ":";
//     private static int PRECESSION = 6;
// 
//     private Double mass;
//     private Double intensity;
// 
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (!(o instanceof Ion)) return false;
// 
//         Ion ion = (Ion) o;
// 
//         if (!getMass().equals(ion.getMass())) return false;
//         return getIntensity().equals(ion.getIntensity());
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = getMass().hashCode();
//         result = 31 * result + getIntensity().hashCode();
//         return result;
//     }
// 
//     public Ion() {}
// 
//     public Ion(double mass, double intensity) {
//         this.mass = mass;
//         this.intensity = intensity;
//     }
// 
//     public Double getIntensity() {
//         return intensity;
//     }
// 
//     public void setIntensity(Double intensity) {
//         this.intensity = intensity;
//     }
// 
//     public Double getMass() {
//         return mass;
//     }
// 
//     public void setMass(Double mass) {
//         this.mass = mass;
//     }
// 
//     public String toString() {
//         return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity());
//     }
// 
//     public int compareTo(Ion o) {
//         return getMass().compareTo(o.getMass());
//     }
// }
// 
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java
// public interface Splash {
// 
//     /**
//      * generates a new spectra hash based on the given spectrum
//      * @return
//      */
//     String splashIt(Spectrum spectrum);
// 
//     /**
//      * adds an optional listener to the
//      * @param listener
//      */
//     void addListener(SplashListener listener);
// }
// 
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java
// public class SplashFactory {
// 
//     public static Splash create() {
//         return createVersion1Splash();
//     }
// 
//     /**
//      * the first official splash release
//      *
//      * @return
//      */
//     public static Splash createVersion1Splash() {
//         return new SplashVersion1();
//     }
// 
// }
// 
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java
// public enum SpectraType {
//     MS('1'),
//     NMR('2'),
//     UV('3'),
//     IR('4'),
//     RAMAN('5');
// 
//     /**
//      * identifier has to be a single character
//      */
//     private final char identifier;
// 
//     /**
//      * creates a new spectra type with the assoicated reference number
//      *
//      * @param referenceNumber
//      */
//     SpectraType(char referenceNumber) {
//         this.identifier = referenceNumber;
//     }
// 
//     /**
//      * access to it's identifier
//      *
//      * @return
//      */
//     public char getIdentifier() {
//         return this.identifier;
//     }
// }
// 
// Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/dao/ValidationResponse.java
// public class ValidationResponse {
//     String referenceSplash;
// 
//     boolean validationSuccessful;
// 
//     public boolean isValidationSuccessful() {
//         return validationSuccessful;
//     }
// 
//     public void setValidationSuccessful(boolean validationSuccessful) {
//         this.validationSuccessful = validationSuccessful;
//     }
// 
//     public ValidationRequest getRequest() {
//         return request;
//     }
// 
//     public void setRequest(ValidationRequest request) {
//         this.request = request;
//     }
// 
//     public String getReferenceSplash() {
//         return referenceSplash;
//     }
// 
//     public void setReferenceSplash(String refrenceSplash) {
//         this.referenceSplash = refrenceSplash;
//     }
// 
//     ValidationRequest request;
// }


import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion;
import edu.ucdavis.fiehnlab.spectra.hash.core.Splash;
import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory;
import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType;
import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.Spectrum;
import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationRequest;
import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationResponse;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
package edu.ucdavis.fiehnlab.spectra.hash.rest;



/**
 * simple rest service, which hashes submitted spectra data, as well as validate provided spectra hashes against the current reference implementation
 */
@CrossOrigin
@org.springframework.web.bind.annotation.RestController
public class RestController {

    private Splash spectraHash;

    private Logger logger = Logger.getLogger(getClass());

    public RestController() {
        spectraHash = SplashFactory.create();
        logger.info("created hash generator of type: " + spectraHash);
    }

    /**
     * converts a spectra to the hash code
     * @param spectrum
     * @return splash code
     */
    @RequestMapping(value = "/splash/it", method = RequestMethod.POST)
    public String convert(@RequestBody Spectrum spectrum) {

        try {
            logger.info("received spectrum: " + spectrum);

            if (spectrum.getIons().isEmpty()) {
                throw new RuntimeException("spectrum must have at least one ion");
            }

            String hash = spectraHash.splashIt(spectrum);
            logger.info("generated hash: " + hash);

            return hash;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            throw new RuntimeException(e);
        }
    }

    @RequestMapping(value = "/splash/it/example" ,method = RequestMethod.GET)
    public Spectrum splashRequestExample() {
        Spectrum spectrum = new Spectrum();
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java
// public class Ion implements Comparable<Ion> {
//     private static String SEPERATOR = ":";
//     private static int PRECESSION = 6;
// 
//     private Double mass;
//     private Double intensity;
// 
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (!(o instanceof Ion)) return false;
// 
//         Ion ion = (Ion) o;
// 
//         if (!getMass().equals(ion.getMass())) return false;
//         return getIntensity().equals(ion.getIntensity());
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = getMass().hashCode();
//         result = 31 * result + getIntensity().hashCode();
//         return result;
//     }
// 
//     public Ion() {}
// 
//     public Ion(double mass, double intensity) {
//         this.mass = mass;
//         this.intensity = intensity;
//     }
// 
//     public Double getIntensity() {
//         return intensity;
//     }
// 
//     public void setIntensity(Double intensity) {
//         this.intensity = intensity;
//     }
// 
//     public Double getMass() {
//         return mass;
//     }
// 
//     public void setMass(Double mass) {
//         this.mass = mass;
//     }
// 
//     public String toString() {
//         return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity());
//     }
// 
//     public int compareTo(Ion o) {
//         return getMass().compareTo(o.getMass());
//     }
// }
// 
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java
// public interface Splash {
// 
//     /**
//      * generates a new spectra hash based on the given spectrum
//      * @return
//      */
//     String splashIt(Spectrum spectrum);
// 
//     /**
//      * adds an optional listener to the
//      * @param listener
//      */
//     void addListener(SplashListener listener);
// }
// 
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java
// public class SplashFactory {
// 
//     public static Splash create() {
//         return createVersion1Splash();
//     }
// 
//     /**
//      * the first official splash release
//      *
//      * @return
//      */
//     public static Splash createVersion1Splash() {
//         return new SplashVersion1();
//     }
// 
// }
// 
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java
// public enum SpectraType {
//     MS('1'),
//     NMR('2'),
//     UV('3'),
//     IR('4'),
//     RAMAN('5');
// 
//     /**
//      * identifier has to be a single character
//      */
//     private final char identifier;
// 
//     /**
//      * creates a new spectra type with the assoicated reference number
//      *
//      * @param referenceNumber
//      */
//     SpectraType(char referenceNumber) {
//         this.identifier = referenceNumber;
//     }
// 
//     /**
//      * access to it's identifier
//      *
//      * @return
//      */
//     public char getIdentifier() {
//         return this.identifier;
//     }
// }
// 
// Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/dao/ValidationResponse.java
// public class ValidationResponse {
//     String referenceSplash;
// 
//     boolean validationSuccessful;
// 
//     public boolean isValidationSuccessful() {
//         return validationSuccessful;
//     }
// 
//     public void setValidationSuccessful(boolean validationSuccessful) {
//         this.validationSuccessful = validationSuccessful;
//     }
// 
//     public ValidationRequest getRequest() {
//         return request;
//     }
// 
//     public void setRequest(ValidationRequest request) {
//         this.request = request;
//     }
// 
//     public String getReferenceSplash() {
//         return referenceSplash;
//     }
// 
//     public void setReferenceSplash(String refrenceSplash) {
//         this.referenceSplash = refrenceSplash;
//     }
// 
//     ValidationRequest request;
// }


// Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/RestController.java
import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion;
import edu.ucdavis.fiehnlab.spectra.hash.core.Splash;
import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory;
import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType;
import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.Spectrum;
import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationRequest;
import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationResponse;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;

package edu.ucdavis.fiehnlab.spectra.hash.rest;



/**
 * simple rest service, which hashes submitted spectra data, as well as validate provided spectra hashes against the current reference implementation
 */
@CrossOrigin
@org.springframework.web.bind.annotation.RestController
public class RestController {

    private Splash spectraHash;

    private Logger logger = Logger.getLogger(getClass());

    public RestController() {
        spectraHash = SplashFactory.create();
        logger.info("created hash generator of type: " + spectraHash);
    }

    /**
     * converts a spectra to the hash code
     * @param spectrum
     * @return splash code
     */
    @RequestMapping(value = "/splash/it", method = RequestMethod.POST)
    public String convert(@RequestBody Spectrum spectrum) {

        try {
            logger.info("received spectrum: " + spectrum);

            if (spectrum.getIons().isEmpty()) {
                throw new RuntimeException("spectrum must have at least one ion");
            }

            String hash = spectraHash.splashIt(spectrum);
            logger.info("generated hash: " + hash);

            return hash;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            throw new RuntimeException(e);
        }
    }

    @RequestMapping(value = "/splash/it/example" ,method = RequestMethod.GET)
    public Spectrum splashRequestExample() {
        Spectrum spectrum = new Spectrum();
        spectrum.setIons(Arrays.asList(new Ion(100, 1), new Ion(101, 2), new Ion(102, 3)));