예제 #1
0
  public boolean Validate(ParserSession PS, Base ParentObject) {
    int Errs = PS.getErrorCount();
    _ParentObject = ParentObject;

    _ColumnObjs =
        ValidationHelper.ProcessColumn(
            PS,
            ParentObject,
            "JSONMapping '" + _Name + "'",
            _Columns,
            new ValidationHelper.Processor() {
              @Override
              public boolean process(ParserSession PS, Base ParentObject, String What, Column C) {
                if (C._Type == ColumnType.BINARY)
                  PS.AddError(
                      ParentObject.getWhat()
                          + " '"
                          + _ParentObject.getFullName()
                          + "' is defining a JSON mapping with column '"
                          + C.getName()
                          + "' which is a binary. Binaries cannot be JSONed.");
                return true;
              }
            });

    if (_Sync == true && _ParentObject.isOCC() == false)
      PS.AddError(
          ParentObject.getWhat()
              + " '"
              + _ParentObject.getFullName()
              + "' is defining a 'sync' JSON mapping but the parent object is not OCC.");

    return Errs == PS.getErrorCount();
  }
예제 #2
0
  public boolean Validate(ParserSession PS, Schema ParentSchema, int pos) {
    int Errs = PS.getErrorCount();
    _ParentSchema = ParentSchema;
    LOG.debug("  Validating Enumeration " + _Name + ".");

    // Mandatories
    if (TextUtil.isNullOrEmpty(_Name) == true)
      return PS.AddError(
          "Schema '"
              + _ParentSchema.getFullName()
              + "' is declaring an enumeration '"
              + _Name
              + "' without a name.");
    if (ValidationHelper.isValidIdentifier(_Name) == false)
      return PS.AddError(
          "Schema '"
              + _ParentSchema.getFullName()
              + "' is declaring an enumeration '"
              + _Name
              + "' with a name which is not valid. "
              + ValidationHelper._ValidIdentifierMessage);
    if (TextUtil.isNullOrEmpty(_Description) == true)
      return PS.AddError(
          "Schema '"
              + _ParentSchema.getFullName()
              + "' is declaring an enumeration '"
              + _Name
              + "' without a description.");
    if (_Id == null)
      return PS.AddError(
          "Schema '"
              + _ParentSchema.getFullName()
              + "' is declaring an enumeration '"
              + _Name
              + "' without an Id type.");
    if (_Value == null)
      return PS.AddError(
          "Schema '"
              + _ParentSchema.getFullName()
              + "' is declaring an enumeration '"
              + _Name
              + "' without a Value type.");

    Object O = new Object();
    O._FST = FrameworkSourcedType.ENUMERATION;
    O._Name = _Name;
    O._Description = _Description;

    Column C =
        new Column(
            "id",
            _Id._TypeStr,
            _Id._Size,
            false,
            ColumnMode.NORMAL,
            true,
            null,
            "The id for this enumeration.");
    O._Columns.add(C);

    C =
        new Column(
            "value",
            _Value._TypeStr,
            _Value._Size,
            false,
            ColumnMode.NORMAL,
            true,
            null,
            "The value for this enumeration.");
    O._Columns.add(C);

    C =
        new Column(
            "label",
            ColumnType.STRING.toString(),
            254,
            false,
            ColumnMode.NORMAL,
            false,
            ProtectionType.ABSOLUTE,
            "The label for this enumeration.");
    O._Columns.add(C);

    C =
        new Column(
            "deactivated",
            ColumnType.DATETIME.toString(),
            null,
            true,
            ColumnMode.NORMAL,
            false,
            null,
            "The label for this enumeration.");
    C._FrameworkManaged = true;
    O._Columns.add(C);

    PrimaryKey PK = new PrimaryKey();
    PK._Columns = new String[] {"id"};
    O._PrimaryKey = PK;

    O._Indices = new ArrayList<Index>();
    Index I = new Index();
    I._Name = "Id";
    I._Columns = new String[] {"id"};
    I._Db = true;
    O._Indices.add(I);

    I = new Index();
    I._Name = "Value";
    I._Columns = new String[] {"value"};
    I._Db = true;
    O._Indices.add(I);

    I = new Index();
    I._Name = "All";
    I._OrderBy = new String[] {"id"};
    I._Db = false;
    O._Indices.add(I);

    _ParentSchema._Objects.add(pos, O);

    return Errs == PS.getErrorCount();
  }