PVOutput integration v1 – code
The entire source is shown below, but can also be downloaded. The MD5 hash for the zip is: 54de9a8eb71637bb00a8f454ae939016
Source
CollectedData.java
package uk.co.vsf.solar.device.integration;
import uk.co.vsf.solar.pvoutput.domain.Output;
/**
* Represents the data collected by any device.
*
* @author Victoria
*/
public interface CollectedData
{
/**
* Populates the output object with the data collected.
*
* @param output
* to populate
*/
void populateOutput(Output output);
}
Device.java
package uk.co.vsf.solar.device.integration;
import java.util.Calendar;
import uk.co.vsf.solar.pvoutput.domain.Output;
public interface Device {
/**
* Collects data from the device. E.g. in the case of the sunny beam,
* fetches the files and copies them locally.
*
* @return data collected
*/
public CollectedData collectDataFromDevice(Calendar dateToCollect);
public DeviceDecorator getDeviceDecorator(Output output, CollectedData collectedData);
}
DeviceDecorator.java
package uk.co.vsf.solar.device.integration;
import uk.co.vsf.solar.pvoutput.domain.Output;
import uk.co.vsf.solar.pvoutput.domain.impl.OutputImpl;
/**
* Interface for decorating the PV Output data.
*
* @author Victoria
*/
public abstract class DeviceDecorator extends OutputImpl
{
@SuppressWarnings("unused")
private Output output;
public DeviceDecorator(Output output)
{
this.output = output;
}
public void applyCollectedData()
{
// do nothing
}
}
EnergyData.java
package uk.co.vsf.solar.device.integration;
/**
* Interface representing energy used within the premises.
*
* @author Victoria
*/
public interface EnergyData extends CollectedData
{
}
SolarData.java
package uk.co.vsf.solar.device.integration;
/**
* Interface for representing solar data collected.
*
* @author Victoria
*/
public interface SolarData extends CollectedData
{
}
WeatherData.java
package uk.co.vsf.solar.device.integration;
/**
* Interface for representing weather data collected.
*
* @author Victoria
*/
public interface WeatherData extends CollectedData
{
}
PeakPower.java
package uk.co.vsf.solar.device.sma.sunnybeam.domain;
import java.math.BigDecimal;
import java.util.Comparator;
import uk.co.vsf.solar.domain.Time;
/**
* Represents peak power which is also twinned with a peak time.
*
* @author Victoria
*/
public class PeakPower {
private BigDecimal peakPower;
private Time peakTime;
public PeakPower(BigDecimal peakPower, Time peakTime) {
this.peakPower = peakPower;
this.peakTime = peakTime;
}
public static PeakPowerComparator getComparator() {
return new PeakPowerComparator();
}
/**
* Comparator for peak power.
*
* @author Victoria
*/
public static class PeakPowerComparator implements Comparator<PeakPower> {
public int compare(PeakPower arg0, PeakPower arg1) {
return arg1.getPeakPowerkW().compareTo(arg0.getPeakPowerkW());
}
}
public BigDecimal getPeakPowerkW() {
return peakPower;
}
public Time getPeakTime() {
return peakTime;
}
}
SunnyBeamDailyOutput.java
package uk.co.vsf.solar.device.sma.sunnybeam.domain;
import static uk.co.vsf.solar.utilities.ConversionUtils.kwhToWatts;
import java.math.BigDecimal;
import uk.co.vsf.solar.device.integration.SolarData;
import uk.co.vsf.solar.domain.Date;
import uk.co.vsf.solar.domain.Time;
import uk.co.vsf.solar.pvoutput.domain.Output;
/**
* Represents the useful available data from the Sunny Beam CSV data file.
*
* @author Victoria
*/
public class SunnyBeamDailyOutput implements SolarData {
private Date date;
private BigDecimal energyGeneratedkWh;
private BigDecimal peakPowerkW;
private Time peakTime;
public SunnyBeamDailyOutput(Date date, BigDecimal energyGeneratedkWh, BigDecimal peakPowerkW, Time peakTime) {
this.date = date;
this.energyGeneratedkWh = energyGeneratedkWh;
this.peakPowerkW = peakPowerkW;
this.peakTime = peakTime;
}
public SunnyBeamDailyOutput(Date date, BigDecimal energyGeneratedkWh, PeakPower peakPower) {
this.date = date;
this.energyGeneratedkWh = energyGeneratedkWh;
this.peakPowerkW = peakPower.getPeakPowerkW();
this.peakTime = peakPower.getPeakTime();
}
/**
* Uses the output in this bean and adds it to the output bean.
*/
public void populateOutput(Output output) {
output.setOutputDate(date);
output.setGenerated(kwhToWatts(energyGeneratedkWh));
output.setPeakPower(kwhToWatts(peakPowerkW));
output.setPeakTime(peakTime);
}
public Date getDate() {
return date;
}
public BigDecimal getEnergyGeneratedkWh() {
return energyGeneratedkWh;
}
public BigDecimal getPeakPowerkW() {
return peakPowerkW;
}
public Time getPeakTime() {
return peakTime;
}
}
SunnyBeam.java
package uk.co.vsf.solar.device.sma.sunnybeam.impl;
import java.util.Calendar;
import uk.co.vsf.solar.device.integration.CollectedData;
import uk.co.vsf.solar.device.integration.Device;
import uk.co.vsf.solar.device.integration.DeviceDecorator;
import uk.co.vsf.solar.pvoutput.domain.Output;
public class SunnyBeam implements Device {
private SunnyBeamFileHandler sunnyBeamFileHandler;
/**
* {@inheritDoc}
*/
public CollectedData collectDataFromDevice(Calendar dateToFetch) {
return sunnyBeamFileHandler.getDataForDate(dateToFetch);
}
/**
* {@inheritDoc}
*/
public DeviceDecorator getDeviceDecorator(Output output, CollectedData collectedData) {
//SunnyBeamDailyOutput collectedSunnybeamData = (SunnyBeamDailyOutput) collectedData;
//return new SunnyBeamData(output, collectedSunnybeamData);
return null;
}
public void setSunnyBeamFileHandler(SunnyBeamFileHandler sunnyBeamFileHandler) {
this.sunnyBeamFileHandler = sunnyBeamFileHandler;
}
}
SunnyBeamDailyOutputReaderImpl.java
package uk.co.vsf.solar.device.sma.sunnybeam.impl;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import uk.co.vsf.solar.device.sma.sunnybeam.SunnyBeamDailyOutputReader;
import uk.co.vsf.solar.device.sma.sunnybeam.domain.PeakPower;
import uk.co.vsf.solar.device.sma.sunnybeam.domain.SunnyBeamDailyOutput;
import uk.co.vsf.solar.domain.Date;
import uk.co.vsf.solar.domain.Time;
import uk.co.vsf.solar.exception.IntegrationException;
import au.com.bytecode.opencsv.CSVReader;
public class SunnyBeamDailyOutputReaderImpl implements SunnyBeamDailyOutputReader {
private static char SEPARATOR = ';';
private static char QUOTE = '\'';
private static int START = 8;
public SunnyBeamDailyOutput readFile(File file) {
try {
FileReader fileReader = new FileReader(file);
CSVReader reader = new CSVReader(fileReader, SEPARATOR, QUOTE, START);
Date fileDate = getFileDate(file);
return readFileData(reader, fileDate);
} catch (FileNotFoundException e) {
throw new IntegrationException(e);
}
}
private Date getFileDate(File file) {
String fileName = file.getName();
fileName = fileName.substring(0, 8);
int year = new Integer(fileName.substring(0, 2));
int month = new Integer(fileName.substring(3, 5));
int day = new Integer(fileName.substring(6, 8));
Date date = new Date(year, month, day);
return date;
}
private SunnyBeamDailyOutput readFileData(CSVReader reader, Date fileDate) {
PeakPower peakPower = getOutputResults(reader);
BigDecimal generatedKWatts = getGeneratedKWatts(reader);
SunnyBeamDailyOutput output = new SunnyBeamDailyOutput(fileDate, generatedKWatts, peakPower);
return output;
}
private PeakPower getOutputResults(CSVReader reader) {
List<PeakPower> peakTimes = new ArrayList<PeakPower>();
for (int i = 0; i < 144; i++) {
try {
String[] row = reader.readNext();
String timeString = row[0];
BigDecimal power = new BigDecimal(row[1]);
int hour = new Integer(timeString.substring(0, 2));
int minute = new Integer(timeString.substring(3, 5));
Time time = new Time(hour, minute);
PeakPower peakPower = new PeakPower(power, time);
peakTimes.add(peakPower);
} catch (IOException e) {
throw new IntegrationException(e);
}
}
Collections.sort(peakTimes, PeakPower.getComparator());
return peakTimes.get(0);
}
private BigDecimal getGeneratedKWatts(CSVReader reader) {
try {
reader.readNext();
reader.readNext();
String[] generatedRow = reader.readNext();
String energyGenerated = generatedRow[1];
return new BigDecimal(energyGenerated);
} catch (IOException e) {
throw new IntegrationException(e);
}
}
}
SunnyBeamData.java
package uk.co.vsf.solar.device.sma.sunnybeam.impl;
import uk.co.vsf.solar.device.integration.DeviceDecorator;
import uk.co.vsf.solar.device.sma.sunnybeam.domain.SunnyBeamDailyOutput;
import uk.co.vsf.solar.pvoutput.domain.Output;
/**
* SunnyBeamData decorator for applying the collected data to the output object.
*
* @author Victoria
*/
public class SunnyBeamData extends DeviceDecorator {
private SunnyBeamDailyOutput dailyOutput;
public SunnyBeamData(Output output, SunnyBeamDailyOutput dailyOutput) {
super(output);
this.dailyOutput = dailyOutput;
}
@Override
public void applyCollectedData() {
super.applyCollectedData();
dailyOutput.populateOutput(this);
}
}
SunnyBeamFileHandler.java
package uk.co.vsf.solar.device.sma.sunnybeam.impl;
import static java.lang.String.format;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Calendar;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import uk.co.vsf.solar.device.CopyDataException;
import uk.co.vsf.solar.device.NoDataForDateException;
import uk.co.vsf.solar.device.integration.CollectedData;
import uk.co.vsf.solar.device.sma.sunnybeam.SunnyBeamDailyOutputReader;
import uk.co.vsf.solar.domain.Date;
public class SunnyBeamFileHandler {
private String sunnybeamDevicePath;
private String copyToDir;
private SunnyBeamDailyOutputReader sunnyBeamDailyOutputReader;
public CollectedData getDataForDate(Calendar dateToLookFor) {
Date date = new Date(dateToLookFor);
File fileForDate = new File(format(sunnybeamDevicePath, date.getYear().substring(2), date.getMonth(), date.getDay()));
if (fileForDate.exists()) {
copyFile(fileForDate);
return sunnyBeamDailyOutputReader.readFile(fileForDate);
}
throw new NoDataForDateException(date);
}
private void copyFile(File fileForDate) {
try {
File outputFile = new File(copyToDir + fileForDate.getName());
outputFile.createNewFile();
outputFile.setWritable(true);
FileUtils.copyFile(fileForDate, outputFile);
} catch (FileNotFoundException e) {
throw new CopyDataException(e);
} catch (IOException e) {
throw new CopyDataException(e);
}
}
public void setSunnybeamDevicePath(String sunnybeamDevicePath) {
this.sunnybeamDevicePath = sunnybeamDevicePath;
}
public void setCopyToDir(String copyToDir) {
this.copyToDir = copyToDir;
}
public void setSunnyBeamDailyOutputReader(SunnyBeamDailyOutputReader sunnyBeamDailyOutputReader) {
this.sunnyBeamDailyOutputReader = sunnyBeamDailyOutputReader;
}
}
SunnyBeamDailyOutputReader.java
package uk.co.vsf.solar.device.sma.sunnybeam;
import java.io.File;
import uk.co.vsf.solar.device.sma.sunnybeam.domain.SunnyBeamDailyOutput;
public interface SunnyBeamDailyOutputReader {
public SunnyBeamDailyOutput readFile(File file);
}
CopyDataException.java
package uk.co.vsf.solar.device;
public class CopyDataException extends RuntimeException {
private static final long serialVersionUID = -9024760240562691398L;
public CopyDataException(Throwable e) {
super(e);
}
}
NoDataForDateException.java
package uk.co.vsf.solar.device;
import uk.co.vsf.solar.domain.Date;
public class NoDataForDateException extends RuntimeException {
private static final long serialVersionUID = 4686913025163352256L;
private Date date;
public NoDataForDateException(Date date) {
this.date = date;
}
public String getDate() {
return date.getDate();
}
}
AbstractDateTime.java
package uk.co.vsf.solar.domain;
class AbstractDateTime
{
protected String getPrintValue(int value)
{
if (value > 9)
{
return "" + value;
}
return "0" + value;
}
}
Date.java
package uk.co.vsf.solar.domain;
import java.util.Calendar;
public class Date extends AbstractDateTime {
private static final int Y2K = 2000;
private int year = Y2K;
private int month;
private int day;
/**
* Default constructor
*
* @param year
* since 2000, so if you want 1988, supply -12
* @param month
* @param day
*/
public Date(int year, int month, int day) {
this.year += year;
this.month = month;
this.day = day;
}
public Date(Calendar date) {
this.year = date.get(Calendar.YEAR);
this.month = date.get(Calendar.MONTH) + 1;
this.day = date.get(Calendar.DAY_OF_MONTH);
}
/**
* Outputs the date as yyyyMMdd.
*
* @return date string
*/
public String getDate() {
return year + getPrintValue(month) + getPrintValue(day);
}
public String getYearPrintValue() {
int sum = year - Y2K;
if (sum >= 0) {
return getPrintValue(sum);
}
sum = sum - (sum * 2);
return getPrintValue(sum);
}
@Override
public String toString() {
return getDate();
}
public String getYear() {
return getPrintValue(year);
}
public String getMonth() {
return getPrintValue(month);
}
public String getDay() {
return getPrintValue(day);
}
}
Time.java
package uk.co.vsf.solar.domain;
public class Time extends AbstractDateTime {
private int hour;
private int minutes;
public Time(int hour, int minutes) {
super();
this.hour = hour;
this.minutes = minutes;
}
public String getTime() {
return getPrintValue(hour) + ":" + getPrintValue(minutes);
}
}
IntegrationException.java
package uk.co.vsf.solar.exception;
public class IntegrationException extends RuntimeException {
private static final long serialVersionUID = -1558712486181262082L;
public IntegrationException(Exception e) {
super(e);
}
}
MuleFactoryImpl.java
package uk.co.vsf.solar.mule.impl;
import org.mule.DefaultMuleMessage;
import org.mule.api.MuleContext;
import org.mule.api.MuleException;
import org.mule.api.MuleMessage;
import org.mule.api.config.ConfigurationException;
import org.mule.api.lifecycle.InitialisationException;
import org.mule.context.DefaultMuleContextFactory;
import org.mule.module.client.MuleClient;
import uk.co.vsf.solar.mule.GeneralMuleException;
import uk.co.vsf.solar.mule.MuleFactory;
public class MuleFactoryImpl implements MuleFactory {
private static final String MULE_CONFIGS = "mule/pvoutput.xml,mule/pvoutput-getmissing.xml,mule/pvoutput-addoutput.xml,spring/applicationContext.xml";
private MuleClient muleClient;
private MuleContext muleContext;
/**
* {@inheritDoc}
*/
public MuleClient getClient() {
if (muleClient == null) {
try {
DefaultMuleContextFactory mcfactory = new DefaultMuleContextFactory();
muleContext = mcfactory.createMuleContext(MULE_CONFIGS);
muleContext.start();
muleClient = new MuleClient(muleContext);
} catch (InitialisationException e) {
throw new GeneralMuleException();
} catch (ConfigurationException e) {
throw new GeneralMuleException();
} catch (MuleException e) {
throw new GeneralMuleException();
}
}
return muleClient;
}
/**
* {@inheritDoc}
*/
public MuleMessage createMuleMessage(Object payload) {
return new DefaultMuleMessage(payload, muleContext);
}
}
GeneralMuleException.java
package uk.co.vsf.solar.mule;
public class GeneralMuleException extends RuntimeException {
}
MuleFactory.java
package uk.co.vsf.solar.mule;
import org.mule.api.MuleMessage;
import org.mule.module.client.MuleClient;
public interface MuleFactory {
/**
* Gets an instance of the mule client.
*
* @return mule client
*/
MuleClient getClient();
/**
* Creates a mule message from the context using the payload provided.
*
* @param payload
* to add to message
* @return message
*/
MuleMessage createMuleMessage(Object payload);
}
Condition.java
package uk.co.vsf.solar.pvoutput.domain.impl;
public enum Condition
{
FINE("Fine"),
PARTLY_CLOUDY("Partly Cloudy"),
MOSTLY_CLOUDY("Mostly Cloudy"),
CLOUDY("Cloudy"),
SHOWERS("Showers"),
SNOW("Snow"),
NOT_SURE("Not Sure");
private String condition;
private Condition(String condition) {
this.condition = condition;
}
public String getCondition() {
return condition;
}
}
OutputImpl.java
package uk.co.vsf.solar.pvoutput.domain.impl;
import static uk.co.vsf.solar.pvoutput.domain.impl.Condition.NOT_SURE;
import uk.co.vsf.solar.domain.Date;
import uk.co.vsf.solar.domain.Time;
import uk.co.vsf.solar.pvoutput.domain.Output;
public class OutputImpl implements Output {
private Date outputDate;
private int generated;
private Integer exported;
private Integer peakPower;
private Time peakTime;
private Condition condition = NOT_SURE;
private Integer minTemperature;
private Integer maxTemperature;
private String comments;
private Integer importPeak;
private Integer importOffPeak;
private Integer importShoulder;
private Integer importHighShoulder;
public String getPostValues() {
StringBuffer stringBuffer = new StringBuffer();
addValue(stringBuffer, OUTPUT_DATE, outputDate.getDate());
addValue(stringBuffer, GENERATED, generated);
addValue(stringBuffer, EXPORTED, exported);
addValue(stringBuffer, PEAK_POWER, peakPower);
if (peakTime != null) {
addValue(stringBuffer, PEAK_TIME, peakTime.getTime());
}
addValue(stringBuffer, CONDITION, condition.getCondition());
addValue(stringBuffer, MIN_TEMP, minTemperature);
addValue(stringBuffer, MAX_TEMP, maxTemperature);
addValue(stringBuffer, COMMENTS, comments);
addValue(stringBuffer, IMPORT_PEAK, importPeak);
addValue(stringBuffer, IMPORT_OFF_PEAK, importOffPeak);
addValue(stringBuffer, IMPORT_SHOULDER, importShoulder);
addValue(stringBuffer, IMPORT_HIGH_SHOULDER, importHighShoulder);
return stringBuffer.toString();
}
private void addValue(StringBuffer stringBuffer, String key, Integer value) {
if (value != null) {
addValue(stringBuffer, key, "" + value);
}
}
private void addValue(StringBuffer stringBuffer, String key, String value) {
if (value != null && !(value.trim().equals(""))) {
if (stringBuffer.length() > 0) {
stringBuffer.append("&");
}
stringBuffer.append(key + "=" + value);
}
}
public String getOutputDate() {
return outputDate.getDate();
}
public void setOutputDate(Date outputDate) {
this.outputDate = outputDate;
}
public int getGenerated() {
return generated;
}
public void setGenerated(int generated) {
this.generated = generated;
}
public Integer getExported() {
return exported;
}
public void setExported(Integer exported) {
this.exported = exported;
}
public Integer getPeakPower() {
return peakPower;
}
public void setPeakPower(Integer peakPower) {
this.peakPower = peakPower;
}
public String getPeakTime() {
return peakTime.getTime();
}
public void setPeakTime(Time peakTime) {
this.peakTime = peakTime;
}
public Condition getCondition() {
return condition;
}
public void setCondition(Condition condition) {
this.condition = condition;
}
public Integer getMinTemperature() {
return minTemperature;
}
public void setMinTemperature(Integer minTemperature) {
this.minTemperature = minTemperature;
}
public Integer getMaxTemperature() {
return maxTemperature;
}
public void setMaxTemperature(Integer maxTemperature) {
this.maxTemperature = maxTemperature;
}
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
public Integer getImportPeak() {
return importPeak;
}
public void setImportPeak(Integer importPeak) {
this.importPeak = importPeak;
}
public Integer getImportOffPeak() {
return importOffPeak;
}
public void setImportOffPeak(Integer importOffPeak) {
this.importOffPeak = importOffPeak;
}
public Integer getImportShoulder() {
return importShoulder;
}
public void setImportShoulder(Integer importShoulder) {
this.importShoulder = importShoulder;
}
public Integer getImportHighShoulder() {
return importHighShoulder;
}
public void setImportHighShoulder(Integer importHighShoulder) {
this.importHighShoulder = importHighShoulder;
}
}
Output.java
package uk.co.vsf.solar.pvoutput.domain;
import uk.co.vsf.solar.domain.Date;
import uk.co.vsf.solar.domain.Time;
import uk.co.vsf.solar.pvoutput.domain.impl.Condition;
public interface Output {
String OUTPUT_DATE = "d";
String GENERATED = "g";
String EXPORTED = "e";
String PEAK_POWER = "pp";
String PEAK_TIME = "pt";
String CONDITION = "cd";
String MIN_TEMP = "tm";
String MAX_TEMP = "tx";
String COMMENTS = "cm";
String IMPORT_PEAK = "ip";
String IMPORT_OFF_PEAK = "io";
String IMPORT_SHOULDER = "is";
String IMPORT_HIGH_SHOULDER = "ih";
public String getPostValues();
public void setOutputDate(Date outputDate);
public void setGenerated(int generated);
public void setExported(Integer exported);
public void setPeakPower(Integer peakPower);
public void setPeakTime(Time peakTime);
public void setCondition(Condition condition);
public void setMinTemperature(Integer minTemperature);
public void setMaxTemperature(Integer maxTemperature);
public void setComments(String comments);
public void setImportPeak(Integer importPeak);
public void setImportOffPeak(Integer importOffPeak);
public void setImportShoulder(Integer importShoulder);
public void setImportHighShoulder(Integer importHighShoulder);
}
OutputBuilderImpl.java
package uk.co.vsf.solar.pvoutput.impl;
import java.util.Calendar;
import java.util.List;
import uk.co.vsf.solar.device.integration.CollectedData;
import uk.co.vsf.solar.device.integration.Device;
import uk.co.vsf.solar.pvoutput.OutputBuilder;
import uk.co.vsf.solar.pvoutput.domain.Output;
import uk.co.vsf.solar.pvoutput.domain.impl.OutputImpl;
public class OutputBuilderImpl implements OutputBuilder {
public List<Device> devices;
public void setDevices(List<Device> devices) {
this.devices = devices;
}
public Output buildOutput(Calendar dateToBuildOutputFor) {
if (!(devices.size() >= 1)) {
throw new IllegalArgumentException("There must be one or more device available.");
}
Output output = new OutputImpl();
for (Device device : devices) {
CollectedData collectedData = device.collectDataFromDevice(dateToBuildOutputFor);
collectedData.populateOutput(output);
}
return output;
}
}
AddOutputServiceImpl.java
package uk.co.vsf.solar.pvoutput.service.impl;
import org.apache.log4j.Logger;
import org.mule.api.MuleException;
import org.mule.api.MuleMessage;
import org.mule.module.client.MuleClient;
import uk.co.vsf.solar.exception.IntegrationException;
import uk.co.vsf.solar.mule.MuleFactory;
import uk.co.vsf.solar.pvoutput.domain.Output;
import uk.co.vsf.solar.pvoutput.service.AddOutputService;
public class AddOutputServiceImpl implements AddOutputService {
private Logger logger = Logger.getLogger(getClass());
/* Spring injected fields */
private MuleFactory muleClientFactory;
public void addOutput(Output output) {
try {
MuleClient client = muleClientFactory.getClient();
MuleMessage messageResult = client.send("vm://addoutput", output.getPostValues(), null);
} catch (MuleException e) {
throw new IntegrationException(e);
} catch (Exception e) {
throw new IntegrationException(e);
}
}
public void setMuleClientFactory(MuleFactory muleClientFactory) {
this.muleClientFactory = muleClientFactory;
}
}
GetMissingServiceImpl.java
package uk.co.vsf.solar.pvoutput.service.impl;
import static uk.co.vsf.solar.utilities.DateUtils.calendarToString;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import org.apache.log4j.Logger;
import org.mule.api.MuleMessage;
import org.mule.api.transport.PropertyScope;
import org.mule.module.client.MuleClient;
import uk.co.vsf.solar.exception.IntegrationException;
import uk.co.vsf.solar.mule.MuleFactory;
import uk.co.vsf.solar.pvoutput.service.GetMissingService;
import uk.co.vsf.solar.utilities.DateUtils;
public class GetMissingServiceImpl implements GetMissingService {
private Logger logger = Logger.getLogger(getClass());
public static final String POST_PARAMS_DATE_FROM = "df";
public static final String POST_PARAMS_DATE_TO = "dt";
/* Spring injected fields */
private MuleFactory muleClientFactory;
private String systemInstallDate;
/**
* {@inheritDoc}
*/
public List<Calendar> missingRecordings() {
try {
MuleClient client = muleClientFactory.getClient();
MuleMessage message = muleClientFactory.createMuleMessage(0);
message.setProperty(POST_PARAMS_DATE_FROM, systemInstallDate, PropertyScope.OUTBOUND);
message.setProperty(POST_PARAMS_DATE_TO, calendarToString(new GregorianCalendar()), PropertyScope.OUTBOUND);
MuleMessage messageResult = client.send("vm://getmissing", message);
String dates = messageResult.getPayloadAsString();
logger.info("Dates found: " + dates);
String[] datesSplit = dates.split(",");
List<Calendar> missingDates = new ArrayList<Calendar>();
for (String date : datesSplit) {
Calendar dateCalendar = DateUtils.stringToCalendar(date);
missingDates.add(dateCalendar);
}
return missingDates;
} catch (Exception e) {
throw new IntegrationException(e);
}
}
public void setMuleClientFactory(MuleFactory muleClientFactory) {
this.muleClientFactory = muleClientFactory;
}
public void setSystemInstallDate(String systemInstallDate) {
this.systemInstallDate = systemInstallDate;
}
}
PvOutputServiceImpl.java
package uk.co.vsf.solar.pvoutput.service.impl;
import java.util.Calendar;
import java.util.List;
import org.apache.log4j.Logger;
import uk.co.vsf.solar.device.NoDataForDateException;
import uk.co.vsf.solar.domain.Date;
import uk.co.vsf.solar.exception.IntegrationException;
import uk.co.vsf.solar.pvoutput.OutputBuilder;
import uk.co.vsf.solar.pvoutput.domain.Output;
import uk.co.vsf.solar.pvoutput.service.AddOutputService;
import uk.co.vsf.solar.pvoutput.service.GetMissingService;
import uk.co.vsf.solar.pvoutput.service.PvOutputService;
public class PvOutputServiceImpl implements PvOutputService {
private Logger logger = Logger.getLogger(getClass());
private GetMissingService getMissingService;
private OutputBuilder outputBuilder;
private AddOutputService addOutputService;
public void publishData() {
List<Calendar> missingDates = getMissingService.missingRecordings();
for (Calendar missingDate : missingDates) {
try {
logger.info("finding data from devices for date: " + new Date(missingDate));
Output output = outputBuilder.buildOutput(missingDate);
logger.info("found data for date");
addOutputService.addOutput(output);
logger.info("added data to website for date");
wait25Seconds();
} catch (NoDataForDateException e) {
logger.info("There was no data found for date: " + e.getDate());
}
}
logger.info("Successfully added all missing outputs");
}
private void wait25Seconds() {
try {
Thread.sleep(25000);
} catch (InterruptedException e) {
throw new IntegrationException(e);
}
}
public void setGetMissingService(GetMissingService getMissingService) {
this.getMissingService = getMissingService;
}
public void setOutputBuilder(OutputBuilder outputBuilder) {
this.outputBuilder = outputBuilder;
}
public void setAddOutputService(AddOutputService addOutputService) {
this.addOutputService = addOutputService;
}
}
AddOutputService.java
package uk.co.vsf.solar.pvoutput.service;
import uk.co.vsf.solar.pvoutput.domain.Output;
public interface AddOutputService {
public void addOutput(Output output);
}
GetMissingService.java
package uk.co.vsf.solar.pvoutput.service;
import java.util.Calendar;
import java.util.List;
public interface GetMissingService {
public List<Calendar> missingRecordings();
}
PvOutputService.java
package uk.co.vsf.solar.pvoutput.service;
public interface PvOutputService {
public void publishData();
}
OutputBuilder.java
package uk.co.vsf.solar.pvoutput;
import java.util.Calendar;
import uk.co.vsf.solar.pvoutput.domain.Output;
public interface OutputBuilder {
public Output buildOutput(Calendar dateToBuildOutputFor);
}
ConversionUtils.java
package uk.co.vsf.solar.utilities;
import java.math.BigDecimal;
public class ConversionUtils {
private static final BigDecimal WATTS_IN_ONE_KWH = new BigDecimal("1000");
public static int kwhToWatts(BigDecimal kWh) {
return kWh.multiply(WATTS_IN_ONE_KWH).intValue();
}
}
DateUtils.java
package uk.co.vsf.solar.utilities;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class DateUtils {
private static final SimpleDateFormat PVOUTPUT_FORMAT = new SimpleDateFormat("yyyyMMdd");
public static String calendarToString(Calendar cal) {
return PVOUTPUT_FORMAT.format(cal.getTime());
}
public static Calendar stringToCalendar(String date) {
try {
Calendar cal = new GregorianCalendar();
cal.setTime(PVOUTPUT_FORMAT.parse(date));
return cal;
} catch (ParseException e) {
throw new UtilitiesException(e);
}
}
}
UtilitiesException.java
package uk.co.vsf.solar.utilities;
public class UtilitiesException extends RuntimeException {
private static final long serialVersionUID = 7378026030882650041L;
public UtilitiesException(Throwable e) {
super(e);
}
}
PVOutputBootstrap.java
package uk.co.vsf.solar;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import uk.co.vsf.solar.pvoutput.service.PvOutputService;
public class PVOutputBootstrap {
public static void main(String... args) {
ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "spring/applicationContext.xml" });
PvOutputService service = (PvOutputService) context.getBean("pvOutputService");
service.publishData();
System.exit(0);
}
}
pvoutput-addoutput.xml
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.2/mule-http.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd">
<flow name="addOutputFlow">
<vm:inbound-endpoint path="addoutput"
exchange-pattern="request-response"
connector-ref="pvoutputConnector" />
<http:outbound-endpoint address="http://localhost:40000/service/r2/addoutput.jsp"
method="POST"
connector-ref="HttpConnector"
exchange-pattern="request-response"
followRedirects="false"
mimeType="application/x-www-form-urlencoded">
<message-properties-transformer>
<add-message-property key="X-Pvoutput-Apikey" value="${pvoutput.api.key}" />
<add-message-property key="X-Pvoutput-SystemId" value="${pvoutput.system.id}" />
</message-properties-transformer>
</http:outbound-endpoint>
</flow>
</mule>
pvoutput-getmissing.xml
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.2/mule-http.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd">
<flow name="getMissingFlow">
<vm:inbound-endpoint ref="GetMissingEndpoint" />
<http:outbound-endpoint address="http://localhost:40000/service/r1/getmissing.jsp?df=#[header:INBOUND:df]&dt=#[header:INBOUND:dt]"
method="GET"
connector-ref="HttpConnector"
exchange-pattern="request-response"
followRedirects="false">
<message-properties-transformer>
<add-message-property key="X-Pvoutput-Apikey" value="${pvoutput.api.key}" />
<add-message-property key="X-Pvoutput-SystemId" value="${pvoutput.system.id}" />
</message-properties-transformer>
</http:outbound-endpoint>
</flow>
</mule>
pvoutput.xml
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.2/mule-http.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd">
<http:connector name="HttpConnector"
enableCookies="false"
keepAlive="false" />
<vm:connector name="pvoutputConnector" />
<vm:endpoint path="getmissing"
exchange-pattern="request-response"
connector-ref="pvoutputConnector"
name="GetMissingEndpoint" />
</mule>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="locations">
<list>
<value>classpath:pvoutput.properties</value>
<value>file:c://properties/pvoutput.properties</value>
</list>
</property>
</bean>
<bean id="muleFactory" class="uk.co.vsf.solar.mule.impl.MuleFactoryImpl" />
<bean id="getMissingService"
class="uk.co.vsf.solar.pvoutput.service.impl.GetMissingServiceImpl">
<property name="muleClientFactory" ref="muleFactory" />
<property name="systemInstallDate" value="${system.install.date}" />
</bean>
<bean id="addOutputService"
class="uk.co.vsf.solar.pvoutput.service.impl.AddOutputServiceImpl">
<property name="muleClientFactory" ref="muleFactory" />
</bean>
<bean id="sunnyBeamDevice" class="uk.co.vsf.solar.device.sma.sunnybeam.impl.SunnyBeam">
<property name="sunnyBeamFileHandler" ref="sunnyBeamFileHandler" />
</bean>
<bean id="outputBuilder" class="uk.co.vsf.solar.pvoutput.impl.OutputBuilderImpl">
<property name="devices">
<list>
<ref bean="sunnyBeamDevice" />
</list>
</property>
</bean>
<bean id="sunnyBeamFileHandler"
class="uk.co.vsf.solar.device.sma.sunnybeam.impl.SunnyBeamFileHandler">
<property name="sunnybeamDevicePath" value="${device.solar.sma.sunnybeam.folder.path}" />
<property name="copyToDir" value="${device.solar.sma.sunnybeam.copy.to.daily}" />
<property name="sunnyBeamDailyOutputReader" ref="sunnyBeamDailyOutputReader" />
</bean>
<bean id="sunnyBeamDailyOutputReader"
class="uk.co.vsf.solar.device.sma.sunnybeam.impl.SunnyBeamDailyOutputReaderImpl" />
<bean id="pvOutputService" class="uk.co.vsf.solar.pvoutput.service.impl.PvOutputServiceImpl">
<property name="addOutputService" ref="addOutputService" />
<property name="outputBuilder" ref="outputBuilder" />
<property name="getMissingService" ref="getMissingService" />
</bean>
</beans>
log4j.properties
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=INFO, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
pvoutput.properties
# yyyyMMdd
system.install.date=20111029
pvoutput.api.key=API KEY HERE
pvoutput.system.id=SYSTEM ID HERE
device.solar.sma.sunnybeam.daily.file.pattern=%s-%s-%s.CSV
device.solar.sma.sunnybeam.monthly.file.pattern=%s-%s.CSV
device.solar.sma.sunnybeam.drive.letter=G
device.solar.sma.sunnybeam.folder.path=${device.solar.sma.sunnybeam.drive.letter}:\\SBEAM\\${device.solar.sma.sunnybeam.daily.file.pattern}
device.solar.sma.sunnybeam.copy.to.dir=C:\\Users\\Victoria\\Desktop\\solar data
device.solar.sma.sunnybeam.copy.to.daily=${device.solar.sma.sunnybeam.copy.to.dir}\\Daily\\
device.solar.sma.sunnybeam.copy.to.monthly=${device.solar.sma.sunnybeam.copy.to.dir}\\Monthly\\
Tests
DailyOutputTest.java
package uk.co.vsf.solar.device.sma.sunnybeam.domain;
import static junit.framework.Assert.assertEquals;
import static uk.co.vsf.solar.utilities.ConversionUtils.kwhToWatts;
import java.math.BigDecimal;
import org.junit.Test;
import uk.co.vsf.solar.domain.Date;
import uk.co.vsf.solar.domain.Time;
import uk.co.vsf.solar.pvoutput.domain.Output;
import uk.co.vsf.solar.pvoutput.domain.impl.OutputImpl;
public class DailyOutputTest
{
@Test
public void populateOutputOK()
{
OutputImpl output = new OutputImpl();
Date date = new Date(2011, 11, 23);
BigDecimal generated = new BigDecimal("1.428");
BigDecimal peak = new BigDecimal("3.226");
Time time = new Time(2, 33);
SunnyBeamDailyOutput dailyOutput = new SunnyBeamDailyOutput(date, generated, peak, time);
dailyOutput.populateOutput(output);
assertEquals(date.getDate(), output.getOutputDate());
assertEquals(kwhToWatts(generated), output.getGenerated());
assertEquals(kwhToWatts(peak), (int) output.getPeakPower());
assertEquals(time.getTime(), output.getPeakTime());
}
@Test(expected = NullPointerException.class)
public void populateOutputNPE()
{
Date date = new Date(2011, 11, 23);
BigDecimal generated = new BigDecimal("1.428");
BigDecimal peak = new BigDecimal("3.226");
Time time = new Time(2, 22);
SunnyBeamDailyOutput dailyOutput = new SunnyBeamDailyOutput(date, generated, peak, time);
dailyOutput.populateOutput(null);
}
}
SunnyBeamDailyOutputReaderTest.java
package uk.co.vsf.solar.device.sma.sunnybeam;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import org.junit.Test;
import uk.co.vsf.solar.device.sma.sunnybeam.domain.SunnyBeamDailyOutput;
import uk.co.vsf.solar.device.sma.sunnybeam.impl.SunnyBeamDailyOutputReaderImpl;
import uk.co.vsf.solar.domain.Date;
import uk.co.vsf.solar.domain.Time;
public class SunnyBeamDailyOutputReaderTest
{
private static final String PATH = "uk/co/vsf/solar/device/sma/sunnybeam/";
@Test
public void readFileOK() throws Exception
{
URL url = getClass().getClassLoader().getResource(PATH + "11-11-02.CSV");
File file = new File(url.toURI());
SunnyBeamDailyOutputReader reader = new SunnyBeamDailyOutputReaderImpl();
SunnyBeamDailyOutput data = reader.readFile(file);
assertEquals(new BigDecimal("2.430"), data.getPeakPowerkW());
assertEquals(new Date(11, 11, 2).getDate(), data.getDate().getDate());
assertEquals(new BigDecimal("9.975"), data.getEnergyGeneratedkWh());
assertEquals(new Time(9, 50).getTime(), data.getPeakTime().getTime());
}
@Test
public void readFileOK2() throws Exception
{
URL url = getClass().getClassLoader().getResource(PATH + "11-11-01.CSV");
File file = new File(url.toURI());
SunnyBeamDailyOutputReader reader = new SunnyBeamDailyOutputReaderImpl();
SunnyBeamDailyOutput data = reader.readFile(file);
assertEquals(new BigDecimal("1.854"), data.getPeakPowerkW());
assertEquals(new Date(11, 11, 1).getDate(), data.getDate().getDate());
assertEquals(new BigDecimal("4.769"), data.getEnergyGeneratedkWh());
assertEquals(new Time(12, 40).getTime(), data.getPeakTime().getTime());
}
}
OutputTest.java
package uk.co.vsf.solar.pvoutput.domain;
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import uk.co.vsf.solar.domain.Date;
import uk.co.vsf.solar.domain.Time;
import uk.co.vsf.solar.pvoutput.domain.impl.Condition;
import uk.co.vsf.solar.pvoutput.domain.impl.OutputImpl;
public class OutputTest {
@Test
public void getPostValues1() {
OutputImpl output = new OutputImpl();
Date date = new Date(12, 01, 29);
output.setOutputDate(date);
output.setGenerated(122);
assertEquals(
Output.OUTPUT_DATE + "=20120129" + "&" + Output.GENERATED + "=122" + "&" + Output.CONDITION + "="
+ Condition.NOT_SURE.getCondition(), output.getPostValues());
}
@Test
public void getPostValues2() {
OutputImpl output = new OutputImpl();
Date date = new Date(12, 01, 29);
output.setOutputDate(date);
int generated = 122;
String comment = "my comment";
int peakPower = 1256;
output.setGenerated(122);
output.setCondition(Condition.FINE);
output.setComments(comment);
output.setPeakPower(peakPower);
assertEquals(Output.OUTPUT_DATE + "=20120129" + "&" + Output.GENERATED + "=" + generated + "&" + Output.PEAK_POWER + "="
+ peakPower + "&" + Output.CONDITION + "=" + Condition.FINE.getCondition() + "&" + Output.COMMENTS + "=" + comment,
output.getPostValues());
}
@Test
public void getPostValues3() {
OutputImpl output = new OutputImpl();
Date date = new Date(12, 01, 29);
output.setOutputDate(date);
Time peakTime = new Time(13, 55);
output.setPeakTime(peakTime);
int generated = 122;
String comment = "my comment";
int peakPower = 1256;
output.setGenerated(122);
output.setCondition(Condition.FINE);
output.setComments(comment);
output.setPeakPower(peakPower);
assertEquals(Output.OUTPUT_DATE + "=20120129" + "&" + Output.GENERATED + "=" + generated + "&" + Output.PEAK_POWER + "="
+ peakPower + "&" + Output.PEAK_TIME + "=13:55" + "&" + Output.CONDITION + "=" + Condition.FINE.getCondition() + "&"
+ Output.COMMENTS + "=" + comment, output.getPostValues());
}
}
AddOutputServiceImplTest.java
package uk.co.vsf.solar.pvoutput.service.impl;
import java.util.GregorianCalendar;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import uk.co.vsf.solar.domain.Date;
import uk.co.vsf.solar.pvoutput.domain.impl.OutputImpl;
import uk.co.vsf.solar.pvoutput.service.AddOutputService;
@ContextConfiguration(value = "/spring/applicationContext.xml")
public class AddOutputServiceImplTest extends AbstractJUnit4SpringContextTests {
@Autowired
@Qualifier("addOutputService")
private AddOutputService addOutputService;
@Test
public void getMissingServiceTest() {
OutputImpl output = new OutputImpl();
output.setOutputDate(new Date(new GregorianCalendar()));
output.setGenerated(1156);
addOutputService.addOutput(output);
}
}
GetMissingServiceImplTest.java
package uk.co.vsf.solar.pvoutput.service.impl;
import java.util.Calendar;
import java.util.List;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import static junit.framework.Assert.*;
import uk.co.vsf.solar.pvoutput.service.GetMissingService;
@ContextConfiguration(value="/spring/applicationContext.xml")
public class GetMissingServiceImplTest extends AbstractJUnit4SpringContextTests {
@Autowired
@Qualifier("getMissingService")
private GetMissingService getMissingService;
@Test
public void getMissingServiceTest()
{
List<Calendar> dates = getMissingService.missingRecordings();
assertNotNull(dates);
assertTrue(dates.size() > 0);
}
}
PvOutputServiceImplTest.java
package uk.co.vsf.solar.pvoutput.service.impl;
import java.util.Calendar;
import java.util.List;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import static junit.framework.Assert.*;
import uk.co.vsf.solar.pvoutput.service.GetMissingService;
import uk.co.vsf.solar.pvoutput.service.PvOutputService;
@ContextConfiguration(value="/spring/applicationContext.xml")
public class PvOutputServiceImplTest extends AbstractJUnit4SpringContextTests {
@Autowired
@Qualifier("pvOutputService")
private PvOutputService pvOutputService;
@Test
public void getMissingServiceTest()
{
pvOutputService.publishData();
}
}
DateUtilsTest.java
package uk.co.vsf.solar.utilities;
import java.util.Calendar;
import java.util.GregorianCalendar;
import org.junit.Test;
import static junit.framework.Assert.*;
public class DateUtilsTest {
@Test
public void toDateString() {
Calendar calendar1 = new GregorianCalendar(2011, 01, 28);
assertEquals("20110228", DateUtils.calendarToString(calendar1));
Calendar calendar2 = new GregorianCalendar(2012, 04, 03);
assertEquals("20120503", DateUtils.calendarToString(calendar2));
Calendar calendar3 = new GregorianCalendar(1999, 11, 25);
assertEquals("19991225", DateUtils.calendarToString(calendar3));
}
@Test
public void toCalendar() {
Calendar calendar1 = new GregorianCalendar(2011, 01, 28);
assertEquals(calendar1, DateUtils.stringToCalendar("20110228"));
Calendar calendar2 = new GregorianCalendar(2012, 04, 03);
assertEquals(calendar2, DateUtils.stringToCalendar("20120503"));
Calendar calendar3 = new GregorianCalendar(1999, 11, 25);
assertEquals(calendar3, DateUtils.stringToCalendar("19991225"));
}
}
Pom
pom.xml
<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>uk.co.vsf.solar</groupId>
<artifactId>pvoutput</artifactId>
<version>0.0.1-SNAPSHOT</version>
<description>Takes input from the Sunny Beam and uploads to PVOutput</description>
<properties>
<version.mule>3.2.1</version.mule>
<version.junit>4.10</version.junit>
<version.opencsv>2.3</version.opencsv>
<!-- Spring version has to be same as Mule uses otherwise you'll get funny
exceptions... -->
<version.spring>3.0.3.RELEASE</version.spring>
<version.log4j>1.2.16</version.log4j>
<version.commons-io>2.1</version.commons-io>
</properties>
<dependencies>
<dependency>
<groupId>org.mule</groupId>
<artifactId>mule-core</artifactId>
<version>${version.mule}</version>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-http</artifactId>
<version>${version.mule}</version>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-file</artifactId>
<version>${version.mule}</version>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-client</artifactId>
<version>${version.mule}</version>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-vm</artifactId>
<version>${version.mule}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>${version.opencsv}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${version.spring}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${version.spring}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${version.spring}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${version.spring}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${version.log4j}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${version.commons-io}</version>
</dependency>
</dependencies>
</project>
Please enable the Disqus feature in order to add comments