Exemplo n.º 1
1
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   EducationJSONImpl other = (EducationJSONImpl) obj;
   if (classes == null) {
     if (other.classes != null) return false;
   } else if (!classes.equals(other.classes)) return false;
   if (concentration == null) {
     if (other.concentration != null) return false;
   } else if (!concentration.equals(other.concentration)) return false;
   if (degree == null) {
     if (other.degree != null) return false;
   } else if (!degree.equals(other.degree)) return false;
   if (school == null) {
     if (other.school != null) return false;
   } else if (!school.equals(other.school)) return false;
   if (type == null) {
     if (other.type != null) return false;
   } else if (!type.equals(other.type)) return false;
   if (with == null) {
     if (other.with != null) return false;
   } else if (!with.equals(other.with)) return false;
   if (year == null) {
     if (other.year != null) return false;
   } else if (!year.equals(other.year)) return false;
   return true;
 }
Exemplo n.º 2
0
  public static void insertPost(Post post, String type) {
    try {
      String postId = post.getId();
      IdNameEntity idNameEntity = post.getFrom();
      String userId = idNameEntity.getId();
      String userName = idNameEntity.getName();
      String commentsCount = post.getComments() == null ? "0" : post.getComments().size() + "";
      String likeCount = post.getLikes() == null ? "0" : post.getLikes().size() + "";

      String columnFamily = COLUMN_FAMILY_FACEBOOK_POST;
      String rowKey = type;
      String superColumn = postId + "-" + userId + "-" + userName;

      Clock clock = new Clock(System.nanoTime());
      Column column = new Column();
      String columnName = commentsCount + "-" + likeCount;
      column.setName(columnName.getBytes(UTF8));
      String columnValue = post.getMessage();
      if (!StringUtils.isBlank(columnValue)) {
        column.setValue(columnValue.getBytes(UTF8));
      } else {
        column.setValue("".getBytes(UTF8));
      }
      column.setTimestamp(clock.timestamp);

      cassandra.insertSuperColumn(columnFamily, rowKey, superColumn, column);
    } catch (UnsupportedEncodingException e) {
      logger.error("[Info: encoding invalid] - [Error: {}]", e.toString());
    }
  }
Exemplo n.º 3
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((employer == null) ? 0 : employer.hashCode());
   result = prime * result + ((endDate == null) ? 0 : endDate.hashCode());
   result = prime * result + ((location == null) ? 0 : location.hashCode());
   result = prime * result + ((position == null) ? 0 : position.hashCode());
   result = prime * result + ((startDate == null) ? 0 : startDate.hashCode());
   return result;
 }
Exemplo n.º 4
0
  public static void removePost(Post post, String type) {
    String postId = post.getId();
    IdNameEntity idNameEntity = post.getFrom();
    String userId = idNameEntity.getId();
    String userName = idNameEntity.getName();

    String columnFamily = COLUMN_FAMILY_FACEBOOK_POST;
    String rowKey = type;
    String superColumn = postId + "-" + userId + "-" + userName;

    cassandra.removeSuperColumn(columnFamily, rowKey, superColumn);
  }
Exemplo n.º 5
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((classes == null) ? 0 : classes.hashCode());
   result = prime * result + ((concentration == null) ? 0 : concentration.hashCode());
   result = prime * result + ((degree == null) ? 0 : degree.hashCode());
   result = prime * result + ((school == null) ? 0 : school.hashCode());
   result = prime * result + ((type == null) ? 0 : type.hashCode());
   result = prime * result + ((with == null) ? 0 : with.hashCode());
   result = prime * result + ((year == null) ? 0 : year.hashCode());
   return result;
 }
Exemplo n.º 6
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   WorkJSONImpl other = (WorkJSONImpl) obj;
   if (employer == null) {
     if (other.employer != null) return false;
   } else if (!employer.equals(other.employer)) return false;
   if (endDate == null) {
     if (other.endDate != null) return false;
   } else if (!endDate.equals(other.endDate)) return false;
   if (location == null) {
     if (other.location != null) return false;
   } else if (!location.equals(other.location)) return false;
   if (position == null) {
     if (other.position != null) return false;
   } else if (!position.equals(other.position)) return false;
   if (startDate == null) {
     if (other.startDate != null) return false;
   } else if (!startDate.equals(other.startDate)) return false;
   return true;
 }
