public RelationshipTerminalState(PersistentResource record, String relationshipName) { this.record = record; this.relationshipType = record.getRelationshipType(relationshipName); this.relationshipName = relationshipName; }
public RelationshipTerminalState(PersistentResource record, String relationshipName) { this.record = record; this.relationshipType = record.getRelationshipType(relationshipName); this.relationshipName = relationshipName; }
RelationshipType type = getRelationshipType(fieldName); Set<PersistentResource> resources = filter(ReadPermission.class, getRelationUncheckedUnfiltered(fieldName));
RelationshipType type = getRelationshipType(fieldName); Set<PersistentResource> resources = filter(ReadPermission.class, getRelationUncheckedUnfiltered(fieldName));
/** * Get relationship mappings. * * @param relationshipFunction a function to load the value of a relationship. Takes a string of the relationship * name and returns the relationship's value. * @return Relationship mapping */ protected Map<String, Relationship> getRelationshipsWithRelationshipFunction( final Function<String, Set<PersistentResource>> relationshipFunction) { final Map<String, Relationship> relationshipMap = new LinkedHashMap<>(); final Set<String> relationshipFields = filterFields(dictionary.getRelationships(obj)); for (String field : relationshipFields) { TreeMap<String, Resource> orderedById = new TreeMap<>(lengthFirstComparator); for (PersistentResource relationship : relationshipFunction.apply(field)) { orderedById.put(relationship.getId(), new ResourceIdentifier(relationship.getType(), relationship.getId()).castToResource()); } Collection<Resource> resources = orderedById.values(); Data<Resource> data; RelationshipType relationshipType = getRelationshipType(field); if (relationshipType.isToOne()) { data = resources.isEmpty() ? new Data<>((Resource) null) : new Data<>(resources.iterator().next()); } else { data = new Data<>(resources); } // TODO - links relationshipMap.put(field, new Relationship(null, data)); } return relationshipMap; }
/** * Get relationship mappings. * * @param relationshipFunction a function to load the value of a relationship. Takes a string of the relationship * name and returns the relationship's value. * @return Relationship mapping */ protected Map<String, Relationship> getRelationshipsWithRelationshipFunction( final Function<String, Set<PersistentResource>> relationshipFunction) { final Map<String, Relationship> relationshipMap = new LinkedHashMap<>(); final Set<String> relationshipFields = filterFields(dictionary.getRelationships(obj)); for (String field : relationshipFields) { TreeMap<String, Resource> orderedById = new TreeMap<>(lengthFirstComparator); for (PersistentResource relationship : relationshipFunction.apply(field)) { orderedById.put(relationship.getId(), new ResourceIdentifier(relationship.getType(), relationship.getId()).castToResource()); } Collection<Resource> resources = orderedById.values(); Data<Resource> data; RelationshipType relationshipType = getRelationshipType(field); if (relationshipType.isToOne()) { data = resources.isEmpty() ? new Data<>((Resource) null) : new Data<>(resources.iterator().next()); } else { data = new Data<>(resources); } // TODO - links relationshipMap.put(field, new Relationship(null, data)); } return relationshipMap; }
RelationshipType type = getRelationshipType(relationName);
RelationshipType type = getRelationshipType(relationName);
Optional<Sorting> sorting, Optional<Pagination> pagination) { RelationshipType type = getRelationshipType(relationName); final Class<?> relationClass = dictionary.getParameterizedType(obj, relationName); if (relationClass == null) {
RelationshipType inverseRelationType = inverseResource.getRelationshipType(inverseName); if (inverseRelationType.isToOne()) {
Optional<Sorting> sorting, Optional<Pagination> pagination) { RelationshipType type = getRelationshipType(relationName); final Class<?> relationClass = dictionary.getParameterizedType(obj, relationName); if (relationClass == null) {
RelationshipType inverseRelationType = inverseResource.getRelationshipType(inverseName); if (inverseRelationType.isToOne()) {
RelationshipType inverseRelationType = inverseResource.getRelationshipType(inverseField); if (inverseRelationType.isToOne()) {
RelationshipType inverseRelationType = inverseResource.getRelationshipType(inverseField); if (inverseRelationType.isToOne()) {
.filter(relationName -> newResource.getRelationshipType(relationName).isToMany() && newResource.getValueUnchecked(relationName) == null) .forEach(relationName -> newResource.setValue(relationName, new LinkedHashSet<>()));
.filter(relationName -> newResource.getRelationshipType(relationName).isToMany() && newResource.getValueUnchecked(relationName) == null) .forEach(relationName -> newResource.setValue(relationName, new LinkedHashSet<>()));
RelationshipType type = getRelationshipType(fieldName); if (type.isToOne()) {
RelationshipType type = getRelationshipType(fieldName); if (type.isToOne()) {