protected final void addAllNodesTable( ImmutableSchemata.Builder builder,
IndexRules.Builder indexRuleBuilder,
ExecutionContext context ) {
NamespaceRegistry registry = context.getNamespaceRegistry();
TypeSystem typeSystem = context.getValueFactories().getTypeSystem();
String tableName = AllNodes.ALL_NODES_NAME.getName();
boolean first = true;
Map<String, String> typesForNames = new HashMap<String, String>();
Set<String> fullTextSearchableNames = new HashSet<String>();
for (JcrPropertyDefinition defn : propertyDefinitions) {
if (defn.isResidual()) continue;
if (defn.isPrivate()) continue;
// if (defn.isMultiple()) continue;
Name name = defn.getInternalName();
String columnName = name.getString(registry);
if (first) {
builder.addTable(tableName, columnName);
first = false;
}
String type = typeSystem.getDefaultType();
if (defn.getRequiredType() != PropertyType.UNDEFINED) {
type = types.get(defn.getRequiredType());
}
assert type != null;
String previousType = typesForNames.put(columnName, type);
if (previousType != null && !previousType.equals(type)) {
// There are two property definitions with the same name but different types, so we need to find a common type ...
type = typeSystem.getCompatibleType(previousType, type);
}
boolean fullTextSearchable = fullTextSearchableNames.contains(columnName) || defn.isFullTextSearchable();
if (fullTextSearchable) fullTextSearchableNames.add(columnName);
// Add (or overwrite) the column ...
builder.addColumn(tableName, columnName, type, fullTextSearchable);