Example #1
0
 private void addField(ResourceField newField) {
   if (fields.contains(newField)) {
     // Already there, we need to merge certain values.
     // If the field is marked as selectionOnly, but a resultField with same name, we can change it
     // to selectable
     ResourceField existingField = this.getFieldByIrisName(newField.getIrisName());
     if (!newField.getSelectionField().isEmpty()) {
       existingField.setSelectionField(newField.getSelectionField());
     }
     // If the data type of the new field differs from the existing one, set it to String to be the
     // most open type possible.
     if (!newField.getValueType().equals(existingField.getValueType())) {
       existingField.setValueType(GeneratorConstants.T24_TYPE_STRING);
     }
     // If the new field is the primary key, mark the existing field as the primary key
     if (!existingField.isPrimaryKey() && newField.isPrimaryKey()) {
       existingField.setPrimaryKey(true);
     }
   } else {
     // Not there yet, so add it.
     fields.add(newField);
   }
 }