var angular = require('angular');
require('../modules');
require('./TaskRepository');
  'use strict';

  var __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) {
      for (var key in parent) {
        if (__hasProp.call(parent, key)) {
          child[key] = parent[key];
        }
      }

      function ctor() {
        this.constructor = child;
      }
      ctor.prototype = parent.prototype;
      child.prototype = new ctor();
      child.__super__ = parent.prototype;
      child.__super__.constructor = parent;
      return child;
    };

  var module = angular.module('task.services');

  module.factory('TaskCacheArray', function(CacheArray, $q, TaskRepository) {
    function TaskCacheArray() {
      TaskCacheArray.__super__.constructor.apply(this, arguments);
    }

    __extends(TaskCacheArray, CacheArray);

    TaskCacheArray.prototype.getByIds = function(ids) {
      var promises = _.map(ids, function(id) {
        return TaskRepository.getTaskById(id);
      });

      return $q.all(promises);
    };

    TaskCacheArray.prototype.getItemId = function(item) {
      return item.id;
    };

    return TaskCacheArray;
  });