Beispiel #1
0
 @Override
 public Query<T> retrieveKnownFields() {
   final MappedClass mc = ds.getMapper().getMappedClass(clazz);
   final List<String> fields = new ArrayList<String>(mc.getPersistenceFields().size() + 1);
   for (final MappedField mf : mc.getPersistenceFields()) {
     fields.add(mf.getNameToStore());
   }
   retrievedFields(true, fields.toArray(new String[fields.size()]));
   return this;
 }
Beispiel #2
0
 @SuppressWarnings("deprecation")
 private List<Index> collectFieldIndexes(final MappedClass mc) {
   List<Index> list = new ArrayList<Index>();
   for (final MappedField mf : mc.getPersistenceFields()) {
     if (mf.hasAnnotation(Indexed.class)) {
       final Indexed indexed = mf.getAnnotation(Indexed.class);
       list.add(convert(indexed, mf.getNameToStore()));
     } else if (mf.hasAnnotation(Text.class)) {
       final Text text = mf.getAnnotation(Text.class);
       list.add(convert(text, mf.getNameToStore()));
     }
   }
   return list;
 }
Beispiel #3
0
  private List<Index> collectNestedIndexes(
      final MappedClass mc, final List<MappedClass> parentMCs) {
    List<Index> list = new ArrayList<Index>();
    for (final MappedField mf : mc.getPersistenceFields()) {
      if (!mf.isTypeMongoCompatible()
          && !mf.hasAnnotation(Reference.class)
          && !mf.hasAnnotation(Serialized.class)
          && !mf.hasAnnotation(NotSaved.class)
          && !mf.isTransient()) {

        final List<MappedClass> parents = new ArrayList<MappedClass>(parentMCs);
        parents.add(mc);

        List<MappedClass> classes = new ArrayList<MappedClass>();
        MappedClass mappedClass =
            mapper.getMappedClass(mf.isSingleValue() ? mf.getType() : mf.getSubClass());
        classes.add(mappedClass);
        classes.addAll(mapper.getSubTypes(mappedClass));
        for (MappedClass aClass : classes) {
          for (Index index : collectIndexes(aClass, parents)) {
            List<Field> fields = new ArrayList<Field>();
            for (Field field : index.fields()) {
              fields.add(
                  new FieldBuilder()
                      .value(
                          field.value().equals("$**")
                              ? field.value()
                              : mf.getNameToStore() + "." + field.value())
                      .type(field.type())
                      .weight(field.weight()));
            }
            list.add(new IndexBuilder(index).fields(fields));
          }
        }
      }
    }

    return list;
  }