Skip to content

Commit

Permalink
Merge pull request #259 from ybroeker/feat/transformation
Browse files Browse the repository at this point in the history
Refactor transformation
  • Loading branch information
phillip-kruger authored May 28, 2020
2 parents 9c27af6 + ae6df5e commit 3ac5c98
Show file tree
Hide file tree
Showing 26 changed files with 295 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.smallrye.graphql.schema.ScanningContext;
import io.smallrye.graphql.schema.SchemaBuilderException;
import io.smallrye.graphql.schema.helper.Direction;
import io.smallrye.graphql.schema.helper.FormatHelper;
import io.smallrye.graphql.schema.helper.TypeNameHelper;
import io.smallrye.graphql.schema.model.Reference;
import io.smallrye.graphql.schema.model.ReferenceType;
Expand Down Expand Up @@ -189,6 +190,9 @@ private Reference getReference(Direction direction,
return Scalars.getIDScalar(fieldTypeName);
} else if (Scalars.isScalar(fieldTypeName)) {
// Scalar
if (FormatHelper.hasAnyFormatting(annotations)) {
return Scalars.getFormattedScalar(fieldTypeName);
}
return Scalars.getScalar(fieldTypeName);
} else if (fieldType.kind().equals(Type.Kind.ARRAY)) {
// Array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ public class FormatHelper {
private FormatHelper() {
}

/**
* Tests, if any formatting is present.
*
* @param annotations the annotations
* @return if formatting is present
*/
public static boolean hasAnyFormatting(Annotations annotations) {
return getDateFormat(annotations).isPresent()
|| getNumberFormat(annotations).isPresent();
}

/**
* Get the format model object for a certain type.
*
Expand Down
1 change: 1 addition & 0 deletions common/schema-model/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ A Reference contains:
- the classname
- the graphql name
- the reference type
- a classname, into which the referenced class can be converted, which is understood by graphql. Used for transformations.

=== Reference Type

Expand Down
Binary file modified common/schema-model/classdiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion common/schema-model/classdiagram.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<mxfile host="www.draw.io" modified="2020-05-11T20:13:09.472Z" agent="5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" etag="z_VCSTGcYXryRwr32Qwn" version="13.1.0" type="device"><diagram id="Q51CJkZVq1hCxGUKNIIE" name="Page-1">7Z1dc5s4F4B/TS6zwzf4Mk6TvtlJ0m6S7W73ZkfBsk2KkRfkJM6vfwVINggJ2wWB09DJTC358GH06OjonCNxYp4vXj/HYDm/QRMYnhja5PXE/HRiGLruOeS/tGad17iGlVfM4mBChbYV98EbpJUarV0FE5iUBDFCIQ6W5UofRRH0cakOxDF6KYtNUVi+6hLMYKXi3gdhtfavYILn7Hdp2vaL/8FgNqeX9mz6xQIwYVqRzMEEvRSqzIsT8zxGCOefFq/nMEwfHnsu+XGXkm83NxbDCO9zwIU9/uuPCanWvt8+mQ/nc2/1x6k1ojeH1+wXwwl5ALSIYjxHMxSB8GJbO47RKprA9LQaKW1lrhFakkqdVD5BjNe0NcEKI1I1x4uQflu9dfprErSKfVh3v5QeDOIZxDWC9ITpjylcgT6ZzxAtII7XRCCGIcDBc7m1AYVmtpHbHPoVBeSeDY0Cbut2fgjF27G08inyG6VHbVvnLI7BuiC2TAUS+XU2/YFdx+Mam5O3bLtOnnzI74CVCs9kW5UBdABM7JrvBSbWVY8GplE3MDlu+TquXg8TDzknrwimd6aZbOe4YHI60kwjm9NMox0wmXadvBqY9H7GOfga4L8Ln7+np/rNpqVPr/TMWWFNCxOQzLNrNsNRt/bmUR8pIfJQkFynDJJhmLUgeWYzeWbCqQWP9Y5uwWsJIme0L0NMufTMkMMxZNIRVcZERd7qhAm9Dya6UUZX/670m2SB75B+upprb29/a/6p7e7LkeEcBUcWr4t0t5YjXt40O+HIfB+6RciEs6/xbR8HEiY3AzOocpQhwctbO2ZsuuY0PMDtRnkZH015ee9NefGGkVVvGPHyHQ2C1ntWXvqeTDB/Vd9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pob5Q4nIverQZLNr0YrIY+eOjfapBZkYgtfqwyUVgXOXChhgvhZhotgUGKMUqDZZvvPsdgOb/JQnXmxf8B</diagram></mxfile>
<mxfile host="www.draw.io" modified="2020-05-16T15:47:28.200Z" agent="5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" etag="oyzQTpSnq5Qfe6gZwi56" version="13.1.2" type="device"><diagram id="Q51CJkZVq1hCxGUKNIIE" name="Page-1">7Z1dc5s4F4B/TS7zDt/gyzhN+nYnSdsk293uTUfBsk2KkRfkJM6vXwGSDULCuEbgNHQyU0s+fBg9Ojo650icmOeLl48xWM6v0QSGJ4Y2eTkxP5wYhq57DvkvrVnnNa5h5RWzOJhQoW3FXfAKaaVGa1fBBCYlQYxQiINludJHUQR9XKoDcYyey2JTFJavugQzWKm480FYrf0rmOA5+12atv3i/zCYzemlPZt+sQBMmFYkczBBz4Uq8+LEPI8Rwvmnxcs5DNOHx55Lftyl5NvNjcUwwk0OuLDHf32dkGrt+82jeX8+91ZfT60RvTm8Zr8YTsgDoEUU4zmaoQiEF9vacYxW0QSmp9VIaStzhdCSVOqk8hFivKatCVYYkao5XoT02+qt01+ToFXsw7r7pfRgEM8grhGkJ0x/TOEK9Ml8hGgBcbwmAjEMAQ6eyq0NKDSzjdzm0C8oIPdsaBRwW7fzQyjejqWVT5HfKD1q2zpncQzWBbFlKpDIr7PpD+w6HtfYnLxl23Xy5EN+B6xUeCbbqgygPWBi13wrMLGuejQwjbqByXHL13H1eph4yDl5RTC9Mc1kO8cFk9ORZhrZnGYa7YDJtOvk1cCk9zPOwZcA/134/D091f9sWvrwQs+cFda0MAHJPLvmYTjqVmMe9ZESIvcFyXXKIBmGWQuSZx4mz0w4teCx3tEteC1B5IyaMsSUS88MORxDJh1RZUxU5K1OmND7YKIbZfTpx0q/Thb4Fumnq7n2+vq35p/ablOODOcoOLJ4XaS7tRzx8qbZCUfm29AtQiacpsa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P4T41ODTNCVKHQzUh5FNEBsYp6Hky9hsPEh7/hiFdMCUXJqZqql6+YA9pIQpHibeXqbrZgK0CRMC0QzU3pJhqOowXSsDof7yQ7paQGgpVJgb7QSkPIgd/pzxYVT0xmA1qzAadfz2X17Dx1eUFSPdHH8yGw82GTdd6O2aDJdszY7Aa2hsl9ueid6vBkk0vBquhDx76txpkViRiC2KrTBTWyg5cqOFCmBvQEhikGKM0WLb57mOaA3KdherMi/8A</diagram></mxfile>
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,32 @@
* @author Phillip Kruger ([email protected])
*/
public class Reference implements Serializable {
private String graphQlClassName;
private String className;
private String name;
private ReferenceType type;

public Reference() {
}

public Reference(String javaName, String name, ReferenceType type) {
public Reference(String javaName, String name, ReferenceType type, String graphQlClassName) {
this.className = javaName;
this.name = name;
this.type = type;
this.graphQlClassName = graphQlClassName;
}

public Reference(String javaName, String name, ReferenceType type) {
this(javaName, name, type, javaName);
}

public Reference(final Reference reference) {
this.className = reference.className;
this.name = reference.name;
this.type = reference.type;
this(reference.className, reference.name, reference.type, reference.graphQlClassName);
}

/**
* This represent the Java Class Name
*
*
* @return String full class name
*/
public String getClassName() {
Expand All @@ -57,7 +61,7 @@ public void setName(String name) {

/**
* This represent the GraphQL Type
*
*
* @return
*/
public ReferenceType getType() {
Expand All @@ -67,4 +71,18 @@ public ReferenceType getType() {
public void setType(ReferenceType type) {
this.type = type;
}

/**
* The class into which this reference can be converted, which can be handled by graphql
*
* For example, String for Dates or formatted Numbers, BigInteger for long and BigInteger.
*
* Used for transforming.
*
* @return full class name
*/
public String getGraphQlClassName() {
return graphQlClassName;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
public class Scalars {
private static final Map<String, Reference> scalarMap = new HashMap<>();
private static final Map<String, Reference> formattedScalarMap = new HashMap<>();
private static final String STRING = "String";
private static final String BOOLEAN = "Boolean";
private static final String INTEGER = "Int";
Expand All @@ -50,61 +51,70 @@ public static Reference getScalar(String className) {
return scalarMap.get(className);
}

public static Reference getFormattedScalar(String className) {
return formattedScalarMap.get(className);
}

public static Reference getIDScalar(String className) {
return new Reference(className, "ID", ReferenceType.SCALAR);
return new Reference(className, "ID", ReferenceType.SCALAR, className);
}

static {
populateScalar(char.class.getName(), STRING);
populateScalar(Character.class.getName(), STRING);
populateScalar(String.class.getName(), STRING);
populateScalar(UUID.class.getName(), STRING);
populateScalar(char.class.getName(), STRING, String.class.getName());
populateScalar(Character.class.getName(), STRING, String.class.getName());
populateScalar(String.class.getName(), STRING, String.class.getName());
populateScalar(UUID.class.getName(), STRING, String.class.getName());

populateScalar(URL.class.getName(), STRING);
populateScalar(URI.class.getName(), STRING);
populateScalar(URL.class.getName(), STRING, String.class.getName());
populateScalar(URI.class.getName(), STRING, String.class.getName());

populateScalar(Boolean.class.getName(), BOOLEAN);
populateScalar(boolean.class.getName(), BOOLEAN);

populateScalar(Integer.class.getName(), INTEGER);
populateScalar(int.class.getName(), INTEGER);
populateScalar(Short.class.getName(), INTEGER);
populateScalar(short.class.getName(), INTEGER);
populateScalar(Byte.class.getName(), INTEGER);
populateScalar(byte.class.getName(), INTEGER);

populateScalar(Float.class.getName(), FLOAT);
populateScalar(float.class.getName(), FLOAT);
populateScalar(Double.class.getName(), FLOAT);
populateScalar(double.class.getName(), FLOAT);
populateScalar(Integer.class.getName(), INTEGER, Integer.class.getName());
populateScalar(int.class.getName(), INTEGER, Integer.class.getName());
populateScalar(Short.class.getName(), INTEGER, Integer.class.getName());
populateScalar(short.class.getName(), INTEGER, Integer.class.getName());
populateScalar(Byte.class.getName(), INTEGER, Integer.class.getName());
populateScalar(byte.class.getName(), INTEGER, Integer.class.getName());

populateScalar(BigInteger.class.getName(), BIGINTEGER);
populateScalar(Long.class.getName(), BIGINTEGER);
populateScalar(long.class.getName(), BIGINTEGER);
populateScalar(Float.class.getName(), FLOAT, Float.class.getName());
populateScalar(float.class.getName(), FLOAT, Float.class.getName());
populateScalar(Double.class.getName(), FLOAT, Float.class.getName());
populateScalar(double.class.getName(), FLOAT, Float.class.getName());

populateScalar(BigDecimal.class.getName(), BIGDECIMAL);
populateScalar(BigInteger.class.getName(), BIGINTEGER, BigInteger.class.getName());
populateScalar(Long.class.getName(), BIGINTEGER, BigInteger.class.getName());
populateScalar(long.class.getName(), BIGINTEGER, BigInteger.class.getName());

populateScalar(LocalDate.class.getName(), DATE);
populateScalar(Date.class.getName(), DATE);
populateScalar(BigDecimal.class.getName(), BIGDECIMAL, BigDecimal.class.getName());

populateScalar(LocalTime.class.getName(), TIME);
populateScalar(Time.class.getName(), TIME);
populateScalar(OffsetTime.class.getName(), TIME);
populateScalar(LocalDate.class.getName(), DATE, String.class.getName());
populateScalar(Date.class.getName(), DATE, String.class.getName());

populateScalar(LocalDateTime.class.getName(), DATETIME);
populateScalar(java.util.Date.class.getName(), DATETIME);
populateScalar(Timestamp.class.getName(), DATETIME);
populateScalar(ZonedDateTime.class.getName(), DATETIME);
populateScalar(OffsetDateTime.class.getName(), DATETIME);
populateScalar(LocalTime.class.getName(), TIME, String.class.getName());
populateScalar(Time.class.getName(), TIME, String.class.getName());
populateScalar(OffsetTime.class.getName(), TIME, String.class.getName());

populateScalar(Duration.class.getName(), DURATION);
populateScalar(Period.class.getName(), PERIOD);
populateScalar(LocalDateTime.class.getName(), DATETIME, String.class.getName());
populateScalar(java.util.Date.class.getName(), DATETIME, String.class.getName());
populateScalar(Timestamp.class.getName(), DATETIME, String.class.getName());
populateScalar(ZonedDateTime.class.getName(), DATETIME, String.class.getName());
populateScalar(OffsetDateTime.class.getName(), DATETIME, String.class.getName());

populateScalar(ID, ID);
populateScalar(Duration.class.getName(), DURATION, String.class.getName());
populateScalar(Period.class.getName(), PERIOD, String.class.getName());
}

private static void populateScalar(String className, String scalarName) {
scalarMap.put(className, new Reference(className, scalarName, ReferenceType.SCALAR));
populateScalar(className, scalarName, className);
}

private static void populateScalar(String className, String scalarName, String externalClassName) {
scalarMap.put(className, new Reference(className, scalarName, ReferenceType.SCALAR, externalClassName));

//Currently, each scalar is formatted as String
formattedScalarMap.put(className, new Reference(className, STRING, ReferenceType.SCALAR, String.class.getName()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void testSchemaModelCreation() throws IOException {

// Test default value
Assert.assertTrue("Problem with Default value in mutation operation argument",
lines.contains("updateItemPowerLevel(itemID: BigInteger!, powerLevel: Int = \"5\"): Item"));
lines.contains("updateItemPowerLevel(itemID: BigInteger!, powerLevel: Int = 5): Item"));

Assert.assertTrue("Problem with Default value in query operation argument",
lines.contains("allHeroesIn(city: String = \"New York, NY\"): [SuperHero]"));
Expand Down
7 changes: 7 additions & 0 deletions server/implementation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Loading

0 comments on commit 3ac5c98

Please sign in to comment.