Ejemplo n.º 1
0
 @Override
 public Map<String, Serializable> getSQLStatementsProperties(Model model, Database database) {
   Map<String, Serializable> properties = new HashMap<String, Serializable>();
   properties.put("idType", "varchar(36)");
   properties.put("aclOptimizationsEnabled", Boolean.valueOf(aclOptimizationsEnabled));
   properties.put("pathOptimizationsEnabled", Boolean.valueOf(pathOptimizationsEnabled));
   properties.put("fulltextAnalyzer", fulltextAnalyzer);
   properties.put("fulltextEnabled", Boolean.valueOf(!fulltextDisabled));
   if (!fulltextDisabled) {
     Table ft = database.getTable(model.FULLTEXT_TABLE_NAME);
     properties.put("fulltextTable", ft.getQuotedName());
     ModelFulltext fti = model.getFulltextInfo();
     List<String> lines = new ArrayList<String>(fti.indexNames.size());
     for (String indexName : fti.indexNames) {
       String suffix = model.getFulltextIndexSuffix(indexName);
       Column ftft = ft.getColumn(model.FULLTEXT_FULLTEXT_KEY + suffix);
       Column ftst = ft.getColumn(model.FULLTEXT_SIMPLETEXT_KEY + suffix);
       Column ftbt = ft.getColumn(model.FULLTEXT_BINARYTEXT_KEY + suffix);
       String concat;
       if (compatibilityFulltextTable) {
         // tsvector
         concat = "  NEW.%s := COALESCE(NEW.%s, ''::TSVECTOR) || COALESCE(NEW.%s, ''::TSVECTOR);";
       } else {
         // text with space at beginning and end
         concat = "  NEW.%s := ' ' || COALESCE(NEW.%s, '') || ' ' || COALESCE(NEW.%s, '') || ' ';";
       }
       String line =
           String.format(concat, ftft.getQuotedName(), ftst.getQuotedName(), ftbt.getQuotedName());
       lines.add(line);
     }
     properties.put("fulltextTriggerStatements", StringUtils.join(lines, "\n"));
   }
   String[] permissions =
       NXCore.getSecurityService().getPermissionsToCheck(SecurityConstants.BROWSE);
   List<String> permsList = new LinkedList<String>();
   for (String perm : permissions) {
     permsList.add("('" + perm + "')");
   }
   properties.put("readPermissions", StringUtils.join(permsList, ", "));
   properties.put("usersSeparator", getUsersSeparator());
   properties.put("everyone", SecurityConstants.EVERYONE);
   properties.put("readAclMaxSize", Integer.toString(readAclMaxSize));
   return properties;
 }