-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
partial implementation of changes for #175
- Loading branch information
1 parent
9994bf6
commit 8f52539
Showing
7 changed files
with
240 additions
and
6 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/main/java/edu/tamu/scholars/middleware/graphql/inert/model/person/Position.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package edu.tamu.scholars.middleware.graphql.inert.model.person; | ||
|
||
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY; | ||
|
||
import java.util.List; | ||
|
||
import edu.tamu.scholars.middleware.discovery.model.Common; | ||
import edu.tamu.scholars.middleware.graphql.model.AbstractNestedDocument; | ||
import io.leangen.graphql.annotations.types.GraphQLType; | ||
import org.springframework.data.solr.core.mapping.Indexed; | ||
import org.springframework.data.solr.core.mapping.SolrDocument; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
import edu.tamu.scholars.middleware.discovery.annotation.CollectionSource; | ||
import edu.tamu.scholars.middleware.discovery.annotation.NestedMultiValuedProperty; | ||
import edu.tamu.scholars.middleware.discovery.annotation.NestedObject; | ||
import edu.tamu.scholars.middleware.discovery.annotation.NestedObject.Reference; | ||
import edu.tamu.scholars.middleware.discovery.annotation.PropertySource; | ||
// import io.leangen.graphql.annotations.GraphQLIgnore; | ||
|
||
// @GraphQLIgnore | ||
@GraphQLType( | ||
name = "CustomPosition" | ||
) | ||
|
||
@JsonInclude(NON_EMPTY) | ||
public class Position extends AbstractNestedDocument { | ||
private String title; | ||
private String[] type; | ||
|
||
public Position() { | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
public String[] getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String[] type) { | ||
this.type = type; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/edu/tamu/scholars/middleware/graphql/inert/service/PositionResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package edu.tamu.scholars.middleware.graphql.inert.service; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import edu.tamu.scholars.middleware.discovery.model.Individual; | ||
import edu.tamu.scholars.middleware.discovery.model.repo.IndividualRepo; | ||
// import edu.tamu.scholars.middleware.graphql.model.Collection; | ||
import graphql.language.Field; | ||
import io.leangen.graphql.annotations.GraphQLArgument; | ||
import io.leangen.graphql.annotations.GraphQLEnvironment; | ||
import io.leangen.graphql.annotations.GraphQLQuery; | ||
import io.leangen.graphql.spqr.spring.annotations.GraphQLApi; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
import edu.tamu.scholars.middleware.graphql.inert.model.person.Position; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@GraphQLApi | ||
@Service | ||
public class PositionResolver { | ||
@Autowired | ||
private IndividualRepo repo; | ||
|
||
@Autowired | ||
private ObjectMapper mapper; | ||
|
||
@GraphQLQuery(name = "position") | ||
// @formatter:off | ||
public Position getById( | ||
@GraphQLArgument(name = "id") String id, | ||
@GraphQLEnvironment List<Field> fields | ||
) { | ||
// @formatter:on | ||
|
||
|
||
Optional<Individual> position = repo.findById(id); | ||
ObjectNode node = mapper.valueToTree(position); | ||
System.out.println("**** NODE: " + node); | ||
return mapper.convertValue(node, Position.class); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/edu/tamu/scholars/middleware/graphql/model/person/Position.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package edu.tamu.scholars.middleware.graphql.model.person; | ||
|
||
import edu.tamu.scholars.middleware.graphql.model.person.PositionOrganization; | ||
|
||
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import edu.tamu.scholars.middleware.graphql.model.AbstractNestedDocument; | ||
import io.leangen.graphql.annotations.types.GraphQLType; | ||
import java.lang.String; | ||
import java.util.List; | ||
|
||
/** | ||
* This file is automatically generated on compile. | ||
* | ||
* Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
*/ | ||
@GraphQLType( | ||
name = "PersonPosition" | ||
) | ||
@JsonInclude(NON_EMPTY) | ||
public class Position extends AbstractNestedDocument { | ||
private static final long serialVersionUID = -294827460L; | ||
|
||
private String label; | ||
|
||
private String type; | ||
|
||
private List<PositionOrganization> organizations; | ||
|
||
public Position() { | ||
super(); | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public List<PositionOrganization> getOrganizations() { | ||
return organizations; | ||
} | ||
|
||
public void setOrganizations(List<PositionOrganization> organizations) { | ||
this.organizations = organizations; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/edu/tamu/scholars/middleware/graphql/model/person/PositionOrganization.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package edu.tamu.scholars.middleware.graphql.model.person; | ||
|
||
import edu.tamu.scholars.middleware.graphql.model.person.PositionOrganizationParent; | ||
|
||
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import edu.tamu.scholars.middleware.graphql.model.AbstractNestedDocument; | ||
import io.leangen.graphql.annotations.types.GraphQLType; | ||
import java.lang.String; | ||
import java.util.List; | ||
|
||
/** | ||
* This file is automatically generated on compile. | ||
* | ||
* Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
*/ | ||
@GraphQLType( | ||
name = "PersonPositionOrganization" | ||
) | ||
@JsonInclude(NON_EMPTY) | ||
public class PositionOrganization extends AbstractNestedDocument { | ||
private static final long serialVersionUID = -913043057L; | ||
|
||
private String label; | ||
|
||
private List<PositionOrganizationParent> parent; | ||
|
||
public PositionOrganization() { | ||
super(); | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
public List<PositionOrganizationParent> getParent() { | ||
return parent; | ||
} | ||
|
||
public void setParent(List<PositionOrganizationParent> parent) { | ||
this.parent = parent; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...in/java/edu/tamu/scholars/middleware/graphql/model/person/PositionOrganizationParent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package edu.tamu.scholars.middleware.graphql.model.person; | ||
|
||
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import edu.tamu.scholars.middleware.graphql.model.AbstractNestedDocument; | ||
import io.leangen.graphql.annotations.types.GraphQLType; | ||
import java.lang.String; | ||
|
||
/** | ||
* This file is automatically generated on compile. | ||
* | ||
* Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
*/ | ||
@GraphQLType( | ||
name = "PersonPositionOrganizationParent" | ||
) | ||
@JsonInclude(NON_EMPTY) | ||
public class PositionOrganizationParent extends AbstractNestedDocument { | ||
private static final long serialVersionUID = -1355915495L; | ||
|
||
private String label; | ||
|
||
public PositionOrganizationParent() { | ||
super(); | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters