use of com.mysema.codegen.model.SimpleType in project querydsl by querydsl.
the class SpatialSupport method registerTypes.
private static void registerTypes(TypeMappings typeMappings) {
Map<String, String> additions = Maps.newHashMap();
additions.put("Geometry", "GeometryPath");
additions.put("GeometryCollection", "GeometryCollectionPath");
additions.put("LinearRing", "LinearRingPath");
additions.put("LineString", "LineStringPath");
additions.put("MultiLineString", "MultiLineStringPath");
additions.put("MultiPoint", "MultiPointPath");
additions.put("MultiPolygon", "MultiPolygonPath");
additions.put("Point", "PointPath");
additions.put("Polygon", "PolygonPath");
additions.put("PolyHedralSurface", "PolyhedralSurfacePath");
for (Map.Entry<String, String> entry : additions.entrySet()) {
typeMappings.register(new SimpleType("org.geolatte.geom." + entry.getKey()), new SimpleType("com.querydsl.spatial." + entry.getValue()));
}
}
use of com.mysema.codegen.model.SimpleType in project querydsl by querydsl.
the class SpatialSupport method registerJTSTypes.
private static void registerJTSTypes(TypeMappings typeMappings) {
Map<String, String> additions = Maps.newHashMap();
additions.put("Geometry", "JTSGeometryPath");
additions.put("GeometryCollection", "JTSGeometryCollectionPath");
additions.put("LinearRing", "JTSLinearRingPath");
additions.put("LineString", "JTSLineStringPath");
additions.put("MultiLineString", "JTSMultiLineStringPath");
additions.put("MultiPoint", "JTSMultiPointPath");
additions.put("MultiPolygon", "JTSMultiPolygonPath");
additions.put("Point", "JTSPointPath");
additions.put("Polygon", "JTSPolygonPath");
for (Map.Entry<String, String> entry : additions.entrySet()) {
typeMappings.register(new SimpleType("com.vividsolutions.jts.geom." + entry.getKey()), new SimpleType("com.querydsl.spatial.jts." + entry.getValue()));
}
}
use of com.mysema.codegen.model.SimpleType in project querydsl by querydsl.
the class CustomTypeTest method customType.
@Test
public void customType() throws IOException {
SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity", false, false);
EntityType entityType = new EntityType(type);
entityType.addProperty(new Property(entityType, "property", new ClassType(Double[].class)));
typeMappings.register(new ClassType(Double[].class), new ClassType(Point.class));
typeMappings.register(entityType, queryTypeFactory.create(entityType));
assertTrue(typeMappings.isRegistered(entityType.getProperties().iterator().next().getType()));
serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
assertTrue(writer.toString().contains("public final com.querydsl.codegen.Point property = " + "new com.querydsl.codegen.Point(forProperty(\"property\"));"));
}
use of com.mysema.codegen.model.SimpleType in project querydsl by querydsl.
the class PropertyTest method equals_and_hashCode.
@Test
public void equals_and_hashCode() {
Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.querydsl.DomainClass", "com.querydsl", "DomainClass", false, false);
EntityType type = new EntityType(typeModel);
Property p1 = new Property(type, "property", type, Collections.<String>emptyList());
Property p2 = new Property(type, "property", type, Collections.<String>emptyList());
assertEquals(p1, p1);
assertEquals(p1, p2);
assertEquals(p1.hashCode(), p2.hashCode());
}
use of com.mysema.codegen.model.SimpleType in project querydsl by querydsl.
the class JPADomainExporter method handleProperty.
private void handleProperty(EntityType entityType, Class<?> cl, Attribute<?, ?> p) throws NoSuchMethodException, ClassNotFoundException {
Class<?> clazz = Object.class;
try {
clazz = p.getJavaType();
} catch (MappingException e) {
// ignore
}
Type propertyType = getType(cl, clazz, p.getName());
AnnotatedElement annotated = getAnnotatedElement(cl, p.getName());
propertyType = getTypeOverride(propertyType, annotated);
if (propertyType == null) {
return;
}
if (p.isCollection()) {
if (p instanceof MapAttribute) {
MapAttribute<?, ?, ?> map = (MapAttribute<?, ?, ?>) p;
Type keyType = typeFactory.get(map.getKeyJavaType());
Type valueType = typeFactory.get(map.getElementType().getJavaType());
valueType = getPropertyType(p, valueType);
propertyType = new SimpleType(propertyType, normalize(propertyType.getParameters().get(0), keyType), normalize(propertyType.getParameters().get(1), valueType));
} else {
Type valueType = typeFactory.get(((PluralAttribute<?, ?, ?>) p).getElementType().getJavaType());
valueType = getPropertyType(p, valueType);
propertyType = new SimpleType(propertyType, normalize(propertyType.getParameters().get(0), valueType));
}
} else {
propertyType = getPropertyType(p, propertyType);
}
Property property = createProperty(entityType, p.getName(), propertyType, annotated);
entityType.addProperty(property);
}
Aggregations