use of com.manydesigns.elements.reflection.PropertyAccessor in project Portofino by ManyDesigns.
the class TableFormBuilder method configFields.
// **************************************************************************
// Builder configuration
// **************************************************************************
public TableFormBuilder configFields(String... fieldNames) {
propertyAccessors = new ArrayList<PropertyAccessor>();
for (String currentField : fieldNames) {
try {
PropertyAccessor accessor = classAccessor.getProperty(currentField);
propertyAccessors.add(accessor);
} catch (NoSuchFieldException e) {
logger.warn("Field not found: {}", currentField);
}
}
return this;
}
use of com.manydesigns.elements.reflection.PropertyAccessor in project Portofino by ManyDesigns.
the class ReflectionUtil method classAccessorToJson.
public static JSONWriter classAccessorToJson(ClassAccessor accessor, JSONStringer js) {
js.object();
js.key("name").value(accessor.getName());
js.key("keyProperties").array();
for (PropertyAccessor p : accessor.getKeyProperties()) {
js.value(p.getName());
}
js.endArray();
js.key("properties").array();
for (PropertyAccessor p : accessor.getProperties()) {
propertyAccessorToJson(js, p);
}
js.endArray();
js.key("annotations").array();
for (Annotation ann : accessor.getAnnotations()) {
annotationToJson(js, ann);
}
js.endArray();
return js.endObject();
}
use of com.manydesigns.elements.reflection.PropertyAccessor in project Portofino by ManyDesigns.
the class ClassAccessorDecorator method init.
private void init(ClassAccessor delegate, ClassAccessor decoratorAccessor, Object decorator) {
int p = 0, k = 0;
for (PropertyAccessor accessor : delegate.getProperties()) {
try {
PropertyAccessor decoratingProperty = decoratorAccessor.getProperty(accessor.getName());
PropertyAccessorDecorator propertyAccessorDecorator = new PropertyAccessorDecorator(accessor, decoratingProperty);
properties[p] = propertyAccessorDecorator;
if (decoratingProperty.getType().isAssignableFrom(PropertyAccessor.class) && decorator != null) {
decoratingProperty.set(decorator, propertyAccessorDecorator);
}
} catch (NoSuchFieldException e) {
properties[p] = accessor;
}
if (ArrayUtils.contains(delegate.getKeyProperties(), accessor)) {
keyProperties[k++] = properties[p];
}
p++;
}
for (Annotation annotation : delegate.getAnnotations()) {
this.annotations.put(annotation.annotationType(), annotation);
}
for (Annotation annotation : decoratorAccessor.getAnnotations()) {
this.annotations.put(annotation.annotationType(), annotation);
}
}
use of com.manydesigns.elements.reflection.PropertyAccessor in project Portofino by ManyDesigns.
the class AbstractCrudAction method configureDetailLink.
protected void configureDetailLink(TableFormBuilder tableFormBuilder) {
boolean isShowingKey = false;
for (PropertyAccessor property : classAccessor.getKeyProperties()) {
if (tableFormBuilder.getPropertyAccessors().contains(property) && tableFormBuilder.isPropertyVisible(property)) {
isShowingKey = true;
break;
}
}
OgnlTextFormat hrefFormat = getReadURLFormat();
if (isShowingKey) {
logger.debug("TableForm: configuring detail links for primary key properties");
for (PropertyAccessor property : classAccessor.getKeyProperties()) {
tableFormBuilder.configHrefTextFormat(property.getName(), hrefFormat);
}
} else {
logger.debug("TableForm: configuring detail link for the first visible property");
for (PropertyAccessor property : classAccessor.getProperties()) {
if (tableFormBuilder.getPropertyAccessors().contains(property) && tableFormBuilder.isPropertyVisible(property)) {
tableFormBuilder.configHrefTextFormat(property.getName(), hrefFormat);
break;
}
}
}
}
use of com.manydesigns.elements.reflection.PropertyAccessor in project Portofino by ManyDesigns.
the class ManyToManyAction method loadOnePk.
protected void loadOnePk(Object key) throws Exception {
TableAccessor tableAccessor = new TableAccessor(m2mConfiguration.getActualRelationTable());
PropertyAccessor onePkAccessor = tableAccessor.getProperty(m2mConfiguration.getActualOnePropertyName());
if (onePkAccessor == null) {
logger.error("Not a property: {}", m2mConfiguration.getActualOnePropertyName());
return;
}
Class type = onePkAccessor.getType();
onePk = OgnlUtils.convertValue(key, type);
}
Aggregations