All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.loom.simpleds.RetrieveEntityAnnotationProcessor Maven / Gradle / Ivy

The newest version!
package org.loom.simpleds;

import javax.inject.Inject;

import org.loom.annotation.RetrieveEntities;
import org.loom.annotation.RetrieveEntity;
import org.loom.annotation.processor.AbstractPropertyAnnotationProcessor;
import org.loom.interceptor.RetrieveEntityInterceptor;
import org.loom.mapping.Event;
import org.simpleds.EntityManager;

public class RetrieveEntityAnnotationProcessor  extends AbstractPropertyAnnotationProcessor {

	@Inject
	private EntityManager entityManager;
	
	public RetrieveEntityAnnotationProcessor() {
		super(RetrieveEntity.class, RetrieveEntities.class);
	}

	@Override
	protected void process(Event event, RetrieveEntity annotation, String propertyPath) {
		RetrieveEntityInterceptor interceptor = createRetrieveEntityInterceptor();
		interceptor.setReadOnly(annotation.readOnly());
		if (annotation.idPropertyName().length() > 0) {
			interceptor.setIdPropertyName(annotation.idPropertyName());
		}
		interceptor.setPropertyPath(propertyPath);
		interceptor.setPropertyClass(event.getPropertyClass(propertyPath));
		event.addInterceptor(interceptor);
	}

	private RetrieveEntityInterceptor createRetrieveEntityInterceptor() {
		SimpledsRetrieveEntityInterceptor interceptor = new SimpledsRetrieveEntityInterceptor();
		interceptor.setEntityManager(entityManager);
		return interceptor;
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy