// Path: src/main/java/net/atos/entng/rbs/model/ExportBooking.java
// public class ExportBooking {
// 
// 	public static final String BOOKING_ID = "id";
// 	public static final String BOOKING_OWNER_ID = "owner"; // "ff2238cd-5110-431b-a6fa-bbc4fa51411d",
// 	public static final String BOOKING_START_DATE = "start_date"; //:"2017-06-26T09:00:00.000",
// 	public static final String BOOKING_END_DATE = "end_date"; // "2017-06-26T10:00:00.000",
// 	public static final String BOOKING_REASON = "booking_reason"; // free text
// 	public static final String BOOKING_OWNER_NAME = "owner_name"; // "Catherine BAILLY",
// 	public static final String BOOKING_MODERATOR_ID = "moderator_id"; // null,
// 	public static final String BOOKING_MODERATOR_NAME = "moderator_name"; // null
// 	public static final String SCHOOL_ID = "school_id"; // "a4d06ecc-e3cd-428b-b239-0a82a208f715",
// 	public static final String RESOURCE_TYPE_ID = "type_id"; // 1,
// 	public static final String RESOURCE_TYPE_COLOR = "type_color"; // "#02ed09",
// 	public static final String RESOURCE_ID = "resource_id"; //2,
// 	public static final String RESOURCE_NAME = "resource_name"; // "PC Windaube",
// 	public static final String RESOURCE_COLOR = "resource_color"; // "#02ed19",
// 	public static final String SCHOOL_NAME = "school_name"; // added by post treatment (stored in MongoDB, not PostgreSQL)
// 	public static final String QUANTITY = "quantity"; // 5
// 
// 	private JsonObject data;
// 
// 	public ExportBooking(JsonObject data) {
// 		this.data = data;
// 	}
// 
// 	public JsonObject toJson() {
// 		return data;
// 	}
// 
// 	public String getSchoolId() {
// 		return data.getString(SCHOOL_ID);
// 	}
// 
// 	public void setSchoolName(String schoolName) {
// 		data.put(SCHOOL_NAME, schoolName);
// 	}
// 
// 	public String getColor() {
// 		String resourceColor = data.getString(RESOURCE_COLOR);
// 		if (resourceColor == null || resourceColor.isEmpty()) {
// 			return data.getString(RESOURCE_TYPE_COLOR);
// 		}
// 		return resourceColor;
// 	}
// 
// 	public String getStart() {
// 		return data.getString(BOOKING_START_DATE);
// 	}
// 
// 	public String getEnd() {
// 		return data.getString(BOOKING_END_DATE);
// 	}
// 
// 	public Number getQuantity() {
// 		return data.getInteger(QUANTITY);
// 	}
// 
// 
// 	@Override
// 	public String toString() {
// 		final StringBuffer sb = new StringBuffer("ExportBooking{");
// 		sb.append("resource=").append(getResource());
// 		sb.append(", owner=").append(getOwner());
// 		sb.append(", start=").append(getStart());
// 		sb.append(", end=").append(getEnd());
// 		sb.append(", quantity=").append(getQuantity());
// 		sb.append('}');
// 		return sb.toString();
// 	}
// 
// 	public String getOwner() {
// 		return data.getString(BOOKING_OWNER_NAME);
// 	}
// 
// 	public String getResource() {
// 		return data.getString(RESOURCE_NAME);
// 	}
// 
// 	public String getSchoolName() {
// 		return data.getString(SCHOOL_NAME);
// 	}
// 
// 	public String getBookingReason() {
// 		return data.getString(BOOKING_REASON);
// 	}
// 
// 	public Number getId() {
// 		return data.getInteger(BOOKING_ID);
// 	}
// 
// 	public String getOwnerId() {
// 		return data.getString(BOOKING_OWNER_ID);
// 	}
// }


