Skip to content

Commit

Permalink
#175: make graphql Position extension work with existing Person mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Nelson committed Jan 30, 2020
1 parent 52b4dbe commit 9c00914
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 129 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ public Organization getById(
System.out.println("**** NODE: " + node);
return mapper.convertValue(node, Organization.class);
}



@GraphQLQuery
public Organization[] organizations(@GraphQLContext Position position) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
import edu.tamu.scholars.middleware.graphql.inert.model.person.Position;
import edu.tamu.scholars.middleware.graphql.inert.model.person.PositionStub;

import edu.tamu.scholars.middleware.graphql.inert.model.person.Person;
//import edu.tamu.scholars.middleware.graphql.inert.model.person.Person;
import edu.tamu.scholars.middleware.graphql.model.Person;
import edu.tamu.scholars.middleware.graphql.model.Relationship;

import java.util.List;
import java.util.Optional;
import java.util.ArrayList;
import java.util.Iterator;

@GraphQLApi
@Service
Expand All @@ -39,7 +42,6 @@ public Position getById(
) {
// @formatter:on


Optional<Individual> position = repo.findById(id);
ObjectNode node = mapper.valueToTree(position);
System.out.println("**** NODE: " + node);
Expand All @@ -48,23 +50,22 @@ public Position getById(


@GraphQLQuery
public Position[] positions(@GraphQLContext Person person) {
PositionStub[] positions = person.getPositions();
Position[] list = new Position[positions.length];
public List<Position> positions(@GraphQLContext Person person) {
List<Relationship> positions = person.getPositions();
//List<edu.tamu.scholars.middleware.graphql.model.person.Position> positions = person.getPositions();

System.out.println("**** found " + positions.length + " positions");
for (int i = 0; i < positions.length; i++) {
PositionStub pos = positions[i];
Optional<Individual> position = repo.findById(pos.getId());
System.out.println("found " + position);
ObjectNode node = mapper.valueToTree(position);
System.out.println("**** NODE: " + node);
Position real = mapper.convertValue(node, Position.class);
List<Position> list = new ArrayList<Position>();

for (Relationship rel: positions) {
//for (edu.tamu.scholars.middleware.graphql.model.person.Position rel: positions) {
Optional<Individual> position = repo.findById(rel.getId());

list[i] = real;
}
ObjectNode node = mapper.valueToTree(position);
System.out.println("**** NODE: " + node);
Position real = mapper.convertValue(node, Position.class);
list.add(real);
}
return list;
}


}

0 comments on commit 9c00914

Please sign in to comment.