List of usage examples for org.springframework.data.mapping PersistentProperty getType
Class<?> getType();
From source file:org.lightadmin.core.persistence.metamodel.PersistentPropertyType.java
public static boolean isOfBinaryFileType(PersistentProperty persistentProperty) { return forType(persistentProperty.getType()) == FILE; }
From source file:org.lightadmin.core.persistence.metamodel.PersistentPropertyType.java
public static boolean isOfFileReferenceType(PersistentProperty persistentProperty) { if (forType(persistentProperty.getType()) == STRING && persistentProperty.isAnnotationPresent(FileReference.class)) { return true; }//from w w w . ja v a 2 s . com return false; }
From source file:org.lightadmin.core.persistence.metamodel.PersistentPropertyType.java
private static boolean isOfTimeType(PersistentProperty persistentProperty) { Class attrType = persistentProperty.getType(); if (java.sql.Time.class.equals(attrType)) { return true; }//from w w w . j a v a 2 s .c om if (LocalTime.class.equals(attrType)) { return true; } if (Date.class.equals(attrType) || Calendar.class.equals(attrType)) { return hasTemporalType(persistentProperty, TemporalType.TIME); } return false; }
From source file:org.lightadmin.core.persistence.metamodel.PersistentPropertyType.java
private static boolean isOfDateType(PersistentProperty persistentProperty) { Class<?> attrType = persistentProperty.getType(); if (java.sql.Date.class.equals(attrType)) { return true; }/*from w ww. jav a 2 s. co m*/ if (LocalDate.class.equals(attrType)) { return true; } if (Date.class.equals(attrType) || Calendar.class.equals(attrType)) { return hasTemporalType(persistentProperty, TemporalType.DATE); } return false; }
From source file:org.lightadmin.core.persistence.metamodel.PersistentPropertyType.java
private static boolean isOfDateTimeType(PersistentProperty persistentProperty) { Class<?> attrType = persistentProperty.getType(); if (Timestamp.class.equals(attrType)) { return true; }//from w w w .j a va2 s . c o m if (DateTime.class.equals(attrType) || LocalDateTime.class.equals(attrType)) { return true; } if (Date.class.equals(attrType) || Calendar.class.equals(attrType)) { return hasTemporalType(persistentProperty, TemporalType.TIMESTAMP); } return false; }
From source file:org.lightadmin.core.persistence.metamodel.PersistentPropertyType.java
public static PersistentPropertyType forPersistentProperty(PersistentProperty persistentProperty) { final Class<?> attrType = persistentProperty.getType(); if (persistentProperty.isAnnotationPresent(Embedded.class) || persistentProperty.isAnnotationPresent(EmbeddedId.class)) { return PersistentPropertyType.EMBEDDED; }//from www . j a va2 s . c o m if (persistentProperty.isAssociation()) { if (persistentProperty.isCollectionLike()) { return PersistentPropertyType.ASSOC_MULTI; } return PersistentPropertyType.ASSOC; } if (persistentProperty.isMap()) { return PersistentPropertyType.MAP; } if (ClassUtils.isAssignable(Enum.class, attrType)) { return ENUM; } if (forType(attrType) == STRING && persistentProperty.isAnnotationPresent(FileReference.class)) { return PersistentPropertyType.FILE; } if (isOfDateType(persistentProperty)) { return DATE; } if (isOfTimeType(persistentProperty)) { return TIME; } if (isOfDateTimeType(persistentProperty)) { return DATE_TIME; } return forType(attrType); }
From source file:com.turbospaces.model.BO.java
/** * register the set of persistent classes and enrich kryo with some extract serialized related to persistent class. * //from w w w . j a v a2 s.co m * @param kryo * serialization provider * @param persistentEntities * classes to register * @throws ClassNotFoundException * re-throw conversion service * @throws NoSuchMethodException * re-throw cglib's exception * @throws SecurityException * re-throw cglib's exception * @throws IntrospectionException * re-throw introspection exception */ public static void registerPersistentClasses(final DecoratedKryo kryo, final BasicPersistentEntity... persistentEntities) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IntrospectionException { for (BasicPersistentEntity<?, ?> e : persistentEntities) { BO bo = new BO(e); bo.getOriginalPersistentEntity().doWithProperties(new PropertyHandler() { @Override public void doWithPersistentProperty(final PersistentProperty p) { Class type = p.getType(); if (type.isArray() && !kryo.isTypeRegistered(type)) { SingleDimensionArraySerializer serializer = new SingleDimensionArraySerializer(type, kryo); kryo.register(type, serializer); } else if (type.isEnum() && !kryo.isTypeRegistered(type)) { EnumSerializer enumSerializer = new EnumSerializer(type); kryo.register(type, enumSerializer); } } }); Class<?> arrayWrapperType = Class.forName("[L" + e.getType().getName() + ";"); PropertiesSerializer serializer = new PropertiesSerializer(kryo, bo); SingleDimensionArraySerializer arraysSerializer = new SingleDimensionArraySerializer(arrayWrapperType, kryo); kryo.register(e.getType(), serializer); kryo.register(arrayWrapperType, arraysSerializer); } }
From source file:com.expedia.seiso.web.assembler.ItemAssociationHandler.java
@Override public void doWithAssociation(Association<? extends PersistentProperty<?>> assoc) { val item = wrapper.getBean(); // val doesn't work here for some reason. PersistentProperty<?> prop = assoc.getInverse(); val propName = prop.getName(); val propType = prop.getType(); val child = projection.getChild(propName); // Link// w w w .j a v a 2s .co m if (topLevel) { val restResource = prop.findAnnotation(RestResource.class); val path = (restResource == null ? propName : restResource.path()); resource.addLink(itemLinks.itemPropertyLink(item, path)); } // Property if (child != null) { if (Item.class.isAssignableFrom(propType)) { val propEntity = (Item) wrapper.getProperty(prop); val propResource = assembler.toResource(apiVersion, propEntity, child, false); resource.setAssociation(propName, propResource); } else if (List.class.isAssignableFrom(propType)) { val propEntityList = (List<?>) wrapper.getProperty(prop); val propResourceList = assembler.toResourceList(apiVersion, propEntityList, child); resource.setAssociation(propName, propResourceList); } else { log.warn("Don't know how to handle association type {}", propType); } } }
From source file:com.turbospaces.serialization.PropertiesSerializer.java
/** * create new properties serialized with the provided entity meta-data information. * /*from w w w . j a va 2 s . co m*/ * @param kryo * kryo serialization provider * @param entityMetadata * class meta data provider */ public PropertiesSerializer(final DecoratedKryo kryo, final BO entityMetadata) { super(kryo, new ArrayList<CachedSerializationProperty>(entityMetadata.getOrderedProperties().length) { private static final long serialVersionUID = 1L; { PersistentProperty[] orderedProperties = entityMetadata.getOrderedProperties(); for (PersistentProperty orderedProperty : orderedProperties) add(new CachedSerializationProperty(orderedProperty.getType(), orderedProperty.getField())); } }.toArray(new CachedSerializationProperty[entityMetadata.getOrderedProperties().length])); this.entityMetadata = entityMetadata; }