Exemplo n.º 7
0
  public static void insertPostPopular(Post post, String type, Integer position) {
    try {
      String postId = post.getId();
      IdNameEntity idNameEntity = post.getFrom();
      String userId = idNameEntity.getId();
      String userName = idNameEntity.getName();

      String columnFamily = COLUMN_FAMILY_FACEBOOK_POST_POPULAR;
      String rowKey = (type + "-" + position);

      Clock clock = new Clock(System.nanoTime());
      Column column = new Column();
      String columnName = (postId + "-" + userId + "-" + userName);
      column.setName(columnName.getBytes(UTF8));
      String columnValue = post.getMessage();
      column.setValue(columnValue.getBytes(UTF8));
      column.setTimestamp(clock.timestamp);

      cassandra.insertColumn(columnFamily, rowKey, column);
    } catch (UnsupportedEncodingException e) {
      logger.error("[Info: encoding invalid] - [Error: {}]", e.toString());
    }
  }
Exemplo n.º 8
0
  public static XContentBuilder toJson(
      Post post,
      String riverName,
      Map<String, List<EntityReference>> entities,
      Map<String, List<String>> mauiTopics,
      List<Map<String, String>> bayesianAnalyzedText)
      throws IOException {
    XContentBuilder out = XContentFactory.jsonBuilder().startObject();
    out.field("PostId", post.getId());
    out.field("PostLink", post.getLink() != null ? post.getLink().toString() : null);
    out.field("PostCreatedTime", post.getCreatedTime());

    IdNameEntity idName = null;
    if ((idName = post.getFrom()) != null) {
      out.field("PostFromId", idName.getId());
      out.field("PostFromName", idName.getName());
    }
    if (post.getStatusType() != null) {
      out.field("PostStatusType", post.getStatusType());
    }
    out.field("Post", post.getMessage());

    if (entities != null) {
      if (entities.isEmpty()) {
        out.field("entities", "{}");
      } else {
        out.startArray("entities");
        for (Map.Entry<String, List<EntityReference>> entityEntry : entities.entrySet()) {
          out.startObject();
          out.startArray(entityEntry.getKey());
          for (EntityReference er : entityEntry.getValue()) {
            out.startObject();
            out.field("entity-label", er.getEntityLabel());
            out.field("entity-reference", er.getEntityReference());
            out.field("entity-confidence", er.getConfidence());
            out.startArray("entity-type");
            for (String s : er.getEntityTypeList()) {
              out.startObject();
              out.field("type", s);
              out.endObject();
            }
            out.endArray();
            out.endObject();
          }
          out.endArray();
          out.endObject();
        }
        out.endArray();
      }
    }

    if (mauiTopics != null) {
      if (mauiTopics.isEmpty()) {
        out.field("topics", "{}");
      } else {
        out.startArray("topics");
        out.startObject();
        for (Map.Entry<String, List<String>> e : mauiTopics.entrySet()) {
          out.startArray(e.getKey());
          for (String s : e.getValue()) {
            out.startObject();
            out.field("text", s);
            out.endObject();
          }
          out.endArray();
        }
        out.endObject();
        out.endArray();
      }
    }

    if (bayesianAnalyzedText != null) {
      if (bayesianAnalyzedText.isEmpty()) {
        out.field("BayesianAnalysers", "{}");
      } else {
        out.startArray("BayesianAnalysers");
        out.startObject();
        for (Map<String, String> m : bayesianAnalyzedText) {
          if (m == null || m.isEmpty()) {
            continue;
          }
          for (Map.Entry<String, String> e : m.entrySet()) {
            out.startArray(e.getKey());
            out.startObject();
            out.field("text", e.getValue());
            out.endObject();
            out.endArray();
          }
        }
        out.endObject();
        out.endArray();
      }
    }

    if (riverName != null) {
      out.field("RiverName", riverName);
    }
    return out.endObject();
  }