Skip to content

Commit

Permalink
hide meta data from presentation model #517
Browse files Browse the repository at this point in the history
  • Loading branch information
remmeier committed Feb 5, 2020
1 parent 4e19871 commit d31d5f6
Showing 1 changed file with 30 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.List;

import io.crnk.core.engine.internal.utils.PreconditionUtil;
import io.crnk.core.queryspec.FilterOperator;
import io.crnk.core.queryspec.FilterSpec;
import io.crnk.core.queryspec.PathSpec;
import io.crnk.core.queryspec.QuerySpec;
import io.crnk.core.repository.ResourceRepository;
Expand Down Expand Up @@ -94,28 +96,37 @@ public <T extends MetaElement> T findElement(Class<T> metaType, Class<?> impleme
throw new UnsupportedOperationException();
}

private QuerySpec createQuerySpec() {
QuerySpec querySpec = new QuerySpec(MetaResource.class);
querySpec.setLimit(1000L);
querySpec.includeRelation(PathSpec.of("attributes"));
querySpec.includeRelation(PathSpec.of("repository"));
}

QuerySpec dataTypeSpec = new QuerySpec(MetaDataObject.class);
dataTypeSpec.includeRelation(PathSpec.of("attributes", "type"));
querySpec.putRelatedSpec(MetaDataObject.class, dataTypeSpec);
protected QuerySpec createQuerySpec() {
QuerySpec querySpec = new QuerySpec(MetaResource.class);
querySpec.setLimit(1000L);
querySpec.includeRelation(PathSpec.of("attributes"));
querySpec.includeRelation(PathSpec.of("repository"));

QuerySpec typeSpec = new QuerySpec(MetaType.class);
typeSpec.includeRelation(PathSpec.of("elementType"));
querySpec.putRelatedSpec(MetaType.class, typeSpec);
QuerySpec dataTypeSpec = new QuerySpec(MetaDataObject.class);
dataTypeSpec.includeRelation(PathSpec.of("attributes", "type"));
querySpec.putRelatedSpec(MetaDataObject.class, dataTypeSpec);

QuerySpec attrSpec = new QuerySpec(MetaAttribute.class);
attrSpec.includeRelation(PathSpec.of("type"));
querySpec.putRelatedSpec(MetaAttribute.class, attrSpec);
QuerySpec typeSpec = new QuerySpec(MetaType.class);
typeSpec.includeRelation(PathSpec.of("elementType"));
querySpec.putRelatedSpec(MetaType.class, typeSpec);

QuerySpec fieldSpec = new QuerySpec(MetaResourceField.class);
fieldSpec.includeRelation(PathSpec.of("type"));
querySpec.putRelatedSpec(MetaResourceField.class, fieldSpec);
return querySpec;
}
QuerySpec attrSpec = new QuerySpec(MetaAttribute.class);
attrSpec.includeRelation(PathSpec.of("type"));
querySpec.putRelatedSpec(MetaAttribute.class, attrSpec);

QuerySpec fieldSpec = new QuerySpec(MetaResourceField.class);
fieldSpec.includeRelation(PathSpec.of("type"));
querySpec.putRelatedSpec(MetaResourceField.class, fieldSpec);

filterResources(querySpec);

return querySpec;
}

protected void filterResources(QuerySpec querySpec) {
FilterSpec metaFilter = PathSpec.of("resourceType").filter(FilterOperator.LIKE, "meta%");
querySpec.addFilter(FilterSpec.not(metaFilter));
}
}

0 comments on commit d31d5f6

Please sign in to comment.