示例#1
0
  private Map<String, String[]> getCollectionFieldMap() {

    if (collectionFieldMap != null) {
      return collectionFieldMap;
    }

    // get basic stuff from Schema
    String[] collectionTypes = getCollectionTypes();
    collectionFieldMap = new TreeMap<String, String[]>();
    for (String type : collectionTypes) {
      Set<String> propertyNames = Schema.getDefaultSchema().getPropertyNames(type);
      for (String attr : BASE_ATTRIBUTES) {
        propertyNames.remove(attr);
      }

      Iterator<String> i = propertyNames.iterator();
      while (i.hasNext()) {
        String property = i.next();
        Class cls = Schema.getDefaultSchema().getPropertyType(type, property);
        if (!cls.isPrimitive() && cls != String.class && cls != Date.class) {
          i.remove();
        }
      }
      String[] props = new String[propertyNames.size()];
      propertyNames.toArray(props);
      Arrays.sort(props);
      collectionFieldMap.put(type, props);
    }

    // add URAP stuff that's not visible to usergrid-stack
    for (Map.Entry<String, String[]> entry : URAP_ATTRIBUTES.entrySet()) {
      String type = entry.getKey();
      String[] attributes = entry.getValue();
      Arrays.sort(attributes);
      collectionFieldMap.put(type, attributes);
    }

    return collectionFieldMap;
  }
  private boolean skipIndexingForType(String type, ApplicationScope applicationScope) {

    boolean skipIndexing = false;

    MapManager mm = getMapManagerForTypes(applicationScope);
    IndexSchemaCache indexSchemaCache = indexSchemaCacheFactory.getInstance(mm);
    String collectionName = Schema.defaultCollectionName(type);
    Optional<Map> collectionIndexingSchema = indexSchemaCache.getCollectionSchema(collectionName);

    if (collectionIndexingSchema.isPresent()) {
      Map jsonMapData = collectionIndexingSchema.get();
      final ArrayList fields = (ArrayList) jsonMapData.get("fields");
      if (fields.size() == 1 && fields.get(0).equals("none")) {
        skipIndexing = true;
      }
    }

    return skipIndexing;
  }
示例#3
0
  private String[] getCollectionTypes() {

    if (collectionNames != null) {
      return collectionNames;
    }

    Collection<CollectionInfo> system_collections =
        getDefaultSchema().getCollections(Application.ENTITY_TYPE).values();

    ArrayList<String> collections = new ArrayList<String>(system_collections.size());
    for (CollectionInfo collection : system_collections) {
      if (!Schema.isAssociatedEntityType(collection.getType())) {
        collections.add(collection.getType());
      }
    }

    collectionNames = new String[collections.size()];
    Collections.sort(collections);
    return collections.toArray(collectionNames);
  }