예제 #1
0
 /** returns lower case representation of the documentType.name */
 @JsonIgnore
 public String getType() {
   // DAT-278
   return EntityHelper.getLabel(labels);
 }
예제 #2
0
  public Entity(
      String metaKey,
      FortressSegment segment,
      @NotEmpty EntityInputBean entityInput,
      @NotEmpty DocumentType documentType)
      throws FlockException {
    this();

    assert documentType != null;
    assert segment != null;

    labels.add(documentType.getName());
    this.metaKey = metaKey;
    this.noLogs = entityInput.isEntityOnly();
    this.segment = segment; // (FortressNode)documentType.getFortress();
    // DAT-278
    String docType = documentType.getName();
    if (docType == null) docType = documentType.getCode();

    if (docType == null)
      throw new RuntimeException(
          "Unable to resolve the doc type code [" + documentType + "] for  " + entityInput);

    newEntity = true;

    docType = docType.toLowerCase();
    code = entityInput.getCode();
    key =
        EntityHelper.parseKey(
            this.segment.getFortress().getId(),
            documentType.getId(),
            (code != null ? code : this.metaKey));
    // key = this.fortress.getId() + "." + documentType.getId() + "." + (code != null ? code :
    // metaKey);

    if (entityInput.getName() == null || entityInput.getName().equals(""))
      this.name = (code == null ? docType : (docType + "." + code));
    else this.name = entityInput.getName();

    //        if ( entityInput.getDescription()!=null &&
    // !entityInput.getDescription().equals(entityInput.getName()))
    //            this.description = entityInput.getDescription();

    //        indexName = indexHelper.getIndexRoot(this.segment);

    if (entityInput.getProperties() != null && !entityInput.getProperties().isEmpty()) {
      props = new DynamicPropertiesContainer(entityInput.getProperties());
    }

    Date when = entityInput.getWhen();

    if (when == null)
      fortressCreate =
          new DateTime(
                  dateCreated,
                  DateTimeZone.forTimeZone(
                      TimeZone.getTimeZone(this.segment.getFortress().getTimeZone())))
              .getMillis();
    else
      fortressCreate =
          new DateTime(when.getTime())
              .getMillis(); // new DateTime( when.getTime(),
                            // DateTimeZone.forTimeZone(TimeZone.getTimeZone(entityInput.getMetaTZ()))).toDate().getTime();
    if (entityInput.getLastChange() != null) {
      long fWhen = entityInput.getLastChange().getTime();
      if (fWhen != fortressCreate) fortressLastWhen = fWhen;
    }

    // Content date has the last say on when the update happened
    if (entityInput.getContent() != null && entityInput.getContent().getWhen() != null) {
      fortressLastWhen = entityInput.getContent().getWhen().getTime();
    }

    // lastUpdate = 0l;
    if (entityInput.isEntityOnly()) this.event = entityInput.getEvent();
    this.suppressSearch(entityInput.isSearchSuppressed());
  }