Package com.m4f.business.domain

Examples of com.m4f.business.domain.MediationService


    // Create a new CronTaskReport
    CronTaskReport report = cronTaskReportService.create();
    report.setObject_id(mediationId);
    report.setDate(new Date());
    report.setType(CronTaskReport.TYPE.INTERNAL_FEED);
    MediationService mediationService = mediatorService.getMediationService(mediationId, null);
    report.setDescription(new StringBuffer("Creating feed for MediationService ").append(mediationService.getName()).toString());
    if(mediationService.getHasFeed()) {
      report.setResult("NOOK because has feed.");
      cronTaskReportService.save(report);
      return;
    }
    try {
      LOGGER.info("Creating feeds for " + mediationService.getName() + " service");   
      Provider provider =  providerService.getProviderByMediationService(mediationId, null);   
      FeedSchools feedSchools = internalFeedService.createFeedSchools(host, provider, mediationService);
      internalFeedService.saveFeedSchools(feedSchools);
      HashMap<Long, ExtendedSchool> schools = new HashMap<Long, ExtendedSchool>();
      Collection<ExtendedCourse> courses =
          extendedCourseService.getCoursesByOwner(mediationService.getId(), null, null);
      for(ExtendedCourse course : courses) {
        ExtendedSchool school = extendedSchoolService.getSchool(course.getSchool(), Locale.getDefault());
        if(school != null) schools.put(school.getId(), school);
      }
      for(ExtendedSchool school : schools.values()) {
View Full Code Here


    report.setDate(new Date());
    report.setType(CronTaskReport.TYPE.INTERNAL_FEED);
    try {
      // Start the process   
      Provider provider =  providerService.getProviderByMediationService(mediationId, null);   
      MediationService mediationService = mediatorService.getMediationService(mediationId, null);
      //Set report description
      report.setDescription(new StringBuffer("Servicio de mediación: ").append(mediationService.getName()).toString());
     
      if(!mediationService.getHasFeed()) { // All must be manual mediator, but it's another check.
        FeedSchools feedSchools = internalFeedService.createFeedSchools(FRONTEND_HOST, provider, mediationService);
        internalFeedService.saveFeedSchools(feedSchools);
        HashMap<Long, ExtendedSchool> schools = new HashMap<Long, ExtendedSchool>();
        Collection<ExtendedCourse> courses =
          extendedCourseService.getCoursesByOwner(mediationService.getId(), null, null);
        for(ExtendedCourse course : courses) {
          ExtendedSchool school = extendedSchoolService.getSchool(course.getSchool(), Locale.getDefault());
          if(school != null) schools.put(school.getId(), school);
        }
        for(ExtendedSchool school : schools.values()) {
View Full Code Here

    report.setDate(new Date());
    report.setType(CronTaskReport.TYPE.INTERNAL_FEED);
    try {
      // Start the process   
      provider =  providerService.getProviderByMediationService(mediationId, null);   
      MediationService mediationService = mediatorService.getMediationService(mediationId, null);
      LOGGER.info("Mediation name: " + mediationService.getName());
      //Set report description
      report.setDescription(new StringBuffer("Internal feed para Srv. mediacion: ").append(mediationService.getName()).toString());
     
      if(!mediationService.getHasFeed() && provider != null) { // All must be manual mediator, but it's another check.
        FeedSchools feedSchools = internalFeedService.createFeedSchools(FRONTEND_HOST, provider, mediationService);
        internalFeedService.saveFeedSchools(feedSchools);
        HashMap<Long, ExtendedSchool> schools = new HashMap<Long, ExtendedSchool>();
        Collection<ExtendedCourse> courses =
          extendedCourseService.getCoursesByOwner(mediationService.getId(), null, null);
        for(ExtendedCourse course : courses) {
          ExtendedSchool school = extendedSchoolService.getSchool(course.getSchool(), Locale.getDefault());
          if(school != null) schools.put(school.getId(), school);
        }
        for(ExtendedSchool school : schools.values()) {
View Full Code Here

    report.setDate(new Date());
    report.setType(CronTaskReport.TYPE.INTERNAL_FEED);
    try {
      // Start the process   
      Provider provider =  providerService.getProviderByMediationService(mediationId, null);   
      MediationService mediationService = mediatorService.getMediationService(mediationId, null);
      //Set report description
      report.setDescription(new StringBuffer("Servicio de mediación: ").append(mediationService.getName()).toString());
     
      if(!mediationService.getHasFeed()) { // All must be manual mediator, but it's another check.
        FeedSchools feedSchools = internalFeedService.createFeedSchools(host, provider, mediationService);
        internalFeedService.saveFeedSchools(feedSchools);
        HashMap<Long, ExtendedSchool> schools = new HashMap<Long, ExtendedSchool>();
        Collection<ExtendedCourse> courses =
          extendedCourseService.getCoursesByOwner(mediationService.getId(), null, null);
        for(ExtendedCourse course : courses) {
          ExtendedSchool school = extendedSchoolService.getSchool(course.getSchool(), Locale.getDefault());
          if(school != null) schools.put(school.getId(), school);
        }
        for(ExtendedSchool school : schools.values()) {
View Full Code Here

    }
    return authorities;
  }
 
  private boolean isAutomaticMediator(InternalUser user) throws Exception {
    MediationService mediationService =
      this.serviceLocator.getMediatorService().getMediationServiceByUser(user.getId(), Locale.getDefault());
    return mediationService.getHasFeed();
  }
View Full Code Here

  }

  @Override
  public Provider getProviderByUserName(String userName, Locale locale)
      throws Exception {
    MediationService mediator =
      this.getMediatorService().getMediationServiceByUser(
          this.getUserService().getUser(userName).getId(),
          locale);
    if(mediator == null) {
      throw new Exception("The user " + userName +
          " doesn't have a mediator assigned.");
    }
    Provider provider = this.getProviderService().findProviderByMediator(mediator, null);
    if(provider == null) {
      throw new Exception("Mediator with id " + mediator.getId() +
          " hasn't provider.");
    }
    return provider;
  }
View Full Code Here

 
  @RequestMapping(value="/detail/{mediationId}", method=RequestMethod.GET)
  public String getDetail(@PathVariable Long mediationId,
      Model model, Locale locale) {
    try {
      MediationService mediationService =
        this.serviceLocator.getMediatorService().getMediationService(mediationId, locale);
      model.addAttribute("mediationService", mediationService);
      model.addAttribute("members", this.serviceLocator.getUserService().findUsersByMediationService(mediationService));
    } catch (Exception e) {
      this.viewHelper.errorManagement(e);
View Full Code Here

  public String getView(@PathVariable Long mediationId,
      Principal currentUser, Model model, Locale locale,
      @RequestHeader(required=false,value="referer") String referer,
      HttpSession session) {
    try {
      MediationService mediationService =
        this.serviceLocator.getMediatorService().getMediationService(mediationId, locale);
      MediationForm form = new MediationForm();
      form.setMediationService(mediationService);
      form.setLongitude(mediationService.getGeoLocation().getLongitude());
      form.setLatitude(mediationService.getGeoLocation().getLatitude());
      //TODO aunque no sea un servicio de mediacion automatico también tiene un proveedor asociado.
      Provider provider = this.serviceLocator.getProviderService().createProvider();
      if(mediationService.getHasFeed()) {
        provider = this.serviceLocator.getProviderService().findProviderByMediator(mediationService, locale);
      }
      form.setProvider(provider);
      form.addMembers(this.serviceLocator.getUserService().findUsersByMediationService(mediationService));
      model.addAttribute("mediation", form);
View Full Code Here

  public String save(@ModelAttribute("mediation") @Valid MediationForm form,
      BindingResult result, Principal currentUser, Locale locale,
      @RequestHeader("Host") String host, HttpSession session) {
   
    try {
      MediationService mediationService = form.getMediationService();
      if(form.getLatitude() != null && form.getLongitude() != null) {
        mediationService.setGeoLocation(new GeoPt(form.getLatitude(), form.getLongitude()));
      }
      mediationService.addUsers(form.getMembers()); // TODO I think that this donĀ“t do anything useful, because there are not member fields in the form.
      this.validator.validate(mediationService, result);
      if(result.hasErrors()) {
        return "mediation.form";
      }
      if(mediationService.getId() != null) { // Edit mode. Get old mediation to set the user list and not lost them.
        MediationService mediationOld = this.serviceLocator.getMediatorService().getMediationService(mediationService.getId(), locale);
        mediationService.setMembers(mediationOld.getMembers());
      }
      mediationService.setDeleted(Boolean.FALSE);
      this.serviceLocator.getMediatorService().save(mediationService, locale);
      Provider provider = form.getProvider();
      provider.setName(mediationService.getName());
View Full Code Here

  public String delete(@PathVariable Long mediationId,
      Principal currentUser, Model model, Locale locale,
      @RequestHeader("referer") String referer,
      @RequestHeader("Host") String host) {
    try {
      MediationService mediationService =
        this.serviceLocator.getMediatorService().getMediationService(mediationId, locale);
      /*
       * TODO comento la eliminacion del provider cuando se elimina el mediation service, ya que esto implica que  hay que eliminar
       * todos los centros, cursos, cursos del catalogo asociados a este provider. Ademas, ya no hay que distinguir si el meditionservice
       * tiene feed, porque siempre se crea un proveedor cuando se anyade un mediation service.
View Full Code Here

TOP

Related Classes of com.m4f.business.domain.MediationService

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.