Package com.casamind.adware.server.domain

Examples of com.casamind.adware.server.domain.Slot


      SimpleDateFormat icalFormatter = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
      SimpleDateFormat logFormatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm Z");
      Company company = DatastoreProxy.getCompanyByLogin(attendee);
      if (company != null) {
        log.info("Found company: " + company.getLastname());
        Slot slot = new Slot();
        slot.setOwnerId(company.getId());
        log.info("DTSTART :" + startDate);
        Date parsedStartDate = icalFormatter.parse(startDate);
        log.info("Parsed start date :" + logFormatter.format(parsedStartDate));
        log.info("DTEND :" + endDate);
        Date parsedEndDate = icalFormatter.parse(endDate);
        log.info("Parsed end date :" + logFormatter.format(parsedEndDate));
        slot.setStartDate(parsedStartDate);
        slot.setEndDate(parsedEndDate);
        slot.setStatus(SlotStatus.Ordered);
        long slotInterval = parsedEndDate.getTime() - parsedStartDate.getTime();
        log.info("Interval in miliseconds: " + slotInterval);
        long slotDurationInMilisecondes = (long) duration * 60 * 1000;
        log.info("Default slot duration in miliseconds: " + slotDurationInMilisecondes);
        long nbSlots = slotInterval / slotDurationInMilisecondes;
        log.info("Number of slots (Long): " + nbSlots);
        slot.setNbSlots((int) nbSlots);
        slot.setPrice(price);
        Slot entity = DatastoreProxy.createSlot(slot);
        log.info("Created new slot for company:" + company.getLastname());
        log.info(entity.toString());
      } else {
        log.warning("Did not find a company with attendee: " + attendee);
        log.info("Trying to a find a publisher with attendee: " + attendee);
        Publisher publisher = DatastoreProxy.getPublisherByLogin(attendee);
        if (publisher != null) {
          log.info("Found publisher with attendee: " + publisher.getFirstname() + " " + publisher.getLastname());
          Slot slot = new Slot();
          slot.setOwnerId(publisher.getId());
          log.info("DTSTART :" + startDate);
          Date parsedStartDate = icalFormatter.parse(startDate);
          log.info("Parsed start date :" + logFormatter.format(parsedStartDate));
          log.info("DTEND :" + endDate);
          Date parsedEndDate = icalFormatter.parse(endDate);
          log.info("Parsed end date :" + logFormatter.format(parsedEndDate));
          slot.setStartDate(parsedStartDate);
          slot.setEndDate(parsedEndDate);
          slot.setStatus(SlotStatus.Ordered);
          long slotInterval = parsedEndDate.getTime() - parsedStartDate.getTime();
          log.info("Interval in miliseconds: " + slotInterval);
          long slotDurationInMilisecondes = (long) duration * 60 * 1000;
          log.info("Default slot duration in miliseconds: " + slotDurationInMilisecondes);
          long nbSlots = slotInterval / slotDurationInMilisecondes;
          log.info("Number of slots (Long): " + nbSlots);
          slot.setNbSlots((int) nbSlots);
          slot.setPrice(price);
          Slot entity = DatastoreProxy.createSlot(slot);
          log.info("Created new slot for publisher:" + publisher.getFirstname() + " " + publisher.getLastname());
          log.info(entity.toString());
        } else {
          log.warning("Could not find publisher: " + attendee);
        }
        response.getWriter().println(logFormatter.format(new Date()) + " : Finshed! See the server logs for debug.");
      }
View Full Code Here


          List<Long> ids = new ArrayList<Long>();
          for (String idStr : entityIds.split(",")){
            ids.add(Long.parseLong(idStr));
          }
          for (Long id : ids){           
            Slot entity = DatastoreProxy.getSlotById(id);
            if (entity != null) {
              serviceStr += "Cr&eacute;neau publicitaire du " + formatter.format(entity.getStartDate()) + " au " + formatter.format(entity.getEndDate()) + "\n";
              unitPriceStr += Integer.toString(entity.getPrice()) + "\n";
              totalPrice += entity.getPrice();
              log.info("Found slot with id=" + id + ". Will add service line.");
            } else {
              log.warning("No slot found with id=" + id);
            }
          }
View Full Code Here

  }

  @Override
  public List<ProductSummaryDTO> getProductSummariesBySlotId(Long id) {
    List<ProductSummaryDTO> list = new ArrayList<ProductSummaryDTO>();
    Slot slot = DatastoreProxy.getSlotById(id);
    if (slot != null) {
      for (Long pId : slot.getProductIds()) {
        list.add(Product.toSummaryDTO(DatastoreProxy.getProductById(pId)));
      }
    }
    return list;
  }
View Full Code Here

        }
        for (int n = 0; n < 5; n++) {
          start = calendar.getTime();
          calendar.add(Calendar.HOUR, 12);
          end = calendar.getTime();
          Slot slot = new Slot(1, 10, start, end, publisher.getId());
          for (int p = 0; p < slot.getNbSlots(); p++) {
            slot.getProductIds().add(products.get(rand.nextInt(products.size())));
          }
          slot.setStatus(rand.nextInt(1));
          slotDAO.put(slot);
          slot.setOwnerId(publisher.getId());
          slots.add(slot.getId());
        }
        publisherDAO.put(publisher);
      }
      companyDAO.put(company);
    }
