private int resourceSchedules(
     Asset defaultAsset,
     ArrayList<ResourceSchedule> getResourceSchedules,
     HashMap<String, Asset> assets,
     List<SlideshowInterval> timelineIntervalList,
     int slide,
     long timeInMillis) {
   int sizeSchedules = getResourceSchedules.size();
   for (int i = 0; i < sizeSchedules - 1; ++i) {
     ResourceSchedule GetResourceSchedules = getResourceSchedules.get(i);
     if (timeInMillis > GetResourceSchedules.getStartTime()) {
       ++slide;
     }
     timelineIntervalList.add(
         resourceScheduleToDate(
             GetResourceSchedules, assets.get(GetResourceSchedules.getResourceId())));
     if (defaultAsset != null) {
       long getEndTime = GetResourceSchedules.getEndTime();
       if (getEndTime != getResourceSchedules.get(i + 1).getStartTime()) {
         if (getEndTime < timeInMillis) {
           ++slide;
         }
         timelineIntervalList.add(
             defaultDate(
                 getEndTime, getResourceSchedules.get(i + 1).getStartTime(), defaultAsset));
       }
     }
   }
   return slide;
 }
Exemplo n.º 2
0
 private SlideshowInterval resourceScheduleToDate(ResourceSchedule schedule, Asset asset) {
   SlideshowInterval out = new SlideshowInterval();
   out.setStartDate(timestampToTimelineDate(schedule.getStartTime()));
   out.setEndDate(timestampToTimelineDate(schedule.getEndTime()));
   out.setHeadline(schedule.getName());
   out.setAsset(asset);
   return out;
 }
 private HashMap<String, Asset> setRecourceIds(ArrayList<ResourceSchedule> getResourceSchedules) {
   Set<String> resourceIds = new HashSet<>();
   for (ResourceSchedule item : getResourceSchedules) {
     resourceIds.add(item.getResourceId());
   }
   Iterable<Resource> resourcesSet = resourceHolderResourceRepository.findAll(resourceIds);
   HashMap<String, Asset> assets = resourcesToAssetMap(resourcesSet);
   return assets;
 }
  public SlideshowData generateTimelineData(String resourceHolderId) throws Exception {
    ResourceHolder resourceHolder = resourceHolderRepository.findOne(resourceHolderId);
    exceptionNullResourceHolder(resourceHolder);
    Resource resource = getIdResource();
    Asset defaultAsset = defaultAsset(resource);
    Slideshow timeline = new Slideshow();
    setTimeline(defaultAsset, timeline);
    ResourceSchedule schedule = ScheduleServiceImplSimple.findOne(resource.getScheduleId());
    nullExceptionSchedule(schedule);

    ArrayList<ResourceSchedule> getResourceSchedules = schedule.getResourceSchedules();
    int sizeOfResourceSchedules = getResourceSchedules.size();
    if (sizeOfResourceSchedules == 0) {
      throw new Exception("", null);
    }

    HashMap<String, Asset> assets = setRecourceIds(getResourceSchedules);
    List<SlideshowInterval> timelineIntervalList = new ArrayList<>();
    int slide = 0;
    Calendar calendar = GregorianCalendar.getInstance();
    long timeInMillis = calendar.getTimeInMillis();
    slide =
        resourceSchedules(
            defaultAsset, getResourceSchedules, assets, timelineIntervalList, slide, timeInMillis);
    if (sizeOfResourceSchedules > 0) {
      ResourceSchedule sizeOfResourceSchedule =
          getResourceSchedules.get(sizeOfResourceSchedules - 1);
      if (timeInMillis > sizeOfResourceSchedule.getEndTime()) {
        slide = 0;
      }
      timelineIntervalList.add(
          resourceScheduleToDate(
              sizeOfResourceSchedule, assets.get(sizeOfResourceSchedule.getResourceId())));
    }
    timeline.setDate(timelineIntervalList);
    return new SlideshowData(timeline, slide);
  }
Exemplo n.º 5
0
  public SlideshowData generateTimelineData(String resourceHolderId, String contentId)
      throws Exception {

    Resource resource = getResource(contentId);

    Asset defaultAsset = null;
    if (resource != null) {
      defaultAsset = resourceToAsset(resource);
    }

    Slideshow timeline = new Slideshow();

    if (defaultAsset != null) {
      setDefaultProperties(defaultAsset, timeline);
    } else {
      setOptionalProperties(timeline);
    }

    ResourceSchedule schedule = ScheduleServiceImplSimple.findOne(resource.getScheduleId());

    if (schedule == null) {
      try {
        throw new Exception("");
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    if (schedule.getResourceSchedules().size() == 0) {
      throw new Exception("", null);
    }

    Set<String> resourceIds = new HashSet<>();

    // zmienic
    for (ResourceSchedule item : schedule.getResourceSchedules()) {
      resourceIds.add(item.getResourceId());
    }

    Iterable<Resource> resourcesSet = resourceHolderResourceRepository.findAll(resourceIds);
    HashMap<String, Asset> assets = resourcesToAssetMap(resourcesSet);

    List<SlideshowInterval> timelineIntervalList = new ArrayList<>();
    int slide = 0;

    Calendar calendar = GregorianCalendar.getInstance();

    for (int i = 0; i < schedule.getResourceSchedules().size() - 1; ++i) {
      long startTime = schedule.getResourceSchedules().get(i).getStartTime();

      if (calendar.getTimeInMillis() > startTime) {
        ++slide;
      }
      timelineIntervalList.add(
          resourceScheduleToDate(
              schedule.getResourceSchedules().get(i),
              assets.get(schedule.getResourceSchedules().get(i).getResourceId())));
      if (defaultAsset != null) {
        if (schedule.getResourceSchedules().get(i).getEndTime()
            != schedule.getResourceSchedules().get(i + 1).getStartTime()) {
          if (schedule.getResourceSchedules().get(i).getEndTime() < calendar.getTimeInMillis()) {
            ++slide;
          }
          timelineIntervalList.add(
              defaultDate(
                  schedule.getResourceSchedules().get(i).getEndTime(),
                  schedule.getResourceSchedules().get(i + 1).getStartTime(),
                  defaultAsset));
        }
      }
    }
    if (schedule.getResourceSchedules().size() > 0) {
      if (calendar.getTimeInMillis()
          > schedule
              .getResourceSchedules()
              .get(schedule.getResourceSchedules().size() - 1)
              .getEndTime()) {
        slide = 0;
      }

      timelineIntervalList.add(
          resourceScheduleToDate(
              schedule.getResourceSchedules().get(schedule.getResourceSchedules().size() - 1),
              assets.get(
                  schedule
                      .getResourceSchedules()
                      .get(schedule.getResourceSchedules().size() - 1)
                      .getResourceId())));
    }

    timeline.setDate(timelineIntervalList);
    return new SlideshowData(timeline, slide);
  }