private TemplateResult createItem(
      DataAccess access, DataTemplate template, Map<String, String> param) throws BaseException {
    DataSource dataSource = getDataSource(access, param.get(Helper.Keys.SourceId));
    if (dataSource.getState() != DataInformation.DataState.READY)
      throw new NotReadyException("The datasource %s is not yet ready.", dataSource.getId());

    Item item = dataSource.createItem(param);
    return template.transform(item);
  }
  private TemplateResult addInteraction(
      DataAccess access, DataTemplate template, Map<String, String> param) throws BaseException {
    DataSource dataSource = getDataSource(access, param.get(Helper.Keys.SourceId));

    if (dataSource.getState() != DataInformation.DataState.READY)
      throw new NotReadyException("The datasource %s is not yet ready.", dataSource.getId());

    String itemId = param.get(Helper.Keys.ItemId);
    String userId = param.get(Helper.Keys.UserId);
    String type = param.get(Helper.Keys.Type);
    String value = param.get(Helper.Keys.Value);
    String timestamp = param.get(Helper.Keys.TimeStamp);

    Date date = null;
    if (timestamp != null && !timestamp.isEmpty()) {
      Long t = Long.parseLong(timestamp);
      if (t != null) {
        date = new Date(t);
      }
    }

    if (date == null) {
      date = new Date();
    }

    if (dataSource.tryGetItem(itemId) == null) {
      Map<String, String> temp = new HashMap<>();
      temp.put(Helper.Keys.ItemId, itemId);
      dataSource.createItem(temp);
    }

    if (dataSource.tryGetUser(userId) == null) {
      Map<String, String> temp = new HashMap<>();
      temp.put(Helper.Keys.UserId, userId);
      dataSource.createUser(temp);
    }

    Message message = dataSource.addInteraction(itemId, userId, date, type, value, param);
    return template.transform(message);
  }