endTime = xmlFormatter.parse(xmlFormatter.format(slot.getEndDate()));
log.warning("Slot from '" + logFormatter.format(slot.getStartDate()) + "' to '" + logFormatter.format(slot.getEndDate()) + "' did not have any product! The slot will be skipped.");
} else {
for (int index = 0 ; index < slot.getProductIds().size() && endTime.compareTo(slot.getEndDate()) < 0; index++) {
Long prId = slot.getProductIds().get(index);
Product product = DatastoreProxy.getProductById(prId);
if (product != null) {
calendar.setTime(startTime);
calendar.add(Calendar.MINUTE, defaultSlotDurationInMinutes);
endTime = calendar.getTime();
List<Resource> resources = DatastoreProxy.getResourcesByProductId(product.getId());
List<String> resourcesURLs = new ArrayList<String>();
if (resources != null) {
for (Resource r : resources) {
if (r != null) {
resourcesURLs.add(r.getImageURL());
}
}
}
Long pbId = product.getPublisherId();
if (pbId != null) {
Publisher publisher = DatastoreProxy.getPublisherById(pbId);
if (publisher != null) {
Long cpId = publisher.getCompanyId();
if (cpId != null) {
Company company = DatastoreProxy.getCompanyById(cpId);
if (company != null) {
Ad ad = new Ad(startTime, endTime, company.getLastname(), product.getName(), product.getSlogan(), product.getText(), product.getLink(), resourcesURLs, true, new Double(1));
adDAO.put(ad);
schedule.getAdIds().add(ad.getId());
startTime = calendar.getTime();
sb.append("\n<AdDTO>");
sb.append("\n<Id>" + ad.getUUID() + "</Id>");
sb.append("\n<Company>");
sb.append("\n<Id>" + company.getUUID() + "</Id>");
sb.append("\n<Name>" + ad.getCompany() + "</Name>");
sb.append("\n</Company>");
sb.append("\n<Publisher>");
sb.append("\n<Id>" + publisher.getUUID() + "</Id>");
sb.append("\n<Name>" + publisher.getFirstname() + " " + publisher.getLastname() + "</Name>");
sb.append("\n</Publisher>");
sb.append("\n<Product>");
sb.append("\n<Id>" + product.getUUID() + "</Id>");
sb.append("\n<Name>" + ad.getProduct() + "</Name>");
sb.append("\n<Text>" + ad.getText() + "</Text>");
sb.append("\n<Link>" + ad.getLink() + "</Link>");
sb.append("\n<Slogan>" + ad.getSlogan() + "</Slogan>");
sb.append("\n</Product>");