private void writeServices(JsonGenerator jsonGenerator) {
try {
jsonGenerator.writeArrayFieldStart(JsonConstants.SERVICES);
for(Job job : vrp.getJobs().values()){
if(!(job instanceof Service)) continue;
Service service = (Service)job;
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField(JsonConstants.Job.ID, service.getId());
jsonGenerator.writeStringField(JsonConstants.Job.TYPE,service.getType());
jsonGenerator.writeStringField(JsonConstants.Job.NAME,service.getName());
jsonGenerator.writeObjectFieldStart(JsonConstants.Job.ADDRESS);
jsonGenerator.writeStringField(JsonConstants.Address.ID, service.getLocationId());
jsonGenerator.writeNumberField(JsonConstants.Address.LON, service.getCoord().getX());
jsonGenerator.writeNumberField(JsonConstants.Address.LAT,service.getCoord().getY());
jsonGenerator.writeEndObject();
jsonGenerator.writeNumberField(JsonConstants.Job.SERVICE_DURATION, service.getServiceDuration());
jsonGenerator.writeObjectFieldStart(JsonConstants.Job.TIME_WINDOW);
jsonGenerator.writeNumberField(JsonConstants.TimeWindow.START,service.getTimeWindow().getStart());
jsonGenerator.writeNumberField(JsonConstants.TimeWindow.END,service.getTimeWindow().getEnd());
jsonGenerator.writeEndObject();
jsonGenerator.writeArrayFieldStart(JsonConstants.Job.SIZE);
for(int i=0;i<service.getSize().getNuOfDimensions();i++){
jsonGenerator.writeNumber(service.getSize().get(i));
}
jsonGenerator.writeEndArray();
jsonGenerator.writeArrayFieldStart(JsonConstants.Job.SKILLS);
for(String skill : service.getRequiredSkills().values()){
jsonGenerator.writeString(skill);
}
jsonGenerator.writeEndArray();
jsonGenerator.writeEndObject();
}