private Object convertToEntity(Object entityOrView) { if (entityOrView instanceof BasicDirtyTracker) { EntityViewProxy view = (EntityViewProxy) entityOrView; return evm.getEntityReference(em, view); } return entityOrView; } }
@EntityView(StorageQuotaPlan.class) public abstract class StorageQuotaPlanView { @JsonIgnore @IdMapping("id") public abstract StorageQuotaPlanId getId(); @Mapping("gigabyteLimit") public Integer getGigabyteLimit() { return getId().getGigabyteLimit(); } @Mapping("alertPercent") public abstract Short getAlertPercent(); }
public EntityViewRepositoryImpl(JpaEntityInformation<E, ?> entityInformation, EntityManager entityManager, CriteriaBuilderFactory cbf, EntityViewManager evm, Class<V> entityViewClass) { this.entityInformation = entityInformation; this.entityManager = entityManager; this.cbf = cbf; this.evm = evm; this.setting = EntityViewSetting.create(entityViewClass); this.entityViewClass = entityViewClass; }
/** * Adds the attribute's default attribute filter to the attribute filters of this setting * or overwrites the filter value of an existing default attribute filter. * * @param attributeName The name of the attribute filter * @param filterValue The filter value for the attribute filter */ public void addAttributeFilter(String attributeName, Object filterValue) { checkExistingFiltersForAttribute(attributeName, AttributeFilter.DEFAULT_NAME); this.attributeFilters.put(attributeName, new AttributeFilterActivation(filterValue)); }
/** * Creates a copy of <code>this</code> {@linkplain EntityViewSetting} for the given entity view subtype. * * @param subtype The entity view subtype * @param <X> Entity view subtype * @param <Y> The query builder type * @return A copy for the given subtype */ public <X extends T, Y extends FullQueryBuilder<X, Y>> EntityViewSetting<X, Y> forSubtype(Class<X> subtype) { return new EntityViewSetting<>(this, subtype); }
/** * Enables and adds the view filter with the given name in this setting. * * @param filterName The name of the view filter * @return <code>this</code> for method chaining * @since 1.3.0 */ public EntityViewSetting<T, Q> withViewFilter(String filterName) { addViewFilter(filterName); return this; }
@SuppressWarnings("unchecked") public static <T> Class<Comparator<T>> getComparatorClass(CollectionMapping mapping) { if (Comparator.class == mapping.comparator()) { return null; } return (Class<Comparator<T>>) mapping.comparator(); }
/** * Set a entity view property or hint. * If a property or hint is not recognized, it is silently ignored. * @param propertyName name of property or hint * @param value value for property or hint * @return <code>this</code> for method chaining * @since 1.3.0 */ public EntityViewSetting<T, Q> withProperty(String propertyName, Object value) { setProperty(propertyName, value); return this; }
@EntityView(Car.class) public interface CarView { public String getName(); public String getColor(); }
/** * Like {@link EntityViewSetting#create(java.lang.Class, java.lang.String)} but with the <code>viewConstructorname</code> set to null. * * @param entityViewClass The entity view class that should be used for the object builder * @param <T> The type of the entity view * @return A new entity view setting */ public static <T> EntityViewSetting<T, CriteriaBuilder<T>> create(Class<T> entityViewClass) { return new EntityViewSetting<T, CriteriaBuilder<T>>(entityViewClass, 0, Integer.MAX_VALUE, false, null); }
private Object convertToEntity(Object entityOrView) { if (entityOrView instanceof BasicDirtyTracker) { EntityViewProxy view = (EntityViewProxy) entityOrView; return evm.getEntityReference(em, view); } return entityOrView; } }
/** * @author Christian Beikov * @since 1.2.0 */ @EntityView(Person.class) public interface PersonSimpleView { @IdMapping Long getId(); String getName(); }
/** * Like {@link EntityViewSetting#create(java.lang.Class, int, int, java.lang.String)} but with the <code>viewConstructorname</code> set to null. * * @param entityViewClass The entity view class that should be used for the object builder * @param firstResult The position of the first result to retrieve, numbered from 0 * @param maxResults The maximum number of results to retrieve * @param <T> The type of the entity view * @return A new entity view setting */ public static <T> EntityViewSetting<T, PaginatedCriteriaBuilder<T>> create(Class<T> entityViewClass, int firstResult, int maxResults) { return new EntityViewSetting<T, PaginatedCriteriaBuilder<T>>(entityViewClass, firstResult, maxResults, true, null); }
/** * @author Christian Beikov * @since 1.2.0 */ @EntityView(Cat.class) public interface CatSimpleView { @IdMapping Long getId(); String getName(); }
/** * @author Christian Beikov * @since 1.2.0 */ @EntityView(Cat.class) public interface CatWithOwnerView extends CatSimpleView { PersonSimpleView getOwner(); }
@EntityView(Bucket.class) public interface BucketContentView extends IdHolderView<String> { @CollectionMapping(ignoreIndex = true) public List<BucketObjectView> getObjects(); }
@EntityView(BucketObject.class) public interface BucketObjectRepresentationView { @IdMapping("id") public BucketObjectId getId(); @Mapping("bucket.owner.id") public Long getOwnerId(); public BucketObjectVersionRepresentationView getContentVersion(); }
@EntityView(StorageQuotaPlan.class) public abstract class StorageQuotaPlanChoiceRepresentationView extends StorageQuotaPlanChoiceRepresentation { private static final long serialVersionUID = 1L; public StorageQuotaPlanChoiceRepresentationView( @Mapping("id") StorageQuotaPlanId id) { super(id.getQuotaModelId(), id.getGigabyteLimit()); } @JsonIgnore @IdMapping("id") public abstract StorageQuotaPlanId getId(); }