private Updates computeUpdates(
      List<com.antoshkaplus.words.model.Translation> local, List<Translation> remote) {

    Updates updates = new Updates();
    LocalTranslationList localList = new LocalTranslationList(local);

    for (Translation r : remote) {
      com.antoshkaplus.words.model.Translation t = localList.extract(r);
      if (t == null) {
        updates.localNotFound.add(toLocal(r));
      } else {
        long t_creation = t.creationDate.getTime();
        long r_creation = r.getCreationDate().getValue();
        boolean creationEqual = t_creation == r_creation;
        long earliestCreation = Math.min(t_creation, r_creation);
        if (updateDateLess(t, r)) {
          // r is newer
          if (!creationEqual) {
            r.setCreationDate(new DateTime(earliestCreation));
            // we are fine sending something with
            // same update date
            updates.remote.add(r);
          }
          com.antoshkaplus.words.model.Translation tr = toLocal(r);
          tr.id = t.id;
          updates.localIntersection.add(tr);
        } else {
          if (!creationEqual) {
            t.creationDate = new Date(earliestCreation);
            updates.localIntersection.add(t);
          }
          updates.remote.add(toRemote(t));
        }
      }
    }
    for (com.antoshkaplus.words.model.Translation t : localList.getList()) {
      updates.remote.add(toRemote(t));
    }
    updates.localNew = localList.getList();
    return updates;
  }
 private com.antoshkaplus.words.model.Translation toLocal(Translation r) {
   com.antoshkaplus.words.model.Translation t = new com.antoshkaplus.words.model.Translation();
   t.creationDate = new Date(r.getCreationDate().getValue());
   t.updateDate = new Date(r.getUpdateDate().getValue());
   t.deleted = r.getDeleted();
   t.foreignWord = r.getForeignWord();
   t.nativeWord = r.getNativeWord();
   return t;
 }