Package com.casamind.adware.server.domain

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


    try {
      DocumentListEntry entry = null;
      if (task.equals(GoogleDocumentsTaskTypes.CREATE)) {
        log.info("Entering GDataTaskTypes.CREATE task!");
        if (companyId != null) {
          Company company = DatastoreProxy.getCompanyById(companyId);
          if (company != null) {
           
          } else {
            log.warning("No Compny found with id=" + companyId + ". Will exit servlet!");
          }
          String serviceStr = "", unitPriceStr = "";
          Double totalPrice = 0.0, totalDue = 0.0;
          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);
            }
          }
          String body = Strings.convertStreamToString(new FileInputStream("WEB-INF/files/templates/bill_slot_invoiced.html"));
          body = Strings.formatSpecialCharacters(body
              .replace("$billDate", formatter.format(new Date()))
              .replace("$billNumber", Integer.toString(billNumber))
              .replace("$project", "Avicena")
              .replace("$company", company.getDisplayName())
              .replace("$billingAddress", company.getBillingAddress())
              .replace("$phone", company.getPhone())
              .replace("$email", company.getEmail())
              .replace("$service", serviceStr)
              .replace("$unitPrice", unitPriceStr)
              .replace("$discount", Integer.toString(0))
              .replace("$totalPrice", Integer.toString(dto.getPrice()))
              .replace("$totalDue", Double.toString(dto.getPrice() + (dto.getPrice() * 0.196))));
 