View Full Code Here

    resp.getWriter().println("Finished at: " + new Date());
  }

  private void deleteEventEntry(Long entityId) {
    log.info("Deleting calendar event entries for withdrawn slot with entityId: " + entityId);
    Slot slot = DatastoreProxy.getSlotById(entityId);
    if (slot != null) {
      log.info("Purging Google Calendar from '" + logFormatter.format(slot.getStartDate()) + "' to '" + logFormatter.format(slot.getEndDate()) + "'");
      try {
        CalendarEventFeed rangeFeed = proxy.getEventsRangeFeed(slot.getStartDate(), slot.getEndDate());
        List<CalendarEventEntry> entriesToDelete = new ArrayList<CalendarEventEntry>();
        entriesToDelete.addAll(rangeFeed.getEntries());
        int size = entriesToDelete.size();
        while (size > 0) {
          log.info("Adding " + size + " event entries to mass deletion batch...");
          proxy.batchEntries(entriesToDelete, BatchOperationType.DELETE);
          rangeFeed = proxy.getEventsRangeFeed(slot.getStartDate(), slot.getEndDate());
          entriesToDelete.clear();
          entriesToDelete.addAll(rangeFeed.getEntries());
          size = entriesToDelete.size();
        }
        log.info("Finshed mass deletion batch.");
View Full Code Here

      new ObjectifyGenericDAO<Product>(Product.class).put(entity);
    return entity;
  }

  public static Slot updateSlot(SlotDTO dto) {
    Slot entity = Slot.toEntity(getSlotById(dto.getId()), dto);
    if (entity != null)
      new ObjectifyGenericDAO<Slot>(Slot.class).put(entity);
    return entity;
  }
View Full Code Here

    return datastoreItem;
  }

  public static Slot createSlot(Slot entity) {
    ObjectifyGenericDAO<Slot> dao = new ObjectifyGenericDAO<Slot>(Slot.class);
    Slot datastoreItem = null;
    if (entity != null) {
      Key<Slot> key = dao.put(entity);
      try {
        datastoreItem = dao.get(key);
      } catch (EntityNotFoundException e) {
View Full Code Here

                SimpleDateFormat icalFormatter = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
                SimpleDateFormat logFormatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm Z");
                Company company = DatastoreProxy.getCompanyByLogin(login);
                if (company != null) {
                  log.info("Found company: " + company.getLastname());
                  Slot slot = new Slot();
                  slot.setOwnerId(company.getId());
                  log.info("DTSTART :" + startDate.getValue());
                  Date parsedStartDate = icalFormatter.parse(startDate.getValue());
                  log.info("Parsed start date :" + logFormatter.format(parsedStartDate));
                  log.info("DTEND :" + endDate.getValue());
                  Date parsedEndDate = icalFormatter.parse(endDate.getValue());
                  log.info("Parsed end date :" + logFormatter.format(parsedEndDate));
                  slot.setStartDate(parsedStartDate);
                  slot.setEndDate(parsedEndDate);
                  slot.setStatus(SlotStatus.Ordered);
                  long slotInterval = parsedEndDate.getTime() - parsedStartDate.getTime();
                  log.info("Interval in miliseconds: " + slotInterval);
                  long slotDurationInMilisecondes = (long) duration * 60 * 1000;
                  log.info("Default slot duration in miliseconds: " + slotDurationInMilisecondes);
                  long nbSlots = slotInterval / slotDurationInMilisecondes;
                  log.info("Number of slots (Long): " + nbSlots);
                  slot.setNbSlots((int) nbSlots);
                  slot.setPrice(price);
                  Slot entity = DatastoreProxy.createSlot(slot);
                  log.info("Created new slot for company:" + company.getLastname());
                  log.info(entity.toString());
                } else {
                  log.info("Did not find a company with login: " + login);
                  log.info("Trying to a find a publisher with login: " + login);
                  Publisher publisher = DatastoreProxy.getPublisherByLogin(login);
                  if (publisher != null) {
                    log.info("Found publisher with login: " + publisher.getFirstname() + " " + publisher.getLastname());
                    Slot slot = new Slot();
                    slot.setOwnerId(publisher.getId());
                    log.info("DTSTART :" + startDate.getValue());
                    Date parsedStartDate = icalFormatter.parse(startDate.getValue());
                    log.info("Parsed start date :" + logFormatter.format(parsedStartDate));
                    log.info("DTEND :" + endDate.getValue());
                    Date parsedEndDate = icalFormatter.parse(endDate.getValue());
                    log.info("Parsed end date :" + logFormatter.format(parsedEndDate));
                    slot.setStartDate(parsedStartDate);
                    slot.setEndDate(parsedEndDate);
                    slot.setStatus(SlotStatus.Ordered);
                    long slotInterval = parsedEndDate.getTime() - parsedStartDate.getTime();
                    log.info("Interval in miliseconds: " + slotInterval);
                    long slotDurationInMilisecondes = (long) duration * 60 * 1000;
                    log.info("Default slot duration in miliseconds: " + slotDurationInMilisecondes);
                    long nbSlots = slotInterval / slotDurationInMilisecondes;
                    log.info("Number of slots (Long): " + nbSlots);
                    slot.setNbSlots((int) nbSlots);
                    slot.setPrice(price);
                    Slot entity = DatastoreProxy.createSlot(slot);
                    log.info("Created new slot for publisher:" + publisher.getFirstname() + " " + publisher.getLastname());
                    log.info(entity.toString());
                  } else {
                    log.warning("Could not find publisher: " + login);
                  }
                }
              } else {
View Full Code Here

TOP

Related Classes of com.casamind.adware.server.domain.Slot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.