use of com.squareup.protoparser.ProtoFile in project teiid by teiid.
the class ProtobufMetadataProcessor method toTeiidSchema.
private void toTeiidSchema(String name, String contents, MetadataFactory mf, String cacheName) throws TranslatorException {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Processing Proto file:", name, " with contents\n", contents);
ProtoFile protoFile = ProtoParser.parse(name, contents);
List<MessageElement> messageTypes = filter(protoFile.typeElements(), MessageElement.class);
List<EnumElement> enumTypes = filter(protoFile.typeElements(), EnumElement.class);
// add tables
HashSet<String> deleteTables = new HashSet<>();
for (MessageElement messageElement : messageTypes) {
Table t = addTable(mf, messageTypes, enumTypes, messageElement, null, deleteTables);
if (t != null) {
if (t.getAnnotation() != null && findFromAnnotation(AT_CACHE, t.getAnnotation(), "name") != null) {
t.setProperty(CACHE, findFromAnnotation(AT_CACHE, t.getAnnotation(), "name"));
} else {
// in metadata, as both parent child must be in single cache.
if (getParentTag(t) == -1) {
t.setProperty(CACHE, cacheName);
}
}
}
}
for (String tableName : deleteTables) {
mf.getSchema().removeTable(tableName);
}
}
Aggregations