import fr.wseduc.webutils.I18n;
import net.atos.entng.rbs.model.ExportBooking;
import org.joda.time.DateTime;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Locale;
            return booking.getStartDate().compareTo(t1.getStartDate());
        }
    }

	private final int CALENDAR_WIDTH = 680;
    private final int NUMBER_OF_BOOKINGS_BY_PAGE = 25;

	public JsonListFormatter(JsonObject jsonFileObject, String host, Locale locale, String userTimeZone) {
        super(jsonFileObject, host, locale, userTimeZone);
	}

	public JsonObject format(){

        JsonObject convertedObject = new JsonObject();
        convertedObject.put(EDITION_DATE_FIELD_NAME, DateTime.now().toString("dd/MM/YYYY"));

        // General calendar settings
        convertedObject.put(CALENDAR_WIDTH_FIELD_NAME, CALENDAR_WIDTH);
        convertedObject.put(CALENDAR_WIDTH_UNIT_FIELD_NAME, DEFAULT_SIZE_UNIT);
        convertedObject.put(I18N_TITLE, I18n.getInstance().translate(MAP_I18N.get(I18N_TITLE), this.host, this.locale));
        JsonArray exportBookingList = exportObject.getJsonArray(BOOKING_LIST_FIELD_NAME);

        // Building resource list
        ArrayList<Long> performedResourceId = new ArrayList<Long>();
        JsonArray resourceList = new fr.wseduc.webutils.collections.JsonArray();

        final String i18nTo = I18n.getInstance().translate(MAP_I18N.get(I18N_TO), this.host, this.locale);

        for (int i = 0; i < exportBookingList.size(); i++) {
            JsonObject bookingIterator = exportBookingList.getJsonObject(i);
// Path: src/main/java/net/atos/entng/rbs/model/ExportBooking.java
// public class ExportBooking {
// 
// 	public static final String BOOKING_ID = "id";
// 	public static final String BOOKING_OWNER_ID = "owner"; // "ff2238cd-5110-431b-a6fa-bbc4fa51411d",
// 	public static final String BOOKING_START_DATE = "start_date"; //:"2017-06-26T09:00:00.000",
// 	public static final String BOOKING_END_DATE = "end_date"; // "2017-06-26T10:00:00.000",
// 	public static final String BOOKING_REASON = "booking_reason"; // free text
// 	public static final String BOOKING_OWNER_NAME = "owner_name"; // "Catherine BAILLY",
// 	public static final String BOOKING_MODERATOR_ID = "moderator_id"; // null,
// 	public static final String BOOKING_MODERATOR_NAME = "moderator_name"; // null
// 	public static final String SCHOOL_ID = "school_id"; // "a4d06ecc-e3cd-428b-b239-0a82a208f715",
// 	public static final String RESOURCE_TYPE_ID = "type_id"; // 1,
// 	public static final String RESOURCE_TYPE_COLOR = "type_color"; // "#02ed09",
// 	public static final String RESOURCE_ID = "resource_id"; //2,
// 	public static final String RESOURCE_NAME = "resource_name"; // "PC Windaube",
// 	public static final String RESOURCE_COLOR = "resource_color"; // "#02ed19",
// 	public static final String SCHOOL_NAME = "school_name"; // added by post treatment (stored in MongoDB, not PostgreSQL)
// 	public static final String QUANTITY = "quantity"; // 5
// 
// 	private JsonObject data;
// 
// 	public ExportBooking(JsonObject data) {
// 		this.data = data;
// 	}
// 
// 	public JsonObject toJson() {
// 		return data;
// 	}
// 
// 	public String getSchoolId() {
// 		return data.getString(SCHOOL_ID);
// 	}
// 
// 	public void setSchoolName(String schoolName) {
// 		data.put(SCHOOL_NAME, schoolName);
// 	}
// 
// 	public String getColor() {
// 		String resourceColor = data.getString(RESOURCE_COLOR);
// 		if (resourceColor == null || resourceColor.isEmpty()) {
// 			return data.getString(RESOURCE_TYPE_COLOR);
// 		}
// 		return resourceColor;
// 	}
// 
// 	public String getStart() {
// 		return data.getString(BOOKING_START_DATE);
// 	}
// 
// 	public String getEnd() {
// 		return data.getString(BOOKING_END_DATE);
// 	}
// 
// 	public Number getQuantity() {
// 		return data.getInteger(QUANTITY);
// 	}
// 
// 
// 	@Override
// 	public String toString() {
// 		final StringBuffer sb = new StringBuffer("ExportBooking{");
// 		sb.append("resource=").append(getResource());
// 		sb.append(", owner=").append(getOwner());
// 		sb.append(", start=").append(getStart());
// 		sb.append(", end=").append(getEnd());
// 		sb.append(", quantity=").append(getQuantity());
// 		sb.append('}');
// 		return sb.toString();
// 	}
// 
// 	public String getOwner() {
// 		return data.getString(BOOKING_OWNER_NAME);
// 	}
// 
// 	public String getResource() {
// 		return data.getString(RESOURCE_NAME);
// 	}
// 
// 	public String getSchoolName() {
// 		return data.getString(SCHOOL_NAME);
// 	}
// 
// 	public String getBookingReason() {
// 		return data.getString(BOOKING_REASON);
// 	}
// 
// 	public Number getId() {
// 		return data.getInteger(BOOKING_ID);
// 	}
// 
// 	public String getOwnerId() {
// 		return data.getString(BOOKING_OWNER_ID);
// 	}
// }


// Path: src/main/java/net/atos/entng/rbs/service/pdf/JsonListFormatter.java
import fr.wseduc.webutils.I18n;
import net.atos.entng.rbs.model.ExportBooking;
import org.joda.time.DateTime;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Locale;

            return booking.getStartDate().compareTo(t1.getStartDate());
        }
    }

	private final int CALENDAR_WIDTH = 680;
    private final int NUMBER_OF_BOOKINGS_BY_PAGE = 25;

	public JsonListFormatter(JsonObject jsonFileObject, String host, Locale locale, String userTimeZone) {
        super(jsonFileObject, host, locale, userTimeZone);
	}

	public JsonObject format(){

        JsonObject convertedObject = new JsonObject();
        convertedObject.put(EDITION_DATE_FIELD_NAME, DateTime.now().toString("dd/MM/YYYY"));

        // General calendar settings
        convertedObject.put(CALENDAR_WIDTH_FIELD_NAME, CALENDAR_WIDTH);
        convertedObject.put(CALENDAR_WIDTH_UNIT_FIELD_NAME, DEFAULT_SIZE_UNIT);
        convertedObject.put(I18N_TITLE, I18n.getInstance().translate(MAP_I18N.get(I18N_TITLE), this.host, this.locale));
        JsonArray exportBookingList = exportObject.getJsonArray(BOOKING_LIST_FIELD_NAME);

        // Building resource list
        ArrayList<Long> performedResourceId = new ArrayList<Long>();
        JsonArray resourceList = new fr.wseduc.webutils.collections.JsonArray();

        final String i18nTo = I18n.getInstance().translate(MAP_I18N.get(I18N_TO), this.host, this.locale);

        for (int i = 0; i < exportBookingList.size(); i++) {
            JsonObject bookingIterator = exportBookingList.getJsonObject(i);
            Long currentResourceId = bookingIterator.getLong(ExportBooking.RESOURCE_ID);