'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
/**
 * Created by geweimin on 17/4/1.
 */
/**
 *
 * @author Tom Baeyens
 * @author (Javascript) Dmitry Farafonov
 */

var ActivityImpl = function ActivityImpl(activityJson) {
  var _this = this;

  this.outgoingTransitions = [];
  this.outgoingTransitions = [];
  this.incomingTransitions = [];
  this.activityBehavior = null;
  this.parent = null;
  this.scope = false;
  this.async = false;
  this.exclusive = false;
  this.x = -1;
  this.y = -1;
  this.width = -1;
  this.height = -1;
  this.properties = {};

  // console.log("activityJson: ", activityJson);

  if (activityJson !== undefined) {
    this.setId(activityJson.activityId);

    Object.keys(activityJson.properties).forEach(function (propertyName) {
      _this.setProperty(propertyName, activityJson.properties[propertyName]);
    });
    // this.setProperty("name", activityJson.activityName);
    // this.setProperty("type", activityJson.activityType);
    this.setX(activityJson.x);
    this.setY(activityJson.y);
    this.setWidth(activityJson.width);
    this.setHeight(activityJson.height);

    if (activityJson.multiInstance) {
      this.setProperty('multiInstance', activityJson.multiInstance);
    }
    if (activityJson.collapsed) {
      this.setProperty('collapsed', activityJson.collapsed);
    }
    if (activityJson.isInterrupting !== undefined) {
      this.setProperty('isInterrupting', activityJson.isInterrupting);
    }
  }
};

ActivityImpl.prototype = {
  outgoingTransitions: [],
  incomingTransitions: [],
  activityBehavior: null,
  parent: null,
  scope: false,
  async: false,
  exclusive: false,

  id: null,

  properties: {},

  // Graphical information
  x: -1,
  y: -1,
  width: -1,
  height: -1,

  setId: function setId(id) {
    this.id = id;
  },

  getId: function getId() {
    return this.id;
  },

  setProperty: function setProperty(name, value) {
    this.properties[name] = value;
  },
  getProperty: function getProperty(name) {
    return this.properties[name];
  },

  createOutgoingTransition: function createOutgoingTransition(transitionId) {},

  toString: function toString(id) {
    return 'Activity(' + id + ')';
  },

  getParentActivity: function getParentActivity() {
    /*
     if (parent instanceof ActivityImpl) {
     79       return (ActivityImpl) parent;
     80     }
     81     return null;
     */
    return this.parent;
  },

  // restricted setters ///////////////////////////////////////////////////////

  setOutgoingTransitions: function setOutgoingTransitions(outgoingTransitions) {
    this.outgoingTransitions = outgoingTransitions;
  },

  setParent: function setParent(parent) {
    this.parent = parent;
  },

  setIncomingTransitions: function setIncomingTransitions(incomingTransitions) {
    this.incomingTransitions = incomingTransitions;
  },

  // getters and setters //////////////////////////////////////////////////////

  getOutgoingTransitions: function getOutgoingTransitions() {
    return this.outgoingTransitions;
  },

  getActivityBehavior: function getActivityBehavior() {
    return this.activityBehavior;
  },

  setActivityBehavior: function setActivityBehavior(activityBehavior) {
    this.activityBehavior = activityBehavior;
  },

  getParent: function getParent() {
    return this.parent;
  },

  getIncomingTransitions: function getIncomingTransitions() {
    return this.incomingTransitions;
  },

  isScope: function isScope() {
    return this.scope;
  },

  setScope: function setScope(isScope) {
    this.scope = isScope;
  },

  getX: function getX() {
    return this.x;
  },

  setX: function setX(x) {
    this.x = x;
  },

  getY: function getY() {
    return this.y;
  },

  setY: function setY(y) {
    this.y = y;
  },

  getWidth: function getWidth() {
    return this.width;
  },

  setWidth: function setWidth(width) {
    this.width = width;
  },

  getHeight: function getHeight() {
    return this.height;
  },

  setHeight: function setHeight(height) {
    this.height = height;
  },

  isAsync: function isAsync() {
    return this.async;
  },

  setAsync: function setAsync(isAsync) {
    this.async = isAsync;
  },

  isExclusive: function isExclusive() {
    return this.exclusive;
  },

  setExclusive: function setExclusive(isExclusive) {
    this.exclusive = isExclusive;
  },

  vvoid: function vvoid() {}
};

exports.default = ActivityImpl;