'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _fogLayoutsManager = require('../managers/fogLayoutsManager');

var _fogLayoutsManager2 = _interopRequireDefault(_fogLayoutsManager);

var _appUtils = require('../utils/appUtils');

var _appUtils2 = _interopRequireDefault(_appUtils);

var _underscore = require('underscore');

var _underscore2 = _interopRequireDefault(_underscore);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var findFogLayoutsByInstanceId = function findFogLayoutsByInstanceId(props, params, callback) {
  var instanceId = _appUtils2.default.getProperty(params, props.instanceId);

  _fogLayoutsManager2.default.findByinstanceId(instanceId).then(_appUtils2.default.onFindOptional.bind(null, params, props.setProperty, callback));
}; /*
    * *******************************************************************************
    *  * Copyright (c) 2018 Edgeworx, Inc.
    *  *
    *  * This program and the accompanying materials are made available under the
    *  * terms of the Eclipse Public License v. 2.0 which is available at
    *  * http://www.eclipse.org/legal/epl-2.0
    *  *
    *  * SPDX-License-Identifier: EPL-2.0
    *  *******************************************************************************
    *
    */

var createFogLayout = function createFogLayout(props, params, callback) {
  _fogLayoutsManager2.default.create(props.data).then(_appUtils2.default.onCreate.bind(null, params, props.setProperty, 'Unable to create Fog Layout object.', callback));
};

var updateFogLayout = function updateFogLayout(props, params, callback) {
  var instanceId = _appUtils2.default.getProperty(params, props.instanceId);

  _fogLayoutsManager2.default.updateLayoutByInstanceId(instanceId, props.updatedData).then(_appUtils2.default.onUpdate.bind(null, params, 'Unable to update Fog Layout', callback));
};

var findFogLayoutsByInstanceIds = function findFogLayoutsByInstanceIds(props, params, callback) {
  var fogData = _appUtils2.default.getProperty(params, props.fogData);

  _fogLayoutsManager2.default.findByinstanceId(fogData).then(_appUtils2.default.onFindOptional.bind(null, params, props.setProperty, callback));
};

var deleteFogLayoutsByInstanceId = function deleteFogLayoutsByInstanceId(props, params, callback) {
  var instanceId = _appUtils2.default.getProperty(params, props.instanceId);

  _fogLayoutsManager2.default.deleteLayoutsByInstanceId(instanceId).then(_appUtils2.default.onDeleteOptional.bind(null, params, callback));
};

exports.default = {
  createFogLayout: createFogLayout,
  deleteFogLayoutsByInstanceId: deleteFogLayoutsByInstanceId,
  findFogLayoutsByInstanceId: findFogLayoutsByInstanceId,
  findFogLayoutsByInstanceIds: findFogLayoutsByInstanceIds,
  updateFogLayout: updateFogLayout
};