use of io.crnk.example.springboot.domain.model.History in project crnk-framework by crnk-project.
the class HistoryFieldContributor method getResourceFields.
@Override
public List<ResourceField> getResourceFields(ResourceFieldContributorContext context) {
// this method could be omitted if the history field is added regularly to Project and Task resource. This would be
// simpler and recommended, but may not always be possible. Here we demonstrate doing it dynamically.
InformationBuilder.Field fieldBuilder = context.getInformationBuilder().createResourceField();
fieldBuilder.name("history");
fieldBuilder.genericType(new TypeToken<List<History>>() {
}.getType());
fieldBuilder.oppositeResourceType("history");
fieldBuilder.fieldType(ResourceFieldType.RELATIONSHIP);
// field values are "null" on resource and we make use of automated lookup to the relationship repository
// instead:
fieldBuilder.lookupIncludeBehavior(LookupIncludeBehavior.AUTOMATICALLY_ALWAYS);
fieldBuilder.accessor(new ResourceFieldAccessor() {
@Override
public Object getValue(Object resource) {
return null;
}
@Override
public void setValue(Object resource, Object fieldValue) {
}
});
return Arrays.asList(fieldBuilder.build());
}
use of io.crnk.example.springboot.domain.model.History in project crnk-framework by crnk-project.
the class HistoryResourceRepository method findOne.
@Override
public History findOne(UUID id, QuerySpec querySpec) {
History history = new History();
history.setId(id);
history.setName("test");
return history;
}
use of io.crnk.example.springboot.domain.model.History in project crnk-framework by crnk-project.
the class HistoryResourceRepository method findAll.
@Override
public ResourceList<History> findAll(Iterable<UUID> ids, QuerySpec querySpec) {
DefaultResourceList list = new DefaultResourceList();
for (UUID id : ids) {
History history = new History();
history.setId(id);
history.setName("test");
list.add(history);
}
return list;
}
use of io.crnk.example.springboot.domain.model.History in project crnk-framework by crnk-project.
the class HistoryRelationshipRepository method findManyTargets.
@Override
public ResourceList<History> findManyTargets(Serializable sourceId, String fieldName, QuerySpec querySpec) {
DefaultResourceList list = new DefaultResourceList();
for (int i = 0; i < 10; i++) {
History history = new History();
history.setId(UUID.nameUUIDFromBytes(("historyElement" + i).getBytes()));
history.setName("historyElement" + i);
list.add(history);
}
return list;
}
Aggregations