Exemplo n.º 1
0
 private boolean doesSectionContain(
     FieldDataPacket section, String lookFor, MiniLocalization localization) {
   FieldSpec fields[] = section.getFieldSpecs().asArray();
   for (int f = 0; f < fields.length; ++f) {
     MartusField field = getField(fields[f].getTag());
     if (field.contains(lookFor, localization)) return true;
   }
   return false;
 }
Exemplo n.º 2
0
  public FieldType getFieldType(String fieldTag) {
    MartusField field = getField(fieldTag);
    if (field == null) return new FieldTypeUnknown();

    return field.getType();
  }
Exemplo n.º 3
0
  public MartusField getField(String fieldTag) {
    PoolOfReusableChoicesLists noRelevantReusableChoices = PoolOfReusableChoicesLists.EMPTY_POOL;
    if (fieldTag.equals(PSEUDOFIELD_LOCAL_ID)) {
      MartusField localIdField =
          new MartusField(
              FieldSpec.createStandardField(fieldTag, new FieldTypeNormal()),
              noRelevantReusableChoices);
      localIdField.setData(getLocalId());
      return localIdField;
    }

    if (fieldTag.equals(PSEUDOFIELD_LAST_SAVED_DATE)) {
      MartusField lastSavedDateField =
          new MartusField(
              FieldSpec.createStandardField(fieldTag, new FieldTypeDate()),
              noRelevantReusableChoices);
      lastSavedDateField.setData(getLastSavedDate());
      return lastSavedDateField;
    }

    if (fieldTag.equals(Bulletin.TAGLASTSAVED)
        || fieldTag.equals(Bulletin.PSEUDOFIELD_LAST_SAVED_TIMESTAMP)) {
      MartusField lastSavedTimestampField =
          new MartusField(
              FieldSpec.createStandardField(fieldTag, new FieldTypeNormal()),
              noRelevantReusableChoices);
      lastSavedTimestampField.setData(Long.toString(getLastSavedTime()));
      return lastSavedTimestampField;
    }

    // FIXME: Rename TAGSTATUS to PSEUDOFIELD_STATUS (globally)
    if (fieldTag.equals(TAGSTATUS)) {
      MartusField statusField =
          new MartusField(
              FieldSpec.createStandardField(fieldTag, new FieldTypeNormal()),
              noRelevantReusableChoices);
      statusField.setData(getStatus());
      return statusField;
    }

    if (fieldTag.equals(PSEUDOFIELD_ALL_PRIVATE)) {
      MartusField allPrivateField =
          new MartusField(
              FieldSpec.createStandardField(fieldTag, new FieldTypeBoolean()),
              noRelevantReusableChoices);
      if (isAllPrivate()) allPrivateField.setData(FieldSpec.TRUESTRING);
      else allPrivateField.setData(FieldSpec.FALSESTRING);
      return allPrivateField;
    }

    if (fieldTag.equals(BulletinConstants.TAGWASSENT)
        || fieldTag.equals(Bulletin.PSEUDOFIELD_WAS_SENT))
      throw new RuntimeException("Bulletin doesn't know if it was sent or not");

    if (isFieldInPublicSection(fieldTag)) return fieldData.getField(fieldTag);
    return getPrivateFieldDataPacket().getField(fieldTag);
  }
Exemplo n.º 4
0
  public String get(String fieldTag) {
    MartusField field = getField(fieldTag);
    if (field == null) return "";

    return field.getData();
  }
Exemplo n.º 5
0
  public void set(String fieldTag, String value) {
    MartusField field = getField(fieldTag);
    if (field == null) return;

    field.setData(value);
  }