Example #1
0
  protected void prune(SchemaImpl schema) {
    Map<String, Field> fields = schema.getResourceFields();
    Map<String, Filter> filters = schema.getCollectionFilters();

    for (String name : new HashSet<String>(fields.keySet())) {
      Field field = fields.get(name);

      List<FieldType> subTypeEnums = field.getSubTypeEnums();
      List<String> subTypes = field.getSubTypes();

      for (int i = 0; i < subTypeEnums.size(); i++) {
        if (subTypeEnums.get(i) == FieldType.TYPE
            && !schemaMap.containsKey(subTypes.get(i))
            && !"type".equals(subTypes.get(i))) {
          fields.remove(name);
          filters.remove(name);
          break;
        }
      }
    }

    Iterator<String> childrenIter = schema.getChildren().iterator();
    while (childrenIter.hasNext()) {
      if (!schemaMap.containsKey(childrenIter.next())) {
        childrenIter.remove();
      }
    }
  }
Example #2
0
  public synchronized void init() {
    if (init) {
      return;
    }

    schemaMap = new HashMap<String, Schema>();

    if (schemaFactory instanceof SubSchemaFactory) {
      ((SubSchemaFactory) schemaFactory).init();
    }

    List<SchemaImpl> result = new ArrayList<SchemaImpl>();

    for (Schema schema : schemaFactory.listSchemas()) {
      if (schema instanceof SchemaImpl) {
        /* Copy */
        SchemaImpl impl = new SchemaImpl((SchemaImpl) schema);

        for (SchemaPostProcessor post : postProcessors) {
          impl = post.postProcessRegister(impl, this);
          if (impl == null) {
            break;
          }
        }

        if (impl != null) {
          result.add(impl);
          schemaMap.put(impl.getId(), impl);
        }
      }
    }

    schemaList = result;

    for (SchemaImpl schema : schemaList) {
      for (SchemaPostProcessor post : postProcessors) {
        schema = post.postProcess(schema, this);
      }
    }

    for (SchemaImpl schema : schemaList) {
      prune(schema);
    }

    if (SERIALIZE.get()) {
      serializeSchema(listSchemas(), getId());
      synchronized (schemaFactory) {
        serializeSchema(schemaFactory.listSchemas(), schemaFactory.getId());
      }
    }

    init = true;
  }