if (priorFile != null) {
for (DescriptorProto message : priorFile.getMessageTypeList()) {
MessageOptions options = message.getOptions();
if ((options != null) &&
(options.hasExtension(TableOptions.fdbsql))) {
TableOptions toptions = options.getExtension(TableOptions.fdbsql);
if (toptions.getIsGroup()) {
priorMessage = message;
break;
}
}
}
}
nextField = 1;
if (priorMessage != null) {
TableOptions options = priorMessage.getOptions().getExtension(TableOptions.fdbsql);
if (options.hasNextField()) {
nextField = options.getNextField();
}
else {
nextField = priorMessage.getField(priorMessage.getFieldCount() - 1)
.getNumber() + 1;
}
}
fieldNames.clear();
for (Table table : tables) {
String fieldName = uniqueIdent(ident(table.getName().getTableName(), false), fieldNames);
fieldBuilder = messageBuilder.addFieldBuilder();
fieldBuilder.setName(fieldName);
fieldBuilder.setLabel(Label.LABEL_OPTIONAL);
fieldBuilder.setType(Type.TYPE_MESSAGE);
fieldBuilder.setTypeName(tableMessageNames.get(table));
FieldOptions.Builder fieldBuilderOptions = FieldOptions.newBuilder();
ColumnOptions.Builder columnOptions = ColumnOptions.newBuilder();
columnOptions.setUuid(table.getUuid().toString());
priorField = null;
if (priorMessage != null) {
for (FieldDescriptorProto field : priorMessage.getFieldList()) {
FieldOptions options = field.getOptions();
if ((options != null) &&
(options.hasExtension(ColumnOptions.fdbsql))) {
ColumnOptions coptions = options.getExtension(ColumnOptions.fdbsql);
if (coptions.getUuid().equals(columnOptions.getUuid())) {
priorField = field;
break;
}
}