View Full Code Here


    admin.setReceiveNewsLetter(true);
    admin.setReceiveNotifications(true);
    admin.setAccessLevel(AccessLevels.Administrator);
    userAccountDAO.put(admin);
    for (int i = 0; i < 2; i++) {
      Company company = new Company();
      company.setAccessLevel(AccessLevels.Company);
      company.setLogin("company" + i + "@example.com");
      company.setService(AuthTypes.GOOGLE);
      company.setUniqueId(company.getLogin() + "-" + company.getService());
      company.setLastname("Company " + i);
      company.setFirstname("");
      company.setStreet("Street adress for company " + 1);
      company.setCity("City " + i);
      company.setPhone("+212522" + (100000 + rand.nextInt(999999)));
      company.setFax("+212522" + (100000 + rand.nextInt(999999)));
      company.setMobile("+2126" + (10000000 + rand.nextInt(99999999)));
      company.setEmail("contact@company" + i + ".com");
      company.setWebsite("www.company" + i + ".com");
      company.setReceiveNewsLetter(false);
      company.setReceiveNotifications(false);
      company.setLastLoginOn(calendar.getTime());
      companyDAO.put(company);
      for (int j = 0; j < 2; j++) {
        Publisher publisher = new Publisher();
        publisher.setAccessLevel(AccessLevels.Publisher);
        publisher.setLogin("publisher" + j + "@company" + i + ".com");
        publisher.setService(AuthTypes.GOOGLE);
        publisher.setUniqueId(publisher.getLogin() + "-" + publisher.getService());
        publisher.setFirstname("Publisher");
        publisher.setLastname(j + "-" + i);
        publisher.setPhone("+212522" + (100000 + rand.nextInt(999999)));
        publisher.setEmail("publisher" + j + "@company" + i + ".com");
        ArrayList<Long> products = new ArrayList<Long>();
        ArrayList<Long> slots = new ArrayList<Long>();
        publisherDAO.put(publisher);
        publisher.setCompanyId(company.getId());
        for (int k = 0; k < 5; k++) {
          Product product = new Product();
          product.setName("Product" + k + "-" + j + "-" + i);
          product.setSlogan("Slogan");
          product.setText("Text");
View Full Code Here

        log.info("Rol added successfully!");
      }
      try {
        Publisher publisher = (Publisher) owner;
        log.info("Owner is a publisher. Adding company ACL entries...");
        Company company = DatastoreProxy.getCompanyById(publisher.getCompanyId());
        String cLogin = company.getLogin();
        if (cLogin != null && !"".equals(cLogin)) {
          log.info("Adding ACL.\n\tuser: " + cLogin + ".\n\trole: " + role);
          proxy.addAclRole(entry, cLogin, role);
          log.info("Rol added successfully!");
        }
        String cEmail = company.getEmail();
        if (cEmail != null && !"".equals(cEmail)) {
          log.info("Adding ACL.\n\tuser: " + cEmail + ".\n\trole: " + role);
          proxy.addAclRole(entry, cEmail, role);
          log.info("Rol added successfully!");
        }
View Full Code Here

    return Company.toDTO(DatastoreProxy.getCompanyById(id));
  }

  @Override
  public CompanyDTO createCompany(CompanyDTO dto) {
    Company entity = Company.toEntity(null, dto);
    entity.setGdataLogin(gdataWebLogin);
    entity.setGdataPassword(gdataWebPassword);
    CompanyDTO returnedDTO = Company.toDTO((DatastoreProxy.createCompany(entity)));
    QueueFactory.getQueue("gdata").add(TaskOptions.Builder.withUrl("/tasks/gdata/reports").param("task", GoogleDocumentsTaskTypes.CREATE).param("title", returnedDTO.getUUID()).param("folder", ReportTypes.COMPANY));
    return returnedDTO;
  }
View Full Code Here

        for (Product entity : DatastoreProxy.getProductsByPublisherId(publisher.getId())) {
          list.add(Product.toSummaryDTO(entity));
        }
      }
    } else if (accessLevel == AccessLevels.Company) {
      Company company = DatastoreProxy.getCompanyByLogin(login);
      if (company != null) {
        for (Publisher entity : DatastoreProxy.getPublishersByCompanyId(company.getId())) {
          list.add(Publisher.toSummaryDTO(entity));
        }
      }
    } else if (accessLevel == AccessLevels.Administrator) {
      for (Company entity : DatastoreProxy.getCompanies()) {
View Full Code Here

      // get products by publisher
      for (Product entity : DatastoreProxy.getProductsByPublisherId(id)) {
        list.add(Product.toSummaryDTO(entity));
      }
    } else {
      Company company = DatastoreProxy.getCompanyById(id);
      if (company != null) {
        // get products by company
        for (Publisher pub : DatastoreProxy.getPublishersByCompanyId(id)) {
          for (Product product : DatastoreProxy.getProductsByPublisherId(pub.getId())) {
            list.add(Product.toSummaryDTO(product));
View Full Code Here

 
  public static String invoice(GDataDocumentsProxy proxy, List<SlotDTO> objects, Date dueDate) {
    String link = "www.casamind.com";
    String entityIds = "";
    try {
      Company company = DatastoreProxy.getCompanyById(objects.get(0).getCompany().getId());
      if (company != null){
        int billNumber = generateBillNumber();
        String title = "FACTURE_" + company.getId().toString() + "_" + Integer.toString(billNumber) + "_" + company.getDisplayName();
        for (SlotDTO dto : objects) {
          entityIds += dto.getId() + ",";
        }
        if (entityIds.endsWith(",")) {
          entityIds = entityIds.substring(0, entityIds.length() - 1);
View Full Code Here

        cc.put(email, name);
      }
      try {
        Publisher publisher = (Publisher) owner;
        log.info("Owner is a publisher. Adding company to CC recipients...");
        Company company = DatastoreProxy.getCompanyById(publisher.getCompanyId());
        String companyName = company.getDisplayName();
        String companyLogin = company.getLogin();
        if (Strings.isValidEmailAddress(companyLogin)) {
          cc.put(companyLogin, companyName);
          String companyEmail = company.getEmail();
          if (Strings.isValidEmailAddress(companyEmail) && !email.equals(companyLogin)) {
            cc.put(companyEmail, companyName);
          }
        } else {
          log.warning("Invalid company login!\n\tcompanyId: " + company.getId() + "\n\tlogin: " + company.getLogin());
        }
      } catch (ClassCastException e) {
        log.info("Owner is a company.");
      }
      bcc.put("mouncif.faqir@casamind.com", "Mouncif FAQIR");
View Full Code Here

  }
 
  private String getBillingAddress (UserAccount owner){
    String billingAddress = "";
    try {
      Company company = (Company) owner;
      billingAddress = company.getBillingAddress();
    } catch (ClassCastException e) {
      Publisher publisher = (Publisher) owner;
      Company company = DatastoreProxy.getCompanyById(publisher.getCompanyId());
      if (company != null) {
        billingAddress = company.getBillingAddress();
      } else {
        log.warning("Could not find company with id: " + publisher.getCompanyId() + "\nBilling address is void.");
      }
    }
    return billingAddress;
View Full Code Here

  public static Slot getSlotById(Long id) {
    return new ObjectifyGenericDAO<Slot>(Slot.class).getByProperty("id", id);
  }

  public static Company updateCompany(CompanyDTO dto) {
    Company entity = Company.toEntity(getCompanyById(dto.getId()), dto);
    if (entity != null)
      new ObjectifyGenericDAO<Company>(Company.class).put(entity);
    return entity;
  }
View Full Code Here

TOP

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

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.